mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 02:42:54 +08:00
Handle judgement reverts with actual display updates
This commit is contained in:
parent
0859c336de
commit
98fef6ece2
@ -63,6 +63,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestBasicCounting()
|
public void TestBasicCounting()
|
||||||
{
|
{
|
||||||
|
int previousValue = 0;
|
||||||
|
|
||||||
AddAssert("counter displaying zero", () => counter.Current.Value == 0);
|
AddAssert("counter displaying zero", () => counter.Current.Value == 0);
|
||||||
|
|
||||||
AddRepeatStep("Add judgement", applyOneJudgement, 10);
|
AddRepeatStep("Add judgement", applyOneJudgement, 10);
|
||||||
@ -72,14 +74,16 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddStep("Revert judgement", () =>
|
AddStep("Revert judgement", () =>
|
||||||
{
|
{
|
||||||
|
previousValue = counter.Current.Value;
|
||||||
|
|
||||||
scoreProcessor.RevertResult(new JudgementResult(new HitObject(), new OsuJudgement()));
|
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);
|
AddStep("Add judgement", applyOneJudgement);
|
||||||
|
|
||||||
AddUntilStep("counter opaque", () => counter.Child.Alpha == 1);
|
AddUntilStep("counter non-zero", () => counter.Current.Value > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyOneJudgement()
|
private void applyOneJudgement()
|
||||||
|
@ -74,7 +74,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
timedAttributes = r.Result;
|
timedAttributes = r.Result;
|
||||||
IsValid = true;
|
IsValid = true;
|
||||||
if (lastJudgement != null)
|
if (lastJudgement != null)
|
||||||
onNewJudgement(lastJudgement);
|
onJudgementChanged(lastJudgement);
|
||||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,8 +85,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
if (scoreProcessor != null)
|
if (scoreProcessor != null)
|
||||||
{
|
{
|
||||||
scoreProcessor.NewJudgement += onNewJudgement;
|
scoreProcessor.NewJudgement += onJudgementChanged;
|
||||||
scoreProcessor.JudgementReverted += onJudgementReverted;
|
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;
|
lastJudgement = judgement;
|
||||||
|
|
||||||
var attrib = getAttributeAtTime(judgement);
|
var attrib = getAttributeAtTime(judgement);
|
||||||
|
|
||||||
if (gameplayState == null || attrib == null)
|
if (gameplayState == null || attrib == null)
|
||||||
|
{
|
||||||
|
IsValid = false;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var calculator = gameplayState.Ruleset.CreatePerformanceCalculator(attrib, gameplayState.Score.ScoreInfo);
|
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;
|
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 LocalisableString FormatCount(int count) => count.ToString(@"D");
|
||||||
|
|
||||||
protected override IHasText CreateText() => new TextComponent
|
protected override IHasText CreateText() => new TextComponent
|
||||||
@ -146,7 +147,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (scoreProcessor != null)
|
if (scoreProcessor != null)
|
||||||
scoreProcessor.NewJudgement -= onNewJudgement;
|
scoreProcessor.NewJudgement -= onJudgementChanged;
|
||||||
|
|
||||||
loadCancellationSource?.Cancel();
|
loadCancellationSource?.Cancel();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user