Qt: Display warning before allowing cheats

This commit is contained in:
Connor McLaughlin 2021-07-17 15:13:28 +10:00
parent 6008b9f1e9
commit efaf3d6ce5
2 changed files with 36 additions and 4 deletions

View File

@ -1605,7 +1605,35 @@ void MainWindow::onToolsMemoryCardEditorTriggered()
void MainWindow::onToolsCheatManagerTriggered()
{
if (!m_cheat_manager_dialog)
{
if (m_host_interface->GetBoolSettingValue("UI", "DisplayCheatWarning", true))
{
QCheckBox* cb = new QCheckBox(tr("Do not show again"));
QMessageBox mb(this);
mb.setWindowTitle(tr("Cheat Manager"));
mb.setText(
tr("Using cheats can have unpredictable effects on games, causing crashes, graphical glitches, and corrupted "
"saves. By using the cheat manager, you agree that it is an unsupported configuration, and we will not "
"provide you with any assistance when games break.\n\nCheats persist through save states even after being "
"disabled, please remember to reset/reboot the game after turning off any codes.\n\nAre you sure you want "
"to continue?"));
mb.setIcon(QMessageBox::Warning);
mb.addButton(QMessageBox::Yes);
mb.addButton(QMessageBox::No);
mb.setDefaultButton(QMessageBox::No);
mb.setCheckBox(cb);
connect(cb, &QCheckBox::stateChanged, [](int state) {
QtHostInterface::GetInstance()->SetBoolSettingValue("UI", "DisplayCheatWarning",
(state != Qt::CheckState::Checked));
});
if (mb.exec() == QMessageBox::No)
return;
}
m_cheat_manager_dialog = new CheatManagerDialog(this);
}
m_cheat_manager_dialog->setModal(false);
m_cheat_manager_dialog->show();

View File

@ -3600,9 +3600,13 @@ bool CommonHostInterface::LoadCheatList(const char* filename)
return false;
}
AddOSDMessage(TranslateStdString("OSDMessage", "Loaded %n cheats from list.", "", cl->GetCodeCount()) +
TranslateStdString("OSDMessage", " %n cheats are enabled.", "", cl->GetEnabledCodeCount()),
10.0f);
if (cl->GetEnabledCodeCount() > 0)
{
AddOSDMessage(TranslateStdString("OSDMessage", "%n cheats are enabled. This may result in instability.", "",
cl->GetEnabledCodeCount()),
30.0f);
}
System::SetCheatList(std::move(cl));
return true;
}
@ -3628,7 +3632,7 @@ bool CommonHostInterface::LoadCheatListFromDatabase()
if (!cl->LoadFromPackage(System::GetRunningCode()))
return false;
AddOSDMessage(TranslateStdString("OSDMessage", "Loaded %n cheats from database.", "", cl->GetCodeCount()), 10.0f);
Log_InfoPrintf("Loaded %u cheats from database.", cl->GetCodeCount());
System::SetCheatList(std::move(cl));
return true;
}