Files
haikuports/games-engines/openmw/patches/openmw-0.45.0.patchset
Gerasim Troeglazov f45610fccf OpenMW: bump version
2019-03-30 00:03:29 +10:00

368 lines
12 KiB
Plaintext

From cb32f03f326ac562d3fdc1fb94daf2d7000eba44 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 6 Oct 2018 20:54:27 +1000
Subject: Fix build for Haiku
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 34e1a8f..40610ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -107,6 +107,19 @@ endif()
if (APPLE)
set(MORROWIND_DATA_FILES "./data" CACHE PATH "location of Morrowind data files")
set(OPENMW_RESOURCE_FILES "../Resources/resources" CACHE PATH "location of OpenMW resources files")
+elseif(HAIKU)
+ # Paths
+ SET(BINDIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Where to install binaries")
+ SET(LIBDIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "Where to install libraries")
+ SET(DATAROOTDIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Sets the root of data directories to a non-default location")
+ SET(GLOBAL_DATA_PATH "${DATAROOTDIR}/games/" CACHE PATH "Set data path prefix")
+ SET(DATADIR "${GLOBAL_DATA_PATH}/openmw" CACHE PATH "Sets the openmw data directories to a non-default location")
+ SET(ICONDIR "${DATAROOTDIR}/pixmaps" CACHE PATH "Set icon dir")
+ SET(LICDIR "${DATAROOTDIR}/licenses/openmw" CACHE PATH "Sets the openmw license directory to a non-default location.")
+ SET(GLOBAL_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/config/" CACHE PATH "Set config dir prefix")
+ SET(SYSCONFDIR "${GLOBAL_CONFIG_PATH}/openmw" CACHE PATH "Set config dir")
+ set(MORROWIND_DATA_FILES "${CMAKE_INSTALL_PREFIX}/data" CACHE PATH "location of Morrowind data files")
+ set(OPENMW_RESOURCE_FILES "${CMAKE_INSTALL_PREFIX}/resources" CACHE PATH "location of OpenMW resources files")
elseif(UNIX)
# Paths
SET(BINDIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Where to install binaries")
diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt
index bfc08a7..a0a908a 100644
--- a/apps/launcher/CMakeLists.txt
+++ b/apps/launcher/CMakeLists.txt
@@ -105,6 +105,10 @@ target_link_libraries(openmw-launcher
components
)
+if (HAIKU)
+ target_link_libraries(openmw-launcher be)
+endif (HAIKU)
+
if (DESIRED_QT_VERSION MATCHES 4)
target_link_libraries(openmw-launcher ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
if(WIN32)
diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp
index 072f1f3..7ef82be 100644
--- a/apps/launcher/graphicspage.cpp
+++ b/apps/launcher/graphicspage.cpp
@@ -12,7 +12,11 @@
#define MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
#endif // MAC_OS_X_VERSION_MIN_REQUIRED
+#ifdef __HAIKU__
+#include <Screen.h>
+#else
#include <SDL_video.h>
+#endif
#include <components/files/configurationmanager.hpp>
@@ -57,6 +61,9 @@ bool Launcher::GraphicsPage::setupSDL()
}
#endif
+#ifdef __HAIKU__
+ int displays = 1;
+#else
int displays = SDL_GetNumVideoDisplays();
if (displays < 0)
@@ -69,7 +76,7 @@ bool Launcher::GraphicsPage::setupSDL()
msgBox.exec();
return false;
}
-
+#endif
screenComboBox->clear();
for (int i = 0; i < displays; i++)
{
@@ -168,9 +175,30 @@ void Launcher::GraphicsPage::saveSettings()
mEngineSettings.setInt("screen", "Video", cScreen);
}
+#ifdef __HAIKU__
+static QString makeModeString(int w, int h)
+{
+ QString aspect = getAspect(w, h);
+ QString resolution = QString::number(w) + QString(" x ") + QString::number(h);
+ if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) {
+ resolution.append(" (Wide " + aspect + ")");
+ } else if (aspect == QLatin1String("4:3")) {
+ resolution.append(" (Standard 4:3)");
+ }
+ return resolution;
+}
+#endif
+
QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)
{
QStringList result;
+#ifdef __HAIKU__
+ BScreen mainScreen(B_MAIN_SCREEN_ID);
+ result.append(makeModeString(640, 480));
+ result.append(makeModeString(800, 600));
+ result.append(makeModeString(1024, 768));
+ result.append(makeModeString(mainScreen.Frame().Width() + 1, mainScreen.Frame().Height() + 1));
+#else
SDL_DisplayMode mode;
int modeIndex, modes = SDL_GetNumDisplayModes(screen);
@@ -210,7 +238,7 @@ QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)
result.append(resolution);
}
-
+#endif
result.removeDuplicates();
return result;
}
diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp
index 2982a30..358380c 100644
--- a/apps/launcher/maindialog.cpp
+++ b/apps/launcher/maindialog.cpp
@@ -171,7 +171,11 @@ Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog()
if (msgBox.clickedButton() == wizardButton)
{
+#ifdef __HAIKU__
+ if (!mWizardInvoker->startProcess(QLatin1String("OpenMW-Wizard"), false)) {
+#else
if (!mWizardInvoker->startProcess(QLatin1String("openmw-wizard"), false)) {
+#endif
return FirstRunDialogResultFailure;
} else {
return FirstRunDialogResultWizard;
@@ -390,7 +394,11 @@ bool Launcher::MainDialog::setupGameData()
if (msgBox.clickedButton() == wizardButton)
{
+#ifdef __HAIKU__
+ if (!mWizardInvoker->startProcess(QLatin1String("OpenMW-Wizard"), false)) {
+#else
if (!mWizardInvoker->startProcess(QLatin1String("openmw-wizard"), false)) {
+#endif
return false;
} else {
return true;
@@ -599,6 +607,10 @@ void Launcher::MainDialog::play()
// Launch the game detached
+#ifdef __HAIKU__
+ if (mGameInvoker->startProcess(QLatin1String("OpenMW"), true))
+#else
if (mGameInvoker->startProcess(QLatin1String("openmw"), true))
+#endif
return qApp->quit();
}
diff --git a/apps/launcher/sdlinit.cpp b/apps/launcher/sdlinit.cpp
index 1fe1fd4..22e816f 100644
--- a/apps/launcher/sdlinit.cpp
+++ b/apps/launcher/sdlinit.cpp
@@ -5,6 +5,7 @@
bool initSDL()
{
+#ifndef __HAIKU__
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
SDL_SetMainReady();
// Required for determining screen resolution and such on the Graphics tab
@@ -14,12 +15,14 @@ bool initSDL()
}
signal(SIGINT, SIG_DFL); // We don't want to use the SDL event loop in the launcher,
// so reset SIGINT which SDL wants to redirect to an SDL_Quit event.
-
+#endif
return true;
}
void quitSDL()
{
+#ifndef __HAIKU__
// Disconnect from SDL processes
SDL_Quit();
+#endif
}
diff --git a/apps/launcher/settingspage.cpp b/apps/launcher/settingspage.cpp
index 843b513..59afde7 100644
--- a/apps/launcher/settingspage.cpp
+++ b/apps/launcher/settingspage.cpp
@@ -96,8 +96,11 @@ Launcher::SettingsPage::~SettingsPage()
void Launcher::SettingsPage::on_wizardButton_clicked()
{
mMain->writeSettings();
-
+#ifdef __HAIKU__
+ if (!mWizardInvoker->startProcess(QLatin1String("OpenMW-Wizard"), false))
+#else
if (!mWizardInvoker->startProcess(QLatin1String("openmw-wizard"), false))
+#endif
return;
}
diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp
index 176adfa..2c69d45 100644
--- a/apps/openmw/main.cpp
+++ b/apps/openmw/main.cpp
@@ -243,6 +243,11 @@ int runApplication(int argc, char *argv[])
boost::filesystem::current_path(binary_path.parent_path());
setenv("OSG_GL_TEXTURE_STORAGE", "OFF", 0);
#endif
+#ifdef __HAIKU__
+ boost::filesystem::path binary_path = boost::filesystem::system_complete(boost::filesystem::path(argv[0]));
+ boost::filesystem::current_path(binary_path.parent_path());
+ setenv("OPENMW_DECOMPRESS_TEXTURES", "1", 1);
+#endif
Files::ConfigurationManager cfgMgr;
std::unique_ptr<OMW::Engine> engine;
diff --git a/components/crashcatcher/crashcatcher.cpp b/components/crashcatcher/crashcatcher.cpp
index 2e2ddd1..e9400cf 100644
--- a/components/crashcatcher/crashcatcher.cpp
+++ b/components/crashcatcher/crashcatcher.cpp
@@ -12,7 +12,9 @@
#include <pthread.h>
#include <stdbool.h>
+#ifndef __HAIKU__
#include <sys/ptrace.h>
+#endif
#include <components/debug/debuglog.hpp>
diff --git a/components/crashcatcher/crashcatcher.hpp b/components/crashcatcher/crashcatcher.hpp
index fd8f0d1..5b1bc71 100644
--- a/components/crashcatcher/crashcatcher.hpp
+++ b/components/crashcatcher/crashcatcher.hpp
@@ -3,7 +3,7 @@
#include <string>
-#if (defined(__APPLE__) || (defined(__linux) && !defined(ANDROID)) || (defined(__unix) && !defined(ANDROID)) || defined(__posix))
+#if (defined(__APPLE__) || (defined(__linux) && !defined(ANDROID) && !defined(__HAIKU__)) || (defined(__unix) && !defined(ANDROID) && !defined(__HAIKU__)) || defined(__posix))
#define USE_CRASH_CATCHER 1
#else
#define USE_CRASH_CATCHER 0
diff --git a/components/debug/debugging.cpp b/components/debug/debugging.cpp
index e89a659..04441dd 100644
--- a/components/debug/debugging.cpp
+++ b/components/debug/debugging.cpp
@@ -52,6 +52,9 @@ namespace Debug
int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, char *argv[], const std::string& appName)
{
+#ifdef __HAIKU
+ return innerApplication(argc, argv);
+#else
// Some objects used to redirect cout and cerr
// Scope must be here, so this still works inside the catch block for logging exceptions
std::streambuf* cout_rdbuf = std::cout.rdbuf ();
@@ -113,4 +116,5 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
std::cerr.rdbuf(cerr_rdbuf);
return ret;
+#endif
}
diff --git a/components/files/fixedpath.hpp b/components/files/fixedpath.hpp
index 2e72b81..97c43f0 100644
--- a/components/files/fixedpath.hpp
+++ b/components/files/fixedpath.hpp
@@ -4,7 +4,7 @@
#include <string>
#include <boost/filesystem.hpp>
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__HAIKU__)
#ifndef ANDROID
#include <components/files/linuxpath.hpp>
namespace Files { typedef LinuxPath TargetPathType; }
diff --git a/components/files/linuxpath.cpp b/components/files/linuxpath.cpp
index 3743eef..13c9451 100644
--- a/components/files/linuxpath.cpp
+++ b/components/files/linuxpath.cpp
@@ -1,6 +1,6 @@
#include "linuxpath.hpp"
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__HAIKU__)
#include <pwd.h>
#include <unistd.h>
@@ -54,17 +54,32 @@ LinuxPath::LinuxPath(const std::string& application_name)
boost::filesystem::path LinuxPath::getUserConfigPath() const
{
+#ifdef __HAIKU__
+ boost::filesystem::path path("/boot/home/config/settings");
+ return path / mName;
+#else
return getEnv("XDG_CONFIG_HOME", getUserHome() / ".config") / mName;
+#endif
}
boost::filesystem::path LinuxPath::getUserDataPath() const
{
+#ifdef __HAIKU__
+ boost::filesystem::path path("/boot/home/config/settings");
+ return path / mName;
+#else
return getEnv("XDG_DATA_HOME", getUserHome() / ".local/share") / mName;
+#endif
}
boost::filesystem::path LinuxPath::getCachePath() const
{
+#ifdef __HAIKU__
+ boost::filesystem::path path("/boot/home/config/cache");
+ return path / mName;
+#else
return getEnv("XDG_CACHE_HOME", getUserHome() / ".cache") / mName;
+#endif
}
boost::filesystem::path LinuxPath::getGlobalConfigPath() const
diff --git a/components/files/linuxpath.hpp b/components/files/linuxpath.hpp
index 7950157..32ff3d8 100644
--- a/components/files/linuxpath.hpp
+++ b/components/files/linuxpath.hpp
@@ -1,7 +1,7 @@
#ifndef COMPONENTS_FILES_LINUXPATH_H
#define COMPONENTS_FILES_LINUXPATH_H
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__HAIKU__)
#include <boost/filesystem.hpp>
--
2.19.1
From e7155ea818a5f48ef927752e8d6f5d1db2e42652 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 7 Oct 2018 16:49:50 +1000
Subject: Remove SDL_WINDOW_RESIZABLE flag for haiku
diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp
index f5b4171..897b3e1 100644
--- a/apps/openmw/engine.cpp
+++ b/apps/openmw/engine.cpp
@@ -336,7 +336,11 @@ void OMW::Engine::createWindow(Settings::Manager& settings)
pos_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen);
}
+#ifdef __HAIKU__
+ Uint32 flags = SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN;
+#else
Uint32 flags = SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE;
+#endif
if(fullscreen)
flags |= SDL_WINDOW_FULLSCREEN;
--
2.19.1