mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:02:53 +08:00
Allow legacy skin textures from subpaths
This commit is contained in:
parent
bad1bb6618
commit
eff17c2da5
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user