diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index dfca073b..e3b9bcc7 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -329,6 +329,19 @@ void consoleWin_t::createMainMenu(void) emuMenu->addAction(pauseAct); + emuMenu->addSeparator(); + + // Options -> Full Screen + gameGenieAct = new QAction(tr("Enable Game Genie"), this); + //gameGenieAct->setShortcut( QKeySequence(tr("Ctrl+G"))); + gameGenieAct->setCheckable(true); + gameGenieAct->setStatusTip(tr("Enable Game Genie")); + connect(gameGenieAct, SIGNAL(triggered(bool)), this, SLOT(toggleGameGenie(bool)) ); + + syncActionConfig( gameGenieAct, "SDL.GameGenie" ); + + emuMenu->addAction(gameGenieAct); + //----------------------------------------------------------------------- // Help helpMenu = menuBar()->addMenu(tr("Help")); @@ -829,12 +842,36 @@ void consoleWin_t::consolePause(void) return; } +void consoleWin_t::toggleGameGenie(bool checked) +{ + int gg_enabled; + + fceuWrapperLock(); + g_config->getOption ("SDL.GameGenie", &gg_enabled); + g_config->setOption ("SDL.GameGenie", !gg_enabled); + g_config->save (); + FCEUI_SetGameGenie (gg_enabled); + fceuWrapperUnLock(); + return; +} + void consoleWin_t::aboutFCEUX(void) { printf("About FCEUX\n"); return; } +void consoleWin_t::syncActionConfig( QAction *act, const char *property ) +{ + if ( act->isCheckable() ) + { + int enable; + g_config->getOption ( property, &enable); + + act->setChecked( enable ? true : false ); + } +} + void consoleWin_t::updatePeriodic(void) { //struct timespec ts; diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index 849caaee..a4b6bebb 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -74,6 +74,7 @@ class consoleWin_t : public QMainWindow QAction *resetAct; QAction *sresetAct; QAction *pauseAct; + QAction *gameGenieAct; QTimer *gameTimer; emulatorThread_t *emulatorThread; @@ -84,6 +85,7 @@ class consoleWin_t : public QMainWindow void closeEvent(QCloseEvent *event); void keyPressEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event); + void syncActionConfig( QAction *act, const char *property ); private: void createMainMenu(void); @@ -121,6 +123,7 @@ class consoleWin_t : public QMainWindow void consoleHardReset(void); void consoleSoftReset(void); void consolePause(void); + void toggleGameGenie(bool checked); }; diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index 7c360d3a..5c8943a5 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -203,9 +203,19 @@ DriverKill() */ int LoadGame(const char *path) { + int gg_enabled; + if (isloaded){ CloseGame(); } + + // For some reason, the core of the emulator clears the state of + // the game genie option selection. So check the config each time + // and re-enable the core game genie state if needed. + g_config->getOption ("SDL.GameGenie", &gg_enabled); + + FCEUI_SetGameGenie (gg_enabled); + if(!FCEUI_LoadGame(path, 1)) { return 0; }