1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 19:13:19 +08:00

Also handle null Ruleset.CreateLegacySkinProvider values

Let's just go this way for now, maybe it's a better choice to always create transformers and disallow null, but it's too much work and out of scope at this point
This commit is contained in:
Salman Ahmed 2021-06-11 16:26:53 +03:00
parent f20146d446
commit 108a3deb27

View File

@ -26,7 +26,7 @@ namespace osu.Game.Skinning
Ruleset = ruleset; Ruleset = ruleset;
Beatmap = beatmap; Beatmap = beatmap;
InternalChild = new BeatmapSkinProvidingContainer(beatmapSkin == null ? null : ruleset.CreateLegacySkinProvider(beatmapSkin, beatmap)) InternalChild = new BeatmapSkinProvidingContainer(GetRulesetTransformedSkin(beatmapSkin))
{ {
Child = Content = new Container Child = Content = new Container
{ {
@ -54,13 +54,25 @@ namespace osu.Game.Skinning
{ {
SkinSources.Clear(); SkinSources.Clear();
SkinSources.Add(Ruleset.CreateLegacySkinProvider(skinManager.CurrentSkin.Value, Beatmap)); SkinSources.Add(GetRulesetTransformedSkin(skinManager.CurrentSkin.Value));
// TODO: we also want to return 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.
if (skinManager.CurrentSkin.Value is LegacySkin) if (skinManager.CurrentSkin.Value is LegacySkin)
SkinSources.Add(Ruleset.CreateLegacySkinProvider(skinManager.DefaultLegacySkin, Beatmap)); SkinSources.Add(GetRulesetTransformedSkin(skinManager.DefaultLegacySkin));
SkinSources.Add(Ruleset.CreateLegacySkinProvider(skinManager.DefaultSkin, Beatmap)); SkinSources.Add(GetRulesetTransformedSkin(skinManager.DefaultSkin));
}
protected ISkin GetRulesetTransformedSkin(ISkin skin)
{
if (skin == null)
return null;
var rulesetTransformed = Ruleset.CreateLegacySkinProvider(skin, Beatmap);
if (rulesetTransformed != null)
return rulesetTransformed;
return skin;
} }
} }
} }