1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Implement placement snapping

This commit is contained in:
smoogipoo 2019-10-18 13:48:59 +09:00
parent cb301a4661
commit 463079e148
2 changed files with 5 additions and 2 deletions

View File

@ -240,6 +240,7 @@ namespace osu.Game.Rulesets.Edit
public void BeginPlacement(HitObject hitObject)
{
hitObject.StartTime = GetSnappedTime(hitObject.StartTime, inputManager.CurrentState.Mouse.Position);
}
public void EndPlacement(HitObject hitObject) => EditorBeatmap.Add(hitObject);

View File

@ -152,7 +152,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
if (currentPlacement != null)
{
currentPlacement.UpdatePosition(e.ScreenSpaceMousePosition);
updatePlacementPosition(e.ScreenSpaceMousePosition);
return true;
}
@ -187,10 +187,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
placementBlueprintContainer.Child = currentPlacement = blueprint;
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
blueprint.UpdatePosition(inputManager.CurrentState.Mouse.Position);
updatePlacementPosition(inputManager.CurrentState.Mouse.Position);
}
}
private void updatePlacementPosition(Vector2 screenSpacePosition) => currentPlacement.UpdatePosition(ToScreenSpace(composer.GetSnappedPosition(ToLocalSpace(screenSpacePosition))));
/// <summary>
/// Select all masks in a given rectangle selection area.
/// </summary>