diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-09-24 00:23:48 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-09-24 00:23:48 -0400 |
commit | 0863f9b7e5f165f2b1db8750b20ed35bc0c3701a (patch) | |
tree | 30f7f83e6c699c03081067b01b3fd62a2846e6fc /src/StardewModdingAPI/Framework/Models/ModDataRecord.cs | |
parent | 33af789e2eb4da101cead531b77c29ecf4933549 (diff) | |
download | SMAPI-0863f9b7e5f165f2b1db8750b20ed35bc0c3701a.tar.gz SMAPI-0863f9b7e5f165f2b1db8750b20ed35bc0c3701a.tar.bz2 SMAPI-0863f9b7e5f165f2b1db8750b20ed35bc0c3701a.zip |
revamp mod compatibility fields to allow broader use of mod data records (#361)
Diffstat (limited to 'src/StardewModdingAPI/Framework/Models/ModDataRecord.cs')
-rw-r--r-- | src/StardewModdingAPI/Framework/Models/ModDataRecord.cs | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs b/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs index 8126022d..de219076 100644 --- a/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs +++ b/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs @@ -1,3 +1,4 @@ +using System.Linq; using Newtonsoft.Json; using StardewModdingAPI.Framework.Serialisation; @@ -16,25 +17,22 @@ namespace StardewModdingAPI.Framework.Models /// <summary>The mod name.</summary> public string Name { get; set; } - /// <summary>The oldest incompatible mod version, or <c>null</c> for all past versions.</summary> - [JsonConverter(typeof(SFieldConverter))] - public ISemanticVersion LowerVersion { get; set; } - - /// <summary>The most recent incompatible mod version.</summary> - [JsonConverter(typeof(SFieldConverter))] - public ISemanticVersion UpperVersion { get; set; } - - /// <summary>A label to show to the user instead of <see cref="UpperVersion"/>, when the manifest version differs from the user-facing version.</summary> - public string UpperVersionLabel { get; set; } - /// <summary>The URLs the user can check for a newer version.</summary> public string[] UpdateUrls { get; set; } - /// <summary>The reason phrase to show in the warning, or <c>null</c> to use the default value.</summary> - /// <example>"this version is incompatible with the latest version of the game"</example> - public string ReasonPhrase { get; set; } + /// <summary>The compatibility of given mod versions (if any).</summary> + [JsonConverter(typeof(SFieldConverter))] + public ModCompatibility[] Compatibility { get; set; } = new ModCompatibility[0]; + - /// <summary>Indicates how SMAPI should treat the mod.</summary> - public ModStatus Status { get; set; } = ModStatus.AssumeBroken; + /********* + ** Public methods + *********/ + /// <summary>Get the compatibility record for a given version, if any.</summary> + /// <param name="version">The mod version to check.</param> + public ModCompatibility GetCompatibility(ISemanticVersion version) + { + return this.Compatibility.FirstOrDefault(p => p.MatchesVersion(version)); + } } } |