From 5894d2f0bca96e4af328dab2c7604b671943c529 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 13 Sep 2022 18:12:49 +0900 Subject: [PATCH] Ensure gameplay leaderboard hides with rest of HUD when it should --- .../OnlinePlay/Multiplayer/MultiplayerPlayer.cs | 3 ++- osu.Game/Screens/Play/HUDOverlay.cs | 12 ++++++++++-- osu.Game/Screens/Play/Player.cs | 3 ++- osu.Game/Screens/Play/PlayerConfiguration.cs | 5 +++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs index d6d381d721..655aa08a72 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerPlayer.cs @@ -60,7 +60,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer AllowPause = false, AllowRestart = false, AllowSkipping = room.AutoSkip.Value, - AutomaticallySkipIntro = room.AutoSkip.Value + AutomaticallySkipIntro = room.AutoSkip.Value, + AlwaysShowLeaderboard = true, }) { this.users = users; diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index f9f3693385..a727b8925b 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -9,7 +9,6 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.EnumExtensions; -using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; @@ -80,7 +79,7 @@ namespace osu.Game.Screens.Play private readonly SkinnableTargetContainer mainComponents; - private IEnumerable hideTargets => new Drawable[] { mainComponents, KeyCounter, topRightElements }; + private readonly List hideTargets; public HUDOverlay(DrawableRuleset drawableRuleset, IReadOnlyList mods) { @@ -129,6 +128,8 @@ namespace osu.Game.Screens.Play }, clicksPerSecondCalculator = new ClicksPerSecondCalculator() }; + + hideTargets = new List { mainComponents, KeyCounter, topRightElements }; } [BackgroundDependencyLoader(true)] @@ -173,6 +174,13 @@ namespace osu.Game.Screens.Play replayLoaded.BindValueChanged(replayLoadedValueChanged, true); } + public void Add(Drawable drawable, bool hideWithHUD) + { + base.Add(drawable); + if (hideWithHUD) + hideTargets.Add(drawable); + } + protected override void Update() { base.Update(); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3fd57496bb..659dbd06ef 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -838,6 +838,7 @@ namespace osu.Game.Screens.Play return; leaderboard.Expanded.BindTo(LeaderboardExpandedState); + AddLeaderboardToHUD(leaderboard); }); } @@ -849,7 +850,7 @@ namespace osu.Game.Screens.Play Margin = new MarginPadding { Bottom = 75, Left = 20 }, }; - protected virtual void AddLeaderboardToHUD(GameplayLeaderboard leaderboard) => HUDOverlay.Add(leaderboard); + protected virtual void AddLeaderboardToHUD(GameplayLeaderboard leaderboard) => HUDOverlay.Add(leaderboard, !Configuration.AlwaysShowLeaderboard); private void updateLeaderboardExpandedState() => LeaderboardExpandedState.Value = !LocalUserPlaying.Value || HUDOverlay.HoldingForHUD.Value; diff --git a/osu.Game/Screens/Play/PlayerConfiguration.cs b/osu.Game/Screens/Play/PlayerConfiguration.cs index b1b0e01d80..b82925ccb8 100644 --- a/osu.Game/Screens/Play/PlayerConfiguration.cs +++ b/osu.Game/Screens/Play/PlayerConfiguration.cs @@ -36,5 +36,10 @@ namespace osu.Game.Screens.Play /// Whether the intro should be skipped by default. /// public bool AutomaticallySkipIntro { get; set; } + + /// + /// Whether the gameplay leaderboard should always be shown (usually in a contracted state). + /// + public bool AlwaysShowLeaderboard { get; set; } } }