diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs index 547d0afe4a..f4dc1f18bd 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs @@ -40,6 +40,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables private int rollingHits; private readonly Container tickContainer; + private SkinnableDrawable headPiece; private Color4 colourIdle; private Color4 colourEngaged; @@ -59,7 +60,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables Content.Add(tickContainer = new Container { RelativeSizeAxes = Axes.Both, - Depth = float.MinValue + Depth = -1, }); } @@ -79,7 +80,13 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables protected override void RecreatePieces() { + if (headPiece != null) + Content.Remove(headPiece, true); + base.RecreatePieces(); + + Content.Add(headPiece = createHeadPiece()); + updateColour(); Height = HitObject.IsStrong ? TaikoStrongableHitObject.DEFAULT_STRONG_SIZE : TaikoHitObject.DEFAULT_SIZE; } @@ -122,6 +129,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.DrumRollBody), _ => new ElongatedCirclePiece()); + private SkinnableDrawable createHeadPiece() => new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.DrumRollHead), _ => Empty()) + { + RelativeSizeAxes = Axes.Y, + Depth = -2, + }; + public override bool OnPressed(KeyBindingPressEvent e) => false; private void onNewResult(DrawableHitObject obj, JudgementResult result) @@ -174,7 +187,23 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables private void updateColour(double fadeDuration = 0) { Color4 newColour = Interpolation.ValueAt((float)rollingHits / rolling_hits_for_engaged_colour, colourIdle, colourEngaged, 0, 1); - (MainPiece.Drawable as IHasAccentColour)?.FadeAccent(newColour, fadeDuration); + + if (fadeDuration == 0) + { + // fade duration is 0 when calling via `RecreatePieces()`. + // in this case we want to apply the colour *without* using transforms. + // using transforms may result in the application of colour being undone via `DrawableHitObject.UpdateState()` clearing transforms. + if (MainPiece.Drawable is IHasAccentColour mainPieceWithAccentColour) + mainPieceWithAccentColour.AccentColour = newColour; + + if (headPiece.Drawable is IHasAccentColour headPieceWithAccentColour) + headPieceWithAccentColour.AccentColour = newColour; + } + else + { + (MainPiece.Drawable as IHasAccentColour)?.FadeAccent(newColour, fadeDuration); + (headPiece.Drawable as IHasAccentColour)?.FadeAccent(newColour, fadeDuration); + } } public partial class StrongNestedHit : DrawableStrongNestedHit diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyDrumRoll.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyDrumRoll.cs index 78be0ef643..34339b185d 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyDrumRoll.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyDrumRoll.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -21,14 +20,10 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy { get { - // the reason why this calculation is so involved is that the head & tail sprites have different sizes/radii. - // therefore naively taking the SSDQs of them and making a quad out of them results in a trapezoid shape and not a box. - var headCentre = headCircle.ScreenSpaceDrawQuad.Centre; + var headCentre = (body.ScreenSpaceDrawQuad.TopLeft + body.ScreenSpaceDrawQuad.BottomLeft) / 2; var tailCentre = (tailCircle.ScreenSpaceDrawQuad.TopLeft + tailCircle.ScreenSpaceDrawQuad.BottomLeft) / 2; - float headRadius = headCircle.ScreenSpaceDrawQuad.Height / 2; - float tailRadius = tailCircle.ScreenSpaceDrawQuad.Height / 2; - float radius = Math.Max(headRadius, tailRadius); + float radius = body.ScreenSpaceDrawQuad.Height / 2; var rectangle = new RectangleF(headCentre.X, headCentre.Y, tailCentre.X - headCentre.X, 0).Inflate(radius); return new Quad(rectangle.TopLeft, rectangle.TopRight, rectangle.BottomLeft, rectangle.BottomRight); @@ -37,8 +32,6 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => ScreenSpaceDrawQuad.Contains(screenSpacePos); - private LegacyCirclePiece headCircle = null!; - private Sprite body = null!; private Sprite tailCircle = null!; @@ -66,10 +59,6 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy RelativeSizeAxes = Axes.Both, Texture = skin.GetTexture("taiko-roll-middle", WrapMode.ClampToEdge, WrapMode.ClampToEdge), }, - headCircle = new LegacyCirclePiece - { - RelativeSizeAxes = Axes.Y, - }, }; AccentColour = colours.YellowDark; @@ -101,7 +90,6 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy { var colour = LegacyColourCompatibility.DisallowZeroAlpha(accentColour); - headCircle.AccentColour = colour; body.Colour = colour; tailCircle.Colour = colour; } diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs index b5c767c2be..73d32a7933 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/TaikoLegacySkinTransformer.cs @@ -103,6 +103,12 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy { switch (taikoComponent.Component) { + case TaikoSkinComponents.DrumRollHead: + if (GetTexture("taiko-roll-middle") != null) + return new LegacyCirclePiece(); + + return null; + case TaikoSkinComponents.DrumRollBody: if (GetTexture("taiko-roll-middle") != null) return new LegacyDrumRoll(); diff --git a/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs b/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs index 28133ffcb2..31342b30c4 100644 --- a/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs +++ b/osu.Game.Rulesets.Taiko/TaikoSkinComponents.cs @@ -8,6 +8,7 @@ namespace osu.Game.Rulesets.Taiko InputDrum, CentreHit, RimHit, + DrumRollHead, DrumRollBody, DrumRollTick, Swell,