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.
|
|
|
|
|
2023-01-31 16:22:40 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
2023-02-02 09:22:28 +08:00
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
2022-10-06 15:54:47 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2023-01-31 16:22:40 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
2023-02-02 08:50:38 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2023-01-31 16:22:40 +08:00
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
2023-02-02 09:22:28 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2022-10-06 15:54:47 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Skinning.Argon
|
|
|
|
{
|
|
|
|
internal partial class ArgonHoldNoteTailPiece : CompositeDrawable
|
|
|
|
{
|
2023-01-31 16:22:40 +08:00
|
|
|
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-01-31 16:22:40 +08:00
|
|
|
|
2023-02-02 08:50:38 +08:00
|
|
|
private readonly Box shadeBackground;
|
|
|
|
private readonly Box shadeForeground;
|
2023-01-31 16:22:40 +08:00
|
|
|
|
2022-10-06 15:54:47 +08:00
|
|
|
public ArgonHoldNoteTailPiece()
|
|
|
|
{
|
2023-01-31 16:22:40 +08:00
|
|
|
RelativeSizeAxes = Axes.X;
|
2023-02-02 08:50:38 +08:00
|
|
|
Height = ArgonNotePiece.NOTE_HEIGHT;
|
2023-01-31 16:22:40 +08:00
|
|
|
|
|
|
|
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,
|
2023-01-31 16:22:40 +08:00
|
|
|
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
|
|
|
{
|
2023-01-31 16:22:40 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
|
|
|
},
|
2023-02-02 08:50:38 +08:00
|
|
|
},
|
2023-01-31 16:22:40 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(true)]
|
2023-02-02 08:50:38 +08:00
|
|
|
private void load(IScrollingInfo scrollingInfo, DrawableHitObject? drawableObject)
|
2023-01-31 16:22:40 +08:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2023-01-31 16:22:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
|
|
|
|
{
|
2023-02-02 09:22:28 +08:00
|
|
|
Scale = new 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
|
|
|
}
|
|
|
|
}
|