Handle judgement reverts with actual display updates

This commit is contained in:
Dean Herbert 2021-10-05 19:08:30 +09:00
parent 0859c336de
commit 98fef6ece2
2 changed files with 14 additions and 9 deletions

View File

@ -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()

View File

@ -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();
}