From 96d1b093121431dcd20aecc9e78a4e6078be0a5c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 30 Sep 2024 18:15:21 +0900 Subject: [PATCH] Only transform the user's skin, not all fallbacks --- .../TestSceneCatchPlayerLegacySkin.cs | 2 +- .../Skinning/RulesetSkinProvidingContainer.cs | 26 ++++--------------- osu.Game/Skinning/SkinManager.cs | 2 +- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchPlayerLegacySkin.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchPlayerLegacySkin.cs index 792caf6de6..434471e931 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatchPlayerLegacySkin.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatchPlayerLegacySkin.cs @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Catch.Tests CreateTest(); } - AddAssert("legacy HUD combo counter not added", () => !Player.ChildrenOfType().Any()); + AddAssert("legacy HUD combo counter not added", () => Player.ChildrenOfType(), () => Is.Empty); } } } diff --git a/osu.Game/Skinning/RulesetSkinProvidingContainer.cs b/osu.Game/Skinning/RulesetSkinProvidingContainer.cs index 4b40d06f8b..aa05339ecb 100644 --- a/osu.Game/Skinning/RulesetSkinProvidingContainer.cs +++ b/osu.Game/Skinning/RulesetSkinProvidingContainer.cs @@ -4,7 +4,6 @@ #nullable disable using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using JetBrains.Annotations; using osu.Framework.Allocation; @@ -67,28 +66,13 @@ namespace osu.Game.Skinning // Populate a local list first so we can adjust the returned order as we go. var sources = new List(); - Debug.Assert(ParentSource != null); - - foreach (var source in ParentSource.AllSources) - { - switch (source) - { - case Skin skin: - sources.Add(GetRulesetTransformedSkin(skin)); - break; - } - } - - // TODO: check - int lastDefaultSkinIndex = sources.IndexOf(sources.OfType().LastOrDefault()); + // We want to transform the current user's skin for the current ruleset. + // Assume it's the first skin provided by the parent source (generally the case for both SkinManager and tests). + if (ParentSource?.AllSources.FirstOrDefault() is ISkin skin) + sources.Add(GetRulesetTransformedSkin(skin)); // Ruleset resources should be given the ability to override game-wide defaults - // This is achieved by placing them before the last instance of DefaultSkin. - // Note that DefaultSkin may not be present in some test scenes. - if (lastDefaultSkinIndex >= 0) - sources.Insert(lastDefaultSkinIndex, rulesetResourcesSkin); - else - sources.Add(rulesetResourcesSkin); + sources.Add(rulesetResourcesSkin); SetSources(sources); } diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index 9018c2e2c3..b0c41eca79 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -256,7 +256,7 @@ namespace osu.Game.Skinning // This handles cases where a user skin doesn't have the required resources for complete display of // certain elements. - if (CurrentSkin.Value is LegacySkin && CurrentSkin.Value != DefaultClassicSkin) + if (CurrentSkin.Value != DefaultClassicSkin) yield return DefaultClassicSkin; if (CurrentSkin.Value != trianglesSkin)