1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-30 03:59:55 +08:00

Allow legacy skin textures from subpaths

This commit is contained in:
smoogipoo
2020-04-06 19:02:50 +09:00
Unverified
parent bad1bb6618
commit eff17c2da5
2 changed files with 23 additions and 15 deletions
+21 -14
View File
@@ -243,21 +243,24 @@ namespace osu.Game.Skinning
public override Texture GetTexture(string componentName)
{
componentName = getFallbackName(componentName);
float ratio = 2;
var texture = Textures?.Get($"{componentName}@2x");
if (texture == null)
foreach (var name in getFallbackNames(componentName))
{
ratio = 1;
texture = Textures?.Get(componentName);
float ratio = 2;
var texture = Textures?.Get($"{name}@2x");
if (texture == null)
{
ratio = 1;
texture = Textures?.Get(name);
}
if (texture != null)
texture.ScaleAdjust = ratio;
return texture;
}
if (texture != null)
texture.ScaleAdjust = ratio;
return texture;
return null;
}
public override SampleChannel GetSample(ISampleInfo sampleInfo)
@@ -277,10 +280,14 @@ namespace osu.Game.Skinning
return null;
}
private string getFallbackName(string componentName)
private IEnumerable<string> getFallbackNames(string componentName)
{
// May be something like "Gameplay/osu/approachcircle" from lazer, or "Arrows/note1" from a user skin.
yield return componentName;
// Fall back to using the last piece for components coming from lazer (e.g. "Gameplay/osu/approachcircle" -> "approachcircle").
string lastPiece = componentName.Split('/').Last();
return componentName.StartsWith("Gameplay/taiko/") ? "taiko-" + lastPiece : lastPiece;
yield return componentName.StartsWith("Gameplay/taiko/") ? "taiko-" + lastPiece : lastPiece;
}
}
}
+2 -1
View File
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions;
using osu.Framework.IO.Stores;
using osu.Game.Database;
@@ -27,7 +28,7 @@ namespace osu.Game.Skinning
foreach (var filename in base.GetFilenames(name))
{
var path = getPathForFile(filename);
var path = getPathForFile(filename.ToStandardisedPath());
if (path != null)
yield return path;
}