mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Select newly created control point
This commit is contained in:
parent
307d3709e0
commit
6330fa5dc5
@ -92,7 +92,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
Pieces.Add(new PathControlPointPiece(slider, point).With(d =>
|
Pieces.Add(new PathControlPointPiece(slider, point).With(d =>
|
||||||
{
|
{
|
||||||
if (allowSelection)
|
if (allowSelection)
|
||||||
d.RequestSelection = selectPiece;
|
d.RequestSelection = selectionRequested;
|
||||||
|
|
||||||
d.DragStarted = dragStarted;
|
d.DragStarted = dragStarted;
|
||||||
d.DragInProgress = dragInProgress;
|
d.DragInProgress = dragInProgress;
|
||||||
@ -128,6 +128,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
|
if (Pieces.Any(piece => piece.IsHovered))
|
||||||
|
return false;
|
||||||
|
|
||||||
foreach (var piece in Pieces)
|
foreach (var piece in Pieces)
|
||||||
{
|
{
|
||||||
piece.IsSelected.Value = false;
|
piece.IsSelected.Value = false;
|
||||||
@ -151,15 +154,22 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectPiece(PathControlPointPiece piece, MouseButtonEvent e)
|
private void selectionRequested(PathControlPointPiece piece, MouseButtonEvent e)
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
|
if (e.Button == MouseButton.Left && inputManager.CurrentState.Keyboard.ControlPressed)
|
||||||
piece.IsSelected.Toggle();
|
piece.IsSelected.Toggle();
|
||||||
else
|
else
|
||||||
{
|
SetSelectionTo(piece.ControlPoint);
|
||||||
foreach (var p in Pieces)
|
}
|
||||||
p.IsSelected.Value = p == piece;
|
|
||||||
}
|
/// <summary>
|
||||||
|
/// Selects the <see cref="PathControlPointPiece"/> corresponding to the given <paramref name="pathControlPoint"/>,
|
||||||
|
/// and deselects all other <see cref="PathControlPointPiece"/>s.
|
||||||
|
/// </summary>
|
||||||
|
public void SetSelectionTo(PathControlPoint pathControlPoint)
|
||||||
|
{
|
||||||
|
foreach (var p in Pieces)
|
||||||
|
p.IsSelected.Value = p.ControlPoint == pathControlPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -140,7 +140,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
case MouseButton.Left:
|
case MouseButton.Left:
|
||||||
if (e.ControlPressed && IsSelected)
|
if (e.ControlPressed && IsSelected)
|
||||||
{
|
{
|
||||||
placementControlPointIndex = addControlPoint(e.MousePosition);
|
placementControlPoint = addControlPoint(e.MousePosition);
|
||||||
|
ControlPointVisualiser?.SetSelectionTo(placementControlPoint);
|
||||||
return true; // Stop input from being handled and modifying the selection
|
return true; // Stop input from being handled and modifying the selection
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,11 +151,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int? placementControlPointIndex;
|
[CanBeNull]
|
||||||
|
private PathControlPoint placementControlPoint;
|
||||||
|
|
||||||
protected override bool OnDragStart(DragStartEvent e)
|
protected override bool OnDragStart(DragStartEvent e)
|
||||||
{
|
{
|
||||||
if (placementControlPointIndex != null)
|
if (placementControlPoint != null)
|
||||||
{
|
{
|
||||||
changeHandler?.BeginChange();
|
changeHandler?.BeginChange();
|
||||||
return true;
|
return true;
|
||||||
@ -165,16 +167,16 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
protected override void OnDrag(DragEvent e)
|
protected override void OnDrag(DragEvent e)
|
||||||
{
|
{
|
||||||
Debug.Assert(placementControlPointIndex != null);
|
Debug.Assert(placementControlPoint != null);
|
||||||
|
|
||||||
HitObject.Path.ControlPoints[placementControlPointIndex.Value].Position = e.MousePosition - HitObject.Position;
|
placementControlPoint.Position = e.MousePosition - HitObject.Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDragEnd(DragEndEvent e)
|
protected override void OnDragEnd(DragEndEvent e)
|
||||||
{
|
{
|
||||||
if (placementControlPointIndex != null)
|
if (placementControlPoint != null)
|
||||||
{
|
{
|
||||||
placementControlPointIndex = null;
|
placementControlPoint = null;
|
||||||
changeHandler?.EndChange();
|
changeHandler?.EndChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,7 +195,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int addControlPoint(Vector2 position)
|
private PathControlPoint addControlPoint(Vector2 position)
|
||||||
{
|
{
|
||||||
position -= HitObject.Position;
|
position -= HitObject.Position;
|
||||||
|
|
||||||
@ -211,10 +213,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the control points from the insertion index onwards to make room for the insertion
|
var pathControlPoint = new PathControlPoint { Position = position };
|
||||||
controlPoints.Insert(insertionIndex, new PathControlPoint { Position = position });
|
|
||||||
|
|
||||||
return insertionIndex;
|
// Move the control points from the insertion index onwards to make room for the insertion
|
||||||
|
controlPoints.Insert(insertionIndex, pathControlPoint);
|
||||||
|
|
||||||
|
return pathControlPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeControlPoints(List<PathControlPoint> toRemove)
|
private void removeControlPoints(List<PathControlPoint> toRemove)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user