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

Implement selection time snapping

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

View File

@ -244,6 +244,8 @@ namespace osu.Game.Rulesets.Edit
public override Vector2 GetSnappedPosition(Vector2 position) => beatSnapGrid?.GetSnapPosition(position) ?? position;
public override double GetSnappedTime(double startTime, Vector2 position) => beatSnapGrid?.GetSnapTime(position) ?? startTime;
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
@ -294,5 +296,7 @@ namespace osu.Game.Rulesets.Edit
protected virtual DistanceSnapGrid CreateDistanceSnapGrid([NotNull] IEnumerable<HitObject> selectedHitObjects) => null;
public abstract Vector2 GetSnappedPosition(Vector2 position);
public abstract double GetSnappedTime(double startTime, Vector2 screenSpacePosition);
}
}

View File

@ -15,6 +15,7 @@ using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
namespace osu.Game.Screens.Edit.Compose.Components
{
@ -237,6 +238,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
// Move the hitobjects
selectionHandler.HandleMovement(new MoveSelectionEvent(blueprint, blueprint.ScreenSpaceMovementStartPosition, ToScreenSpace(snappedPosition)));
// Apply the start time at the newly snapped-to position
double offset = composer.GetSnappedTime(draggedObject.StartTime, snappedPosition) - draggedObject.StartTime;
foreach (HitObject obj in selectionHandler.SelectedHitObjects)
obj.StartTime += offset;
}
protected override void Dispose(bool isDisposing)