diff options
Diffstat (limited to 'src/StardewModdingAPI/Framework/Models')
-rw-r--r-- | src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs b/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs index 9bf06552..bcc62bb4 100644 --- a/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs +++ b/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs @@ -14,8 +14,11 @@ 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> + public string LowerVersion { get; set; } + /// <summary>The most recent incompatible mod version.</summary> - public string Version { get; set; } + public string UpperVersion { get; set; } /// <summary>The URL the user can check for an official updated version.</summary> public string UpdateUrl { get; set; } @@ -23,7 +26,7 @@ namespace StardewModdingAPI.Framework.Models /// <summary>The URL the user can check for an unofficial updated version.</summary> public string UnofficialUpdateUrl { get; set; } - /// <summary>A regular expression matching version strings to consider compatible, even if they technically precede <see cref="Version"/>.</summary> + /// <summary>A regular expression matching version strings to consider compatible, even if they technically precede <see cref="UpperVersion"/>.</summary> public string ForceCompatibleVersion { get; set; } @@ -34,14 +37,17 @@ namespace StardewModdingAPI.Framework.Models /// <param name="version">The current version of the matching mod.</param> public bool IsCompatible(ISemanticVersion version) { - ISemanticVersion incompatibleVersion = new SemanticVersion(this.Version); + ISemanticVersion lowerVersion = this.LowerVersion != null ? new SemanticVersion(this.LowerVersion) : null; + ISemanticVersion upperVersion = new SemanticVersion(this.UpperVersion); - // allow newer versions - if (version.IsNewerThan(incompatibleVersion)) + // ignore versions not in range + if (lowerVersion != null && version.IsOlderThan(lowerVersion)) + return true; + if (version.IsNewerThan(upperVersion)) return true; // allow versions matching override return !string.IsNullOrWhiteSpace(this.ForceCompatibleVersion) && Regex.IsMatch(version.ToString(), this.ForceCompatibleVersion, RegexOptions.IgnoreCase); } } -}
\ No newline at end of file +} |