From df1db8611c73c0f2d87154e3895d6f8b0f156705 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Fri, 16 Oct 2020 08:36:20 +0200 Subject: [PATCH] move skin-specific config retrieval to GetDrawableComponent --- osu.Game/Skinning/HUDSkinComponents.cs | 4 +++- osu.Game/Skinning/LegacyAccuracyCounter.cs | 13 +------------ osu.Game/Skinning/LegacyScoreCounter.cs | 14 +------------- osu.Game/Skinning/LegacySkin.cs | 10 ++++++++++ 4 files changed, 15 insertions(+), 26 deletions(-) diff --git a/osu.Game/Skinning/HUDSkinComponents.cs b/osu.Game/Skinning/HUDSkinComponents.cs index d690a23dee..6ec575e106 100644 --- a/osu.Game/Skinning/HUDSkinComponents.cs +++ b/osu.Game/Skinning/HUDSkinComponents.cs @@ -7,6 +7,8 @@ namespace osu.Game.Skinning { ComboCounter, ScoreCounter, - AccuracyCounter + ScoreText, + AccuracyCounter, + AccuracyText } } diff --git a/osu.Game/Skinning/LegacyAccuracyCounter.cs b/osu.Game/Skinning/LegacyAccuracyCounter.cs index 0a64545aee..6c194a06d3 100644 --- a/osu.Game/Skinning/LegacyAccuracyCounter.cs +++ b/osu.Game/Skinning/LegacyAccuracyCounter.cs @@ -15,9 +15,6 @@ namespace osu.Game.Skinning { private readonly ISkin skin; - private readonly string scorePrefix; - private readonly int scoreOverlap; - public LegacyAccuracyCounter(ISkin skin) { Anchor = Anchor.TopRight; @@ -27,20 +24,12 @@ namespace osu.Game.Skinning Margin = new MarginPadding(10); this.skin = skin; - scorePrefix = skin.GetConfig(LegacySkinConfiguration.LegacySetting.ScorePrefix)?.Value ?? "score"; - scoreOverlap = skin.GetConfig(LegacySkinConfiguration.LegacySetting.ScoreOverlap)?.Value ?? -2; } [Resolved(canBeNull: true)] private HUDOverlay hud { get; set; } - protected sealed override OsuSpriteText CreateSpriteText() => - new LegacySpriteText(skin, scorePrefix) - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Spacing = new Vector2(-scoreOverlap, 0) - }; + protected sealed override OsuSpriteText CreateSpriteText() => skin?.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.AccuracyText)) as OsuSpriteText ?? new OsuSpriteText(); protected override void Update() { diff --git a/osu.Game/Skinning/LegacyScoreCounter.cs b/osu.Game/Skinning/LegacyScoreCounter.cs index e931497564..41bf35722b 100644 --- a/osu.Game/Skinning/LegacyScoreCounter.cs +++ b/osu.Game/Skinning/LegacyScoreCounter.cs @@ -5,7 +5,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osuTK; namespace osu.Game.Skinning { @@ -13,9 +12,6 @@ namespace osu.Game.Skinning { private readonly ISkin skin; - private readonly string scorePrefix; - private readonly int scoreOverlap; - protected override double RollingDuration => 1000; protected override Easing RollingEasing => Easing.Out; @@ -28,8 +24,6 @@ namespace osu.Game.Skinning Origin = Anchor.TopRight; this.skin = skin; - scorePrefix = skin.GetConfig(LegacySkinConfiguration.LegacySetting.ScorePrefix)?.Value ?? "score"; - scoreOverlap = skin.GetConfig(LegacySkinConfiguration.LegacySetting.ScoreOverlap)?.Value ?? -2; // base class uses int for display, but externally we bind to ScoreProcessor as a double for now. Current.BindValueChanged(v => base.Current.Value = (int)v.NewValue); @@ -37,12 +31,6 @@ namespace osu.Game.Skinning Margin = new MarginPadding(10); } - protected sealed override OsuSpriteText CreateSpriteText() => - new LegacySpriteText(skin, scorePrefix) - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - Spacing = new Vector2(-scoreOverlap, 0) - }; + protected sealed override OsuSpriteText CreateSpriteText() => skin?.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreText)) as OsuSpriteText ?? new OsuSpriteText(); } } diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index e1cd095ba8..f5265f2d6e 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 @@ -347,6 +348,15 @@ namespace osu.Game.Skinning case HUDSkinComponents.AccuracyCounter: return new LegacyAccuracyCounter(this); + + case HUDSkinComponents.ScoreText: + case HUDSkinComponents.AccuracyText: + string scorePrefix = GetConfig(LegacySkinConfiguration.LegacySetting.ScorePrefix)?.Value ?? "score"; + int scoreOverlap = GetConfig(LegacySkinConfiguration.LegacySetting.ScoreOverlap)?.Value ?? -2; + return new LegacySpriteText(this, scorePrefix) + { + Spacing = new Vector2(-scoreOverlap, 0) + }; } return null;