mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-22 18:15:14 +00:00
more cleaning
This commit is contained in:
parent
fa2c82e9a3
commit
76f58e0cda
@ -76,10 +76,10 @@ static bool isPSNSignedIn = false;
|
|||||||
|
|
||||||
// Gui
|
// Gui
|
||||||
static bool load_game_size = true;
|
static bool load_game_size = true;
|
||||||
static std::vector<GameInstallDir> settings_install_dirs = {};
|
static std::vector<GameDirectories> settings_directories = {};
|
||||||
std::vector<bool> install_dirs_enabled = {};
|
static std::vector<bool> directories_enabled = {};
|
||||||
std::filesystem::path settings_addon_install_dir = {};
|
static std::filesystem::path settings_addon_directories = {};
|
||||||
std::filesystem::path save_data_path = {};
|
static std::filesystem::path save_data_path = {};
|
||||||
static bool isFullscreen = false;
|
static bool isFullscreen = false;
|
||||||
static std::string fullscreenMode = "Windowed";
|
static std::string fullscreenMode = "Windowed";
|
||||||
static bool isHDRAllowed = false;
|
static bool isHDRAllowed = false;
|
||||||
@ -439,56 +439,56 @@ void setCheckCompatibilityOnStartup(bool use) {
|
|||||||
checkCompatibilityOnStartup = use;
|
checkCompatibilityOnStartup = use;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool addGameInstallDir(const std::filesystem::path& dir, bool enabled) {
|
bool addGameDirectories(const std::filesystem::path& dir, bool enabled) {
|
||||||
for (const auto& install_dir : settings_install_dirs) {
|
for (const auto& directories : settings_directories) {
|
||||||
if (install_dir.path == dir) {
|
if (directories.path == dir) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings_install_dirs.push_back({dir, enabled});
|
settings_directories.push_back({dir, enabled});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeGameInstallDir(const std::filesystem::path& dir) {
|
void removeGameDirectories(const std::filesystem::path& dir) {
|
||||||
auto iterator =
|
auto iterator = std::find_if(
|
||||||
std::find_if(settings_install_dirs.begin(), settings_install_dirs.end(),
|
settings_directories.begin(), settings_directories.end(),
|
||||||
[&dir](const GameInstallDir& install_dir) { return install_dir.path == dir; });
|
[&dir](const GameDirectories& directories) { return directories.path == dir; });
|
||||||
if (iterator != settings_install_dirs.end()) {
|
if (iterator != settings_directories.end()) {
|
||||||
settings_install_dirs.erase(iterator);
|
settings_directories.erase(iterator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled) {
|
void setGameDirectoriesEnabled(const std::filesystem::path& dir, bool enabled) {
|
||||||
auto iterator =
|
auto iterator = std::find_if(
|
||||||
std::find_if(settings_install_dirs.begin(), settings_install_dirs.end(),
|
settings_directories.begin(), settings_directories.end(),
|
||||||
[&dir](const GameInstallDir& install_dir) { return install_dir.path == dir; });
|
[&dir](const GameDirectories& directories) { return directories.path == dir; });
|
||||||
if (iterator != settings_install_dirs.end()) {
|
if (iterator != settings_directories.end()) {
|
||||||
iterator->enabled = enabled;
|
iterator->enabled = enabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAddonInstallDir(const std::filesystem::path& dir) {
|
void setAddonDirectories(const std::filesystem::path& dir) {
|
||||||
settings_addon_install_dir = dir;
|
settings_addon_directories = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config) {
|
void setGameDirectories(const std::vector<std::filesystem::path>& dirs_config) {
|
||||||
settings_install_dirs.clear();
|
settings_directories.clear();
|
||||||
for (const auto& dir : dirs_config) {
|
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) {
|
void setAllGameDirectories(const std::vector<GameDirectories>& dirs_config) {
|
||||||
settings_install_dirs = dirs_config;
|
settings_directories = dirs_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSaveDataPath(const std::filesystem::path& path) {
|
void setSaveDataPath(const std::filesystem::path& path) {
|
||||||
save_data_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;
|
std::vector<std::filesystem::path> enabled_dirs;
|
||||||
for (const auto& dir : settings_install_dirs) {
|
for (const auto& dir : settings_directories) {
|
||||||
if (dir.enabled) {
|
if (dir.enabled) {
|
||||||
enabled_dirs.push_back(dir.path);
|
enabled_dirs.push_back(dir.path);
|
||||||
}
|
}
|
||||||
@ -496,20 +496,20 @@ const std::vector<std::filesystem::path> getGameInstallDirs() {
|
|||||||
return enabled_dirs;
|
return enabled_dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<bool> getGameInstallDirsEnabled() {
|
const std::vector<bool> getGameDirsEnabled() {
|
||||||
std::vector<bool> enabled_dirs;
|
std::vector<bool> enabled_dirs;
|
||||||
for (const auto& dir : settings_install_dirs) {
|
for (const auto& dir : settings_directories) {
|
||||||
enabled_dirs.push_back(dir.enabled);
|
enabled_dirs.push_back(dir.enabled);
|
||||||
}
|
}
|
||||||
return enabled_dirs;
|
return enabled_dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path getAddonInstallDir() {
|
std::filesystem::path getAddonDirectory() {
|
||||||
if (settings_addon_install_dir.empty()) {
|
if (settings_addon_directories.empty()) {
|
||||||
// Default for users without a config file or a config file from before this option existed
|
// 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 Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "addcont";
|
||||||
}
|
}
|
||||||
return settings_addon_install_dir;
|
return settings_addon_directories;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetLanguage() {
|
u32 GetLanguage() {
|
||||||
@ -621,29 +621,29 @@ void load(const std::filesystem::path& path) {
|
|||||||
|
|
||||||
load_game_size = toml::find_or<bool>(gui, "loadGameSizeEnabled", true);
|
load_game_size = toml::find_or<bool>(gui, "loadGameSizeEnabled", true);
|
||||||
|
|
||||||
const auto install_dir_array =
|
const auto directories_array =
|
||||||
toml::find_or<std::vector<std::u8string>>(gui, "installDirs", {});
|
toml::find_or<std::vector<std::u8string>>(gui, "Directories", {});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
install_dirs_enabled = toml::find<std::vector<bool>>(gui, "installDirsEnabled");
|
directories_enabled = toml::find<std::vector<bool>>(gui, "DirectoriesEnabled");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// If it does not exist, assume that all are enabled.
|
// 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()) {
|
if (directories_enabled.size() < directories_array.size()) {
|
||||||
install_dirs_enabled.resize(install_dir_array.size(), true);
|
directories_enabled.resize(directories_array.size(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_install_dirs.clear();
|
settings_directories.clear();
|
||||||
for (size_t i = 0; i < install_dir_array.size(); i++) {
|
for (size_t i = 0; i < directories_array.size(); i++) {
|
||||||
settings_install_dirs.push_back(
|
settings_directories.push_back(
|
||||||
{std::filesystem::path{install_dir_array[i]}, install_dirs_enabled[i]});
|
{std::filesystem::path{directories_array[i]}, directories_enabled[i]});
|
||||||
}
|
}
|
||||||
|
|
||||||
save_data_path = toml::find_fs_path_or(gui, "saveDataPath", {});
|
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")) {
|
if (data.contains("Settings")) {
|
||||||
@ -755,8 +755,8 @@ void save(const std::filesystem::path& path) {
|
|||||||
data["Debug"]["FPSColor"] = isFpsColor;
|
data["Debug"]["FPSColor"] = isFpsColor;
|
||||||
data["Keys"]["TrophyKey"] = trophyKey;
|
data["Keys"]["TrophyKey"] = trophyKey;
|
||||||
|
|
||||||
std::vector<std::string> install_dirs;
|
std::vector<std::string> directories;
|
||||||
std::vector<bool> install_dirs_enabled;
|
std::vector<bool> directories_enabled;
|
||||||
|
|
||||||
// temporary structure for ordering
|
// temporary structure for ordering
|
||||||
struct DirEntry {
|
struct DirEntry {
|
||||||
@ -765,7 +765,7 @@ void save(const std::filesystem::path& path) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector<DirEntry> sorted_dirs;
|
std::vector<DirEntry> sorted_dirs;
|
||||||
for (const auto& dirInfo : settings_install_dirs) {
|
for (const auto& dirInfo : settings_directories) {
|
||||||
sorted_dirs.push_back(
|
sorted_dirs.push_back(
|
||||||
{std::string{fmt::UTF(dirInfo.path.u8string()).data}, dirInfo.enabled});
|
{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) {
|
for (const auto& entry : sorted_dirs) {
|
||||||
install_dirs.push_back(entry.path_str);
|
directories.push_back(entry.path_str);
|
||||||
install_dirs_enabled.push_back(entry.enabled);
|
directories_enabled.push_back(entry.enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
data["GUI"]["installDirs"] = install_dirs;
|
data["GUI"]["Directories"] = directories;
|
||||||
data["GUI"]["installDirsEnabled"] = install_dirs_enabled;
|
data["GUI"]["DirectoriesEnabled"] = directories_enabled;
|
||||||
data["GUI"]["saveDataPath"] = std::string{fmt::UTF(save_data_path.u8string()).data};
|
data["GUI"]["saveDataPath"] = std::string{fmt::UTF(save_data_path.u8string()).data};
|
||||||
data["GUI"]["loadGameSizeEnabled"] = load_game_size;
|
data["GUI"]["loadGameSizeEnabled"] = load_game_size;
|
||||||
|
|
||||||
data["GUI"]["addonInstallDir"] =
|
data["GUI"]["addonDirectories"] =
|
||||||
std::string{fmt::UTF(settings_addon_install_dir.u8string()).data};
|
std::string{fmt::UTF(settings_addon_directories.u8string()).data};
|
||||||
data["Settings"]["consoleLanguage"] = m_language;
|
data["Settings"]["consoleLanguage"] = m_language;
|
||||||
|
|
||||||
// Sorting of TOML sections
|
// Sorting of TOML sections
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
namespace Config {
|
namespace Config {
|
||||||
|
|
||||||
struct GameInstallDir {
|
struct GameDirectories {
|
||||||
std::filesystem::path path;
|
std::filesystem::path path;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
};
|
};
|
||||||
@ -110,20 +110,20 @@ int* GetControllerCustomColor();
|
|||||||
void SetControllerCustomColor(int r, int b, int g);
|
void SetControllerCustomColor(int r, int b, int g);
|
||||||
void setUserName(const std::string& type);
|
void setUserName(const std::string& type);
|
||||||
void setChooseHomeTab(const std::string& type);
|
void setChooseHomeTab(const std::string& type);
|
||||||
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config);
|
void setGameDirectories(const std::vector<std::filesystem::path>& dirs_config);
|
||||||
void setAllGameInstallDirs(const std::vector<GameInstallDir>& dirs_config);
|
void setAllGameDirectories(const std::vector<GameDirectories>& dirs_config);
|
||||||
void setSaveDataPath(const std::filesystem::path& path);
|
void setSaveDataPath(const std::filesystem::path& path);
|
||||||
void setCompatibilityEnabled(bool use);
|
void setCompatibilityEnabled(bool use);
|
||||||
void setCheckCompatibilityOnStartup(bool use);
|
void setCheckCompatibilityOnStartup(bool use);
|
||||||
// Gui
|
// Gui
|
||||||
bool addGameInstallDir(const std::filesystem::path& dir, bool enabled = true);
|
bool addGameDirectories(const std::filesystem::path& dir, bool enabled = true);
|
||||||
void removeGameInstallDir(const std::filesystem::path& dir);
|
void removeGameDirectories(const std::filesystem::path& dir);
|
||||||
void setGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled);
|
void setGameDirectoriesEnabled(const std::filesystem::path& dir, bool enabled);
|
||||||
void setAddonInstallDir(const std::filesystem::path& dir);
|
void setAddonDirectories(const std::filesystem::path& dir);
|
||||||
|
|
||||||
const std::vector<std::filesystem::path> getGameInstallDirs();
|
const std::vector<std::filesystem::path>& getGameDirectories();
|
||||||
const std::vector<bool> getGameInstallDirsEnabled();
|
const std::vector<bool>& getGameDirectoriesEnabled();
|
||||||
std::filesystem::path getAddonInstallDir();
|
const std::filesystem::path& getAddonDirectories();
|
||||||
|
|
||||||
void setDefaultValues();
|
void setDefaultValues();
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ int PS4_SYSV_ABI sceAppContentAddcontMount(u32 service_label,
|
|||||||
OrbisAppContentMountPoint* mount_point) {
|
OrbisAppContentMountPoint* mount_point) {
|
||||||
LOG_INFO(Lib_AppContent, "called");
|
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();
|
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
|
||||||
|
|
||||||
for (int i = 0; i < addcont_count; i++) {
|
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");
|
LOG_ERROR(Lib_AppContent, "(DUMMY) called");
|
||||||
auto* param_sfo = Common::Singleton<PSF>::Instance();
|
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()) {
|
if (const auto value = param_sfo->GetString("TITLE_ID"); value.has_value()) {
|
||||||
title_id = *value;
|
title_id = *value;
|
||||||
} else {
|
} else {
|
||||||
|
10
src/main.cpp
10
src/main.cpp
@ -112,7 +112,7 @@ int main(int argc, char* argv[]) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::addGameInstallDir(config_path);
|
Config::addGameDirectories(config_path);
|
||||||
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
||||||
std::cout << "Game folder successfully saved.\n";
|
std::cout << "Game folder successfully saved.\n";
|
||||||
exit(0);
|
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 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"
|
std::cout << "Warning: No game folder set, please set it by calling shadps4"
|
||||||
" with the --add-game-folder <folder_name> argument\n";
|
" 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
|
// Check if the provided path is a valid file
|
||||||
if (!std::filesystem::exists(eboot_path)) {
|
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;
|
bool game_found = false;
|
||||||
const int max_depth = 5;
|
const int max_depth = 5;
|
||||||
for (const auto& install_dir : Config::getGameInstallDirs()) {
|
for (const auto& directories : Config::getGameDirectories()) {
|
||||||
if (auto found_path = Common::FS::FindGameByID(install_dir, game_path, max_depth)) {
|
if (auto found_path = Common::FS::FindGameByID(directories, game_path, max_depth)) {
|
||||||
eboot_path = *found_path;
|
eboot_path = *found_path;
|
||||||
game_found = true;
|
game_found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -12,9 +12,9 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#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);
|
auto layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
layout->addWidget(SetupGamesDirectory());
|
layout->addWidget(SetupGamesDirectory());
|
||||||
@ -26,9 +26,9 @@ GameInstallDialog::GameInstallDialog() : m_gamesDirectory(nullptr) {
|
|||||||
setWindowIcon(QIcon(":images/shadps4.ico"));
|
setWindowIcon(QIcon(":images/shadps4.ico"));
|
||||||
}
|
}
|
||||||
|
|
||||||
GameInstallDialog::~GameInstallDialog() {}
|
GameDirectoryDialog::~GameDirectoryDialog() {}
|
||||||
|
|
||||||
void GameInstallDialog::BrowseGamesDirectory() {
|
void GameDirectoryDialog::BrowseGamesDirectory() {
|
||||||
auto path = QFileDialog::getExistingDirectory(this, tr("Games Directory"));
|
auto path = QFileDialog::getExistingDirectory(this, tr("Games Directory"));
|
||||||
|
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
@ -36,7 +36,7 @@ void GameInstallDialog::BrowseGamesDirectory() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameInstallDialog::BrowseAddonsDirectory() {
|
void GameDirectoryDialog::BrowseAddonsDirectory() {
|
||||||
auto path = QFileDialog::getExistingDirectory(this, tr("DLC Directory"));
|
auto path = QFileDialog::getExistingDirectory(this, tr("DLC Directory"));
|
||||||
|
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
@ -44,7 +44,7 @@ void GameInstallDialog::BrowseAddonsDirectory() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* GameInstallDialog::SetupGamesDirectory() {
|
QWidget* GameDirectoryDialog::SetupGamesDirectory() {
|
||||||
auto group = new QGroupBox(tr("Games Directory"));
|
auto group = new QGroupBox(tr("Games Directory"));
|
||||||
auto layout = new QHBoxLayout(group);
|
auto layout = new QHBoxLayout(group);
|
||||||
|
|
||||||
@ -53,22 +53,22 @@ QWidget* GameInstallDialog::SetupGamesDirectory() {
|
|||||||
// Browse button.
|
// Browse button.
|
||||||
auto browse = new QPushButton(tr("Browse"));
|
auto browse = new QPushButton(tr("Browse"));
|
||||||
|
|
||||||
connect(browse, &QPushButton::clicked, this, &GameInstallDialog::BrowseGamesDirectory);
|
connect(browse, &QPushButton::clicked, this, &GameDirectoryDialog::BrowseGamesDirectory);
|
||||||
|
|
||||||
layout->addWidget(browse);
|
layout->addWidget(browse);
|
||||||
|
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* GameInstallDialog::SetupAddonsDirectory() {
|
QWidget* GameDirectoryDialog::SetupAddonsDirectory() {
|
||||||
auto group = new QGroupBox(tr("DLC Directory"));
|
auto group = new QGroupBox(tr("DLC Directory"));
|
||||||
auto layout = new QHBoxLayout(group);
|
auto layout = new QHBoxLayout(group);
|
||||||
|
|
||||||
// Input.
|
// Input.
|
||||||
m_addonsDirectory = new QLineEdit();
|
m_addonsDirectory = new QLineEdit();
|
||||||
QString install_dir;
|
QString directories;
|
||||||
Common::FS::PathToQString(install_dir, Config::getAddonInstallDir());
|
Common::FS::PathToQString(directories, Config::getAddonDirectories());
|
||||||
m_addonsDirectory->setText(install_dir);
|
m_addonsDirectory->setText(directories);
|
||||||
m_addonsDirectory->setMinimumWidth(400);
|
m_addonsDirectory->setMinimumWidth(400);
|
||||||
|
|
||||||
layout->addWidget(m_addonsDirectory);
|
layout->addWidget(m_addonsDirectory);
|
||||||
@ -76,49 +76,46 @@ QWidget* GameInstallDialog::SetupAddonsDirectory() {
|
|||||||
// Browse button.
|
// Browse button.
|
||||||
auto browse = new QPushButton(tr("Browse"));
|
auto browse = new QPushButton(tr("Browse"));
|
||||||
|
|
||||||
connect(browse, &QPushButton::clicked, this, &GameInstallDialog::BrowseAddonsDirectory);
|
connect(browse, &QPushButton::clicked, this, &GameDirectoryDialog::BrowseAddonsDirectory);
|
||||||
|
|
||||||
layout->addWidget(browse);
|
layout->addWidget(browse);
|
||||||
|
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* GameInstallDialog::SetupDialogActions() {
|
QWidget* GameDirectoryDialog::SetupDialogActions() {
|
||||||
auto actions = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
auto actions = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
connect(actions, &QDialogButtonBox::accepted, this, &GameInstallDialog::Save);
|
connect(actions, &QDialogButtonBox::accepted, this, &GameDirectoryDialog::Save);
|
||||||
connect(actions, &QDialogButtonBox::rejected, this, &GameInstallDialog::reject);
|
connect(actions, &QDialogButtonBox::rejected, this, &GameDirectoryDialog::reject);
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameInstallDialog::Save() {
|
void GameDirectoryDialog::Save() {
|
||||||
// Check games directory.
|
// Check games directory.
|
||||||
auto gamesDirectory = m_gamesDirectory->text();
|
auto gamesDirectory = m_gamesDirectory->text();
|
||||||
auto addonsDirectory = m_addonsDirectory->text();
|
auto addonsDirectory = m_addonsDirectory->text();
|
||||||
|
|
||||||
if (gamesDirectory.isEmpty() || !QDir(gamesDirectory).exists() ||
|
if (gamesDirectory.isEmpty() || !QDir(gamesDirectory).exists() ||
|
||||||
!QDir::isAbsolutePath(gamesDirectory)) {
|
!QDir::isAbsolutePath(gamesDirectory)) {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),"The value location for games is not valid.");
|
||||||
"The value for location for games is not valid.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addonsDirectory.isEmpty() || !QDir::isAbsolutePath(addonsDirectory)) {
|
if (addonsDirectory.isEmpty() || !QDir::isAbsolutePath(addonsDirectory)) {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),"The value location for DLC is not valid.");
|
||||||
"The value for location for DLC is not valid.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QDir addonsDir(addonsDirectory);
|
QDir addonsDir(addonsDirectory);
|
||||||
if (!addonsDir.exists()) {
|
if (!addonsDir.exists()) {
|
||||||
if (!addonsDir.mkpath(".")) {
|
if (!addonsDir.mkpath(".")) {
|
||||||
QMessageBox::critical(this, tr("Error"),
|
QMessageBox::critical(this, tr("Error"),"The DLC location could not be created.");
|
||||||
"The DLC location could not be created.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Config::addGameInstallDir(Common::FS::PathFromQString(gamesDirectory));
|
Config::addGameDirectories(Common::FS::PathFromQString(gamesDirectory));
|
||||||
Config::setAddonInstallDir(Common::FS::PathFromQString(addonsDirectory));
|
Config::setAddonDirectories(Common::FS::PathFromQString(addonsDirectory));
|
||||||
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||||
Config::save(config_dir / "config.toml");
|
Config::save(config_dir / "config.toml");
|
||||||
accept();
|
accept();
|
||||||
|
@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
|
|
||||||
class GameInstallDialog final : public QDialog {
|
class GameDirectoryDialog final : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GameInstallDialog();
|
GameDirectoryDialog();
|
||||||
~GameInstallDialog();
|
~GameDirectoryDialog();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void BrowseGamesDirectory();
|
void BrowseGamesDirectory();
|
||||||
|
@ -39,10 +39,10 @@ GameInfoClass::~GameInfoClass() = default;
|
|||||||
|
|
||||||
void GameInfoClass::GetGameInfo(QWidget* parent) {
|
void GameInfoClass::GetGameInfo(QWidget* parent) {
|
||||||
QStringList filePaths;
|
QStringList filePaths;
|
||||||
for (const auto& installLoc : Config::getGameInstallDirs()) {
|
for (const auto& installLoc : Config::getGameDirectories()) {
|
||||||
QString installDir;
|
QString Directories;
|
||||||
Common::FS::PathToQString(installDir, installLoc);
|
Common::FS::PathToQString(Directories, installLoc);
|
||||||
ScanDirectoryRecursively(installDir, filePaths, 0);
|
ScanDirectoryRecursively(Directories, filePaths, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_games = QtConcurrent::mapped(filePaths, [&](const QString& path) {
|
m_games = QtConcurrent::mapped(filePaths, [&](const QString& path) {
|
||||||
|
@ -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();
|
|
||||||
}
|
|
@ -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;
|
|
||||||
};
|
|
@ -504,7 +504,7 @@ public:
|
|||||||
game_update_path = folder_path + "-patch";
|
game_update_path = folder_path + "-patch";
|
||||||
}
|
}
|
||||||
Common::FS::PathToQString(
|
Common::FS::PathToQString(
|
||||||
dlc_path, Config::getAddonInstallDir() /
|
dlc_path, Config::getAddonDirectories() /
|
||||||
Common::FS::PathFromQString(folder_path).parent_path().filename());
|
Common::FS::PathFromQString(folder_path).parent_path().filename());
|
||||||
Common::FS::PathToQString(save_data_path,
|
Common::FS::PathToQString(save_data_path,
|
||||||
Config::GetSaveDataPath() / "1" / m_games[itemID].save_dir);
|
Config::GetSaveDataPath() / "1" / m_games[itemID].save_dir);
|
||||||
|
@ -219,7 +219,7 @@ bool EditorDialog::hasUnsavedChanges() {
|
|||||||
void EditorDialog::loadInstalledGames() {
|
void EditorDialog::loadInstalledGames() {
|
||||||
previous_game = "default";
|
previous_game = "default";
|
||||||
QStringList filePaths;
|
QStringList filePaths;
|
||||||
for (const auto& installLoc : Config::getGameInstallDirs()) {
|
for (const auto& installLoc : Config::getGameDirectories()) {
|
||||||
QString installDir;
|
QString installDir;
|
||||||
Common::FS::PathToQString(installDir, installLoc);
|
Common::FS::PathToQString(installDir, installLoc);
|
||||||
QDir parentFolder(installDir);
|
QDir parentFolder(installDir);
|
||||||
|
@ -124,7 +124,7 @@ int main(int argc, char* argv[]) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::addGameInstallDir(config_path);
|
Config::addGameDirectories(config_path);
|
||||||
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
||||||
std::cout << "Game folder successfully saved.\n";
|
std::cout << "Game folder successfully saved.\n";
|
||||||
exit(0);
|
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 no game directories are set and no command line argument, prompt for it
|
||||||
if (Config::getGameInstallDirsEnabled().empty() && !has_command_line_argument) {
|
if (Config::getGameDirectoriesEnabled().empty() && !has_command_line_argument) {
|
||||||
GameInstallDialog dlg;
|
GameDirectoryDialog dlg;
|
||||||
dlg.exec();
|
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
|
// If not a file, treat it as a game ID and search in install directories recursively
|
||||||
bool game_found = false;
|
bool game_found = false;
|
||||||
const int max_depth = 5;
|
const int max_depth = 5;
|
||||||
for (const auto& install_dir : Config::getGameInstallDirs()) {
|
for (const auto& directories : Config::getGameDirectories()) {
|
||||||
if (auto found_path = Common::FS::FindGameByID(install_dir, game_path, max_depth)) {
|
if (auto found_path = Common::FS::FindGameByID(directories, game_path, max_depth)) {
|
||||||
game_file_path = *found_path;
|
game_file_path = *found_path;
|
||||||
game_found = true;
|
game_found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -709,10 +709,9 @@ void MainWindow::CreateConnects() {
|
|||||||
.arg(game_path);
|
.arg(game_path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Package install.
|
|
||||||
connect(ui->bootGameAct, &QAction::triggered, this, &MainWindow::BootGame);
|
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
|
// elf viewer
|
||||||
connect(ui->addElfFolderAct, &QAction::triggered, m_elf_viewer.data(),
|
connect(ui->addElfFolderAct, &QAction::triggered, m_elf_viewer.data(),
|
||||||
@ -973,8 +972,8 @@ void MainWindow::BootGame() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::InstallDirectory() {
|
void MainWindow::Directories() {
|
||||||
GameInstallDialog dlg;
|
GameDirectoryDialog dlg;
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
RefreshGameTable();
|
RefreshGameTable();
|
||||||
}
|
}
|
||||||
@ -1085,7 +1084,7 @@ void MainWindow::SetUiIcons(bool isWhite) {
|
|||||||
ui->aboutAct->setIcon(RecolorIcon(ui->aboutAct->icon(), isWhite));
|
ui->aboutAct->setIcon(RecolorIcon(ui->aboutAct->icon(), isWhite));
|
||||||
ui->setlistModeListAct->setIcon(RecolorIcon(ui->setlistModeListAct->icon(), isWhite));
|
ui->setlistModeListAct->setIcon(RecolorIcon(ui->setlistModeListAct->icon(), isWhite));
|
||||||
ui->setlistModeGridAct->setIcon(RecolorIcon(ui->setlistModeGridAct->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->menuThemes->setIcon(RecolorIcon(ui->menuThemes->icon(), isWhite));
|
||||||
ui->menuGame_List_Icons->setIcon(RecolorIcon(ui->menuGame_List_Icons->icon(), isWhite));
|
ui->menuGame_List_Icons->setIcon(RecolorIcon(ui->menuGame_List_Icons->icon(), isWhite));
|
||||||
ui->menuUtils->setIcon(RecolorIcon(ui->menuUtils->icon(), isWhite));
|
ui->menuUtils->setIcon(RecolorIcon(ui->menuUtils->icon(), isWhite));
|
||||||
|
@ -35,7 +35,7 @@ public:
|
|||||||
explicit MainWindow(QWidget* parent = nullptr);
|
explicit MainWindow(QWidget* parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
bool Init();
|
bool Init();
|
||||||
void InstallDirectory();
|
void Directories();
|
||||||
void StartGame();
|
void StartGame();
|
||||||
void PauseGame();
|
void PauseGame();
|
||||||
bool showLabels;
|
bool showLabels;
|
||||||
@ -118,7 +118,7 @@ protected:
|
|||||||
|
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
std::filesystem::path last_install_dir = "";
|
std::filesystem::path last_directories = "";
|
||||||
bool delete_file_on_install = false;
|
bool delete_file_on_install = false;
|
||||||
bool use_for_all_queued = false;
|
bool use_for_all_queued = false;
|
||||||
};
|
};
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
QAction* setlistModeListAct;
|
QAction* setlistModeListAct;
|
||||||
QAction* setlistModeGridAct;
|
QAction* setlistModeGridAct;
|
||||||
QAction* setlistElfAct;
|
QAction* setlistElfAct;
|
||||||
QAction* gameInstallPathAct;
|
QAction* gamePathAct;
|
||||||
QAction* downloadCheatsPatchesAct;
|
QAction* downloadCheatsPatchesAct;
|
||||||
QAction* dumpGameListAct;
|
QAction* dumpGameListAct;
|
||||||
QAction* trophyViewerAct;
|
QAction* trophyViewerAct;
|
||||||
@ -131,9 +131,9 @@ public:
|
|||||||
setlistElfAct = new QAction(MainWindow);
|
setlistElfAct = new QAction(MainWindow);
|
||||||
setlistElfAct->setObjectName("setlistElfAct");
|
setlistElfAct->setObjectName("setlistElfAct");
|
||||||
setlistElfAct->setCheckable(true);
|
setlistElfAct->setCheckable(true);
|
||||||
gameInstallPathAct = new QAction(MainWindow);
|
gamePathAct = new QAction(MainWindow);
|
||||||
gameInstallPathAct->setObjectName("gameInstallPathAct");
|
gamePathAct->setObjectName("gamePathAct");
|
||||||
gameInstallPathAct->setIcon(QIcon(":images/folder_icon.png"));
|
gamePathAct->setIcon(QIcon(":images/folder_icon.png"));
|
||||||
downloadCheatsPatchesAct = new QAction(MainWindow);
|
downloadCheatsPatchesAct = new QAction(MainWindow);
|
||||||
downloadCheatsPatchesAct->setObjectName("downloadCheatsPatchesAct");
|
downloadCheatsPatchesAct->setObjectName("downloadCheatsPatchesAct");
|
||||||
downloadCheatsPatchesAct->setIcon(QIcon(":images/update_icon.png"));
|
downloadCheatsPatchesAct->setIcon(QIcon(":images/update_icon.png"));
|
||||||
@ -329,7 +329,7 @@ public:
|
|||||||
menuGame_List_Mode->addAction(setlistModeGridAct);
|
menuGame_List_Mode->addAction(setlistModeGridAct);
|
||||||
menuGame_List_Mode->addAction(setlistElfAct);
|
menuGame_List_Mode->addAction(setlistElfAct);
|
||||||
menuSettings->addAction(configureAct);
|
menuSettings->addAction(configureAct);
|
||||||
menuSettings->addAction(gameInstallPathAct);
|
menuSettings->addAction(gamePathAct);
|
||||||
menuSettings->addAction(menuUtils->menuAction());
|
menuSettings->addAction(menuUtils->menuAction());
|
||||||
menuUtils->addAction(downloadCheatsPatchesAct);
|
menuUtils->addAction(downloadCheatsPatchesAct);
|
||||||
menuUtils->addAction(dumpGameListAct);
|
menuUtils->addAction(dumpGameListAct);
|
||||||
@ -381,8 +381,8 @@ public:
|
|||||||
setlistModeGridAct->setText(
|
setlistModeGridAct->setText(
|
||||||
QCoreApplication::translate("MainWindow", "Grid View", nullptr));
|
QCoreApplication::translate("MainWindow", "Grid View", nullptr));
|
||||||
setlistElfAct->setText(QCoreApplication::translate("MainWindow", "Elf Viewer", nullptr));
|
setlistElfAct->setText(QCoreApplication::translate("MainWindow", "Elf Viewer", nullptr));
|
||||||
gameInstallPathAct->setText(
|
gamePathAct->setText(
|
||||||
QCoreApplication::translate("MainWindow", "Game Install Directory", nullptr));
|
QCoreApplication::translate("MainWindow", "Game Directory", nullptr));
|
||||||
downloadCheatsPatchesAct->setText(
|
downloadCheatsPatchesAct->setText(
|
||||||
QCoreApplication::translate("MainWindow", "Download Cheats/Patches", nullptr));
|
QCoreApplication::translate("MainWindow", "Download Cheats/Patches", nullptr));
|
||||||
dumpGameListAct->setText(
|
dumpGameListAct->setText(
|
||||||
|
@ -267,9 +267,9 @@ SettingsDialog::SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
|
|||||||
{
|
{
|
||||||
connect(ui->addFolderButton, &QPushButton::clicked, this, [this]() {
|
connect(ui->addFolderButton, &QPushButton::clicked, this, [this]() {
|
||||||
QString file_path_string =
|
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);
|
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);
|
QListWidgetItem* item = new QListWidgetItem(file_path_string);
|
||||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||||
item->setCheckState(Qt::Checked);
|
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();
|
QString item_path_string = selected_item ? selected_item->text() : QString();
|
||||||
if (!item_path_string.isEmpty()) {
|
if (!item_path_string.isEmpty()) {
|
||||||
auto file_path = Common::FS::PathFromQString(item_path_string);
|
auto file_path = Common::FS::PathFromQString(item_path_string);
|
||||||
Config::removeGameInstallDir(file_path);
|
Config::removeGameDirectories(file_path);
|
||||||
delete selected_item;
|
delete selected_item;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -793,7 +793,7 @@ void SettingsDialog::UpdateSettings() {
|
|||||||
m_gui_settings->SetValue(gui::gl_showBackgroundImage,
|
m_gui_settings->SetValue(gui::gl_showBackgroundImage,
|
||||||
ui->showBackgroundImageCheckBox->isChecked());
|
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++) {
|
for (int i = 0; i < ui->gameFoldersListWidget->count(); i++) {
|
||||||
QListWidgetItem* item = ui->gameFoldersListWidget->item(i);
|
QListWidgetItem* item = ui->gameFoldersListWidget->item(i);
|
||||||
QString path_string = item->text();
|
QString path_string = item->text();
|
||||||
@ -802,7 +802,7 @@ void SettingsDialog::UpdateSettings() {
|
|||||||
|
|
||||||
dirs_with_states.push_back({path, enabled});
|
dirs_with_states.push_back({path, enabled});
|
||||||
}
|
}
|
||||||
Config::setAllGameInstallDirs(dirs_with_states);
|
Config::setAllGameDirectories(dirs_with_states);
|
||||||
|
|
||||||
#ifdef ENABLE_DISCORD_RPC
|
#ifdef ENABLE_DISCORD_RPC
|
||||||
auto* rpc = Common::Singleton<DiscordRPCHandler::RPC>::Instance();
|
auto* rpc = Common::Singleton<DiscordRPCHandler::RPC>::Instance();
|
||||||
@ -825,28 +825,28 @@ void SettingsDialog::ResetInstallFolders() {
|
|||||||
|
|
||||||
if (data.contains("GUI")) {
|
if (data.contains("GUI")) {
|
||||||
const toml::value& gui = data.at("GUI");
|
const toml::value& gui = data.at("GUI");
|
||||||
const auto install_dir_array =
|
const auto directories_array =
|
||||||
toml::find_or<std::vector<std::u8string>>(gui, "installDirs", {});
|
toml::find_or<std::vector<std::u8string>>(gui, "directories", {});
|
||||||
|
|
||||||
std::vector<bool> install_dirs_enabled;
|
std::vector<bool> directories_enabled;
|
||||||
try {
|
try {
|
||||||
install_dirs_enabled = Config::getGameInstallDirsEnabled();
|
directories_enabled = Config::getGameDirectoriesEnabled();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// If it does not exist, assume that all are enabled.
|
// 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()) {
|
if (directories_enabled.size() < directories_array.size()) {
|
||||||
install_dirs_enabled.resize(install_dir_array.size(), true);
|
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++) {
|
for (size_t i = 0; i < directories_array.size(); i++) {
|
||||||
std::filesystem::path dir = install_dir_array[i];
|
std::filesystem::path dir = directories_array[i];
|
||||||
bool enabled = install_dirs_enabled[i];
|
bool enabled = directories_enabled[i];
|
||||||
|
|
||||||
settings_install_dirs_config.push_back({dir, enabled});
|
settings_directories_config.push_back({dir, enabled});
|
||||||
|
|
||||||
QString path_string;
|
QString path_string;
|
||||||
Common::FS::PathToQString(path_string, dir);
|
Common::FS::PathToQString(path_string, dir);
|
||||||
@ -857,7 +857,7 @@ void SettingsDialog::ResetInstallFolders() {
|
|||||||
ui->gameFoldersListWidget->addItem(item);
|
ui->gameFoldersListWidget->addItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::setAllGameInstallDirs(settings_install_dirs_config);
|
Config::setAllGameDirectories(settings_directories_config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SettingsDialog::setDefaultValues() {
|
void SettingsDialog::setDefaultValues() {
|
||||||
|
@ -45,7 +45,7 @@ private:
|
|||||||
void OnCursorStateChanged(s16 index);
|
void OnCursorStateChanged(s16 index);
|
||||||
void closeEvent(QCloseEvent* event) override;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
void setDefaultValues();
|
void setDefaultValues();
|
||||||
|
|
||||||
std::unique_ptr<Ui::SettingsDialog> ui;
|
std::unique_ptr<Ui::SettingsDialog> ui;
|
||||||
|
|
||||||
std::map<std::string, int> languages;
|
std::map<std::string, int> languages;
|
||||||
|
Loading…
Reference in New Issue
Block a user