1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:52:54 +08:00

use GameplayClock.IsPaused bindable instead of polling in Update

This commit is contained in:
Nitrous 2024-01-09 15:18:21 +08:00
parent afa808695b
commit 99c7685495
No known key found for this signature in database
GPG Key ID: A5D82BAEC7C1D1F5

View File

@ -32,6 +32,8 @@ namespace osu.Game.Screens.Play.PlayerSettings
private readonly IconButton play;
private readonly BindableBool isPaused = new BindableBool();
[Resolved]
private GameplayClockContainer? gameplayClock { get; set; }
@ -134,6 +136,8 @@ namespace osu.Game.Screens.Play.PlayerSettings
},
};
isPaused.BindValueChanged(e => play.Icon = e.NewValue ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle, true);
void seek(int direction, double amount)
{
double target = Math.Clamp((gameplayClock?.CurrentTime ?? 0) + (direction * amount), 0, gameplayState?.Beatmap.GetLastObjectTime() ?? 0);
@ -145,12 +149,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
{
base.LoadComplete();
rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true);
}
protected override void Update()
{
base.Update();
play.Icon = gameplayClock?.IsRunning == true ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle;
gameplayClock?.IsPaused.BindTo(isPaused);
}
}
}