mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 15:53:21 +08:00
Fix being able to drag out of the blueprint intending to be moved
This commit is contained in:
parent
aa1a226ab7
commit
c76f76e5aa
@ -109,6 +109,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
{
|
{
|
||||||
beginClickSelection(e);
|
beginClickSelection(e);
|
||||||
|
|
||||||
|
prepareSelectionMovement();
|
||||||
|
|
||||||
return e.Button == MouseButton.Left;
|
return e.Button == MouseButton.Left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +147,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
// Special case for when a drag happened instead of a click
|
// Special case for when a drag happened instead of a click
|
||||||
Schedule(() => endClickSelection());
|
Schedule(() => endClickSelection());
|
||||||
|
|
||||||
|
finishSelectionMovement();
|
||||||
|
|
||||||
return e.Button == MouseButton.Left;
|
return e.Button == MouseButton.Left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +158,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
if (e.Button == MouseButton.Right)
|
if (e.Button == MouseButton.Right)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (beginSelectionMovement())
|
if (movementBlueprint != null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (DragBox.HandleDrag(e))
|
if (DragBox.HandleDrag(e))
|
||||||
@ -184,10 +190,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
DragBox.Hide();
|
DragBox.Hide();
|
||||||
selectionHandler.UpdateVisibility();
|
selectionHandler.UpdateVisibility();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return finishSelectionMovement();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
@ -348,14 +353,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
#region Selection Movement
|
#region Selection Movement
|
||||||
|
|
||||||
private Vector2? screenSpaceMovementStartPosition;
|
private Vector2? movementBlueprintOriginalPosition;
|
||||||
private SelectionBlueprint movementBlueprint;
|
private SelectionBlueprint movementBlueprint;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to begin the movement of any selected blueprints.
|
/// Attempts to begin the movement of any selected blueprints.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Whether movement began.</returns>
|
/// <returns>Whether movement began.</returns>
|
||||||
private bool beginSelectionMovement()
|
private bool prepareSelectionMovement()
|
||||||
{
|
{
|
||||||
Debug.Assert(movementBlueprint == null);
|
Debug.Assert(movementBlueprint == null);
|
||||||
|
|
||||||
@ -366,7 +371,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
// Movement is tracked from the blueprint of the earliest hitobject, since it only makes sense to distance snap from that hitobject
|
// Movement is tracked from the blueprint of the earliest hitobject, since it only makes sense to distance snap from that hitobject
|
||||||
movementBlueprint = selectionHandler.SelectedBlueprints.OrderBy(b => b.HitObject.StartTime).First();
|
movementBlueprint = selectionHandler.SelectedBlueprints.OrderBy(b => b.HitObject.StartTime).First();
|
||||||
screenSpaceMovementStartPosition = movementBlueprint.SelectionPoint; // todo: unsure if correct
|
movementBlueprintOriginalPosition = movementBlueprint.SelectionPoint; // todo: unsure if correct
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -381,13 +386,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
if (movementBlueprint == null)
|
if (movementBlueprint == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Debug.Assert(screenSpaceMovementStartPosition != null);
|
Debug.Assert(movementBlueprintOriginalPosition != null);
|
||||||
|
|
||||||
Vector2 startPosition = screenSpaceMovementStartPosition.Value;
|
|
||||||
HitObject draggedObject = movementBlueprint.HitObject;
|
HitObject draggedObject = movementBlueprint.HitObject;
|
||||||
|
|
||||||
// The final movement position, relative to screenSpaceMovementStartPosition
|
// The final movement position, relative to screenSpaceMovementStartPosition
|
||||||
Vector2 movePosition = startPosition + e.ScreenSpaceMousePosition - e.ScreenSpaceMouseDownPosition;
|
Vector2 movePosition = movementBlueprintOriginalPosition.Value + e.ScreenSpaceMousePosition - e.ScreenSpaceMouseDownPosition;
|
||||||
|
|
||||||
(Vector2 snappedPosition, double snappedTime) = snapProvider.GetSnappedPosition(ToLocalSpace(movePosition), draggedObject.StartTime);
|
(Vector2 snappedPosition, double snappedTime) = snapProvider.GetSnappedPosition(ToLocalSpace(movePosition), draggedObject.StartTime);
|
||||||
|
|
||||||
// Move the hitobjects
|
// Move the hitobjects
|
||||||
@ -411,7 +416,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
if (movementBlueprint == null)
|
if (movementBlueprint == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
screenSpaceMovementStartPosition = null;
|
movementBlueprintOriginalPosition = null;
|
||||||
movementBlueprint = null;
|
movementBlueprint = null;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user