From ad1b9a870b5383ca9ada8c52b2bd76960d5579da Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 23 Aug 2020 14:22:27 -0400 Subject: move some console/logging logic out of SCore into a new LogManager --- src/SMAPI/Framework/ModLoading/ModMetadata.cs | 83 ++++++++++++--------------- 1 file changed, 36 insertions(+), 47 deletions(-) (limited to 'src/SMAPI/Framework/ModLoading') diff --git a/src/SMAPI/Framework/ModLoading/ModMetadata.cs b/src/SMAPI/Framework/ModLoading/ModMetadata.cs index 3ad1bd38..e793b0cd 100644 --- a/src/SMAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/SMAPI/Framework/ModLoading/ModMetadata.cs @@ -16,55 +16,58 @@ namespace StardewModdingAPI.Framework.ModLoading /********* ** Accessors *********/ - /// The mod's display name. + /// public string DisplayName { get; } - /// The root path containing mods. + /// public string RootPath { get; } - /// The mod's full directory path within the . + /// public string DirectoryPath { get; } - /// The relative to the . + /// public string RelativeDirectoryPath { get; } - /// The mod manifest. + /// public IManifest Manifest { get; } - /// Metadata about the mod from SMAPI's internal data (if any). + /// public ModDataRecordVersionedFields DataRecord { get; } - /// The metadata resolution status. + /// public ModMetadataStatus Status { get; private set; } - /// Indicates non-error issues with the mod. + /// public ModWarning Warnings { get; private set; } - /// The reason the metadata is invalid, if any. + /// public string Error { get; private set; } - /// Whether the mod folder should be ignored. This is true if it was found within a folder whose name starts with a dot. + /// + public string ErrorDetails { get; private set; } + + /// public bool IsIgnored { get; } - /// The mod instance (if loaded and is false). + /// public IMod Mod { get; private set; } - /// The content pack instance (if loaded and is true). + /// public IContentPack ContentPack { get; private set; } - /// The translations for this mod (if loaded). + /// public TranslationHelper Translations { get; private set; } - /// Writes messages to the console and log file as this mod. + /// public IMonitor Monitor { get; private set; } - /// The mod-provided API (if any). + /// public object Api { get; private set; } - /// The update-check metadata for this mod (if any). + /// public ModEntryModel UpdateCheckData { get; private set; } - /// Whether the mod is a content pack. + /// public bool IsContentPack => this.Manifest?.ContentPackFor != null; @@ -89,28 +92,23 @@ namespace StardewModdingAPI.Framework.ModLoading this.IsIgnored = isIgnored; } - /// Set the mod status. - /// The metadata resolution status. - /// The reason the metadata is invalid, if any. - /// Return the instance for chaining. - public IModMetadata SetStatus(ModMetadataStatus status, string error = null) + /// + public IModMetadata SetStatus(ModMetadataStatus status, string error = null, string errorDetails = null) { this.Status = status; this.Error = error; + this.ErrorDetails = errorDetails; return this; } - /// Set a warning flag for the mod. - /// The warning to set. + /// public IModMetadata SetWarning(ModWarning warning) { this.Warnings |= warning; return this; } - /// Set the mod instance. - /// The mod instance to set. - /// The translations for this mod (if loaded). + /// public IModMetadata SetMod(IMod mod, TranslationHelper translations) { if (this.ContentPack != null) @@ -122,10 +120,7 @@ namespace StardewModdingAPI.Framework.ModLoading return this; } - /// Set the mod instance. - /// The contentPack instance to set. - /// Writes messages to the console and log file. - /// The translations for this mod (if loaded). + /// public IModMetadata SetMod(IContentPack contentPack, IMonitor monitor, TranslationHelper translations) { if (this.Mod != null) @@ -137,29 +132,27 @@ namespace StardewModdingAPI.Framework.ModLoading return this; } - /// Set the mod-provided API instance. - /// The mod-provided API. + /// public IModMetadata SetApi(object api) { this.Api = api; return this; } - /// Set the update-check metadata for this mod. - /// The update-check metadata. + /// public IModMetadata SetUpdateData(ModEntryModel data) { this.UpdateCheckData = data; return this; } - /// Whether the mod manifest was loaded (regardless of whether the mod itself was loaded). + /// public bool HasManifest() { return this.Manifest != null; } - /// Whether the mod has an ID (regardless of whether the ID is valid or the mod itself was loaded). + /// public bool HasID() { return @@ -167,8 +160,7 @@ namespace StardewModdingAPI.Framework.ModLoading && !string.IsNullOrWhiteSpace(this.Manifest.UniqueID); } - /// Whether the mod has the given ID. - /// The mod ID to check. + /// public bool HasID(string id) { return @@ -176,8 +168,7 @@ namespace StardewModdingAPI.Framework.ModLoading && string.Equals(this.Manifest.UniqueID.Trim(), id?.Trim(), StringComparison.OrdinalIgnoreCase); } - /// Get the defined update keys. - /// Only return valid update keys. + /// public IEnumerable GetUpdateKeys(bool validOnly = false) { foreach (string rawKey in this.Manifest?.UpdateKeys ?? new string[0]) @@ -188,8 +179,7 @@ namespace StardewModdingAPI.Framework.ModLoading } } - /// Get the mod IDs that must be installed to load this mod. - /// Whether to include optional dependencies. + /// public IEnumerable GetRequiredModIds(bool includeOptional = false) { HashSet required = new HashSet(StringComparer.OrdinalIgnoreCase); @@ -209,14 +199,13 @@ namespace StardewModdingAPI.Framework.ModLoading yield return this.Manifest.ContentPackFor.UniqueID; } - /// Whether the mod has at least one valid update key set. + /// public bool HasValidUpdateKeys() { return this.GetUpdateKeys(validOnly: true).Any(); } - /// Get whether the mod has any of the given warnings which haven't been suppressed in the . - /// The warnings to check. + /// public bool HasUnsuppressedWarnings(params ModWarning[] warnings) { return warnings.Any(warning => @@ -225,7 +214,7 @@ namespace StardewModdingAPI.Framework.ModLoading ); } - /// Get a relative path which includes the root folder name. + /// public string GetRelativePathWithRoot() { string rootFolderName = Path.GetFileName(this.RootPath) ?? ""; -- cgit