mirror of https://github.com/ppy/osu
Merge pull request #29860 from bdach/fix-nudging
Only allow seek to next/previous object via keybinding if there is no selection
This commit is contained in:
commit
5c826be652
|
@ -8,6 +8,7 @@
|
|||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets;
|
||||
|
@ -82,7 +83,7 @@ public void TestSelectAndShowContextMenuOutsideBounds()
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void TestNudgeSelection()
|
||||
public void TestNudgeSelectionTime()
|
||||
{
|
||||
HitCircle[] addedObjects = null!;
|
||||
|
||||
|
@ -103,6 +104,51 @@ public void TestNudgeSelection()
|
|||
AddAssert("objects reverted to original position", () => addedObjects[0].StartTime == 100);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNudgeSelectionPosition()
|
||||
{
|
||||
HitCircle addedObject = null!;
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(new[]
|
||||
{
|
||||
addedObject = new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||
}));
|
||||
|
||||
AddStep("select object", () => EditorBeatmap.SelectedHitObjects.Add(addedObject));
|
||||
|
||||
AddStep("nudge up", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.Up);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddAssert("object position moved up", () => addedObject.Position.Y, () => Is.EqualTo(99).Within(Precision.FLOAT_EPSILON));
|
||||
|
||||
AddStep("nudge down", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.Down);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddAssert("object position moved down", () => addedObject.Position.Y, () => Is.EqualTo(100).Within(Precision.FLOAT_EPSILON));
|
||||
|
||||
AddStep("nudge left", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.Left);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddAssert("object position moved left", () => addedObject.Position.X, () => Is.EqualTo(99).Within(Precision.FLOAT_EPSILON));
|
||||
|
||||
AddStep("nudge right", () =>
|
||||
{
|
||||
InputManager.PressKey(Key.ControlLeft);
|
||||
InputManager.Key(Key.Right);
|
||||
InputManager.ReleaseKey(Key.ControlLeft);
|
||||
});
|
||||
AddAssert("object position moved right", () => addedObject.Position.X, () => Is.EqualTo(100).Within(Precision.FLOAT_EPSILON));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRotateHotkeys()
|
||||
{
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
|
@ -135,9 +137,42 @@ public void TestSeekBetweenControlPoints()
|
|||
pressAndCheckTime(Key.Up, 0);
|
||||
}
|
||||
|
||||
private void pressAndCheckTime(Key key, double expectedTime)
|
||||
[Test]
|
||||
public void TestSeekBetweenObjects()
|
||||
{
|
||||
AddStep($"press {key}", () => InputManager.Key(key));
|
||||
AddStep("add objects", () =>
|
||||
{
|
||||
EditorBeatmap.Clear();
|
||||
EditorBeatmap.AddRange(new[]
|
||||
{
|
||||
new HitCircle { StartTime = 1000, },
|
||||
new HitCircle { StartTime = 2250, },
|
||||
new HitCircle { StartTime = 3600, },
|
||||
});
|
||||
});
|
||||
AddStep("seek to 0", () => EditorClock.Seek(0));
|
||||
|
||||
pressAndCheckTime(Key.Right, 1000, Key.ControlLeft);
|
||||
pressAndCheckTime(Key.Right, 2250, Key.ControlLeft);
|
||||
pressAndCheckTime(Key.Right, 3600, Key.ControlLeft);
|
||||
pressAndCheckTime(Key.Right, 3600, Key.ControlLeft);
|
||||
pressAndCheckTime(Key.Left, 2250, Key.ControlLeft);
|
||||
pressAndCheckTime(Key.Left, 1000, Key.ControlLeft);
|
||||
pressAndCheckTime(Key.Left, 1000, Key.ControlLeft);
|
||||
}
|
||||
|
||||
private void pressAndCheckTime(Key key, double expectedTime, params Key[] modifiers)
|
||||
{
|
||||
AddStep($"press {key} with {(modifiers.Any() ? string.Join(',', modifiers) : "no modifiers")}", () =>
|
||||
{
|
||||
foreach (var modifier in modifiers)
|
||||
InputManager.PressKey(modifier);
|
||||
|
||||
InputManager.Key(key);
|
||||
|
||||
foreach (var modifier in modifiers)
|
||||
InputManager.ReleaseKey(modifier);
|
||||
});
|
||||
AddUntilStep($"time is {expectedTime}", () => EditorClock.CurrentTime, () => Is.EqualTo(expectedTime).Within(1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -721,10 +721,16 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
|||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.EditorSeekToPreviousHitObject:
|
||||
if (editorBeatmap.SelectedHitObjects.Any())
|
||||
return false;
|
||||
|
||||
seekHitObject(-1);
|
||||
return true;
|
||||
|
||||
case GlobalAction.EditorSeekToNextHitObject:
|
||||
if (editorBeatmap.SelectedHitObjects.Any())
|
||||
return false;
|
||||
|
||||
seekHitObject(1);
|
||||
return true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue