2019-01-24 17:43:03 +09:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-10-29 14:07:06 +09:00
|
|
|
|
2019-10-24 19:02:59 +09:00
|
|
|
using System;
|
2018-10-29 14:07:06 +09:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2019-10-24 19:02:59 +09:00
|
|
|
using osuTK;
|
2018-10-29 14:07:06 +09:00
|
|
|
|
2018-11-07 16:08:56 +09:00
|
|
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
2018-10-29 14:07:06 +09:00
|
|
|
{
|
2019-09-27 18:01:55 +09:00
|
|
|
public class PathControlPointVisualiser : CompositeDrawable
|
2018-10-29 14:07:06 +09:00
|
|
|
{
|
2019-10-24 19:02:59 +09:00
|
|
|
public Action<Vector2[]> ControlPointsChanged;
|
|
|
|
|
2018-10-29 14:07:06 +09:00
|
|
|
private readonly Slider slider;
|
|
|
|
|
2018-11-01 03:52:24 +09:00
|
|
|
private readonly Container<PathControlPointPiece> pieces;
|
2018-10-29 14:07:06 +09:00
|
|
|
|
2018-11-01 03:52:24 +09:00
|
|
|
public PathControlPointVisualiser(Slider slider)
|
2018-10-29 14:07:06 +09:00
|
|
|
{
|
|
|
|
this.slider = slider;
|
|
|
|
|
2018-11-01 03:52:24 +09:00
|
|
|
InternalChild = pieces = new Container<PathControlPointPiece> { RelativeSizeAxes = Axes.Both };
|
2018-11-09 13:58:46 +09:00
|
|
|
}
|
2018-10-29 14:07:06 +09:00
|
|
|
|
2019-09-27 18:00:24 +09:00
|
|
|
protected override void Update()
|
2018-11-09 13:58:46 +09:00
|
|
|
{
|
2019-09-27 18:00:24 +09:00
|
|
|
base.Update();
|
2018-10-29 14:07:06 +09:00
|
|
|
|
2018-11-01 15:38:19 +09:00
|
|
|
while (slider.Path.ControlPoints.Length > pieces.Count)
|
2019-10-24 19:02:59 +09:00
|
|
|
pieces.Add(new PathControlPointPiece(slider, pieces.Count) { ControlPointsChanged = c => ControlPointsChanged?.Invoke(c) });
|
2018-11-01 15:38:19 +09:00
|
|
|
while (slider.Path.ControlPoints.Length < pieces.Count)
|
2018-10-29 14:07:06 +09:00
|
|
|
pieces.Remove(pieces[pieces.Count - 1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|