Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change multiplayer leaderboard to always hide during gameplay unless holding-for-HUD #18221

Merged
merged 2 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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