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

64 lines
1.9 KiB
C#
Raw Normal View History

// 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.Game.Graphics;
2018-03-14 14:18:21 +08:00
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-03-14 14:18:21 +08:00
public class SliderMask : HitObjectMask
{
private readonly SliderBody body;
private readonly DrawableSlider slider;
2018-03-14 14:18:21 +08:00
public SliderMask(DrawableSlider slider)
: base(slider)
{
this.slider = slider;
2018-03-09 22:12:34 +08:00
Position = slider.Position;
var sliderObject = (Slider)slider.HitObject;
InternalChildren = new Drawable[]
{
2018-03-09 22:12:34 +08:00
body = new SliderBody(sliderObject)
{
AccentColour = Color4.Transparent,
2018-03-09 22:12:34 +08:00
PathWidth = sliderObject.Scale * 64
},
2018-03-14 14:18:21 +08:00
new SliderCircleMask(slider.HeadCircle, slider),
new SliderCircleMask(slider.TailCircle, slider),
};
2018-03-09 22:12:34 +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;
2018-02-22 13:11:06 +08:00
// Need to cause one update
body.UpdateProgress(0);
}
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => body.ReceiveMouseInputAt(screenSpacePos);
}
}