From 58cca9da06ecd1081b33f03ea57ea9cea8e88c0c Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 10 Jun 2021 11:57:28 +0300 Subject: [PATCH] Revert "Expose the skin lookup layers of `SkinManager` to a property" This reverts commit 9e652715ced79d2a6f22180c03d3e6024a10da8d. --- osu.Game/Skinning/SkinManager.cs | 44 +++++++++++--------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index 134156e44f..48d6b9254f 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -42,24 +42,6 @@ namespace osu.Game.Skinning public readonly Bindable CurrentSkin = new Bindable(); public readonly Bindable CurrentSkinInfo = new Bindable(SkinInfo.Default) { Default = SkinInfo.Default }; - /// - /// The skin layers of the currently selected user skin for performing lookups on, - /// in order of preference (user skin first, then fallback skins). - /// - public IEnumerable CurrentSkinLayers - { - get - { - yield return CurrentSkin.Value; - - // TODO: we also want to return a DefaultLegacySkin here if the current *beatmap* is providing any skinned elements. - // When attempting to address this, we may want to move the full DefaultLegacySkin fallback logic to within Player itself (to better allow - // for beatmap skin visibility). - if (CurrentSkin.Value is LegacySkin) - yield return defaultLegacySkin; - } - } - public override IEnumerable HandledExtensions => new[] { ".osk" }; protected override string[] HashableFileTypes => new[] { ".ini" }; @@ -238,11 +220,11 @@ namespace osu.Game.Skinning public ISkin FindProvider(Func lookupFunction) { - foreach (var skin in CurrentSkinLayers) - { - if (lookupFunction(skin)) - return skin; - } + if (lookupFunction(CurrentSkin.Value)) + return CurrentSkin.Value; + + if (CurrentSkin.Value is LegacySkin && lookupFunction(defaultLegacySkin)) + return defaultLegacySkin; return null; } @@ -250,12 +232,16 @@ namespace osu.Game.Skinning private T lookupWithFallback(Func func) where T : class { - foreach (var skin in CurrentSkinLayers) - { - var result = func(skin); - if (result != null) - return result; - } + var selectedSkin = func(CurrentSkin.Value); + + if (selectedSkin != null) + return selectedSkin; + + // TODO: we also want to return a DefaultLegacySkin here if the current *beatmap* is providing any skinned elements. + // When attempting to address this, we may want to move the full DefaultLegacySkin fallback logic to within Player itself (to better allow + // for beatmap skin visibility). + if (CurrentSkin.Value is LegacySkin) + return func(defaultLegacySkin); return null; }