summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/Models
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-01-16 16:10:57 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-01-16 16:10:57 -0500
commit6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f (patch)
treefaa9155fae99533110853567003325486f208937 /src/StardewModdingAPI/Framework/Models
parente8825947ca82c8f28ad9bc8a225fb4fb749814cb (diff)
parent1f3d3c8c93c7a427486b60cf649b86cef140e88b (diff)
downloadSMAPI-6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f.tar.gz
SMAPI-6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f.tar.bz2
SMAPI-6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Framework/Models')
-rw-r--r--src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs b/src/StardewModdingAPI/Framework/Models/IncompatibleMod.cs
index 9bf06552..bcf5639c 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,9 +26,13 @@ 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; }
+ /// <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; }
+
/*********
** Public methods
@@ -34,14 +41,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
+}