From 104aa314127bd816d5dbcac8c57ecb84b12f20d1 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 14 Mar 2017 20:48:02 -0400 Subject: let players override SMAPI incompatible-code detection if needed --- .../Framework/Models/IncompatibleMod.cs | 65 ---------------------- .../Framework/Models/ModCompatibility.cs | 65 ++++++++++++++++++++++ .../Framework/Models/ModCompatibilityType.cs | 12 ++++ src/StardewModdingAPI/Framework/Models/SConfig.cs | 4 +- 4 files changed, 79 insertions(+), 67 deletions(-) delete mode 100644 src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs create mode 100644 src/StardewModdingAPI/Framework/Models/ModCompatibility.cs create mode 100644 src/StardewModdingAPI/Framework/Models/ModCompatibilityType.cs (limited to 'src/StardewModdingAPI/Framework/Models') diff --git a/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs b/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs deleted file mode 100644 index 29e18ddb..00000000 --- a/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Runtime.Serialization; -using Newtonsoft.Json; - -namespace StardewModdingAPI.Framework.Models -{ - /// Contains abstract metadata about an incompatible mod. - internal class IncompatibleMod - { - /********* - ** Accessors - *********/ - /**** - ** From config - ****/ - /// The unique mod ID. - public string ID { get; set; } - - /// The mod name. - public string Name { get; set; } - - /// The oldest incompatible mod version, or null for all past versions. - public string LowerVersion { get; set; } - - /// The most recent incompatible mod version. - public string UpperVersion { get; set; } - - /// The URL the user can check for an official updated version. - public string UpdateUrl { get; set; } - - /// The URL the user can check for an unofficial updated version. - public string UnofficialUpdateUrl { get; set; } - - /// A regular expression matching version strings to consider compatible, even if they technically precede . - public string ForceCompatibleVersion { get; set; } - - /// The reason phrase to show in the warning, or null to use the default value. - /// "this version is incompatible with the latest version of the game" - public string ReasonPhrase { get; set; } - - - /**** - ** Injected - ****/ - /// The semantic version corresponding to . - [JsonIgnore] - public ISemanticVersion LowerSemanticVersion { get; set; } - - /// The semantic version corresponding to . - [JsonIgnore] - public ISemanticVersion UpperSemanticVersion { get; set; } - - - /********* - ** Private methods - *********/ - /// The method called when the model finishes deserialising. - /// The deserialisation context. - [OnDeserialized] - private void OnDeserialized(StreamingContext context) - { - this.LowerSemanticVersion = this.LowerVersion != null ? new SemanticVersion(this.LowerVersion) : null; - this.UpperSemanticVersion = this.UpperVersion != null ? new SemanticVersion(this.UpperVersion) : null; - } - } -} diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs new file mode 100644 index 00000000..1e71dae0 --- /dev/null +++ b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs @@ -0,0 +1,65 @@ +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace StardewModdingAPI.Framework.Models +{ + /// Metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code. + internal class ModCompatibility + { + /********* + ** Accessors + *********/ + /**** + ** From config + ****/ + /// The unique mod ID. + public string ID { get; set; } + + /// The mod name. + public string Name { get; set; } + + /// The oldest incompatible mod version, or null for all past versions. + public string LowerVersion { get; set; } + + /// The most recent incompatible mod version. + public string UpperVersion { get; set; } + + /// The URL the user can check for an official updated version. + public string UpdateUrl { get; set; } + + /// The URL the user can check for an unofficial updated version. + public string UnofficialUpdateUrl { get; set; } + + /// The reason phrase to show in the warning, or null to use the default value. + /// "this version is incompatible with the latest version of the game" + public string ReasonPhrase { get; set; } + + /// Indicates how SMAPI should consider the mod. + public ModCompatibilityType Compatibility { get; set; } + + + /**** + ** Injected + ****/ + /// The semantic version corresponding to . + [JsonIgnore] + public ISemanticVersion LowerSemanticVersion { get; set; } + + /// The semantic version corresponding to . + [JsonIgnore] + public ISemanticVersion UpperSemanticVersion { get; set; } + + + /********* + ** Private methods + *********/ + /// The method called when the model finishes deserialising. + /// The deserialisation context. + [OnDeserialized] + private void OnDeserialized(StreamingContext context) + { + this.LowerSemanticVersion = this.LowerVersion != null ? new SemanticVersion(this.LowerVersion) : null; + this.UpperSemanticVersion = this.UpperVersion != null ? new SemanticVersion(this.UpperVersion) : null; + } + } +} diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibilityType.cs b/src/StardewModdingAPI/Framework/Models/ModCompatibilityType.cs new file mode 100644 index 00000000..35edec5e --- /dev/null +++ b/src/StardewModdingAPI/Framework/Models/ModCompatibilityType.cs @@ -0,0 +1,12 @@ +namespace StardewModdingAPI.Framework.Models +{ + /// Indicates how SMAPI should consider a mod. + internal enum ModCompatibilityType + { + /// Assume the mod is not compatible, even if SMAPI doesn't detect any incompatible code. + AssumeBroken = 0, + + /// Assume the mod is compatible, even if SMAPI detects incompatible code. + AssumeCompatible = 1 + } +} diff --git a/src/StardewModdingAPI/Framework/Models/SConfig.cs b/src/StardewModdingAPI/Framework/Models/SConfig.cs index 558da82a..0de96297 100644 --- a/src/StardewModdingAPI/Framework/Models/SConfig.cs +++ b/src/StardewModdingAPI/Framework/Models/SConfig.cs @@ -12,7 +12,7 @@ /// Whether to check if a newer version of SMAPI is available on startup. public bool CheckForUpdates { get; set; } = true; - /// A list of mod versions which should be considered incompatible. - public IncompatibleMod[] IncompatibleMods { get; set; } + /// A list of mod versions which should be considered compatible or incompatible regardless of whether SMAPI detects incompatible code. + public ModCompatibility[] ModCompatibility { get; set; } } } -- cgit