Add support to use legacy combo fonts for the counter on legacy skins

This commit is contained in:
Salman Ahmed
2020-08-03 21:40:13 +03:00
parent 9d10658e3c
commit 29053048ff
5 changed files with 18 additions and 4 deletions

View File

@ -13,6 +13,7 @@ namespace osu.Game.Rulesets.Catch
Droplet, Droplet,
CatcherIdle, CatcherIdle,
CatcherFail, CatcherFail,
CatcherKiai CatcherKiai,
CatchComboCounter
} }
} }

View File

@ -6,6 +6,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
using static osu.Game.Skinning.LegacySkinConfiguration;
namespace osu.Game.Rulesets.Catch.Skinning namespace osu.Game.Rulesets.Catch.Skinning
{ {
@ -51,6 +52,16 @@ namespace osu.Game.Rulesets.Catch.Skinning
case CatchSkinComponents.CatcherKiai: case CatchSkinComponents.CatcherKiai:
return this.GetAnimation("fruit-catcher-kiai", true, true, true) ?? return this.GetAnimation("fruit-catcher-kiai", true, true, true) ??
this.GetAnimation("fruit-ryuuta", true, true, true); this.GetAnimation("fruit-ryuuta", true, true, true);
case CatchSkinComponents.CatchComboCounter:
var comboFont = GetConfig<LegacySetting, string>(LegacySetting.ComboPrefix)?.Value ?? "score";
var fontOverlap = GetConfig<LegacySetting, float>(LegacySetting.ComboOverlap)?.Value ?? -2f;
// For simplicity, let's use legacy combo font texture existence as a way to identify legacy skins from default.
if (HasFont(comboFont))
return new LegacyComboCounter(Source, comboFont, fontOverlap);
break;
} }
return null; return null;

View File

@ -94,7 +94,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
var font = GetConfig<OsuSkinConfiguration, string>(OsuSkinConfiguration.HitCirclePrefix)?.Value ?? "default"; var font = GetConfig<OsuSkinConfiguration, string>(OsuSkinConfiguration.HitCirclePrefix)?.Value ?? "default";
var overlap = GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.HitCircleOverlap)?.Value ?? -2; var overlap = GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.HitCircleOverlap)?.Value ?? -2;
return !hasFont(font) return !HasFont(font)
? null ? null
: new LegacySpriteText(Source, font) : new LegacySpriteText(Source, font)
{ {
@ -145,7 +145,5 @@ namespace osu.Game.Rulesets.Osu.Skinning
return Source.GetConfig<TLookup, TValue>(lookup); return Source.GetConfig<TLookup, TValue>(lookup);
} }
private bool hasFont(string fontName) => Source.GetTexture($"{fontName}-0") != null;
} }
} }

View File

@ -15,6 +15,8 @@ namespace osu.Game.Skinning
public enum LegacySetting public enum LegacySetting
{ {
Version, Version,
ComboPrefix,
ComboOverlap,
AnimationFramerate, AnimationFramerate,
LayeredHitSounds, LayeredHitSounds,
} }

View File

@ -47,5 +47,7 @@ namespace osu.Game.Skinning
} }
public abstract IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup); public abstract IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup);
protected bool HasFont(string fontPrefix) => GetTexture($"{fontPrefix}-0") != null;
} }
} }