Simplify slider path bindings

Adds a slight performance overhead, but solves the memory leak and makes the code much easier to follow.
This commit is contained in:
Naxess 2021-04-08 03:21:56 +02:00
parent d1d56c636a
commit d6490899e2

View File

@ -50,7 +50,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
[Resolved]
private OsuColour colours { get; set; }
private IBindable<int> sliderVersion;
private IBindable<Vector2> sliderPosition;
private IBindable<float> sliderScale;
private IBindable<Vector2> controlPointPosition;
@ -59,20 +58,11 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{
this.slider = slider;
ControlPoint = controlPoint;
var pathTypes = new List<IBindable<PathType?>>();
slider.Path.ControlPoints.BindCollectionChanged((_, args) =>
slider.Path.Version.BindValueChanged(_ =>
{
pathTypes.Clear();
foreach (var point in slider.Path.ControlPoints)
{
IBindable<PathType?> boundTypeCopy = point.Type.GetBoundCopy();
pathTypes.Add(boundTypeCopy);
boundTypeCopy.BindValueChanged(_ => PointsInSegment = slider.Path.PointsInSegment(controlPoint));
}
PointsInSegment = slider.Path.PointsInSegment(controlPoint);
PointsInSegment = slider.Path.PointsInSegment(ControlPoint);
updatePathType();
}, runOnceImmediately: true);
controlPoint.Type.BindValueChanged(_ => updateMarkerDisplay());
@ -120,9 +110,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
{
base.LoadComplete();
sliderVersion = slider.Path.Version.GetBoundCopy();
sliderVersion.BindValueChanged(_ => updatePathType());
sliderPosition = slider.PositionBindable.GetBoundCopy();
sliderPosition.BindValueChanged(_ => updateMarkerDisplay());