1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 10:02:59 +08:00

Use cleaner solution via cancellation of older schedule

This commit is contained in:
Dean Herbert 2019-12-26 19:05:32 +09:00
parent 8903f286ef
commit a041f32072

View File

@ -350,18 +350,7 @@ namespace osu.Game.Screens.Play
if (!showResults) return; if (!showResults) return;
using (BeginDelayedSequence(1000)) using (BeginDelayedSequence(1000))
{ scheduleGotoRanking();
completionProgressDelegate = Schedule(delegate
{
if (!this.IsCurrentScreen()) return;
var score = CreateScore();
if (DrawableRuleset.ReplayScore == null)
scoreManager.Import(score).Wait();
this.Push(CreateResults(score));
});
}
} }
protected virtual ScoreInfo CreateScore() protected virtual ScoreInfo CreateScore()
@ -541,14 +530,8 @@ namespace osu.Game.Screens.Play
{ {
if (completionProgressDelegate != null && !completionProgressDelegate.Cancelled && !completionProgressDelegate.Completed) if (completionProgressDelegate != null && !completionProgressDelegate.Cancelled && !completionProgressDelegate.Completed)
{ {
// Proceed to result screen if beatmap already finished playing. // proceed to result screen if beatmap already finished playing
// This is scheduled since the player needs to become the current screen before the delegate runs. This happens after the return true. scheduleGotoRanking();
Scheduler.Add(() =>
{
if (!completionProgressDelegate.Completed && !completionProgressDelegate.Cancelled)
completionProgressDelegate.RunTask();
});
return true; return true;
} }
@ -583,6 +566,19 @@ namespace osu.Game.Screens.Play
storyboardReplacesBackground.Value = false; storyboardReplacesBackground.Value = false;
} }
private void scheduleGotoRanking()
{
completionProgressDelegate?.Cancel();
completionProgressDelegate = Schedule(delegate
{
var score = CreateScore();
if (DrawableRuleset.ReplayScore == null)
scoreManager.Import(score).Wait();
this.Push(CreateResults(score));
});
}
#endregion #endregion
} }
} }