diff options
| author | Martino Fontana <tinozzo123@gmail.com> | 2023-07-24 20:12:32 +0200 |
|---|---|---|
| committer | Martino Fontana <tinozzo123@gmail.com> | 2023-07-24 20:48:32 +0200 |
| commit | 0892998af170ecbbe45dff87d8352bdfb97bca82 (patch) | |
| tree | 648656feb3aad17540098ba3ebf776cebf6db64f /Source/Core/DolphinQt/Config/GameConfigWidget.cpp | |
| parent | 0a2afa48b7bb09fdf3c01c0600359e3f5588df3c (diff) | |
Qt/GameConfigWidget: Add `reverse` argument for `{Save,Load}CheckBox`
In order to not hard code `if (key == "FastDiscSpeed")`
Diffstat (limited to 'Source/Core/DolphinQt/Config/GameConfigWidget.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/Config/GameConfigWidget.cpp | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/Source/Core/DolphinQt/Config/GameConfigWidget.cpp b/Source/Core/DolphinQt/Config/GameConfigWidget.cpp index a702c90f84..3ab83c11ff 100644 --- a/Source/Core/DolphinQt/Config/GameConfigWidget.cpp +++ b/Source/Core/DolphinQt/Config/GameConfigWidget.cpp @@ -219,30 +219,19 @@ void GameConfigWidget::ConnectWidgets() } void GameConfigWidget::LoadCheckBox(QCheckBox* checkbox, const std::string& section, - const std::string& key) + const std::string& key, bool reverse) { bool checked; - if (key == "FastDiscSpeed") - { - if (m_gameini_local.GetOrCreateSection(section)->Get("FastDiscSpeed", &checked)) - return checkbox->setCheckState(!checked ? Qt::Checked : Qt::Unchecked); - - if (m_gameini_default.GetOrCreateSection(section)->Get("FastDiscSpeed", &checked)) - return checkbox->setCheckState(!checked ? Qt::Checked : Qt::Unchecked); - } - else - { - if (m_gameini_local.GetOrCreateSection(section)->Get(key, &checked)) - return checkbox->setCheckState(checked ? Qt::Checked : Qt::Unchecked); + if (m_gameini_local.GetOrCreateSection(section)->Get(key, &checked)) + return checkbox->setCheckState(checked ^ reverse ? Qt::Checked : Qt::Unchecked); - if (m_gameini_default.GetOrCreateSection(section)->Get(key, &checked)) - return checkbox->setCheckState(checked ? Qt::Checked : Qt::Unchecked); - } + if (m_gameini_default.GetOrCreateSection(section)->Get(key, &checked)) + return checkbox->setCheckState(checked ^ reverse ? Qt::Checked : Qt::Unchecked); checkbox->setCheckState(Qt::PartiallyChecked); } void GameConfigWidget::SaveCheckBox(QCheckBox* checkbox, const std::string& section, - const std::string& key) + const std::string& key, bool reverse) { // Delete any existing entries from the local gameini if checkbox is undetermined. // Otherwise, write the current value to the local gameini if the value differs from the default @@ -256,13 +245,7 @@ void GameConfigWidget::SaveCheckBox(QCheckBox* checkbox, const std::string& sect return; } - bool checked = checkbox->checkState() == Qt::Checked; - - if (key == "FastDiscSpeed") - { - m_gameini_local.GetOrCreateSection(section)->Set(key, !checked); - return; - } + bool checked = (checkbox->checkState() == Qt::Checked) ^ reverse; if (m_gameini_default.Exists(section, key)) { @@ -293,7 +276,7 @@ void GameConfigWidget::LoadSettings() LoadCheckBox(m_enable_mmu, "Core", "MMU"); LoadCheckBox(m_enable_fprf, "Core", "FPRF"); LoadCheckBox(m_sync_gpu, "Core", "SyncGPU"); - LoadCheckBox(m_enable_fast_disc, "Core", "FastDiscSpeed"); + LoadCheckBox(m_enable_fast_disc, "Core", "FastDiscSpeed", true); LoadCheckBox(m_use_dsp_hle, "Core", "DSPHLE"); std::string determinism_mode; @@ -343,7 +326,7 @@ void GameConfigWidget::SaveSettings() SaveCheckBox(m_enable_mmu, "Core", "MMU"); SaveCheckBox(m_enable_fprf, "Core", "FPRF"); SaveCheckBox(m_sync_gpu, "Core", "SyncGPU"); - SaveCheckBox(m_enable_fast_disc, "Core", "FastDiscSpeed"); + SaveCheckBox(m_enable_fast_disc, "Core", "FastDiscSpeed", true); SaveCheckBox(m_use_dsp_hle, "Core", "DSPHLE"); int determinism_num = m_deterministic_dual_core->currentIndex(); |
