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
1 changed files with 16 additions and 5 deletions

View File

@ -88,6 +88,9 @@ public class Player : OsuScreen, IProvideCursor
private bool loadedSuccessfully => RulesetContainer?.Objects.Any() == true;
private bool allowRestart = true;
private bool exited = false;
[BackgroundDependencyLoader]
private void load(AudioManager audio, OsuConfigManager config, APIAccess api)
{
@ -208,10 +211,12 @@ private void load(AudioManager audio, OsuConfigManager config, APIAccess api)
new HotkeyRetryOverlay
{
Action = () => {
//we want to hide the hitrenderer immediately (looks better).
//we may be able to remove this once the mouse cursor trail is improved.
RulesetContainer?.Hide();
Restart();
if (allowRestart) {
//we want to hide the hitrenderer immediately (looks better).
//we may be able to remove this once the mouse cursor trail is improved.
RulesetContainer?.Hide();
Restart();
}
},
}
};
@ -266,6 +271,7 @@ private void initializeStoryboard(bool asyncLoad)
public void Restart()
{
exited = true;
sampleRestart?.Play();
ValidForResume = false;
RestartRequested?.Invoke();
@ -288,6 +294,11 @@ private void onCompletion()
{
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
{
Beatmap = Beatmap.Value.BeatmapInfo,
@ -295,7 +306,7 @@ private void onCompletion()
};
scoreProcessor.PopulateScore(score);
score.User = RulesetContainer.Replay?.User ?? api.LocalUser.Value;
Push(new Results(score));
if (!exited) Push(new Results(score));
});
}
}