2018-10-25 09:16:25 +00: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 10:34:35 +00:00
|
|
|
using System.Collections.Generic;
|
2018-10-25 09:16:25 +00:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
2018-10-25 10:34:35 +00:00
|
|
|
using OpenTK;
|
2018-10-25 09:16:25 +00:00
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
|
|
|
|
{
|
2018-10-26 04:51:03 +00:00
|
|
|
public class SliderBodyPiece : CompositeDrawable
|
2018-10-25 09:16:25 +00:00
|
|
|
{
|
|
|
|
private readonly Slider slider;
|
2018-10-25 10:34:35 +00:00
|
|
|
private readonly ManualSliderBody body;
|
2018-10-25 09:16:25 +00:00
|
|
|
|
2018-10-26 04:51:03 +00:00
|
|
|
public SliderBodyPiece(Slider slider)
|
2018-10-25 09:16:25 +00:00
|
|
|
{
|
|
|
|
this.slider = slider;
|
2018-10-25 10:34:35 +00:00
|
|
|
|
|
|
|
InternalChild = body = new ManualSliderBody
|
2018-10-25 09:16:25 +00:00
|
|
|
{
|
|
|
|
AccentColour = Color4.Transparent,
|
|
|
|
PathWidth = slider.Scale * 64
|
|
|
|
};
|
|
|
|
|
|
|
|
slider.PositionChanged += _ => updatePosition();
|
2018-10-26 06:33:21 +00:00
|
|
|
slider.ScaleChanged += _ => body.PathWidth = slider.Scale * 64;
|
2018-10-25 09:16:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
body.BorderColour = colours.Yellow;
|
|
|
|
|
|
|
|
updatePosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updatePosition() => Position = slider.StackedPosition;
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
2018-11-01 08:59:37 +00:00
|
|
|
slider.Path.Calculate();
|
2018-10-25 10:34:35 +00:00
|
|
|
|
|
|
|
var vertices = new List<Vector2>();
|
2018-11-01 08:59:37 +00:00
|
|
|
slider.Path.GetPathToProgress(vertices, 0, 1);
|
2018-10-25 10:34:35 +00:00
|
|
|
|
|
|
|
body.SetVertices(vertices);
|
|
|
|
|
2018-10-25 09:16:25 +00:00
|
|
|
Size = body.Size;
|
|
|
|
OriginPosition = body.PathOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|