mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 15:33:05 +08:00
Simplify pause handling by moving transform logic to bindable change event
This commit is contained in:
parent
679a550d83
commit
01bd765384
@ -95,6 +95,16 @@ namespace osu.Game.Screens.Play
|
||||
localGameplayClock = new LocalGameplayClock(userOffsetClock);
|
||||
|
||||
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;
|
||||
@ -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
|
||||
Seek(GameplayClock.CurrentTime);
|
||||
|
||||
this.TransformBindableTo(pauseFreqAdjust, 1, 200, Easing.In);
|
||||
adjustableClock.Start();
|
||||
}
|
||||
|
||||
IsPaused.Value = false;
|
||||
}
|
||||
|
||||
@ -202,8 +212,6 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
this.TransformBindableTo(pauseFreqAdjust, 0, 200, Easing.Out).OnComplete(_ => adjustableClock.Stop());
|
||||
|
||||
IsPaused.Value = true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user