add initial support for 64-bit Windows hack (#767)
This commit is contained in:
parent
62c1f11109
commit
3fa0433c98
|
@ -1,7 +1,4 @@
|
|||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<Import Project="find-game-folder.targets" />
|
||||
|
||||
<!--set properties -->
|
||||
<PropertyGroup>
|
||||
<Version>3.9.5</Version>
|
||||
|
@ -9,9 +6,15 @@
|
|||
|
||||
<LangVersion>latest</LangVersion>
|
||||
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
|
||||
<DefineConstants Condition="$(OS) == 'Windows_NT'">$(DefineConstants);SMAPI_FOR_WINDOWS;SMAPI_FOR_XNA</DefineConstants>
|
||||
|
||||
<!--<DefineConstants>$(DefineConstants);SMAPI_FOR_WINDOWS_64BIT_HACK</DefineConstants>-->
|
||||
<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>
|
||||
|
||||
<!--find game folder-->
|
||||
<Import Project="find-game-folder.targets" />
|
||||
|
||||
<!-- if game path is invalid, show one user-friendly error instead of a slew of reference errors -->
|
||||
<Target Name="ValidateInstallPath" AfterTargets="BeforeBuild">
|
||||
<Error Condition="!Exists('$(GamePath)')" Text="Failed to find the game install path automatically. You can specify where to find it; see https://smapi.io/package/custom-game-path." />
|
||||
|
@ -76,5 +79,4 @@
|
|||
|
||||
<!-- Somehow this makes Visual Studio for Mac recognise the previous section. Nobody knows why. -->
|
||||
<PropertyGroup Condition="'$(RunConfiguration)' == 'Default'" />
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -57,7 +57,8 @@ SMAPI uses a small number of conditional compilation constants, which you can se
|
|||
flag | purpose
|
||||
---- | -------
|
||||
`SMAPI_FOR_WINDOWS` | Whether SMAPI is being compiled for Windows; if not set, the code assumes Linux/MacOS. Set automatically in `common.targets`.
|
||||
`SMAPI_FOR_XNA` | Whether SMAPI is being compiled for XNA Framework; if not set, the code assumes MonoGame. Set automatically in `common.targets` with the same value as `SMAPI_FOR_WINDOWS`.
|
||||
`SMAPI_FOR_WINDOWS_64BIT_HACK` | Whether SMAPI is being [compiled for Windows with a 64-bit Linux version of the game](https://github.com/Pathoschild/SMAPI/issues/767). This is highly specialized and shouldn't be used in most cases. False by default.
|
||||
`SMAPI_FOR_XNA` | Whether SMAPI is being compiled for XNA Framework; if not set, the code assumes MonoGame. Set automatically in `common.targets` with the same value as `SMAPI_FOR_WINDOWS` (unless `SMAPI_FOR_WINDOWS_64BIT_HACK` is set).
|
||||
`HARMONY_2` | Whether to enable experimental Harmony 2.0 support and rewrite existing Harmony 1._x_ mods for compatibility. Note that you need to replace `build/0Harmony.dll` with a Harmony 2.0 build (or switch to a package reference) to use this flag.
|
||||
|
||||
## For SMAPI developers
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
<!-- Windows only -->
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" />
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" Condition="!$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Game framework -->
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
<!-- Windows only -->
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" />
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" Condition="!$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Game framework -->
|
||||
|
|
|
@ -38,6 +38,14 @@ namespace StardewModdingAPI
|
|||
/// <summary>The target game platform.</summary>
|
||||
internal static GamePlatform Platform { get; } = (GamePlatform)Enum.Parse(typeof(GamePlatform), LowLevelEnvironmentUtility.DetectPlatform());
|
||||
|
||||
/// <summary>Whether SMAPI is being compiled for Windows with a 64-bit Linux version of the game. This is highly specialized and shouldn't be used in most cases.</summary>
|
||||
internal static bool IsWindows64BitHack { get; } =
|
||||
#if SMAPI_FOR_WINDOWS_64BIT_HACK
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
|
||||
/// <summary>The game framework running the game.</summary>
|
||||
internal static GameFramework GameFramework { get; } =
|
||||
#if SMAPI_FOR_XNA
|
||||
|
@ -47,7 +55,7 @@ namespace StardewModdingAPI
|
|||
#endif
|
||||
|
||||
/// <summary>The game's assembly name.</summary>
|
||||
internal static string GameAssemblyName => EarlyConstants.Platform == GamePlatform.Windows ? "Stardew Valley" : "StardewValley";
|
||||
internal static string GameAssemblyName => EarlyConstants.Platform == GamePlatform.Windows && !EarlyConstants.IsWindows64BitHack ? "Stardew Valley" : "StardewValley";
|
||||
|
||||
/// <summary>The <see cref="Context.ScreenId"/> value which should appear in the SMAPI log, if any.</summary>
|
||||
internal static int? LogScreenId { get; set; }
|
||||
|
@ -231,33 +239,27 @@ namespace StardewModdingAPI
|
|||
targetAssemblies.Add(typeof(StardewModdingAPI.IManifest).Assembly);
|
||||
|
||||
// get changes for platform
|
||||
switch (targetPlatform)
|
||||
if (Constants.Platform != Platform.Windows || EarlyConstants.IsWindows64BitHack)
|
||||
{
|
||||
case Platform.Linux:
|
||||
case Platform.Mac:
|
||||
removeAssemblyReferences.AddRange(new[]
|
||||
{
|
||||
"Netcode",
|
||||
"Stardew Valley"
|
||||
});
|
||||
targetAssemblies.Add(
|
||||
typeof(StardewValley.Game1).Assembly // note: includes Netcode types on Linux/Mac
|
||||
);
|
||||
break;
|
||||
|
||||
case Platform.Windows:
|
||||
removeAssemblyReferences.Add(
|
||||
"StardewValley"
|
||||
);
|
||||
targetAssemblies.AddRange(new[]
|
||||
{
|
||||
typeof(Netcode.NetBool).Assembly,
|
||||
typeof(StardewValley.Game1).Assembly
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new InvalidOperationException($"Unknown target platform '{targetPlatform}'.");
|
||||
removeAssemblyReferences.AddRange(new[]
|
||||
{
|
||||
"Netcode",
|
||||
"Stardew Valley"
|
||||
});
|
||||
targetAssemblies.Add(
|
||||
typeof(StardewValley.Game1).Assembly // note: includes Netcode types on Linux/Mac
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
removeAssemblyReferences.Add(
|
||||
"StardewValley"
|
||||
);
|
||||
targetAssemblies.AddRange(new[]
|
||||
{
|
||||
typeof(Netcode.NetBool).Assembly,
|
||||
typeof(StardewValley.Game1).Assembly
|
||||
});
|
||||
}
|
||||
|
||||
// get changes for game framework
|
||||
|
|
|
@ -287,6 +287,9 @@ namespace StardewModdingAPI.Framework.Logging
|
|||
string platformLabel = EnvironmentUtility.GetFriendlyPlatformName(Constants.Platform);
|
||||
if ((Constants.GameFramework == GameFramework.Xna) != (Constants.Platform == Platform.Windows))
|
||||
platformLabel += $" with {Constants.GameFramework}";
|
||||
#if SMAPI_FOR_WINDOWS_64BIT_HACK
|
||||
platformLabel += " 64-bit hack";
|
||||
#endif
|
||||
|
||||
// init logging
|
||||
this.Monitor.Log($"SMAPI {Constants.ApiVersion} with Stardew Valley {Constants.GameVersion} on {platformLabel}", LogLevel.Info);
|
||||
|
|
|
@ -419,7 +419,7 @@ namespace StardewModdingAPI.Framework
|
|||
Game1.mapDisplayDevice = new SDisplayDevice(Game1.content, Game1.game1.GraphicsDevice);
|
||||
|
||||
// log GPU info
|
||||
#if SMAPI_FOR_WINDOWS
|
||||
#if SMAPI_FOR_WINDOWS && !SMAPI_FOR_WINDOWS_64BIT_HACK
|
||||
this.Monitor.Log($"Running on GPU: {Game1.game1.GraphicsDevice?.Adapter?.Description ?? "<unknown>"}");
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
|
||||
<PropertyGroup Condition="$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LargeAddressAware" Version="1.0.5" />
|
||||
<PackageReference Include="Mono.Cecil" Version="0.11.3" />
|
||||
|
@ -34,7 +38,7 @@
|
|||
|
||||
<!-- Windows only -->
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" />
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" Condition="!$(DefineConstants.Contains(SMAPI_FOR_WINDOWS_64BIT_HACK))" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
Loading…
Reference in New Issue