1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 09:47:24 +08:00
osu-lazer/osu.Game.Rulesets.Mania/Skinning/Argon/ArgonHoldNoteTailPiece.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

82 lines
2.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;
2023-02-02 08:50:38 +08:00
using osuTK.Graphics;
using osu.Framework.Bindables;
2022-10-06 15:54:47 +08:00
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2023-02-02 08:50:38 +08:00
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
2023-02-02 08:50:38 +08:00
using osu.Framework.Graphics;
using osu.Framework.Extensions.Color4Extensions;
2022-10-06 15:54:47 +08:00
namespace osu.Game.Rulesets.Mania.Skinning.Argon
{
internal partial class ArgonHoldNoteTailPiece : CompositeDrawable
{
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
2023-02-02 08:50:38 +08:00
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
2023-02-02 08:50:38 +08:00
private readonly Box shadeBackground;
private readonly Box shadeForeground;
2022-10-06 15:54:47 +08:00
public ArgonHoldNoteTailPiece()
{
RelativeSizeAxes = Axes.X;
2023-02-02 08:50:38 +08:00
Height = ArgonNotePiece.NOTE_HEIGHT;
CornerRadius = ArgonNotePiece.CORNER_RADIUS;
Masking = true;
2023-01-31 16:23:25 +08:00
InternalChildren = new Drawable[]
{
2023-02-02 08:50:38 +08:00
shadeBackground = new Box
2023-01-31 16:23:25 +08:00
{
2023-02-02 08:50:38 +08:00
RelativeSizeAxes = Axes.Both,
},
new Container
{
RelativeSizeAxes = Axes.Both,
Height = ArgonNotePiece.NOTE_ACCENT_RATIO,
2023-02-01 09:52:58 +08:00
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
CornerRadius = ArgonNotePiece.CORNER_RADIUS,
Masking = true,
2023-01-31 16:23:25 +08:00
Children = new Drawable[]
{
2023-02-02 08:50:38 +08:00
shadeForeground = new Box
2023-01-31 16:23:25 +08:00
{
RelativeSizeAxes = Axes.Both,
},
},
2023-02-02 08:50:38 +08:00
},
};
}
[BackgroundDependencyLoader(true)]
2023-02-02 08:50:38 +08:00
private void load(IScrollingInfo scrollingInfo, DrawableHitObject? drawableObject)
{
direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(onDirectionChanged, true);
2023-02-02 08:50:38 +08:00
if (drawableObject != null)
{
accentColour.BindTo(drawableObject.AccentColour);
accentColour.BindValueChanged(onAccentChanged, true);
}
}
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
{
2023-02-01 09:52:58 +08:00
Scale = new osuTK.Vector2(1, direction.NewValue == ScrollingDirection.Up ? -1 : 1);
2022-10-06 15:54:47 +08:00
}
2023-02-02 08:50:38 +08:00
private void onAccentChanged(ValueChangedEvent<Color4> accent)
{
shadeBackground.Colour = accent.NewValue.Darken(1.7f);
shadeForeground.Colour = accent.NewValue.Darken(1.1f);
}
2022-10-06 15:54:47 +08:00
}
}