1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Remove requirement of base calls to ensure user skin container layouts are retrieved

This commit is contained in:
Dean Herbert 2024-08-22 17:14:35 +09:00
parent b57b8168a6
commit 1435fe24ae
No known key found for this signature in database
6 changed files with 38 additions and 24 deletions

View File

@ -35,10 +35,6 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
if (containerLookup.Ruleset == null)
return base.GetDrawableComponent(lookup);
// Skin has configuration.
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
return d;
// we don't have enough assets to display these components (this is especially the case on a "beatmap" skin).
if (!IsProvidingLegacyResources)
return null;

View File

@ -85,10 +85,6 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
if (containerLookup.Ruleset == null)
return base.GetDrawableComponent(lookup);
// Skin has configuration.
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
return d;
// we don't have enough assets to display these components (this is especially the case on a "beatmap" skin).
if (!IsProvidingLegacyResources)
return null;

View File

@ -49,10 +49,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
if (containerLookup.Ruleset == null)
return base.GetDrawableComponent(lookup);
// Skin has configuration.
if (base.GetDrawableComponent(lookup) is UserConfiguredLayoutContainer d)
return d;
// we don't have enough assets to display these components (this is especially the case on a "beatmap" skin).
if (!IsProvidingLegacyResources)
return null;

View File

@ -187,18 +187,23 @@ namespace osu.Game.Skinning
case SkinnableSprite.SpriteComponentLookup sprite:
return this.GetAnimation(sprite.LookupName, false, false, maxSize: sprite.MaxSize);
case GlobalSkinnableContainerLookup containerLookup:
// It is important to return null if the user has not configured this yet.
// This allows skin transformers the opportunity to provide default components.
if (!LayoutInfos.TryGetValue(containerLookup.Component, out var layoutInfo)) return null;
if (!layoutInfo.TryGetDrawableInfo(containerLookup.Ruleset, out var drawableInfos)) return null;
return new UserConfiguredLayoutContainer
case UserSkinComponentLookup userLookup:
switch (userLookup.Component)
{
RelativeSizeAxes = Axes.Both,
ChildrenEnumerable = drawableInfos.Select(i => i.CreateInstance())
};
case GlobalSkinnableContainerLookup containerLookup:
// It is important to return null if the user has not configured this yet.
// This allows skin transformers the opportunity to provide default components.
if (!LayoutInfos.TryGetValue(containerLookup.Component, out var layoutInfo)) return null;
if (!layoutInfo.TryGetDrawableInfo(containerLookup.Ruleset, out var drawableInfos)) return null;
return new UserConfiguredLayoutContainer
{
RelativeSizeAxes = Axes.Both,
ChildrenEnumerable = drawableInfos.Select(i => i.CreateInstance())
};
}
break;
}
return null;

View File

@ -43,7 +43,10 @@ namespace osu.Game.Skinning
Lookup = lookup;
}
public void Reload() => Reload(CurrentSkin.GetDrawableComponent(Lookup) as Container);
public void Reload() => Reload((
CurrentSkin.GetDrawableComponent(new UserSkinComponentLookup(Lookup))
?? CurrentSkin.GetDrawableComponent(Lookup))
as Container);
public void Reload(Container? componentsContainer)
{

View File

@ -0,0 +1,18 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
namespace osu.Game.Skinning
{
/// <summary>
/// A lookup class which is only for internal use, and explicitly to get a user-level configuration.
/// </summary>
internal class UserSkinComponentLookup : ISkinComponentLookup
{
public readonly ISkinComponentLookup Component;
public UserSkinComponentLookup(ISkinComponentLookup component)
{
Component = component;
}
}
}