From edc624c4beb63114772cc9e2de80c85bff91af16 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 Sep 2022 16:07:16 +0900 Subject: [PATCH] Tweak slider ball fade to be less present after slider ends --- .../Skinning/Argon/ArgonSliderBall.cs | 58 ++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSliderBall.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSliderBall.cs index 5c31f079d4..ae5c75549c 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSliderBall.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSliderBall.cs @@ -1,11 +1,14 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Objects.Drawables; using osuTK; using osuTK.Graphics; @@ -16,6 +19,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon private readonly Box fill; private readonly SpriteIcon icon; + private readonly Vector2 defaultIconScale = new Vector2(0.6f, 0.8f); + + [Resolved(canBeNull: true)] + private DrawableHitObject? parentObject { get; set; } + public ArgonSliderBall() { Size = new Vector2(ArgonMainCirclePiece.OUTER_GRADIENT_SIZE); @@ -37,7 +45,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon icon = new SpriteIcon { Size = new Vector2(48), - Scale = new Vector2(0.6f, 0.8f), + Scale = defaultIconScale, Icon = FontAwesome.Solid.AngleRight, Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -45,11 +53,57 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon }; } + protected override void LoadComplete() + { + base.LoadComplete(); + + 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)) + { + this.FadeOut(duration, Easing.OutQuint); + icon.ScaleTo(defaultIconScale * icon_scale, duration, Easing.OutQuint); + } + } + protected override void Update() { base.Update(); - fill.Rotation = -Rotation; + //undo rotation on layers which should not be rotated. + float appliedRotation = Parent.Rotation; + + fill.Rotation = -appliedRotation; + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (parentObject != null) + parentObject.ApplyCustomUpdateState -= updateStateTransforms; } } }