1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 19:47:24 +08:00
osu-lazer/osu.Game/Skinning/ResourceStoreBackedSkin.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.9 KiB
C#
Raw Normal View History

// 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.
2021-06-23 14:41:45 +08:00
using System;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores;
using osu.Framework.Platform;
using osu.Game.Audio;
namespace osu.Game.Skinning
{
/// <summary>
/// An <see cref="ISkin"/> that uses an underlying <see cref="IResourceStore{T}"/> with namespaces for resources retrieval.
/// </summary>
public class ResourceStoreBackedSkin : ISkin, IDisposable
{
private readonly TextureStore textures;
private readonly ISampleStore samples;
public ResourceStoreBackedSkin(IResourceStore<byte[]> resources, GameHost host, AudioManager audio)
{
2022-08-02 18:50:57 +08:00
textures = new TextureStore(host.Renderer, host.CreateTextureLoaderStore(new NamespacedResourceStore<byte[]>(resources, @"Textures")));
samples = audio.GetSampleStore(new NamespacedResourceStore<byte[]>(resources, @"Samples"));
}
2021-06-23 14:52:00 +08:00
public Drawable? GetDrawableComponent(ISkinComponent component) => null;
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => textures.Get(componentName, wrapModeS, wrapModeT);
2021-06-23 14:52:00 +08:00
public ISample? GetSample(ISampleInfo sampleInfo)
{
foreach (string? lookup in sampleInfo.LookupNames)
{
ISample? sample = samples.Get(lookup);
if (sample != null)
return sample;
}
return null;
}
2022-03-25 14:53:55 +08:00
public IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)
where TLookup : notnull
where TValue : notnull
=> null;
2021-06-23 14:41:45 +08:00
public void Dispose()
{
textures.Dispose();
samples.Dispose();
2021-06-23 14:41:45 +08:00
}
}
}