diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-04-23 20:34:47 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-04-23 20:34:47 -0400 |
commit | 5f595d8a464174bf8ec6940476cf6e05014e17b4 (patch) | |
tree | 42c0df4c412793f6057646c575839e3d90e3cc5f | |
parent | 6f43a3dae5795f941819168475fc3bef08ecec70 (diff) | |
download | SMAPI-5f595d8a464174bf8ec6940476cf6e05014e17b4.tar.gz SMAPI-5f595d8a464174bf8ec6940476cf6e05014e17b4.tar.bz2 SMAPI-5f595d8a464174bf8ec6940476cf6e05014e17b4.zip |
let mods specify a minimum game version in their manifest.json (#264)
-rw-r--r-- | release-notes.md | 1 | ||||
-rw-r--r-- | src/StardewModdingAPI/Framework/Manifest.cs | 3 | ||||
-rw-r--r-- | src/StardewModdingAPI/IManifest.cs | 3 | ||||
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 19 |
4 files changed, 26 insertions, 0 deletions
diff --git a/release-notes.md b/release-notes.md index fcad4ccc..2f1dffd2 100644 --- a/release-notes.md +++ b/release-notes.md @@ -20,6 +20,7 @@ For players: For mod developers: * Fixed mouse-changed event never updating prior mouse position. * Fixed `monitor.ExitGameImmediately` not working correctly. +* Mods can now specify a minimum game version in their `manifest.json`. ## 1.9 See [log](https://github.com/Pathoschild/SMAPI/compare/1.8...1.9). diff --git a/src/StardewModdingAPI/Framework/Manifest.cs b/src/StardewModdingAPI/Framework/Manifest.cs index 189da9a8..f9c90ff6 100644 --- a/src/StardewModdingAPI/Framework/Manifest.cs +++ b/src/StardewModdingAPI/Framework/Manifest.cs @@ -26,6 +26,9 @@ namespace StardewModdingAPI.Framework /// <summary>The minimum SMAPI version required by this mod, if any.</summary> public string MinimumApiVersion { get; set; } + /// <summary>The minimum game version required by this mod, if any.</summary> + public string MinimumGameVersion { get; set; } + /// <summary>The name of the DLL in the directory that has the <see cref="Mod.Entry"/> method.</summary> public string EntryDll { get; set; } diff --git a/src/StardewModdingAPI/IManifest.cs b/src/StardewModdingAPI/IManifest.cs index 3e4b7513..f73b0c8f 100644 --- a/src/StardewModdingAPI/IManifest.cs +++ b/src/StardewModdingAPI/IManifest.cs @@ -18,6 +18,9 @@ /// <summary>The minimum SMAPI version required by this mod, if any.</summary> string MinimumApiVersion { get; set; } + /// <summary>The minimum game version required by this mod, if any.</summary> + string MinimumGameVersion { get; set; } + /// <summary>The unique mod ID.</summary> string UniqueID { get; set; } diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 00b5709f..678fa90d 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -436,6 +436,25 @@ namespace StardewModdingAPI } } + // validate game version + if (!string.IsNullOrWhiteSpace(manifest.MinimumGameVersion)) + { + try + { + ISemanticVersion minVersion = new SemanticVersion(manifest.MinimumGameVersion); + if (minVersion.IsNewerThan(Constants.GameVersion)) + { + this.Monitor.Log($"{skippedPrefix} because it needs Stardew Valley {minVersion} or later. Please update Stardew Valley to the latest version to use this mod.", LogLevel.Error); + continue; + } + } + catch (FormatException ex) when (ex.Message.Contains("not a valid semantic version")) + { + this.Monitor.Log($"{skippedPrefix} because it has an invalid minimum game version '{manifest.MinimumApiVersion}'. This should be a semantic version number like {Constants.GameVersion}.", LogLevel.Error); + continue; + } + } + // create per-save directory if (manifest.PerSaveConfigs) { |