From 7c84e7b3832553a9b31d1bcc01d9cab720675b80 Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Sun, 2 Aug 2020 20:58:59 -0400 Subject: [PATCH] Added global cheat enable and auto load/save checkboxes --- src/drivers/Qt/CheatsConf.cpp | 36 +++++++++++++++++++++++++++++++++++ src/drivers/Qt/CheatsConf.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/src/drivers/Qt/CheatsConf.cpp b/src/drivers/Qt/CheatsConf.cpp index 74c0a41a..74f61a15 100644 --- a/src/drivers/Qt/CheatsConf.cpp +++ b/src/drivers/Qt/CheatsConf.cpp @@ -86,6 +86,19 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent) connect( actvCheatList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(actvCheatItemClicked( QTreeWidgetItem*, int)) ); + hbox = new QHBoxLayout(); + + enaCheats = new QCheckBox( tr("Enable Cheats") ); + autoSave = new QCheckBox( tr("Auto Load / Save with Game") ); + + enaCheats->setChecked( !globalCheatDisabled ); + autoSave->setChecked( !disableAutoLSCheats ); + + hbox->addWidget( enaCheats ); + hbox->addWidget( autoSave ); + + vbox1->addLayout( hbox ); + vbox1->addWidget( actvCheatList ); hbox = new QHBoxLayout(); @@ -366,6 +379,9 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent) connect( delCheatBtn , SIGNAL(clicked(void)), this, SLOT(deleteActvCheat(void)) ); connect( modCheatBtn , SIGNAL(clicked(void)), this, SLOT(updateCheatParameters(void)) ); + connect( enaCheats, SIGNAL(stateChanged(int)), this, SLOT(globalEnableCheats(int)) ); + connect( autoSave , SIGNAL(stateChanged(int)), this, SLOT(autoLoadSaveCheats(int)) ); + connect( importCheatFileBtn, SIGNAL(clicked(void)), this, SLOT(openCheatFile(void)) ); showActiveCheatList(true); @@ -845,3 +861,23 @@ void GuiCheatsDialog_t::actvCheatItemClicked( QTreeWidgetItem *item, int column } } //---------------------------------------------------------------------------- +void GuiCheatsDialog_t::globalEnableCheats(int state) +{ + fceuWrapperLock(); + FCEUI_GlobalToggleCheat( state != Qt::Unchecked ); + fceuWrapperUnLock(); +} +//---------------------------------------------------------------------------- +void GuiCheatsDialog_t::autoLoadSaveCheats(int state) +{ + if ( state == Qt::Unchecked ) + { + printf("If this option is unchecked, you must manually save the cheats by yourself, or all the changes you made to the cheat list would be discarded silently without any asking once you close the game!\nDo you really want to do it in this way?"); + disableAutoLSCheats = 2; + } + else + { + disableAutoLSCheats = 0; + } +} +//---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/CheatsConf.h b/src/drivers/Qt/CheatsConf.h index 43dc8da7..35d1bc48 100644 --- a/src/drivers/Qt/CheatsConf.h +++ b/src/drivers/Qt/CheatsConf.h @@ -51,6 +51,8 @@ class GuiCheatsDialog_t : public QDialog QCheckBox *useNeVal; QCheckBox *useGrVal; QCheckBox *useLtVal; + QCheckBox *enaCheats; + QCheckBox *autoSave; QTreeWidget *actvCheatList; QTreeWidget *srchResults; QLineEdit *cheatNameEntry; @@ -84,6 +86,8 @@ class GuiCheatsDialog_t : public QDialog void addActvCheat(void); void deleteActvCheat(void); void updateCheatParameters(void); + void autoLoadSaveCheats(int state); + void globalEnableCheats(int state); void actvCheatItemClicked( QTreeWidgetItem *item, int column); };