2019-01-24 08:43:03 +00:00
|
|
|
|
// 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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-04-06 09:12:44 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2022-05-28 01:05:33 +00:00
|
|
|
|
using osu.Framework.Audio;
|
2019-02-21 10:04:31 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2022-08-17 06:40:01 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-10-02 03:02:47 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-04-06 09:12:44 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2022-05-24 08:36:43 +00:00
|
|
|
|
using osu.Game.Overlays;
|
2018-04-06 09:12:44 +00:00
|
|
|
|
using osu.Game.Screens.Edit;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-04-06 09:12:44 +00:00
|
|
|
|
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>
|
2020-04-28 09:35:37 +00:00
|
|
|
|
public abstract partial class EditorClockTestScene : OsuManualInputManagerTestScene
|
2018-04-06 09:12:44 +00:00
|
|
|
|
{
|
2022-05-24 08:36:43 +00:00
|
|
|
|
[Cached]
|
|
|
|
|
private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
|
|
|
|
|
|
2018-04-06 09:12:44 +00:00
|
|
|
|
protected readonly BindableBeatDivisor BeatDivisor = new BindableBeatDivisor();
|
2022-05-26 09:30:37 +00:00
|
|
|
|
|
2022-08-17 06:40:01 +00:00
|
|
|
|
protected EditorClock EditorClock;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-05-28 01:05:33 +00:00
|
|
|
|
private readonly Bindable<double> frequencyAdjustment = new BindableDouble(1);
|
|
|
|
|
|
2022-08-17 06:40:01 +00:00
|
|
|
|
private IBeatmap editorClockBeatmap;
|
2020-09-30 07:39:02 +00:00
|
|
|
|
protected virtual bool ScrollUsingMouseWheel => true;
|
|
|
|
|
|
2022-08-17 06:40:01 +00:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
|
|
|
|
private readonly Container<Drawable> content = new Container { RelativeSizeAxes = Axes.Both };
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-07-11 08:07:14 +00:00
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
2018-06-12 10:51:35 +00:00
|
|
|
|
{
|
2018-07-11 08:07:14 +00:00
|
|
|
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
2018-06-12 10:51:35 +00:00
|
|
|
|
|
2022-08-17 06:40:01 +00:00
|
|
|
|
editorClockBeatmap = CreateEditorClockBeatmap();
|
|
|
|
|
|
|
|
|
|
base.Content.AddRange(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
EditorClock = new EditorClock(editorClockBeatmap, BeatDivisor),
|
|
|
|
|
content
|
|
|
|
|
});
|
|
|
|
|
|
2018-06-12 10:51:35 +00:00
|
|
|
|
dependencies.Cache(BeatDivisor);
|
2022-08-17 06:40:01 +00:00
|
|
|
|
dependencies.CacheAs(EditorClock);
|
2018-06-12 10:51:35 +00:00
|
|
|
|
|
|
|
|
|
return dependencies;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 04:22:55 +00:00
|
|
|
|
protected override void LoadComplete()
|
2018-04-06 09:12:44 +00:00
|
|
|
|
{
|
2022-08-17 06:40:01 +00:00
|
|
|
|
Beatmap.Value = CreateWorkingBeatmap(editorClockBeatmap);
|
|
|
|
|
|
2022-01-18 04:22:55 +00:00
|
|
|
|
base.LoadComplete();
|
2022-05-28 01:05:33 +00:00
|
|
|
|
|
2018-06-07 07:46:54 +00:00
|
|
|
|
Beatmap.BindValueChanged(beatmapChanged, true);
|
2022-05-28 01:05:33 +00:00
|
|
|
|
|
|
|
|
|
AddSliderStep("editor clock rate", 0.0, 2.0, 1.0, v => frequencyAdjustment.Value = v);
|
2018-04-06 09:12:44 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-08-17 06:40:01 +00:00
|
|
|
|
protected virtual IBeatmap CreateEditorClockBeatmap() => new Beatmap();
|
|
|
|
|
|
2019-02-21 09:56:34 +00:00
|
|
|
|
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
|
2018-04-06 10:14:04 +00:00
|
|
|
|
{
|
2022-05-28 01:05:33 +00:00
|
|
|
|
e.OldValue?.Track.RemoveAdjustment(AdjustableProperty.Frequency, frequencyAdjustment);
|
|
|
|
|
e.NewValue.Track.AddAdjustment(AdjustableProperty.Frequency, frequencyAdjustment);
|
2022-08-17 06:40:01 +00:00
|
|
|
|
EditorClock.ChangeSource(e.NewValue.Track);
|
2018-04-06 10:14:04 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-10-02 03:02:47 +00:00
|
|
|
|
protected override bool OnScroll(ScrollEvent e)
|
2018-04-06 09:12:44 +00:00
|
|
|
|
{
|
2020-09-30 07:39:02 +00:00
|
|
|
|
if (!ScrollUsingMouseWheel)
|
|
|
|
|
return false;
|
|
|
|
|
|
2018-09-19 11:52:57 +00:00
|
|
|
|
if (e.ScrollDelta.Y > 0)
|
2022-08-17 06:40:01 +00:00
|
|
|
|
EditorClock.SeekBackward(true);
|
2018-04-06 09:12:44 +00:00
|
|
|
|
else
|
2022-08-17 06:40:01 +00:00
|
|
|
|
EditorClock.SeekForward(true);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-04-06 09:12:44 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|