mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
Add resume requesting support and fix exit scenarios
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user