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-04-13 17:19:50 +08:00
|
|
|
|
|
2019-10-24 18:02:59 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-10-24 18:02:59 +08:00
|
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2018-11-07 15:08:56 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-11-07 15:08:56 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-09-27 17:45:22 +08:00
|
|
|
|
public class SliderSelectionBlueprint : OsuSelectionBlueprint<Slider>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-10-01 18:33:24 +08:00
|
|
|
|
protected readonly SliderBodyPiece BodyPiece;
|
|
|
|
|
protected readonly SliderCircleSelectionBlueprint HeadBlueprint;
|
|
|
|
|
protected readonly SliderCircleSelectionBlueprint TailBlueprint;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-10-24 18:04:00 +08:00
|
|
|
|
[Resolved(CanBeNull = true)]
|
2019-10-24 18:02:59 +08:00
|
|
|
|
private HitObjectComposer composer { get; set; }
|
|
|
|
|
|
2018-11-06 16:56:04 +08:00
|
|
|
|
public SliderSelectionBlueprint(DrawableSlider slider)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
: base(slider)
|
|
|
|
|
{
|
|
|
|
|
var sliderObject = (Slider)slider.HitObject;
|
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
2019-10-01 18:33:24 +08:00
|
|
|
|
BodyPiece = new SliderBodyPiece(),
|
|
|
|
|
HeadBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.Start),
|
|
|
|
|
TailBlueprint = CreateCircleSelectionBlueprint(slider, SliderPosition.End),
|
2019-10-24 18:02:59 +08:00
|
|
|
|
new PathControlPointVisualiser(sliderObject) { ControlPointsChanged = onNewControlPoints },
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-27 17:45:22 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
2019-10-01 18:33:24 +08:00
|
|
|
|
BodyPiece.UpdateFrom(HitObject);
|
2019-09-27 17:45:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-24 18:02:59 +08:00
|
|
|
|
private void onNewControlPoints(Vector2[] controlPoints)
|
|
|
|
|
{
|
|
|
|
|
var unsnappedPath = new SliderPath(controlPoints.Length > 2 ? PathType.Bezier : PathType.Linear, controlPoints);
|
2019-10-25 11:34:49 +08:00
|
|
|
|
var snappedDistance = composer?.GetSnappedDistanceFromDistance(HitObject.StartTime, (float)unsnappedPath.Distance) ?? (float)unsnappedPath.Distance;
|
2019-10-24 18:02:59 +08:00
|
|
|
|
|
|
|
|
|
HitObject.Path = new SliderPath(unsnappedPath.Type, controlPoints, snappedDistance);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 18:33:24 +08:00
|
|
|
|
public override Vector2 SelectionPoint => HeadBlueprint.SelectionPoint;
|
|
|
|
|
|
2019-10-25 17:37:44 +08:00
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => BodyPiece.ReceivePositionalInputAt(screenSpacePos);
|
|
|
|
|
|
2019-10-01 18:33:24 +08:00
|
|
|
|
protected virtual SliderCircleSelectionBlueprint CreateCircleSelectionBlueprint(DrawableSlider slider, SliderPosition position) => new SliderCircleSelectionBlueprint(slider, position);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|