Added game genie enable menu logic.

This commit is contained in:
Matthew Budd 2020-07-11 12:59:14 -04:00
parent 74afb50949
commit c41cd863c6
3 changed files with 50 additions and 0 deletions

View File

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

View File

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

View File

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