Skip to content

Commit

Permalink
Merge pull request ppy#18221 from peppy/multiplayer-leaderboard-hiding
Browse files Browse the repository at this point in the history
Change multiplayer leaderboard to always hide during gameplay unless holding-for-HUD
  • Loading branch information
smoogipoo authored May 11, 2022
2 parents 55b9d66 + d05cd69 commit 52c8382
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
12 changes: 10 additions & 2 deletions osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class MultiplayerPlayer : RoomSubmittingPlayer

private readonly MultiplayerRoomUser[] users;

private readonly Bindable<bool> leaderboardExpanded = new BindableBool();

private LoadingLayer loadingDisplay;
private FillFlowContainer leaderboardFlow;

Expand Down Expand Up @@ -76,13 +78,16 @@ private void load()
Spacing = new Vector2(5)
});

HUDOverlay.HoldingForHUD.BindValueChanged(_ => updateLeaderboardExpandedState());
LocalUserPlaying.BindValueChanged(_ => updateLeaderboardExpandedState(), true);

// todo: this should be implemented via a custom HUD implementation, and correctly masked to the main content area.
LoadComponentAsync(leaderboard = new MultiplayerGameplayLeaderboard(GameplayState.Ruleset.RulesetInfo, ScoreProcessor, users), l =>
{
if (!LoadedBeatmapSuccessfully)
return;

((IBindable<bool>)leaderboard.Expanded).BindTo(HUDOverlay.ShowHud);
leaderboard.Expanded.BindTo(leaderboardExpanded);

leaderboardFlow.Insert(0, l);

Expand All @@ -99,7 +104,7 @@ private void load()

LoadComponentAsync(new GameplayChatDisplay(Room)
{
Expanded = { BindTarget = HUDOverlay.ShowHud },
Expanded = { BindTarget = leaderboardExpanded },
}, chat => leaderboardFlow.Insert(2, chat));

HUDOverlay.Add(loadingDisplay = new LoadingLayer(true) { Depth = float.MaxValue });
Expand Down Expand Up @@ -152,6 +157,9 @@ protected override void StartGameplay()
}
}

private void updateLeaderboardExpandedState() =>
leaderboardExpanded.Value = !LocalUserPlaying.Value || HUDOverlay.HoldingForHUD.Value;

private void failAndBail(string message = null)
{
if (!string.IsNullOrEmpty(message))
Expand Down
16 changes: 9 additions & 7 deletions osu.Game/Screens/Play/HUDOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public class HUDOverlay : Container, IKeyBindingHandler<GlobalAction>

internal readonly IBindable<bool> IsPlaying = new Bindable<bool>();

private bool holdingForHUD;
public IBindable<bool> HoldingForHUD => holdingForHUD;

private readonly BindableBool holdingForHUD = new BindableBool();

private readonly SkinnableTargetContainer mainComponents;

Expand Down Expand Up @@ -144,14 +146,16 @@ private void load(OsuConfigManager config, INotificationOverlay notificationOver
hideTargets.ForEach(d => d.Hide());
}

public override void Hide() => throw new InvalidOperationException($"{nameof(HUDOverlay)} should not be hidden as it will remove the ability of a user to quit. Use {nameof(ShowHud)} instead.");
public override void Hide() =>
throw new InvalidOperationException($"{nameof(HUDOverlay)} should not be hidden as it will remove the ability of a user to quit. Use {nameof(ShowHud)} instead.");

protected override void LoadComplete()
{
base.LoadComplete();

ShowHud.BindValueChanged(visible => hideTargets.ForEach(d => d.FadeTo(visible.NewValue ? 1 : 0, FADE_DURATION, FADE_EASING)));

holdingForHUD.BindValueChanged(_ => updateVisibility());
IsPlaying.BindValueChanged(_ => updateVisibility());
configVisibilityMode.BindValueChanged(_ => updateVisibility(), true);

Expand Down Expand Up @@ -204,7 +208,7 @@ private void updateVisibility()
if (ShowHud.Disabled)
return;

if (holdingForHUD)
if (holdingForHUD.Value)
{
ShowHud.Value = true;
return;
Expand Down Expand Up @@ -287,8 +291,7 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
switch (e.Action)
{
case GlobalAction.HoldForHUD:
holdingForHUD = true;
updateVisibility();
holdingForHUD.Value = true;
return true;

case GlobalAction.ToggleInGameInterface:
Expand Down Expand Up @@ -318,8 +321,7 @@ public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
switch (e.Action)
{
case GlobalAction.HoldForHUD:
holdingForHUD = false;
updateVisibility();
holdingForHUD.Value = false;
break;
}
}
Expand Down

0 comments on commit 52c8382

Please sign in to comment.