diff --git a/src/drivers/Qt/CheatsConf.cpp b/src/drivers/Qt/CheatsConf.cpp index d995700d..79cc3c60 100644 --- a/src/drivers/Qt/CheatsConf.cpp +++ b/src/drivers/Qt/CheatsConf.cpp @@ -52,6 +52,9 @@ void openCheatDialog(QWidget *parent) { if (win != NULL) { + win->activateWindow(); + win->raise(); + win->setFocus(); return; } win = new GuiCheatsDialog_t(parent); @@ -198,6 +201,18 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent) vbox1->addLayout(hbox); + hbox = new QHBoxLayout(); + lbl = new QLabel(tr("Type:")); + typeEntry = new QComboBox(); + typeEntry->addItem(tr("0: Periodic Set (Every Frame)"), 0 ); + typeEntry->addItem(tr("1: Substitute/Freeze"), 1 ); + typeEntry->setCurrentIndex(1); + + hbox->addWidget(lbl,1); + hbox->addWidget(typeEntry,10); + + vbox1->addLayout(hbox); + hbox = new QHBoxLayout(); addCheatBtn = new QPushButton(tr("Add")); @@ -435,6 +450,8 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent) setLayout(mainLayout); + modCheatBtn->setDefault(true); + connect(srchResetBtn, SIGNAL(clicked(void)), this, SLOT(resetSearchCallback(void))); connect(knownValBtn, SIGNAL(clicked(void)), this, SLOT(knownValueCallback(void))); connect(eqValBtn, SIGNAL(clicked(void)), this, SLOT(equalValueCallback(void))); @@ -719,6 +736,8 @@ void GuiCheatsDialog_t::showActiveCheatList(bool redraw) { win = this; + enaCheats->setChecked(!globalCheatDisabled); + actvCheatRedraw = redraw; if (redraw) @@ -871,6 +890,7 @@ void GuiCheatsDialog_t::addActvCheat(void) uint32 a = 0; uint8 v = 0; int c = -1; + int t = 1; std::string name, cmpStr; a = strtoul(cheatAddrEntry->displayText().toStdString().c_str(), NULL, 16); @@ -890,8 +910,10 @@ void GuiCheatsDialog_t::addActvCheat(void) name = cheatNameEntry->text().toStdString(); + t = typeEntry->currentData().toInt(); + FCEU_WRAPPER_LOCK(); - FCEUI_AddCheat(name.c_str(), a, v, c, 1); + FCEUI_AddCheat(name.c_str(), a, v, c, t); FCEU_WRAPPER_UNLOCK(); showActiveCheatList(true); @@ -921,6 +943,7 @@ void GuiCheatsDialog_t::deleteActvCheat(void) cheatAddrEntry->setText(tr("")); cheatValEntry->setText(tr("")); cheatCmpEntry->setText(tr("")); + typeEntry->setCurrentIndex(0); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::updateCheatParameters(void) @@ -969,6 +992,8 @@ void GuiCheatsDialog_t::updateCheatParameters(void) //printf("Name: %s \n", name.c_str() ); + type = typeEntry->currentData().toInt(); + FCEU_WRAPPER_LOCK(); FCEUI_SetCheat(row, &name, a, v, c, s, type); @@ -1022,6 +1047,8 @@ void GuiCheatsDialog_t::actvCheatItemClicked(QTreeWidgetItem *item, int column) } cheatNameEntry->setText(tr(name.c_str())); + + typeEntry->setCurrentIndex(type); } //---------------------------------------------------------------------------- void GuiCheatsDialog_t::globalEnableCheats(int state) diff --git a/src/drivers/Qt/CheatsConf.h b/src/drivers/Qt/CheatsConf.h index c06e9f75..4eab63a9 100644 --- a/src/drivers/Qt/CheatsConf.h +++ b/src/drivers/Qt/CheatsConf.h @@ -67,6 +67,7 @@ protected: QLineEdit *neValEntry; QLineEdit *grValEntry; QLineEdit *ltValEntry; + QComboBox *typeEntry; QFont font; int fontCharWidth; diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 9332dac4..23e4bf40 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -862,6 +862,7 @@ void consoleWin_t::initHotKeys(void) connect( Hotkeys[ HK_TOGGLE_BG ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleBackground(void)) ); connect( Hotkeys[ HK_TOGGLE_FG ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleForeground(void)) ); connect( Hotkeys[ HK_FKB_ENABLE ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleFamKeyBrdEnable(void)) ); + connect( Hotkeys[ HK_TOGGLE_ALL_CHEATS ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleGlobalCheatEnable(void)) ); connect( Hotkeys[ HK_SAVE_STATE_0 ].getShortcut(), SIGNAL(activated()), this, SLOT(saveState0(void)) ); connect( Hotkeys[ HK_SAVE_STATE_1 ].getShortcut(), SIGNAL(activated()), this, SLOT(saveState1(void)) ); @@ -3173,6 +3174,20 @@ void consoleWin_t::toggleFamKeyBrdEnable(void) toggleFamilyKeyboardFunc(); } +extern int globalCheatDisabled; + +void consoleWin_t::toggleGlobalCheatEnable(void) +{ + FCEU_WRAPPER_LOCK(); + FCEUI_GlobalToggleCheat(globalCheatDisabled); + FCEU_WRAPPER_UNLOCK(); + + g_config->setOption("SDL.CheatsDisabled", globalCheatDisabled); + g_config->save(); + + updateCheatDialog(); +} + void consoleWin_t::warnAmbiguousShortcut( QShortcut *shortcut) { char stmp[256]; diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index 4586e06b..d4451965 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -415,6 +415,7 @@ class consoleWin_t : public QMainWindow void toggleBackground(void); void toggleForeground(void); void toggleFamKeyBrdEnable(void); + void toggleGlobalCheatEnable(void); void saveState0(void); void saveState1(void); void saveState2(void); diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp index 386571ee..25442b96 100644 --- a/src/drivers/Qt/config.cpp +++ b/src/drivers/Qt/config.cpp @@ -83,6 +83,9 @@ int getHotKeyConfig( int i, const char **nameOut, const char **keySeqOut, const case HK_CHEAT_MENU: name = "CheatMenu"; keySeq = ""; title = "Open Cheat Window"; group = "Tools"; break; + case HK_TOGGLE_ALL_CHEATS: + name = "ToggleCheats"; keySeq = ""; title = "Toggle Global Cheat Enable"; group = "Tools"; + break; case HK_BIND_STATE: name = "BindState"; keySeq = ""; title = "Bind Save State to Movie"; group = "Movie"; break; diff --git a/src/drivers/Qt/config.h b/src/drivers/Qt/config.h index 0bb68e78..d719f12d 100644 --- a/src/drivers/Qt/config.h +++ b/src/drivers/Qt/config.h @@ -53,7 +53,7 @@ enum HOTKEY { // Display HK_TOGGLE_FG, HK_TOGGLE_BG, HK_TOGGLE_INPUT_DISPLAY, HK_LAG_COUNTER_DISPLAY, - HK_CHEAT_MENU, HK_LOAD_LUA, + HK_CHEAT_MENU, HK_TOGGLE_ALL_CHEATS, HK_LOAD_LUA, HK_MUTE_CAPTURE, HK_FA_LAG_SKIP, HK_VOLUME_DOWN, HK_VOLUME_UP, diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index 8c5ef9e7..12790b69 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -39,6 +39,7 @@ #include "Qt/unix-netplay.h" #include "Qt/AviRecord.h" #include "Qt/HexEditor.h" +#include "Qt/CheatsConf.h" #include "Qt/SymbolicDebug.h" #include "Qt/CodeDataLogger.h" #include "Qt/ConsoleDebugger.h" @@ -352,6 +353,8 @@ int LoadGame(const char *path, bool silent) debugSymbolTable.loadGameSymbols(); + updateCheatDialog(); + CDLoggerROMChanged(); int state_to_load;