Added change state select menu radio button logic.

This commit is contained in:
Matthew Budd 2020-07-09 21:33:53 -04:00
parent 0d8c442b35
commit 67b7c34576
2 changed files with 115 additions and 0 deletions

View File

@ -99,6 +99,9 @@ void consoleWin_t::keyReleaseEvent(QKeyEvent *event)
//---------------------------------------------------------------------------
void consoleWin_t::createMainMenu(void)
{
QMenu *subMenu;
QActionGroup *group;
// This is needed for menu bar to show up on MacOS
menuBar()->setNativeMenuBar(false);
@ -166,6 +169,37 @@ void consoleWin_t::createMainMenu(void)
fileMenu->addAction(quickSaveAct);
// File -> Change State
subMenu = fileMenu->addMenu(tr("Change State"));
group = new QActionGroup(this);
group->setExclusive(true);
for (int i=0; i<10; i++)
{
char stmp[8];
sprintf( stmp, "%i", i );
state[i] = new QAction(tr(stmp));
state[i]->setCheckable(true);
group->addAction(state[i]);
subMenu->addAction(state[i]);
}
state[0]->setChecked(true);
connect(state[0], SIGNAL(triggered()), this, SLOT(changeState0(void)) );
connect(state[1], SIGNAL(triggered()), this, SLOT(changeState1(void)) );
connect(state[2], SIGNAL(triggered()), this, SLOT(changeState2(void)) );
connect(state[3], SIGNAL(triggered()), this, SLOT(changeState3(void)) );
connect(state[4], SIGNAL(triggered()), this, SLOT(changeState4(void)) );
connect(state[5], SIGNAL(triggered()), this, SLOT(changeState5(void)) );
connect(state[6], SIGNAL(triggered()), this, SLOT(changeState6(void)) );
connect(state[7], SIGNAL(triggered()), this, SLOT(changeState7(void)) );
connect(state[8], SIGNAL(triggered()), this, SLOT(changeState8(void)) );
connect(state[9], SIGNAL(triggered()), this, SLOT(changeState9(void)) );
fileMenu->addSeparator();
// File -> Quit
@ -478,6 +512,76 @@ void consoleWin_t::quickSave(void)
fceuWrapperUnLock();
}
void consoleWin_t::changeState0(void)
{
fceuWrapperLock();
FCEUI_SelectState( 0, 1 );
fceuWrapperUnLock();
}
void consoleWin_t::changeState1(void)
{
fceuWrapperLock();
FCEUI_SelectState( 1, 1 );
fceuWrapperUnLock();
}
void consoleWin_t::changeState2(void)
{
fceuWrapperLock();
FCEUI_SelectState( 2, 1 );
fceuWrapperUnLock();
}
void consoleWin_t::changeState3(void)
{
fceuWrapperLock();
FCEUI_SelectState( 3, 1 );
fceuWrapperUnLock();
}
void consoleWin_t::changeState4(void)
{
fceuWrapperLock();
FCEUI_SelectState( 4, 1 );
fceuWrapperUnLock();
}
void consoleWin_t::changeState5(void)
{
fceuWrapperLock();
FCEUI_SelectState( 5, 1 );
fceuWrapperUnLock();
}
void consoleWin_t::changeState6(void)
{
fceuWrapperLock();
FCEUI_SelectState( 6, 1 );
fceuWrapperUnLock();
}
void consoleWin_t::changeState7(void)
{
fceuWrapperLock();
FCEUI_SelectState( 7, 1 );
fceuWrapperUnLock();
}
void consoleWin_t::changeState8(void)
{
fceuWrapperLock();
FCEUI_SelectState( 8, 1 );
fceuWrapperUnLock();
}
void consoleWin_t::changeState9(void)
{
fceuWrapperLock();
FCEUI_SelectState( 9, 1 );
fceuWrapperUnLock();
}
void consoleWin_t::openGamePadConfWin(void)
{
if ( gamePadConfWin != NULL )

View File

@ -66,6 +66,7 @@ class consoleWin_t : public QMainWindow
QAction *autoResume;
QAction *fullscreen;
QAction *aboutAct;
QAction *state[10];
QTimer *gameTimer;
emulatorThread_t *emulatorThread;
@ -97,6 +98,16 @@ class consoleWin_t : public QMainWindow
void toggleAutoResume(void);
void toggleFullscreen(void);
void updatePeriodic(void);
void changeState0(void);
void changeState1(void);
void changeState2(void);
void changeState3(void);
void changeState4(void);
void changeState5(void);
void changeState6(void);
void changeState7(void);
void changeState8(void);
void changeState9(void);
};