summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-10-20 14:43:09 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-10-20 14:43:09 -0400
commite09499f628e6fb019ea856b197111f4a5bf3adf8 (patch)
tree981c7738013761ca62ada13c59ba1e25b17aca8a /src/SMAPI
parent896f98f2604f508cd94f2fcb0aa34cd914a042b5 (diff)
downloadSMAPI-e09499f628e6fb019ea856b197111f4a5bf3adf8.tar.gz
SMAPI-e09499f628e6fb019ea856b197111f4a5bf3adf8.tar.bz2
SMAPI-e09499f628e6fb019ea856b197111f4a5bf3adf8.zip
recommend compatible SMAPI version in game version check error
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Constants.cs20
-rw-r--r--src/SMAPI/Framework/SCore.cs14
-rw-r--r--src/SMAPI/Program.cs18
3 files changed, 33 insertions, 19 deletions
diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs
index 1a20ac68..83b17401 100644
--- a/src/SMAPI/Constants.cs
+++ b/src/SMAPI/Constants.cs
@@ -107,6 +107,26 @@ namespace StardewModdingAPI
/*********
** Internal methods
*********/
+ /// <summary>Get the SMAPI version to recommend for an older game version, if any.</summary>
+ /// <param name="version">The game version to search.</param>
+ /// <returns>Returns the compatible SMAPI version, or <c>null</c> if none was found.</returns>
+ internal static ISemanticVersion GetCompatibleApiVersion(ISemanticVersion version)
+ {
+ switch (version.ToString())
+ {
+ case "1.3.28":
+ return new SemanticVersion(2, 7, 0);
+
+ case "1.2.30":
+ case "1.2.31":
+ case "1.2.32":
+ case "1.2.33":
+ return new SemanticVersion(2, 5, 5);
+ }
+
+ return null;
+ }
+
/// <summary>Get metadata for mapping assemblies to the current platform.</summary>
/// <param name="targetPlatform">The target game platform.</param>
internal static PlatformAssemblyMap GetAssemblyMap(Platform targetPlatform)
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index 47370afd..6c897382 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -159,20 +159,6 @@ namespace StardewModdingAPI.Framework
}
#endif
- // validate game version
- if (Constants.GameVersion.IsOlderThan(Constants.MinimumGameVersion))
- {
- this.Monitor.Log($"Oops! You're running Stardew Valley {Constants.GameVersion}, but the oldest supported version is {Constants.MinimumGameVersion}. Please update your game before using SMAPI.", LogLevel.Error);
- this.PressAnyKeyToExit();
- return;
- }
- if (Constants.MaximumGameVersion != null && Constants.GameVersion.IsNewerThan(Constants.MaximumGameVersion))
- {
- this.Monitor.Log($"Oops! You're running Stardew Valley {Constants.GameVersion}, but this version of SMAPI is only compatible up to Stardew Valley {Constants.MaximumGameVersion}. Please check for a newer version of SMAPI: https://smapi.io.", LogLevel.Error);
- this.PressAnyKeyToExit();
- return;
- }
-
// apply game patches
new GamePatcher(this.Monitor).Apply(
new DialoguePatch(this.MonitorForGame, this.Reflection)
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index c6f39e3f..b46ecff4 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -83,15 +83,23 @@ namespace StardewModdingAPI
)
+ "See the readme.txt file for details."
);
+ return;
}
- // Stardew Valley 1.2 types not present
- if (Type.GetType($"StardewValley.LocalizedContentManager+LanguageCode, {gameAssemblyName}", throwOnError: false) == null)
+ // validate game version
+ if (Constants.GameVersion.IsOlderThan(Constants.MinimumGameVersion))
{
- PrintErrorAndExit(Constants.GameVersion.IsOlderThan(Constants.MinimumGameVersion)
- ? $"Oops! You're running Stardew Valley {Constants.GameVersion}, but the oldest supported version is {Constants.MinimumGameVersion}. Please update your game before using SMAPI."
- : "Oops! SMAPI doesn't seem to be compatible with your game. Make sure you're running the latest version of Stardew Valley and SMAPI."
+ ISemanticVersion suggestedApiVersion = Constants.GetCompatibleApiVersion(Constants.GameVersion);
+ PrintErrorAndExit(suggestedApiVersion != null
+ ? $"Oops! You're running Stardew Valley {Constants.GameVersion}, but the oldest supported version is {Constants.MinimumGameVersion}. You can install SMAPI {suggestedApiVersion} instead to fix this error, or update your game to the latest version."
+ : $"Oops! You're running Stardew Valley {Constants.GameVersion}, but the oldest supported version is {Constants.MinimumGameVersion}. Please update your game before using SMAPI."
);
+ return;
+ }
+ if (Constants.MaximumGameVersion != null && Constants.GameVersion.IsNewerThan(Constants.MaximumGameVersion))
+ {
+ PrintErrorAndExit($"Oops! You're running Stardew Valley {Constants.GameVersion}, but this version of SMAPI is only compatible up to Stardew Valley {Constants.MaximumGameVersion}. Please check for a newer version of SMAPI: https://smapi.io.");
+ return;
}
}