more cleaning

This commit is contained in:
Dmugetsu 2025-06-29 05:44:49 -06:00
parent fa2c82e9a3
commit 76f58e0cda
17 changed files with 138 additions and 299 deletions

View File

@ -76,10 +76,10 @@ static bool isPSNSignedIn = false;
// Gui
static bool load_game_size = true;
static std::vector<GameInstallDir> settings_install_dirs = {};
std::vector<bool> install_dirs_enabled = {};
std::filesystem::path settings_addon_install_dir = {};
std::filesystem::path save_data_path = {};
static std::vector<GameDirectories> settings_directories = {};
static std::vector<bool> directories_enabled = {};
static std::filesystem::path settings_addon_directories = {};
static std::filesystem::path save_data_path = {};
static bool isFullscreen = false;
static std::string fullscreenMode = "Windowed";
static bool isHDRAllowed = false;
@ -439,56 +439,56 @@ void setCheckCompatibilityOnStartup(bool use) {
checkCompatibilityOnStartup = use;
}
bool addGameInstallDir(const std::filesystem::path& dir, bool enabled) {
for (const auto& install_dir : settings_install_dirs) {
if (install_dir.path == dir) {
bool addGameDirectories(const std::filesystem::path& dir, bool enabled) {
for (const auto& directories : settings_directories) {
if (directories.path == dir) {
return false;
}
}
settings_install_dirs.push_back({dir, enabled});
settings_directories.push_back({dir, enabled});
return true;
}
void removeGameInstallDir(const std::filesystem::path& dir) {
auto iterator =
std::find_if(settings_install_dirs.begin(), settings_install_dirs.end(),
[&dir](const GameInstallDir& install_dir) { return install_dir.path == dir; });
if (iterator != settings_install_dirs.end()) {
settings_install_dirs.erase(iterator);
void removeGameDirectories(const std::filesystem::path& dir) {
auto iterator = std::find_if(
settings_directories.begin(), settings_directories.end(),
[&dir](const GameDirectories& directories) { return directories.path == dir; });
if (iterator != settings_directories.end()) {
settings_directories.erase(iterator);
}
}
void setGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled) {
auto iterator =
std::find_if(settings_install_dirs.begin(), settings_install_dirs.end(),
[&dir](const GameInstallDir& install_dir) { return install_dir.path == dir; });
if (iterator != settings_install_dirs.end()) {
void setGameDirectoriesEnabled(const std::filesystem::path& dir, bool enabled) {
auto iterator = std::find_if(
settings_directories.begin(), settings_directories.end(),
[&dir](const GameDirectories& directories) { return directories.path == dir; });
if (iterator != settings_directories.end()) {
iterator->enabled = enabled;
}
}
void setAddonInstallDir(const std::filesystem::path& dir) {
settings_addon_install_dir = dir;
void setAddonDirectories(const std::filesystem::path& dir) {
settings_addon_directories = dir;
}
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config) {
settings_install_dirs.clear();
void setGameDirectories(const std::vector<std::filesystem::path>& dirs_config) {
settings_directories.clear();
for (const auto& dir : dirs_config) {
settings_install_dirs.push_back({dir, true});
settings_directories.push_back({dir, true});
}
}
void setAllGameInstallDirs(const std::vector<GameInstallDir>& dirs_config) {
settings_install_dirs = dirs_config;
void setAllGameDirectories(const std::vector<GameDirectories>& dirs_config) {
settings_directories = dirs_config;
}
void setSaveDataPath(const std::filesystem::path& path) {
save_data_path = path;
}
const std::vector<std::filesystem::path> getGameInstallDirs() {
const std::vector<std::filesystem::path> getGameDirectories() {
std::vector<std::filesystem::path> enabled_dirs;
for (const auto& dir : settings_install_dirs) {
for (const auto& dir : settings_directories) {
if (dir.enabled) {
enabled_dirs.push_back(dir.path);
}
@ -496,20 +496,20 @@ const std::vector<std::filesystem::path> getGameInstallDirs() {
return enabled_dirs;
}
const std::vector<bool> getGameInstallDirsEnabled() {
const std::vector<bool> getGameDirsEnabled() {
std::vector<bool> enabled_dirs;
for (const auto& dir : settings_install_dirs) {
for (const auto& dir : settings_directories) {
enabled_dirs.push_back(dir.enabled);
}
return enabled_dirs;
}
std::filesystem::path getAddonInstallDir() {
if (settings_addon_install_dir.empty()) {
std::filesystem::path getAddonDirectory() {
if (settings_addon_directories.empty()) {
// Default for users without a config file or a config file from before this option existed
return Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "addcont";
}
return settings_addon_install_dir;
return settings_addon_directories;
}
u32 GetLanguage() {
@ -621,29 +621,29 @@ void load(const std::filesystem::path& path) {
load_game_size = toml::find_or<bool>(gui, "loadGameSizeEnabled", true);
const auto install_dir_array =
toml::find_or<std::vector<std::u8string>>(gui, "installDirs", {});
const auto directories_array =
toml::find_or<std::vector<std::u8string>>(gui, "Directories", {});
try {
install_dirs_enabled = toml::find<std::vector<bool>>(gui, "installDirsEnabled");
directories_enabled = toml::find<std::vector<bool>>(gui, "DirectoriesEnabled");
} catch (...) {
// If it does not exist, assume that all are enabled.
install_dirs_enabled.resize(install_dir_array.size(), true);
directories_enabled.resize(directories_array.size(), true);
}
if (install_dirs_enabled.size() < install_dir_array.size()) {
install_dirs_enabled.resize(install_dir_array.size(), true);
if (directories_enabled.size() < directories_array.size()) {
directories_enabled.resize(directories_array.size(), true);
}
settings_install_dirs.clear();
for (size_t i = 0; i < install_dir_array.size(); i++) {
settings_install_dirs.push_back(
{std::filesystem::path{install_dir_array[i]}, install_dirs_enabled[i]});
settings_directories.clear();
for (size_t i = 0; i < directories_array.size(); i++) {
settings_directories.push_back(
{std::filesystem::path{directories_array[i]}, directories_enabled[i]});
}
save_data_path = toml::find_fs_path_or(gui, "saveDataPath", {});
settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", {});
settings_addon_directories = toml::find_fs_path_or(gui, "addonDirectories", {});
}
if (data.contains("Settings")) {
@ -755,8 +755,8 @@ void save(const std::filesystem::path& path) {
data["Debug"]["FPSColor"] = isFpsColor;
data["Keys"]["TrophyKey"] = trophyKey;
std::vector<std::string> install_dirs;
std::vector<bool> install_dirs_enabled;
std::vector<std::string> directories;
std::vector<bool> directories_enabled;
// temporary structure for ordering
struct DirEntry {
@ -765,7 +765,7 @@ void save(const std::filesystem::path& path) {
};
std::vector<DirEntry> sorted_dirs;
for (const auto& dirInfo : settings_install_dirs) {
for (const auto& dirInfo : settings_directories) {
sorted_dirs.push_back(
{std::string{fmt::UTF(dirInfo.path.u8string()).data}, dirInfo.enabled});
}
@ -778,17 +778,17 @@ void save(const std::filesystem::path& path) {
});
for (const auto& entry : sorted_dirs) {
install_dirs.push_back(entry.path_str);
install_dirs_enabled.push_back(entry.enabled);
directories.push_back(entry.path_str);
directories_enabled.push_back(entry.enabled);
}
data["GUI"]["installDirs"] = install_dirs;
data["GUI"]["installDirsEnabled"] = install_dirs_enabled;
data["GUI"]["Directories"] = directories;
data["GUI"]["DirectoriesEnabled"] = directories_enabled;
data["GUI"]["saveDataPath"] = std::string{fmt::UTF(save_data_path.u8string()).data};
data["GUI"]["loadGameSizeEnabled"] = load_game_size;
data["GUI"]["addonInstallDir"] =
std::string{fmt::UTF(settings_addon_install_dir.u8string()).data};
data["GUI"]["addonDirectories"] =
std::string{fmt::UTF(settings_addon_directories.u8string()).data};
data["Settings"]["consoleLanguage"] = m_language;
// Sorting of TOML sections

View File

@ -9,7 +9,7 @@
namespace Config {
struct GameInstallDir {
struct GameDirectories {
std::filesystem::path path;
bool enabled;
};
@ -110,20 +110,20 @@ int* GetControllerCustomColor();
void SetControllerCustomColor(int r, int b, int g);
void setUserName(const std::string& type);
void setChooseHomeTab(const std::string& type);
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config);
void setAllGameInstallDirs(const std::vector<GameInstallDir>& dirs_config);
void setGameDirectories(const std::vector<std::filesystem::path>& dirs_config);
void setAllGameDirectories(const std::vector<GameDirectories>& dirs_config);
void setSaveDataPath(const std::filesystem::path& path);
void setCompatibilityEnabled(bool use);
void setCheckCompatibilityOnStartup(bool use);
// Gui
bool addGameInstallDir(const std::filesystem::path& dir, bool enabled = true);
void removeGameInstallDir(const std::filesystem::path& dir);
void setGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled);
void setAddonInstallDir(const std::filesystem::path& dir);
bool addGameDirectories(const std::filesystem::path& dir, bool enabled = true);
void removeGameDirectories(const std::filesystem::path& dir);
void setGameDirectoriesEnabled(const std::filesystem::path& dir, bool enabled);
void setAddonDirectories(const std::filesystem::path& dir);
const std::vector<std::filesystem::path> getGameInstallDirs();
const std::vector<bool> getGameInstallDirsEnabled();
std::filesystem::path getAddonInstallDir();
const std::vector<std::filesystem::path>& getGameDirectories();
const std::vector<bool>& getGameDirectoriesEnabled();
const std::filesystem::path& getAddonDirectories();
void setDefaultValues();

View File

@ -57,7 +57,7 @@ int PS4_SYSV_ABI sceAppContentAddcontMount(u32 service_label,
OrbisAppContentMountPoint* mount_point) {
LOG_INFO(Lib_AppContent, "called");
const auto& mount_dir = Config::getAddonInstallDir() / title_id / entitlement_label->data;
const auto& mount_dir = Config::getAddonDirectories() / title_id / entitlement_label->data;
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
for (int i = 0; i < addcont_count; i++) {
@ -244,7 +244,7 @@ int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initPar
LOG_ERROR(Lib_AppContent, "(DUMMY) called");
auto* param_sfo = Common::Singleton<PSF>::Instance();
const auto addons_dir = Config::getAddonInstallDir();
const auto addons_dir = Config::getAddonDirectories();
if (const auto value = param_sfo->GetString("TITLE_ID"); value.has_value()) {
title_id = *value;
} else {

View File

@ -112,7 +112,7 @@ int main(int argc, char* argv[]) {
exit(1);
}
Config::addGameInstallDir(config_path);
Config::addGameDirectories(config_path);
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
std::cout << "Game folder successfully saved.\n";
exit(0);
@ -174,7 +174,7 @@ int main(int argc, char* argv[]) {
}
// If no game directory is set and no command line argument, prompt for it
if (Config::getGameInstallDirs().empty()) {
if (Config::getGameDirectories().empty()) {
std::cout << "Warning: No game folder set, please set it by calling shadps4"
" with the --add-game-folder <folder_name> argument\n";
}
@ -189,11 +189,11 @@ int main(int argc, char* argv[]) {
// Check if the provided path is a valid file
if (!std::filesystem::exists(eboot_path)) {
// If not a file, treat it as a game ID and search in install directories recursively
// If not a file, treat it as a game ID and search in directories recursively
bool game_found = false;
const int max_depth = 5;
for (const auto& install_dir : Config::getGameInstallDirs()) {
if (auto found_path = Common::FS::FindGameByID(install_dir, game_path, max_depth)) {
for (const auto& directories : Config::getGameDirectories()) {
if (auto found_path = Common::FS::FindGameByID(directories, game_path, max_depth)) {
eboot_path = *found_path;
game_found = true;
break;

View File

@ -12,9 +12,9 @@
#include <QPushButton>
#include <QVBoxLayout>
#include "game_install_dialog.h"
#include "game_directory_dialog.h"
GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
GameDirectoryDialog::GameDirectoryDialog() : m_gamesDirectory(nullptr) {
auto layout = new QVBoxLayout(this);
layout->addWidget(SetupGamesDirectory());
@ -26,9 +26,9 @@ GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
setWindowIcon(QIcon(":images/shadps4.ico"));
}
GameInstallDialog::~GameInstallDialog() {}
GameDirectoryDialog::~GameDirectoryDialog() {}
void GameInstallDialog::BrowseGamesDirectory() {
void GameDirectoryDialog::BrowseGamesDirectory() {
auto path = QFileDialog::getExistingDirectory(this, tr("Games Directory"));
if (!path.isEmpty()) {
@ -36,7 +36,7 @@ void GameInstallDialog::BrowseGamesDirectory() {
}
}
void GameInstallDialog::BrowseAddonsDirectory() {
void GameDirectoryDialog::BrowseAddonsDirectory() {
auto path = QFileDialog::getExistingDirectory(this, tr("DLC Directory"));
if (!path.isEmpty()) {
@ -44,7 +44,7 @@ void GameInstallDialog::BrowseAddonsDirectory() {
}
}
QWidget* GameInstallDialog::SetupGamesDirectory() {
QWidget* GameDirectoryDialog::SetupGamesDirectory() {
auto group = new QGroupBox(tr("Games Directory"));
auto layout = new QHBoxLayout(group);
@ -53,22 +53,22 @@ QWidget* GameInstallDialog::SetupGamesDirectory() {
// Browse button.
auto browse = new QPushButton(tr("Browse"));
connect(browse, &QPushButton::clicked, this, &GameInstallDialog::BrowseGamesDirectory);
connect(browse, &QPushButton::clicked, this, &GameDirectoryDialog::BrowseGamesDirectory);
layout->addWidget(browse);
return group;
}
QWidget* GameInstallDialog::SetupAddonsDirectory() {
QWidget* GameDirectoryDialog::SetupAddonsDirectory() {
auto group = new QGroupBox(tr("DLC Directory"));
auto layout = new QHBoxLayout(group);
// Input.
m_addonsDirectory = new QLineEdit();
QString install_dir;
Common::FS::PathToQString(install_dir, Config::getAddonInstallDir());
m_addonsDirectory->setText(install_dir);
QString directories;
Common::FS::PathToQString(directories, Config::getAddonDirectories());
m_addonsDirectory->setText(directories);
m_addonsDirectory->setMinimumWidth(400);
layout->addWidget(m_addonsDirectory);
@ -76,49 +76,46 @@ QWidget* GameInstallDialog::SetupAddonsDirectory() {
// Browse button.
auto browse = new QPushButton(tr("Browse"));
connect(browse, &QPushButton::clicked, this, &GameInstallDialog::BrowseAddonsDirectory);
connect(browse, &QPushButton::clicked, this, &GameDirectoryDialog::BrowseAddonsDirectory);
layout->addWidget(browse);
return group;
}
QWidget* GameInstallDialog::SetupDialogActions() {
QWidget* GameDirectoryDialog::SetupDialogActions() {
auto actions = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(actions, &QDialogButtonBox::accepted, this, &GameInstallDialog::Save);
connect(actions, &QDialogButtonBox::rejected, this, &GameInstallDialog::reject);
connect(actions, &QDialogButtonBox::accepted, this, &GameDirectoryDialog::Save);
connect(actions, &QDialogButtonBox::rejected, this, &GameDirectoryDialog::reject);
return actions;
}
void GameInstallDialog::Save() {
void GameDirectoryDialog::Save() {
// Check games directory.
auto gamesDirectory = m_gamesDirectory->text();
auto addonsDirectory = m_addonsDirectory->text();
if (gamesDirectory.isEmpty() || !QDir(gamesDirectory).exists() ||
!QDir::isAbsolutePath(gamesDirectory)) {
QMessageBox::critical(this, tr("Error"),
"The value for location for games is not valid.");
QMessageBox::critical(this, tr("Error"),"The value location for games is not valid.");
return;
}
if (addonsDirectory.isEmpty() || !QDir::isAbsolutePath(addonsDirectory)) {
QMessageBox::critical(this, tr("Error"),
"The value for location for DLC is not valid.");
QMessageBox::critical(this, tr("Error"),"The value location for DLC is not valid.");
return;
}
QDir addonsDir(addonsDirectory);
if (!addonsDir.exists()) {
if (!addonsDir.mkpath(".")) {
QMessageBox::critical(this, tr("Error"),
"The DLC location could not be created.");
QMessageBox::critical(this, tr("Error"),"The DLC location could not be created.");
return;
}
}
Config::addGameInstallDir(Common::FS::PathFromQString(gamesDirectory));
Config::setAddonInstallDir(Common::FS::PathFromQString(addonsDirectory));
Config::addGameDirectories(Common::FS::PathFromQString(gamesDirectory));
Config::setAddonDirectories(Common::FS::PathFromQString(addonsDirectory));
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
Config::save(config_dir / "config.toml");
accept();

View File

@ -10,11 +10,11 @@
class QLineEdit;
class GameInstallDialog final : public QDialog {
class GameDirectoryDialog final : public QDialog {
Q_OBJECT
public:
GameInstallDialog();
~GameInstallDialog();
GameDirectoryDialog();
~GameDirectoryDialog();
private slots:
void BrowseGamesDirectory();

View File

@ -39,10 +39,10 @@ GameInfoClass::~GameInfoClass() = default;
void GameInfoClass::GetGameInfo(QWidget* parent) {
QStringList filePaths;
for (const auto& installLoc : Config::getGameInstallDirs()) {
QString installDir;
Common::FS::PathToQString(installDir, installLoc);
ScanDirectoryRecursively(installDir, filePaths, 0);
for (const auto& installLoc : Config::getGameDirectories()) {
QString Directories;
Common::FS::PathToQString(Directories, installLoc);
ScanDirectoryRecursively(Directories, filePaths, 0);
}
m_games = QtConcurrent::mapped(filePaths, [&](const QString& path) {

View File

@ -1,125 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <QDialogButtonBox>
#include <QDir>
#include <QFileDialog>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QPushButton>
#include <QVBoxLayout>
#include "game_directory_dialog.h"
GameInstallDialog::GameDirectoryDialog() : m_gamesDirectory(nullptr) {
auto layout = new QVBoxLayout(this);
layout->addWidget(SetupGamesDirectory());
layout->addWidget(SetupAddonsDirectory());
layout->addStretch();
layout->addWidget(SetupDialogActions());
setWindowTitle(tr("shadPS4 - Choose directory"));
setWindowIcon(QIcon(":images/shadps4.ico"));
}
GameInstallDialog::~GameDirectoryDialog() {}
void GameInstallDialog::BrowseGamesDirectory() {
auto path = QFileDialog::getExistingDirectory(this, tr("Games Directory"));
if (!path.isEmpty()) {
m_gamesDirectory->setText(QDir::toNativeSeparators(path));
}
}
void GameInstallDialog::BrowseAddonsDirectory() {
auto path = QFileDialog::getExistingDirectory(this, tr("DLC Directory"));
if (!path.isEmpty()) {
m_addonsDirectory->setText(QDir::toNativeSeparators(path));
}
}
QWidget* GameInstallDialog::SetupGamesDirectory() {
auto group = new QGroupBox(tr("Games Directory"));
auto layout = new QHBoxLayout(group);
layout->addWidget(m_gamesDirectory);
// Browse button.
auto browse = new QPushButton(tr("Browse"));
connect(browse, &QPushButton::clicked, this, &GameInstallDialog::BrowseGamesDirectory);
layout->addWidget(browse);
return group;
}
QWidget* GameInstallDialog::SetupAddonsDirectory() {
auto group = new QGroupBox(tr("DLC Directory"));
auto layout = new QHBoxLayout(group);
// Input.
m_addonsDirectory = new QLineEdit();
QString install_dir;
Common::FS::PathToQString(install_dir, Config::getAddonInstallDir());
m_addonsDirectory->setText(install_dir);
m_addonsDirectory->setMinimumWidth(400);
layout->addWidget(m_addonsDirectory);
// Browse button.
auto browse = new QPushButton(tr("Browse"));
connect(browse, &QPushButton::clicked, this, &GameInstallDialog::BrowseAddonsDirectory);
layout->addWidget(browse);
return group;
}
QWidget* GameInstallDialog::SetupDialogActions() {
auto actions = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(actions, &QDialogButtonBox::accepted, this, &GameInstallDialog::Save);
connect(actions, &QDialogButtonBox::rejected, this, &GameInstallDialog::reject);
return actions;
}
void GameInstallDialog::Save() {
// Check games directory.
auto gamesDirectory = m_gamesDirectory->text();
auto addonsDirectory = m_addonsDirectory->text();
if (gamesDirectory.isEmpty() || !QDir(gamesDirectory).exists() ||
!QDir::isAbsolutePath(gamesDirectory)) {
QMessageBox::critical(this, tr("Error"),
"The value for location for games is not valid.");
return;
}
if (addonsDirectory.isEmpty() || !QDir::isAbsolutePath(addonsDirectory)) {
QMessageBox::critical(this, tr("Error"),
"The value for location for DLC is not valid.");
return;
}
QDir addonsDir(addonsDirectory);
if (!addonsDir.exists()) {
if (!addonsDir.mkpath(".")) {
QMessageBox::critical(this, tr("Error"),
"The DLC location could not be created.");
return;
}
}
Config::addGameInstallDir(Common::FS::PathFromQString(gamesDirectory));
Config::setAddonInstallDir(Common::FS::PathFromQString(addonsDirectory));
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
Config::save(config_dir / "config.toml");
accept();
}

View File

@ -1,32 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <QDialog>
#include "common/config.h"
#include "common/path_util.h"
class QLineEdit;
class GameInstallDialog final : public QDialog {
Q_OBJECT
public:
GameDirectoryDialog();
~GameDirectoryDialog();
private slots:
void BrowseGamesDirectory();
void BrowseAddonsDirectory();
private:
QWidget* SetupGamesDirectory();
QWidget* SetupAddonsDirectory();
QWidget* SetupDialogActions();
void Save();
private:
QLineEdit* m_gamesDirectory;
QLineEdit* m_addonsDirectory;
};

View File

@ -504,7 +504,7 @@ public:
game_update_path = folder_path + "-patch";
}
Common::FS::PathToQString(
dlc_path, Config::getAddonInstallDir() /
dlc_path, Config::getAddonDirectories() /
Common::FS::PathFromQString(folder_path).parent_path().filename());
Common::FS::PathToQString(save_data_path,
Config::GetSaveDataPath() / "1" / m_games[itemID].save_dir);

View File

@ -219,7 +219,7 @@ bool EditorDialog::hasUnsavedChanges() {
void EditorDialog::loadInstalledGames() {
previous_game = "default";
QStringList filePaths;
for (const auto& installLoc : Config::getGameInstallDirs()) {
for (const auto& installLoc : Config::getGameDirectories()) {
QString installDir;
Common::FS::PathToQString(installDir, installLoc);
QDir parentFolder(installDir);

View File

@ -124,7 +124,7 @@ int main(int argc, char* argv[]) {
exit(1);
}
Config::addGameInstallDir(config_path);
Config::addGameDirectories(config_path);
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
std::cout << "Game folder successfully saved.\n";
exit(0);
@ -162,8 +162,8 @@ int main(int argc, char* argv[]) {
}
// If no game directories are set and no command line argument, prompt for it
if (Config::getGameInstallDirsEnabled().empty() && !has_command_line_argument) {
GameInstallDialog dlg;
if (Config::getGameDirectoriesEnabled().empty() && !has_command_line_argument) {
GameDirectoryDialog dlg;
dlg.exec();
}
@ -190,8 +190,8 @@ int main(int argc, char* argv[]) {
// If not a file, treat it as a game ID and search in install directories recursively
bool game_found = false;
const int max_depth = 5;
for (const auto& install_dir : Config::getGameInstallDirs()) {
if (auto found_path = Common::FS::FindGameByID(install_dir, game_path, max_depth)) {
for (const auto& directories : Config::getGameDirectories()) {
if (auto found_path = Common::FS::FindGameByID(directories, game_path, max_depth)) {
game_file_path = *found_path;
game_found = true;
break;

View File

@ -710,9 +710,8 @@ void MainWindow::CreateConnects() {
}
});
// Package install.
connect(ui->bootGameAct, &QAction::triggered, this, &MainWindow::BootGame);
connect(ui->gameInstallPathAct, &QAction::triggered, this, &MainWindow::InstallDirectory);
connect(ui->gamePathAct, &QAction::triggered, this, &MainWindow::Directories);
// elf viewer
connect(ui->addElfFolderAct, &QAction::triggered, m_elf_viewer.data(),
@ -973,8 +972,8 @@ void MainWindow::BootGame() {
}
}
void MainWindow::InstallDirectory() {
GameInstallDialog dlg;
void MainWindow::Directories() {
GameDirectoryDialog dlg;
dlg.exec();
RefreshGameTable();
}
@ -1085,7 +1084,7 @@ void MainWindow::SetUiIcons(bool isWhite) {
ui->aboutAct->setIcon(RecolorIcon(ui->aboutAct->icon(), isWhite));
ui->setlistModeListAct->setIcon(RecolorIcon(ui->setlistModeListAct->icon(), isWhite));
ui->setlistModeGridAct->setIcon(RecolorIcon(ui->setlistModeGridAct->icon(), isWhite));
ui->gameInstallPathAct->setIcon(RecolorIcon(ui->gameInstallPathAct->icon(), isWhite));
ui->gamePathAct->setIcon(RecolorIcon(ui->gamePathAct->icon(), isWhite));
ui->menuThemes->setIcon(RecolorIcon(ui->menuThemes->icon(), isWhite));
ui->menuGame_List_Icons->setIcon(RecolorIcon(ui->menuGame_List_Icons->icon(), isWhite));
ui->menuUtils->setIcon(RecolorIcon(ui->menuUtils->icon(), isWhite));

View File

@ -35,7 +35,7 @@ public:
explicit MainWindow(QWidget* parent = nullptr);
~MainWindow();
bool Init();
void InstallDirectory();
void Directories();
void StartGame();
void PauseGame();
bool showLabels;
@ -118,7 +118,7 @@ protected:
void resizeEvent(QResizeEvent* event) override;
std::filesystem::path last_install_dir = "";
std::filesystem::path last_directories = "";
bool delete_file_on_install = false;
bool use_for_all_queued = false;
};

View File

@ -23,7 +23,7 @@ public:
QAction* setlistModeListAct;
QAction* setlistModeGridAct;
QAction* setlistElfAct;
QAction* gameInstallPathAct;
QAction* gamePathAct;
QAction* downloadCheatsPatchesAct;
QAction* dumpGameListAct;
QAction* trophyViewerAct;
@ -131,9 +131,9 @@ public:
setlistElfAct = new QAction(MainWindow);
setlistElfAct->setObjectName("setlistElfAct");
setlistElfAct->setCheckable(true);
gameInstallPathAct = new QAction(MainWindow);
gameInstallPathAct->setObjectName("gameInstallPathAct");
gameInstallPathAct->setIcon(QIcon(":images/folder_icon.png"));
gamePathAct = new QAction(MainWindow);
gamePathAct->setObjectName("gamePathAct");
gamePathAct->setIcon(QIcon(":images/folder_icon.png"));
downloadCheatsPatchesAct = new QAction(MainWindow);
downloadCheatsPatchesAct->setObjectName("downloadCheatsPatchesAct");
downloadCheatsPatchesAct->setIcon(QIcon(":images/update_icon.png"));
@ -329,7 +329,7 @@ public:
menuGame_List_Mode->addAction(setlistModeGridAct);
menuGame_List_Mode->addAction(setlistElfAct);
menuSettings->addAction(configureAct);
menuSettings->addAction(gameInstallPathAct);
menuSettings->addAction(gamePathAct);
menuSettings->addAction(menuUtils->menuAction());
menuUtils->addAction(downloadCheatsPatchesAct);
menuUtils->addAction(dumpGameListAct);
@ -381,8 +381,8 @@ public:
setlistModeGridAct->setText(
QCoreApplication::translate("MainWindow", "Grid View", nullptr));
setlistElfAct->setText(QCoreApplication::translate("MainWindow", "Elf Viewer", nullptr));
gameInstallPathAct->setText(
QCoreApplication::translate("MainWindow", "Game Install Directory", nullptr));
gamePathAct->setText(
QCoreApplication::translate("MainWindow", "Game Directory", nullptr));
downloadCheatsPatchesAct->setText(
QCoreApplication::translate("MainWindow", "Download Cheats/Patches", nullptr));
dumpGameListAct->setText(

View File

@ -267,9 +267,9 @@ SettingsDialog::SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
{
connect(ui->addFolderButton, &QPushButton::clicked, this, [this]() {
QString file_path_string =
QFileDialog::getExistingDirectory(this, tr("Directory to install games"));
QFileDialog::getExistingDirectory(this, tr("Games directories"));
auto file_path = Common::FS::PathFromQString(file_path_string);
if (!file_path.empty() && Config::addGameInstallDir(file_path, true)) {
if (!file_path.empty() && Config::addGameDirectories(file_path, true)) {
QListWidgetItem* item = new QListWidgetItem(file_path_string);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(Qt::Checked);
@ -287,7 +287,7 @@ SettingsDialog::SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
QString item_path_string = selected_item ? selected_item->text() : QString();
if (!item_path_string.isEmpty()) {
auto file_path = Common::FS::PathFromQString(item_path_string);
Config::removeGameInstallDir(file_path);
Config::removeGameDirectories(file_path);
delete selected_item;
}
});
@ -793,7 +793,7 @@ void SettingsDialog::UpdateSettings() {
m_gui_settings->SetValue(gui::gl_showBackgroundImage,
ui->showBackgroundImageCheckBox->isChecked());
std::vector<Config::GameInstallDir> dirs_with_states;
std::vector<Config::GameDirectories> dirs_with_states;
for (int i = 0; i < ui->gameFoldersListWidget->count(); i++) {
QListWidgetItem* item = ui->gameFoldersListWidget->item(i);
QString path_string = item->text();
@ -802,7 +802,7 @@ void SettingsDialog::UpdateSettings() {
dirs_with_states.push_back({path, enabled});
}
Config::setAllGameInstallDirs(dirs_with_states);
Config::setAllGameDirectories(dirs_with_states);
#ifdef ENABLE_DISCORD_RPC
auto* rpc = Common::Singleton<DiscordRPCHandler::RPC>::Instance();
@ -825,28 +825,28 @@ void SettingsDialog::ResetInstallFolders() {
if (data.contains("GUI")) {
const toml::value& gui = data.at("GUI");
const auto install_dir_array =
toml::find_or<std::vector<std::u8string>>(gui, "installDirs", {});
const auto directories_array =
toml::find_or<std::vector<std::u8string>>(gui, "directories", {});
std::vector<bool> install_dirs_enabled;
std::vector<bool> directories_enabled;
try {
install_dirs_enabled = Config::getGameInstallDirsEnabled();
directories_enabled = Config::getGameDirectoriesEnabled();
} catch (...) {
// If it does not exist, assume that all are enabled.
install_dirs_enabled.resize(install_dir_array.size(), true);
directories_enabled.resize(directories_array.size(), true);
}
if (install_dirs_enabled.size() < install_dir_array.size()) {
install_dirs_enabled.resize(install_dir_array.size(), true);
if (directories_enabled.size() < directories_array.size()) {
directories_enabled.resize(directories_array.size(), true);
}
std::vector<Config::GameInstallDir> settings_install_dirs_config;
std::vector<Config::GameDirectories> settings_directories_config;
for (size_t i = 0; i < install_dir_array.size(); i++) {
std::filesystem::path dir = install_dir_array[i];
bool enabled = install_dirs_enabled[i];
for (size_t i = 0; i < directories_array.size(); i++) {
std::filesystem::path dir = directories_array[i];
bool enabled = directories_enabled[i];
settings_install_dirs_config.push_back({dir, enabled});
settings_directories_config.push_back({dir, enabled});
QString path_string;
Common::FS::PathToQString(path_string, dir);
@ -857,7 +857,7 @@ void SettingsDialog::ResetInstallFolders() {
ui->gameFoldersListWidget->addItem(item);
}
Config::setAllGameInstallDirs(settings_install_dirs_config);
Config::setAllGameDirectories(settings_directories_config);
}
}
void SettingsDialog::setDefaultValues() {