Fix remaining cases of not using host-created TextureLoaderStore

This commit is contained in:
Dean Herbert 2019-01-25 11:41:44 +09:00
parent d2ee08ad7b
commit 6b3d53750c
3 changed files with 11 additions and 7 deletions

View File

@ -74,15 +74,18 @@ public partial class BeatmapManager : ArchiveModelManager<BeatmapSetInfo, Beatma
private readonly AudioManager audioManager; private readonly AudioManager audioManager;
private GameHost host;
private readonly List<DownloadBeatmapSetRequest> currentDownloads = new List<DownloadBeatmapSetRequest>(); private readonly List<DownloadBeatmapSetRequest> currentDownloads = new List<DownloadBeatmapSetRequest>();
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, APIAccess api, AudioManager audioManager, IIpcHost importHost = null, public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, APIAccess api, AudioManager audioManager, GameHost importHost = null,
WorkingBeatmap defaultBeatmap = null) WorkingBeatmap defaultBeatmap = null)
: base(storage, contextFactory, new BeatmapStore(contextFactory), importHost) : base(storage, contextFactory, new BeatmapStore(contextFactory), importHost)
{ {
this.rulesets = rulesets; this.rulesets = rulesets;
this.api = api; this.api = api;
this.audioManager = audioManager; this.audioManager = audioManager;
this.host = importHost;
DefaultBeatmap = defaultBeatmap; DefaultBeatmap = defaultBeatmap;
@ -254,7 +257,7 @@ public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap
if (beatmapInfo.Metadata == null) if (beatmapInfo.Metadata == null)
beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata; beatmapInfo.Metadata = beatmapInfo.BeatmapSet.Metadata;
WorkingBeatmap working = new BeatmapManagerWorkingBeatmap(Files.Store, beatmapInfo, audioManager); WorkingBeatmap working = new BeatmapManagerWorkingBeatmap(Files.Store, new LargeTextureStore(host.CreateTextureLoaderStore(Files.Store)), beatmapInfo, audioManager);
previous?.TransferTo(working); previous?.TransferTo(working);

View File

@ -22,10 +22,11 @@ protected class BeatmapManagerWorkingBeatmap : WorkingBeatmap
private readonly IResourceStore<byte[]> store; private readonly IResourceStore<byte[]> store;
private readonly AudioManager audioManager; private readonly AudioManager audioManager;
public BeatmapManagerWorkingBeatmap(IResourceStore<byte[]> store, BeatmapInfo beatmapInfo, AudioManager audioManager) public BeatmapManagerWorkingBeatmap(IResourceStore<byte[]> store, TextureStore textureStore, BeatmapInfo beatmapInfo, AudioManager audioManager)
: base(beatmapInfo) : base(beatmapInfo)
{ {
this.store = store; this.store = store;
this.textureStore = textureStore;
this.audioManager = audioManager; this.audioManager = audioManager;
} }
@ -44,7 +45,7 @@ protected override IBeatmap GetBeatmap()
private string getPathForFile(string filename) => BeatmapSetInfo.Files.First(f => string.Equals(f.Filename, filename, StringComparison.InvariantCultureIgnoreCase)).FileInfo.StoragePath; private string getPathForFile(string filename) => BeatmapSetInfo.Files.First(f => string.Equals(f.Filename, filename, StringComparison.InvariantCultureIgnoreCase)).FileInfo.StoragePath;
private LargeTextureStore textureStore; private TextureStore textureStore;
protected override bool BackgroundStillValid(Texture b) => false; // bypass lazy logic. we want to return a new background each time for refcounting purposes. protected override bool BackgroundStillValid(Texture b) => false; // bypass lazy logic. we want to return a new background each time for refcounting purposes.
@ -55,7 +56,7 @@ protected override Texture GetBackground()
try try
{ {
return (textureStore ?? (textureStore = new LargeTextureStore(new TextureLoaderStore(store)))).Get(getPathForFile(Metadata.BackgroundFile)); return textureStore.Get(getPathForFile(Metadata.BackgroundFile));
} }
catch catch
{ {

View File

@ -111,8 +111,8 @@ private void load()
dependencies.Cache(contextFactory = new DatabaseContextFactory(Host.Storage)); dependencies.Cache(contextFactory = new DatabaseContextFactory(Host.Storage));
var largeStore = new LargeTextureStore(new TextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures"))); var largeStore = new LargeTextureStore(Host.CreateTextureLoaderStore(new NamespacedResourceStore<byte[]>(Resources, @"Textures")));
largeStore.AddStore(new TextureLoaderStore(new OnlineStore())); largeStore.AddStore(Host.CreateTextureLoaderStore(new OnlineStore()));
dependencies.Cache(largeStore); dependencies.Cache(largeStore);
dependencies.CacheAs(this); dependencies.CacheAs(this);