2019-05-31 13:40:53 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2018-06-18 15:03:00 +08:00
|
|
|
using NUnit.Framework;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2020-04-23 16:07:55 +08:00
|
|
|
namespace osu.Game.Tests.Visual.Editing
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2018-06-18 16:05:18 +08:00
|
|
|
[TestFixture]
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class TestSceneEditorSeekSnapping : EditorClockTestScene
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2019-05-15 03:37:25 +08:00
|
|
|
public TestSceneEditorSeekSnapping()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
BeatDivisor.Value = 4;
|
|
|
|
}
|
|
|
|
|
2022-01-18 12:22:55 +08:00
|
|
|
protected override void LoadComplete()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2022-01-18 12:22:55 +08:00
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
Child = new TimingPointVisualiser(Beatmap.Value.Beatmap, 5000) { Clock = EditorClock };
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override Beatmap CreateEditorClockBeatmap()
|
|
|
|
{
|
2018-04-13 17:19:50 +08:00
|
|
|
var testBeatmap = new Beatmap
|
|
|
|
{
|
2019-10-25 18:48:01 +08:00
|
|
|
ControlPointInfo = new ControlPointInfo(),
|
2018-04-13 17:19:50 +08:00
|
|
|
HitObjects =
|
|
|
|
{
|
|
|
|
new HitCircle { StartTime = 0 },
|
|
|
|
new HitCircle { StartTime = 5000 }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-10-25 18:48:01 +08:00
|
|
|
testBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 200 });
|
|
|
|
testBeatmap.ControlPointInfo.Add(100, new TimingControlPoint { BeatLength = 400 });
|
|
|
|
testBeatmap.ControlPointInfo.Add(175, new TimingControlPoint { BeatLength = 800 });
|
|
|
|
testBeatmap.ControlPointInfo.Add(350, new TimingControlPoint { BeatLength = 200 });
|
|
|
|
testBeatmap.ControlPointInfo.Add(450, new TimingControlPoint { BeatLength = 100 });
|
|
|
|
testBeatmap.ControlPointInfo.Add(500, new TimingControlPoint { BeatLength = 307.69230769230802 });
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
return testBeatmap;
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests whether time is correctly seeked without snapping.
|
|
|
|
/// </summary>
|
2018-06-18 15:03:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSeekNoSnapping()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
|
|
|
|
// Forwards
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(0)", () => EditorClock.Seek(0));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(0);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(33)", () => EditorClock.Seek(33));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(33);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(89)", () => EditorClock.Seek(89));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(89);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
// Backwards
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(25)", () => EditorClock.Seek(25));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(25);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(0)", () => EditorClock.Seek(0));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(0);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests whether seeking to exact beat times puts us on the beat time.
|
|
|
|
/// These are the white/yellow ticks on the graph.
|
|
|
|
/// </summary>
|
2018-06-18 15:03:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSeekSnappingOnBeat()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(0), Snap", () => EditorClock.SeekSnapped(0));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(0);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(50), Snap", () => EditorClock.SeekSnapped(50));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(50);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(100), Snap", () => EditorClock.SeekSnapped(100));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(100);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(175), Snap", () => EditorClock.SeekSnapped(175));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(175);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(350), Snap", () => EditorClock.SeekSnapped(350));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(350);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(400), Snap", () => EditorClock.SeekSnapped(400));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(400);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(450), Snap", () => EditorClock.SeekSnapped(450));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(450);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests whether seeking to somewhere in the middle between beats puts us on the expected beats.
|
|
|
|
/// For example, snapping between a white/yellow beat should put us on either the yellow or white, depending on which one we're closer too.
|
|
|
|
/// </summary>
|
2018-06-18 15:03:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSeekSnappingInBetweenBeat()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(24), Snap", () => EditorClock.SeekSnapped(24));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(0);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(26), Snap", () => EditorClock.SeekSnapped(26));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(50);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(150), Snap", () => EditorClock.SeekSnapped(150));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(100);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(170), Snap", () => EditorClock.SeekSnapped(170));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(175);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(274), Snap", () => EditorClock.SeekSnapped(274));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(175);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(276), Snap", () => EditorClock.SeekSnapped(276));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(350);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests that when seeking forward with no beat snapping, beats are never explicitly snapped to, nor the next timing point (if we've skipped it).
|
|
|
|
/// </summary>
|
2018-06-18 15:03:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSeekForwardNoSnapping()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward", () => EditorClock.SeekForward());
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(50);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward", () => EditorClock.SeekForward());
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(100);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward", () => EditorClock.SeekForward());
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(200);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward", () => EditorClock.SeekForward());
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(400);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward", () => EditorClock.SeekForward());
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(450);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests that when seeking forward with beat snapping, all beats are snapped to and timing points are never skipped.
|
|
|
|
/// </summary>
|
2018-06-18 15:03:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSeekForwardSnappingOnBeat()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(50);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(100);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(175);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(350);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(400);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(450);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests that when seeking forward from in-between two beats, the next beat or timing point is snapped to, and no beats are skipped.
|
|
|
|
/// This will also test being extremely close to the next beat/timing point, to ensure rounding is not an issue.
|
|
|
|
/// </summary>
|
2018-06-18 15:03:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSeekForwardSnappingFromInBetweenBeat()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(49)", () => EditorClock.Seek(49));
|
2022-08-17 15:39:24 +08:00
|
|
|
checkTime(49);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(50);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(49.999)", () => EditorClock.Seek(49.999));
|
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(100);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(99)", () => EditorClock.Seek(99));
|
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(100);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(99.999)", () => EditorClock.Seek(99.999));
|
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 19:23:45 +08:00
|
|
|
checkTime(150);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(174)", () => EditorClock.Seek(174));
|
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(175);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(349)", () => EditorClock.Seek(349));
|
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(350);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(399)", () => EditorClock.Seek(399));
|
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(400);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(449)", () => EditorClock.Seek(449));
|
|
|
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(450);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests that when seeking backward with no beat snapping, beats are never explicitly snapped to, nor the next timing point (if we've skipped it).
|
|
|
|
/// </summary>
|
2018-06-18 15:03:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSeekBackwardNoSnapping()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(450)", () => EditorClock.Seek(450));
|
2022-08-17 15:39:24 +08:00
|
|
|
checkTime(450);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(400);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(350);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(150);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(50);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(0);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests that when seeking backward with beat snapping, all beats are snapped to and timing points are never skipped.
|
|
|
|
/// </summary>
|
2018-06-18 15:03:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSeekBackwardSnappingOnBeat()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(450)", () => EditorClock.Seek(450));
|
2022-08-17 15:39:24 +08:00
|
|
|
checkTime(450);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(400);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(350);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(175);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(100);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(50);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(0);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests that when seeking backward from in-between two beats, the previous beat or timing point is snapped to, and no beats are skipped.
|
|
|
|
/// This will also test being extremely close to the previous beat/timing point, to ensure rounding is not an issue.
|
|
|
|
/// </summary>
|
2018-06-18 15:03:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSeekBackwardSnappingFromInBetweenBeat()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(451)", () => EditorClock.Seek(451));
|
2022-08-17 15:39:24 +08:00
|
|
|
checkTime(451);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(450);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(450.999)", () => EditorClock.Seek(450.999));
|
|
|
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(450);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(401)", () => EditorClock.Seek(401));
|
|
|
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(400);
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(401.999)", () => EditorClock.Seek(401.999));
|
|
|
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(400);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests that there are no rounding issues when snapping to beats within a timing point with a floating-point beatlength.
|
|
|
|
/// </summary>
|
2018-06-18 15:03:00 +08:00
|
|
|
[Test]
|
|
|
|
public void TestSeekingWithFloatingPointBeatLength()
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
|
|
|
|
double lastTime = 0;
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Seek(0)", () => EditorClock.Seek(0));
|
2022-08-17 15:39:24 +08:00
|
|
|
checkTime(0);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2018-06-18 15:03:00 +08:00
|
|
|
for (int i = 0; i < 9; i++)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
AddStep("SeekForward, Snap", () =>
|
|
|
|
{
|
2022-08-17 14:40:01 +08:00
|
|
|
lastTime = EditorClock.CurrentTime;
|
|
|
|
EditorClock.SeekForward(true);
|
2018-04-13 17:19:50 +08:00
|
|
|
});
|
2022-08-17 14:40:01 +08:00
|
|
|
AddAssert("Time > lastTime", () => EditorClock.CurrentTime > lastTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2018-06-18 15:03:00 +08:00
|
|
|
for (int i = 0; i < 9; i++)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
AddStep("SeekBackward, Snap", () =>
|
|
|
|
{
|
2022-08-17 14:40:01 +08:00
|
|
|
lastTime = EditorClock.CurrentTime;
|
|
|
|
EditorClock.SeekBackward(true);
|
2018-04-13 17:19:50 +08:00
|
|
|
});
|
2022-08-17 14:40:01 +08:00
|
|
|
AddAssert("Time < lastTime", () => EditorClock.CurrentTime < lastTime);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2022-08-09 18:15:32 +08:00
|
|
|
checkTime(0);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2022-08-17 14:40:01 +08:00
|
|
|
private void checkTime(double expectedTime) => AddUntilStep($"Current time is {expectedTime}", () => EditorClock.CurrentTime, () => Is.EqualTo(expectedTime));
|
2022-08-09 18:15:32 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
private void reset()
|
|
|
|
{
|
2022-08-17 14:40:01 +08:00
|
|
|
AddStep("Reset", () => EditorClock.Seek(0));
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
private partial class TimingPointVisualiser : CompositeDrawable
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
private readonly double length;
|
|
|
|
|
|
|
|
private readonly Drawable tracker;
|
|
|
|
|
2018-04-19 19:44:38 +08:00
|
|
|
public TimingPointVisualiser(IBeatmap beatmap, double length)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
this.length = length;
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
Width = 0.75f;
|
|
|
|
|
|
|
|
FillFlowContainer timelineContainer;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
Name = "Background",
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Black.Opacity(85f)
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Name = "Tracks",
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Padding = new MarginPadding(15),
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
tracker = new Box
|
|
|
|
{
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
RelativePositionAxes = Axes.X,
|
|
|
|
Width = 2,
|
|
|
|
Colour = Color4.Red,
|
|
|
|
},
|
|
|
|
timelineContainer = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Spacing = new Vector2(0, 5)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var timingPoints = beatmap.ControlPointInfo.TimingPoints;
|
|
|
|
|
|
|
|
for (int i = 0; i < timingPoints.Count; i++)
|
|
|
|
{
|
|
|
|
TimingControlPoint next = i == timingPoints.Count - 1 ? null : timingPoints[i + 1];
|
|
|
|
timelineContainer.Add(new TimingPointTimeline(timingPoints[i], next?.Time ?? length, length));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
tracker.X = (float)(Time.Current / length);
|
|
|
|
}
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
private partial class TimingPointTimeline : CompositeDrawable
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
public TimingPointTimeline(TimingControlPoint timingPoint, double endTime, double fullDuration)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
Box createMainTick(double time) => new Box
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
RelativePositionAxes = Axes.X,
|
|
|
|
X = (float)(time / fullDuration),
|
|
|
|
Height = 10,
|
|
|
|
Width = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
Box createBeatTick(double time) => new Box
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
RelativePositionAxes = Axes.X,
|
|
|
|
X = (float)(time / fullDuration),
|
|
|
|
Height = 5,
|
|
|
|
Width = 2,
|
|
|
|
Colour = time > endTime ? Color4.Gray : Color4.Yellow
|
|
|
|
};
|
|
|
|
|
|
|
|
AddInternal(createMainTick(timingPoint.Time));
|
|
|
|
AddInternal(createMainTick(endTime));
|
|
|
|
|
|
|
|
for (double t = timingPoint.Time + timingPoint.BeatLength / 4; t < fullDuration; t += timingPoint.BeatLength / 4)
|
|
|
|
AddInternal(createBeatTick(t));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|