summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md1
-rw-r--r--src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs10
-rw-r--r--src/SMAPI/Framework/SCore.cs14
3 files changed, 21 insertions, 4 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 9cd45f61..e558a1bb 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -3,6 +3,7 @@
# Release notes
## Upcoming release
* For mod authors:
+ * Dynamic content packs created via `helper.ContentPacks.CreateTemporary` or `CreateFake` are now listed in the log file.
* Fixed assets loaded through a fake content pack not working correctly since 3.14.0.
## 3.14.1
diff --git a/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs
index 9f4a7ceb..6bc091fa 100644
--- a/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ContentPackHelper.cs
@@ -42,7 +42,15 @@ namespace StardewModdingAPI.Framework.ModHelpers
public IContentPack CreateFake(string directoryPath)
{
string id = Guid.NewGuid().ToString("N");
- return this.CreateTemporary(directoryPath, id, id, id, id, new SemanticVersion(1, 0, 0));
+ string relativePath = Path.GetRelativePath(Constants.ModsPath, directoryPath);
+ return this.CreateTemporary(
+ directoryPath: directoryPath,
+ id: id,
+ name: $"{this.Mod.DisplayName} (fake content pack: {relativePath})",
+ description: $"A temporary content pack created by the {this.Mod.DisplayName} mod.",
+ author: "???",
+ new SemanticVersion(1, 0, 0)
+ );
}
/// <inheritdoc />
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index c8dcf747..0465b6f1 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -1846,7 +1846,7 @@ namespace StardewModdingAPI.Framework
IContentPackHelper contentPackHelper = new ContentPackHelper(
mod: mod,
contentPacks: new Lazy<IContentPack[]>(GetContentPacks),
- createContentPack: (dirPath, manifest) => this.CreateFakeContentPack(dirPath, manifest, contentCore, mod)
+ createContentPack: (dirPath, fakeManifest) => this.CreateFakeContentPack(dirPath, fakeManifest, contentCore, mod)
);
IDataHelper dataHelper = new DataHelper(mod, mod.DirectoryPath, jsonHelper);
IReflectionHelper reflectionHelper = new ReflectionHelper(mod, mod.DisplayName, this.Reflection);
@@ -1883,8 +1883,10 @@ namespace StardewModdingAPI.Framework
/// <param name="parentMod">The mod for which the content pack is being created.</param>
private IContentPack CreateFakeContentPack(string packDirPath, IManifest packManifest, ContentCoordinator contentCore, IModMetadata parentMod)
{
+ // create fake mod info
+ string relativePath = Path.GetRelativePath(Constants.ModsPath, packDirPath);
IModMetadata fakeMod = new ModMetadata(
- displayName: $"{parentMod.DisplayName} (fake content pack: {Path.GetRelativePath(Constants.ModsPath, packDirPath)})",
+ displayName: packManifest.Name,
directoryPath: packDirPath,
rootPath: Constants.ModsPath,
manifest: packManifest,
@@ -1892,16 +1894,22 @@ namespace StardewModdingAPI.Framework
isIgnored: false
);
+ // create mod helpers
IMonitor packMonitor = this.LogManager.GetMonitor(packManifest.Name);
IFilePathLookup relativePathCache = this.GetFilePathLookup(packDirPath);
-
GameContentHelper gameContentHelper = new(contentCore, fakeMod, packManifest.Name, packMonitor, this.Reflection);
IModContentHelper packContentHelper = new ModContentHelper(contentCore, packDirPath, fakeMod, packManifest.Name, gameContentHelper.GetUnderlyingContentManager(), relativePathCache, this.Reflection);
TranslationHelper packTranslationHelper = new(fakeMod, contentCore.GetLocale(), contentCore.Language);
+ // add content pack
ContentPack contentPack = new(packDirPath, packManifest, packContentHelper, packTranslationHelper, this.Toolkit.JsonHelper, relativePathCache);
this.ReloadTranslationsForTemporaryContentPack(parentMod, contentPack);
parentMod.FakeContentPacks.Add(new WeakReference<ContentPack>(contentPack));
+
+ // log change
+ string pathLabel = packDirPath.Contains("..") ? packDirPath : relativePath;
+ this.Monitor.Log($"{parentMod.DisplayName} created dynamic content pack '{packManifest.Name}' (unique ID: {packManifest.UniqueID}{(packManifest.Name.Contains(pathLabel) ? "" : $", path: {pathLabel}")}).");
+
return contentPack;
}