mirror of
https://github.com/ppy/osu.git
synced 2025-03-11 16:47:46 +08:00
Handle control point positional updates within SliderPath
This commit is contained in:
parent
2b5f9515de
commit
16f8341a02
@ -117,14 +117,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make control points relative
|
|
||||||
Vector2 first = slider.Path.ControlPoints[0].Position.Value;
|
|
||||||
for (int i = 0; i < slider.Path.ControlPoints.Count; i++)
|
|
||||||
slider.Path.ControlPoints[i].Position.Value = slider.Path.ControlPoints[i].Position.Value - first;
|
|
||||||
|
|
||||||
// The slider's position defines the position of the first control point, and all further control points are relative to that point
|
|
||||||
slider.Position += first;
|
|
||||||
|
|
||||||
// Since pieces are re-used, they will not point to the deleted control points while remaining selected
|
// Since pieces are re-used, they will not point to the deleted control points while remaining selected
|
||||||
foreach (var piece in Pieces)
|
foreach (var piece in Pieces)
|
||||||
piece.IsSelected.Value = false;
|
piece.IsSelected.Value = false;
|
||||||
|
@ -100,6 +100,8 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
{
|
{
|
||||||
SamplesBindable.ItemsAdded += _ => updateNestedSamples();
|
SamplesBindable.ItemsAdded += _ => updateNestedSamples();
|
||||||
SamplesBindable.ItemsRemoved += _ => updateNestedSamples();
|
SamplesBindable.ItemsRemoved += _ => updateNestedSamples();
|
||||||
|
|
||||||
|
Path.OffsetChanged += offset => Position += offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
|
@ -16,6 +16,12 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
{
|
{
|
||||||
public class SliderPath
|
public class SliderPath
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when the offset of the path changes.
|
||||||
|
/// The provided value indicates the offset, and should be used to re-calculate the position of the containing drawable.
|
||||||
|
/// </summary>
|
||||||
|
public event Action<Vector2> OffsetChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current version of this <see cref="SliderPath"/>. Updated when any change to the path occurs.
|
/// The current version of this <see cref="SliderPath"/>. Updated when any change to the path occurs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -62,6 +68,20 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
foreach (var c in items)
|
foreach (var c in items)
|
||||||
c.Changed -= invalidate;
|
c.Changed -= invalidate;
|
||||||
|
|
||||||
|
// Make all control points relative to the first one
|
||||||
|
if (ControlPoints.Count > 0)
|
||||||
|
{
|
||||||
|
Vector2 first = ControlPoints[0].Position.Value;
|
||||||
|
|
||||||
|
if (first != Vector2.Zero)
|
||||||
|
{
|
||||||
|
foreach (var c in ControlPoints)
|
||||||
|
c.Position.Value -= first;
|
||||||
|
|
||||||
|
OffsetChanged?.Invoke(first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user