mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 08:55:35 +08:00
Merge pull request #6008 from peppy/fix-sample-fallback
Add back missing sample fallback to default skin Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
This commit is contained in:
commit
404ad3834d
@ -11,10 +11,13 @@ using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
@ -57,7 +60,7 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
private TextureStore textureStore;
|
||||
|
||||
private ISampleStore sampleStore;
|
||||
private ISampleStore localSampleStore;
|
||||
|
||||
/// <summary>
|
||||
/// The playfield.
|
||||
@ -158,8 +161,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 +337,8 @@ namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
localSampleStore?.Dispose();
|
||||
|
||||
if (Config != null)
|
||||
{
|
||||
onScreenDisplay?.StopTracking(this, Config);
|
||||
@ -463,4 +468,50 @@ namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A sample store which adds a fallback source.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is a temporary implementation to workaround ISampleStore limitations.
|
||||
/// </remarks>
|
||||
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 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() => throw new NotImplementedException();
|
||||
|
||||
public void AddAdjustment(AdjustableProperty type, BindableDouble adjustBindable) => throw new NotImplementedException();
|
||||
|
||||
public void RemoveAdjustment(AdjustableProperty type, BindableDouble adjustBindable) => throw new NotImplementedException();
|
||||
|
||||
public BindableDouble Volume => throw new NotImplementedException();
|
||||
|
||||
public BindableDouble Balance => throw new NotImplementedException();
|
||||
|
||||
public BindableDouble Frequency => throw new NotImplementedException();
|
||||
|
||||
public int PlaybackConcurrency
|
||||
{
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user