From 9495cc0f493a11960aa23551e164018681d08f79 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 23 Sep 2017 22:07:29 -0400 Subject: rename mod compatibility records for broader use (#361) --- .../Framework/ModLoading/ModMetadata.cs | 12 ++++----- .../Framework/ModLoading/ModResolver.cs | 30 +++++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src/StardewModdingAPI/Framework/ModLoading') diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs b/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs index ab590e10..5055da75 100644 --- a/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs @@ -1,4 +1,4 @@ -using StardewModdingAPI.Framework.Models; +using StardewModdingAPI.Framework.Models; namespace StardewModdingAPI.Framework.ModLoading { @@ -17,8 +17,8 @@ namespace StardewModdingAPI.Framework.ModLoading /// The mod manifest. public IManifest Manifest { get; } - /// Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code. - public ModCompatibility Compatibility { get; } + /// Metadata about the mod from SMAPI's internal data (if any). + public ModDataRecord DataRecord { get; } /// The metadata resolution status. public ModMetadataStatus Status { get; private set; } @@ -37,13 +37,13 @@ namespace StardewModdingAPI.Framework.ModLoading /// The mod's display name. /// The mod's full directory path. /// The mod manifest. - /// Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code. - public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModCompatibility compatibility) + /// Metadata about the mod from SMAPI's internal data (if any). + public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModDataRecord dataRecord) { this.DisplayName = displayName; this.DirectoryPath = directoryPath; this.Manifest = manifest; - this.Compatibility = compatibility; + this.DataRecord = dataRecord; } /// Set the mod status. diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs index 02fd85ea..2da10348 100644 --- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs +++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs @@ -17,11 +17,11 @@ namespace StardewModdingAPI.Framework.ModLoading /// Get manifest metadata for each folder in the given root path. /// The root path to search for mods. /// The JSON helper with which to read manifests. - /// Metadata about mods that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code. + /// Metadata about mods from SMAPI's internal data. /// Returns the manifests by relative folder. - public IEnumerable ReadManifests(string rootPath, JsonHelper jsonHelper, IEnumerable compatibilityRecords) + public IEnumerable ReadManifests(string rootPath, JsonHelper jsonHelper, IEnumerable dataRecords) { - compatibilityRecords = compatibilityRecords.ToArray(); + dataRecords = dataRecords.ToArray(); foreach (DirectoryInfo modDir in this.GetModFolders(rootPath)) { @@ -54,15 +54,15 @@ namespace StardewModdingAPI.Framework.ModLoading } // validate metadata - ModCompatibility compatibility = null; + ModDataRecord dataRecord = null; if (manifest != null) { // get unique key for lookups string key = !string.IsNullOrWhiteSpace(manifest.UniqueID) ? manifest.UniqueID : manifest.EntryDll; - // get compatibility record - compatibility = ( - from mod in compatibilityRecords + // get data record + dataRecord = ( + from mod in dataRecords where mod.ID.Any(p => p.Matches(key, manifest)) && (mod.LowerVersion == null || !manifest.Version.IsOlderThan(mod.LowerVersion)) @@ -79,7 +79,7 @@ namespace StardewModdingAPI.Framework.ModLoading ? ModMetadataStatus.Found : ModMetadataStatus.Failed; - yield return new ModMetadata(displayName, modDir.FullName, manifest, compatibility).SetStatus(status, error); + yield return new ModMetadata(displayName, modDir.FullName, manifest, dataRecord).SetStatus(status, error); } } @@ -99,22 +99,22 @@ namespace StardewModdingAPI.Framework.ModLoading // validate compatibility { - ModCompatibility compatibility = mod.Compatibility; - switch (compatibility?.Status) + ModDataRecord dataRecord = mod.DataRecord; + switch (dataRecord?.Status) { case ModStatus.Obsolete: - mod.SetStatus(ModMetadataStatus.Failed, $"it's obsolete: {compatibility.ReasonPhrase}"); + mod.SetStatus(ModMetadataStatus.Failed, $"it's obsolete: {dataRecord.ReasonPhrase}"); continue; case ModStatus.AssumeBroken: { - string reasonPhrase = compatibility.ReasonPhrase ?? "it's no longer compatible"; + string reasonPhrase = dataRecord.ReasonPhrase ?? "it's no longer compatible"; string error = $"{reasonPhrase}. Please check for a "; - if (mod.Manifest.Version.Equals(compatibility.UpperVersion) && compatibility.UpperVersionLabel == null) + if (mod.Manifest.Version.Equals(dataRecord.UpperVersion) && dataRecord.UpperVersionLabel == null) error += "newer version"; else - error += $"version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()}"; - error += " at " + string.Join(" or ", compatibility.UpdateUrls); + error += $"version newer than {dataRecord.UpperVersionLabel ?? dataRecord.UpperVersion.ToString()}"; + error += " at " + string.Join(" or ", dataRecord.UpdateUrls); mod.SetStatus(ModMetadataStatus.Failed, error); continue; -- cgit