1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:33:20 +08:00

now without the weird hacks

This commit is contained in:
itsMapleLeaf 2023-02-01 18:50:38 -06:00
parent 0d6e757baf
commit a8ce0a3278

View File

@ -2,84 +2,80 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osuTK.Graphics;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Framework.Graphics;
using osu.Framework.Extensions.Color4Extensions;
namespace osu.Game.Rulesets.Mania.Skinning.Argon namespace osu.Game.Rulesets.Mania.Skinning.Argon
{ {
internal partial class ArgonHoldNoteTailPiece : CompositeDrawable internal partial class ArgonHoldNoteTailPiece : CompositeDrawable
{ {
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>(); private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
private readonly Container container; private readonly Box shadeBackground;
private readonly Box shadeForeground;
public ArgonHoldNoteTailPiece() public ArgonHoldNoteTailPiece()
{ {
// holds end at the middle of the tail,
// so we do * 2 pull up the hold body to be the height of a note
Height = ArgonNotePiece.NOTE_HEIGHT * 2;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Height = ArgonNotePiece.NOTE_HEIGHT;
CornerRadius = ArgonNotePiece.CORNER_RADIUS; CornerRadius = ArgonNotePiece.CORNER_RADIUS;
Masking = true; Masking = true;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
container = new Container shadeBackground = new Box
{ {
RelativeSizeAxes = Axes.Both,
},
new Container
{
RelativeSizeAxes = Axes.Both,
Height = ArgonNotePiece.NOTE_ACCENT_RATIO,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
CornerRadius = ArgonNotePiece.CORNER_RADIUS, CornerRadius = ArgonNotePiece.CORNER_RADIUS,
Masking = true, Masking = true,
Children = new Drawable[] Children = new Drawable[]
{ {
new Box shadeForeground = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Colour4.Black,
Alpha = 0.4f,
},
new Container
{
CornerRadius = ArgonNotePiece.CORNER_RADIUS,
Masking = true,
RelativeSizeAxes = Axes.Both,
Height = 1 - ArgonNotePiece.NOTE_ACCENT_RATIO,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Colour4.Black,
Alpha = 0.3f,
}
}
}, },
}, },
} },
}; };
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(IScrollingInfo scrollingInfo) private void load(IScrollingInfo scrollingInfo, DrawableHitObject? drawableObject)
{ {
direction.BindTo(scrollingInfo.Direction); direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(onDirectionChanged, true); direction.BindValueChanged(onDirectionChanged, true);
if (drawableObject != null)
{
accentColour.BindTo(drawableObject.AccentColour);
accentColour.BindValueChanged(onAccentChanged, true);
}
} }
private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction) private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
{ {
Scale = new osuTK.Vector2(1, direction.NewValue == ScrollingDirection.Up ? -1 : 1); Scale = new osuTK.Vector2(1, direction.NewValue == ScrollingDirection.Up ? -1 : 1);
} }
private void onAccentChanged(ValueChangedEvent<Color4> accent)
{
shadeBackground.Colour = accent.NewValue.Darken(1.7f);
shadeForeground.Colour = accent.NewValue.Darken(1.1f);
}
} }
} }