From f476301670d208690f660a054a3463d35b80142a Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Tue, 27 Feb 2024 14:11:48 +0000 Subject: [PATCH] There's no such thing as the global data directory That's what resources/vfs is for. --- apps/launcher/datafilespage.cpp | 10 +++++----- components/config/gamesettings.cpp | 10 ++++------ components/config/gamesettings.hpp | 3 ++- components/config/launchersettings.cpp | 6 +++--- components/files/configurationmanager.cpp | 5 ----- components/files/configurationmanager.hpp | 1 - 6 files changed, 14 insertions(+), 21 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 92b86e9cec..a0287afd87 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -279,9 +279,9 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName) if (!mDataLocal.isEmpty()) directories.insert(0, mDataLocal); - const auto& globalDataDir = mGameSettings.getGlobalDataDir(); - if (!globalDataDir.empty()) - directories.insert(0, Files::pathToQString(globalDataDir)); + const auto& resourcesVfs = mGameSettings.getResourcesVfs(); + if (!resourcesVfs.isEmpty()) + directories.insert(0, resourcesVfs); std::unordered_set visitedDirectories; for (const QString& currentDir : directories) @@ -315,8 +315,8 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName) item->setFont(font); } - // deactivate data-local and global data directory: they are always included - if (currentDir == mDataLocal || Files::pathFromQString(currentDir) == globalDataDir) + // deactivate data-local and resources/vfs: they are always included + if (currentDir == mDataLocal || currentDir == resourcesVfs) { auto flags = item->flags(); item->setFlags(flags & ~(Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled)); diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index 53924c4313..f8ff3d362c 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -64,13 +64,11 @@ void Config::GameSettings::validatePaths() } } -std::filesystem::path Config::GameSettings::getGlobalDataDir() const +QString Config::GameSettings::getResourcesVfs() const { - // global data dir may not exists if OpenMW is not installed (ie if run from build directory) - const auto& path = mCfgMgr.getGlobalDataPath(); - if (std::filesystem::exists(path)) - return std::filesystem::canonical(path); - return {}; + QString resources = mSettings.value(QString("resources"), QString("./resources")); + resources += "/vfs"; + return QFileInfo(resources).canonicalFilePath(); } QStringList Config::GameSettings::values(const QString& key, const QStringList& defaultValues) const diff --git a/components/config/gamesettings.hpp b/components/config/gamesettings.hpp index 34e3dc73ea..bef108e2c7 100644 --- a/components/config/gamesettings.hpp +++ b/components/config/gamesettings.hpp @@ -53,7 +53,8 @@ namespace Config } QStringList getDataDirs() const; - std::filesystem::path getGlobalDataDir() const; + + QString getResourcesVfs() const; inline void removeDataDir(const QString& dir) { diff --git a/components/config/launchersettings.cpp b/components/config/launchersettings.cpp index 9d12535619..2f4decb762 100644 --- a/components/config/launchersettings.cpp +++ b/components/config/launchersettings.cpp @@ -233,10 +233,10 @@ void Config::LauncherSettings::setContentList(const GameSettings& gameSettings) return; } - // global and local data directories are not part of any profile - const auto globalDataDir = Files::pathToQString(gameSettings.getGlobalDataDir()); + // local data directory and resources/vfs are not part of any profile + const auto resourcesVfs = gameSettings.getResourcesVfs(); const auto dataLocal = gameSettings.getDataLocal(); - dirs.removeAll(globalDataDir); + dirs.removeAll(resourcesVfs); dirs.removeAll(dataLocal); // if any existing profile in launcher matches the content list, make that profile the default diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index 210261cdf4..10e10375bb 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -411,11 +411,6 @@ namespace Files return mFixedPath.getLocalPath(); } - const std::filesystem::path& ConfigurationManager::getGlobalDataPath() const - { - return mFixedPath.getGlobalDataPath(); - } - const std::filesystem::path& ConfigurationManager::getCachePath() const { return mFixedPath.getCachePath(); diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index 8a5bca0869..aec7799fea 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -45,7 +45,6 @@ namespace Files const std::filesystem::path& getGlobalPath() const; const std::filesystem::path& getLocalPath() const; - const std::filesystem::path& getGlobalDataPath() const; const std::filesystem::path& getUserConfigPath() const; const std::filesystem::path& getUserDataPath() const; const std::filesystem::path& getLocalDataPath() const;