From cb11f1e2ca907cf9d99d5ff76c40b2d0b2957ceb Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 18 May 2022 20:02:12 -0400 Subject: re-add internal content manager for asset propagation This will be used by the new asset propagation in SMAPI 4.0 & Stardew Valley 1.6. --- src/SMAPI/Framework/ContentCoordinator.cs | 17 ++++++++++++++++- src/SMAPI/Metadata/CoreAssetPropagator.cs | 8 +++++++- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs index 2b13f57a..da8f0da9 100644 --- a/src/SMAPI/Framework/ContentCoordinator.cs +++ b/src/SMAPI/Framework/ContentCoordinator.cs @@ -151,8 +151,23 @@ namespace StardewModdingAPI.Framework onAssetLoaded: onAssetLoaded ) ); + + var contentManagerForAssetPropagation = new GameContentManagerForAssetPropagation( + name: nameof(GameContentManagerForAssetPropagation), + serviceProvider: serviceProvider, + rootDirectory: rootDirectory, + currentCulture: currentCulture, + coordinator: this, + monitor: monitor, + reflection: reflection, + onDisposing: this.OnDisposing, + onLoadingFirstAsset: onLoadingFirstAsset, + onAssetLoaded: onAssetLoaded + ); + this.ContentManagers.Add(contentManagerForAssetPropagation); + this.VanillaContentManager = new LocalizedContentManager(serviceProvider, rootDirectory); - this.CoreAssets = new CoreAssetPropagator(this.MainContentManager, this.Monitor, reflection, name => this.ParseAssetName(name, allowLocales: true)); + this.CoreAssets = new CoreAssetPropagator(this.MainContentManager, contentManagerForAssetPropagation, this.Monitor, reflection, name => this.ParseAssetName(name, allowLocales: true)); this.LocaleCodes = new Lazy>(() => this.GetLocaleCodes(customLanguages: Enumerable.Empty())); } diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index e014f9a9..6cb5a73a 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI.Framework.ContentManagers; using StardewModdingAPI.Framework.Reflection; using StardewModdingAPI.Internal; using StardewModdingAPI.Toolkit.Utilities; @@ -32,6 +33,9 @@ namespace StardewModdingAPI.Metadata /// The main content manager through which to reload assets. private readonly LocalizedContentManager MainContentManager; + /// An internal content manager used only for asset propagation. See remarks on . + private readonly GameContentManagerForAssetPropagation DisposableContentManager; + /// Writes messages to the console. private readonly IMonitor Monitor; @@ -60,12 +64,14 @@ namespace StardewModdingAPI.Metadata *********/ /// Initialize the core asset data. /// The main content manager through which to reload assets. + /// An internal content manager used only for asset propagation. /// Writes messages to the console. /// Simplifies access to private code. /// Parse a raw asset name. - public CoreAssetPropagator(LocalizedContentManager mainContent, IMonitor monitor, Reflector reflection, Func parseAssetName) + public CoreAssetPropagator(LocalizedContentManager mainContent, GameContentManagerForAssetPropagation disposableContent, IMonitor monitor, Reflector reflection, Func parseAssetName) { this.MainContentManager = mainContent; + this.DisposableContentManager = disposableContent; this.Monitor = monitor; this.Reflection = reflection; this.ParseAssetName = parseAssetName; -- cgit