mirror of
https://github.com/ppy/osu
synced 2024-12-14 02:46:27 +00:00
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:
parent
d1d56c636a
commit
d6490899e2
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user