1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 22:47:20 +08:00
osu-lazer/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs

85 lines
2.9 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 13:22:42 +03:00
using osu.Framework.Allocation;
2019-02-21 19:04:31 +09:00
using osu.Framework.Bindables;
2018-05-20 13:22:42 +03:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
2018-05-20 13:22:42 +03:00
using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
using osu.Game.Rulesets.UI.Scrolling;
2018-11-20 16:51:59 +09:00
using osuTK;
using osuTK.Graphics;
2018-05-20 13:22:42 +03:00
2018-11-07 16:08:56 +09:00
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
2018-05-20 13:22:42 +03:00
{
public class HoldNoteSelectionBlueprint : ManiaSelectionBlueprint
2018-05-20 13:22:42 +03:00
{
public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject;
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
2018-05-20 13:22:42 +03:00
private readonly BodyPiece body;
2018-11-06 17:56:04 +09:00
public HoldNoteSelectionBlueprint(DrawableHoldNote hold)
2018-05-20 13:22:42 +03:00
: base(hold)
{
InternalChildren = new Drawable[]
{
2018-11-06 17:56:04 +09:00
new HoldNoteNoteSelectionBlueprint(hold.Head),
new HoldNoteNoteSelectionBlueprint(hold.Tail),
2018-05-22 09:09:25 +03:00
body = new BodyPiece
2018-05-20 13:22:42 +03:00
{
AccentColour = Color4.Transparent
},
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, IScrollingInfo scrollingInfo)
2018-05-20 13:22:42 +03:00
{
body.BorderColour = colours.Yellow;
direction.BindTo(scrollingInfo.Direction);
2018-05-20 13:22:42 +03:00
}
2018-06-07 19:00:02 +09:00
protected override void Update()
{
base.Update();
Size = HitObject.DrawSize + new Vector2(0, HitObject.Tail.DrawHeight);
// This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do
2018-07-19 19:44:06 +09:00
// When scrolling upwards our origin is already at the top of the head note (which is the intended location),
// but when scrolling downwards our origin is at the _bottom_ of the tail note (where we need to be at the _top_ of the tail note)
if (direction.Value == ScrollingDirection.Down)
Y -= HitObject.Tail.DrawHeight;
2018-06-07 19:00:02 +09:00
}
public override Quad SelectionQuad => ScreenSpaceDrawQuad;
2018-11-06 17:56:04 +09:00
private class HoldNoteNoteSelectionBlueprint : NoteSelectionBlueprint
2018-06-07 19:00:02 +09:00
{
2018-11-06 17:56:04 +09:00
public HoldNoteNoteSelectionBlueprint(DrawableNote note)
2018-06-07 19:00:02 +09:00
: base(note)
{
Select();
}
protected override void Update()
{
base.Update();
Anchor = HitObject.Anchor;
Origin = HitObject.Origin;
2018-06-07 19:00:02 +09:00
Position = HitObject.DrawPosition;
}
// Todo: This is temporary, since the note masks don't do anything special yet. In the future they will handle input.
public override bool HandlePositionalInput => false;
2018-06-07 19:00:02 +09:00
}
2018-05-20 13:22:42 +03:00
}
}