2018-02-20 17:01:45 +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;
|
2018-03-29 21:06:45 +08:00
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2018-02-20 17:01:45 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2018-03-14 14:18:21 +08:00
|
|
|
|
using osu.Game.Rulesets.Edit;
|
2018-02-20 17:01:45 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
2018-03-12 16:33:10 +08:00
|
|
|
|
using OpenTK;
|
2018-02-20 17:01:45 +08:00
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
|
|
|
|
|
{
|
2018-03-14 14:18:21 +08:00
|
|
|
|
public class SliderMask : HitObjectMask
|
2018-02-20 17:01:45 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly SliderBody body;
|
2018-03-01 13:34:31 +08:00
|
|
|
|
private readonly DrawableSlider slider;
|
2018-02-20 17:01:45 +08:00
|
|
|
|
|
2018-03-14 14:18:21 +08:00
|
|
|
|
public SliderMask(DrawableSlider slider)
|
2018-02-20 17:01:45 +08:00
|
|
|
|
: base(slider)
|
|
|
|
|
{
|
2018-03-01 13:34:31 +08:00
|
|
|
|
this.slider = slider;
|
|
|
|
|
|
2018-03-09 22:12:34 +08:00
|
|
|
|
Position = slider.Position;
|
|
|
|
|
|
|
|
|
|
var sliderObject = (Slider)slider.HitObject;
|
2018-02-20 17:01:45 +08:00
|
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
2018-03-09 22:12:34 +08:00
|
|
|
|
body = new SliderBody(sliderObject)
|
2018-02-20 17:01:45 +08:00
|
|
|
|
{
|
|
|
|
|
AccentColour = Color4.Transparent,
|
2018-03-09 22:12:34 +08:00
|
|
|
|
PathWidth = sliderObject.Scale * 64
|
2018-02-20 17:01:45 +08:00
|
|
|
|
},
|
2018-03-14 14:18:21 +08:00
|
|
|
|
new SliderCircleMask(slider.HeadCircle, slider),
|
|
|
|
|
new SliderCircleMask(slider.TailCircle, slider),
|
2018-02-20 17:01:45 +08:00
|
|
|
|
};
|
2018-03-09 22:12:34 +08:00
|
|
|
|
|
|
|
|
|
sliderObject.PositionChanged += _ => Position = slider.Position;
|
2018-02-20 17:01:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
body.BorderColour = colours.Yellow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
2018-03-01 13:34:31 +08:00
|
|
|
|
Size = slider.Size;
|
|
|
|
|
OriginPosition = slider.OriginPosition;
|
|
|
|
|
|
2018-02-22 13:11:06 +08:00
|
|
|
|
// Need to cause one update
|
|
|
|
|
body.UpdateProgress(0);
|
2018-02-20 17:01:45 +08:00
|
|
|
|
}
|
2018-03-12 16:33:10 +08:00
|
|
|
|
|
|
|
|
|
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => body.ReceiveMouseInputAt(screenSpacePos);
|
2018-03-29 21:06:45 +08:00
|
|
|
|
|
|
|
|
|
public override Vector2 SelectionPoint => ToScreenSpace(OriginPosition);
|
|
|
|
|
public override Quad SelectionQuad => body.PathDrawQuad;
|
2018-02-20 17:01:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|