Add sane pausing logic

This commit is contained in:
Dean Herbert 2020-10-27 18:13:45 +09:00
parent 9e6b0a42ec
commit 851d45d2eb
3 changed files with 22 additions and 0 deletions

View File

@ -101,6 +101,13 @@ public override bool UpdateSubTree()
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 @@ private void updateClock()
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 @@ private class FrameStabilityClock : GameplayClock, IFrameStableClock
public readonly Bindable<bool> IsCatchingUp = new Bindable<bool>();
public readonly Bindable<bool> WaitingOnFrames = new Bindable<bool>();
public override IEnumerable<Bindable<double>> NonGameplayAdjustments => ParentGameplayClock?.NonGameplayAdjustments ?? Enumerable.Empty<Bindable<double>>();
public FrameStabilityClock(FramedClock underlyingClock)
@ -239,6 +249,8 @@ public FrameStabilityClock(FramedClock underlyingClock)
}
IBindable<bool> IFrameStableClock.IsCatchingUp => IsCatchingUp;
IBindable<bool> IFrameStableClock.WaitingOnFrames => WaitingOnFrames;
}
}
}

View File

@ -9,5 +9,7 @@ namespace osu.Game.Rulesets.UI
public interface IFrameStableClock : IFrameBasedClock
{
IBindable<bool> IsCatchingUp { get; }
IBindable<bool> WaitingOnFrames { get; }
}
}

View File

@ -238,6 +238,14 @@ private void load(AudioManager audio, OsuConfigManager config, OsuGame game)
skipOverlay.Hide();
}
DrawableRuleset.FrameStableClock.WaitingOnFrames.BindValueChanged(waiting =>
{
if (waiting.NewValue)
GameplayClockContainer.Stop();
else
GameplayClockContainer.Start();
});
DrawableRuleset.IsPaused.BindValueChanged(paused =>
{
updateGameplayState();