1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 10:22:56 +08:00

Remove implicit LegacySkin check and refactor anything using it

This commit is contained in:
Salman Ahmed 2021-06-21 04:16:58 +03:00
parent 780388d174
commit 5cfd0e3223
2 changed files with 22 additions and 11 deletions

View File

@ -26,7 +26,7 @@ namespace osu.Game.Skinning
Ruleset = ruleset; Ruleset = ruleset;
Beatmap = beatmap; Beatmap = beatmap;
InternalChild = new BeatmapSkinProvidingContainer(GetRulesetTransformedSkin(beatmapSkin)) InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin is LegacySkin ? GetLegacyRulesetTransformedSkin(beatmapSkin) : beatmapSkin)
{ {
Child = Content = new Container Child = Content = new Container
{ {
@ -54,23 +54,34 @@ namespace osu.Game.Skinning
{ {
SkinSources.Clear(); SkinSources.Clear();
SkinSources.Add(GetRulesetTransformedSkin(skinManager.CurrentSkin.Value)); // TODO: we also want to insert a DefaultLegacySkin here if the current *beatmap* is providing any skinned elements.
// TODO: we also want to return a DefaultLegacySkin here if the current *beatmap* is providing any skinned elements. switch (skinManager.CurrentSkin.Value)
if (skinManager.CurrentSkin.Value is LegacySkin && skinManager.CurrentSkin.Value != skinManager.DefaultLegacySkin) {
SkinSources.Add(GetRulesetTransformedSkin(skinManager.DefaultLegacySkin)); case LegacySkin currentLegacySkin:
SkinSources.Add(GetLegacyRulesetTransformedSkin(currentLegacySkin));
if (currentLegacySkin != skinManager.DefaultLegacySkin)
SkinSources.Add(GetLegacyRulesetTransformedSkin(skinManager.DefaultLegacySkin));
break;
default:
SkinSources.Add(skinManager.CurrentSkin.Value);
break;
}
} }
protected ISkin GetRulesetTransformedSkin(ISkin skin) protected ISkin GetLegacyRulesetTransformedSkin(ISkin legacySkin)
{ {
if (!(skin is LegacySkin)) if (legacySkin == null)
return skin; return null;
var rulesetTransformed = Ruleset.CreateLegacySkinProvider(skin, Beatmap); var rulesetTransformed = Ruleset.CreateLegacySkinProvider(legacySkin, Beatmap);
if (rulesetTransformed != null) if (rulesetTransformed != null)
return rulesetTransformed; return rulesetTransformed;
return skin; return legacySkin;
} }
} }
} }

View File

@ -99,7 +99,7 @@ namespace osu.Game.Tests.Visual
base.UpdateSkins(); base.UpdateSkins();
if (skin != null) if (skin != null)
SkinSources.Insert(0, GetRulesetTransformedSkin(skin)); SkinSources.Insert(0, skin is LegacySkin ? GetLegacyRulesetTransformedSkin(skin) : skin);
} }
} }
} }