From 10bf3d383c80e3bd5436a9ea99e7d2c96ed4fa96 Mon Sep 17 00:00:00 2001 From: DanielSvoboda Date: Sun, 23 Mar 2025 18:25:11 -0300 Subject: [PATCH] QT: Fix PR 2662 (#2676) --- src/common/config.cpp | 6 +++--- src/common/config.h | 2 +- src/qt_gui/main.cpp | 7 ++++++- src/qt_gui/settings_dialog.cpp | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 0b5fb8be1..fd6538f85 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -82,6 +82,7 @@ static std::string trophyKey; // Gui static bool load_game_size = true; static std::vector settings_install_dirs = {}; +std::vector install_dirs_enabled = {}; std::filesystem::path settings_addon_install_dir = {}; std::filesystem::path save_data_path = {}; u32 main_window_geometry_x = 400; @@ -643,8 +644,8 @@ const std::vector getGameInstallDirs() { return enabled_dirs; } -const std::vector& getAllGameInstallDirs() { - return settings_install_dirs; +const std::vector getGameInstallDirsEnabled() { + return install_dirs_enabled; } std::filesystem::path getAddonInstallDir() { @@ -839,7 +840,6 @@ void load(const std::filesystem::path& path) { const auto install_dir_array = toml::find_or>(gui, "installDirs", {}); - std::vector install_dirs_enabled; try { install_dirs_enabled = toml::find>(gui, "installDirsEnabled"); } catch (...) { diff --git a/src/common/config.h b/src/common/config.h index e495be52a..4202da88a 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -161,7 +161,7 @@ u32 getMainWindowGeometryY(); u32 getMainWindowGeometryW(); u32 getMainWindowGeometryH(); const std::vector getGameInstallDirs(); -const std::vector& getAllGameInstallDirs(); +const std::vector getGameInstallDirsEnabled(); std::filesystem::path getAddonInstallDir(); u32 getMainWindowTheme(); u32 getIconSize(); diff --git a/src/qt_gui/main.cpp b/src/qt_gui/main.cpp index 36dc226ae..d70294e40 100644 --- a/src/qt_gui/main.cpp +++ b/src/qt_gui/main.cpp @@ -157,8 +157,13 @@ int main(int argc, char* argv[]) { } } + bool allInstallDirsDisabled = + std::all_of(Config::getGameInstallDirsEnabled().begin(), + Config::getGameInstallDirsEnabled().end(), [](bool val) { return !val; }); + // If no game directory is set and no command line argument, prompt for it - if (Config::getGameInstallDirs().empty() && !has_command_line_argument) { + if (Config::getGameInstallDirs().empty() && allInstallDirsDisabled && + !has_command_line_argument) { GameInstallDialog dlg; dlg.exec(); } diff --git a/src/qt_gui/settings_dialog.cpp b/src/qt_gui/settings_dialog.cpp index a8beef8da..d789f6f48 100644 --- a/src/qt_gui/settings_dialog.cpp +++ b/src/qt_gui/settings_dialog.cpp @@ -821,7 +821,7 @@ void SettingsDialog::ResetInstallFolders() { std::vector install_dirs_enabled; try { - install_dirs_enabled = toml::find>(gui, "installDirsEnabled"); + install_dirs_enabled = Config::getGameInstallDirsEnabled(); } catch (...) { // If it does not exist, assume that all are enabled. install_dirs_enabled.resize(install_dir_array.size(), true);