From b7f8716de9cd1f32c4ea9ad7f6b32b43b842167c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Apr 2022 14:10:08 +0900 Subject: [PATCH 1/2] Add test coverage of skin lookups failing when `@2x` and extension are present --- .../Skinning/LegacySkinTextureFallbackTest.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs b/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs index 7516e7500b..db7fc0b4a0 100644 --- a/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs +++ b/osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs @@ -69,6 +69,20 @@ public sealed class LegacySkinTextureFallbackTest "Gameplay/osu/followpoint", "followpoint", 1 }, + new object[] + { + // Looking up a filename with extension specified should work. + new[] { "followpoint.png" }, + "followpoint.png", + "followpoint.png", 1 + }, + new object[] + { + // Looking up a filename with extension specified should also work with @2x sprites. + new[] { "followpoint@2x.png" }, + "followpoint.png", + "followpoint@2x.png", 2 + }, }; [TestCaseSource(nameof(fallbackTestCases))] From 205edb65a2d800eb7bf54bdf3d1b8e56f4c81f19 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 7 Apr 2022 14:16:16 +0900 Subject: [PATCH 2/2] Fix filename lookups on `LegacySkin`s going awry when extension is specified Due to the logic present to handle `@2x` fallback, the extension was potentially being added at the wrong point in the filename. This change ensures that the lookup filenames are always correct. Closes https://github.com/ppy/osu/issues/17690. --- osu.Game/Skinning/LegacySkin.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 92713023f4..a97b5d44ce 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -443,7 +443,11 @@ protected override void ParseConfigurationStream(Stream stream) string lookupName = name.Replace(@"@2x", string.Empty); float ratio = 2; - var texture = Textures?.Get(@$"{lookupName}@2x", wrapModeS, wrapModeT); + string twoTimesFilename = Path.HasExtension(lookupName) + ? @$"{Path.GetFileNameWithoutExtension(lookupName)}@2x{Path.GetExtension(lookupName)}" + : @$"{lookupName}@2x"; + + var texture = Textures?.Get(twoTimesFilename, wrapModeS, wrapModeT); if (texture == null) {