2022-10-06 15:54:08 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning.Argon
|
|
|
|
{
|
|
|
|
internal partial class ArgonNotePiece : CompositeDrawable
|
|
|
|
{
|
|
|
|
public const float NOTE_HEIGHT = 42;
|
2023-01-23 15:01:45 +08:00
|
|
|
public const float NOTE_ACCENT_RATIO = 0.82f;
|
2022-10-07 17:44:24 +08:00
|
|
|
public const float CORNER_RADIUS = 3.4f;
|
2022-10-06 15:54:08 +08:00
|
|
|
|
|
|
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
|
|
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
|
|
|
|
|
|
|
private readonly Box colouredBox;
|
|
|
|
private readonly Box shadow;
|
|
|
|
|
|
|
|
public ArgonNotePiece()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
Height = NOTE_HEIGHT;
|
|
|
|
|
|
|
|
CornerRadius = CORNER_RADIUS;
|
|
|
|
Masking = true;
|
|
|
|
|
2023-03-09 18:02:15 +08:00
|
|
|
InternalChildren = new[]
|
2022-10-06 15:54:08 +08:00
|
|
|
{
|
|
|
|
shadow = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2023-01-23 15:01:45 +08:00
|
|
|
Height = NOTE_ACCENT_RATIO,
|
2022-10-06 15:54:08 +08:00
|
|
|
Masking = true,
|
|
|
|
CornerRadius = CORNER_RADIUS,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
colouredBox = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new Circle
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Height = CORNER_RADIUS * 2,
|
|
|
|
},
|
2023-03-09 18:02:15 +08:00
|
|
|
CreateIcon(),
|
2022-10-06 15:54:08 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-09 18:02:15 +08:00
|
|
|
protected virtual Drawable CreateIcon() => new SpriteIcon
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Y = 4,
|
|
|
|
// TODO: replace with a non-squashed version.
|
|
|
|
// The 0.7f height scale should be removed.
|
|
|
|
Icon = FontAwesome.Solid.AngleDown,
|
|
|
|
Size = new Vector2(20),
|
|
|
|
Scale = new Vector2(1, 0.7f)
|
|
|
|
};
|
|
|
|
|
2022-10-06 15:54:08 +08:00
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
private void load(IScrollingInfo scrollingInfo, DrawableHitObject? drawableObject)
|
|
|
|
{
|
|
|
|
direction.BindTo(scrollingInfo.Direction);
|
|
|
|
direction.BindValueChanged(onDirectionChanged, true);
|
|
|
|
|
|
|
|
if (drawableObject != null)
|
|
|
|
{
|
|
|
|
accentColour.BindTo(drawableObject.AccentColour);
|
|
|
|
accentColour.BindValueChanged(onAccentChanged, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
|
|
|
{
|
|
|
|
colouredBox.Anchor = colouredBox.Origin = direction.NewValue == ScrollingDirection.Up
|
|
|
|
? Anchor.TopCentre
|
|
|
|
: Anchor.BottomCentre;
|
2023-02-01 09:52:58 +08:00
|
|
|
|
|
|
|
Scale = new Vector2(1, direction.NewValue == ScrollingDirection.Up ? -1 : 1);
|
2022-10-06 15:54:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onAccentChanged(ValueChangedEvent<Color4> accent)
|
|
|
|
{
|
|
|
|
colouredBox.Colour = ColourInfo.GradientVertical(
|
|
|
|
accent.NewValue.Lighten(0.1f),
|
|
|
|
accent.NewValue
|
|
|
|
);
|
|
|
|
|
|
|
|
shadow.Colour = accent.NewValue.Darken(0.5f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|