Merge pull request #17708 from frenzibyte/fix-texture-lookups-no-longer-handling-paths

Fix skin texture lookups not handling paths with extensions
This commit is contained in:
Dean Herbert 2022-04-07 22:01:40 +09:00 committed by GitHub
commit c40b1bf30c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -83,6 +83,20 @@ namespace osu.Game.Tests.NonVisual.Skinning
"followpoint.png", "followpoint.png",
"followpoint@2x.png", 2 "followpoint@2x.png", 2
}, },
new object[]
{
// Looking up a path with extension specified should work.
new[] { "Gameplay/osu/followpoint.png" },
"Gameplay/osu/followpoint.png",
"Gameplay/osu/followpoint.png", 1
},
new object[]
{
// Looking up a path with extension specified should also work with @2x sprites.
new[] { "Gameplay/osu/followpoint@2x.png" },
"Gameplay/osu/followpoint.png",
"Gameplay/osu/followpoint@2x.png", 2
},
}; };
[TestCaseSource(nameof(fallbackTestCases))] [TestCaseSource(nameof(fallbackTestCases))]

View File

@ -443,9 +443,7 @@ namespace osu.Game.Skinning
string lookupName = name.Replace(@"@2x", string.Empty); string lookupName = name.Replace(@"@2x", string.Empty);
float ratio = 2; float ratio = 2;
string twoTimesFilename = Path.HasExtension(lookupName) string twoTimesFilename = $"{Path.ChangeExtension(lookupName, null)}@2x{Path.GetExtension(lookupName)}";
? @$"{Path.GetFileNameWithoutExtension(lookupName)}@2x{Path.GetExtension(lookupName)}"
: @$"{lookupName}@2x";
var texture = Textures?.Get(twoTimesFilename, wrapModeS, wrapModeT); var texture = Textures?.Get(twoTimesFilename, wrapModeS, wrapModeT);