From e8d3d26d1607d381718ae0bf3650aa6ad6239c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 23 Nov 2023 09:26:31 +0900 Subject: [PATCH] Fix slider length not updating when adding new anchor via ctrl-click --- .../Components/PathControlPointVisualiser.cs | 12 ++++----- .../Sliders/SliderSelectionBlueprint.cs | 27 +++++++++++++------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs index 1a94d6253d..3add95b2b2 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/Components/PathControlPointVisualiser.cs @@ -159,9 +159,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components if (allowSelection) d.RequestSelection = selectionRequested; - d.DragStarted = dragStarted; - d.DragInProgress = dragInProgress; - d.DragEnded = dragEnded; + d.DragStarted = DragStarted; + d.DragInProgress = DragInProgress; + d.DragEnded = DragEnded; })); Connections.Add(new PathControlPointConnectionPiece(hitObject, e.NewStartingIndex + i)); @@ -267,7 +267,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components private int draggedControlPointIndex; private HashSet selectedControlPoints; - private void dragStarted(PathControlPoint controlPoint) + public void DragStarted(PathControlPoint controlPoint) { dragStartPositions = hitObject.Path.ControlPoints.Select(point => point.Position).ToArray(); dragPathTypes = hitObject.Path.ControlPoints.Select(point => point.Type).ToArray(); @@ -279,7 +279,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components changeHandler?.BeginChange(); } - private void dragInProgress(DragEvent e) + public void DragInProgress(DragEvent e) { Vector2[] oldControlPoints = hitObject.Path.ControlPoints.Select(cp => cp.Position).ToArray(); var oldPosition = hitObject.Position; @@ -341,7 +341,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components hitObject.Path.ControlPoints[i].Type = dragPathTypes[i]; } - private void dragEnded() => changeHandler?.EndChange(); + public void DragEnded() => changeHandler?.EndChange(); #endregion diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs index 80c4cee7f2..a4b8064f05 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs @@ -39,9 +39,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders [CanBeNull] protected PathControlPointVisualiser ControlPointVisualiser { get; private set; } - [Resolved(CanBeNull = true)] - private IPositionSnapProvider positionSnapProvider { get; set; } - [Resolved(CanBeNull = true)] private IDistanceSnapProvider distanceSnapProvider { get; set; } @@ -191,15 +188,29 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders [CanBeNull] private PathControlPoint placementControlPoint; - protected override bool OnDragStart(DragStartEvent e) => placementControlPoint != null; + protected override bool OnDragStart(DragStartEvent e) + { + if (placementControlPoint == null) + return base.OnDragStart(e); + + ControlPointVisualiser?.DragStarted(placementControlPoint); + return true; + } protected override void OnDrag(DragEvent e) { + base.OnDrag(e); + if (placementControlPoint != null) - { - var result = positionSnapProvider?.FindSnappedPositionAndTime(ToScreenSpace(e.MousePosition)); - placementControlPoint.Position = ToLocalSpace(result?.ScreenSpacePosition ?? ToScreenSpace(e.MousePosition)) - HitObject.Position; - } + ControlPointVisualiser?.DragInProgress(e); + } + + protected override void OnDragEnd(DragEndEvent e) + { + base.OnDragEnd(e); + + if (placementControlPoint != null) + ControlPointVisualiser?.DragEnded(); } protected override void OnMouseUp(MouseUpEvent e)