summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Program.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-05-20 00:29:04 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-05-20 00:29:04 -0400
commit9ef4876c5e7de02d17785ebe7950f0edc57ae194 (patch)
treee9a1a16c31c57126a6dc6b2fd5526531d9a7dbfc /src/StardewModdingAPI/Program.cs
parent2781c27786739abc6f8f948e3068b0c997296524 (diff)
downloadSMAPI-9ef4876c5e7de02d17785ebe7950f0edc57ae194.tar.gz
SMAPI-9ef4876c5e7de02d17785ebe7950f0edc57ae194.tar.bz2
SMAPI-9ef4876c5e7de02d17785ebe7950f0edc57ae194.zip
add metadata to internal mod registry & use mod display name everywhere
Diffstat (limited to 'src/StardewModdingAPI/Program.cs')
-rw-r--r--src/StardewModdingAPI/Program.cs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index ada05320..06523144 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -237,15 +237,15 @@ namespace StardewModdingAPI
this.IsDisposed = true;
// dispose mod data
- foreach (IMod mod in this.ModRegistry.GetMods())
+ foreach (IModMetadata mod in this.ModRegistry.GetMods())
{
try
{
- (mod as IDisposable)?.Dispose();
+ (mod.Mod as IDisposable)?.Dispose();
}
catch (Exception ex)
{
- this.Monitor.Log($"The {mod.ModManifest.Name} mod failed during disposal: {ex.GetLogSummary()}.", LogLevel.Warn);
+ this.Monitor.Log($"The {mod.DisplayName} mod failed during disposal: {ex.GetLogSummary()}.", LogLevel.Warn);
}
}
@@ -580,14 +580,15 @@ namespace StardewModdingAPI
// inject data
mod.ModManifest = manifest;
- mod.Helper = new ModHelper(manifest, metadata.DirectoryPath, jsonHelper, this.ModRegistry, this.CommandManager, contentManager, this.Reflection);
- mod.Monitor = this.GetSecondaryMonitor(manifest.Name);
+ mod.Helper = new ModHelper(metadata.DisplayName, manifest, metadata.DirectoryPath, jsonHelper, this.ModRegistry, this.CommandManager, contentManager, this.Reflection);
+ mod.Monitor = this.GetSecondaryMonitor(metadata.DisplayName);
mod.PathOnDisk = metadata.DirectoryPath;
// track mod
- this.ModRegistry.Add(mod);
+ metadata.SetMod(mod);
+ this.ModRegistry.Add(metadata);
modsLoaded += 1;
- this.Monitor.Log($"Loaded {manifest.Name} by {manifest.Author}, v{manifest.Version} | {manifest.Description}", LogLevel.Info);
+ this.Monitor.Log($"Loaded {metadata.DisplayName} by {manifest.Author}, v{manifest.Version} | {manifest.Description}", LogLevel.Info);
}
catch (Exception ex)
{
@@ -596,21 +597,23 @@ namespace StardewModdingAPI
}
// initialise loaded mods
- foreach (IMod mod in this.ModRegistry.GetMods())
+ foreach (IModMetadata metadata in this.ModRegistry.GetMods())
{
try
{
+ IMod mod = metadata.Mod;
+
// call entry methods
(mod as Mod)?.Entry(); // deprecated since 1.0
mod.Entry(mod.Helper);
// raise deprecation warning for old Entry() methods
if (this.DeprecationManager.IsVirtualMethodImplemented(mod.GetType(), typeof(Mod), nameof(Mod.Entry), new[] { typeof(object[]) }))
- deprecationWarnings.Add(() => this.DeprecationManager.Warn(mod.ModManifest.Name, $"{nameof(Mod)}.{nameof(Mod.Entry)}(object[]) instead of {nameof(Mod)}.{nameof(Mod.Entry)}({nameof(IModHelper)})", "1.0", DeprecationLevel.Info));
+ deprecationWarnings.Add(() => this.DeprecationManager.Warn(metadata.DisplayName, $"{nameof(Mod)}.{nameof(Mod.Entry)}(object[]) instead of {nameof(Mod)}.{nameof(Mod.Entry)}({nameof(IModHelper)})", "1.0", DeprecationLevel.Info));
}
catch (Exception ex)
{
- this.Monitor.Log($"The {mod.ModManifest.Name} mod failed on entry initialisation. It will still be loaded, but may not function correctly.\n{ex.GetLogSummary()}", LogLevel.Warn);
+ this.Monitor.Log($"The {metadata.DisplayName} mod failed on entry initialisation. It will still be loaded, but may not function correctly.\n{ex.GetLogSummary()}", LogLevel.Warn);
}
}