Prefer provided resource store over realm backed to keep tests working

This commit is contained in:
Dean Herbert 2022-03-22 19:07:05 +09:00
parent b4d89b4e31
commit 35d2f973a3
2 changed files with 24 additions and 17 deletions

View File

@ -69,7 +69,7 @@ protected LegacySkin(SkinInfo skin, [CanBeNull] IResourceStore<byte[]> storage,
/// <param name="resources">Access to raw game resources.</param>
/// <param name="configurationStream">An optional stream containing the contents of a skin.ini file.</param>
protected LegacySkin(SkinInfo skin, [CanBeNull] IResourceStore<byte[]> storage, [CanBeNull] IStorageResourceProvider resources, [CanBeNull] Stream configurationStream)
: base(skin, resources, configurationStream)
: base(skin, resources, storage, configurationStream)
{
// todo: this shouldn't really be duplicated here (from ManiaLegacySkinTransformer). we need to come up with a better solution.
hasKeyTexture = new Lazy<bool>(() => this.GetAnimation(

View File

@ -13,6 +13,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.OpenGL.Textures;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
using osu.Framework.Logging;
using osu.Game.Audio;
using osu.Game.Database;
@ -51,30 +52,36 @@ public abstract class Skin : IDisposable, ISkin
public abstract IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup);
private readonly RealmBackedResourceStore skinStorage;
protected Skin(SkinInfo skin, IStorageResourceProvider resources, [CanBeNull] Stream configurationStream = null)
protected Skin(SkinInfo skin, [CanBeNull] IStorageResourceProvider resources, [CanBeNull] IResourceStore<byte[]> storage = null, [CanBeNull] Stream configurationStream = null)
{
if (resources.RealmAccess != null)
if (resources != null)
{
SkinInfo = skin.ToLive(resources.RealmAccess);
skinStorage = new RealmBackedResourceStore(skin, resources.Files);
if (resources.RealmAccess != null)
{
SkinInfo = skin.ToLive(resources.RealmAccess);
var samples = resources?.AudioManager?.GetSampleStore(skinStorage);
if (storage == null)
{
var realmStorage = new RealmBackedResourceStore(skin, resources.Files);
realmStorage.AddExtension("ogg");
storage = realmStorage;
}
}
else
{
SkinInfo = skin.ToLiveUnmanaged();
}
var samples = resources.AudioManager?.GetSampleStore(storage);
if (samples != null)
samples.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
Samples = samples;
Textures = new TextureStore(resources?.CreateTextureLoaderStore(skinStorage));
skinStorage.AddExtension("ogg");
}
else
{
SkinInfo = skin.ToLiveUnmanaged();
Textures = new TextureStore(resources.CreateTextureLoaderStore(storage));
}
configurationStream ??= skinStorage?.GetStream(@"skin.ini");
configurationStream ??= storage?.GetStream(@"skin.ini");
if (configurationStream != null)
// stream will be closed after use by LineBufferedReader.
@ -87,7 +94,7 @@ protected Skin(SkinInfo skin, IStorageResourceProvider resources, [CanBeNull] St
{
string filename = $"{skinnableTarget}.json";
byte[] bytes = skinStorage?.Get(filename);
byte[] bytes = storage?.Get(filename);
if (bytes == null)
continue;