2023-01-12 02:20:56 +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;
|
2023-02-19 03:42:13 +08:00
|
|
|
using osu.Framework.Allocation;
|
2023-01-12 02:20:56 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Testing;
|
2023-02-19 03:42:13 +08:00
|
|
|
using osu.Game.Configuration;
|
2023-02-19 20:33:06 +08:00
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
2023-01-12 02:20:56 +08:00
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
using osuTK.Input;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Tests.Editor
|
|
|
|
{
|
2023-02-19 20:16:40 +08:00
|
|
|
public partial class TestSceneObjectPlacement : EditorTestScene
|
2023-01-12 02:20:56 +08:00
|
|
|
{
|
|
|
|
protected override Ruleset CreateEditorRuleset() => new ManiaRuleset();
|
|
|
|
|
2023-02-19 03:42:13 +08:00
|
|
|
[Resolved]
|
|
|
|
private OsuConfigManager config { get; set; } = null!;
|
|
|
|
|
2023-01-12 02:20:56 +08:00
|
|
|
[Test]
|
2023-02-19 20:54:48 +08:00
|
|
|
public void TestPlacementBeforeTrackStart()
|
2023-01-12 02:20:56 +08:00
|
|
|
{
|
|
|
|
AddStep("Seek to 0", () => EditorClock.Seek(0));
|
|
|
|
AddStep("Select note", () => InputManager.Key(Key.Number2));
|
|
|
|
AddStep("Hover negative span", () =>
|
|
|
|
{
|
|
|
|
InputManager.MoveMouseTo(this.ChildrenOfType<Container>().First(x => x.Name == "Icons").Children[0]);
|
|
|
|
});
|
|
|
|
AddStep("Click", () => InputManager.Click(MouseButton.Left));
|
|
|
|
AddAssert("No notes placed", () => EditorBeatmap.HitObjects.All(x => x.StartTime >= 0));
|
|
|
|
}
|
2023-02-19 03:42:13 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestSeekOnNotePlacement()
|
|
|
|
{
|
2023-02-19 20:33:06 +08:00
|
|
|
double? initialTime = null;
|
|
|
|
|
|
|
|
AddStep("store initial time", () => initialTime = EditorClock.CurrentTime);
|
|
|
|
AddStep("change seek setting to true", () => config.SetValue(OsuSetting.EditorSeekToHitObject, true));
|
|
|
|
placeObject();
|
|
|
|
AddUntilStep("wait for seek to complete", () => !EditorClock.IsSeeking);
|
|
|
|
AddAssert("seeked forward to object", () => EditorClock.CurrentTime, () => Is.GreaterThan(initialTime));
|
2023-02-19 03:42:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestNoSeekOnNotePlacement()
|
|
|
|
{
|
2023-02-19 20:33:06 +08:00
|
|
|
double? initialTime = null;
|
|
|
|
|
|
|
|
AddStep("store initial time", () => initialTime = EditorClock.CurrentTime);
|
|
|
|
AddStep("change seek setting to false", () => config.SetValue(OsuSetting.EditorSeekToHitObject, false));
|
|
|
|
placeObject();
|
|
|
|
AddAssert("not seeking", () => !EditorClock.IsSeeking);
|
|
|
|
AddAssert("time is unchanged", () => EditorClock.CurrentTime, () => Is.EqualTo(initialTime));
|
2023-02-19 03:42:13 +08:00
|
|
|
}
|
|
|
|
|
2023-02-19 20:33:06 +08:00
|
|
|
private void placeObject()
|
2023-02-19 03:42:13 +08:00
|
|
|
{
|
2023-02-19 20:33:06 +08:00
|
|
|
AddStep("select note placement tool", () => InputManager.Key(Key.Number2));
|
|
|
|
AddStep("move mouse to centre of last column", () => InputManager.MoveMouseTo(this.ChildrenOfType<Column>().Last().ScreenSpaceDrawQuad.Centre));
|
|
|
|
AddStep("place note", () => InputManager.Click(MouseButton.Left));
|
2023-02-19 03:42:13 +08:00
|
|
|
}
|
2023-01-12 02:20:56 +08:00
|
|
|
}
|
|
|
|
}
|