diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-09-07 13:06:27 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-09-07 13:06:27 -0400 |
commit | 5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83 (patch) | |
tree | 0a42305174eb84561a584549cd685c5e95670f36 /src/SMAPI/Framework/ModLoading/ModMetadata.cs | |
parent | 8da88b8fe5b41739c5cd0df3280b9770fc7f10a4 (diff) | |
parent | f9fac11028354f15d786d5b854608edb10716f79 (diff) | |
download | SMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.tar.gz SMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.tar.bz2 SMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/ModLoading/ModMetadata.cs')
-rw-r--r-- | src/SMAPI/Framework/ModLoading/ModMetadata.cs | 95 |
1 files changed, 48 insertions, 47 deletions
diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index 3ad1bd38..18d2b112 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -16,55 +16,61 @@ namespace StardewModdingAPI.Framework.ModLoading /********* ** Accessors *********/ - /// <summary>The mod's display name.</summary> + /// <inheritdoc /> public string DisplayName { get; } - /// <summary>The root path containing mods.</summary> + /// <inheritdoc /> public string RootPath { get; } - /// <summary>The mod's full directory path within the <see cref="RootPath"/>.</summary> + /// <inheritdoc /> public string DirectoryPath { get; } - /// <summary>The <see cref="DirectoryPath"/> relative to the <see cref="RootPath"/>.</summary> + /// <inheritdoc /> public string RelativeDirectoryPath { get; } - /// <summary>The mod manifest.</summary> + /// <inheritdoc /> public IManifest Manifest { get; } - /// <summary>Metadata about the mod from SMAPI's internal data (if any).</summary> + /// <inheritdoc /> public ModDataRecordVersionedFields DataRecord { get; } - /// <summary>The metadata resolution status.</summary> + /// <inheritdoc /> public ModMetadataStatus Status { get; private set; } - /// <summary>Indicates non-error issues with the mod.</summary> + /// <inheritdoc /> + public ModFailReason? FailReason { get; private set; } + + /// <inheritdoc /> public ModWarning Warnings { get; private set; } - /// <summary>The reason the metadata is invalid, if any.</summary> + /// <inheritdoc /> public string Error { get; private set; } - /// <summary>Whether the mod folder should be ignored. This is <c>true</c> if it was found within a folder whose name starts with a dot.</summary> + /// <inheritdoc /> + public string ErrorDetails { get; private set; } + + /// <inheritdoc /> public bool IsIgnored { get; } - /// <summary>The mod instance (if loaded and <see cref="IsContentPack"/> is false).</summary> + /// <inheritdoc /> public IMod Mod { get; private set; } - /// <summary>The content pack instance (if loaded and <see cref="IsContentPack"/> is true).</summary> + /// <inheritdoc /> public IContentPack ContentPack { get; private set; } - /// <summary>The translations for this mod (if loaded).</summary> + /// <inheritdoc /> public TranslationHelper Translations { get; private set; } - /// <summary>Writes messages to the console and log file as this mod.</summary> + /// <inheritdoc /> public IMonitor Monitor { get; private set; } - /// <summary>The mod-provided API (if any).</summary> + /// <inheritdoc /> public object Api { get; private set; } - /// <summary>The update-check metadata for this mod (if any).</summary> + /// <inheritdoc /> public ModEntryModel UpdateCheckData { get; private set; } - /// <summary>Whether the mod is a content pack.</summary> + /// <inheritdoc /> public bool IsContentPack => this.Manifest?.ContentPackFor != null; @@ -89,28 +95,32 @@ namespace StardewModdingAPI.Framework.ModLoading this.IsIgnored = isIgnored; } - /// <summary>Set the mod status.</summary> - /// <param name="status">The metadata resolution status.</param> - /// <param name="error">The reason the metadata is invalid, if any.</param> - /// <returns>Return the instance for chaining.</returns> - public IModMetadata SetStatus(ModMetadataStatus status, string error = null) + /// <inheritdoc /> + public IModMetadata SetStatusFound() + { + this.SetStatus(ModMetadataStatus.Found, ModFailReason.Incompatible, null); + this.FailReason = null; + return this; + } + + /// <inheritdoc /> + public IModMetadata SetStatus(ModMetadataStatus status, ModFailReason reason, string error, string errorDetails = null) { this.Status = status; + this.FailReason = reason; this.Error = error; + this.ErrorDetails = errorDetails; return this; } - /// <summary>Set a warning flag for the mod.</summary> - /// <param name="warning">The warning to set.</param> + /// <inheritdoc /> public IModMetadata SetWarning(ModWarning warning) { this.Warnings |= warning; return this; } - /// <summary>Set the mod instance.</summary> - /// <param name="mod">The mod instance to set.</param> - /// <param name="translations">The translations for this mod (if loaded).</param> + /// <inheritdoc /> public IModMetadata SetMod(IMod mod, TranslationHelper translations) { if (this.ContentPack != null) @@ -122,10 +132,7 @@ namespace StardewModdingAPI.Framework.ModLoading 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> - /// <param name="translations">The translations for this mod (if loaded).</param> + /// <inheritdoc /> public IModMetadata SetMod(IContentPack contentPack, IMonitor monitor, TranslationHelper translations) { if (this.Mod != null) @@ -137,29 +144,27 @@ namespace StardewModdingAPI.Framework.ModLoading return this; } - /// <summary>Set the mod-provided API instance.</summary> - /// <param name="api">The mod-provided API.</param> + /// <inheritdoc /> public IModMetadata SetApi(object api) { this.Api = api; return this; } - /// <summary>Set the update-check metadata for this mod.</summary> - /// <param name="data">The update-check metadata.</param> + /// <inheritdoc /> public IModMetadata SetUpdateData(ModEntryModel data) { this.UpdateCheckData = data; return this; } - /// <summary>Whether the mod manifest was loaded (regardless of whether the mod itself was loaded).</summary> + /// <inheritdoc /> public bool HasManifest() { return this.Manifest != null; } - /// <summary>Whether the mod has an ID (regardless of whether the ID is valid or the mod itself was loaded).</summary> + /// <inheritdoc /> public bool HasID() { return @@ -167,8 +172,7 @@ namespace StardewModdingAPI.Framework.ModLoading && !string.IsNullOrWhiteSpace(this.Manifest.UniqueID); } - /// <summary>Whether the mod has the given ID.</summary> - /// <param name="id">The mod ID to check.</param> + /// <inheritdoc /> public bool HasID(string id) { return @@ -176,8 +180,7 @@ namespace StardewModdingAPI.Framework.ModLoading && string.Equals(this.Manifest.UniqueID.Trim(), id?.Trim(), StringComparison.OrdinalIgnoreCase); } - /// <summary>Get the defined update keys.</summary> - /// <param name="validOnly">Only return valid update keys.</param> + /// <inheritdoc /> public IEnumerable<UpdateKey> GetUpdateKeys(bool validOnly = false) { foreach (string rawKey in this.Manifest?.UpdateKeys ?? new string[0]) @@ -188,8 +191,7 @@ namespace StardewModdingAPI.Framework.ModLoading } } - /// <summary>Get the mod IDs that must be installed to load this mod.</summary> - /// <param name="includeOptional">Whether to include optional dependencies.</param> + /// <inheritdoc /> public IEnumerable<string> GetRequiredModIds(bool includeOptional = false) { HashSet<string> required = new HashSet<string>(StringComparer.OrdinalIgnoreCase); @@ -209,14 +211,13 @@ namespace StardewModdingAPI.Framework.ModLoading yield return this.Manifest.ContentPackFor.UniqueID; } - /// <summary>Whether the mod has at least one valid update key set.</summary> + /// <inheritdoc /> public bool HasValidUpdateKeys() { return this.GetUpdateKeys(validOnly: true).Any(); } - /// <summary>Get whether the mod has any of the given warnings which haven't been suppressed in the <see cref="IModMetadata.DataRecord"/>.</summary> - /// <param name="warnings">The warnings to check.</param> + /// <inheritdoc /> public bool HasUnsuppressedWarnings(params ModWarning[] warnings) { return warnings.Any(warning => @@ -225,7 +226,7 @@ namespace StardewModdingAPI.Framework.ModLoading ); } - /// <summary>Get a relative path which includes the root folder name.</summary> + /// <inheritdoc /> public string GetRelativePathWithRoot() { string rootFolderName = Path.GetFileName(this.RootPath) ?? ""; |