Fixed tilde-key crash at end of beatmap.

This commit is contained in:
Michael Manis 2018-01-21 20:09:44 -05:00
parent 64c32f5715
commit ad2df8d8df

View File

@ -88,6 +88,9 @@ namespace osu.Game.Screens.Play
private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true; private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true;
private bool allowRestart = true;
private bool exited = false;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio, OsuConfigManager config, APIAccess api) private void load(AudioManager audio, OsuConfigManager config, APIAccess api)
{ {
@ -208,10 +211,12 @@ namespace osu.Game.Screens.Play
new HotkeyRetryOverlay new HotkeyRetryOverlay
{ {
Action = () => { Action = () => {
//we want to hide the hitrenderer immediately (looks better). if (allowRestart) {
//we may be able to remove this once the mouse cursor trail is improved. //we want to hide the hitrenderer immediately (looks better).
RulesetContainer?.Hide(); //we may be able to remove this once the mouse cursor trail is improved.
Restart(); RulesetContainer?.Hide();
Restart();
}
}, },
} }
}; };
@ -266,6 +271,7 @@ namespace osu.Game.Screens.Play
public void Restart() public void Restart()
{ {
exited = true;
sampleRestart?.Play(); sampleRestart?.Play();
ValidForResume = false; ValidForResume = false;
RestartRequested?.Invoke(); RestartRequested?.Invoke();
@ -288,6 +294,11 @@ namespace osu.Game.Screens.Play
{ {
onCompletionEvent = Schedule(delegate onCompletionEvent = Schedule(delegate
{ {
// This is here to mimic OsuStable behavior. It could be placed outside the delay timer,
// which would remove the need for the check on Push() below, and would make it impossible
// to quick-restart after hitting the last note.
allowRestart = false;
var score = new Score var score = new Score
{ {
Beatmap = Beatmap.Value.BeatmapInfo, Beatmap = Beatmap.Value.BeatmapInfo,
@ -295,7 +306,7 @@ namespace osu.Game.Screens.Play
}; };
scoreProcessor.PopulateScore(score); scoreProcessor.PopulateScore(score);
score.User = RulesetContainer.Replay?.User ?? api.LocalUser.Value; score.User = RulesetContainer.Replay?.User ?? api.LocalUser.Value;
Push(new Results(score)); if (!exited) Push(new Results(score));
}); });
} }
} }