diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs index 1d79d8e408..a8d9f203ae 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneJudgementCounter.cs @@ -81,9 +81,6 @@ public void TestAddJudgementsToCounters() AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Great), 2); AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Miss), 2); AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.Meh), 2); - AddRepeatStep("Add judgement", () => applyOneJudgement(HitResult.LargeTickHit), 2); - AddStep("Show all judgements", () => counterDisplay.Mode.Value = JudgementCounterDisplay.DisplayMode.All); - AddAssert("Check value added whilst hidden", () => hiddenCount() == 2); } [Test] @@ -105,8 +102,10 @@ public void TestChangeFlowDirection() public void TestToggleJudgementNames() { AddStep("Hide judgement names", () => counterDisplay.ShowName.Value = false); + AddWaitStep("wait some", 2); AddAssert("Assert hidden", () => counterDisplay.JudgementContainer.Children.OfType().First().ResultName.Alpha == 0); AddStep("Hide judgement names", () => counterDisplay.ShowName.Value = true); + AddWaitStep("wait some", 2); AddAssert("Assert shown", () => counterDisplay.JudgementContainer.Children.OfType().First().ResultName.Alpha == 1); } diff --git a/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounter.cs b/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounter.cs index efb4c532f9..ea6e9997e3 100644 --- a/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounter.cs +++ b/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounter.cs @@ -20,10 +20,7 @@ public partial class JudgementCounter : OverlayContainer public readonly JudgementCounterInfo Result; - public JudgementCounter(JudgementCounterInfo result) - { - Result = result; - } + public JudgementCounter(JudgementCounterInfo result) => Result = result; public OsuSpriteText ResultName = null!; private FillFlowContainer flowContainer = null!; @@ -52,45 +49,18 @@ private void load(OsuColour colours, IBindable ruleset) var result = Result.Type; - if (result.IsBasic()) - { - Colour = colours.ForHitResult(Result.Type); - return; - } - - if (!result.IsBonus()) - { - Colour = colours.PurpleLight; - return; - } - - Colour = colours.PurpleLighter; + Colour = result.IsBasic() ? colours.ForHitResult(Result.Type) : !result.IsBonus() ? colours.PurpleLight : colours.PurpleLighter; } protected override void LoadComplete() { ShowName.BindValueChanged(value => - { - if (value.NewValue) - { - ResultName.Show(); - return; - } - - ResultName.Hide(); - }, true); + ResultName.FadeTo(value.NewValue ? 1 : 0, JudgementCounterDisplay.TRANSFORM_DURATION, Easing.OutQuint), true); Direction.BindValueChanged(direction => { flowContainer.Direction = direction.NewValue; - - if (direction.NewValue == FillDirection.Vertical) - { - changeAnchor(Anchor.TopLeft); - return; - } - - changeAnchor(Anchor.BottomLeft); + changeAnchor(direction.NewValue == FillDirection.Vertical ? Anchor.TopLeft : Anchor.BottomLeft); void changeAnchor(Anchor anchor) => counter.Anchor = ResultName.Anchor = counter.Origin = ResultName.Origin = anchor; }, true); @@ -98,15 +68,8 @@ protected override void LoadComplete() base.LoadComplete(); } - protected override void PopIn() - { - this.FadeIn(500, Easing.OutQuint); - } - - protected override void PopOut() - { - this.FadeOut(100); - } + protected override void PopIn() => this.FadeIn(JudgementCounterDisplay.TRANSFORM_DURATION, Easing.OutQuint); + protected override void PopOut() => this.FadeOut(100); private sealed partial class JudgementRollingCounter : RollingCounter { diff --git a/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs b/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs index 1842ba1eae..4e2b2a10cd 100644 --- a/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs +++ b/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementCounterDisplay.cs @@ -16,6 +16,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter { public partial class JudgementCounterDisplay : CompositeDrawable, ISkinnableDrawable { + public const int TRANSFORM_DURATION = 500; public bool UsesFixedAnchor { get; set; } [SettingSource("Display mode")] @@ -47,9 +48,7 @@ private void load() }; foreach (var result in tally.Results) - { JudgementContainer.Add(createCounter(result)); - } } protected override void LoadComplete() @@ -62,22 +61,13 @@ protected override void LoadComplete() //Can't pass directly due to Enum conversion foreach (var counter in JudgementContainer.Children.OfType()) - { counter.Direction.Value = getFlow(direction.NewValue); - } }, true); Mode.BindValueChanged(_ => updateMode(), true); ShowMax.BindValueChanged(value => { var firstChild = JudgementContainer.Children.FirstOrDefault(); - - if (value.NewValue) - { - firstChild?.Show(); - return; - } - - firstChild?.Hide(); + firstChild.FadeTo(value.NewValue ? 1 : 0, TRANSFORM_DURATION, Easing.OutQuint); }, true); } @@ -89,22 +79,14 @@ private void updateMode() { case DisplayMode.Simple: counter.Hide(); - break; case DisplayMode.Normal: - if (counter.Result.Type.IsBonus()) - { - counter.Hide(); - break; - } - - counter.Show(); + counter.FadeTo(counter.Result.Type.IsBonus() ? 0 : 1); break; case DisplayMode.All: counter.Show(); - break; default: diff --git a/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementTally.cs b/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementTally.cs index e6bc336b0b..d8eac309aa 100644 --- a/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementTally.cs +++ b/osu.Game/Screens/Play/HUD/JudgementCounter/JudgementTally.cs @@ -7,6 +7,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Game.Rulesets; +using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Scoring; namespace osu.Game.Screens.Play.HUD.JudgementCounter @@ -35,17 +36,14 @@ protected override void LoadComplete() { base.LoadComplete(); - scoreProcessor.NewJudgement += judgement => - { - foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type)) - result.ResultCount.Value++; - }; + scoreProcessor.NewJudgement += judgement => updateCount(judgement, false); + scoreProcessor.JudgementReverted += judgement => updateCount(judgement, true); + } - scoreProcessor.JudgementReverted += judgement => - { - foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type)) - result.ResultCount.Value--; - }; + private void updateCount(JudgementResult judgement, bool revert) + { + foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type)) + result.ResultCount.Value = revert ? result.ResultCount.Value - 1 : result.ResultCount.Value + 1; } } }