mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
use GameplayClock.IsPaused
bindable instead of polling in Update
This commit is contained in:
parent
afa808695b
commit
99c7685495
@ -32,6 +32,8 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
|
|
||||||
private readonly IconButton play;
|
private readonly IconButton play;
|
||||||
|
|
||||||
|
private readonly BindableBool isPaused = new BindableBool();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameplayClockContainer? gameplayClock { get; set; }
|
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)
|
void seek(int direction, double amount)
|
||||||
{
|
{
|
||||||
double target = Math.Clamp((gameplayClock?.CurrentTime ?? 0) + (direction * amount), 0, gameplayState?.Beatmap.GetLastObjectTime() ?? 0);
|
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();
|
base.LoadComplete();
|
||||||
rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true);
|
rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true);
|
||||||
}
|
gameplayClock?.IsPaused.BindTo(isPaused);
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
play.Icon = gameplayClock?.IsRunning == true ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user