2022-09-19 13:58:27 +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.
|
|
|
|
|
2022-09-19 15:07:16 +08:00
|
|
|
using osu.Framework.Allocation;
|
2023-01-04 21:18:33 +08:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2022-09-19 13:58:27 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Colour;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-09-19 15:07:16 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2022-09-19 13:58:27 +08:00
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Argon
|
|
|
|
{
|
|
|
|
public partial class ArgonSliderBall : CircularContainer
|
|
|
|
{
|
|
|
|
private readonly Box fill;
|
|
|
|
private readonly SpriteIcon icon;
|
|
|
|
|
2022-09-19 15:07:16 +08:00
|
|
|
private readonly Vector2 defaultIconScale = new Vector2(0.6f, 0.8f);
|
|
|
|
|
2023-01-04 21:18:33 +08:00
|
|
|
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
|
|
|
|
2022-09-19 15:07:16 +08:00
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
private DrawableHitObject? parentObject { get; set; }
|
|
|
|
|
2022-09-19 13:58:27 +08:00
|
|
|
public ArgonSliderBall()
|
|
|
|
{
|
|
|
|
Size = new Vector2(ArgonMainCirclePiece.OUTER_GRADIENT_SIZE);
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
|
2022-09-19 16:05:36 +08:00
|
|
|
BorderThickness = ArgonMainCirclePiece.GRADIENT_THICKNESS;
|
2022-09-19 13:58:27 +08:00
|
|
|
BorderColour = Color4.White;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
fill = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
|
|
|
icon = new SpriteIcon
|
|
|
|
{
|
|
|
|
Size = new Vector2(48),
|
2022-09-19 15:07:16 +08:00
|
|
|
Scale = defaultIconScale,
|
2022-09-19 13:58:27 +08:00
|
|
|
Icon = FontAwesome.Solid.AngleRight,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-01-04 21:18:33 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
if (parentObject != null)
|
|
|
|
accentColour.BindTo(parentObject.AccentColour);
|
|
|
|
}
|
|
|
|
|
2022-09-19 15:07:16 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2023-01-04 21:18:33 +08:00
|
|
|
accentColour.BindValueChanged(colour =>
|
|
|
|
{
|
|
|
|
fill.Colour = ColourInfo.GradientVertical(colour.NewValue, colour.NewValue.Darken(0.5f));
|
|
|
|
}, true);
|
|
|
|
|
2022-09-19 15:07:16 +08:00
|
|
|
if (parentObject != null)
|
|
|
|
{
|
|
|
|
parentObject.ApplyCustomUpdateState += updateStateTransforms;
|
|
|
|
updateStateTransforms(parentObject, parentObject.State.Value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateStateTransforms(DrawableHitObject drawableObject, ArmedState _)
|
|
|
|
{
|
|
|
|
// Gets called by slider ticks, tails, etc., leading to duplicated
|
|
|
|
// animations which in this case have no visual impact (due to
|
|
|
|
// instant fade) but may negatively affect performance
|
|
|
|
if (drawableObject is not DrawableSlider)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const float duration = 200;
|
|
|
|
const float icon_scale = 0.9f;
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(drawableObject.StateUpdateTime))
|
|
|
|
{
|
|
|
|
this.FadeInFromZero(duration, Easing.OutQuint);
|
|
|
|
icon.ScaleTo(0).Then().ScaleTo(defaultIconScale, duration, Easing.OutElasticHalf);
|
|
|
|
}
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(drawableObject.HitStateUpdateTime))
|
|
|
|
{
|
2023-05-02 14:47:35 +08:00
|
|
|
// intentionally pile on an extra FadeOut to make it happen much faster
|
|
|
|
this.FadeOut(duration / 4, Easing.OutQuint);
|
2022-09-19 15:07:16 +08:00
|
|
|
icon.ScaleTo(defaultIconScale * icon_scale, duration, Easing.OutQuint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-19 13:58:27 +08:00
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
2022-09-19 15:07:16 +08:00
|
|
|
//undo rotation on layers which should not be rotated.
|
2023-10-17 16:40:44 +08:00
|
|
|
float appliedRotation = Parent!.Rotation;
|
2022-09-19 15:07:16 +08:00
|
|
|
|
|
|
|
fill.Rotation = -appliedRotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
if (parentObject != null)
|
|
|
|
parentObject.ApplyCustomUpdateState -= updateStateTransforms;
|
2022-09-19 13:58:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|