1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 16:17:52 +08:00
osu-lazer/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

112 lines
4.1 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-05-20 18:22:42 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2020-03-31 15:42:35 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
2020-03-31 15:42:35 +08:00
using osu.Framework.Graphics.Shapes;
2018-05-20 18:22:42 +08:00
using osu.Game.Graphics;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Edit.Blueprints.Components;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Screens.Edit;
2018-11-20 15:51:59 +08:00
using osuTK;
2018-05-20 18:22:42 +08:00
2018-11-07 15:08:56 +08:00
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
2018-05-20 18:22:42 +08:00
{
public partial class HoldNoteSelectionBlueprint : ManiaSelectionBlueprint<HoldNote>
2018-05-20 18:22:42 +08:00
{
[Resolved]
private OsuColour colours { get; set; } = null!;
[Resolved]
private IEditorChangeHandler? changeHandler { get; set; }
[Resolved]
private EditorBeatmap? editorBeatmap { get; set; }
[Resolved]
private IPositionSnapProvider? positionSnapProvider { get; set; }
2018-05-20 18:22:42 +08:00
private EditHoldNoteEndPiece head = null!;
private EditHoldNoteEndPiece tail = null!;
public HoldNoteSelectionBlueprint(HoldNote hold)
2018-05-20 18:22:42 +08:00
: base(hold)
{
}
[BackgroundDependencyLoader]
2022-01-15 08:06:39 +08:00
private void load()
2018-05-20 18:22:42 +08:00
{
InternalChildren = new Drawable[]
{
head = new EditHoldNoteEndPiece
{
RelativeSizeAxes = Axes.X,
DragStarted = () => changeHandler?.BeginChange(),
Dragging = pos =>
{
double endTimeBeforeDrag = HitObject.EndTime;
double proposedStartTime = positionSnapProvider?.FindSnappedPositionAndTime(pos).Time ?? HitObjectContainer.TimeAtScreenSpacePosition(pos);
double proposedEndTime = endTimeBeforeDrag;
if (proposedStartTime >= proposedEndTime)
return;
HitObject.StartTime = proposedStartTime;
HitObject.EndTime = proposedEndTime;
editorBeatmap?.Update(HitObject);
},
DragEnded = () => changeHandler?.EndChange(),
},
tail = new EditHoldNoteEndPiece
{
RelativeSizeAxes = Axes.X,
DragStarted = () => changeHandler?.BeginChange(),
Dragging = pos =>
{
double proposedStartTime = HitObject.StartTime;
double proposedEndTime = positionSnapProvider?.FindSnappedPositionAndTime(pos).Time ?? HitObjectContainer.TimeAtScreenSpacePosition(pos);
if (proposedStartTime >= proposedEndTime)
return;
HitObject.StartTime = proposedStartTime;
HitObject.EndTime = proposedEndTime;
editorBeatmap?.Update(HitObject);
},
DragEnded = () => changeHandler?.EndChange(),
},
2020-03-31 15:42:35 +08:00
new Container
{
2020-03-31 15:42:35 +08:00
RelativeSizeAxes = Axes.Both,
2020-04-11 14:20:27 +08:00
Masking = true,
2020-03-31 15:42:35 +08:00
BorderThickness = 1,
BorderColour = colours.Yellow,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
}
}
};
}
2018-06-07 18:00:02 +08:00
protected override void Update()
{
base.Update();
head.Y = HitObjectContainer.PositionAtTime(HitObject.Head.StartTime, HitObject.StartTime);
tail.Y = HitObjectContainer.PositionAtTime(HitObject.Tail.StartTime, HitObject.StartTime);
Height = HitObjectContainer.LengthAtTime(HitObject.StartTime, HitObject.EndTime) + tail.DrawHeight;
2018-06-07 18:00:02 +08:00
}
public override Quad SelectionQuad => ScreenSpaceDrawQuad;
2020-04-23 16:52:54 +08:00
public override Vector2 ScreenSpaceSelectionPoint => head.ScreenSpaceDrawQuad.Centre;
2018-05-20 18:22:42 +08:00
}
}