split compile flag into separate Windows + XNA flags (#767)
This commit is contained in:
parent
fdfb060795
commit
73321eceb9
|
@ -9,7 +9,7 @@
|
|||
|
||||
<LangVersion>latest</LangVersion>
|
||||
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
|
||||
<DefineConstants Condition="$(OS) == 'Windows_NT'">$(DefineConstants);SMAPI_FOR_WINDOWS</DefineConstants>
|
||||
<DefineConstants Condition="$(OS) == 'Windows_NT'">$(DefineConstants);SMAPI_FOR_WINDOWS;SMAPI_FOR_XNA</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- if game path is invalid, show one user-friendly error instead of a slew of reference errors -->
|
||||
|
|
|
@ -56,7 +56,8 @@ SMAPI uses a small number of conditional compilation constants, which you can se
|
|||
|
||||
flag | purpose
|
||||
---- | -------
|
||||
`SMAPI_FOR_WINDOWS` | Whether SMAPI is being compiled on Windows for players on Windows. Set automatically in `crossplatform.targets`.
|
||||
`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`.
|
||||
`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
|
||||
|
|
|
@ -47,19 +47,27 @@
|
|||
<Reference Include="0Harmony" Condition="'$(EnableHarmony)' == 'true'" HintPath="$(GamePath)\smapi-internal\0Harmony.dll" Private="$(CopyModReferencesToBuildOutput)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Windows -->
|
||||
<!-- Windows only -->
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="$(CopyModReferencesToBuildOutput)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Game framework -->
|
||||
<Choose>
|
||||
<When Condition="$(DefineConstants.Contains(SMAPI_FOR_XNA))">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="$(CopyModReferencesToBuildOutput)" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="$(CopyModReferencesToBuildOutput)" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="$(CopyModReferencesToBuildOutput)" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="$(CopyModReferencesToBuildOutput)" />
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="$(CopyModReferencesToBuildOutput)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Linux/Mac -->
|
||||
<ItemGroup Condition="'$(OS)' != 'Windows_NT'">
|
||||
</When>
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework" HintPath="$(GamePath)\MonoGame.Framework.dll" Private="$(CopyModReferencesToBuildOutput)" />
|
||||
</ItemGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
||||
|
||||
<!--*********************************************
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SMAPI\SMAPI.csproj" Private="False" />
|
||||
</ItemGroup>
|
||||
|
@ -16,19 +18,21 @@
|
|||
<Reference Include="StardewValley.GameData" HintPath="$(GamePath)\StardewValley.GameData.dll" Private="False" />
|
||||
</ItemGroup>
|
||||
|
||||
<Choose>
|
||||
<!-- Windows -->
|
||||
<When Condition="$(OS) == 'Windows_NT'">
|
||||
<ItemGroup>
|
||||
<!-- Windows only -->
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Game framework -->
|
||||
<Choose>
|
||||
<When Condition="$(DefineConstants.Contains(SMAPI_FOR_XNA))">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
|
||||
<!-- Linux/Mac -->
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework" HintPath="$(GamePath)\MonoGame.Framework.dll" Private="False" />
|
||||
|
@ -41,5 +45,4 @@
|
|||
</ItemGroup>
|
||||
|
||||
<Import Project="..\SMAPI.Internal\SMAPI.Internal.projitems" Label="Shared" />
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
|
|||
#endif
|
||||
{
|
||||
harmony.Patch(
|
||||
#if SMAPI_FOR_WINDOWS
|
||||
#if SMAPI_FOR_XNA
|
||||
original: AccessTools.Method(typeof(SpriteBatch), "InternalDraw"),
|
||||
#else
|
||||
original: AccessTools.Method(typeof(SpriteBatch), "CheckValid", new[] { typeof(Texture2D) }),
|
||||
|
@ -40,7 +40,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
|
|||
/*********
|
||||
** Private methods
|
||||
*********/
|
||||
#if SMAPI_FOR_WINDOWS
|
||||
#if SMAPI_FOR_XNA
|
||||
/// <summary>The method to call instead of <see cref="SpriteBatch.InternalDraw"/>.</summary>
|
||||
/// <param name="texture">The texture to validate.</param>
|
||||
#else
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SMAPI\SMAPI.csproj" Private="False" />
|
||||
<Reference Include="..\..\build\0Harmony.dll" Private="False" />
|
||||
|
@ -16,19 +18,21 @@
|
|||
<Reference Include="$(GameExecutableName)" HintPath="$(GamePath)\$(GameExecutableName).exe" Private="False" />
|
||||
</ItemGroup>
|
||||
|
||||
<Choose>
|
||||
<!-- Windows -->
|
||||
<When Condition="$(OS) == 'Windows_NT'">
|
||||
<ItemGroup>
|
||||
<!-- Windows only -->
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Game framework -->
|
||||
<Choose>
|
||||
<When Condition="$(DefineConstants.Contains(SMAPI_FOR_XNA))">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
|
||||
<!-- Linux/Mac -->
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework" HintPath="$(GamePath)\MonoGame.Framework.dll" Private="False" />
|
||||
|
@ -42,5 +46,4 @@
|
|||
</ItemGroup>
|
||||
|
||||
<Import Project="..\SMAPI.Internal\SMAPI.Internal.projitems" Label="Shared" />
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SMAPI\SMAPI.csproj" Private="False" />
|
||||
</ItemGroup>
|
||||
|
@ -20,5 +22,4 @@
|
|||
</ItemGroup>
|
||||
|
||||
<Import Project="..\SMAPI.Internal\SMAPI.Internal.projitems" Label="Shared" />
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SMAPI.Toolkit.CoreInterfaces\SMAPI.Toolkit.CoreInterfaces.csproj" />
|
||||
<ProjectReference Include="..\SMAPI.Toolkit\SMAPI.Toolkit.csproj" />
|
||||
|
@ -30,6 +32,4 @@
|
|||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
<PlatformTarget Condition="'$(TargetFramework)' == 'net4.5'">x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.28" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="aws-beanstalk-tools-defaults.json" />
|
||||
</ItemGroup>
|
||||
|
@ -44,6 +46,4 @@
|
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
</Project>
|
||||
|
|
|
@ -181,7 +181,7 @@ namespace StardewModdingAPI.Framework
|
|||
{
|
||||
// get field name
|
||||
const string fieldName =
|
||||
#if SMAPI_FOR_WINDOWS
|
||||
#if SMAPI_FOR_XNA
|
||||
"inBeginEndPair";
|
||||
#else
|
||||
"_beginCalled";
|
||||
|
|
|
@ -12,7 +12,7 @@ using System.Text;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
#if SMAPI_FOR_WINDOWS
|
||||
#if SMAPI_FOR_XNA
|
||||
using System.Windows.Forms;
|
||||
#endif
|
||||
using Newtonsoft.Json;
|
||||
|
@ -217,7 +217,7 @@ namespace StardewModdingAPI.Framework
|
|||
this.Toolkit.JsonHelper.JsonSettings.Converters.Add(converter);
|
||||
|
||||
// add error handlers
|
||||
#if SMAPI_FOR_WINDOWS
|
||||
#if SMAPI_FOR_XNA
|
||||
Application.ThreadException += (sender, e) => this.Monitor.Log($"Critical thread exception: {e.Exception.GetLogSummary()}", LogLevel.Error);
|
||||
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
||||
#endif
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LargeAddressAware" Version="1.0.5" />
|
||||
<PackageReference Include="Mono.Cecil" Version="0.11.3" />
|
||||
|
@ -30,20 +32,22 @@
|
|||
<Reference Include="xTile" HintPath="$(GamePath)\xTile.dll" Private="False" />
|
||||
</ItemGroup>
|
||||
|
||||
<Choose>
|
||||
<!-- Windows -->
|
||||
<When Condition="$(OS) == 'Windows_NT'">
|
||||
<ItemGroup>
|
||||
<!-- Windows only -->
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
|
||||
<Reference Include="Netcode" HintPath="$(GamePath)\Netcode.dll" Private="False" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Game framework -->
|
||||
<Choose>
|
||||
<When Condition="$(DefineConstants.Contains(SMAPI_FOR_XNA))">
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" Private="False" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
|
||||
<!-- Linux/Mac -->
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework" HintPath="$(GamePath)\MonoGame.Framework.dll" Private="False" />
|
||||
|
@ -67,5 +71,4 @@
|
|||
</ItemGroup>
|
||||
|
||||
<Import Project="..\SMAPI.Internal\SMAPI.Internal.projitems" Label="Shared" />
|
||||
<Import Project="..\..\build\common.targets" />
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue