summaryrefslogtreecommitdiff
path: root/src/SMAPI.Toolkit
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-12-04 23:47:27 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-12-04 23:47:27 -0500
commitcb9d6ae5ad9252c2a36174856b28f12344d026f3 (patch)
tree3e5b559713bac52099349fa85b2253c4cc29a282 /src/SMAPI.Toolkit
parent0f37c0f92da5fb6fcf9e4317a1b4c8d3f4df8010 (diff)
downloadSMAPI-cb9d6ae5ad9252c2a36174856b28f12344d026f3.tar.gz
SMAPI-cb9d6ae5ad9252c2a36174856b28f12344d026f3.tar.bz2
SMAPI-cb9d6ae5ad9252c2a36174856b28f12344d026f3.zip
improve error when installer is pointed at a SDV 1.5.4 folder
Diffstat (limited to 'src/SMAPI.Toolkit')
-rw-r--r--src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
index 7553c07f..c7ebe6e0 100644
--- a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
+++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Xml.Linq;
using System.Xml.XPath;
using StardewModdingAPI.Toolkit.Utilities;
+using System.Reflection;
#if SMAPI_FOR_WINDOWS
using Microsoft.Win32;
#endif
@@ -59,6 +60,32 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning
&& dir.EnumerateFiles("Stardew Valley.dll").Any();
}
+ /// <summary>Get whether a folder seems to contain Stardew Valley 1.5.4 or earlier.</summary>
+ /// <param name="dir">The folder to check.</param>
+ public bool LooksLikeStardewValley154(DirectoryInfo dir)
+ {
+ if (!dir.Exists || this.LooksLikeGameFolder(dir))
+ return false;
+
+ // get legacy executable
+ FileInfo executable = new FileInfo(Path.Combine(dir.FullName, "Stardew Valley.exe"));
+ if (!executable.Exists)
+ executable = new FileInfo(Path.Combine(dir.FullName, "StardewValley.exe"));
+ if (!executable.Exists)
+ return false;
+
+ // check if it's a standard .NET assembly
+ // This will fail in Stardew Valley 1.5.5+, where it's a binary wrapper around Stardew Valley.dll.
+ try
+ {
+ Version version = AssemblyName.GetAssemblyName(executable.FullName).Version;
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
/*********
** Private methods