Do not use custom sample banks outside of beatmap skin

This commit is contained in:
Bartłomiej Dach 2020-07-28 23:52:09 +02:00
parent 2df5fafea0
commit 2bb436fd3c
2 changed files with 26 additions and 1 deletions

View File

@ -14,6 +14,7 @@ namespace osu.Game.Skinning
public class LegacyBeatmapSkin : LegacySkin
{
protected override bool AllowManiaSkin => false;
protected override bool UseCustomSampleBanks => true;
public LegacyBeatmapSkin(BeatmapInfo beatmap, IResourceStore<byte[]> storage, AudioManager audioManager)
: base(createSkinInfo(beatmap), new LegacySkinResourceStore<BeatmapSetFileInfo>(beatmap.BeatmapSet, storage), audioManager, beatmap.Path)

View File

@ -38,6 +38,12 @@ public class LegacySkin : Skin
protected virtual bool AllowManiaSkin => hasKeyTexture.Value;
/// <summary>
/// Whether this skin can use samples with a custom bank (custom sample set in stable terminology).
/// Added in order to match sample lookup logic from stable (in stable, only the beatmap skin could use samples with a custom sample bank).
/// </summary>
protected virtual bool UseCustomSampleBanks => false;
public new LegacySkinConfiguration Configuration
{
get => base.Configuration as LegacySkinConfiguration;
@ -337,7 +343,12 @@ public override Texture GetTexture(string componentName, WrapMode wrapModeS, Wra
public override SampleChannel GetSample(ISampleInfo sampleInfo)
{
foreach (var lookup in sampleInfo.LookupNames)
var lookupNames = sampleInfo.LookupNames;
if (sampleInfo is HitSampleInfo hitSample)
lookupNames = getLegacyLookupNames(hitSample);
foreach (var lookup in lookupNames)
{
var sample = Samples?.Get(lookup);
@ -361,5 +372,18 @@ private IEnumerable<string> getFallbackNames(string componentName)
string lastPiece = componentName.Split('/').Last();
yield return componentName.StartsWith("Gameplay/taiko/") ? "taiko-" + lastPiece : lastPiece;
}
private IEnumerable<string> getLegacyLookupNames(HitSampleInfo hitSample)
{
var lookupNames = hitSample.LookupNames;
if (!UseCustomSampleBanks && !string.IsNullOrEmpty(hitSample.Suffix))
// for compatibility with stable, exclude the lookup names with the custom sample bank suffix, if they are not valid for use in this skin.
// using .EndsWith() is intentional as it ensures parity in all edge cases
// (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply, but the sample bank should not).
lookupNames = hitSample.LookupNames.Where(name => !name.EndsWith(hitSample.Suffix));
return lookupNames;
}
}
}