diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs index c7d2204de2..4c48d52acd 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs @@ -63,6 +63,8 @@ namespace osu.Game.Tests.Visual.Gameplay [Test] public void TestBasicCounting() { + int previousValue = 0; + AddAssert("counter displaying zero", () => counter.Current.Value == 0); AddRepeatStep("Add judgement", applyOneJudgement, 10); @@ -72,14 +74,16 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("Revert judgement", () => { + previousValue = counter.Current.Value; + scoreProcessor.RevertResult(new JudgementResult(new HitObject(), new OsuJudgement())); }); - AddUntilStep("counter faded", () => counter.Child.Alpha < 1); + AddUntilStep("counter decreased", () => counter.Current.Value < previousValue); AddStep("Add judgement", applyOneJudgement); - AddUntilStep("counter opaque", () => counter.Child.Alpha == 1); + AddUntilStep("counter non-zero", () => counter.Current.Value > 0); } private void applyOneJudgement() diff --git a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs index 9eac62fe73..2ae7b5660a 100644 --- a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs @@ -74,7 +74,7 @@ namespace osu.Game.Screens.Play.HUD timedAttributes = r.Result; IsValid = true; if (lastJudgement != null) - onNewJudgement(lastJudgement); + onJudgementChanged(lastJudgement); }), TaskContinuationOptions.OnlyOnRanToCompletion); } } @@ -85,8 +85,8 @@ namespace osu.Game.Screens.Play.HUD if (scoreProcessor != null) { - scoreProcessor.NewJudgement += onNewJudgement; - scoreProcessor.JudgementReverted += onJudgementReverted; + scoreProcessor.NewJudgement += onJudgementChanged; + scoreProcessor.JudgementReverted += onJudgementChanged; } } @@ -104,14 +104,17 @@ namespace osu.Game.Screens.Play.HUD } } - private void onNewJudgement(JudgementResult judgement) + private void onJudgementChanged(JudgementResult judgement) { lastJudgement = judgement; var attrib = getAttributeAtTime(judgement); if (gameplayState == null || attrib == null) + { + IsValid = false; return; + } var calculator = gameplayState.Ruleset.CreatePerformanceCalculator(attrib, gameplayState.Score.ScoreInfo); @@ -132,8 +135,6 @@ namespace osu.Game.Screens.Play.HUD return timedAttributes[Math.Clamp(attribIndex, 0, timedAttributes.Count - 1)].Attributes; } - private void onJudgementReverted(JudgementResult obj) => IsValid = false; - protected override LocalisableString FormatCount(int count) => count.ToString(@"D"); protected override IHasText CreateText() => new TextComponent @@ -146,7 +147,7 @@ namespace osu.Game.Screens.Play.HUD base.Dispose(isDisposing); if (scoreProcessor != null) - scoreProcessor.NewJudgement -= onNewJudgement; + scoreProcessor.NewJudgement -= onJudgementChanged; loadCancellationSource?.Cancel(); }