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
|
|
|
|
|
|
|
|
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;
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks.Components
|
|
|
|
{
|
2018-10-26 12:51:03 +08:00
|
|
|
public class SliderBodyPiece : CompositeDrawable
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
|
|
|
private readonly Slider slider;
|
2018-10-29 14:25:20 +08:00
|
|
|
private readonly SnakingSliderBody body;
|
2018-10-25 17:16:25 +08:00
|
|
|
|
2018-10-26 12:51:03 +08:00
|
|
|
public SliderBodyPiece(Slider slider)
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
|
|
|
this.slider = slider;
|
2018-10-29 14:25:20 +08:00
|
|
|
InternalChild = body = new SnakingSliderBody(slider)
|
2018-10-25 17:16:25 +08:00
|
|
|
{
|
|
|
|
AccentColour = Color4.Transparent,
|
|
|
|
PathWidth = slider.Scale * 64
|
|
|
|
};
|
|
|
|
|
|
|
|
slider.PositionChanged += _ => updatePosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
body.BorderColour = colours.Yellow;
|
|
|
|
|
|
|
|
updatePosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updatePosition() => Position = slider.StackedPosition;
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
Size = body.Size;
|
|
|
|
OriginPosition = body.PathOffset;
|
|
|
|
|
|
|
|
// Need to cause one update
|
|
|
|
body.UpdateProgress(0);
|
2018-10-29 14:36:43 +08:00
|
|
|
body.Refresh();
|
2018-10-25 17:16:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|