1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +08:00

Re-sync judgement counter display after replay frame reset

This commit is contained in:
Dean Herbert 2024-09-18 14:35:44 +09:00
parent c46e9cbce3
commit 8f49876fe7
No known key found for this signature in database

View File

@ -6,7 +6,6 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
@ -53,8 +52,40 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
{
base.LoadComplete();
scoreProcessor.OnResetFromReplayFrame += updateAllCounts;
scoreProcessor.NewJudgement += judgement => updateCount(judgement, false);
scoreProcessor.JudgementReverted += judgement => updateCount(judgement, true);
updateAllCounts();
}
private void updateAllCounts()
{
// This flow is made to handle cases of watching from the middle of a replay / spectating session.
//
// Once we get an initial state, we can rely on `NewJudgement` and `JudgementReverted`, so
// as a preemptive optimisation, only do a full re-sync if we have all-zero counts.
bool hasCounts = false;
foreach (var r in results)
{
if (r.Value.ResultCount.Value > 0)
{
hasCounts = true;
break;
}
}
if (hasCounts)
return;
foreach (var kvp in scoreProcessor.Statistics)
{
if (!results.TryGetValue(kvp.Key, out var count))
continue;
count.ResultCount.Value = kvp.Value;
}
}
private void updateCount(JudgementResult judgement, bool revert)