diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-09-24 19:55:34 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-09-24 19:55:34 -0400 |
commit | b105c97dda01441d503d31e8b8ac0b3fd35fef14 (patch) | |
tree | 1e92d4a56d9d3647319fd66a814b75f2292fc6b4 /src/StardewModdingAPI/Framework | |
parent | f84def385d3d1b537e7f19b6ae1f90096e136505 (diff) | |
download | SMAPI-b105c97dda01441d503d31e8b8ac0b3fd35fef14.tar.gz SMAPI-b105c97dda01441d503d31e8b8ac0b3fd35fef14.tar.bz2 SMAPI-b105c97dda01441d503d31e8b8ac0b3fd35fef14.zip |
add support for remapping legacy versions for update checks (#361)
Diffstat (limited to 'src/StardewModdingAPI/Framework')
-rw-r--r-- | src/StardewModdingAPI/Framework/Models/ModDataRecord.cs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs b/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs index a2397fa8..0d033e82 100644 --- a/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs +++ b/src/StardewModdingAPI/Framework/Models/ModDataRecord.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using StardewModdingAPI.Framework.Serialisation; @@ -24,6 +25,12 @@ namespace StardewModdingAPI.Framework.Models [JsonConverter(typeof(SFieldConverter))] public ModCompatibility[] Compatibility { get; set; } = new ModCompatibility[0]; + /// <summary>Map local versions to a semantic version for update checks.</summary> + public IDictionary<string, string> MapLocalVersions { get; set; } = new Dictionary<string, string>(); + + /// <summary>Map remote versions to a semantic version for update checks.</summary> + public IDictionary<string, string> MapRemoteVersions { get; set; } = new Dictionary<string, string>(); + /********* ** Public methods @@ -34,5 +41,23 @@ namespace StardewModdingAPI.Framework.Models { return this.Compatibility.FirstOrDefault(p => p.MatchesVersion(version)); } + + /// <summary>Get a semantic local version for update checks.</summary> + /// <param name="version">The local version to normalise.</param> + public string GetLocalVersionForUpdateChecks(string version) + { + return this.MapLocalVersions != null && this.MapLocalVersions.TryGetValue(version, out string newVersion) + ? newVersion + : version; + } + + /// <summary>Get a semantic remote version for update checks.</summary> + /// <param name="version">The remote version to normalise.</param> + public string GetRemoteVersionForUpdateChecks(string version) + { + return this.MapRemoteVersions != null && this.MapRemoteVersions.TryGetValue(version, out string newVersion) + ? newVersion + : version; + } } } |