2019-01-24 17:43:03 +09: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 18:19:50 +09:00
|
|
|
|
|
2018-04-06 18:12:44 +09:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 19:04:31 +09:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-10-02 12:02:47 +09:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-04-06 18:12:44 +09:00
|
|
|
|
using osu.Game.Beatmaps;
|
2022-05-24 17:36:43 +09:00
|
|
|
|
using osu.Game.Overlays;
|
2018-04-06 18:12:44 +09:00
|
|
|
|
using osu.Game.Screens.Edit;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-04-06 18:12:44 +09: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 18:35:37 +09:00
|
|
|
|
public abstract class EditorClockTestScene : OsuManualInputManagerTestScene
|
2018-04-06 18:12:44 +09:00
|
|
|
|
{
|
2022-05-24 17:36:43 +09:00
|
|
|
|
[Cached]
|
|
|
|
|
private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
|
|
|
|
|
|
2018-04-06 18:12:44 +09:00
|
|
|
|
protected readonly BindableBeatDivisor BeatDivisor = new BindableBeatDivisor();
|
2019-04-25 17:36:17 +09:00
|
|
|
|
protected new readonly EditorClock Clock;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2020-09-30 16:39:02 +09:00
|
|
|
|
protected virtual bool ScrollUsingMouseWheel => true;
|
|
|
|
|
|
2019-05-14 22:37:25 +03:00
|
|
|
|
protected EditorClockTestScene()
|
2018-04-06 18:38:44 +09:00
|
|
|
|
{
|
2021-09-14 23:56:57 +09:00
|
|
|
|
Clock = new EditorClock(new Beatmap(), BeatDivisor) { IsCoupled = false };
|
2018-04-06 18:38:44 +09:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-07-11 17:07:14 +09:00
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
2018-06-12 19:51:35 +09:00
|
|
|
|
{
|
2018-07-11 17:07:14 +09:00
|
|
|
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
2018-06-12 19:51:35 +09:00
|
|
|
|
|
|
|
|
|
dependencies.Cache(BeatDivisor);
|
2020-05-22 16:37:28 +09:00
|
|
|
|
dependencies.CacheAs(Clock);
|
2018-06-12 19:51:35 +09:00
|
|
|
|
|
|
|
|
|
return dependencies;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 13:22:55 +09:00
|
|
|
|
protected override void LoadComplete()
|
2018-04-06 18:12:44 +09:00
|
|
|
|
{
|
2022-01-18 13:22:55 +09:00
|
|
|
|
base.LoadComplete();
|
2018-06-07 16:46:54 +09:00
|
|
|
|
Beatmap.BindValueChanged(beatmapChanged, true);
|
2018-04-06 18:12:44 +09:00
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2019-02-21 18:56:34 +09:00
|
|
|
|
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> e)
|
2018-04-06 19:14:04 +09:00
|
|
|
|
{
|
2021-09-14 23:56:57 +09:00
|
|
|
|
Clock.Beatmap = e.NewValue.Beatmap;
|
2021-05-07 09:53:54 +03:00
|
|
|
|
Clock.ChangeSource(e.NewValue.Track);
|
2018-04-06 19:14:04 +09:00
|
|
|
|
Clock.ProcessFrame();
|
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-04-06 19:14:04 +09:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-04-06 19:14:04 +09:00
|
|
|
|
Clock.ProcessFrame();
|
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-10-02 12:02:47 +09:00
|
|
|
|
protected override bool OnScroll(ScrollEvent e)
|
2018-04-06 18:12:44 +09:00
|
|
|
|
{
|
2020-09-30 16:39:02 +09:00
|
|
|
|
if (!ScrollUsingMouseWheel)
|
|
|
|
|
return false;
|
|
|
|
|
|
2018-09-19 20:52:57 +09:00
|
|
|
|
if (e.ScrollDelta.Y > 0)
|
2018-04-06 18:12:44 +09:00
|
|
|
|
Clock.SeekBackward(true);
|
|
|
|
|
else
|
|
|
|
|
Clock.SeekForward(true);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-04-06 18:12:44 +09:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|