only hook into WinForms on Windows for Mac compatibility (#126)

This commit is contained in:
Jesse Plamondon-Willard 2016-10-27 13:40:42 -04:00
parent 2ea2068486
commit f44eb6d66f
2 changed files with 11 additions and 1 deletions

View File

@ -5,7 +5,9 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
#if SMAPI_FOR_WINDOWS
using System.Windows.Forms; using System.Windows.Forms;
#endif
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI.Events; using StardewModdingAPI.Events;
@ -208,8 +210,10 @@ namespace StardewModdingAPI
public static void RunGame() public static void RunGame()
{ {
#if SMAPI_FOR_WINDOWS
Application.ThreadException += Log.Application_ThreadException; Application.ThreadException += Log.Application_ThreadException;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
#endif
AppDomain.CurrentDomain.UnhandledException += Log.CurrentDomain_UnhandledException; AppDomain.CurrentDomain.UnhandledException += Log.CurrentDomain_UnhandledException;
try try

View File

@ -92,6 +92,9 @@
</PropertyGroup> </PropertyGroup>
<Choose> <Choose>
<When Condition="$(OS) == 'Windows_NT'"> <When Condition="$(OS) == 'Windows_NT'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);SMAPI_FOR_WINDOWS</DefineConstants>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86"> <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>False</Private> <Private>False</Private>
@ -117,6 +120,9 @@
</ItemGroup> </ItemGroup>
</When> </When>
<Otherwise> <Otherwise>
<PropertyGroup>
<DefineConstants>$(DefineConstants);SMAPI_FOR_UNIX</DefineConstants>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="MonoGame.Framework"> <Reference Include="MonoGame.Framework">
<HintPath>$(GamePath)\MonoGame.Framework.dll</HintPath> <HintPath>$(GamePath)\MonoGame.Framework.dll</HintPath>
@ -142,7 +148,7 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" Condition="$(OS) == 'Windows_NT'" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />