Skip to content

Commit

Permalink
Merge pull request #17708 from frenzibyte/fix-texture-lookups-no-long…
Browse files Browse the repository at this point in the history
…er-handling-paths

Fix skin texture lookups not handling paths with extensions
  • Loading branch information
peppy authored Apr 7, 2022
2 parents f069893 + fb9fe42 commit c40b1bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 14 additions & 0 deletions osu.Game.Tests/NonVisual/Skinning/LegacySkinTextureFallbackTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ public sealed class LegacySkinTextureFallbackTest
"followpoint.png",
"[email protected]", 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/[email protected]" },
"Gameplay/osu/followpoint.png",
"Gameplay/osu/[email protected]", 2
},
};

[TestCaseSource(nameof(fallbackTestCases))]
Expand Down
4 changes: 1 addition & 3 deletions osu.Game/Skinning/LegacySkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,7 @@ protected override void ParseConfigurationStream(Stream stream)
string lookupName = name.Replace(@"@2x", string.Empty);

float ratio = 2;
string twoTimesFilename = Path.HasExtension(lookupName)
? @$"{Path.GetFileNameWithoutExtension(lookupName)}@2x{Path.GetExtension(lookupName)}"
: @$"{lookupName}@2x";
string twoTimesFilename = $"{Path.ChangeExtension(lookupName, null)}@2x{Path.GetExtension(lookupName)}";

var texture = Textures?.Get(twoTimesFilename, wrapModeS, wrapModeT);

Expand Down

0 comments on commit c40b1bf

Please sign in to comment.