For Qt GUI, added a checkbox to allow for auto load/save of input presets on ROM open/close.
This commit is contained in:
parent
fa18154ac3
commit
c9d0eddec6
|
@ -18,6 +18,7 @@
|
|||
#include "Qt/keyscan.h"
|
||||
#include "Qt/fceuWrapper.h"
|
||||
#include "Qt/ConsoleWindow.h"
|
||||
#include "Qt/ConsoleUtilities.h"
|
||||
#include "Qt/InputConf.h"
|
||||
|
||||
static InputConfDialog_t *win = NULL;
|
||||
|
@ -43,7 +44,7 @@ InputConfDialog_t::InputConfDialog_t(QWidget *parent)
|
|||
QPalette pal;
|
||||
QColor color;
|
||||
char stmp[256];
|
||||
int fourscore;
|
||||
int fourscore, autoInputPreset;
|
||||
|
||||
pal = this->palette();
|
||||
|
||||
|
@ -60,11 +61,15 @@ InputConfDialog_t::InputConfDialog_t(QWidget *parent)
|
|||
hbox = new QHBoxLayout();
|
||||
fourScoreEna = new QCheckBox( tr("Attach 4-Score (Implies four gamepads)") );
|
||||
port2Mic = new QCheckBox( tr("Replace Port 2 Start with Microphone") );
|
||||
autoPreset = new QCheckBox( tr("Auto Load/Save Presets at ROM Open/Close") );
|
||||
|
||||
g_config->getOption("SDL.FourScore", &fourscore);
|
||||
fourScoreEna->setChecked( fourscore );
|
||||
port2Mic->setChecked( replaceP2StartWithMicrophone );
|
||||
|
||||
g_config->getOption( "SDL.AutoInputPreset", &autoInputPreset );
|
||||
autoPreset->setChecked( autoInputPreset );
|
||||
|
||||
hbox->addWidget( fourScoreEna );
|
||||
hbox->addWidget( port2Mic );
|
||||
vbox1->addLayout( hbox );
|
||||
|
@ -117,11 +122,9 @@ InputConfDialog_t::InputConfDialog_t(QWidget *parent)
|
|||
mainLayout->addLayout( hbox );
|
||||
|
||||
vbox = new QVBoxLayout();
|
||||
//hbox = new QHBoxLayout();
|
||||
//vbox->addLayout( hbox );
|
||||
//hbox->addWidget( new QLabel( tr("File:") ) );
|
||||
//hbox->addWidget( saveFileName = new QLineEdit() );
|
||||
//saveFileName->setReadOnly(true);
|
||||
hbox = new QHBoxLayout();
|
||||
vbox->addLayout( hbox );
|
||||
hbox->addWidget( autoPreset );
|
||||
|
||||
hbox = new QHBoxLayout();
|
||||
vbox->addLayout( hbox );
|
||||
|
@ -205,6 +208,7 @@ InputConfDialog_t::InputConfDialog_t(QWidget *parent)
|
|||
|
||||
connect( fourScoreEna, SIGNAL(stateChanged(int)), this, SLOT(fourScoreChanged(int)) );
|
||||
connect( port2Mic , SIGNAL(stateChanged(int)), this, SLOT(port2MicChanged(int)) );
|
||||
connect( autoPreset , SIGNAL(stateChanged(int)), this, SLOT(autoPresetChanged(int)));
|
||||
|
||||
connect( nesPortComboxBox[0], SIGNAL(activated(int)), this, SLOT(port1Select(int)) );
|
||||
connect( nesPortComboxBox[1], SIGNAL(activated(int)), this, SLOT(port2Select(int)) );
|
||||
|
@ -361,6 +365,13 @@ void InputConfDialog_t::port2MicChanged(int state)
|
|||
updatePortLabels();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::autoPresetChanged(int state)
|
||||
{
|
||||
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||
//printf("Set 'SDL.AutoInputPreset' = %i\n", value);
|
||||
g_config->setOption("SDL.AutoInputPreset", value);
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void InputConfDialog_t::openPortConfig(int portNum)
|
||||
{
|
||||
updatePortLabels();
|
||||
|
@ -453,7 +464,7 @@ void InputConfDialog_t::openSavePresetFile(void)
|
|||
int ret, useNativeFileDialogVal;
|
||||
QString filename;
|
||||
std::string path;
|
||||
const char *baseDir;
|
||||
const char *baseDir, *romFile;
|
||||
QFileDialog dialog(this, tr("Save Preset to File") );
|
||||
QDir dir;
|
||||
|
||||
|
@ -472,6 +483,19 @@ void InputConfDialog_t::openSavePresetFile(void)
|
|||
dialog.setLabelText( QFileDialog::Accept, tr("Save") );
|
||||
dialog.setDefaultSuffix( tr(".pre") );
|
||||
|
||||
romFile = getRomFile();
|
||||
|
||||
if ( romFile != NULL )
|
||||
{
|
||||
char dirStr[256], base[256];
|
||||
|
||||
parseFilepath( romFile, dirStr, base );
|
||||
|
||||
strcat( base, ".pre");
|
||||
|
||||
dialog.selectFile( tr(base) );
|
||||
}
|
||||
|
||||
dialog.setDirectory( tr(path.c_str()) );
|
||||
|
||||
// Check config option to use native file dialog or not
|
||||
|
|
|
@ -34,6 +34,7 @@ class InputConfDialog_t : public QDialog
|
|||
QTimer *inputTimer;
|
||||
QCheckBox *fourScoreEna;
|
||||
QCheckBox *port2Mic;
|
||||
QCheckBox *autoPreset;
|
||||
QLabel *nesPortLabel[2];
|
||||
QPushButton *nesPortConfButton[2];
|
||||
QComboBox *nesPortComboxBox[2];
|
||||
|
@ -63,6 +64,7 @@ class InputConfDialog_t : public QDialog
|
|||
void expSelect(int index);
|
||||
void fourScoreChanged(int state);
|
||||
void port2MicChanged(int state);
|
||||
void autoPresetChanged(int state);
|
||||
void openLoadPresetFile(void);
|
||||
void openSavePresetFile(void);
|
||||
void updatePeriodic(void);
|
||||
|
|
|
@ -241,6 +241,8 @@ InitConfig()
|
|||
config->addOption("input3", "SDL.Input.2", "Gamepad.2");
|
||||
config->addOption("input4", "SDL.Input.3", "Gamepad.3");
|
||||
|
||||
config->addOption("autoInputPreset", "SDL.AutoInputPreset", 0);
|
||||
|
||||
// allow for input configuration
|
||||
//config->addOption('i', "inputcfg", "SDL.InputCfg", InputCfg);
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ int reloadLastGame(void)
|
|||
*/
|
||||
int LoadGame(const char *path, bool silent)
|
||||
{
|
||||
int gg_enabled, autoLoadDebug, autoOpenDebugger;
|
||||
int gg_enabled, autoLoadDebug, autoOpenDebugger, autoInputPreset;
|
||||
|
||||
if (isloaded){
|
||||
CloseGame();
|
||||
|
@ -274,7 +274,12 @@ int LoadGame(const char *path, bool silent)
|
|||
FCEUI_LoadState(NULL, false);
|
||||
}
|
||||
|
||||
loadInputSettingsFromFile();
|
||||
g_config->getOption( "SDL.AutoInputPreset", &autoInputPreset );
|
||||
|
||||
if ( autoInputPreset )
|
||||
{
|
||||
loadInputSettingsFromFile();
|
||||
}
|
||||
|
||||
ParseGIInput(GameInfo);
|
||||
RefreshThrottleFPS();
|
||||
|
@ -329,7 +334,14 @@ CloseGame(void)
|
|||
FCEUI_SelectState(state_to_save, 0);
|
||||
FCEUI_SaveState(NULL, false);
|
||||
}
|
||||
saveInputSettingsToFile();
|
||||
|
||||
int autoInputPreset;
|
||||
g_config->getOption( "SDL.AutoInputPreset", &autoInputPreset );
|
||||
|
||||
if ( autoInputPreset )
|
||||
{
|
||||
saveInputSettingsToFile();
|
||||
}
|
||||
|
||||
FCEUI_CloseGame();
|
||||
|
||||
|
|
Loading…
Reference in New Issue