mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 20:52:54 +08:00
Fix slider control point connections not being updated
This commit is contained in:
parent
eba17ecab2
commit
c6618f08aa
@ -20,7 +20,17 @@ 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;
|
private int controlPointIndex;
|
||||||
|
|
||||||
|
public int ControlPointIndex
|
||||||
|
{
|
||||||
|
get => controlPointIndex;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
controlPointIndex = value;
|
||||||
|
updateConnectingPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private IBindable<Vector2> sliderPosition;
|
private IBindable<Vector2> sliderPosition;
|
||||||
private IBindable<int> pathVersion;
|
private IBindable<int> pathVersion;
|
||||||
|
@ -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 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];
|
||||||
@ -82,12 +93,25 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Remove:
|
case NotifyCollectionChangedAction.Remove:
|
||||||
|
int oldSize = Pieces.Count;
|
||||||
|
|
||||||
foreach (var point in e.OldItems.Cast<PathControlPoint>())
|
foreach (var point in e.OldItems.Cast<PathControlPoint>())
|
||||||
{
|
{
|
||||||
Pieces.RemoveAll(p => p.ControlPoint == point);
|
Pieces.RemoveAll(p => p.ControlPoint == point);
|
||||||
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 + e.OldItems.Count < oldSize)
|
||||||
|
{
|
||||||
|
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