1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Implement selection position snapping

This commit is contained in:
smoogipoo 2019-10-16 20:34:02 +09:00
parent c4704f6a29
commit 1dc7c59853
2 changed files with 10 additions and 2 deletions

View File

@ -242,6 +242,8 @@ namespace osu.Game.Rulesets.Edit
public void Delete(HitObject hitObject) => EditorBeatmap.Remove(hitObject);
public override Vector2 GetSnappedPosition(Vector2 position) => beatSnapGrid?.GetSnapPosition(position) ?? position;
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
@ -290,5 +292,7 @@ namespace osu.Game.Rulesets.Edit
/// <returns>The <see cref="DistanceSnapGrid"/> for <paramref name="selectedHitObjects"/>.</returns>
[CanBeNull]
protected virtual DistanceSnapGrid CreateDistanceSnapGrid([NotNull] IEnumerable<HitObject> selectedHitObjects) => null;
public abstract Vector2 GetSnappedPosition(Vector2 position);
}
}

View File

@ -230,9 +230,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void onDragRequested(SelectionBlueprint blueprint, DragEvent dragEvent)
{
var movePosition = blueprint.ScreenSpaceMovementStartPosition + dragEvent.ScreenSpaceMousePosition - dragEvent.ScreenSpaceMouseDownPosition;
HitObject draggedObject = blueprint.HitObject.HitObject;
selectionHandler.HandleMovement(new MoveSelectionEvent(blueprint, blueprint.ScreenSpaceMovementStartPosition, movePosition));
Vector2 movePosition = blueprint.ScreenSpaceMovementStartPosition + dragEvent.ScreenSpaceMousePosition - dragEvent.ScreenSpaceMouseDownPosition;
Vector2 snappedPosition = composer.GetSnappedPosition(ToLocalSpace(movePosition));
// Move the hitobjects
selectionHandler.HandleMovement(new MoveSelectionEvent(blueprint, blueprint.ScreenSpaceMovementStartPosition, ToScreenSpace(snappedPosition)));
}
protected override void Dispose(bool isDisposing)