2018-10-25 17:16:25 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
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;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
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
|
|
|
{
|
2018-11-09 13:19:50 +08:00
|
|
|
public class SliderBodyPiece : SliderPiece
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
|
|
|
private readonly Slider slider;
|
2018-10-25 18:34:35 +08:00
|
|
|
private readonly ManualSliderBody body;
|
2018-10-25 17:16:25 +08:00
|
|
|
|
2018-10-26 12:51:03 +08:00
|
|
|
public SliderBodyPiece(Slider slider)
|
2018-11-09 13:19:50 +08:00
|
|
|
: base(slider)
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
|
|
|
this.slider = slider;
|
2018-10-25 18:34:35 +08:00
|
|
|
|
|
|
|
InternalChild = body = new ManualSliderBody
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
|
|
|
AccentColour = Color4.Transparent,
|
|
|
|
PathWidth = slider.Scale * 64
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
body.BorderColour = colours.Yellow;
|
|
|
|
|
2018-11-09 13:19:50 +08:00
|
|
|
PositionBindable.BindValueChanged(_ => updatePosition(), true);
|
|
|
|
ScaleBindable.BindValueChanged(v => body.PathWidth = v * 64, true);
|
2018-10-25 17:16:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void updatePosition() => Position = slider.StackedPosition;
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
2018-10-25 18:34:35 +08:00
|
|
|
var vertices = new List<Vector2>();
|
2018-11-01 16:59:37 +08:00
|
|
|
slider.Path.GetPathToProgress(vertices, 0, 1);
|
2018-10-25 18:34:35 +08:00
|
|
|
|
|
|
|
body.SetVertices(vertices);
|
|
|
|
|
2018-10-25 17:16:25 +08:00
|
|
|
Size = body.Size;
|
|
|
|
OriginPosition = body.PathOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|