1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 20:22:55 +08:00

Revert disabling taiko sample tests and fix logic

This commit is contained in:
Dean Herbert 2021-06-01 18:56:22 +09:00
parent 54338bdcc5
commit 2e2281c7d2
3 changed files with 17 additions and 12 deletions

View File

@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
[TestCase("taiko-normal-hitnormal")] [TestCase("taiko-normal-hitnormal")]
[TestCase("normal-hitnormal")] [TestCase("normal-hitnormal")]
// [TestCase("hitnormal")] intentionally broken (will play classic default instead). [TestCase("hitnormal")]
public void TestDefaultCustomSampleFromBeatmap(string expectedSample) public void TestDefaultCustomSampleFromBeatmap(string expectedSample)
{ {
SetupSkins(expectedSample, expectedSample); SetupSkins(expectedSample, expectedSample);
@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
[TestCase("taiko-normal-hitnormal")] [TestCase("taiko-normal-hitnormal")]
[TestCase("normal-hitnormal")] [TestCase("normal-hitnormal")]
// [TestCase("hitnormal")] intentionally broken (will play classic default instead). [TestCase("hitnormal")]
public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample) public void TestDefaultCustomSampleFromUserSkinFallback(string expectedSample)
{ {
SetupSkins(string.Empty, expectedSample); SetupSkins(string.Empty, expectedSample);

View File

@ -152,32 +152,35 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
throw new ArgumentOutOfRangeException(nameof(component), $"Invalid component type: {component}"); throw new ArgumentOutOfRangeException(nameof(component), $"Invalid component type: {component}");
} }
public override ISample GetSample(ISampleInfo sampleInfo) => Source.GetSample(new LegacyTaikoSampleInfo(sampleInfo)); public override ISample GetSample(ISampleInfo sampleInfo)
{
if (sampleInfo is HitSampleInfo hitSampleInfo)
return Source.GetSample(new LegacyTaikoSampleInfo(hitSampleInfo));
return base.GetSample(sampleInfo);
}
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Source.GetConfig<TLookup, TValue>(lookup); public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Source.GetConfig<TLookup, TValue>(lookup);
private class LegacyTaikoSampleInfo : ISampleInfo private class LegacyTaikoSampleInfo : HitSampleInfo
{ {
private readonly ISampleInfo source; public LegacyTaikoSampleInfo(HitSampleInfo sampleInfo)
: base(sampleInfo.Name, sampleInfo.Bank, sampleInfo.Suffix, sampleInfo.Volume)
public LegacyTaikoSampleInfo(ISampleInfo source)
{ {
this.source = source;
} }
public IEnumerable<string> LookupNames public override IEnumerable<string> LookupNames
{ {
get get
{ {
foreach (var name in source.LookupNames) foreach (var name in base.LookupNames)
yield return name.Insert(name.LastIndexOf('/') + 1, "taiko-"); yield return name.Insert(name.LastIndexOf('/') + 1, "taiko-");
foreach (var name in source.LookupNames) foreach (var name in base.LookupNames)
yield return name; yield return name;
} }
} }
public int Volume => source.Volume;
} }
} }
} }

View File

@ -519,8 +519,10 @@ namespace osu.Game.Skinning
var sample = Samples?.Get(lookup); var sample = Samples?.Get(lookup);
if (sample != null) if (sample != null)
{
return sample; return sample;
} }
}
return legacyDefaultFallback?.GetSample(sampleInfo); return legacyDefaultFallback?.GetSample(sampleInfo);
} }