Add check to detect whether mania is skinned

This commit is contained in:
mcendu 2020-04-01 11:04:29 +08:00
parent b41bf783d0
commit 716c7fa07a
No known key found for this signature in database
GPG Key ID: FBCD5D45163D6364
1 changed files with 11 additions and 1 deletions

View File

@ -18,6 +18,12 @@ public class ManiaLegacySkinTransformer : ISkin
private Lazy<bool> isLegacySkin;
/// <summary>
/// Whether texture for the keys exists.
/// Used to determine if the mania ruleset is skinned.
/// </summary>
private Lazy<bool> hasKeyTexture;
public ManiaLegacySkinTransformer(ISkinSource source)
{
this.source = source;
@ -29,6 +35,10 @@ public ManiaLegacySkinTransformer(ISkinSource source)
private void sourceChanged()
{
isLegacySkin = new Lazy<bool>(() => source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
hasKeyTexture = new Lazy<bool>(() => source.GetTexture(
source.GetConfig<LegacyManiaSkinConfigurationLookup, string>(
new LegacyManiaSkinConfigurationLookup(4, LegacyManiaSkinConfigurationLookups.KeyImage, 0))?.Value
?? $"mania-key1") != null);
}
public Drawable GetDrawableComponent(ISkinComponent component)
@ -39,7 +49,7 @@ public Drawable GetDrawableComponent(ISkinComponent component)
return getResult(resultComponent);
case ManiaSkinComponent maniaComponent:
if (!isLegacySkin.Value)
if (!isLegacySkin.Value || !hasKeyTexture.Value)
return null;
switch (maniaComponent.Component)