2022-05-20 13:34:33 +08: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.
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2022-05-23 16:56:32 +08:00
|
|
|
using osu.Framework.Audio;
|
2022-05-20 13:34:33 +08:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2022-05-23 16:56:32 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2022-05-20 13:34:33 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
using osu.Game.Screens.Edit;
|
|
|
|
using osu.Game.Screens.Edit.Timing;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Editing
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class TestSceneTapTimingControl : EditorClockTestScene
|
|
|
|
{
|
2022-05-23 16:56:32 +08:00
|
|
|
private EditorBeatmap editorBeatmap => editorBeatmapContainer?.EditorBeatmap;
|
|
|
|
|
|
|
|
private TestSceneHitObjectComposer.EditorBeatmapContainer editorBeatmapContainer;
|
2022-05-20 13:34:33 +08:00
|
|
|
|
|
|
|
[Cached]
|
|
|
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
|
|
|
|
|
|
|
[Cached]
|
|
|
|
private Bindable<ControlPointGroup> selectedGroup = new Bindable<ControlPointGroup>();
|
|
|
|
|
|
|
|
private TapTimingControl control;
|
2022-05-23 16:56:32 +08:00
|
|
|
private OsuSpriteText timingInfo;
|
2022-05-20 13:34:33 +08:00
|
|
|
|
2022-05-23 16:56:32 +08:00
|
|
|
[Resolved]
|
|
|
|
private AudioManager audio { get; set; }
|
2022-05-20 14:56:39 +08:00
|
|
|
|
2022-05-23 16:56:32 +08:00
|
|
|
[SetUpSteps]
|
|
|
|
public void SetUpSteps()
|
|
|
|
{
|
|
|
|
AddStep("create beatmap", () =>
|
|
|
|
{
|
|
|
|
Beatmap.Value = new WaveformTestBeatmap(audio);
|
|
|
|
});
|
2022-05-20 14:56:39 +08:00
|
|
|
|
2022-05-23 16:56:32 +08:00
|
|
|
AddStep("Create component", () =>
|
|
|
|
{
|
|
|
|
Child = editorBeatmapContainer = new TestSceneHitObjectComposer.EditorBeatmapContainer(Beatmap.Value)
|
|
|
|
{
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Width = 400,
|
|
|
|
Scale = new Vector2(1.5f),
|
|
|
|
Child = control = new TapTimingControl(),
|
|
|
|
},
|
|
|
|
timingInfo = new OsuSpriteText(),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
selectedGroup.Value = editorBeatmap.ControlPointInfo.Groups.First();
|
|
|
|
});
|
2022-05-20 13:34:33 +08:00
|
|
|
}
|
|
|
|
|
2022-05-23 16:56:32 +08:00
|
|
|
protected override void Update()
|
2022-05-20 14:56:39 +08:00
|
|
|
{
|
2022-05-23 16:56:32 +08:00
|
|
|
base.Update();
|
2022-05-20 14:56:39 +08:00
|
|
|
|
2022-05-23 16:56:32 +08:00
|
|
|
if (selectedGroup.Value != null)
|
|
|
|
timingInfo.Text = $"offset: {selectedGroup.Value.Time:N2} bpm: {selectedGroup.Value.ControlPoints.OfType<TimingControlPoint>().First().BPM:N2}";
|
2022-05-20 14:56:39 +08:00
|
|
|
}
|
|
|
|
|
2022-05-20 13:34:33 +08:00
|
|
|
[Test]
|
|
|
|
public void TestTapThenReset()
|
|
|
|
{
|
|
|
|
AddStep("click tap button", () =>
|
|
|
|
{
|
|
|
|
control.ChildrenOfType<RoundedButton>()
|
2022-05-20 16:12:35 +08:00
|
|
|
.Last()
|
2022-05-20 13:34:33 +08:00
|
|
|
.TriggerClick();
|
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("wait for track playing", () => Clock.IsRunning);
|
|
|
|
|
|
|
|
AddStep("click reset button", () =>
|
|
|
|
{
|
|
|
|
control.ChildrenOfType<RoundedButton>()
|
2022-05-20 16:12:35 +08:00
|
|
|
.First()
|
2022-05-20 13:34:33 +08:00
|
|
|
.TriggerClick();
|
|
|
|
});
|
|
|
|
|
|
|
|
AddUntilStep("wait for track stopped", () => !Clock.IsRunning);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestBasic()
|
|
|
|
{
|
2022-05-20 14:56:39 +08:00
|
|
|
AddStep("set low bpm", () =>
|
|
|
|
{
|
|
|
|
editorBeatmap.ControlPointInfo.TimingPoints.First().BeatLength = 1000;
|
|
|
|
});
|
2022-05-20 13:34:33 +08:00
|
|
|
|
2022-05-20 14:56:39 +08:00
|
|
|
AddStep("click tap button", () =>
|
2022-05-20 13:34:33 +08:00
|
|
|
{
|
2022-05-20 14:56:39 +08:00
|
|
|
control.ChildrenOfType<RoundedButton>()
|
2022-05-20 16:12:35 +08:00
|
|
|
.Last()
|
2022-05-20 14:56:39 +08:00
|
|
|
.TriggerClick();
|
|
|
|
});
|
|
|
|
|
2022-05-23 16:56:32 +08:00
|
|
|
AddSliderStep("BPM", 30, 400, 128, bpm =>
|
|
|
|
{
|
|
|
|
if (editorBeatmap == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
editorBeatmap.ControlPointInfo.TimingPoints.First().BeatLength = 60000f / bpm;
|
|
|
|
});
|
2022-05-20 13:34:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
Beatmap.Disabled = false;
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|