1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 03:02:54 +08:00

Fix slider control point connections not being updated

This commit is contained in:
kamp 2020-11-16 21:26:08 +01:00
parent eba17ecab2
commit c6618f08aa
2 changed files with 35 additions and 1 deletions

View File

@ -20,7 +20,17 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
private readonly Path path;
private readonly Slider slider;
private readonly int controlPointIndex;
private int controlPointIndex;
public int ControlPointIndex
{
get => controlPointIndex;
set
{
controlPointIndex = value;
updateConnectingPath();
}
}
private IBindable<Vector2> sliderPosition;
private IBindable<int> pathVersion;

View File

@ -66,6 +66,17 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
// If inserting in the 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++)
{
var point = (PathControlPoint)e.NewItems[i];
@ -82,12 +93,25 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
break;
case NotifyCollectionChangedAction.Remove:
int oldSize = Pieces.Count;
foreach (var point in e.OldItems.Cast<PathControlPoint>())
{
Pieces.RemoveAll(p => p.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 + e.OldItems.Count < oldSize)
{
foreach (var connection in Connections)
{
if (connection.ControlPointIndex >= e.OldStartingIndex)
connection.ControlPointIndex -= e.OldItems.Count;
}
}
break;
}
}