1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 00:33:21 +08:00

Add back missing sample fallback to default skin

This commit is contained in:
Dean Herbert 2019-09-05 23:01:35 +09:00
parent 9d0151f19f
commit 0a6c42972c
2 changed files with 69 additions and 3 deletions

View File

@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.UI
private TextureStore textureStore;
private ISampleStore sampleStore;
private ISampleStore localSampleStore;
/// <summary>
/// The playfield.
@ -158,8 +158,8 @@ namespace osu.Game.Rulesets.UI
textureStore.AddStore(dependencies.Get<TextureStore>());
dependencies.Cache(textureStore);
sampleStore = dependencies.Get<AudioManager>().GetSampleStore(new NamespacedResourceStore<byte[]>(resources, "Samples"));
dependencies.CacheAs(sampleStore);
localSampleStore = dependencies.Get<AudioManager>().GetSampleStore(new NamespacedResourceStore<byte[]>(resources, "Samples"));
dependencies.CacheAs(new FallbackSampleStore(localSampleStore, dependencies.Get<ISampleStore>()));
}
onScreenDisplay = dependencies.Get<OnScreenDisplay>();
@ -334,6 +334,8 @@ namespace osu.Game.Rulesets.UI
{
base.Dispose(isDisposing);
localSampleStore?.Dispose();
if (Config != null)
{
onScreenDisplay?.StopTracking(this, Config);

View File

@ -0,0 +1,64 @@
// 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.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
namespace osu.Game.Rulesets.UI
{
public class FallbackSampleStore : ISampleStore
{
private readonly ISampleStore primary;
private readonly ISampleStore secondary;
public FallbackSampleStore(ISampleStore primary, ISampleStore secondary)
{
this.primary = primary;
this.secondary = secondary;
}
public void Dispose()
{
primary.Dispose();
secondary.Dispose();
}
public SampleChannel Get(string name) => primary.Get(name) ?? secondary.Get(name);
public Task<SampleChannel> GetAsync(string name) => primary.GetAsync(name) ?? secondary.GetAsync(name);
public Stream GetStream(string name) => primary.GetStream(name) ?? secondary.GetStream(name);
public IEnumerable<string> GetAvailableResources() => primary.GetAvailableResources().Concat(secondary.GetAvailableResources());
public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
{
primary.AddAdjustment(type, adjustBindable);
secondary.AddAdjustment(type, adjustBindable);
}
public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable)
{
primary.RemoveAdjustment(type, adjustBindable);
primary.RemoveAdjustment(type, adjustBindable);
}
public BindableDouble Volume => primary.Volume;
public BindableDouble Balance => primary.Balance;
public BindableDouble Frequency => primary.Frequency;
public int PlaybackConcurrency
{
get => primary.PlaybackConcurrency;
set => primary.PlaybackConcurrency = value;
}
}
}