Merge pull request #5795 from iiSaLMaN/allow-fallback-to-samples-without-bank

Try retrieving samples without bank names
This commit is contained in:
Dean Herbert
2019-08-28 13:12:51 +09:00
committed by GitHub
13 changed files with 70 additions and 49 deletions

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
@ -43,28 +42,20 @@ namespace osu.Game.Skinning
{
channels = hitSamples.Select(s =>
{
var ch = loadChannel(s, skin.GetSample);
var ch = skin.GetSample(s);
if (ch == null && allowFallback)
ch = loadChannel(s, audio.Samples.Get);
foreach (var lookup in s.LookupNames)
if ((ch = audio.Samples.Get($"Gameplay/{lookup}")) != null)
break;
if (ch != null)
ch.Volume.Value = s.Volume / 100.0;
return ch;
}).Where(c => c != null).ToArray();
}
private SampleChannel loadChannel(ISampleInfo info, Func<string, SampleChannel> getSampleFunction)
{
foreach (var lookup in info.LookupNames)
{
var ch = getSampleFunction($"Gameplay/{lookup}");
if (ch == null)
continue;
ch.Volume.Value = info.Volume / 100.0;
return ch;
}
return null;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);