1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 09:32:54 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Edit/Layers/Selection/Overlays/SliderSelectionMask.cs

68 lines
2.1 KiB
C#
Raw Normal View History

2018-04-13 17:19:50 +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;
using osu.Framework.Graphics.Primitives;
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Osu.Edit.Layers.Selection.Overlays
{
2018-10-03 12:28:00 +08:00
public class SliderSelectionMask : SelectionMask
2018-04-13 17:19:50 +08:00
{
private readonly SliderBody body;
private readonly DrawableSlider slider;
2018-10-03 12:28:00 +08:00
public SliderSelectionMask(DrawableSlider slider)
2018-04-13 17:19:50 +08:00
: base(slider)
{
this.slider = slider;
Position = slider.Position;
var sliderObject = (Slider)slider.HitObject;
InternalChildren = new Drawable[]
{
body = new SliderBody(sliderObject)
{
AccentColour = Color4.Transparent,
PathWidth = sliderObject.Scale * 64
},
2018-10-03 12:28:00 +08:00
new SliderCircleSelectionMask(slider.HeadCircle, slider),
new SliderCircleSelectionMask(slider.TailCircle, slider),
2018-04-13 17:19:50 +08:00
};
sliderObject.PositionChanged += _ => Position = slider.Position;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
body.BorderColour = colours.Yellow;
}
protected override void Update()
{
base.Update();
Size = slider.Size;
OriginPosition = slider.OriginPosition;
// Need to cause one update
body.UpdateProgress(0);
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => body.ReceivePositionalInputAt(screenSpacePos);
2018-04-13 17:19:50 +08:00
public override Vector2 SelectionPoint => ToScreenSpace(OriginPosition);
public override Quad SelectionQuad => body.PathDrawQuad;
}
}