Added global cheat enable and auto load/save checkboxes

This commit is contained in:
Matthew Budd 2020-08-02 20:58:59 -04:00
parent e99cc1d64d
commit 7c84e7b383
2 changed files with 40 additions and 0 deletions

View File

@ -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;
}
}
//----------------------------------------------------------------------------

View File

@ -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);
};