From 04871fe55a3f4855ff71627c8e09236229dd9cff Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 11 Jun 2025 17:35:53 +0900 Subject: [PATCH 1/3] Add setting to leaderboard to allow disabling automatic collapsing Was a 2 minute implementation, so why not? Addresses https://github.com/ppy/osu/discussions/33523. --- osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs index a7c4bc99b2..49b46298c9 100644 --- a/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs @@ -29,6 +29,9 @@ namespace osu.Game.Screens.Play.HUD public DrawableGameplayLeaderboardScore? TrackedScore { get; private set; } + [SettingSource("Collapse during gameplay", "If enabled, the leaderboard will become more compact during active gameplay.")] + public Bindable CollapseDuringGameplay { get; } = new BindableBool(true); + [Resolved] private Player? player { get; set; } @@ -98,6 +101,7 @@ namespace osu.Game.Screens.Play.HUD userPlayingState.BindValueChanged(_ => Scheduler.AddOnce(updateState)); holdingForHUD.BindValueChanged(_ => Scheduler.AddOnce(updateState)); ForceExpand.BindValueChanged(_ => Scheduler.AddOnce(updateState)); + CollapseDuringGameplay.BindValueChanged(_ => Scheduler.AddOnce(updateState)); updateState(); } @@ -108,7 +112,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 = ForceExpand.Value || userPlayingState.Value != LocalUserPlayingState.Playing || holdingForHUD.Value; + expanded.Value = !CollapseDuringGameplay.Value || ForceExpand.Value || userPlayingState.Value != LocalUserPlayingState.Playing || holdingForHUD.Value; } /// From ebfc3c9ccf8a77f062e04236dc9f8392967007ae Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 12 Jun 2025 17:27:23 +0900 Subject: [PATCH 2/3] Combine two similar flags into one --- .../Visual/Gameplay/TestSceneGameplayLeaderboard.cs | 2 +- .../Multiplayer/MultiplayerGameplayLeaderboardTestScene.cs | 2 +- .../Multiplayer/TestSceneMultiSpectatorLeaderboard.cs | 2 +- .../TestSceneMultiplayerGameplayLeaderboardTeams.cs | 6 ++++-- .../OnlinePlay/Multiplayer/Spectate/MultiSpectatorScreen.cs | 2 +- osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs | 5 +---- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs index f45e6326d1..d026afcd6d 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs @@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("toggle expanded", () => { if (leaderboard.IsNotNull()) - leaderboard.ForceExpand.Value = !leaderboard.ForceExpand.Value; + leaderboard.CollapseDuringGameplay.Value = !leaderboard.CollapseDuringGameplay.Value; }); AddSliderStep("set player score", 50, 5000000, 1222333, v => playerScore.Value = v); diff --git a/osu.Game.Tests/Visual/Multiplayer/MultiplayerGameplayLeaderboardTestScene.cs b/osu.Game.Tests/Visual/Multiplayer/MultiplayerGameplayLeaderboardTestScene.cs index 3008edf41f..955737578a 100644 --- a/osu.Game.Tests/Visual/Multiplayer/MultiplayerGameplayLeaderboardTestScene.cs +++ b/osu.Game.Tests/Visual/Multiplayer/MultiplayerGameplayLeaderboardTestScene.cs @@ -167,7 +167,7 @@ namespace osu.Game.Tests.Visual.Multiplayer public void TestScoreUpdates() { AddRepeatStep("update state", UpdateUserStatesRandomly, 100); - AddToggleStep("switch compact mode", expanded => Leaderboard!.ForceExpand.Value = expanded); + AddToggleStep("switch compact mode", collapsed => Leaderboard!.CollapseDuringGameplay.Value = collapsed); } [Test] diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorLeaderboard.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorLeaderboard.cs index 131b644dcb..c39708352e 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorLeaderboard.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorLeaderboard.cs @@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.Multiplayer { Anchor = Anchor.Centre, Origin = Anchor.Centre, - ForceExpand = { Value = true } + CollapseDuringGameplay = { Value = false } } }); }); diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs index 40d8650c69..6141820cb7 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs @@ -44,14 +44,16 @@ namespace osu.Game.Tests.Visual.Multiplayer Team2Score = { BindTarget = LeaderboardProvider.TeamScores[1] } }, Add); - LoadComponentAsync(new GameplayMatchScoreDisplay + GameplayMatchScoreDisplay matchScoreDisplay; + LoadComponentAsync(matchScoreDisplay = new GameplayMatchScoreDisplay { Anchor = Anchor.BottomCentre, Origin = Anchor.BottomCentre, Team1Score = { BindTarget = LeaderboardProvider.TeamScores[0] }, Team2Score = { BindTarget = LeaderboardProvider.TeamScores[1] }, - Expanded = { BindTarget = Leaderboard!.ForceExpand }, }, Add); + + Leaderboard!.CollapseDuringGameplay.BindValueChanged(_ => matchScoreDisplay.Expanded.Value = !Leaderboard.CollapseDuringGameplay.Value); }); } } diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/MultiSpectatorScreen.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/MultiSpectatorScreen.cs index 06efffbf6e..7ad8bdf454 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/MultiSpectatorScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/MultiSpectatorScreen.cs @@ -154,7 +154,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate }); leaderboardFlow.Insert(0, Leaderboard = new DrawableGameplayLeaderboard { - ForceExpand = { Value = true } + CollapseDuringGameplay = { Value = false } }); LoadComponentAsync(new GameplayChatDisplay(room) diff --git a/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs index 49b46298c9..f8e54efbf2 100644 --- a/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs @@ -20,8 +20,6 @@ namespace osu.Game.Screens.Play.HUD { public partial class DrawableGameplayLeaderboard : CompositeDrawable, ISerialisableDrawable { - public readonly Bindable ForceExpand = new Bindable(); - protected readonly FillFlowContainer Flow; private bool requiresScroll; @@ -100,7 +98,6 @@ 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)); CollapseDuringGameplay.BindValueChanged(_ => Scheduler.AddOnce(updateState)); updateState(); } @@ -112,7 +109,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 = !CollapseDuringGameplay.Value || ForceExpand.Value || userPlayingState.Value != LocalUserPlayingState.Playing || holdingForHUD.Value; + expanded.Value = !CollapseDuringGameplay.Value || userPlayingState.Value != LocalUserPlayingState.Playing || holdingForHUD.Value; } /// From 612f853baabdc2e209de1b2047aac315fe7272c8 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 12 Jun 2025 17:30:11 +0900 Subject: [PATCH 3/3] Localise new setting --- .../SkinComponents/SkinnableComponentStrings.cs | 11 +++++++++++ .../Screens/Play/HUD/DrawableGameplayLeaderboard.cs | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs index b21446e18a..66abf2bfd5 100644 --- a/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs +++ b/osu.Game/Localisation/SkinComponents/SkinnableComponentStrings.cs @@ -84,6 +84,17 @@ namespace osu.Game.Localisation.SkinComponents /// public static LocalisableString UseRelativeSize => new TranslatableString(getKey(@"use_relative_size"), @"Use relative size"); + /// + /// "Collapse during gameplay" + /// + public static LocalisableString CollapseDuringGameplay => new TranslatableString(getKey(@"collapse_during_gameplay"), @"Collapse during gameplay"); + + /// + /// "If enabled, the leaderboard will become more compact during active gameplay." + /// + public static LocalisableString CollapseDuringGameplayDescription => + new TranslatableString(getKey(@"if_enabled_the_leaderboard_will"), @"If enabled, the leaderboard will become more compact during active gameplay."); + private static string getKey(string key) => $@"{prefix}:{key}"; } } diff --git a/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs index f8e54efbf2..dd55e5f926 100644 --- a/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/DrawableGameplayLeaderboard.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Game.Configuration; using osu.Game.Graphics.Containers; +using osu.Game.Localisation.SkinComponents; using osu.Game.Screens.Select.Leaderboards; using osu.Game.Skinning; using osuTK; @@ -27,7 +28,7 @@ namespace osu.Game.Screens.Play.HUD public DrawableGameplayLeaderboardScore? TrackedScore { get; private set; } - [SettingSource("Collapse during gameplay", "If enabled, the leaderboard will become more compact during active gameplay.")] + [SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.CollapseDuringGameplay), nameof(SkinnableComponentStrings.CollapseDuringGameplayDescription))] public Bindable CollapseDuringGameplay { get; } = new BindableBool(true); [Resolved]