diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySpinnerBonusCounter.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySpinnerBonusCounter.cs new file mode 100644 index 0000000000..3c4a6be4dd --- /dev/null +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySpinnerBonusCounter.cs @@ -0,0 +1,56 @@ +// 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.Bindables; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Skinning; +using osuTK; +using static osu.Game.Rulesets.Osu.Skinning.Legacy.LegacySpinner; + +namespace osu.Game.Rulesets.Osu.Skinning.Legacy +{ + public class LegacySpinnerBonusCounter : CompositeDrawable + { + private LegacySpriteText bonusCounter; + + private DrawableSpinner drawableSpinner; + + private IBindable gainedBonus; + + [BackgroundDependencyLoader] + private void load(DrawableHitObject drawableHitObject, ISkinSource source) + { + drawableSpinner = (DrawableSpinner)drawableHitObject; + + InternalChild = new LegacyCoordinatesContainer + { + Child = bonusCounter = ((LegacySpriteText)source.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreText))).With(s => + { + s.Alpha = 0f; + s.Anchor = Anchor.TopCentre; + s.Origin = Anchor.Centre; + s.Font = s.Font.With(fixedWidth: false); + s.Scale = new Vector2(SPRITE_SCALE); + s.Y = LegacyCoordinatesContainer.SPINNER_TOP_OFFSET + 299; + }), + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + gainedBonus = drawableSpinner.GainedBonus.GetBoundCopy(); + gainedBonus.BindValueChanged(bonus => + { + bonusCounter.Text = $"{bonus.NewValue}"; + bonusCounter.FadeOutFromOne(800, Easing.Out); + bonusCounter.ScaleTo(SPRITE_SCALE * 2f).Then().ScaleTo(SPRITE_SCALE * 1.28f, 800, Easing.Out); + }); + } + } +} diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs index d4a403fbd2..ed09031fc1 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/OsuLegacySkinTransformer.cs @@ -6,6 +6,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Skinning; using osuTK; +using static osu.Game.Skinning.LegacySkinConfiguration; namespace osu.Game.Rulesets.Osu.Skinning.Legacy { @@ -17,6 +18,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy private bool hasSpinner => spinnerStyle.Value != SpinnerStyle.Modern; + private bool hasScoreFont => this.HasFont(GetConfig(LegacySetting.ScorePrefix)?.Value ?? "score"); + /// /// On osu-stable, hitcircles have 5 pixels of transparent padding on each side to allow for shadows etc. /// Their hittable area is 128px, but the actual circle portion is 118px. @@ -133,6 +136,12 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy return new LegacyOldStyleSpinner(); return null; + + case OsuSkinComponents.SpinnerBonusCounter: + if (hasSpinner && hasScoreFont) + return new LegacySpinnerBonusCounter(); + + return null; } return null;