Fix Multiple Install Folders (#1328)

* attempt to fix pr

* clang format
This commit is contained in:
ElBread3 2024-10-10 09:52:20 -05:00 committed by GitHub
parent 0a12ba4120
commit 299a29e243
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 48 additions and 10 deletions

View file

@ -534,7 +534,12 @@ void load(const std::filesystem::path& path) {
const auto install_dir_array = const auto install_dir_array =
toml::find_or<std::vector<std::string>>(gui, "installDirs", {}); toml::find_or<std::vector<std::string>>(gui, "installDirs", {});
for (const auto& dir : install_dir_array) { for (const auto& dir : install_dir_array) {
settings_install_dirs.emplace_back(std::filesystem::path{dir}); bool not_already_included =
std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir) ==
settings_install_dirs.end();
if (not_already_included) {
settings_install_dirs.emplace_back(std::filesystem::path{dir});
}
} }
settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", {}); settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", {});

View file

@ -222,21 +222,17 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
// PATH TAB // PATH TAB
{ {
for (const auto& dir : Config::getGameInstallDirs()) {
QString path_string;
Common::FS::PathToQString(path_string, dir);
QListWidgetItem* item = new QListWidgetItem(path_string);
ui->gameFoldersListWidget->addItem(item);
}
ui->removeFolderButton->setEnabled(false); ui->removeFolderButton->setEnabled(false);
connect(ui->addFolderButton, &QPushButton::clicked, this, [this]() { connect(ui->addFolderButton, &QPushButton::clicked, this, [this]() {
const auto config_dir = Config::getGameInstallDirs();
QString file_path_string = QString file_path_string =
QFileDialog::getExistingDirectory(this, tr("Directory to install games")); QFileDialog::getExistingDirectory(this, tr("Directory to install games"));
auto file_path = Common::FS::PathFromQString(file_path_string); auto file_path = Common::FS::PathFromQString(file_path_string);
if (!file_path.empty()) { bool not_already_included =
std::vector<std::filesystem::path> install_dirs = Config::getGameInstallDirs(); std::find(config_dir.begin(), config_dir.end(), file_path) == config_dir.end();
if (!file_path.empty() && not_already_included) {
std::vector<std::filesystem::path> install_dirs = config_dir;
install_dirs.push_back(file_path); install_dirs.push_back(file_path);
Config::setGameInstallDirs(install_dirs); Config::setGameInstallDirs(install_dirs);
QListWidgetItem* item = new QListWidgetItem(file_path_string); QListWidgetItem* item = new QListWidgetItem(file_path_string);
@ -307,6 +303,12 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
ui->dumpShadersCheckBox->installEventFilter(this); ui->dumpShadersCheckBox->installEventFilter(this);
ui->nullGpuCheckBox->installEventFilter(this); ui->nullGpuCheckBox->installEventFilter(this);
// Paths
ui->gameFoldersGroupBox->installEventFilter(this);
ui->gameFoldersListWidget->installEventFilter(this);
ui->addFolderButton->installEventFilter(this);
ui->removeFolderButton->installEventFilter(this);
// Debug // Debug
ui->debugDump->installEventFilter(this); ui->debugDump->installEventFilter(this);
ui->vkValidationCheckBox->installEventFilter(this); ui->vkValidationCheckBox->installEventFilter(this);
@ -357,6 +359,13 @@ void SettingsDialog::LoadValuesFromConfig() {
} }
ui->updateComboBox->setCurrentText(QString::fromStdString(updateChannel)); ui->updateComboBox->setCurrentText(QString::fromStdString(updateChannel));
for (const auto& dir : Config::getGameInstallDirs()) {
QString path_string;
Common::FS::PathToQString(path_string, dir);
QListWidgetItem* item = new QListWidgetItem(path_string);
ui->gameFoldersListWidget->addItem(item);
}
QString backButtonBehavior = QString::fromStdString(Config::getBackButtonBehavior()); QString backButtonBehavior = QString::fromStdString(Config::getBackButtonBehavior());
int index = ui->backButtonBehaviorComboBox->findData(backButtonBehavior); int index = ui->backButtonBehaviorComboBox->findData(backButtonBehavior);
ui->backButtonBehaviorComboBox->setCurrentIndex(index != -1 ? index : 0); ui->backButtonBehaviorComboBox->setCurrentIndex(index != -1 ? index : 0);
@ -452,6 +461,15 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
text = tr("nullGpuCheckBox"); text = tr("nullGpuCheckBox");
} }
// Path
if (elementName == "gameFoldersGroupBox" || elementName == "gameFoldersListWidget") {
text = tr("gameFoldersBox");
} else if (elementName == "addFolderButton") {
text = tr("addFolderButton");
} else if (elementName == "removeFolderButton") {
text = tr("removeFolderButton");
}
// Debug // Debug
if (elementName == "debugDump") { if (elementName == "debugDump") {
text = tr("debugDump"); text = tr("debugDump");

View file

@ -1083,6 +1083,21 @@
<source>nullGpuCheckBox</source> <source>nullGpuCheckBox</source>
<translation>Enable Null GPU:\nFor the sake of technical debugging, disables game rendering as if there were no graphics card.</translation> <translation>Enable Null GPU:\nFor the sake of technical debugging, disables game rendering as if there were no graphics card.</translation>
</message> </message>
<message>
<location filename="../settings_dialog.cpp" line="465"/>
<source>gameFoldersBox</source>
<translation>Game Folders: The list of folders to check for installed games.</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="465"/>
<source>addFolderButton</source>
<translation>Add: Add a folder to the list.</translation>
</message>
<message>
<location filename="../settings_dialog.cpp" line="465"/>
<source>removeFolderButton</source>
<translation>Remove: Remove a folder from the list.</translation>
</message>
<message> <message>
<location filename="../settings_dialog.cpp" line="329"/> <location filename="../settings_dialog.cpp" line="329"/>
<source>debugDump</source> <source>debugDump</source>