1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-17 16:13:33 +08:00

Fix gameplay leaderboard not always being expanded in gameplay leaderboard

I'd have preferred a `get; init;` property but tests were also attached
at the hip to the public bindable. Without some extra composition this
is the best that I can do.
This commit is contained in:
Bartłomiej Dach
2025-05-07 12:02:36 +02:00
Unverified
parent efc3e17630
commit 8cc2af4060
6 changed files with 10 additions and 9 deletions
@@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("toggle expanded", () =>
{
if (leaderboard.IsNotNull())
leaderboard.Expanded.Value = !leaderboard.Expanded.Value;
leaderboard.ForceExpand.Value = !leaderboard.ForceExpand.Value;
});
AddSliderStep("set player score", 50, 5000000, 1222333, v => playerScore.Value = v);
@@ -167,7 +167,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
public void TestScoreUpdates()
{
AddRepeatStep("update state", UpdateUserStatesRandomly, 100);
AddToggleStep("switch compact mode", expanded => Leaderboard!.Expanded.Value = expanded);
AddToggleStep("switch compact mode", expanded => Leaderboard!.ForceExpand.Value = expanded);
}
[Test]
@@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Expanded = { Value = true }
ForceExpand = { Value = true }
}
});
});
@@ -50,7 +50,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
Origin = Anchor.BottomCentre,
Team1Score = { BindTarget = LeaderboardProvider.TeamScores[0] },
Team2Score = { BindTarget = LeaderboardProvider.TeamScores[1] },
Expanded = { BindTarget = Leaderboard!.Expanded },
Expanded = { BindTarget = Leaderboard!.ForceExpand },
}, Add);
});
}
@@ -154,7 +154,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
});
leaderboardFlow.Insert(0, Leaderboard = new DrawableGameplayLeaderboard
{
Expanded = { Value = true }
ForceExpand = { Value = true }
});
LoadComponentAsync(new GameplayChatDisplay(room)
@@ -20,7 +20,7 @@ namespace osu.Game.Screens.Play.HUD
{
public partial class DrawableGameplayLeaderboard : CompositeDrawable, ISerialisableDrawable
{
public Bindable<bool> Expanded = new Bindable<bool>();
public readonly Bindable<bool> ForceExpand = new Bindable<bool>();
protected readonly FillFlowContainer<DrawableGameplayLeaderboardScore> Flow;
@@ -40,7 +40,7 @@ namespace osu.Game.Screens.Play.HUD
private readonly IBindable<LocalUserPlayingState> userPlayingState = new Bindable<LocalUserPlayingState>();
private readonly IBindable<bool> holdingForHUD = new Bindable<bool>();
private const int max_panels = 8;
private readonly Bindable<bool> expanded = new Bindable<bool>();
/// <summary>
/// Create a new leaderboard.
@@ -100,6 +100,7 @@ namespace osu.Game.Screens.Play.HUD
configVisibility.BindValueChanged(_ => Scheduler.AddOnce(updateState));
userPlayingState.BindValueChanged(_ => Scheduler.AddOnce(updateState));
holdingForHUD.BindValueChanged(_ => Scheduler.AddOnce(updateState));
ForceExpand.BindValueChanged(_ => Scheduler.AddOnce(updateState));
updateState();
}
@@ -110,7 +111,7 @@ namespace osu.Game.Screens.Play.HUD
scroll.ScrollToStart(false);
Flow.FadeTo(player?.Configuration.ShowLeaderboard != false && configVisibility.Value ? 1 : 0, 100, Easing.OutQuint);
Expanded.Value = userPlayingState.Value == LocalUserPlayingState.Playing || holdingForHUD.Value;
expanded.Value = ForceExpand.Value || userPlayingState.Value == LocalUserPlayingState.Playing || holdingForHUD.Value;
}
/// <summary>
@@ -128,7 +129,7 @@ namespace osu.Game.Screens.Play.HUD
TrackedScore = drawable;
}
drawable.Expanded.BindTo(Expanded);
drawable.Expanded.BindTo(expanded);
Flow.Add(drawable);
drawable.ScorePosition.BindValueChanged(_ => Scheduler.AddOnce(sort));