Simplify state changes further

This commit is contained in:
Dean Herbert 2020-10-28 15:32:20 +09:00
parent c9515653b3
commit 2b1e79a4e8

View File

@ -120,7 +120,12 @@ namespace osu.Game.Rulesets.UI
applyFrameStability(ref proposedTime); applyFrameStability(ref proposedTime);
if (hasReplayAttached) if (hasReplayAttached)
state = updateReplay(ref proposedTime); {
bool valid = updateReplay(ref proposedTime);
if (!valid)
state = PlaybackState.NotValid;
}
if (proposedTime != manualClock.CurrentTime) if (proposedTime != manualClock.CurrentTime)
direction = proposedTime > manualClock.CurrentTime ? 1 : -1; direction = proposedTime > manualClock.CurrentTime ? 1 : -1;
@ -132,8 +137,8 @@ namespace osu.Game.Rulesets.UI
double timeBehind = Math.Abs(manualClock.CurrentTime - parentGameplayClock.CurrentTime); double timeBehind = Math.Abs(manualClock.CurrentTime - parentGameplayClock.CurrentTime);
// determine whether catch-up is required. // determine whether catch-up is required.
if (state != PlaybackState.NotValid) if (state == PlaybackState.Valid && timeBehind > 0)
state = timeBehind > 0 ? PlaybackState.RequiresCatchUp : PlaybackState.Valid; state = PlaybackState.RequiresCatchUp;
frameStableClock.IsCatchingUp.Value = timeBehind > 200; frameStableClock.IsCatchingUp.Value = timeBehind > 200;
@ -146,7 +151,8 @@ namespace osu.Game.Rulesets.UI
/// Attempt to advance replay playback for a given time. /// Attempt to advance replay playback for a given time.
/// </summary> /// </summary>
/// <param name="proposedTime">The time which is to be displayed.</param> /// <param name="proposedTime">The time which is to be displayed.</param>
private PlaybackState updateReplay(ref double proposedTime) /// <returns>Whether playback is still valid.</returns>
private bool updateReplay(ref double proposedTime)
{ {
double? newTime; double? newTime;
@ -172,10 +178,10 @@ namespace osu.Game.Rulesets.UI
} }
if (newTime == null) if (newTime == null)
return PlaybackState.NotValid; return false;
proposedTime = newTime.Value; proposedTime = newTime.Value;
return PlaybackState.Valid; return true;
} }
/// <summary> /// <summary>