mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 08:39:44 +00:00
Adding saveSettingInt() and loadSettingInt()
Convenience methods for saving and loading integer settings. Versions for QSpinBox and QComboBox are included. Right now, only simple settings are used for it; we have some additional settings that include validation that aren't using these new methods.
This commit is contained in:
parent
1a2efd441c
commit
42ce22f568
2 changed files with 37 additions and 17 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue