1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 14:03:22 +08:00
osu-lazer/osu.Game.Rulesets.Mania/Skinning/Argon/ArgonHoldNoteTailPiece.cs

106 lines
3.8 KiB
C#
Raw Normal View History

2022-10-06 15:54:47 +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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2023-01-23 15:01:45 +08:00
using osu.Framework.Graphics.Sprites;
2022-10-06 15:54:47 +08:00
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
2023-01-23 15:01:45 +08:00
using osuTK;
2022-10-06 15:54:47 +08:00
using osuTK.Graphics;
namespace osu.Game.Rulesets.Mania.Skinning.Argon
{
2022-11-24 13:32:20 +08:00
internal partial class ArgonHoldNoteTailPiece : CompositeDrawable
2022-10-06 15:54:47 +08:00
{
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
2023-01-23 15:01:45 +08:00
private readonly Container spriteContainer;
private readonly Container shadeContainer;
private readonly Circle hitLine;
2022-10-06 15:54:47 +08:00
public ArgonHoldNoteTailPiece()
{
RelativeSizeAxes = Axes.X;
2023-01-23 15:01:45 +08:00
// multiply by two so that the hold body extends up to the height of the note head accent
Height = ArgonNotePiece.NOTE_HEIGHT * ArgonNotePiece.NOTE_ACCENT_RATIO * 2;
2022-10-06 15:54:47 +08:00
CornerRadius = ArgonNotePiece.CORNER_RADIUS;
Masking = true;
InternalChildren = new Drawable[]
{
2023-01-23 15:01:45 +08:00
shadeContainer = new Container {
2022-10-06 15:54:47 +08:00
RelativeSizeAxes = Axes.Both,
2023-01-23 15:01:45 +08:00
Height = 0.5f,
2022-10-06 15:54:47 +08:00
CornerRadius = ArgonNotePiece.CORNER_RADIUS,
2023-01-23 15:01:45 +08:00
Masking = true,
Children = new Drawable[] {
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.2f,
},
},
},
spriteContainer = new Container {
RelativeSizeAxes = Axes.X,
Height = ArgonNotePiece.NOTE_HEIGHT,
2022-10-06 15:54:47 +08:00
Children = new Drawable[]
{
2023-01-23 15:01:45 +08:00
new SpriteIcon
2022-10-06 15:54:47 +08:00
{
2023-01-23 15:01:45 +08:00
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Y = 4,
Icon = FontAwesome.Solid.AngleDown,
Size = new Vector2(20),
Scale = new Vector2(1, 0.7f),
Colour = Color4.White,
Alpha = 0.2f,
},
},
2022-10-06 15:54:47 +08:00
},
2023-01-23 15:01:45 +08:00
hitLine = new Circle {
2022-10-06 15:54:47 +08:00
RelativeSizeAxes = Axes.X,
Height = ArgonNotePiece.CORNER_RADIUS * 2,
},
};
}
[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)
{
2023-01-23 15:01:45 +08:00
hitLine.Anchor = hitLine.Origin =
spriteContainer.Anchor = spriteContainer.Origin =
shadeContainer.Anchor = shadeContainer.Origin =
direction.NewValue == ScrollingDirection.Up
? Anchor.TopCentre
: Anchor.BottomCentre;
2022-10-06 15:54:47 +08:00
}
private void onAccentChanged(ValueChangedEvent<Color4> accent)
{
2023-01-23 15:01:45 +08:00
hitLine.Colour = accent.NewValue;
2022-10-06 15:54:47 +08:00
}
}
}