Modify flow to avoid weird bindable and value resetting

This commit is contained in:
Dean Herbert
2022-08-16 13:04:56 +09:00
parent c9baadcf88
commit 6761f869f9
4 changed files with 14 additions and 26 deletions

View File

@ -77,15 +77,10 @@ namespace osu.Game.Screens.Play
/// </summary>
protected virtual bool PauseOnFocusLost => true;
public Action RestartRequested;
public Action<bool> RestartRequested;
private bool isRestarting;
/// <summary>
/// Is set to true when the quick retry hotkey has been pressed.
/// </summary>
public Bindable<bool> IsQuickRestart = new Bindable<bool>();
private Bindable<bool> mouseWheelDisabled;
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
@ -272,7 +267,7 @@ namespace osu.Game.Screens.Play
FailOverlay = new FailOverlay
{
SaveReplay = prepareAndImportScore,
OnRetry = Restart,
OnRetry = () => Restart(),
OnQuit = () => PerformExit(true),
},
new HotkeyExitOverlay
@ -298,9 +293,8 @@ namespace osu.Game.Screens.Play
{
if (!this.IsCurrentScreen()) return;
IsQuickRestart.Value = true;
fadeOut(true);
Restart();
Restart(true);
},
});
}
@ -453,7 +447,7 @@ namespace osu.Game.Screens.Play
{
OnResume = Resume,
Retries = RestartCount,
OnRetry = Restart,
OnRetry = () => Restart(),
OnQuit = () => PerformExit(true),
},
},
@ -660,7 +654,8 @@ namespace osu.Game.Screens.Play
/// Restart gameplay via a parent <see cref="PlayerLoader"/>.
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>
/// </summary>
public void Restart()
/// <param name="quickRestart">Whether a quick restart was requested (skipping intro etc.).</param>
public void Restart(bool quickRestart = false)
{
if (!Configuration.AllowRestart)
return;
@ -672,7 +667,7 @@ namespace osu.Game.Screens.Play
musicController.Stop();
sampleRestart?.Play();
RestartRequested?.Invoke();
RestartRequested?.Invoke(quickRestart);
PerformExit(false);
}
@ -852,7 +847,7 @@ namespace osu.Game.Screens.Play
failAnimationLayer.Start();
if (GameplayState.Mods.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
Restart();
Restart(true);
return true;
}