From b0529d564a7e91f6c5af59c538b659f5e2ebfc4c Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Sun, 2 Aug 2020 21:19:32 -0400 Subject: [PATCH] Added pause while cheat window is active checkbox logic. --- src/drivers/Qt/CheatsConf.cpp | 42 ++++++++++++++++++++++++++++++++++- src/drivers/Qt/CheatsConf.h | 4 ++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/drivers/Qt/CheatsConf.cpp b/src/drivers/Qt/CheatsConf.cpp index 74f61a15..29f9bdaf 100644 --- a/src/drivers/Qt/CheatsConf.cpp +++ b/src/drivers/Qt/CheatsConf.cpp @@ -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); +} +//---------------------------------------------------------------------------- diff --git a/src/drivers/Qt/CheatsConf.h b/src/drivers/Qt/CheatsConf.h index 35d1bc48..1adb7b82 100644 --- a/src/drivers/Qt/CheatsConf.h +++ b/src/drivers/Qt/CheatsConf.h @@ -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); };