Added pause while cheat window is active checkbox logic.

This commit is contained in:
Matthew Budd 2020-08-02 21:19:32 -04:00
parent 7c84e7b383
commit b0529d564a
2 changed files with 45 additions and 1 deletions

View File

@ -54,6 +54,9 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
setWindowTitle("Cheat Search");
pauseWhileActive = false;
wasPausedByCheats = false;
//resize( 512, 512 );
// Window Layout Box
@ -365,7 +368,14 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
groupBox->setLayout( vbox3 );
mainLayout->addWidget( cheatSearchFrame );
vbox = new QVBoxLayout();
pauseBox = new QCheckBox( tr("Pause emulation when this window is active") );
vbox->addWidget( cheatSearchFrame );
vbox->addWidget( pauseBox );
mainLayout->addLayout( vbox );
setLayout( mainLayout );
@ -381,6 +391,7 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
connect( enaCheats, SIGNAL(stateChanged(int)), this, SLOT(globalEnableCheats(int)) );
connect( autoSave , SIGNAL(stateChanged(int)), this, SLOT(autoLoadSaveCheats(int)) );
connect( pauseBox , SIGNAL(stateChanged(int)), this, SLOT(pauseWindowState(int)) );
connect( importCheatFileBtn, SIGNAL(clicked(void)), this, SLOT(openCheatFile(void)) );
@ -389,6 +400,12 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
//----------------------------------------------------------------------------
GuiCheatsDialog_t::~GuiCheatsDialog_t(void)
{
if (EmulationPaused && wasPausedByCheats)
{
EmulationPaused = 0;
FCEU_printf ("Emulation paused: %d\n", EmulationPaused);
}
wasPausedByCheats = false;
}
//----------------------------------------------------------------------------
@ -881,3 +898,26 @@ void GuiCheatsDialog_t::autoLoadSaveCheats(int state)
}
}
//----------------------------------------------------------------------------
void GuiCheatsDialog_t::pauseWindowState(int state)
{
pauseWhileActive = (state != Qt::Unchecked);
if (pauseWhileActive)
{
if (EmulationPaused == 0)
{
EmulationPaused = 1;
wasPausedByCheats = true;
}
}
else
{
if (EmulationPaused && wasPausedByCheats)
{
EmulationPaused = 0;
}
wasPausedByCheats = false;
}
FCEU_printf ("Emulation paused: %d\n", EmulationPaused);
}
//----------------------------------------------------------------------------

View File

@ -53,6 +53,7 @@ class GuiCheatsDialog_t : public QDialog
QCheckBox *useLtVal;
QCheckBox *enaCheats;
QCheckBox *autoSave;
QCheckBox *pauseBox;
QTreeWidget *actvCheatList;
QTreeWidget *srchResults;
QLineEdit *cheatNameEntry;
@ -68,6 +69,8 @@ class GuiCheatsDialog_t : public QDialog
int fontCharWidth;
int actvCheatIdx;
bool actvCheatRedraw;
bool pauseWhileActive;
bool wasPausedByCheats;
private:
void showCheatSearchResults(void);
@ -88,6 +91,7 @@ class GuiCheatsDialog_t : public QDialog
void updateCheatParameters(void);
void autoLoadSaveCheats(int state);
void globalEnableCheats(int state);
void pauseWindowState(int state);
void actvCheatItemClicked( QTreeWidgetItem *item, int column);
};