Skip to content

Commit

Permalink
Fix Multiple Install Folders (#1328)
Browse files Browse the repository at this point in the history
* attempt to fix pr

* clang format
  • Loading branch information
ElBread3 authored Oct 10, 2024
1 parent 0a12ba4 commit 299a29e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,12 @@ void load(const std::filesystem::path& path) {
const auto install_dir_array =
toml::find_or<std::vector<std::string>>(gui, "installDirs", {});
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", {});
Expand Down
36 changes: 27 additions & 9 deletions src/qt_gui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,17 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge

// 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);

connect(ui->addFolderButton, &QPushButton::clicked, this, [this]() {
const auto config_dir = Config::getGameInstallDirs();
QString file_path_string =
QFileDialog::getExistingDirectory(this, tr("Directory to install games"));
auto file_path = Common::FS::PathFromQString(file_path_string);
if (!file_path.empty()) {
std::vector<std::filesystem::path> install_dirs = Config::getGameInstallDirs();
bool not_already_included =
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);
Config::setGameInstallDirs(install_dirs);
QListWidgetItem* item = new QListWidgetItem(file_path_string);
Expand Down Expand Up @@ -307,6 +303,12 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
ui->dumpShadersCheckBox->installEventFilter(this);
ui->nullGpuCheckBox->installEventFilter(this);

// Paths
ui->gameFoldersGroupBox->installEventFilter(this);
ui->gameFoldersListWidget->installEventFilter(this);
ui->addFolderButton->installEventFilter(this);
ui->removeFolderButton->installEventFilter(this);

// Debug
ui->debugDump->installEventFilter(this);
ui->vkValidationCheckBox->installEventFilter(this);
Expand Down Expand Up @@ -357,6 +359,13 @@ void SettingsDialog::LoadValuesFromConfig() {
}
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());
int index = ui->backButtonBehaviorComboBox->findData(backButtonBehavior);
ui->backButtonBehaviorComboBox->setCurrentIndex(index != -1 ? index : 0);
Expand Down Expand Up @@ -452,6 +461,15 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
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
if (elementName == "debugDump") {
text = tr("debugDump");
Expand Down
15 changes: 15 additions & 0 deletions src/qt_gui/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,21 @@
<source>nullGpuCheckBox</source>
<translation>Enable Null GPU:\nFor the sake of technical debugging, disables game rendering as if there were no graphics card.</translation>
</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>
<location filename="../settings_dialog.cpp" line="329"/>
<source>debugDump</source>
Expand Down

0 comments on commit 299a29e

Please sign in to comment.