mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 17:52:56 +08:00
Merge pull request #10876 from nbvdkamp/slider-control-point-connection-fix
Fix slider control point connections not being updated
This commit is contained in:
commit
37b9550e6e
@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
|
|
||||||
private readonly Path path;
|
private readonly Path path;
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
private readonly int controlPointIndex;
|
public int ControlPointIndex { get; set; }
|
||||||
|
|
||||||
private IBindable<Vector2> sliderPosition;
|
private IBindable<Vector2> sliderPosition;
|
||||||
private IBindable<int> pathVersion;
|
private IBindable<int> pathVersion;
|
||||||
@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
public PathControlPointConnectionPiece(Slider slider, int controlPointIndex)
|
public PathControlPointConnectionPiece(Slider slider, int controlPointIndex)
|
||||||
{
|
{
|
||||||
this.slider = slider;
|
this.slider = slider;
|
||||||
this.controlPointIndex = controlPointIndex;
|
ControlPointIndex = controlPointIndex;
|
||||||
|
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
|
|
||||||
path.ClearVertices();
|
path.ClearVertices();
|
||||||
|
|
||||||
int nextIndex = controlPointIndex + 1;
|
int nextIndex = ControlPointIndex + 1;
|
||||||
if (nextIndex == 0 || nextIndex >= slider.Path.ControlPoints.Count)
|
if (nextIndex == 0 || nextIndex >= slider.Path.ControlPoints.Count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -66,6 +66,17 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
switch (e.Action)
|
switch (e.Action)
|
||||||
{
|
{
|
||||||
case NotifyCollectionChangedAction.Add:
|
case NotifyCollectionChangedAction.Add:
|
||||||
|
// If inserting in the path (not appending),
|
||||||
|
// update indices of existing connections after insert location
|
||||||
|
if (e.NewStartingIndex < Pieces.Count)
|
||||||
|
{
|
||||||
|
foreach (var connection in Connections)
|
||||||
|
{
|
||||||
|
if (connection.ControlPointIndex >= e.NewStartingIndex)
|
||||||
|
connection.ControlPointIndex += e.NewItems.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < e.NewItems.Count; i++)
|
for (int i = 0; i < e.NewItems.Count; i++)
|
||||||
{
|
{
|
||||||
var point = (PathControlPoint)e.NewItems[i];
|
var point = (PathControlPoint)e.NewItems[i];
|
||||||
@ -88,6 +99,17 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
Connections.RemoveAll(c => c.ControlPoint == point);
|
Connections.RemoveAll(c => c.ControlPoint == point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If removing before the end of the path,
|
||||||
|
// update indices of connections after remove location
|
||||||
|
if (e.OldStartingIndex < Pieces.Count)
|
||||||
|
{
|
||||||
|
foreach (var connection in Connections)
|
||||||
|
{
|
||||||
|
if (connection.ControlPointIndex >= e.OldStartingIndex)
|
||||||
|
connection.ControlPointIndex -= e.OldItems.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user