2018-05-20 10:22:42 +00: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;
|
2018-07-19 10:30:20 +00:00
|
|
|
|
using osu.Framework.Configuration;
|
2018-05-20 10:22:42 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
2018-07-19 10:30:20 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
|
using OpenTK;
|
2018-05-20 10:22:42 +00:00
|
|
|
|
using OpenTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Edit.Layers.Selection.Overlays
|
|
|
|
|
{
|
|
|
|
|
public class HoldNoteMask : HitObjectMask
|
|
|
|
|
{
|
2018-07-19 10:30:20 +00:00
|
|
|
|
public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject;
|
|
|
|
|
|
|
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
|
|
|
|
2018-05-20 10:22:42 +00:00
|
|
|
|
private readonly BodyPiece body;
|
|
|
|
|
|
|
|
|
|
public HoldNoteMask(DrawableHoldNote hold)
|
|
|
|
|
: base(hold)
|
|
|
|
|
{
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
|
{
|
2018-06-07 10:00:02 +00:00
|
|
|
|
new HoldNoteNoteMask(hold.Head),
|
|
|
|
|
new HoldNoteNoteMask(hold.Tail),
|
2018-05-22 06:09:25 +00:00
|
|
|
|
body = new BodyPiece
|
2018-05-20 10:22:42 +00:00
|
|
|
|
{
|
|
|
|
|
AccentColour = Color4.Transparent
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-07-19 10:30:20 +00:00
|
|
|
|
private void load(OsuColour colours, IScrollingInfo scrollingInfo)
|
2018-05-20 10:22:42 +00:00
|
|
|
|
{
|
|
|
|
|
body.BorderColour = colours.Yellow;
|
2018-07-19 10:30:20 +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 Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
2018-07-19 10:30:20 +00:00
|
|
|
|
Size = HitObject.DrawSize + new Vector2(0, HitObject.Tail.DrawHeight);
|
2018-06-07 10:00:02 +00:00
|
|
|
|
Position = Parent.ToLocalSpace(HitObject.ScreenSpaceDrawQuad.TopLeft);
|
2018-07-19 10:30:20 +00:00
|
|
|
|
|
|
|
|
|
// This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do
|
2018-07-19 10:44:06 +00:00
|
|
|
|
// When scrolling upwards our origin is already at the top of the head note (which is the intended location),
|
2018-07-19 10:30:20 +00:00
|
|
|
|
// 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 10:00:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class HoldNoteNoteMask : NoteMask
|
|
|
|
|
{
|
|
|
|
|
public HoldNoteNoteMask(DrawableNote note)
|
|
|
|
|
: base(note)
|
|
|
|
|
{
|
|
|
|
|
Select();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
2018-07-19 10:30:20 +00:00
|
|
|
|
Anchor = HitObject.Anchor;
|
|
|
|
|
Origin = HitObject.Origin;
|
|
|
|
|
|
2018-06-07 10:00:02 +00:00
|
|
|
|
Position = HitObject.DrawPosition;
|
|
|
|
|
}
|
2018-07-19 10:32:47 +00:00
|
|
|
|
|
|
|
|
|
// Todo: This is temporary, since the note masks don't do anything special yet. In the future they will handle input.
|
2018-09-26 05:01:15 +00:00
|
|
|
|
public override bool HandlePositionalInput => false;
|
2018-06-07 10:00:02 +00:00
|
|
|
|
}
|
2018-05-20 10:22:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|