1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

Make SampleInfo choose its own lookup name

This commit is contained in:
smoogipoo 2018-07-02 14:18:41 +09:00
parent 8b0c6a4c85
commit 310c4a7d6c
2 changed files with 15 additions and 10 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
namespace osu.Game.Audio
{
@ -33,6 +34,12 @@ namespace osu.Game.Audio
/// </summary>
public int Volume;
public virtual IEnumerable<string> LookupNames => new[]
{
$"{Namespace}/{Bank}-{Name}",
$"{Bank}-{Name}" // Without namespace as a fallback
};
public SampleInfo Clone() => (SampleInfo)MemberwiseClone();
}
}

View File

@ -44,19 +44,17 @@ namespace osu.Game.Skinning
private SampleChannel loadChannel(SampleInfo info, Func<string, SampleChannel> getSampleFunction)
{
SampleChannel ch = null;
foreach (var lookup in info.LookupNames)
{
var ch = getSampleFunction($"Gameplay/{lookup}");
if (ch == null)
continue;
if (info.Namespace != null)
ch = getSampleFunction($"Gameplay/{info.Namespace}/{info.Bank}-{info.Name}");
// try without namespace as a fallback.
if (ch == null)
ch = getSampleFunction($"Gameplay/{info.Bank}-{info.Name}");
if (ch != null)
ch.Volume.Value = info.Volume / 100.0;
return ch;
}
return ch;
return null;
}
}
}