mirror of
https://github.com/ppy/osu
synced 2025-03-11 05:49:12 +00:00
Add resume requesting support and fix exit scenarios
This commit is contained in:
parent
536b5e0dab
commit
9433a97747
@ -130,6 +130,13 @@ namespace osu.Game.Rulesets.UI
|
||||
/// <returns>The input manager.</returns>
|
||||
public abstract PassThroughInputManager CreateInputManager();
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the interactive user requests resuming from a paused state.
|
||||
/// Allows potentially delaying the resume process until an interaction is performed.
|
||||
/// </summary>
|
||||
/// <param name="continueResume">The action to run when resuming is to be completed.</param>
|
||||
public void RequestResume(Action continueResume) => continueResume();
|
||||
|
||||
protected virtual ReplayInputHandler CreateReplayInputHandler(Replay replay) => null;
|
||||
|
||||
protected FrameStabilityContainer FrameStabilityContainer;
|
||||
|
@ -352,8 +352,10 @@ namespace osu.Game.Screens.Play
|
||||
&& !HasFailed
|
||||
// cannot pause if already paused (and not in the process of resuming)
|
||||
&& (GameplayClockContainer.IsPaused.Value == false || IsResuming)
|
||||
// cannot pause too soon after previous pause
|
||||
&& (!lastPauseActionTime.HasValue || GameplayClockContainer.GameplayClock.CurrentTime >= lastPauseActionTime + pause_cooldown);
|
||||
&& (!pauseCooldownActive || IsResuming);
|
||||
|
||||
private bool pauseCooldownActive =>
|
||||
lastPauseActionTime.HasValue && GameplayClockContainer.GameplayClock.CurrentTime < lastPauseActionTime + pause_cooldown;
|
||||
|
||||
private bool canResume =>
|
||||
// cannot resume from a non-paused state
|
||||
@ -376,6 +378,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (!canPause) return;
|
||||
|
||||
IsResuming = false;
|
||||
GameplayClockContainer.Stop();
|
||||
PauseOverlay.Show();
|
||||
lastPauseActionTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
||||
@ -385,12 +388,20 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (!canResume) return;
|
||||
|
||||
//todo: add resume request support to ruleset
|
||||
IsResuming = true;
|
||||
|
||||
GameplayClockContainer.Start();
|
||||
PauseOverlay.Hide();
|
||||
IsResuming = false;
|
||||
|
||||
// time-based conditions may allow instant resume.
|
||||
if (GameplayClockContainer.GameplayClock.CurrentTime < Beatmap.Value.Beatmap.HitObjects.First().StartTime)
|
||||
completeResume();
|
||||
else
|
||||
RulesetContainer.RequestResume(completeResume);
|
||||
|
||||
void completeResume()
|
||||
{
|
||||
GameplayClockContainer.Start();
|
||||
IsResuming = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -445,6 +456,10 @@ namespace osu.Game.Screens.Play
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pauseCooldownActive && !GameplayClockContainer.IsPaused.Value)
|
||||
// still want to block if we are within the cooldown period and not already paused.
|
||||
return true;
|
||||
|
||||
GameplayClockContainer.ResetLocalAdjustments();
|
||||
|
||||
fadeOut();
|
||||
|
Loading…
Reference in New Issue
Block a user