diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-05-03 00:23:26 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-05-03 00:23:26 -0400 |
commit | 4bee6311c4f6bf654d8b9c54a53597347de65c4f (patch) | |
tree | 1876d58b73378ea67886e33650c8988cbbbb1eab /src/SMAPI/Program.cs | |
parent | 6a6001c7e6a03ff6fb0da992a87c6ef30d6bc952 (diff) | |
download | SMAPI-4bee6311c4f6bf654d8b9c54a53597347de65c4f.tar.gz SMAPI-4bee6311c4f6bf654d8b9c54a53597347de65c4f.tar.bz2 SMAPI-4bee6311c4f6bf654d8b9c54a53597347de65c4f.zip |
add prompt when in beta channel and a new version is found
Diffstat (limited to 'src/SMAPI/Program.cs')
-rw-r--r-- | src/SMAPI/Program.cs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index 64520ccf..ebe44cf7 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -241,6 +241,23 @@ namespace StardewModdingAPI return; } + // check update marker + if (File.Exists(Constants.UpdateMarker)) + { + string rawUpdateFound = File.ReadAllText(Constants.UpdateMarker); + if (SemanticVersion.TryParse(rawUpdateFound, out ISemanticVersion updateFound)) + { + if (Constants.ApiVersion.IsPrerelease() && updateFound.IsNewerThan(Constants.ApiVersion)) + { + this.Monitor.Log("A new version of SMAPI was detected last time you played.", LogLevel.Error); + this.Monitor.Log($"You can update to {updateFound}: https://smapi.io.", LogLevel.Error); + this.Monitor.Log("Press any key to continue playing anyway. (This only appears when using a SMAPI beta.)", LogLevel.Info); + Console.ReadKey(); + } + } + File.Delete(Constants.UpdateMarker); + } + // show details if game crashed during last session if (File.Exists(Constants.FatalCrashMarker)) { @@ -548,6 +565,7 @@ namespace StardewModdingAPI this.Monitor.Log("Checking for updates...", LogLevel.Trace); // check SMAPI version + ISemanticVersion updateFound = null; try { ModInfoModel response = client.GetModInfo($"GitHub:{this.Settings.GitHubProjectName}").Single().Value; @@ -560,9 +578,15 @@ namespace StardewModdingAPI this.Monitor.Log($"Error: {response.Error}"); } else if (this.IsValidUpdate(Constants.ApiVersion, latestBeta, this.Settings.UseBetaChannel)) + { + updateFound = latestBeta; this.Monitor.Log($"You can update SMAPI to {latestBeta}: {Constants.HomePageUrl}", LogLevel.Alert); + } else if (this.IsValidUpdate(Constants.ApiVersion, latestStable, this.Settings.UseBetaChannel)) + { + updateFound = latestStable; this.Monitor.Log($"You can update SMAPI to {latestStable}: {Constants.HomePageUrl}", LogLevel.Alert); + } else this.Monitor.Log(" SMAPI okay.", LogLevel.Trace); } @@ -575,6 +599,10 @@ namespace StardewModdingAPI ); } + // show update message on next launch + if (updateFound != null) + File.WriteAllText(Constants.UpdateMarker, updateFound.ToString()); + // check mod versions if (mods.Any()) { |