From 760d8c6dfe207eb581ec101bd14a36d2d20bb3d8 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Fri, 12 Mar 2021 20:09:18 +1000 Subject: Add Haiku support diff --git a/CMakeLists.txt b/CMakeLists.txt index f8f1842..ab2c7f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -319,6 +319,10 @@ Set (FLARE_HEADERS ./src/WidgetTooltip.h ) +if(HAIKU) + set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS}" "-lbe") +endif() + # Add icon and file info to executable for Windows systems IF (WIN32) SET(FLARE_SOURCES diff --git a/src/main.cpp b/src/main.cpp index 11727c6..331ad34 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,6 +58,8 @@ public: #ifdef _WIN32 #include "PlatformWin32.cpp" +#elif __HAIKU__ +#include "PlatformHaiku.cpp" #elif __ANDROID__ #include "PlatformAndroid.cpp" #elif __IPHONEOS__ diff --git a/src/PlatformHaiku.cpp b/src/PlatformHaiku.cpp new file mode 100644 index 0000000..4430bef --- /dev/null +++ b/src/PlatformHaiku.cpp @@ -0,0 +1,122 @@ +/* +Copyright © 2021 Gerasim Troeglazov + +FLARE is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, +either version 3 of the License, or (at your option) any later version. + +FLARE is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +FLARE. If not, see http://www.gnu.org/licenses/ +*/ + +#ifdef PLATFORM_CPP_INCLUDE +#ifndef PLATFORM_CPP +#define PLATFORM_CPP + +#include "Platform.h" +#include "Settings.h" +#include "SharedResources.h" +#include "Utils.h" +#include "UtilsFileSystem.h" +#include "UtilsParsing.h" + +#include + +#include +#include +#include + +#include +#include +#include +#include + +Platform platform; + +Platform::Platform() + : has_exit_button(true) + , is_mobile_device(false) + , force_hardware_cursor(false) + , has_lock_file(false) + , config_menu_type(CONFIG_MENU_TYPE_DESKTOP) + , default_renderer("") + , config_video(Platform::Video::COUNT, true) + , config_audio(Platform::Audio::COUNT, true) + , config_interface(Platform::Interface::COUNT, true) + , config_input(Platform::Input::COUNT, true) + , config_misc(Platform::Misc::COUNT, true) +{ +} + +Platform::~Platform() { +} + +void Platform::setPaths() { + BPath path; + find_directory(B_USER_SETTINGS_DIRECTORY, &path); + settings->path_conf = std::string(path.Path()) + "/flare/"; + Filesystem::createDir(settings->path_conf); + + settings->path_user = settings->path_conf; + Filesystem::createDir(settings->path_user + "mods/"); + Filesystem::createDir(settings->path_user + "saves/"); + + bool path_data = false; + + if (Filesystem::pathExists(settings->custom_path_data)) { + if (!path_data) settings->path_data = settings->custom_path_data; + path_data = true; + } + else if (!settings->custom_path_data.empty()) { + Utils::logError("Settings: Could not find specified game data directory."); + settings->custom_path_data = ""; + } + + if (Filesystem::pathExists("./mods")) { + if (!path_data) settings->path_data = "./"; + path_data = true; + } + +#if defined DATA_INSTALL_DIR + if (!path_data) settings->path_data = DATA_INSTALL_DIR "/"; + if (!path_data && Filesystem::pathExists(settings->path_data)) path_data = true; +#endif + + find_directory(B_SYSTEM_DATA_DIRECTORY, &path); + + if (!path_data) settings->path_data = std::string(path.Path()) + "/flare/"; + if (!path_data && Filesystem::pathExists(settings->path_data)) path_data = true; + if (!path_data) settings->path_data = "./"; +} + +bool Platform::dirCreate(const std::string& path) { + if (mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == -1) { + std::string error_msg = "Platform::dirCreate (" + path + ")"; + perror(error_msg.c_str()); + return false; + } + return true; +} + +bool Platform::dirRemove(const std::string& path) { + if (rmdir(path.c_str()) == -1) { + std::string error_msg = "Platform::dirRemove (" + path + ")"; + perror(error_msg.c_str()); + return false; + } + return true; +} + +// unused +void Platform::FSInit() {} +bool Platform::FSCheckReady() { return true; } +void Platform::FSCommit() {} +void Platform::setScreenSize() {} +void Platform::setExitEventFilter() {} + +#endif // PLATFORM_CPP +#endif // PLATFORM_CPP_INCLUDE -- 2.30.2