2019-12-10 10:20:08 +08: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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-12-10 10:20:08 +08:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics.Lines;
|
2022-11-03 19:25:23 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2019-12-10 10:20:08 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|
|
|
{
|
2019-12-11 19:14:16 +08:00
|
|
|
/// <summary>
|
2024-05-05 02:53:48 +08:00
|
|
|
/// A visualisation of the lines between <see cref="PathControlPointPiece{T}"/>s.
|
2019-12-11 19:14:16 +08:00
|
|
|
/// </summary>
|
2024-05-05 02:53:48 +08:00
|
|
|
/// <typeparam name="T">The type of <see cref="OsuHitObject"/> which this <see cref="PathControlPointConnection{T}"/> visualises.</typeparam>
|
|
|
|
public partial class PathControlPointConnection<T> : SmoothPath where T : OsuHitObject, IHasPath
|
2019-12-10 10:20:08 +08:00
|
|
|
{
|
2022-11-03 19:25:23 +08:00
|
|
|
private readonly T hitObject;
|
2019-12-10 10:20:08 +08:00
|
|
|
|
2022-11-03 19:25:23 +08:00
|
|
|
private IBindable<Vector2> hitObjectPosition;
|
2019-12-10 10:20:08 +08:00
|
|
|
private IBindable<int> pathVersion;
|
2024-04-01 14:31:34 +08:00
|
|
|
private IBindable<int> stackHeight;
|
2019-12-10 10:20:08 +08:00
|
|
|
|
2024-05-05 02:53:48 +08:00
|
|
|
public PathControlPointConnection(T hitObject)
|
2019-12-10 10:20:08 +08:00
|
|
|
{
|
2022-11-03 19:25:23 +08:00
|
|
|
this.hitObject = hitObject;
|
2024-05-05 02:53:48 +08:00
|
|
|
PathRadius = 1;
|
2019-12-10 10:20:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-11-03 19:25:23 +08:00
|
|
|
hitObjectPosition = hitObject.PositionBindable.GetBoundCopy();
|
2024-01-13 09:24:33 +08:00
|
|
|
hitObjectPosition.BindValueChanged(_ => Scheduler.AddOnce(updateConnectingPath));
|
2019-12-10 10:20:08 +08:00
|
|
|
|
2022-11-03 19:25:23 +08:00
|
|
|
pathVersion = hitObject.Path.Version.GetBoundCopy();
|
2024-01-13 09:24:33 +08:00
|
|
|
pathVersion.BindValueChanged(_ => Scheduler.AddOnce(updateConnectingPath));
|
2019-12-10 10:20:08 +08:00
|
|
|
|
2024-04-01 14:31:34 +08:00
|
|
|
stackHeight = hitObject.StackHeightBindable.GetBoundCopy();
|
|
|
|
stackHeight.BindValueChanged(_ => updateConnectingPath());
|
2024-03-31 08:23:05 +08:00
|
|
|
|
2019-12-10 10:20:08 +08:00
|
|
|
updateConnectingPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Updates the path connecting this control point to the next one.
|
|
|
|
/// </summary>
|
|
|
|
private void updateConnectingPath()
|
|
|
|
{
|
2024-05-05 02:53:48 +08:00
|
|
|
Position = hitObject.StackedPosition;
|
2019-12-10 10:20:08 +08:00
|
|
|
|
2024-05-05 02:53:48 +08:00
|
|
|
ClearVertices();
|
2019-12-10 10:20:08 +08:00
|
|
|
|
2024-05-05 02:53:48 +08:00
|
|
|
foreach (var controlPoint in hitObject.Path.ControlPoints)
|
|
|
|
AddVertex(controlPoint.Position);
|
2019-12-10 10:20:08 +08:00
|
|
|
|
2024-05-05 02:53:48 +08:00
|
|
|
OriginPosition = PositionInBoundingBox(Vector2.Zero);
|
2019-12-10 10:20:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|