diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-12-05 00:51:24 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2021-12-05 00:51:24 -0500 |
commit | 98d01d522d488192b5d5da50d70752a8c0739a94 (patch) | |
tree | f23154fc08394d66171a399b52142dc4d770b9df /src/SMAPI.Installer/InteractiveInstaller.cs | |
parent | cb9d6ae5ad9252c2a36174856b28f12344d026f3 (diff) | |
download | SMAPI-98d01d522d488192b5d5da50d70752a8c0739a94.tar.gz SMAPI-98d01d522d488192b5d5da50d70752a8c0739a94.tar.bz2 SMAPI-98d01d522d488192b5d5da50d70752a8c0739a94.zip |
improve error when installer is pointed at a compatibility-branch game folder
Diffstat (limited to 'src/SMAPI.Installer/InteractiveInstaller.cs')
-rw-r--r-- | src/SMAPI.Installer/InteractiveInstaller.cs | 65 |
1 files changed, 48 insertions, 17 deletions
diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index 424fe42b..6694c257 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -10,6 +10,7 @@ using StardewModdingAPI.Installer.Framework; using StardewModdingAPI.Internal.ConsoleWriting; using StardewModdingAPI.Toolkit; using StardewModdingAPI.Toolkit.Framework; +using StardewModdingAPI.Toolkit.Framework.GameScanning; using StardewModdingAPI.Toolkit.Framework.ModScanning; using StardewModdingAPI.Toolkit.Utilities; @@ -633,18 +634,39 @@ namespace StardewModdingApi.Installer // use specified path if (specifiedPath != null) { + string errorPrefix = $"You specified --game-path \"{specifiedPath}\", but"; + var dir = new DirectoryInfo(specifiedPath); if (!dir.Exists) { - this.PrintError($"You specified --game-path \"{specifiedPath}\", but that folder doesn't exist."); + this.PrintError($"{errorPrefix} that folder doesn't exist."); return null; } - if (!context.LooksLikeGameFolder(dir)) + + switch (context.GetGameFolderType(dir)) { - this.PrintError($"You specified --game-path \"{specifiedPath}\", but that folder doesn't contain the Stardew Valley executable."); - return null; + case GameFolderType.Valid: + return dir; + + case GameFolderType.Legacy154OrEarlier: + this.PrintWarning($"{errorPrefix} that directory seems to have Stardew Valley 1.5.4 or earlier."); + this.PrintWarning("Please update your game to the latest version to use SMAPI."); + return null; + + case GameFolderType.LegacyCompatibilityBranch: + this.PrintWarning($"{errorPrefix} that directory seems to have the Stardew Valley legacy 'compatibility' branch."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the full main version of the game."); + this.PrintWarning("Please update your game to the main branch to use SMAPI."); + return null; + + case GameFolderType.NoGameFound: + this.PrintWarning($"{errorPrefix} that directory doesn't contain a Stardew Valley executable."); + return null; + + default: + this.PrintWarning($"{errorPrefix} that directory doesn't seem to contain a valid game install."); + return null; } - return dir; } // let user choose detected path @@ -702,23 +724,32 @@ namespace StardewModdingApi.Installer this.PrintWarning("That directory doesn't seem to exist."); continue; } - if (!context.LooksLikeGameFolder(directory)) + + switch (context.GetGameFolderType(directory)) { - if (context.LooksLikeStardewValley154(directory)) - { + case GameFolderType.Valid: + this.PrintInfo(" OK!"); + return directory; + + case GameFolderType.Legacy154OrEarlier: this.PrintWarning("That directory seems to have Stardew Valley 1.5.4 or earlier."); this.PrintWarning("Please update your game to the latest version to use SMAPI."); - } - else - { + continue; + + case GameFolderType.LegacyCompatibilityBranch: + this.PrintWarning("That directory seems to have the Stardew Valley legacy 'compatibility' branch."); + this.PrintWarning("Unfortunately SMAPI is only compatible with the full main version of the game."); + this.PrintWarning("Please update your game to the main branch to use SMAPI."); + continue; + + case GameFolderType.NoGameFound: this.PrintWarning("That directory doesn't contain a Stardew Valley executable."); - } - continue; - } + continue; - // looks OK - this.PrintInfo(" OK!"); - return directory; + default: + this.PrintWarning("That directory doesn't seem to contain a valid game install."); + continue; + } } } |