diff --git a/osu.Game/Screens/Play/HUD/ComboCounter.cs b/osu.Game/Screens/Play/HUD/ComboCounter.cs index d15a8d25ec..5bffa18032 100644 --- a/osu.Game/Screens/Play/HUD/ComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/ComboCounter.cs @@ -1,6 +1,7 @@ // 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; @@ -18,7 +19,7 @@ namespace osu.Game.Screens.Play.HUD public bool IsRolling { get; protected set; } - protected SpriteText PopOutCount; + protected Drawable PopOutCount; protected virtual double PopOutDuration => 150; protected virtual float PopOutScale => 2.0f; @@ -37,7 +38,7 @@ namespace osu.Game.Screens.Play.HUD /// protected Easing RollingEasing => Easing.None; - protected SpriteText DisplayedCountSpriteText; + protected Drawable DisplayedCountSpriteText; private int previousValue; @@ -47,30 +48,34 @@ namespace osu.Game.Screens.Play.HUD protected ComboCounter() { AutoSizeAxes = Axes.Both; + } + [BackgroundDependencyLoader] + private void load() + { Children = new Drawable[] { - DisplayedCountSpriteText = new OsuSpriteText + DisplayedCountSpriteText = CreateSpriteText().With(s => { - Alpha = 0, - }, - PopOutCount = new OsuSpriteText + s.Alpha = 0; + }), + PopOutCount = CreateSpriteText().With(s => { - Alpha = 0, - Margin = new MarginPadding(0.05f), - } + s.Alpha = 0; + s.Margin = new MarginPadding(0.05f); + }) }; - TextSize = 80; - Current.ValueChanged += combo => updateCount(combo.NewValue == 0); } + protected virtual Drawable CreateSpriteText() => new OsuSpriteText(); + protected override void LoadComplete() { base.LoadComplete(); - DisplayedCountSpriteText.Text = FormatCount(Current.Value); + ((IHasText)DisplayedCountSpriteText).Text = FormatCount(Current.Value); DisplayedCountSpriteText.Anchor = Anchor; DisplayedCountSpriteText.Origin = Origin; @@ -94,20 +99,6 @@ namespace osu.Game.Screens.Play.HUD } } - private float textSize; - - public float TextSize - { - get => textSize; - set - { - textSize = value; - - DisplayedCountSpriteText.Font = DisplayedCountSpriteText.Font.With(size: TextSize); - PopOutCount.Font = PopOutCount.Font.With(size: TextSize); - } - } - /// /// Increments the combo by an amount. /// diff --git a/osu.Game/Screens/Play/HUD/LegacyComboCounter.cs b/osu.Game/Screens/Play/HUD/LegacyComboCounter.cs index 8a94d19609..54a4338885 100644 --- a/osu.Game/Screens/Play/HUD/LegacyComboCounter.cs +++ b/osu.Game/Screens/Play/HUD/LegacyComboCounter.cs @@ -1,8 +1,13 @@ // 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 osuTK; using osu.Framework.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Skinning; namespace osu.Game.Screens.Play.HUD { @@ -26,6 +31,22 @@ namespace osu.Game.Screens.Play.HUD Margin = new MarginPadding { Top = 5, Left = 20 }; } + [Resolved] + private ISkinSource skin { get; set; } + + protected override Drawable CreateSpriteText() + { + return skin?.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreText)) ?? new OsuSpriteText(); + + /* + new OsuSpriteText + { + Font = OsuFont.Numeric.With(size: 40), + UseFullGlyphHeight = false, + }); + */ + } + protected override void LoadComplete() { base.LoadComplete(); @@ -41,7 +62,7 @@ namespace osu.Game.Screens.Play.HUD protected virtual void TransformPopOut(int newValue) { - PopOutCount.Text = FormatCount(newValue); + ((IHasText)PopOutCount).Text = FormatCount(newValue); PopOutCount.ScaleTo(PopOutScale); PopOutCount.FadeTo(PopOutInitialAlpha); @@ -60,13 +81,13 @@ namespace osu.Game.Screens.Play.HUD protected virtual void TransformNoPopOut(int newValue) { - DisplayedCountSpriteText.Text = FormatCount(newValue); + ((IHasText)DisplayedCountSpriteText).Text = FormatCount(newValue); DisplayedCountSpriteText.ScaleTo(1); } protected virtual void TransformPopOutSmall(int newValue) { - DisplayedCountSpriteText.Text = FormatCount(newValue); + ((IHasText)DisplayedCountSpriteText).Text = FormatCount(newValue); DisplayedCountSpriteText.ScaleTo(PopOutSmallScale); DisplayedCountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing); } diff --git a/osu.Game/Skinning/HUDSkinComponents.cs b/osu.Game/Skinning/HUDSkinComponents.cs index 6f3e2cbaf5..7577ba066c 100644 --- a/osu.Game/Skinning/HUDSkinComponents.cs +++ b/osu.Game/Skinning/HUDSkinComponents.cs @@ -5,6 +5,7 @@ namespace osu.Game.Skinning { public enum HUDSkinComponents { - ComboCounter + ComboCounter, + ScoreText } } diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index b8b9349cc0..fddea40b04 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -19,6 +19,7 @@ using osu.Game.Beatmaps.Formats; using osu.Game.IO; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play.HUD; +using osuTK; using osuTK.Graphics; namespace osu.Game.Skinning @@ -334,6 +335,14 @@ namespace osu.Game.Skinning { case HUDSkinComponents.ComboCounter: return new LegacyComboCounter(); + + case HUDSkinComponents.ScoreText: + const string font = "score"; + + if (!this.HasFont(font)) + return null; + + return new LegacySpriteText(this, font); } return null;