diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-02-24 17:54:31 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-02-24 17:54:31 -0500 |
commit | 414cf5c197b5b59776d3dda914eb15710efb0868 (patch) | |
tree | 0393a95194ad78cf4440c68657b0488b7db6d68b /src/SMAPI/Framework/ModLoading/ModMetadata.cs | |
parent | 5da8b707385b9851ff3f6442de58519125f5c96f (diff) | |
parent | f2e8450706d1971d774f870081deffdb0c6b92eb (diff) | |
download | SMAPI-414cf5c197b5b59776d3dda914eb15710efb0868.tar.gz SMAPI-414cf5c197b5b59776d3dda914eb15710efb0868.tar.bz2 SMAPI-414cf5c197b5b59776d3dda914eb15710efb0868.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/ModLoading/ModMetadata.cs')
-rw-r--r-- | src/SMAPI/Framework/ModLoading/ModMetadata.cs | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index 30fe211b..1a0f9994 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -1,4 +1,5 @@ -using StardewModdingAPI.Framework.Models; +using System; +using StardewModdingAPI.Framework.ModData; namespace StardewModdingAPI.Framework.ModLoading { @@ -18,7 +19,7 @@ namespace StardewModdingAPI.Framework.ModLoading public IManifest Manifest { get; } /// <summary>Metadata about the mod from SMAPI's internal data (if any).</summary> - public ModDataRecord DataRecord { get; } + public ParsedModDataRecord DataRecord { get; } /// <summary>The metadata resolution status.</summary> public ModMetadataStatus Status { get; private set; } @@ -26,12 +27,21 @@ namespace StardewModdingAPI.Framework.ModLoading /// <summary>The reason the metadata is invalid, if any.</summary> public string Error { get; private set; } - /// <summary>The mod instance (if it was loaded).</summary> + /// <summary>The mod instance (if loaded and <see cref="IsContentPack"/> is false).</summary> public IMod Mod { get; private set; } + /// <summary>The content pack instance (if loaded and <see cref="IsContentPack"/> is true).</summary> + public IContentPack ContentPack { get; private set; } + + /// <summary>Writes messages to the console and log file as this mod.</summary> + public IMonitor Monitor { get; private set; } + /// <summary>The mod-provided API (if any).</summary> public object Api { get; private set; } + /// <summary>Whether the mod is a content pack.</summary> + public bool IsContentPack => this.Manifest?.ContentPackFor != null; + /********* ** Public methods @@ -41,7 +51,7 @@ namespace StardewModdingAPI.Framework.ModLoading /// <param name="directoryPath">The mod's full directory path.</param> /// <param name="manifest">The mod manifest.</param> /// <param name="dataRecord">Metadata about the mod from SMAPI's internal data (if any).</param> - public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModDataRecord dataRecord) + public ModMetadata(string displayName, string directoryPath, IManifest manifest, ParsedModDataRecord dataRecord) { this.DisplayName = displayName; this.DirectoryPath = directoryPath; @@ -64,7 +74,24 @@ namespace StardewModdingAPI.Framework.ModLoading /// <param name="mod">The mod instance to set.</param> public IModMetadata SetMod(IMod mod) { + if (this.ContentPack != null) + throw new InvalidOperationException("A mod can't be both an assembly mod and content pack."); + this.Mod = mod; + this.Monitor = mod.Monitor; + return this; + } + + /// <summary>Set the mod instance.</summary> + /// <param name="contentPack">The contentPack instance to set.</param> + /// <param name="monitor">Writes messages to the console and log file.</param> + public IModMetadata SetMod(IContentPack contentPack, IMonitor monitor) + { + if (this.Mod != null) + throw new InvalidOperationException("A mod can't be both an assembly mod and content pack."); + + this.ContentPack = contentPack; + this.Monitor = monitor; return this; } |