summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-05-03 00:23:26 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-05-03 00:23:26 -0400
commit4bee6311c4f6bf654d8b9c54a53597347de65c4f (patch)
tree1876d58b73378ea67886e33650c8988cbbbb1eab /src/SMAPI
parent6a6001c7e6a03ff6fb0da992a87c6ef30d6bc952 (diff)
downloadSMAPI-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')
-rw-r--r--src/SMAPI/Constants.cs3
-rw-r--r--src/SMAPI/Program.cs28
2 files changed, 31 insertions, 0 deletions
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index 2ef26704..f87141b2 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -88,6 +88,9 @@ namespace StardewModdingAPI
/// <summary>The file path which stores a fatal crash message for the next run.</summary>
internal static string FatalCrashMarker => Path.Combine(Constants.ExecutionPath, "StardewModdingAPI.crash.marker");
+ /// <summary>The file path which stores the detected update version for the next run.</summary>
+ internal static string UpdateMarker => Path.Combine(Constants.ExecutionPath, "StardewModdingAPI.update.marker");
+
/// <summary>The full path to the folder containing mods.</summary>
internal static string ModPath { get; } = Path.Combine(Constants.ExecutionPath, "Mods");
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())
{