From 851d45d2ebea669f18243e924956a6ab7e0ea695 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Oct 2020 18:13:45 +0900 Subject: [PATCH] Add sane pausing logic --- osu.Game/Rulesets/UI/FrameStabilityContainer.cs | 12 ++++++++++++ osu.Game/Rulesets/UI/IFrameStableClock.cs | 2 ++ osu.Game/Screens/Play/Player.cs | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs index fb6c7d4c17..987dca7073 100644 --- a/osu.Game/Rulesets/UI/FrameStabilityContainer.cs +++ b/osu.Game/Rulesets/UI/FrameStabilityContainer.cs @@ -101,6 +101,13 @@ namespace osu.Game.Rulesets.UI int loops = 0; + if (frameStableClock.WaitingOnFrames.Value) + { + // for now, force one update loop to check if frames have arrived + // this may have to change in the future where we want stable user pausing during replay playback. + validState = true; + } + while (validState && requireMoreUpdateLoops && loops++ < MaxCatchUpFrames) { updateClock(); @@ -203,6 +210,7 @@ namespace osu.Game.Rulesets.UI requireMoreUpdateLoops |= timeBehind != 0; frameStableClock.IsCatchingUp.Value = timeBehind > 200; + frameStableClock.WaitingOnFrames.Value = !validState; // The manual clock time has changed in the above code. The framed clock now needs to be updated // to ensure that the its time is valid for our children before input is processed @@ -231,6 +239,8 @@ namespace osu.Game.Rulesets.UI public readonly Bindable IsCatchingUp = new Bindable(); + public readonly Bindable WaitingOnFrames = new Bindable(); + public override IEnumerable> NonGameplayAdjustments => ParentGameplayClock?.NonGameplayAdjustments ?? Enumerable.Empty>(); public FrameStabilityClock(FramedClock underlyingClock) @@ -239,6 +249,8 @@ namespace osu.Game.Rulesets.UI } IBindable IFrameStableClock.IsCatchingUp => IsCatchingUp; + + IBindable IFrameStableClock.WaitingOnFrames => WaitingOnFrames; } } } diff --git a/osu.Game/Rulesets/UI/IFrameStableClock.cs b/osu.Game/Rulesets/UI/IFrameStableClock.cs index d888eefdc6..c1d8733d26 100644 --- a/osu.Game/Rulesets/UI/IFrameStableClock.cs +++ b/osu.Game/Rulesets/UI/IFrameStableClock.cs @@ -9,5 +9,7 @@ namespace osu.Game.Rulesets.UI public interface IFrameStableClock : IFrameBasedClock { IBindable IsCatchingUp { get; } + + IBindable WaitingOnFrames { get; } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3c0c643413..3e79ea0840 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -238,6 +238,14 @@ namespace osu.Game.Screens.Play skipOverlay.Hide(); } + DrawableRuleset.FrameStableClock.WaitingOnFrames.BindValueChanged(waiting => + { + if (waiting.NewValue) + GameplayClockContainer.Stop(); + else + GameplayClockContainer.Start(); + }); + DrawableRuleset.IsPaused.BindValueChanged(paused => { updateGameplayState();