2019-01-24 16:43:03 +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.
|
2018-10-25 17:16:25 +08:00
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2018-10-25 18:34:35 +08:00
|
|
|
using System.Collections.Generic;
|
2018-10-25 17:16:25 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2020-12-04 19:21:53 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Skinning.Default;
|
2018-11-20 15:51:59 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2018-10-25 17:16:25 +08:00
|
|
|
|
2018-11-07 15:08:56 +08:00
|
|
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
2019-09-27 17:45:22 +08:00
|
|
|
public partial class SliderBodyPiece : BlueprintPiece<Slider>
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
2018-10-25 18:34:35 +08:00
|
|
|
private readonly ManualSliderBody body;
|
2018-10-25 17:16:25 +08:00
|
|
|
|
2020-09-28 16:32:57 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Offset in absolute (local) coordinates from the start of the curve.
|
|
|
|
/// </summary>
|
|
|
|
public Vector2 PathStartLocation => body.PathOffset;
|
|
|
|
|
2023-01-11 04:16:34 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Offset in absolute (local) coordinates from the end of the curve.
|
|
|
|
/// </summary>
|
|
|
|
public Vector2 PathEndLocation => body.PathEndOffset;
|
2023-01-18 16:33:14 +08:00
|
|
|
|
2019-09-27 17:45:22 +08:00
|
|
|
public SliderBodyPiece()
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
2018-10-25 18:34:35 +08:00
|
|
|
InternalChild = body = new ManualSliderBody
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
2019-09-27 17:45:22 +08:00
|
|
|
AccentColour = Color4.Transparent
|
2018-10-25 17:16:25 +08:00
|
|
|
};
|
2021-05-08 22:33:03 +08:00
|
|
|
|
|
|
|
// SliderSelectionBlueprint relies on calling ReceivePositionalInputAt on this drawable to determine whether selection should occur.
|
|
|
|
// Without AlwaysPresent, a movement in a parent container (ie. the editor composer area resizing) could cause incorrect input handling.
|
|
|
|
AlwaysPresent = true;
|
2018-10-25 17:16:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
body.BorderColour = colours.Yellow;
|
|
|
|
}
|
|
|
|
|
2022-10-27 15:02:04 +08:00
|
|
|
private int? lastVersion;
|
|
|
|
|
2019-09-27 17:45:22 +08:00
|
|
|
public override void UpdateFrom(Slider hitObject)
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
2019-09-27 17:45:22 +08:00
|
|
|
base.UpdateFrom(hitObject);
|
2018-10-25 17:16:25 +08:00
|
|
|
|
2019-09-27 17:45:22 +08:00
|
|
|
body.PathRadius = hitObject.Scale * OsuHitObject.OBJECT_RADIUS;
|
2019-09-27 17:00:24 +08:00
|
|
|
|
2022-10-27 15:02:04 +08:00
|
|
|
if (lastVersion != hitObject.Path.Version.Value)
|
|
|
|
{
|
|
|
|
lastVersion = hitObject.Path.Version.Value;
|
|
|
|
|
|
|
|
var vertices = new List<Vector2>();
|
|
|
|
hitObject.Path.GetPathToProgress(vertices, 0, 1);
|
2018-10-25 18:34:35 +08:00
|
|
|
|
2022-10-27 15:02:04 +08:00
|
|
|
body.SetVertices(vertices);
|
|
|
|
}
|
2018-10-25 18:34:35 +08:00
|
|
|
|
2018-10-25 17:16:25 +08:00
|
|
|
Size = body.Size;
|
|
|
|
OriginPosition = body.PathOffset;
|
|
|
|
}
|
2019-11-05 16:31:52 +08:00
|
|
|
|
2020-10-09 13:05:00 +08:00
|
|
|
public void RecyclePath() => body.RecyclePath();
|
2021-05-08 22:33:03 +08:00
|
|
|
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => body.ReceivePositionalInputAt(screenSpacePos);
|
2018-10-25 17:16:25 +08:00
|
|
|
}
|
|
|
|
}
|