1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-29 05:52:56 +08:00

move skin-specific config retrieval to GetDrawableComponent

This commit is contained in:
Morilli 2020-10-16 08:36:20 +02:00
parent 085d8d0ecb
commit df1db8611c
4 changed files with 15 additions and 26 deletions

View File

@ -7,6 +7,8 @@ namespace osu.Game.Skinning
{ {
ComboCounter, ComboCounter,
ScoreCounter, ScoreCounter,
AccuracyCounter ScoreText,
AccuracyCounter,
AccuracyText
} }
} }

View File

@ -15,9 +15,6 @@ namespace osu.Game.Skinning
{ {
private readonly ISkin skin; private readonly ISkin skin;
private readonly string scorePrefix;
private readonly int scoreOverlap;
public LegacyAccuracyCounter(ISkin skin) public LegacyAccuracyCounter(ISkin skin)
{ {
Anchor = Anchor.TopRight; Anchor = Anchor.TopRight;
@ -27,20 +24,12 @@ namespace osu.Game.Skinning
Margin = new MarginPadding(10); Margin = new MarginPadding(10);
this.skin = skin; this.skin = skin;
scorePrefix = skin.GetConfig<LegacySkinConfiguration.LegacySetting, string>(LegacySkinConfiguration.LegacySetting.ScorePrefix)?.Value ?? "score";
scoreOverlap = skin.GetConfig<LegacySkinConfiguration.LegacySetting, int>(LegacySkinConfiguration.LegacySetting.ScoreOverlap)?.Value ?? -2;
} }
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private HUDOverlay hud { get; set; } private HUDOverlay hud { get; set; }
protected sealed override OsuSpriteText CreateSpriteText() => protected sealed override OsuSpriteText CreateSpriteText() => skin?.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.AccuracyText)) as OsuSpriteText ?? new OsuSpriteText();
new LegacySpriteText(skin, scorePrefix)
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Spacing = new Vector2(-scoreOverlap, 0)
};
protected override void Update() protected override void Update()
{ {

View File

@ -5,7 +5,6 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -13,9 +12,6 @@ namespace osu.Game.Skinning
{ {
private readonly ISkin skin; private readonly ISkin skin;
private readonly string scorePrefix;
private readonly int scoreOverlap;
protected override double RollingDuration => 1000; protected override double RollingDuration => 1000;
protected override Easing RollingEasing => Easing.Out; protected override Easing RollingEasing => Easing.Out;
@ -28,8 +24,6 @@ namespace osu.Game.Skinning
Origin = Anchor.TopRight; Origin = Anchor.TopRight;
this.skin = skin; this.skin = skin;
scorePrefix = skin.GetConfig<LegacySkinConfiguration.LegacySetting, string>(LegacySkinConfiguration.LegacySetting.ScorePrefix)?.Value ?? "score";
scoreOverlap = skin.GetConfig<LegacySkinConfiguration.LegacySetting, int>(LegacySkinConfiguration.LegacySetting.ScoreOverlap)?.Value ?? -2;
// base class uses int for display, but externally we bind to ScoreProcessor as a double for now. // 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); Current.BindValueChanged(v => base.Current.Value = (int)v.NewValue);
@ -37,12 +31,6 @@ namespace osu.Game.Skinning
Margin = new MarginPadding(10); Margin = new MarginPadding(10);
} }
protected sealed override OsuSpriteText CreateSpriteText() => protected sealed override OsuSpriteText CreateSpriteText() => skin?.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreText)) as OsuSpriteText ?? new OsuSpriteText();
new LegacySpriteText(skin, scorePrefix)
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Spacing = new Vector2(-scoreOverlap, 0)
};
} }
} }

View File

@ -19,6 +19,7 @@ using osu.Game.Beatmaps.Formats;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Skinning namespace osu.Game.Skinning
@ -347,6 +348,15 @@ namespace osu.Game.Skinning
case HUDSkinComponents.AccuracyCounter: case HUDSkinComponents.AccuracyCounter:
return new LegacyAccuracyCounter(this); return new LegacyAccuracyCounter(this);
case HUDSkinComponents.ScoreText:
case HUDSkinComponents.AccuracyText:
string scorePrefix = GetConfig<LegacySkinConfiguration.LegacySetting, string>(LegacySkinConfiguration.LegacySetting.ScorePrefix)?.Value ?? "score";
int scoreOverlap = GetConfig<LegacySkinConfiguration.LegacySetting, int>(LegacySkinConfiguration.LegacySetting.ScoreOverlap)?.Value ?? -2;
return new LegacySpriteText(this, scorePrefix)
{
Spacing = new Vector2(-scoreOverlap, 0)
};
} }
return null; return null;