Revert changes to SkinnableTestScene but change load order

This commit is contained in:
Dean Herbert 2020-09-22 13:32:00 +09:00
parent 1b261f177f
commit 7c40071b21
1 changed files with 12 additions and 21 deletions

View File

@ -153,38 +153,29 @@ private class TestLegacySkin : LegacySkin
{
private readonly bool extrapolateAnimations;
private readonly HashSet<string> legacyFontPrefixes = new HashSet<string>();
public TestLegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager, bool extrapolateAnimations)
: base(skin, storage, audioManager, "skin.ini")
{
this.extrapolateAnimations = extrapolateAnimations;
// use a direct string lookup instead of enum to avoid having to reference ruleset assemblies.
legacyFontPrefixes.Add(GetConfig<string, string>("HitCirclePrefix")?.Value ?? "default");
legacyFontPrefixes.Add(GetConfig<string, string>("ScorePrefix")?.Value ?? "score");
legacyFontPrefixes.Add(GetConfig<string, string>("ComboPrefix")?.Value ?? "score");
}
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
{
var lookup = base.GetTexture(componentName, wrapModeS, wrapModeT);
if (lookup != null)
return lookup;
// extrapolate frames to test longer animations
if (extrapolateAnimations && isAnimationComponent(componentName, out var number) && number < 60)
return base.GetTexture(componentName.Replace($"-{number}", $"-{number % 2}"), wrapModeS, wrapModeT);
if (extrapolateAnimations)
{
var match = Regex.Match(componentName, "-([0-9]*)");
return base.GetTexture(componentName, wrapModeS, wrapModeT);
}
if (match.Length > 0 && int.TryParse(match.Groups[1].Value, out var number) && number < 60)
return base.GetTexture(componentName.Replace($"-{number}", $"-{number % 2}"), wrapModeS, wrapModeT);
}
private bool isAnimationComponent(string componentName, out int number)
{
number = 0;
// legacy font glyph textures have the pattern "{fontPrefix}-{character}", which could be mistaken for an animation frame.
if (legacyFontPrefixes.Any(p => componentName.StartsWith($"{p}-")))
return false;
var match = Regex.Match(componentName, "-([0-9]*)");
return match.Length > 0 && int.TryParse(match.Groups[1].Value, out number);
return null;
}
}
}