2019-01-24 16:43:03 +08:00
|
|
|
|
// 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-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-08 19:13:24 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-06-08 14:17:22 +08:00
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Objects.Drawables.Pieces
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the static hit markers of notes.
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal class NotePiece : Container, IHasAccentColour
|
|
|
|
|
{
|
2018-06-07 13:27:59 +08:00
|
|
|
|
public const float NOTE_HEIGHT = 10;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private const float head_colour_height = 6;
|
|
|
|
|
|
2018-06-08 20:41:20 +08:00
|
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private readonly Box colouredBox;
|
|
|
|
|
|
|
|
|
|
public NotePiece()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2018-06-07 13:27:59 +08:00
|
|
|
|
Height = NOTE_HEIGHT;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
},
|
|
|
|
|
colouredBox = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = head_colour_height,
|
|
|
|
|
Alpha = 0.2f
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-08 19:13:24 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2018-06-08 20:41:20 +08:00
|
|
|
|
private void load(IScrollingInfo scrollingInfo)
|
2018-06-08 14:17:22 +08:00
|
|
|
|
{
|
2018-06-08 20:41:20 +08:00
|
|
|
|
direction.BindTo(scrollingInfo.Direction);
|
2019-02-22 19:13:38 +08:00
|
|
|
|
direction.BindValueChanged(dir =>
|
2018-06-08 20:41:20 +08:00
|
|
|
|
{
|
2019-02-22 19:13:38 +08:00
|
|
|
|
colouredBox.Anchor = colouredBox.Origin = dir.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre;
|
2018-06-08 20:41:20 +08:00
|
|
|
|
}, true);
|
2018-06-08 14:17:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private Color4 accentColour;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public Color4 AccentColour
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => accentColour;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (accentColour == value)
|
|
|
|
|
return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
accentColour = value;
|
|
|
|
|
|
|
|
|
|
colouredBox.Colour = AccentColour.Lighten(0.9f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|