diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index ac3c77c7..1f6dcf5f 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -4,10 +4,6 @@ if (WIN32) option(UNLEASHED_RECOMP_D3D12 "Add D3D12 support for rendering" ON) endif() -if (CMAKE_SYSTEM_NAME MATCHES "Linux") - option(UNLEASHED_RECOMP_FLATPAK "Configure the build for Flatpak compatibility." OFF) -endif() - function(BIN2C) cmake_parse_arguments(BIN2C_ARGS "" "TARGET_OBJ;SOURCE_FILE;DEST_FILE;ARRAY_NAME;COMPRESSION_TYPE" "" ${ARGN}) @@ -300,13 +296,6 @@ else() add_executable(UnleashedRecomp ${UNLEASHED_RECOMP_CXX_SOURCES}) endif() -if (UNLEASHED_RECOMP_FLATPAK) - target_compile_definitions(UnleashedRecomp PRIVATE - "UNLEASHED_RECOMP_FLATPAK" - "GAME_INSTALL_DIRECTORY_PREPROC=\"/var/data\"" - ) -endif() - if (UNLEASHED_RECOMP_D3D12) find_package(directx-headers CONFIG REQUIRED) find_package(directx12-agility CONFIG REQUIRED) diff --git a/UnleashedRecomp/user/config.cpp b/UnleashedRecomp/user/config.cpp index 07dc56d3..05c98d50 100644 --- a/UnleashedRecomp/user/config.cpp +++ b/UnleashedRecomp/user/config.cpp @@ -5,15 +5,16 @@ std::vector g_configDefinitions; +const bool g_isRuntimeFlatpak = +#if defined(__linux__) + getenv("FLATPAK_SANDBOX_DIR") != nullptr; +#else + false; +#endif + #define CONFIG_DEFINE_ENUM_TEMPLATE(type) \ static std::unordered_map g_##type##_template = -#if defined(__linux__) - const bool g_isRuntimeFlatpak = getenv("FLATPAK_SANDBOX_DIR") != nullptr; -#else - const bool g_isRuntimeFlatpak = false; -#endif - CONFIG_DEFINE_ENUM_TEMPLATE(ELanguage) { { "English", ELanguage::English }, diff --git a/UnleashedRecomp/user/paths.cpp b/UnleashedRecomp/user/paths.cpp index 7dcc6a1f..122c88cf 100644 --- a/UnleashedRecomp/user/paths.cpp +++ b/UnleashedRecomp/user/paths.cpp @@ -4,32 +4,36 @@ std::filesystem::path g_executableRoot = os::process::GetExecutablePath().remove_filename(); std::filesystem::path g_userPath = BuildUserPath(); -extern const std::string g_gamepath = GetGamePath().string(); +extern const std::string g_gamepath = GetGamePath(); bool CheckPortable() { return std::filesystem::exists(g_executableRoot / "portable.txt"); } -std::filesystem::path GetGamePath() +std::string GetGamePath() { #if defined(__linux__) - if (g_isRuntimeFlatpak || CheckPortable()) - return GAME_INSTALL_DIRECTORY_PREPROC; + if (g_isRuntimeFlatpak) + return "/var/data"; + + if (CheckPortable()) + return g_executableRoot.string(); const char* homeDir = getenv("HOME"); + if (homeDir == nullptr) { - return GAME_INSTALL_DIRECTORY_PREPROC; + return g_executableRoot.string(); } else { std::filesystem::path homePath = homeDir; std::filesystem::path gamePath = homePath / ".local/share" / USER_DIRECTORY; - return gamePath; + return gamePath.string(); } #else - return GAME_INSTALL_DIRECTORY_PREPROC; + return "."; #endif } diff --git a/UnleashedRecomp/user/paths.h b/UnleashedRecomp/user/paths.h index 7881d81d..af47818e 100644 --- a/UnleashedRecomp/user/paths.h +++ b/UnleashedRecomp/user/paths.h @@ -4,15 +4,11 @@ #define USER_DIRECTORY "UnleashedRecomp" -#ifndef GAME_INSTALL_DIRECTORY_PREPROC -#define GAME_INSTALL_DIRECTORY_PREPROC "." -#endif - bool CheckPortable(); std::filesystem::path BuildUserPath(); const std::filesystem::path& GetUserPath(); extern const std::string g_gamepath; -std::filesystem::path GetGamePath(); +std::string GetGamePath(); inline std::filesystem::path GetSavePath(bool checkForMods) { diff --git a/flatpak/io.github.hedge_dev.unleashedrecomp.json b/flatpak/io.github.hedge_dev.unleashedrecomp.json index f6ae9324..34926b5f 100644 --- a/flatpak/io.github.hedge_dev.unleashedrecomp.json +++ b/flatpak/io.github.hedge_dev.unleashedrecomp.json @@ -20,7 +20,7 @@ "name": "UnleashedRecomp", "buildsystem": "simple", "build-commands": [ - "cmake --preset linux-release -DUNLEASHED_RECOMP_FLATPAK=ON -DSDL2MIXER_VORBIS=VORBISFILE -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache", + "cmake --preset linux-release -DSDL2MIXER_VORBIS=VORBISFILE -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache", "cmake --build out/build/linux-release --target UnleashedRecomp", "mkdir -p /app/bin", "cp out/build/linux-release/UnleashedRecomp/UnleashedRecomp /app/bin/UnleashedRecomp",