From 067d5f6b693c9e30ff5f4f2b1cd363b036a7b3cc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 4 Nov 2016 23:31:06 -0400 Subject: add minimum game version check (#163) --- src/StardewModdingAPI/Constants.cs | 3 +++ src/StardewModdingAPI/Program.cs | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs index e5752dfd..48304de5 100644 --- a/src/StardewModdingAPI/Constants.cs +++ b/src/StardewModdingAPI/Constants.cs @@ -25,6 +25,9 @@ namespace StardewModdingAPI /// SMAPI's current semantic version. public static readonly Version Version = new Version(1, 0, 0, $"alpha-{DateTime.UtcNow.ToString("yyyyMMddHHmm")}"); + /// The minimum supported version of Stardew Valley. + public const string MinimumGameVersion = "1.1"; + /// The GitHub repository to check for updates. public const string GitHubRepository = "cjsu/SMAPI"; diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 01cb3ac5..8c38a88b 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -69,12 +69,19 @@ namespace StardewModdingAPI try { Log.SyncColour($"Launching SMAPI {Constants.Version} with Stardew Valley {Game1.version} on {Environment.OSVersion}", ConsoleColor.DarkGray); // make sure this is the first line, to simplify troubleshooting instructions - Log.Debug("Initialising..."); - // set window title - Console.Title = Constants.ConsoleTitle; + // verify version + if (String.Compare(Game1.version, Constants.MinimumGameVersion, StringComparison.InvariantCultureIgnoreCase) < 0) + { + Log.Error($"Oops! You're running Stardew Valley {Game1.version}, but the oldest supported version is {Constants.MinimumGameVersion}. Please update your game before using SMAPI. If you're on the Steam beta channel, note that the beta channel may not receive the latest updates."); + Log.Debug("Shutting down. Press any key to continue..."); + Console.ReadKey(); + return; + } - // verify paths + // initialise + Log.Debug("Initialising..."); + Console.Title = Constants.ConsoleTitle; Program.VerifyPath(Program.ModPath); Program.VerifyPath(Constants.LogDir); if (!File.Exists(Program.GameExecutablePath)) -- cgit