osu/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs

73 lines
2.6 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 10:22:42 +00:00
using osu.Framework.Allocation;
2019-02-21 10:04:31 +00:00
using osu.Framework.Bindables;
2018-05-20 10:22:42 +00:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
2018-05-20 10:22:42 +00: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 07:51:59 +00:00
using osuTK;
using osuTK.Graphics;
2018-05-20 10:22:42 +00:00
2018-11-07 07:08:56 +00:00
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
2018-05-20 10:22:42 +00:00
{
public class HoldNoteSelectionBlueprint : ManiaSelectionBlueprint
2018-05-20 10:22:42 +00:00
{
public new DrawableHoldNote DrawableObject => (DrawableHoldNote)base.DrawableObject;
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
[Resolved]
private OsuColour colours { get; set; }
2018-05-20 10:22:42 +00:00
2018-11-06 08:56:04 +00:00
public HoldNoteSelectionBlueprint(DrawableHoldNote hold)
2018-05-20 10:22:42 +00:00
: base(hold)
{
}
[BackgroundDependencyLoader]
private void load(IScrollingInfo scrollingInfo)
2018-05-20 10:22:42 +00:00
{
direction.BindTo(scrollingInfo.Direction);
2018-05-20 10:22:42 +00:00
}
2018-06-07 10:00:02 +00:00
protected override void LoadComplete()
{
base.LoadComplete();
InternalChildren = new Drawable[]
{
2019-11-07 04:23:00 +00:00
new HoldNoteNoteSelectionBlueprint(DrawableObject, HoldNotePosition.Start),
new HoldNoteNoteSelectionBlueprint(DrawableObject, HoldNotePosition.End),
new BodyPiece
{
AccentColour = Color4.Transparent,
BorderColour = colours.Yellow
},
};
}
2018-06-07 10:00:02 +00:00
protected override void Update()
{
base.Update();
2019-11-07 04:31:06 +00:00
// Todo: This shouldn't exist, mania should not reference the drawable hitobject directly.
if (DrawableObject.IsLoaded)
{
Size = DrawableObject.DrawSize + new Vector2(0, DrawableObject.Tail.DrawHeight);
2019-11-07 04:31:06 +00:00
// This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do
// 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 -= DrawableObject.Tail.DrawHeight;
}
2018-06-07 10:00:02 +00:00
}
public override Quad SelectionQuad => ScreenSpaceDrawQuad;
2018-05-20 10:22:42 +00:00
}
}