From f81107eb5ac7dacb58c2b0955a975e0113eaf5e2 Mon Sep 17 00:00:00 2001 From: nanashi-1 Date: Mon, 26 Sep 2022 20:07:43 +0800 Subject: [PATCH 01/14] add gameplay leaderboard config --- osu.Game/Configuration/OsuConfigManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 54c545e367..8d1de971b3 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -131,6 +131,7 @@ namespace osu.Game.Configuration SetDefault(OsuSetting.ShowHealthDisplayWhenCantFail, true); SetDefault(OsuSetting.FadePlayfieldWhenHealthLow, true); SetDefault(OsuSetting.KeyOverlay, false); + SetDefault(OsuSetting.GameplayLeaderboard, true); SetDefault(OsuSetting.AlwaysPlayFirstComboBreak, true); SetDefault(OsuSetting.FloatingComments, false); @@ -294,6 +295,7 @@ namespace osu.Game.Configuration LightenDuringBreaks, ShowStoryboard, KeyOverlay, + GameplayLeaderboard, PositionalHitsounds, PositionalHitsoundsLevel, AlwaysPlayFirstComboBreak, From bed25ff60e92b87d212a15281d65556e555e587c Mon Sep 17 00:00:00 2001 From: nanashi-1 Date: Mon, 26 Sep 2022 20:08:26 +0800 Subject: [PATCH 02/14] add gameplay leaderboard config string --- osu.Game/Localisation/GameplaySettingsStrings.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/osu.Game/Localisation/GameplaySettingsStrings.cs b/osu.Game/Localisation/GameplaySettingsStrings.cs index 13cfcc3a19..40f39d927d 100644 --- a/osu.Game/Localisation/GameplaySettingsStrings.cs +++ b/osu.Game/Localisation/GameplaySettingsStrings.cs @@ -79,6 +79,11 @@ namespace osu.Game.Localisation /// public static LocalisableString AlwaysShowKeyOverlay => new TranslatableString(getKey(@"key_overlay"), @"Always show key overlay"); + /// + /// "Always show gameplay leaderboard" + /// + public static LocalisableString AlwaysShowGameplayLeaderboard => new TranslatableString(getKey(@"gameplay_leaderboard"), @"Always show gameplay leaderboard"); + /// /// "Always play first combo break sound" /// From dc051a8b7992ebf6f7a7b8f08da6b16ea8b97ee8 Mon Sep 17 00:00:00 2001 From: nanashi-1 Date: Mon, 26 Sep 2022 20:08:58 +0800 Subject: [PATCH 03/14] add gameplay leaderboard config --- osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs index 0893af7d3e..12534c51a8 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs @@ -38,6 +38,12 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay Current = config.GetBindable(OsuSetting.KeyOverlay), Keywords = new[] { "counter" }, }, + new SettingsCheckbox + { + LabelText = GameplaySettingsStrings.AlwaysShowGameplayLeaderboard, + Current = config.GetBindable(OsuSetting.GameplayLeaderboard), + Keywords = new[] { "leaderboard", "score" }, + }, }; } } From ee4d1b2d58cbb2d3c2fa51f65d88eea438f7e070 Mon Sep 17 00:00:00 2001 From: nanashi-1 Date: Mon, 26 Sep 2022 20:13:07 +0800 Subject: [PATCH 04/14] add config visibility --- .../Screens/Play/HUD/GameplayLeaderboard.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osu.Game/Screens/Play/HUD/GameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/GameplayLeaderboard.cs index 2d816fbd55..b618ce907d 100644 --- a/osu.Game/Screens/Play/HUD/GameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/GameplayLeaderboard.cs @@ -3,12 +3,14 @@ using System; using System.Linq; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Caching; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; +using osu.Game.Configuration; using osu.Game.Graphics.Containers; using osu.Game.Users; using osuTK; @@ -18,6 +20,10 @@ namespace osu.Game.Screens.Play.HUD { public abstract class GameplayLeaderboard : CompositeDrawable { + + private const int duration = 100; + + private readonly Bindable configVisibility = new Bindable(); private readonly Cached sorting = new Cached(); public Bindable Expanded = new Bindable(); @@ -57,11 +63,19 @@ namespace osu.Game.Screens.Play.HUD }; } + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility); + } + protected override void LoadComplete() { base.LoadComplete(); Scheduler.AddDelayed(sort, 1000, true); + + configVisibility.BindValueChanged(_ => updateVisibility(), true); } /// @@ -193,5 +207,8 @@ namespace osu.Game.Screens.Play.HUD public override bool HandlePositionalInput => false; public override bool HandleNonPositionalInput => false; } + + private void updateVisibility() => + Flow.FadeTo(configVisibility.Value ? 1 : 0, duration); } } From 5c132aadeb4fb60bd4dc0a50e3a9d5872643b0f1 Mon Sep 17 00:00:00 2001 From: nanashi-1 Date: Mon, 26 Sep 2022 20:15:17 +0800 Subject: [PATCH 05/14] add visual test --- .../Gameplay/TestSceneGameplayLeaderboard.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs index 72656c29b1..eb5846669f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs @@ -5,12 +5,14 @@ using System.Linq; using NUnit.Framework; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.PolygonExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Framework.Utils; +using osu.Game.Configuration; using osu.Game.Online.API.Requests.Responses; using osu.Game.Screens.Play.HUD; using osuTK; @@ -24,6 +26,8 @@ namespace osu.Game.Tests.Visual.Gameplay private readonly BindableDouble playerScore = new BindableDouble(); + private Bindable configVisibility = new Bindable(); + public TestSceneGameplayLeaderboard() { AddStep("toggle expanded", () => @@ -35,6 +39,12 @@ namespace osu.Game.Tests.Visual.Gameplay AddSliderStep("set player score", 50, 5000000, 1222333, v => playerScore.Value = v); } + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility); + } + [Test] public void TestLayoutWithManyScores() { @@ -129,6 +139,21 @@ namespace osu.Game.Tests.Visual.Gameplay => AddAssert($"leaderboard height is {panelCount} panels high", () => leaderboard.DrawHeight == (GameplayLeaderboardScore.PANEL_HEIGHT + leaderboard.Spacing) * panelCount); } + [Test] + public void TestVisibility() + { + createLeaderboard(); + addLocalPlayer(); + + AddStep("set visible true", () => configVisibility.Value = true); + AddWaitStep("wait", 1); + AddAssert("is leaderboard fully visible", () => leaderboard.FlowAlpha == 1); + + AddStep("set visible false", () => configVisibility.Value = false); + AddWaitStep("wait", 1); + AddAssert("is leaderboard fully invisible", () => leaderboard.FlowAlpha == 0); + } + private void addLocalPlayer() { AddStep("add local player", () => @@ -163,6 +188,8 @@ namespace osu.Game.Tests.Visual.Gameplay { public float Spacing => Flow.Spacing.Y; + public float FlowAlpha => Flow.Alpha; + public bool CheckPositionByUsername(string username, int? expectedPosition) { var scoreItem = Flow.FirstOrDefault(i => i.User?.Username == username); From 4295d9c169b5b1453162131909c6f58c95ff7cdb Mon Sep 17 00:00:00 2001 From: nanashi-1 Date: Mon, 26 Sep 2022 21:11:14 +0800 Subject: [PATCH 06/14] revert --- .../Gameplay/TestSceneGameplayLeaderboard.cs | 27 ------------------- .../Screens/Play/HUD/GameplayLeaderboard.cs | 17 ------------ 2 files changed, 44 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs index eb5846669f..72656c29b1 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayLeaderboard.cs @@ -5,14 +5,12 @@ using System.Linq; using NUnit.Framework; -using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.PolygonExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Framework.Utils; -using osu.Game.Configuration; using osu.Game.Online.API.Requests.Responses; using osu.Game.Screens.Play.HUD; using osuTK; @@ -26,8 +24,6 @@ namespace osu.Game.Tests.Visual.Gameplay private readonly BindableDouble playerScore = new BindableDouble(); - private Bindable configVisibility = new Bindable(); - public TestSceneGameplayLeaderboard() { AddStep("toggle expanded", () => @@ -39,12 +35,6 @@ namespace osu.Game.Tests.Visual.Gameplay AddSliderStep("set player score", 50, 5000000, 1222333, v => playerScore.Value = v); } - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility); - } - [Test] public void TestLayoutWithManyScores() { @@ -139,21 +129,6 @@ namespace osu.Game.Tests.Visual.Gameplay => AddAssert($"leaderboard height is {panelCount} panels high", () => leaderboard.DrawHeight == (GameplayLeaderboardScore.PANEL_HEIGHT + leaderboard.Spacing) * panelCount); } - [Test] - public void TestVisibility() - { - createLeaderboard(); - addLocalPlayer(); - - AddStep("set visible true", () => configVisibility.Value = true); - AddWaitStep("wait", 1); - AddAssert("is leaderboard fully visible", () => leaderboard.FlowAlpha == 1); - - AddStep("set visible false", () => configVisibility.Value = false); - AddWaitStep("wait", 1); - AddAssert("is leaderboard fully invisible", () => leaderboard.FlowAlpha == 0); - } - private void addLocalPlayer() { AddStep("add local player", () => @@ -188,8 +163,6 @@ namespace osu.Game.Tests.Visual.Gameplay { public float Spacing => Flow.Spacing.Y; - public float FlowAlpha => Flow.Alpha; - public bool CheckPositionByUsername(string username, int? expectedPosition) { var scoreItem = Flow.FirstOrDefault(i => i.User?.Username == username); diff --git a/osu.Game/Screens/Play/HUD/GameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/GameplayLeaderboard.cs index b618ce907d..2d816fbd55 100644 --- a/osu.Game/Screens/Play/HUD/GameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/GameplayLeaderboard.cs @@ -3,14 +3,12 @@ using System; using System.Linq; -using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Caching; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; -using osu.Game.Configuration; using osu.Game.Graphics.Containers; using osu.Game.Users; using osuTK; @@ -20,10 +18,6 @@ namespace osu.Game.Screens.Play.HUD { public abstract class GameplayLeaderboard : CompositeDrawable { - - private const int duration = 100; - - private readonly Bindable configVisibility = new Bindable(); private readonly Cached sorting = new Cached(); public Bindable Expanded = new Bindable(); @@ -63,19 +57,11 @@ namespace osu.Game.Screens.Play.HUD }; } - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility); - } - protected override void LoadComplete() { base.LoadComplete(); Scheduler.AddDelayed(sort, 1000, true); - - configVisibility.BindValueChanged(_ => updateVisibility(), true); } /// @@ -207,8 +193,5 @@ namespace osu.Game.Screens.Play.HUD public override bool HandlePositionalInput => false; public override bool HandleNonPositionalInput => false; } - - private void updateVisibility() => - Flow.FadeTo(configVisibility.Value ? 1 : 0, duration); } } From 5d18001d7542159c2959ea75499b4ca5b6da8621 Mon Sep 17 00:00:00 2001 From: nanashi-1 Date: Mon, 26 Sep 2022 21:11:38 +0800 Subject: [PATCH 07/14] move config --- .../Screens/Play/HUD/SoloGameplayLeaderboard.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs index eff7870d89..fb7e2ff00f 100644 --- a/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Game.Configuration; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Users; @@ -13,6 +15,9 @@ namespace osu.Game.Screens.Play.HUD { public class SoloGameplayLeaderboard : GameplayLeaderboard { + private const int duration = 100; + + private readonly Bindable configVisibility = new Bindable(); private readonly IUser trackingUser; public readonly IBindableList Scores = new BindableList(); @@ -31,10 +36,18 @@ namespace osu.Game.Screens.Play.HUD this.trackingUser = trackingUser; } + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility); + } + protected override void LoadComplete() { base.LoadComplete(); Scores.BindCollectionChanged((_, _) => Scheduler.AddOnce(showScores), true); + + configVisibility.BindValueChanged(_ => updateVisibility(), true); } private void showScores() @@ -69,5 +82,8 @@ namespace osu.Game.Screens.Play.HUD // Local score should always show lower than any existing scores in cases of ties. local.DisplayOrder.Value = long.MaxValue; } + + private void updateVisibility() => + Flow.FadeTo(configVisibility.Value ? 1 : 0, duration); } } From 1fab1db145843644699095a4ab319d832c84e5ae Mon Sep 17 00:00:00 2001 From: nanashi-1 Date: Mon, 26 Sep 2022 21:11:48 +0800 Subject: [PATCH 08/14] move test --- .../TestSceneSoloGameplayLeaderboard.cs | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs index ac73e88468..cb48275e21 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs @@ -9,11 +9,13 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Testing; using osu.Framework.Utils; +using osu.Game.Configuration; using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Screens.Play.HUD; +using osu.Game.Users; namespace osu.Game.Tests.Visual.Gameplay { @@ -24,6 +26,16 @@ namespace osu.Game.Tests.Visual.Gameplay private readonly BindableList scores = new BindableList(); + private Bindable configVisibility = new Bindable(); + + private TestSoloGameplayLeaderboard? testSoloGameplayLeaderboard; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility); + } + [SetUpSteps] public void SetUpSteps() { @@ -37,7 +49,7 @@ namespace osu.Game.Tests.Visual.Gameplay Id = 2, }; - Child = new SoloGameplayLeaderboard(trackingUser) + Child = testSoloGameplayLeaderboard = new TestSoloGameplayLeaderboard(trackingUser) { Scores = { BindTarget = scores }, Anchor = Anchor.Centre, @@ -57,6 +69,18 @@ namespace osu.Game.Tests.Visual.Gameplay AddSliderStep("combo", 0, 1000, 0, v => scoreProcessor.Combo.Value = v); } + [Test] + public void TestVisibility() + { + AddStep("set visible true", () => configVisibility.Value = true); + AddWaitStep("wait", 1); + AddAssert("is leaderboard fully visible", () => testSoloGameplayLeaderboard?.FlowAlpha == 1); + + AddStep("set visible false", () => configVisibility.Value = false); + AddWaitStep("wait", 1); + AddAssert("is leaderboard fully invisible", () => testSoloGameplayLeaderboard?.FlowAlpha == 0); + } + private static List createSampleScores() { return new[] @@ -68,5 +92,13 @@ namespace osu.Game.Tests.Visual.Gameplay new ScoreInfo { User = new APIUser { Username = @"Susko3" }, TotalScore = RNG.Next(500000, 1000000) }, }.Concat(Enumerable.Range(0, 50).Select(i => new ScoreInfo { User = new APIUser { Username = $"User {i + 1}" }, TotalScore = 1000000 - i * 10000 })).ToList(); } + + private class TestSoloGameplayLeaderboard : SoloGameplayLeaderboard + { + public float FlowAlpha => Flow.Alpha; + public TestSoloGameplayLeaderboard(IUser trackingUser) + : base(trackingUser) + { } + } } } From 214a1c2d7fede26719017d7e8dcf73838661d02a Mon Sep 17 00:00:00 2001 From: nanashi-1 Date: Mon, 26 Sep 2022 21:26:13 +0800 Subject: [PATCH 09/14] code factor --- .../Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs index cb48275e21..128e8b6c8a 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs @@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual.Gameplay private readonly BindableList scores = new BindableList(); - private Bindable configVisibility = new Bindable(); + private readonly Bindable configVisibility = new Bindable(); private TestSoloGameplayLeaderboard? testSoloGameplayLeaderboard; @@ -96,9 +96,11 @@ namespace osu.Game.Tests.Visual.Gameplay private class TestSoloGameplayLeaderboard : SoloGameplayLeaderboard { public float FlowAlpha => Flow.Alpha; + public TestSoloGameplayLeaderboard(IUser trackingUser) - : base(trackingUser) - { } + : base(trackingUser) + { + } } } } From bac3108aea03fb72b9ccc146b6cfb7353cf8f63a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Sep 2022 14:29:59 +0900 Subject: [PATCH 10/14] Remove unnecessary keywords --- osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs index 12534c51a8..88a27840d8 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs @@ -42,7 +42,6 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay { LabelText = GameplaySettingsStrings.AlwaysShowGameplayLeaderboard, Current = config.GetBindable(OsuSetting.GameplayLeaderboard), - Keywords = new[] { "leaderboard", "score" }, }, }; } From 320f134634fa3095c8522abc0b228c22f2671d92 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Sep 2022 14:43:08 +0900 Subject: [PATCH 11/14] Use same logic as `KeyCounterDisplay` --- osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs | 9 ++++++++- osu.Game/Screens/Play/ReplayPlayer.cs | 1 + osu.Game/Screens/Play/SoloPlayer.cs | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs index fb7e2ff00f..471aaf9a6d 100644 --- a/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs @@ -31,6 +31,12 @@ namespace osu.Game.Screens.Play.HUD [Resolved] private ScoreManager scoreManager { get; set; } = null!; + /// + /// Whether the leaderboard should be visible regardless of the configuration value. + /// This is true by default, but can be changed. + /// + public readonly Bindable AlwaysVisible = new Bindable(true); + public SoloGameplayLeaderboard(IUser trackingUser) { this.trackingUser = trackingUser; @@ -47,6 +53,7 @@ namespace osu.Game.Screens.Play.HUD base.LoadComplete(); Scores.BindCollectionChanged((_, _) => Scheduler.AddOnce(showScores), true); + AlwaysVisible.BindValueChanged(_ => updateVisibility()); configVisibility.BindValueChanged(_ => updateVisibility(), true); } @@ -84,6 +91,6 @@ namespace osu.Game.Screens.Play.HUD } private void updateVisibility() => - Flow.FadeTo(configVisibility.Value ? 1 : 0, duration); + this.FadeTo(AlwaysVisible.Value || configVisibility.Value ? 1 : 0, duration); } } diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index 163b9c593f..5382e283e0 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -62,6 +62,7 @@ namespace osu.Game.Screens.Play protected override GameplayLeaderboard CreateGameplayLeaderboard() => new SoloGameplayLeaderboard(Score.ScoreInfo.User) { + AlwaysVisible = { Value = true }, Scores = { BindTarget = LeaderboardScores } }; diff --git a/osu.Game/Screens/Play/SoloPlayer.cs b/osu.Game/Screens/Play/SoloPlayer.cs index d7730737d6..ee19391b89 100644 --- a/osu.Game/Screens/Play/SoloPlayer.cs +++ b/osu.Game/Screens/Play/SoloPlayer.cs @@ -48,6 +48,7 @@ namespace osu.Game.Screens.Play protected override GameplayLeaderboard CreateGameplayLeaderboard() => new SoloGameplayLeaderboard(Score.ScoreInfo.User) { + AlwaysVisible = { Value = false }, Scores = { BindTarget = LeaderboardScores } }; From 4260ace1a6d24ff2a5282a89d93646b5a75a508a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Sep 2022 14:46:35 +0900 Subject: [PATCH 12/14] Fix test coverage --- .../TestSceneSoloGameplayLeaderboard.cs | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs index 128e8b6c8a..8e438e98b6 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs @@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual.Gameplay private readonly Bindable configVisibility = new Bindable(); - private TestSoloGameplayLeaderboard? testSoloGameplayLeaderboard; + private SoloGameplayLeaderboard leaderboard = null!; [BackgroundDependencyLoader] private void load(OsuConfigManager config) @@ -49,11 +49,12 @@ namespace osu.Game.Tests.Visual.Gameplay Id = 2, }; - Child = testSoloGameplayLeaderboard = new TestSoloGameplayLeaderboard(trackingUser) + Child = leaderboard = new SoloGameplayLeaderboard(trackingUser) { Scores = { BindTarget = scores }, Anchor = Anchor.Centre, Origin = Anchor.Centre, + AlwaysVisible = { Value = false }, Expanded = { Value = true }, }; }); @@ -72,13 +73,17 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestVisibility() { - AddStep("set visible true", () => configVisibility.Value = true); - AddWaitStep("wait", 1); - AddAssert("is leaderboard fully visible", () => testSoloGameplayLeaderboard?.FlowAlpha == 1); + AddStep("set config visible true", () => configVisibility.Value = true); + AddUntilStep("leaderboard visible", () => leaderboard.Alpha == 1); - AddStep("set visible false", () => configVisibility.Value = false); - AddWaitStep("wait", 1); - AddAssert("is leaderboard fully invisible", () => testSoloGameplayLeaderboard?.FlowAlpha == 0); + AddStep("set config visible false", () => configVisibility.Value = false); + AddUntilStep("leaderboard not visible", () => leaderboard.Alpha == 0); + + AddStep("set always visible", () => leaderboard.AlwaysVisible.Value = true); + AddUntilStep("leaderboard visible", () => leaderboard.Alpha == 1); + + AddStep("set config visible true", () => configVisibility.Value = true); + AddAssert("leaderboard still visible", () => leaderboard.Alpha == 1); } private static List createSampleScores() @@ -92,15 +97,5 @@ namespace osu.Game.Tests.Visual.Gameplay new ScoreInfo { User = new APIUser { Username = @"Susko3" }, TotalScore = RNG.Next(500000, 1000000) }, }.Concat(Enumerable.Range(0, 50).Select(i => new ScoreInfo { User = new APIUser { Username = $"User {i + 1}" }, TotalScore = 1000000 - i * 10000 })).ToList(); } - - private class TestSoloGameplayLeaderboard : SoloGameplayLeaderboard - { - public float FlowAlpha => Flow.Alpha; - - public TestSoloGameplayLeaderboard(IUser trackingUser) - : base(trackingUser) - { - } - } } } From 87a1e05641d596025c73f3a572560990d391eb69 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Sep 2022 15:06:05 +0900 Subject: [PATCH 13/14] Remove unused using statement --- .../Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs index 8e438e98b6..6b52e934b7 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboard.cs @@ -15,7 +15,6 @@ using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Scoring; using osu.Game.Screens.Play.HUD; -using osu.Game.Users; namespace osu.Game.Tests.Visual.Gameplay { From 0296685c74bbc47cebdc9d7c09b91bc10e10ff6f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Sep 2022 17:25:24 +0900 Subject: [PATCH 14/14] Start key counter / gameplay leaderboard hidden to avoid initial fade out --- osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs | 3 +++ osu.Game/Screens/Play/KeyCounterDisplay.cs | 1 + 2 files changed, 4 insertions(+) diff --git a/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs index 471aaf9a6d..53981b9edc 100644 --- a/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/SoloGameplayLeaderboard.cs @@ -53,6 +53,9 @@ namespace osu.Game.Screens.Play.HUD base.LoadComplete(); Scores.BindCollectionChanged((_, _) => Scheduler.AddOnce(showScores), true); + // Alpha will be updated via `updateVisibility` below. + Alpha = 0; + AlwaysVisible.BindValueChanged(_ => updateVisibility()); configVisibility.BindValueChanged(_ => updateVisibility(), true); } diff --git a/osu.Game/Screens/Play/KeyCounterDisplay.cs b/osu.Game/Screens/Play/KeyCounterDisplay.cs index b6094726c0..1b726b0f7b 100644 --- a/osu.Game/Screens/Play/KeyCounterDisplay.cs +++ b/osu.Game/Screens/Play/KeyCounterDisplay.cs @@ -39,6 +39,7 @@ namespace osu.Game.Screens.Play { Direction = FillDirection.Horizontal, AutoSizeAxes = Axes.Both, + Alpha = 0, }; }