Added autofire pattern presets to Qt emulation menu. Changed custom autofire pattern entry to use a single dialog window. Autofire pattern is now saved as a config parameter.
This commit is contained in:
parent
11f1a16ce5
commit
635cd07020
|
@ -678,6 +678,7 @@ void consoleWin_t::createMainMenu(void)
|
||||||
QMenu *subMenu, *aviMenu;
|
QMenu *subMenu, *aviMenu;
|
||||||
QActionGroup *group;
|
QActionGroup *group;
|
||||||
int useNativeMenuBar;
|
int useNativeMenuBar;
|
||||||
|
int customAutofireOnFrames, customAutofireOffFrames;
|
||||||
//QShortcut *shortcut;
|
//QShortcut *shortcut;
|
||||||
|
|
||||||
menubar = new consoleMenuBar(this);
|
menubar = new consoleMenuBar(this);
|
||||||
|
@ -1283,17 +1284,45 @@ void consoleWin_t::createMainMenu(void)
|
||||||
// Emulation -> AutoFire Pattern
|
// Emulation -> AutoFire Pattern
|
||||||
subMenu = emuMenu->addMenu(tr("&AutoFire Pattern"));
|
subMenu = emuMenu->addMenu(tr("&AutoFire Pattern"));
|
||||||
|
|
||||||
// Emulation -> AutoFire Pattern -> # On Frames
|
group = new QActionGroup(this);
|
||||||
act = new QAction(tr("# O&N Frames"), this);
|
group->setExclusive(true);
|
||||||
act->setStatusTip(tr("# ON Frames"));
|
|
||||||
connect(act, SIGNAL(triggered()), this, SLOT(setAutoFireOnFrames(void)) );
|
|
||||||
|
|
||||||
subMenu->addAction(act);
|
for (int i=1; i<6; i++)
|
||||||
|
{
|
||||||
|
char stmp[64];
|
||||||
|
|
||||||
// Emulation -> AutoFire Pattern -> # Off Frames
|
for (int j=1; j<=(6-i); j++)
|
||||||
act = new QAction(tr("# O&FF Frames"), this);
|
{
|
||||||
act->setStatusTip(tr("# OFF Frames"));
|
sprintf( stmp, "%i On, %i Off", i, j );
|
||||||
connect(act, SIGNAL(triggered()), this, SLOT(setAutoFireOffFrames(void)) );
|
autoFireMenuAction *afAct = new autoFireMenuAction( i, j, tr(stmp), this);
|
||||||
|
afAct->setCheckable(true);
|
||||||
|
group->addAction(afAct);
|
||||||
|
subMenu->addAction(afAct);
|
||||||
|
afActList.push_back(afAct);
|
||||||
|
|
||||||
|
connect( afAct, SIGNAL(triggered(void)), afAct, SLOT(activateCB(void)) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_config->getOption("SDL.AutofireCustomOnFrames" , &customAutofireOnFrames );
|
||||||
|
g_config->getOption("SDL.AutofireCustomOffFrames" , &customAutofireOffFrames);
|
||||||
|
|
||||||
|
afActCustom = new autoFireMenuAction( customAutofireOnFrames, customAutofireOffFrames, tr("Custom"), this);
|
||||||
|
afActCustom->setCheckable(true);
|
||||||
|
group->addAction(afActCustom);
|
||||||
|
subMenu->addAction(afActCustom);
|
||||||
|
//afActList.push_back(afAct);
|
||||||
|
|
||||||
|
connect( afActCustom, SIGNAL(triggered(void)), afActCustom, SLOT(activateCB(void)) );
|
||||||
|
|
||||||
|
subMenu->addSeparator();
|
||||||
|
|
||||||
|
syncAutoFirePatternMenu();
|
||||||
|
|
||||||
|
// Emulation -> AutoFire Pattern -> Set Custom Pattern
|
||||||
|
act = new QAction(tr("Set Custom Pattern"), this);
|
||||||
|
act->setStatusTip(tr("Set Custom Pattern"));
|
||||||
|
connect(act, SIGNAL(triggered()), this, SLOT(setCustomAutoFire(void)) );
|
||||||
|
|
||||||
subMenu->addAction(act);
|
subMenu->addAction(act);
|
||||||
|
|
||||||
|
@ -3082,51 +3111,96 @@ void consoleWin_t::emuSetFrameAdvDelay(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void consoleWin_t::setAutoFireOnFrames(void)
|
void consoleWin_t::syncAutoFirePatternMenu(void)
|
||||||
|
{
|
||||||
|
int on, off;
|
||||||
|
|
||||||
|
GetAutoFirePattern( &on, &off );
|
||||||
|
|
||||||
|
for (size_t i=0; i<afActList.size(); i++)
|
||||||
|
{
|
||||||
|
if ( afActList[i]->isMatch( on, off ) )
|
||||||
|
{
|
||||||
|
afActList[i]->setChecked(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we get here, then the custom option is selected.
|
||||||
|
afActCustom->setChecked(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
void consoleWin_t::setCustomAutoFire(void)
|
||||||
{
|
{
|
||||||
int ret, autoFireOnFrames, autoFireOffFrames;
|
int ret, autoFireOnFrames, autoFireOffFrames;
|
||||||
QInputDialog dialog(this);
|
QDialog dialog(this);
|
||||||
|
QLabel *lbl;
|
||||||
|
QGridLayout *grid;
|
||||||
|
QVBoxLayout *vbox;
|
||||||
|
QSpinBox *onBox, *offBox;
|
||||||
|
QPushButton *okButton, *cancelButton;
|
||||||
|
|
||||||
GetAutoFirePattern( &autoFireOnFrames, &autoFireOffFrames );
|
autoFireOnFrames = afActCustom->getOnValue();
|
||||||
|
autoFireOffFrames = afActCustom->getOffValue();
|
||||||
|
|
||||||
dialog.setWindowTitle( tr("AutoFire Pattern ON Frames") );
|
dialog.setWindowTitle( tr("Custom AutoFire Pattern") );
|
||||||
dialog.setLabelText( tr("Specify desired number of ON frames in autofire pattern:") );
|
|
||||||
dialog.setOkButtonText( tr("Ok") );
|
onBox = new QSpinBox();
|
||||||
dialog.setInputMode( QInputDialog::IntInput );
|
offBox = new QSpinBox();
|
||||||
dialog.setIntRange( 1, 30 );
|
|
||||||
dialog.setIntValue( autoFireOnFrames );
|
onBox->setMinimum( 1);
|
||||||
|
offBox->setMinimum( 1);
|
||||||
|
onBox->setMaximum(30);
|
||||||
|
offBox->setMaximum(30);
|
||||||
|
|
||||||
|
onBox->setValue( autoFireOnFrames );
|
||||||
|
offBox->setValue( autoFireOffFrames );
|
||||||
|
|
||||||
|
vbox = new QVBoxLayout();
|
||||||
|
grid = new QGridLayout();
|
||||||
|
|
||||||
|
lbl = new QLabel( tr("# ON Frames") );
|
||||||
|
|
||||||
|
grid->addWidget( lbl, 0, 0 );
|
||||||
|
|
||||||
|
lbl = new QLabel( tr("# OFF Frames") );
|
||||||
|
|
||||||
|
grid->addWidget( lbl, 1, 0 );
|
||||||
|
|
||||||
|
grid->addWidget( onBox , 0, 1 );
|
||||||
|
grid->addWidget( offBox, 1, 1 );
|
||||||
|
|
||||||
|
okButton = new QPushButton( tr("Ok") );
|
||||||
|
cancelButton = new QPushButton( tr("Cancel") );
|
||||||
|
|
||||||
|
grid->addWidget( cancelButton , 2, 0 );
|
||||||
|
grid->addWidget( okButton , 2, 1 );
|
||||||
|
|
||||||
|
vbox->addLayout( grid );
|
||||||
|
|
||||||
|
dialog.setLayout( vbox );
|
||||||
|
|
||||||
|
connect( cancelButton, SIGNAL(clicked(void)), &dialog, SLOT(reject(void)) );
|
||||||
|
connect( okButton, SIGNAL(clicked(void)), &dialog, SLOT(accept(void)) );
|
||||||
|
|
||||||
|
okButton->setDefault(true);
|
||||||
|
|
||||||
ret = dialog.exec();
|
ret = dialog.exec();
|
||||||
|
|
||||||
if ( QDialog::Accepted == ret )
|
if ( QDialog::Accepted == ret )
|
||||||
{
|
{
|
||||||
autoFireOnFrames = dialog.intValue();
|
autoFireOnFrames = onBox->value();
|
||||||
|
autoFireOffFrames = offBox->value();
|
||||||
|
|
||||||
SetAutoFirePattern( autoFireOnFrames, autoFireOffFrames );
|
afActCustom->setPattern( autoFireOnFrames, autoFireOffFrames );
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void consoleWin_t::setAutoFireOffFrames(void)
|
if ( afActCustom->isChecked() )
|
||||||
{
|
{
|
||||||
int ret, autoFireOnFrames, autoFireOffFrames;
|
afActCustom->activateCB();
|
||||||
QInputDialog dialog(this);
|
}
|
||||||
|
g_config->setOption("SDL.AutofireCustomOnFrames" , autoFireOnFrames );
|
||||||
GetAutoFirePattern( &autoFireOnFrames, &autoFireOffFrames );
|
g_config->setOption("SDL.AutofireCustomOffFrames" , autoFireOffFrames);
|
||||||
|
g_config->save();
|
||||||
dialog.setWindowTitle( tr("AutoFire Pattern OFF Frames") );
|
|
||||||
dialog.setLabelText( tr("Specify desired number of OFF frames in autofire pattern:") );
|
|
||||||
dialog.setOkButtonText( tr("Ok") );
|
|
||||||
dialog.setInputMode( QInputDialog::IntInput );
|
|
||||||
dialog.setIntRange( 1, 30 );
|
|
||||||
dialog.setIntValue( autoFireOffFrames );
|
|
||||||
|
|
||||||
ret = dialog.exec();
|
|
||||||
|
|
||||||
if ( QDialog::Accepted == ret )
|
|
||||||
{
|
|
||||||
autoFireOffFrames = dialog.intValue();
|
|
||||||
|
|
||||||
SetAutoFirePattern( autoFireOnFrames, autoFireOffFrames );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4111,4 +4185,33 @@ void consoleRecentRomAction::activateCB(void)
|
||||||
fceuWrapperUnLock();
|
fceuWrapperUnLock();
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
autoFireMenuAction::autoFireMenuAction(int on, int off, QString name, QWidget *parent)
|
||||||
|
: QAction( name, parent)
|
||||||
|
{
|
||||||
|
onFrames = on; offFrames = off;
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
autoFireMenuAction::~autoFireMenuAction(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void autoFireMenuAction::activateCB(void)
|
||||||
|
{
|
||||||
|
g_config->setOption("SDL.AutofireOnFrames" , onFrames );
|
||||||
|
g_config->setOption("SDL.AutofireOffFrames" , offFrames);
|
||||||
|
g_config->save();
|
||||||
|
|
||||||
|
SetAutoFirePattern( onFrames, offFrames );
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool autoFireMenuAction::isMatch( int on, int off )
|
||||||
|
{
|
||||||
|
return ( (on == onFrames) && (off == offFrames) );
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void autoFireMenuAction::setPattern(int on, int off)
|
||||||
|
{
|
||||||
|
onFrames = on; offFrames = off;
|
||||||
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -72,6 +72,29 @@ class consoleMenuBar : public QMenuBar
|
||||||
void keyReleaseEvent(QKeyEvent *event);
|
void keyReleaseEvent(QKeyEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class autoFireMenuAction : public QAction
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
autoFireMenuAction(int on, int off, QString name, QWidget *parent = 0);
|
||||||
|
~autoFireMenuAction(void);
|
||||||
|
|
||||||
|
bool isMatch( int on, int off );
|
||||||
|
|
||||||
|
void setPattern( int on, int off );
|
||||||
|
|
||||||
|
int getOnValue(void){ return onFrames; };
|
||||||
|
int getOffValue(void){ return offFrames; };
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void activateCB(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int onFrames;
|
||||||
|
int offFrames;
|
||||||
|
};
|
||||||
|
|
||||||
class consoleRecentRomAction : public QAction
|
class consoleRecentRomAction : public QAction
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -225,6 +248,8 @@ class consoleWin_t : public QMainWindow
|
||||||
bool mainMenuPauseWhenActv;
|
bool mainMenuPauseWhenActv;
|
||||||
|
|
||||||
std::list <std::string*> romList;
|
std::list <std::string*> romList;
|
||||||
|
std::vector <autoFireMenuAction*> afActList;
|
||||||
|
autoFireMenuAction *afActCustom;
|
||||||
|
|
||||||
unsigned int updateCounter;
|
unsigned int updateCounter;
|
||||||
protected:
|
protected:
|
||||||
|
@ -245,6 +270,7 @@ class consoleWin_t : public QMainWindow
|
||||||
void changeState(int slot);
|
void changeState(int slot);
|
||||||
void saveState(int slot);
|
void saveState(int slot);
|
||||||
void loadState(int slot);
|
void loadState(int slot);
|
||||||
|
void syncAutoFirePatternMenu(void);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void openDebugWindow(void);
|
void openDebugWindow(void);
|
||||||
|
@ -331,8 +357,7 @@ class consoleWin_t : public QMainWindow
|
||||||
void recordMovie(void);
|
void recordMovie(void);
|
||||||
void recordMovieAs(void);
|
void recordMovieAs(void);
|
||||||
void playMovieFromBeginning(void);
|
void playMovieFromBeginning(void);
|
||||||
void setAutoFireOnFrames(void);
|
void setCustomAutoFire(void);
|
||||||
void setAutoFireOffFrames(void);
|
|
||||||
void incrSoundVolume(void);
|
void incrSoundVolume(void);
|
||||||
void decrSoundVolume(void);
|
void decrSoundVolume(void);
|
||||||
void toggleLagCounterDisplay(void);
|
void toggleLagCounterDisplay(void);
|
||||||
|
|
|
@ -529,6 +529,10 @@ InitConfig()
|
||||||
config->addOption("input4", "SDL.Input.3", "Gamepad.3");
|
config->addOption("input4", "SDL.Input.3", "Gamepad.3");
|
||||||
|
|
||||||
config->addOption("autoInputPreset", "SDL.AutoInputPreset", 0);
|
config->addOption("autoInputPreset", "SDL.AutoInputPreset", 0);
|
||||||
|
config->addOption("SDL.AutofireOnFrames" , 1);
|
||||||
|
config->addOption("SDL.AutofireOffFrames", 1);
|
||||||
|
config->addOption("SDL.AutofireCustomOnFrames" , 1);
|
||||||
|
config->addOption("SDL.AutofireCustomOffFrames", 1);
|
||||||
|
|
||||||
// display input
|
// display input
|
||||||
config->addOption("inputdisplay", "SDL.InputDisplay", 0);
|
config->addOption("inputdisplay", "SDL.InputDisplay", 0);
|
||||||
|
|
|
@ -739,6 +739,13 @@ int fceuWrapperInit( int argc, char *argv[] )
|
||||||
|
|
||||||
g_config->getOption ("SDL.DrawInputAids", &drawInputAidsEnable);
|
g_config->getOption ("SDL.DrawInputAids", &drawInputAidsEnable);
|
||||||
|
|
||||||
|
// Initialize Autofire Pattern
|
||||||
|
int autofireOnFrames=1, autofireOffFrames=1;
|
||||||
|
g_config->getOption ("SDL.AutofireOnFrames" , &autofireOnFrames );
|
||||||
|
g_config->getOption ("SDL.AutofireOffFrames", &autofireOffFrames);
|
||||||
|
|
||||||
|
SetAutoFirePattern( autofireOnFrames, autofireOffFrames );
|
||||||
|
|
||||||
// check to see if recording HUD to AVI is enabled
|
// check to see if recording HUD to AVI is enabled
|
||||||
int rh;
|
int rh;
|
||||||
g_config->getOption("SDL.RecordHUD", &rh);
|
g_config->getOption("SDL.RecordHUD", &rh);
|
||||||
|
|
Loading…
Reference in New Issue