1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Simplify pause handling by moving transform logic to bindable change event

This commit is contained in:
Dean Herbert 2020-12-10 17:42:47 +09:00
parent 679a550d83
commit 01bd765384

View File

@ -95,6 +95,16 @@ namespace osu.Game.Screens.Play
localGameplayClock = new LocalGameplayClock(userOffsetClock); localGameplayClock = new LocalGameplayClock(userOffsetClock);
GameplayClock.IsPaused.BindTo(IsPaused); GameplayClock.IsPaused.BindTo(IsPaused);
IsPaused.BindValueChanged(onPaused);
}
private void onPaused(ValueChangedEvent<bool> isPaused)
{
if (isPaused.NewValue)
this.TransformBindableTo(pauseFreqAdjust, 0, 200, Easing.Out).OnComplete(_ => adjustableClock.Stop());
else
this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In);
} }
private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset; private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset;
@ -160,9 +170,9 @@ namespace osu.Game.Screens.Play
// This accounts for the audio clock source potentially taking time to enter a completely stopped state // This accounts for the audio clock source potentially taking time to enter a completely stopped state
Seek(GameplayClock.CurrentTime); Seek(GameplayClock.CurrentTime);
this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In);
adjustableClock.Start(); adjustableClock.Start();
} }
IsPaused.Value = false; IsPaused.Value = false;
} }
@ -202,8 +212,6 @@ namespace osu.Game.Screens.Play
public void Stop() public void Stop()
{ {
this.TransformBindableTo(pauseFreqAdjust, 0, 200, Easing.Out).OnComplete(_ => adjustableClock.Stop());
IsPaused.Value = true; IsPaused.Value = true;
} }