From 4cfe80f33add3bb8e59e5088ae14315c6df5f37a Mon Sep 17 00:00:00 2001
From: Magnus Norddahl <dpjudas@users.noreply.github.com>
Date: Thu, 29 Aug 2019 21:04:50 +0200
Subject: [PATCH] GZDB can now boot using mono

---
 Source/Core/BuilderMono.csproj | 16 ++++++++--------
 Source/Core/General/General.cs | 13 +++++++++++++
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/Source/Core/BuilderMono.csproj b/Source/Core/BuilderMono.csproj
index 682d5cab2..5242e7121 100644
--- a/Source/Core/BuilderMono.csproj
+++ b/Source/Core/BuilderMono.csproj
@@ -27,7 +27,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
     <DebugSymbols>true</DebugSymbols>
     <OutputPath>..\..\Build\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL</DefineConstants>
+    <DefineConstants>TRACE;DEBUG;NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL NO_WIN32</DefineConstants>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <DebugType>full</DebugType>
     <PlatformTarget>x86</PlatformTarget>
@@ -48,7 +48,7 @@
     <ErrorReport>prompt</ErrorReport>
     <DocumentationFile>
     </DocumentationFile>
-    <DefineConstants>NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL</DefineConstants>
+    <DefineConstants>NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL NO_WIN32</DefineConstants>
     <WarningLevel>4</WarningLevel>
     <DebugSymbols>true</DebugSymbols>
     <NoWarn>1591</NoWarn>
@@ -57,7 +57,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug + Profiler|x86' ">
     <DebugSymbols>true</DebugSymbols>
     <OutputPath>..\..\Build\</OutputPath>
-    <DefineConstants>TRACE;DEBUG;PROFILE NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL</DefineConstants>
+    <DefineConstants>TRACE;DEBUG;PROFILE NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL NO_WIN32</DefineConstants>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <DocumentationFile>
     </DocumentationFile>
@@ -79,7 +79,7 @@
     <PlatformTarget>x86</PlatformTarget>
     <UseVSHostingProcess>false</UseVSHostingProcess>
     <ErrorReport>prompt</ErrorReport>
-    <DefineConstants>TRACE;PROFILE NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL</DefineConstants>
+    <DefineConstants>TRACE;PROFILE NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL NO_WIN32</DefineConstants>
     <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
@@ -89,7 +89,7 @@
     </DocumentationFile>
     <Prefer32Bit>false</Prefer32Bit>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-    <DefineConstants>TRACE;DEBUG;NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL</DefineConstants>
+    <DefineConstants>TRACE;DEBUG;NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL NO_WIN32</DefineConstants>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
     <PlatformTarget>x64</PlatformTarget>
@@ -97,14 +97,14 @@
     <Prefer32Bit>false</Prefer32Bit>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <Optimize>true</Optimize>
-    <DefineConstants>TRACE;NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL</DefineConstants>
+    <DefineConstants>TRACE;NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL NO_WIN32</DefineConstants>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug + Profiler|x64'">
     <PlatformTarget>x64</PlatformTarget>
     <OutputPath>..\..\Build\</OutputPath>
     <Prefer32Bit>false</Prefer32Bit>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-    <DefineConstants>TRACE;DEBUG;PROFILE NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL</DefineConstants>
+    <DefineConstants>TRACE;DEBUG;PROFILE NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL NO_WIN32</DefineConstants>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release + Profiler|x64'">
     <PlatformTarget>x64</PlatformTarget>
@@ -112,7 +112,7 @@
     <Prefer32Bit>false</Prefer32Bit>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <Optimize>true</Optimize>
-    <DefineConstants>PROFILE NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL</DefineConstants>
+    <DefineConstants>PROFILE NO_SCINTILLA NO_FORMS_DESIGN NO_DEVIL NO_WIN32</DefineConstants>
   </PropertyGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
diff --git a/Source/Core/General/General.cs b/Source/Core/General/General.cs
index 61cb36f5b..7493e3510 100755
--- a/Source/Core/General/General.cs
+++ b/Source/Core/General/General.cs
@@ -54,6 +54,14 @@ namespace CodeImp.DoomBuilder
 		private static extern void ilInit();
 #endif
 
+#if NO_WIN32
+
+	internal static bool LockWindowUpdate(IntPtr hwnd) { return true; }
+	internal static bool MessageBeep(MessageBeepType type) { return true; }
+	internal static void ZeroMemory(IntPtr dest, int size) { }
+	internal static int SendMessage(IntPtr hwnd, uint Msg, IntPtr wParam, IntPtr lParam) { return 0; }
+
+#else
         [DllImport("user32.dll")]
 		internal static extern bool LockWindowUpdate(IntPtr hwnd);
 
@@ -94,6 +102,7 @@ namespace CodeImp.DoomBuilder
 
 		//[DllImport("user32.dll")]
 		//internal static extern int GetScrollInfo(IntPtr windowptr, int bar, IntPtr scrollinfo);
+#endif
 
 		#endregion
 
@@ -2044,10 +2053,14 @@ namespace CodeImp.DoomBuilder
 		// This returns the short path name for a file
 		public static string GetShortFilePath(string longpath)
 		{
+#if NO_WIN32
+			return longpath;
+#else
 			const int maxlen = 256;
 			StringBuilder shortname = new StringBuilder(maxlen);
 			GetShortPathName(longpath, shortname, maxlen);
 			return shortname.ToString();
+#endif
 		}
 
 		//mxd
-- 
GitLab