From 40640b29115eac5339721a78654e245278028339 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 4 Oct 2018 19:55:34 +1000
Subject: Fix data dir for Haiku


diff --git a/Media/CMakeLists.txt b/Media/CMakeLists.txt
index c644ed1..41172f3 100644
--- a/Media/CMakeLists.txt
+++ b/Media/CMakeLists.txt
@@ -5,6 +5,8 @@
 # Set media target directory
 if (WIN32)
   set(MYGUI_MEDIA_PATH "Media")
+elseif (HAIKU)
+  set(MYGUI_MEDIA_PATH "data/MYGUI/Media")
 elseif (UNIX)
   set(MYGUI_MEDIA_PATH "share/MYGUI/Media")
 elseif (APPLE)
-- 
2.19.0


From aa46ff1e95801bcfee50e052c82220ca8866ae3d Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 4 Oct 2018 20:54:38 +1000
Subject: Fix resource path


diff --git a/CMake/InstallResources.cmake b/CMake/InstallResources.cmake
index 47f28f1..c771423 100644
--- a/CMake/InstallResources.cmake
+++ b/CMake/InstallResources.cmake
@@ -45,6 +45,8 @@ endif ()
 if (MYGUI_INSTALL_SAMPLES OR MYGUI_INSTALL_TOOLS)
 	if (WIN32)
 		set(MYGUI_MEDIA_DIR "../../Media")
+	elseif (HAIKU)
+		set(MYGUI_MEDIA_DIR "/system/data/MYGUI/Media")
 	elseif (UNIX)
 		set(MYGUI_MEDIA_DIR "../share/MYGUI/Media")
 	else ()
-- 
2.19.0


From 9f39d1b46430ac7d0750779c9f5d8f83d611b56e Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 4 Oct 2018 20:54:56 +1000
Subject: Fix crash


diff --git a/Common/FileSystemInfo/FileSystemInfo.h b/Common/FileSystemInfo/FileSystemInfo.h
index f1324cb..be25f24 100644
--- a/Common/FileSystemInfo/FileSystemInfo.h
+++ b/Common/FileSystemInfo/FileSystemInfo.h
@@ -39,9 +39,14 @@ namespace common
 	{
 		std::wstring result;
 		result.resize(_input.size());
+#ifndef __HAIKU__
 		static std::locale sLocale("");
 		for (unsigned int i=0; i<_input.size(); ++i)
 			result[i] = std::tolower(_input[i], sLocale);
+#else
+		for (unsigned int i=0; i<_input.size(); ++i)
+			result[i] = std::tolower(_input[i]);
+#endif
 		return result;
 	}
 
-- 
2.19.0


From 8627190f4cbc8f0c1bb27b193fe0110c92e6fbb5 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 4 Oct 2018 22:00:45 +1000
Subject: Set app dir


diff --git a/Common/Base/Main.h b/Common/Base/Main.h
index 426ba4d..6a20e86 100644
--- a/Common/Base/Main.h
+++ b/Common/Base/Main.h
@@ -15,6 +15,9 @@
 #include <windows.h>
 #include <direct.h>
 #endif
+#ifdef __HAIKU__
+#include <unistd.h>
+#endif
 
 #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
 #	ifdef MYGUI_CHECK_MEMORY_LEAKS
@@ -22,6 +25,17 @@
 #	else
 #		define MYGUI_APP(cls) INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT argc) { return startApp<cls>(); }
 #	endif
+#elif defined(__HAIKU__)
+#	define MYGUI_APP(cls) \
+	int main(int argc, char **argv) \
+	{ \
+		char *ptr; \
+		if(ptr = strrchr(argv[0], '/')) { \
+			*ptr = '\0'; \
+			chdir(argv[0]); \
+		} \
+		return startApp<cls>(); \
+	}
 #else
 #	define MYGUI_APP(cls) int main(int argc, char **argv) { return startApp<cls>(); }
 #endif
-- 
2.19.0

