diff --git a/apps/launcher/advancedpage.cpp b/apps/launcher/advancedpage.cpp index 2c33992ac3..97c2870b30 100644 --- a/apps/launcher/advancedpage.cpp +++ b/apps/launcher/advancedpage.cpp @@ -207,7 +207,7 @@ bool Launcher::AdvancedPage::loadSettings() { // Saves loadSettingBool(timePlayedCheckbox, "timeplayed", "Saves"); - maximumQuicksavesComboBox->setValue(Settings::Manager::getInt("max quicksaves", "Saves")); + loadSettingInt(maximumQuicksavesComboBox,"max quicksaves", "Saves"); // Other Settings QString screenshotFormatString = QString::fromStdString(Settings::Manager::getString("screenshot format", "General")).toUpper(); @@ -252,14 +252,10 @@ void Launcher::AdvancedPage::saveSettings() saveSettingBool(normaliseRaceSpeedCheckBox, "normalise race speed", "Game"); saveSettingBool(swimUpwardCorrectionCheckBox, "swim upward correction", "Game"); saveSettingBool(avoidCollisionsCheckBox, "NPCs avoid collisions", "Game"); - int unarmedFactorsStrengthIndex = unarmedFactorsStrengthComboBox->currentIndex(); - if (unarmedFactorsStrengthIndex != Settings::Manager::getInt("strength influences hand to hand", "Game")) - Settings::Manager::setInt("strength influences hand to hand", "Game", unarmedFactorsStrengthIndex); + saveSettingInt(unarmedFactorsStrengthComboBox, "strength influences hand to hand", "Game"); saveSettingBool(stealingFromKnockedOutCheckBox, "always allow stealing from knocked out actors", "Game"); saveSettingBool(enableNavigatorCheckBox, "enable", "Navigator"); - int numPhysicsThreads = physicsThreadsSpinBox->value(); - if (numPhysicsThreads != Settings::Manager::getInt("async num threads", "Physics")) - Settings::Manager::setInt("async num threads", "Physics", numPhysicsThreads); + saveSettingInt(physicsThreadsSpinBox, "async num threads", "Physics"); } // Visuals @@ -349,9 +345,7 @@ void Launcher::AdvancedPage::saveSettings() saveSettingBool(showMeleeInfoCheckBox, "show melee info", "Game"); saveSettingBool(showProjectileDamageCheckBox, "show projectile damage", "Game"); saveSettingBool(changeDialogTopicsCheckBox, "color topic enable", "GUI"); - int showOwnedCurrentIndex = showOwnedComboBox->currentIndex(); - if (showOwnedCurrentIndex != Settings::Manager::getInt("show owned", "Game")) - Settings::Manager::setInt("show owned", "Game", showOwnedCurrentIndex); + saveSettingInt(showOwnedComboBox,"show owned", "Game"); saveSettingBool(stretchBackgroundCheckBox, "stretch menu background", "GUI"); saveSettingBool(useZoomOnMapCheckBox, "allow zooming", "Map"); saveSettingBool(graphicHerbalismCheckBox, "graphic herbalism", "Game"); @@ -370,11 +364,7 @@ void Launcher::AdvancedPage::saveSettings() { // Saves Settings saveSettingBool(timePlayedCheckbox, "timeplayed", "Saves"); - int maximumQuicksaves = maximumQuicksavesComboBox->value(); - if (maximumQuicksaves != Settings::Manager::getInt("max quicksaves", "Saves")) - { - Settings::Manager::setInt("max quicksaves", "Saves", maximumQuicksaves); - } + saveSettingInt(maximumQuicksavesComboBox, "max quicksaves", "Saves"); // Other Settings std::string screenshotFormatString = screenshotFormatComboBox->currentText().toLower().toStdString(); @@ -416,6 +406,32 @@ void Launcher::AdvancedPage::saveSettingBool(QCheckBox *checkbox, const std::str Settings::Manager::setBool(setting, group, cValue); } +void Launcher::AdvancedPage::loadSettingInt(QComboBox *comboBox, const std::string &setting, const std::string &group) +{ + int currentIndex = Settings::Manager::getInt(setting, group); + comboBox->setCurrentIndex(currentIndex); +} + +void Launcher::AdvancedPage::saveSettingInt(QComboBox *comboBox, const std::string &setting, const std::string &group) +{ + int currentIndex = comboBox->currentIndex(); + if (currentIndex != Settings::Manager::getInt(setting, group)) + Settings::Manager::setInt(setting, group, currentIndex); +} + +void Launcher::AdvancedPage::loadSettingInt(QSpinBox *spinBox, const std::string &setting, const std::string &group) +{ + int value = Settings::Manager::getInt(setting, group); + spinBox->setValue(value); +} + +void Launcher::AdvancedPage::saveSettingInt(QSpinBox *spinBox, const std::string &setting, const std::string &group) +{ + int value = spinBox->value(); + if (value != Settings::Manager::getInt(setting, group)) + Settings::Manager::setInt(setting, group, value); +} + void Launcher::AdvancedPage::slotLoadedCellsChanged(QStringList cellNames) { loadCellsForAutocomplete(cellNames); diff --git a/apps/launcher/advancedpage.hpp b/apps/launcher/advancedpage.hpp index 9685dcefeb..1d16fae706 100644 --- a/apps/launcher/advancedpage.hpp +++ b/apps/launcher/advancedpage.hpp @@ -41,8 +41,12 @@ namespace Launcher * @param filePaths the file paths of the content files to be examined */ void loadCellsForAutocomplete(QStringList filePaths); - void loadSettingBool(QCheckBox *checkbox, const std::string& setting, const std::string& group); - void saveSettingBool(QCheckBox *checkbox, const std::string& setting, const std::string& group); + static void loadSettingBool(QCheckBox *checkbox, const std::string& setting, const std::string& group); + static void saveSettingBool(QCheckBox *checkbox, const std::string& setting, const std::string& group); + static void loadSettingInt(QComboBox *comboBox, const std::string& setting, const std::string& group); + static void saveSettingInt(QComboBox *comboBox, const std::string& setting, const std::string& group); + static void loadSettingInt(QSpinBox *spinBox, const std::string& setting, const std::string& group); + static void saveSettingInt(QSpinBox *spinBox, const std::string& setting, const std::string& group); }; } #endif