Add step for adjusting editor clock rate in test scene

This commit is contained in:
Salman Ahmed 2022-05-28 04:05:33 +03:00
parent e12d188dad
commit 2fac710d4b
1 changed files with 10 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
@ -24,6 +25,8 @@ public abstract class EditorClockTestScene : OsuManualInputManagerTestScene
[Cached]
protected new readonly EditorClock Clock;
private readonly Bindable<double> frequencyAdjustment = new BindableDouble(1);
protected virtual bool ScrollUsingMouseWheel => true;
protected EditorClockTestScene()
@ -44,14 +47,21 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
protected override void LoadComplete()
{
base.LoadComplete();
Beatmap.BindValueChanged(beatmapChanged, true);
AddSliderStep("editor clock rate", 0.0, 2.0, 1.0, v => frequencyAdjustment.Value = v);
}
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
{
e.OldValue?.Track.RemoveAdjustment(AdjustableProperty.Frequency, frequencyAdjustment);
Clock.Beatmap = e.NewValue.Beatmap;
Clock.ChangeSource(e.NewValue.Track);
Clock.ProcessFrame();
e.NewValue.Track.AddAdjustment(AdjustableProperty.Frequency, frequencyAdjustment);
}
protected override void Update()