mirror of
https://github.com/ppy/osu
synced 2024-12-12 18:07:52 +00:00
4df7ff21c7
The editor clock, which is responsible for performing the seek, was not aware of changes in control points due to reading from the wrong beatmap. `loadableBeatmap` is not actually changed by any of the editor components; `playableBeatmap` and `editorBeatmap` are. For now this is changed to use `playableBeatmap`. A better follow-up would be to use `editorBeatmap`, but it would probably be best to move the beat snap bindable into `EditorBeatmap` first.
74 lines
2.3 KiB
C#
74 lines
2.3 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Bindables;
|
|
using osu.Framework.Input.Events;
|
|
using osu.Framework.Timing;
|
|
using osu.Game.Beatmaps;
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
using osu.Game.Screens.Edit;
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
{
|
|
/// <summary>
|
|
/// Provides a clock, beat-divisor, and scrolling capability for test cases of editor components that
|
|
/// are preferrably tested within the presence of a clock and seek controls.
|
|
/// </summary>
|
|
public abstract class EditorClockTestScene : OsuManualInputManagerTestScene
|
|
{
|
|
protected readonly BindableBeatDivisor BeatDivisor = new BindableBeatDivisor();
|
|
protected new readonly EditorClock Clock;
|
|
|
|
protected virtual bool ScrollUsingMouseWheel => true;
|
|
|
|
protected EditorClockTestScene()
|
|
{
|
|
Clock = new EditorClock(new ControlPointInfo(), BeatDivisor) { IsCoupled = false };
|
|
}
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
{
|
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
|
|
dependencies.Cache(BeatDivisor);
|
|
dependencies.CacheAs(Clock);
|
|
|
|
return dependencies;
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
Beatmap.BindValueChanged(beatmapChanged, true);
|
|
}
|
|
|
|
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
|
|
{
|
|
Clock.ControlPointInfo = e.NewValue.Beatmap.ControlPointInfo;
|
|
Clock.ChangeSource((IAdjustableClock)e.NewValue.Track ?? new StopwatchClock());
|
|
Clock.ProcessFrame();
|
|
}
|
|
|
|
protected override void Update()
|
|
{
|
|
base.Update();
|
|
|
|
Clock.ProcessFrame();
|
|
}
|
|
|
|
protected override bool OnScroll(ScrollEvent e)
|
|
{
|
|
if (!ScrollUsingMouseWheel)
|
|
return false;
|
|
|
|
if (e.ScrollDelta.Y > 0)
|
|
Clock.SeekBackward(true);
|
|
else
|
|
Clock.SeekForward(true);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|