From 06212bca51eed12d8cf887f3e14a6031344043c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 18 Jan 2023 21:41:00 +0100 Subject: [PATCH 1/3] Restructure test scene to demonstrate failure --- .../Gameplay/TestSceneJudgementCounter.cs | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs index d104e25df0..19c93fab62 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs @@ -25,35 +25,33 @@ namespace osu.Game.Tests.Visual.Gameplay private JudgementTally judgementTally = null!; private TestJudgementCounterDisplay counterDisplay = null!; + private DependencyProvidingContainer content = null!; + + protected override Container Content => content; + private readonly Bindable lastJudgementResult = new Bindable(); private int iteration; [SetUpSteps] - public void SetupSteps() => AddStep("Create components", () => + public void SetUpSteps() => AddStep("Create components", () => { var ruleset = CreateRuleset(); Debug.Assert(ruleset != null); scoreProcessor = new ScoreProcessor(ruleset); - Child = new DependencyProvidingContainer + base.Content.Child = new DependencyProvidingContainer { RelativeSizeAxes = Axes.Both, CachedDependencies = new (Type, object)[] { (typeof(ScoreProcessor), scoreProcessor), (typeof(Ruleset), ruleset) }, Children = new Drawable[] { judgementTally = new JudgementTally(), - new DependencyProvidingContainer + content = new DependencyProvidingContainer { RelativeSizeAxes = Axes.Both, CachedDependencies = new (Type, object)[] { (typeof(JudgementTally), judgementTally) }, - Child = counterDisplay = new TestJudgementCounterDisplay - { - Margin = new MarginPadding { Top = 100 }, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre - } } }, }; @@ -78,6 +76,8 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestAddJudgementsToCounters() { + AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay()); + AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Great), 2); AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Miss), 2); AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Meh), 2); @@ -86,6 +86,8 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestAddWhilstHidden() { + AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay()); + AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.LargeTickHit), 2); AddAssert("Check value added whilst hidden", () => hiddenCount() == 2); AddStep("Show all judgements", () => counterDisplay.Mode.Value = JudgementCounterDisplay.DisplayMode.All); @@ -94,6 +96,8 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestChangeFlowDirection() { + AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay()); + AddStep("Set direction vertical", () => counterDisplay.FlowDirection.Value = Direction.Vertical); AddStep("Set direction horizontal", () => counterDisplay.FlowDirection.Value = Direction.Horizontal); } @@ -101,6 +105,8 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestToggleJudgementNames() { + AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay()); + AddStep("Hide judgement names", () => counterDisplay.ShowJudgementNames.Value = false); AddWaitStep("wait some", 2); AddAssert("Assert hidden", () => counterDisplay.CounterFlow.Children.First().ResultName.Alpha == 0); @@ -112,6 +118,8 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestHideMaxValue() { + AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay()); + AddStep("Hide max judgement", () => counterDisplay.ShowMaxJudgement.Value = false); AddWaitStep("wait some", 2); AddAssert("Check max hidden", () => counterDisplay.CounterFlow.ChildrenOfType().First().Alpha == 0); @@ -121,6 +129,8 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestCycleDisplayModes() { + AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay()); + AddStep("Show basic judgements", () => counterDisplay.Mode.Value = JudgementCounterDisplay.DisplayMode.Simple); AddWaitStep("wait some", 2); AddAssert("Check only basic", () => counterDisplay.CounterFlow.ChildrenOfType().Last().Alpha == 0); @@ -139,6 +149,13 @@ namespace osu.Game.Tests.Visual.Gameplay private partial class TestJudgementCounterDisplay : JudgementCounterDisplay { public new FillFlowContainer CounterFlow => base.CounterFlow; + + public TestJudgementCounterDisplay() + { + Margin = new MarginPadding { Top = 100 }; + Anchor = Anchor.TopCentre; + Origin = Anchor.TopCentre; + } } } } From 7299d227d1d30d7b46edce5af93084fadf85b64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 18 Jan 2023 21:42:22 +0100 Subject: [PATCH 2/3] Add failing test case --- .../Visual/Gameplay/TestSceneJudgementCounter.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs index 19c93fab62..46900a2af1 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs @@ -126,6 +126,16 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("Show max judgement", () => counterDisplay.ShowMaxJudgement.Value = true); } + [Test] + public void TestMaxValueStartsHidden() + { + AddStep("create counter", () => Child = counterDisplay = new TestJudgementCounterDisplay + { + ShowMaxJudgement = { Value = false } + }); + AddAssert("Check max hidden", () => counterDisplay.CounterFlow.ChildrenOfType().First().Alpha == 0); + } + [Test] public void TestCycleDisplayModes() { From 769f8c61907fe584d09000385ae6d119fc19fff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 18 Jan 2023 21:46:28 +0100 Subject: [PATCH 3/3] Fix `ShowMaxJudgement` callback conflicting with `JudgementCounter.Pop{In,Out}` Both `JudgementCounterDisplay` (via the `ShowMaxJudgement` callback) and the `JudgementCounter.Pop{In,Out}` methods were operating on the alpha of the `JudgementCounter`. This meant that if the counter display was created with max judgement initially hidden, it would be hidden by the `ShowMaxJudgement` callback first, but then _unhidden_ by `PopIn()`. --- .../Play/HUD/JudgementCounter/JudgementCounterDisplay.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs b/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs index 4ec90edeb0..e30f8f9be3 100644 --- a/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs +++ b/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs @@ -68,10 +68,12 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter Mode.BindValueChanged(_ => updateMode(), true); - ShowMaxJudgement.BindValueChanged(value => + ShowMaxJudgement.BindValueChanged(showMax => { var firstChild = CounterFlow.Children.FirstOrDefault(); - firstChild.FadeTo(value.NewValue ? 1 : 0, TRANSFORM_DURATION, Easing.OutQuint); + + if (firstChild != null) + firstChild.State.Value = showMax.NewValue ? Visibility.Visible : Visibility.Hidden; }, true); }