mirror of
https://github.com/ppy/osu
synced 2025-04-17 20:45:49 +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>
|
/// <returns>The input manager.</returns>
|
||||||
public abstract PassThroughInputManager CreateInputManager();
|
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 virtual ReplayInputHandler CreateReplayInputHandler(Replay replay) => null;
|
||||||
|
|
||||||
protected FrameStabilityContainer FrameStabilityContainer;
|
protected FrameStabilityContainer FrameStabilityContainer;
|
||||||
|
@ -352,8 +352,10 @@ namespace osu.Game.Screens.Play
|
|||||||
&& !HasFailed
|
&& !HasFailed
|
||||||
// cannot pause if already paused (and not in the process of resuming)
|
// cannot pause if already paused (and not in the process of resuming)
|
||||||
&& (GameplayClockContainer.IsPaused.Value == false || IsResuming)
|
&& (GameplayClockContainer.IsPaused.Value == false || IsResuming)
|
||||||
// cannot pause too soon after previous pause
|
&& (!pauseCooldownActive || IsResuming);
|
||||||
&& (!lastPauseActionTime.HasValue || GameplayClockContainer.GameplayClock.CurrentTime >= lastPauseActionTime + pause_cooldown);
|
|
||||||
|
private bool pauseCooldownActive =>
|
||||||
|
lastPauseActionTime.HasValue && GameplayClockContainer.GameplayClock.CurrentTime < lastPauseActionTime + pause_cooldown;
|
||||||
|
|
||||||
private bool canResume =>
|
private bool canResume =>
|
||||||
// cannot resume from a non-paused state
|
// cannot resume from a non-paused state
|
||||||
@ -376,6 +378,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (!canPause) return;
|
if (!canPause) return;
|
||||||
|
|
||||||
|
IsResuming = false;
|
||||||
GameplayClockContainer.Stop();
|
GameplayClockContainer.Stop();
|
||||||
PauseOverlay.Show();
|
PauseOverlay.Show();
|
||||||
lastPauseActionTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
lastPauseActionTime = GameplayClockContainer.GameplayClock.CurrentTime;
|
||||||
@ -385,13 +388,21 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (!canResume) return;
|
if (!canResume) return;
|
||||||
|
|
||||||
//todo: add resume request support to ruleset
|
|
||||||
IsResuming = true;
|
IsResuming = true;
|
||||||
|
|
||||||
GameplayClockContainer.Start();
|
|
||||||
PauseOverlay.Hide();
|
PauseOverlay.Hide();
|
||||||
|
|
||||||
|
// 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;
|
IsResuming = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -445,6 +456,10 @@ namespace osu.Game.Screens.Play
|
|||||||
return true;
|
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();
|
GameplayClockContainer.ResetLocalAdjustments();
|
||||||
|
|
||||||
fadeOut();
|
fadeOut();
|
||||||
|
Loading…
Reference in New Issue
Block a user