mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 19:45:06 +08:00
Merge pull request #782 from peppy/fix-fail-pause-conflict
Fix and simplify pause logic
This commit is contained in:
commit
55d4d83712
@ -1 +1 @@
|
|||||||
Subproject commit 67f39580365f7d0a42f8788eae2b60881dde1c67
|
Subproject commit f8e5b10f6883af83ffbc431b03fe4ee3e89797a6
|
@ -38,7 +38,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public Action RestartRequested;
|
public Action RestartRequested;
|
||||||
|
|
||||||
public bool IsPaused => !decoupledClock.IsRunning;
|
public bool IsPaused { get; private set; }
|
||||||
|
|
||||||
internal override bool AllowRulesetChange => false;
|
internal override bool AllowRulesetChange => false;
|
||||||
|
|
||||||
@ -264,19 +264,18 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (!canPause && !force) return;
|
if (!canPause && !force) return;
|
||||||
|
|
||||||
// the actual pausing is potentially happening on a different thread.
|
if (IsPaused) return;
|
||||||
// we want to wait for the source clock to stop so we can be sure all components are in a stable state.
|
|
||||||
if (!IsPaused)
|
|
||||||
{
|
|
||||||
decoupledClock.Stop();
|
|
||||||
|
|
||||||
Schedule(() => Pause(force));
|
// stop the decoupled clock (stops the audio eventually)
|
||||||
return;
|
decoupledClock.Stop();
|
||||||
}
|
|
||||||
|
// stop processing updatess on the offset clock (instantly freezes time for all our components)
|
||||||
|
offsetClock.ProcessSourceClockFrames = false;
|
||||||
|
|
||||||
|
IsPaused = true;
|
||||||
|
|
||||||
// we need to do a final check after all of our children have processed up to the paused clock time.
|
// we need to do a final check after all of our children have processed up to the paused clock time.
|
||||||
// this is to cover cases where, for instance, the player fails in the last processed frame (which would change canPause).
|
// this is to cover cases where, for instance, the player fails in the current processing frame.
|
||||||
// as the scheduler runs before children updates, let's schedule for the next frame.
|
|
||||||
Schedule(() =>
|
Schedule(() =>
|
||||||
{
|
{
|
||||||
if (!canPause) return;
|
if (!canPause) return;
|
||||||
@ -291,6 +290,11 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public void Resume()
|
public void Resume()
|
||||||
{
|
{
|
||||||
|
if (!IsPaused) return;
|
||||||
|
|
||||||
|
IsPaused = false;
|
||||||
|
offsetClock.ProcessSourceClockFrames = true;
|
||||||
|
|
||||||
lastPauseActionTime = Time.Current;
|
lastPauseActionTime = Time.Current;
|
||||||
hudOverlay.KeyCounter.IsCounting = true;
|
hudOverlay.KeyCounter.IsCounting = true;
|
||||||
hudOverlay.Progress.Hide();
|
hudOverlay.Progress.Hide();
|
||||||
|
Loading…
Reference in New Issue
Block a user