code handler update add switch dialog

This commit is contained in:
Nayla Hanegan 2024-06-10 22:35:41 -04:00
commit 1550565855
7 changed files with 63 additions and 11 deletions

View file

@ -67,15 +67,15 @@ void GeneralPane::CreateLayout()
m_main_layout = new QVBoxLayout;
// Create layout here
CreateBasic();
CreateFallbackRegion();
#if defined(USE_ANALYTICS) && USE_ANALYTICS
CreateAnalytics();
#endif
CreateCheats();
m_main_layout->addStretch(1);
setLayout(m_main_layout);
}
void GeneralPane::OnEmulationStateChanged(Core::State state)
@ -100,6 +100,7 @@ void GeneralPane::ConnectLayout()
{
connect(m_checkbox_dualcore, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
connect(m_checkbox_cheats, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
connect(m_combobox_codehandler, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &GeneralPane::OnCodeHandlerChanged);
connect(m_checkbox_override_region_settings, &QCheckBox::stateChanged, this,
&GeneralPane::OnSaveConfig);
connect(m_checkbox_auto_disc_change, &QCheckBox::toggled, this, &GeneralPane::OnSaveConfig);
@ -136,9 +137,6 @@ void GeneralPane::CreateBasic()
m_checkbox_dualcore = new QCheckBox(tr("Enable Dual Core (speedup)"));
basic_group_layout->addWidget(m_checkbox_dualcore);
m_checkbox_cheats = new QCheckBox(tr("Enable Cheats"));
basic_group_layout->addWidget(m_checkbox_cheats);
m_checkbox_override_region_settings = new QCheckBox(tr("Allow Mismatched Region Settings"));
basic_group_layout->addWidget(m_checkbox_override_region_settings);
@ -213,6 +211,28 @@ void GeneralPane::CreateAnalytics()
}
#endif
void GeneralPane::CreateCheats()
{
auto* cheats_group = new QGroupBox(tr("Cheats Settings"));
auto* cheats_group_layout = new QVBoxLayout;
cheats_group->setLayout(cheats_group_layout);
m_main_layout->addWidget(cheats_group);
m_checkbox_cheats = new QCheckBox(tr("Enable Cheats"));
cheats_group_layout->addWidget(m_checkbox_cheats);
// Add dropdown for code handler selection
auto* code_handler_layout = new QFormLayout();
auto* code_handler_label = new QLabel(tr("Code Handler:"));
m_combobox_codehandler = new QComboBox();
m_combobox_codehandler->addItem(tr("Dolphin (Stock)"), QVariant(false));
m_combobox_codehandler->addItem(tr("MPN (Extended)"), QVariant(true));
code_handler_layout->addRow(code_handler_label, m_combobox_codehandler);
cheats_group_layout->addLayout(code_handler_layout);
}
void GeneralPane::LoadConfig()
{
const QSignalBlocker blocker(this);
@ -225,6 +245,7 @@ void GeneralPane::LoadConfig()
#endif
SignalBlocking(m_checkbox_dualcore)->setChecked(Config::Get(Config::MAIN_CPU_THREAD));
SignalBlocking(m_checkbox_cheats)->setChecked(Settings::Instance().GetCheatsEnabled());
SignalBlocking(m_combobox_codehandler)->setCurrentIndex(Config::Get(Config::MAIN_CODE_HANDLER) ? 1 : 0);
SignalBlocking(m_checkbox_override_region_settings)
->setChecked(Config::Get(Config::MAIN_OVERRIDE_REGION_SETTINGS));
SignalBlocking(m_checkbox_auto_disc_change)
@ -340,3 +361,10 @@ void GeneralPane::GenerateNewIdentity()
message_box.exec();
}
#endif
void GeneralPane::OnCodeHandlerChanged(int index)
{
bool use_mpn = m_combobox_codehandler->itemData(index).toBool();
Config::SetBaseOrCurrent(Config::MAIN_CODE_HANDLER, use_mpn); // Ensure correct usage
Config::Save();
}