add 64-bit support to the SMAPI installer (#767)
This commit is contained in:
parent
665c6806d3
commit
47a806533b
|
@ -1,13 +1,16 @@
|
|||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<!--set properties -->
|
||||
<PropertyGroup>
|
||||
<!--set general build properties -->
|
||||
<Version>3.9.5</Version>
|
||||
<Product>SMAPI</Product>
|
||||
|
||||
<LangVersion>latest</LangVersion>
|
||||
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
|
||||
|
||||
<!--<DefineConstants>$(DefineConstants);SMAPI_FOR_WINDOWS_64BIT_HACK</DefineConstants>-->
|
||||
<!--uncomment for 64-bit Stardew Valley on Windows-->
|
||||
<!--<GamePath>D:\dev\SDV 64-bit\6125897</GamePath>
|
||||
<DefineConstants>$(DefineConstants);SMAPI_FOR_WINDOWS_64BIT_HACK</DefineConstants>-->
|
||||
|
||||
<!--set platform-->
|
||||
<DefineConstants Condition="$(OS) == 'Windows_NT'">$(DefineConstants);SMAPI_FOR_WINDOWS</DefineConstants>
|
||||
<DefineConstants Condition="$(OS) == 'Windows_NT' AND !$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))">$(DefineConstants);SMAPI_FOR_XNA</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
|
||||
## Upcoming release
|
||||
* For players:
|
||||
* Added support for unofficial 64-bit Stardew Valley, including automatic support in the SMAPI installer.
|
||||
* Added update checks for Stardew64Installer if it patched the game.
|
||||
* When many mods fail to load, root dependencies are now listed in their own group so it's easier to see which ones you should try updating first.
|
||||
* On macOS, the `StardewModdingAPI.bin.osx` file is no longer overwritten if it's identical to avoid resetting file permissions (thanks to 007wayne!).
|
||||
* Added update checks for Stardew64Installer if it patched the game.
|
||||
* Fixed error for non-English players after returning to title, reloading, and entering town with a completed movie theater.
|
||||
* Fixed `world_clear` console command not removing resource clumps outside the farm and secret woods.
|
||||
* Fixed inconsistent spelling/style for 'macOS'.
|
||||
* Internal changes to prepare for unofficial 64-bit.
|
||||
|
||||
* For modders:
|
||||
* Added asset propagation for `Data\Concessions`.
|
||||
|
|
|
@ -82,7 +82,9 @@ To prepare a crossplatform SMAPI release, you'll need to compile it on two platf
|
|||
[crossplatforming info](https://stardewvalleywiki.com/Modding:Modder_Guide/Test_and_Troubleshoot#Testing_on_all_platforms)
|
||||
on the wiki for the first-time setup.
|
||||
|
||||
1. Update the version numbers in `build/common.targets`, `Constants`, and the `manifest.json` for
|
||||
1. [Install a separate 64-bit version of Stardew Valley](https://github.com/Steviegt6/Stardew64Installer#readme)
|
||||
on Windows.
|
||||
2. Update the version numbers in `build/common.targets`, `Constants`, and the `manifest.json` for
|
||||
bundled mods. Make sure you use a [semantic version](https://semver.org). Recommended format:
|
||||
|
||||
build type | format | example
|
||||
|
@ -90,12 +92,15 @@ on the wiki for the first-time setup.
|
|||
dev build | `<version>-alpha.<date>` | `3.0.0-alpha.20171230`
|
||||
prerelease | `<version>-beta.<date>` | `3.0.0-beta.20171230`
|
||||
release | `<version>` | `3.0.0`
|
||||
|
||||
2. In Windows:
|
||||
3. In Windows:
|
||||
1. Rebuild the solution with the _release_ solution configuration.
|
||||
2. Copy `bin/SMAPI installer` and `bin/SMAPI installer for developers` to Linux/macOS.
|
||||
|
||||
3. In Linux/macOS:
|
||||
2. Back up the `bin/SMAPI installer` and `bin/SMAPI installer for developers` folders.
|
||||
3. Edit `common.targets` and uncomment the Stardew Valley 64-bit section at the top.
|
||||
4. Rebuild the solution again.
|
||||
5. Rename the compiled `StardewModdingAPI.exe` file to `StardewModdingAPI-x64.exe`, and copy it
|
||||
into the `windows-install.dat` files from step ii.
|
||||
6. Copy the folders from step ii to Linux/MacOS.
|
||||
4. In Linux/macOS:
|
||||
1. Rebuild the solution with the _release_ solution configuration.
|
||||
2. Add the `windows-install.*` files from Windows to the `bin/SMAPI installer` and
|
||||
`bin/SMAPI installer for developers` folders compiled on Linux.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue