Add automatic resource mapping for rulesets to their own dll

This commit is contained in:
Dean Herbert
2019-09-04 20:28:21 +09:00
parent 3b650ac646
commit 6197c7fd31
3 changed files with 31 additions and 6 deletions

View File

@ -14,10 +14,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using JetBrains.Annotations;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Framework.IO.Stores;
using osu.Game.Configuration;
using osu.Game.Graphics.Cursor;
using osu.Game.Input.Handlers;
@ -51,6 +55,10 @@ namespace osu.Game.Rulesets.UI
private readonly Lazy<Playfield> playfield;
private TextureStore textureStore;
private ISampleStore sampleStore;
/// <summary>
/// The playfield.
/// </summary>
@ -142,6 +150,18 @@ namespace osu.Game.Rulesets.UI
{
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
var resources = Ruleset.CreateReourceStore();
if (resources != null)
{
textureStore = new TextureStore(new TextureLoaderStore(new NamespacedResourceStore<byte[]>(resources, "Textures")));
textureStore.AddStore(dependencies.Get<TextureStore>());
dependencies.Cache(textureStore);
sampleStore = dependencies.Get<AudioManager>().GetSampleStore(new NamespacedResourceStore<byte[]>(resources, "Samples"));
dependencies.CacheAs(sampleStore);
}
onScreenDisplay = dependencies.Get<OnScreenDisplay>();
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);