summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI')
-rw-r--r--src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs6
-rw-r--r--src/StardewModdingAPI/Framework/Models/ModCompatibility.cs35
2 files changed, 9 insertions, 32 deletions
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
index 16c397be..cf43eb45 100644
--- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs
@@ -72,8 +72,8 @@ namespace StardewModdingAPI.Framework.ModLoading
from mod in compatibilityRecords
where
mod.ID.Contains(key, StringComparer.InvariantCultureIgnoreCase)
- && (mod.LowerSemanticVersion == null || !manifest.Version.IsOlderThan(mod.LowerSemanticVersion))
- && !manifest.Version.IsNewerThan(mod.UpperSemanticVersion)
+ && (mod.LowerVersion == null || !manifest.Version.IsOlderThan(mod.LowerVersion))
+ && !manifest.Version.IsNewerThan(mod.UpperVersion)
select mod
).FirstOrDefault();
}
@@ -113,7 +113,7 @@ namespace StardewModdingAPI.Framework.ModLoading
bool hasUnofficialUrl = !string.IsNullOrWhiteSpace(mod.Compatibility.UnofficialUpdateUrl);
string reasonPhrase = compatibility.ReasonPhrase ?? "it's not compatible with the latest version of the game or SMAPI";
- string error = $"{reasonPhrase}. Please check for a version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion} here:";
+ string error = $"{reasonPhrase}. Please check for a version newer than {compatibility.UpperVersionLabel ?? compatibility.UpperVersion.ToString()} here:";
if (hasOfficialUrl)
error += !hasUnofficialUrl ? $" {compatibility.UpdateUrl}" : $"{Environment.NewLine}- official mod: {compatibility.UpdateUrl}";
if (hasUnofficialUrl)
diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs
index 90cbd237..eb312eff 100644
--- a/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs
+++ b/src/StardewModdingAPI/Framework/Models/ModCompatibility.cs
@@ -1,5 +1,5 @@
-using System.Runtime.Serialization;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
+using StardewModdingAPI.Framework.Serialisation;
namespace StardewModdingAPI.Framework.Models
{
@@ -19,10 +19,12 @@ namespace StardewModdingAPI.Framework.Models
public string Name { get; set; }
/// <summary>The oldest incompatible mod version, or <c>null</c> for all past versions.</summary>
- public string LowerVersion { get; set; }
+ [JsonConverter(typeof(SFieldConverter))]
+ public ISemanticVersion LowerVersion { get; set; }
/// <summary>The most recent incompatible mod version.</summary>
- public string UpperVersion { get; set; }
+ [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; }
@@ -39,30 +41,5 @@ namespace StardewModdingAPI.Framework.Models
/// <summary>Indicates how SMAPI should consider the mod.</summary>
public ModCompatibilityType Compatibility { get; set; }
-
-
- /****
- ** Injected
- ****/
- /// <summary>The semantic version corresponding to <see cref="LowerVersion"/>.</summary>
- [JsonIgnore]
- public ISemanticVersion LowerSemanticVersion { get; set; }
-
- /// <summary>The semantic version corresponding to <see cref="UpperVersion"/>.</summary>
- [JsonIgnore]
- public ISemanticVersion UpperSemanticVersion { get; set; }
-
-
- /*********
- ** Private methods
- *********/
- /// <summary>The method called when the model finishes deserialising.</summary>
- /// <param name="context">The deserialisation context.</param>
- [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;
- }
}
}