1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Merge pull request #22504 from peppy/fix-editor-positional-nudge-undo

Fix beatmap editor positional nudging not being undoable
This commit is contained in:
Bartłomiej Dach 2023-02-04 15:52:34 +01:00 committed by GitHub
commit cb7540564a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,6 +91,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
blueprint.DrawableObject = drawableObject;
}
private bool nudgeMovementActive;
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.ControlPressed)
@ -98,19 +100,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
switch (e.Key)
{
case Key.Left:
moveSelection(new Vector2(-1, 0));
nudgeSelection(new Vector2(-1, 0));
return true;
case Key.Right:
moveSelection(new Vector2(1, 0));
nudgeSelection(new Vector2(1, 0));
return true;
case Key.Up:
moveSelection(new Vector2(0, -1));
nudgeSelection(new Vector2(0, -1));
return true;
case Key.Down:
moveSelection(new Vector2(0, 1));
nudgeSelection(new Vector2(0, 1));
return true;
}
}
@ -118,12 +120,29 @@ namespace osu.Game.Screens.Edit.Compose.Components
return false;
}
protected override void OnKeyUp(KeyUpEvent e)
{
base.OnKeyUp(e);
if (nudgeMovementActive && !e.ControlPressed)
{
Beatmap.EndChange();
nudgeMovementActive = false;
}
}
/// <summary>
/// Move the current selection spatially by the specified delta, in gamefield coordinates (ie. the same coordinates as the blueprints).
/// </summary>
/// <param name="delta"></param>
private void moveSelection(Vector2 delta)
private void nudgeSelection(Vector2 delta)
{
if (!nudgeMovementActive)
{
nudgeMovementActive = true;
Beatmap.BeginChange();
}
var firstBlueprint = SelectionHandler.SelectedBlueprints.FirstOrDefault();
if (firstBlueprint == null)