From c0305343bc9312333957362d124c906f2febd82b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 7 Jun 2021 23:23:44 +0900 Subject: [PATCH] Fix `FindProvider` incorrectly returning `LegacySkinTransformer` itself --- osu.Game/Skinning/LegacySkinTransformer.cs | 8 +++++++- osu.Game/Skinning/SkinProvidingContainer.cs | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/osu.Game/Skinning/LegacySkinTransformer.cs b/osu.Game/Skinning/LegacySkinTransformer.cs index cace4acf6c..651fdddb1b 100644 --- a/osu.Game/Skinning/LegacySkinTransformer.cs +++ b/osu.Game/Skinning/LegacySkinTransformer.cs @@ -16,7 +16,7 @@ namespace osu.Game.Skinning /// /// Transformer used to handle support of legacy features for individual rulesets. /// - public abstract class LegacySkinTransformer : ISkin + public abstract class LegacySkinTransformer : ISkinSource { /// /// Source of the which is being transformed. @@ -50,5 +50,11 @@ namespace osu.Game.Skinning public abstract IBindable GetConfig(TLookup lookup); public ISkin FindProvider(Func lookupFunction) => Source.FindProvider(lookupFunction); + + public event Action SourceChanged + { + add { throw new NotSupportedException(); } + remove { } + } } } diff --git a/osu.Game/Skinning/SkinProvidingContainer.cs b/osu.Game/Skinning/SkinProvidingContainer.cs index 863b5f5a24..0e16cf43ee 100644 --- a/osu.Game/Skinning/SkinProvidingContainer.cs +++ b/osu.Game/Skinning/SkinProvidingContainer.cs @@ -46,8 +46,16 @@ namespace osu.Game.Skinning public ISkin FindProvider(Func lookupFunction) { - if (skin != null && lookupFunction(skin)) - return skin; + if (skin is ISkinSource source) + { + if (source.FindProvider(lookupFunction) is ISkin found) + return found; + } + else if (skin != null) + { + if (lookupFunction(skin)) + return skin; + } return fallbackSource?.FindProvider(lookupFunction); }