Merge pull request #17700 from peppy/fix-skin-lookups-extension-specified

Fix filename lookups on `LegacySkin`s going awry when extension is specified
This commit is contained in:
Dan Balasescu 2022-04-07 17:03:27 +09:00 committed by GitHub
commit f0698937b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -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))]

View File

@ -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)
{