mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 21:01:37 +00:00
Moved game data folder to ~/.local/share/UnleashedRecomp
This commit is contained in:
parent
df5e48f528
commit
13c0146b42
9 changed files with 109 additions and 80 deletions
|
|
@ -303,7 +303,7 @@ endif()
|
|||
if (UNLEASHED_RECOMP_FLATPAK)
|
||||
target_compile_definitions(UnleashedRecomp PRIVATE
|
||||
"UNLEASHED_RECOMP_FLATPAK"
|
||||
"GAME_INSTALL_DIRECTORY=\"/var/data\""
|
||||
"GAME_INSTALL_DIRECTORY_PREPROC=\"/var/data\""
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ PPC_FUNC_IMPL(__imp__sub_824EB490);
|
|||
PPC_FUNC(sub_824EB490)
|
||||
{
|
||||
App::s_isInit = true;
|
||||
App::s_isMissingDLC = !Installer::checkAllDLC(GetGamePath());
|
||||
App::s_isMissingDLC = !Installer::checkAllDLC(g_gamepath);
|
||||
App::s_language = Config::Language;
|
||||
|
||||
SWA::SGlobals::Init();
|
||||
|
|
|
|||
|
|
@ -315,11 +315,11 @@ uint32_t XamContentCreateEx(uint32_t dwUserIndex, const char* szRootName, const
|
|||
}
|
||||
else if (pContentData->dwContentType == XCONTENTTYPE_DLC)
|
||||
{
|
||||
root = GAME_INSTALL_DIRECTORY "/dlc";
|
||||
root = g_gamepath + "/dlc";
|
||||
}
|
||||
else
|
||||
{
|
||||
root = GAME_INSTALL_DIRECTORY;
|
||||
root = g_gamepath;
|
||||
}
|
||||
|
||||
XamRegisterContent(*pContentData, root);
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ void KiSystemStartup()
|
|||
{
|
||||
const auto gameContent = XamMakeContent(XCONTENTTYPE_RESERVED, "Game");
|
||||
const auto updateContent = XamMakeContent(XCONTENTTYPE_RESERVED, "Update");
|
||||
XamRegisterContent(gameContent, GAME_INSTALL_DIRECTORY "/game");
|
||||
XamRegisterContent(updateContent, GAME_INSTALL_DIRECTORY "/update");
|
||||
XamRegisterContent(gameContent, g_gamepath + "/game");
|
||||
XamRegisterContent(updateContent, g_gamepath + "/update");
|
||||
|
||||
const auto saveFilePath = GetSaveFilePath(true);
|
||||
bool saveFileExists = std::filesystem::exists(saveFilePath);
|
||||
|
|
@ -84,7 +84,7 @@ void KiSystemStartup()
|
|||
XamContentCreateEx(0, "D", &gameContent, OPEN_EXISTING, nullptr, nullptr, 0, 0, nullptr);
|
||||
|
||||
std::error_code ec;
|
||||
for (auto& file : std::filesystem::directory_iterator(GAME_INSTALL_DIRECTORY "/dlc", ec))
|
||||
for (auto& file : std::filesystem::directory_iterator(g_gamepath + "/dlc", ec))
|
||||
{
|
||||
if (file.is_directory())
|
||||
{
|
||||
|
|
@ -198,7 +198,7 @@ int main(int argc, char *argv[])
|
|||
HostStartup();
|
||||
|
||||
std::filesystem::path modulePath;
|
||||
bool isGameInstalled = Installer::checkGameInstall(GAME_INSTALL_DIRECTORY, modulePath);
|
||||
bool isGameInstalled = Installer::checkGameInstall(g_gamepath, modulePath);
|
||||
bool runInstallerWizard = forceInstaller || forceDLCInstaller || !isGameInstalled;
|
||||
if (runInstallerWizard)
|
||||
{
|
||||
|
|
@ -208,7 +208,7 @@ int main(int argc, char *argv[])
|
|||
std::_Exit(1);
|
||||
}
|
||||
|
||||
if (!InstallerWizard::Run(GAME_INSTALL_DIRECTORY, isGameInstalled && forceDLCInstaller))
|
||||
if (!InstallerWizard::Run(g_gamepath, isGameInstalled && forceDLCInstaller))
|
||||
{
|
||||
std::_Exit(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ void ModLoader::Init()
|
|||
{
|
||||
configIni = {};
|
||||
|
||||
if (!configIni.read(GAME_INSTALL_DIRECTORY "/cpkredir.ini"))
|
||||
if (!configIni.read(g_gamepath + "/cpkredir.ini"))
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@ std::vector<IConfigDef*> g_configDefinitions;
|
|||
#define CONFIG_DEFINE_ENUM_TEMPLATE(type) \
|
||||
static std::unordered_map<std::string, type> 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 },
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <locale/locale.h>
|
||||
|
||||
extern const bool g_isRuntimeFlatpak;
|
||||
|
||||
class IConfigDef
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,14 +1,38 @@
|
|||
#include "paths.h"
|
||||
#include <user/config.h>
|
||||
#include <os/process.h>
|
||||
|
||||
std::filesystem::path g_executableRoot = os::process::GetExecutablePath().remove_filename();
|
||||
std::filesystem::path g_userPath = BuildUserPath();
|
||||
extern const std::string g_gamepath = GetGamePath().string();
|
||||
|
||||
bool CheckPortable()
|
||||
{
|
||||
return std::filesystem::exists(g_executableRoot / "portable.txt");
|
||||
}
|
||||
|
||||
std::filesystem::path GetGamePath()
|
||||
{
|
||||
#if defined(__linux__)
|
||||
if (g_isRuntimeFlatpak || CheckPortable())
|
||||
return GAME_INSTALL_DIRECTORY_PREPROC;
|
||||
|
||||
const char* homeDir = getenv("HOME");
|
||||
if (homeDir == nullptr)
|
||||
{
|
||||
return GAME_INSTALL_DIRECTORY_PREPROC;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::filesystem::path homePath = homeDir;
|
||||
std::filesystem::path gamePath = homePath / ".local/share" / USER_DIRECTORY;
|
||||
return gamePath;
|
||||
}
|
||||
#else
|
||||
return GAME_INSTALL_DIRECTORY_PREPROC;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::filesystem::path BuildUserPath()
|
||||
{
|
||||
if (CheckPortable())
|
||||
|
|
|
|||
|
|
@ -4,18 +4,15 @@
|
|||
|
||||
#define USER_DIRECTORY "UnleashedRecomp"
|
||||
|
||||
#ifndef GAME_INSTALL_DIRECTORY
|
||||
#define GAME_INSTALL_DIRECTORY "."
|
||||
#ifndef GAME_INSTALL_DIRECTORY_PREPROC
|
||||
#define GAME_INSTALL_DIRECTORY_PREPROC "."
|
||||
#endif
|
||||
|
||||
inline std::filesystem::path GetGamePath()
|
||||
{
|
||||
return GAME_INSTALL_DIRECTORY;
|
||||
}
|
||||
|
||||
bool CheckPortable();
|
||||
std::filesystem::path BuildUserPath();
|
||||
const std::filesystem::path& GetUserPath();
|
||||
extern const std::string g_gamepath;
|
||||
std::filesystem::path GetGamePath();
|
||||
|
||||
inline std::filesystem::path GetSavePath(bool checkForMods)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue