2018-04-13 09:19:50 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
using osu.Game.Screens.Edit;
|
|
|
|
|
using osu.Game.Screens.Edit.Screens.Compose;
|
|
|
|
|
|
|
|
|
|
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 EditorClockTestCase : OsuTestCase
|
|
|
|
|
{
|
|
|
|
|
protected readonly BindableBeatDivisor BeatDivisor = new BindableBeatDivisor();
|
|
|
|
|
protected readonly EditorClock Clock;
|
|
|
|
|
|
|
|
|
|
protected EditorClockTestCase()
|
|
|
|
|
{
|
2018-05-08 13:37:06 +00:00
|
|
|
|
Clock = new EditorClock(new ControlPointInfo(), 5000, BeatDivisor) { IsCoupled = false };
|
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
|
|
|
|
|
|
|
|
|
dependencies.Cache(BeatDivisor);
|
|
|
|
|
dependencies.CacheAs<IFrameBasedClock>(Clock);
|
|
|
|
|
dependencies.CacheAs<IAdjustableClock>(Clock);
|
|
|
|
|
|
|
|
|
|
return dependencies;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
2018-05-23 08:37:39 +00:00
|
|
|
|
private void load()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-06-07 07:46:54 +00:00
|
|
|
|
Beatmap.BindValueChanged(beatmapChanged, true);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void beatmapChanged(WorkingBeatmap working)
|
|
|
|
|
{
|
|
|
|
|
Clock.ControlPointInfo = working.Beatmap.ControlPointInfo;
|
|
|
|
|
Clock.ChangeSource((IAdjustableClock)working.Track ?? new StopwatchClock());
|
|
|
|
|
Clock.ProcessFrame();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
Clock.ProcessFrame();
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-02 17:28:11 +00:00
|
|
|
|
protected override bool OnScroll(InputState state)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-06-02 17:28:11 +00:00
|
|
|
|
if (state.Mouse.ScrollDelta.Y > 0)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Clock.SeekBackward(true);
|
|
|
|
|
else
|
|
|
|
|
Clock.SeekForward(true);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|