Remove automatic slider path offsetting

This commit is contained in:
smoogipoo 2019-12-09 17:54:19 +09:00
parent fa1468325e
commit 883d5bc11d
3 changed files with 8 additions and 22 deletions

View File

@ -16,6 +16,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Compose; using osu.Game.Screens.Edit.Compose;
using osuTK;
using osuTK.Input; using osuTK.Input;
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
@ -122,6 +123,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
return true; return true;
} }
// The path will have a non-zero offset if the head is removed, but sliders don't support this behaviour since the head is positioned at the slider's position
// So the slider needs to be offset by this amount instead, and all control points offset backwards such that the path is re-positioned at (0, 0)
Vector2 first = slider.Path.ControlPoints[0].Position.Value;
foreach (var c in slider.Path.ControlPoints)
c.Position.Value -= first;
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;

View File

@ -113,8 +113,6 @@ namespace osu.Game.Rulesets.Osu.Objects
{ {
SamplesBindable.ItemsAdded += _ => updateNestedSamples(); SamplesBindable.ItemsAdded += _ => updateNestedSamples();
SamplesBindable.ItemsRemoved += _ => updateNestedSamples(); SamplesBindable.ItemsRemoved += _ => updateNestedSamples();
Path.OffsetChanged += offset => Position += offset;
Path.Version.ValueChanged += _ => updateNestedPositions(); Path.Version.ValueChanged += _ => updateNestedPositions();
} }

View File

@ -16,12 +16,6 @@ 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>
@ -66,20 +60,6 @@ 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();
}; };
} }