diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-07 21:18:09 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-05-07 21:18:09 -0400 |
commit | f973b4c51839aa2364879ec2ba66da703f20ae06 (patch) | |
tree | ff9d6e8479e0f60fc983026e9fb7fb2b668e6981 /src/SMAPI/Framework | |
parent | e7e6327b3c85d52ab666aad2a054fbbdbd9431da (diff) | |
download | SMAPI-f973b4c51839aa2364879ec2ba66da703f20ae06.tar.gz SMAPI-f973b4c51839aa2364879ec2ba66da703f20ae06.tar.bz2 SMAPI-f973b4c51839aa2364879ec2ba66da703f20ae06.zip |
move CreateFakeContentPack into its own method
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r-- | src/SMAPI/Framework/SCore.cs | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index a9296d9b..ad6de997 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -1835,22 +1835,6 @@ namespace StardewModdingAPI.Framework TranslationHelper translationHelper = new(mod, contentCore.GetLocale(), contentCore.Language); IModHelper modHelper; { - IContentPack CreateFakeContentPack(string packDirPath, IManifest packManifest) - { - IMonitor packMonitor = this.LogManager.GetMonitor(packManifest.Name); - - IFilePathLookup relativePathCache = this.GetFilePathLookup(packDirPath); - - GameContentHelper gameContentHelper = new(contentCore, mod, packManifest.Name, packMonitor, this.Reflection); - IModContentHelper packContentHelper = new ModContentHelper(contentCore, packDirPath, mod, packManifest.Name, gameContentHelper.GetUnderlyingContentManager(), relativePathCache, this.Reflection); - TranslationHelper packTranslationHelper = new(mod, contentCore.GetLocale(), contentCore.Language); - - ContentPack contentPack = new(packDirPath, packManifest, packContentHelper, packTranslationHelper, this.Toolkit.JsonHelper, relativePathCache); - this.ReloadTranslationsForTemporaryContentPack(mod, contentPack); - mod.FakeContentPacks.Add(new WeakReference<ContentPack>(contentPack)); - return contentPack; - } - IModEvents events = new ModEvents(mod, this.EventManager); ICommandHelper commandHelper = new CommandHelper(mod, this.CommandManager); IFilePathLookup relativePathLookup = this.GetFilePathLookup(mod.DirectoryPath); @@ -1859,7 +1843,11 @@ namespace StardewModdingAPI.Framework #pragma warning restore CS0612 GameContentHelper gameContentHelper = new(contentCore, mod, mod.DisplayName, monitor, this.Reflection); IModContentHelper modContentHelper = new ModContentHelper(contentCore, mod.DirectoryPath, mod, mod.DisplayName, gameContentHelper.GetUnderlyingContentManager(), relativePathLookup, this.Reflection); - IContentPackHelper contentPackHelper = new ContentPackHelper(mod, new Lazy<IContentPack[]>(GetContentPacks), CreateFakeContentPack); + IContentPackHelper contentPackHelper = new ContentPackHelper( + mod: mod, + contentPacks: new Lazy<IContentPack[]>(GetContentPacks), + createContentPack: (dirPath, manifest) => this.CreateFakeContentPack(dirPath, manifest, contentCore, mod) + ); IDataHelper dataHelper = new DataHelper(mod, mod.DirectoryPath, jsonHelper); IReflectionHelper reflectionHelper = new ReflectionHelper(mod, mod.DisplayName, this.Reflection); IModRegistry modRegistryHelper = new ModRegistryHelper(mod, this.ModRegistry, proxyFactory, monitor); @@ -1888,6 +1876,27 @@ namespace StardewModdingAPI.Framework } } + /// <summary>Create a fake content pack instance for a parent mod.</summary> + /// <param name="packDirPath">The absolute path to the fake content pack's directory.</param> + /// <param name="packManifest">The fake content pack's manifest.</param> + /// <param name="contentCore">The content manager to use for mod content.</param> + /// <param name="mod">The mod for which the content pack is being created.</param> + private IContentPack CreateFakeContentPack(string packDirPath, IManifest packManifest, ContentCoordinator contentCore, IModMetadata mod) + { + IMonitor packMonitor = this.LogManager.GetMonitor(packManifest.Name); + + IFilePathLookup relativePathCache = this.GetFilePathLookup(packDirPath); + + GameContentHelper gameContentHelper = new(contentCore, mod, packManifest.Name, packMonitor, this.Reflection); + IModContentHelper packContentHelper = new ModContentHelper(contentCore, packDirPath, mod, packManifest.Name, gameContentHelper.GetUnderlyingContentManager(), relativePathCache, this.Reflection); + TranslationHelper packTranslationHelper = new(mod, contentCore.GetLocale(), contentCore.Language); + + ContentPack contentPack = new(packDirPath, packManifest, packContentHelper, packTranslationHelper, this.Toolkit.JsonHelper, relativePathCache); + this.ReloadTranslationsForTemporaryContentPack(mod, contentPack); + mod.FakeContentPacks.Add(new WeakReference<ContentPack>(contentPack)); + return contentPack; + } + /// <summary>Load a mod's entry class.</summary> /// <param name="modAssembly">The mod assembly.</param> /// <param name="mod">The loaded instance.</param> |