Pass adjustable clocks to components, rather than relying on the track

This commit is contained in:
smoogipoo
2018-03-15 18:08:37 +09:00
parent c8f6a6980b
commit d05947ef48
6 changed files with 33 additions and 24 deletions

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Timing;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
@ -19,8 +20,12 @@ namespace osu.Game.Screens.Edit.Components
{
private readonly IconButton playButton;
public PlaybackControl()
private readonly IAdjustableClock adjustableClock;
public PlaybackControl(IAdjustableClock adjustableClock)
{
this.adjustableClock = adjustableClock;
PlaybackTabControl tabs;
Children = new Drawable[]
@ -54,22 +59,22 @@ namespace osu.Game.Screens.Edit.Components
}
};
tabs.Current.ValueChanged += newValue => Track.Tempo.Value = newValue;
tabs.Current.ValueChanged += newValue => Beatmap.Value.Track.Tempo.Value = newValue;
}
private void togglePause()
{
if (Track.IsRunning)
Track.Stop();
if (adjustableClock.IsRunning)
adjustableClock.Stop();
else
Track.Start();
adjustableClock.Start();
}
protected override void Update()
{
base.Update();
playButton.Icon = Track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
playButton.Icon = adjustableClock.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
}
private class PlaybackTabControl : OsuTabControl<double>