summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Installer/Framework/InstallerPaths.cs11
-rw-r--r--src/SMAPI.Installer/InteractiveInstaller.cs53
-rw-r--r--src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs11
3 files changed, 62 insertions, 13 deletions
diff --git a/src/SMAPI.Installer/Framework/InstallerPaths.cs b/src/SMAPI.Installer/Framework/InstallerPaths.cs
index 2cabf88b..6ba5fa5f 100644
--- a/src/SMAPI.Installer/Framework/InstallerPaths.cs
+++ b/src/SMAPI.Installer/Framework/InstallerPaths.cs
@@ -44,8 +44,8 @@ namespace StardewModdingAPI.Installer.Framework
/// <summary>The full path to the user's config overrides file.</summary>
public string ApiUserConfigPath { get; }
- /// <summary>The full path to the installed SMAPI executable file.</summary>
- public string ExecutablePath { get; }
+ /// <summary>The full path to the installed game executable file.</summary>
+ public string ExecutablePath { get; private set; }
/// <summary>The full path to the vanilla game launcher on Linux/macOS.</summary>
public string UnixLauncherPath { get; }
@@ -79,5 +79,12 @@ namespace StardewModdingAPI.Installer.Framework
this.ApiConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.json");
this.ApiUserConfigPath = Path.Combine(gameDir.FullName, "smapi-internal", "config.user.json");
}
+
+ /// <summary>Override the filename for the <see cref="ExecutablePath"/>.</summary>
+ /// <param name="filename">the file name.</param>
+ public void SetExecutableFileName(string filename)
+ {
+ this.ExecutablePath = Path.Combine(this.GamePath, filename);
+ }
}
}
diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs
index 376949da..6bfc6874 100644
--- a/src/SMAPI.Installer/InteractiveInstaller.cs
+++ b/src/SMAPI.Installer/InteractiveInstaller.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -10,7 +11,6 @@ using StardewModdingAPI.Internal.ConsoleWriting;
using StardewModdingAPI.Toolkit;
using StardewModdingAPI.Toolkit.Framework.ModScanning;
using StardewModdingAPI.Toolkit.Utilities;
-using System.Diagnostics;
namespace StardewModdingApi.Installer
{
@@ -275,7 +275,20 @@ namespace StardewModdingApi.Installer
/*********
- ** Step 4: validate assumptions
+ ** Step 4: detect 64-bit Stardew Valley
+ *********/
+ // detect 64-bit mode
+ bool isWindows64Bit = false;
+ if (context.Platform == Platform.Windows)
+ {
+ FileInfo linuxExecutable = new FileInfo(Path.Combine(paths.GamePath, "StardewValley.exe"));
+ isWindows64Bit = linuxExecutable.Exists && this.Is64Bit(linuxExecutable.FullName);
+ if (isWindows64Bit)
+ paths.SetExecutableFileName(linuxExecutable.Name);
+ }
+
+ /*********
+ ** Step 5: validate assumptions
*********/
// executable exists
if (!File.Exists(paths.ExecutablePath))
@@ -298,7 +311,7 @@ namespace StardewModdingApi.Installer
/*********
- ** Step 5: ask what to do
+ ** Step 6: ask what to do
*********/
ScriptAction action;
{
@@ -306,7 +319,7 @@ namespace StardewModdingApi.Installer
** print header
****/
this.PrintInfo("Hi there! I'll help you install or remove SMAPI. Just one question first.");
- this.PrintDebug($"Game path: {paths.GamePath}");
+ this.PrintDebug($"Game path: {paths.GamePath}{(context.IsWindows ? $" [{(isWindows64Bit ? "64-bit" : "32-bit")}]" : "")}");
this.PrintDebug($"Color scheme: {this.GetDisplayText(scheme)}");
this.PrintDebug("----------------------------------------------------------------------------");
Console.WriteLine();
@@ -344,14 +357,14 @@ namespace StardewModdingApi.Installer
/*********
- ** Step 6: apply
+ ** Step 7: apply
*********/
{
/****
** print header
****/
this.PrintInfo($"That's all I need! I'll {action.ToString().ToLower()} SMAPI now.");
- this.PrintDebug($"Game path: {paths.GamePath}");
+ this.PrintDebug($"Game path: {paths.GamePath}{(context.IsWindows ? $" [{(isWindows64Bit ? "64-bit" : "32-bit")}]" : "")}");
this.PrintDebug($"Color scheme: {this.GetDisplayText(scheme)}");
this.PrintDebug("----------------------------------------------------------------------------");
Console.WriteLine();
@@ -412,6 +425,27 @@ namespace StardewModdingApi.Installer
this.RecursiveCopy(sourceEntry, paths.GameDir);
}
+ if (isWindows64Bit)
+ {
+ this.PrintDebug("Making SMAPI 64-bit...");
+ FileInfo x64Executable = new FileInfo(Path.Combine(paths.BundleDir.FullName, "StardewModdingAPI-x64.exe"));
+ if (x64Executable.Exists)
+ {
+ string targetName = "StardewModdingAPI.exe";
+ this.InteractivelyDelete(Path.Combine(paths.GameDir.FullName, targetName));
+ this.InteractivelyDelete(Path.Combine(paths.GameDir.FullName, x64Executable.Name));
+
+ this.RecursiveCopy(x64Executable, paths.GameDir);
+ File.Move(Path.Combine(paths.GamePath, x64Executable.Name), Path.Combine(paths.GamePath, targetName));
+ }
+ else
+ {
+ this.PrintError($"Oops! Could not find the required '{x64Executable.Name}' installer file. SMAPI was unable to install correctly.");
+ Console.ReadLine();
+ return;
+ }
+ }
+
// replace mod launcher (if possible)
if (context.IsUnix)
{
@@ -535,6 +569,13 @@ namespace StardewModdingApi.Installer
/*********
** Private methods
*********/
+ /// <summary>Get whether an executable is 64-bit.</summary>
+ /// <param name="executablePath">The absolute path to the executable file.</param>
+ private bool Is64Bit(string executablePath)
+ {
+ return AssemblyName.GetAssemblyName(executablePath).ProcessorArchitecture != ProcessorArchitecture.X86;
+ }
+
/// <summary>Get the display text for a color scheme.</summary>
/// <param name="scheme">The color scheme.</param>
private string GetDisplayText(MonitorColorScheme scheme)
diff --git a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
index d18a2204..c90fc1d3 100644
--- a/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
+++ b/src/SMAPI.Toolkit/Framework/GameScanning/GameScanner.cs
@@ -20,9 +20,6 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning
/// <summary>The current OS.</summary>
private readonly Platform Platform;
- /// <summary>The name of the Stardew Valley executable.</summary>
- private readonly string ExecutableName;
-
/*********
** Public methods
@@ -31,7 +28,6 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning
public GameScanner()
{
this.Platform = EnvironmentUtility.DetectPlatform();
- this.ExecutableName = EnvironmentUtility.GetExecutableName(this.Platform);
}
/// <summary>Find all valid Stardew Valley install folders.</summary>
@@ -58,7 +54,12 @@ namespace StardewModdingAPI.Toolkit.Framework.GameScanning
/// <param name="dir">The folder to check.</param>
public bool LooksLikeGameFolder(DirectoryInfo dir)
{
- return dir.Exists && dir.EnumerateFiles(this.ExecutableName).Any();
+ return
+ dir.Exists
+ && (
+ dir.EnumerateFiles("StardewValley.exe").Any()
+ || dir.EnumerateFiles("Stardew Valley.exe").Any()
+ );
}