Qt Input config window further code hardening.

This commit is contained in:
Matthew Budd 2020-11-24 06:25:12 -05:00
parent 85cee7fd4a
commit c4a066c25c
3 changed files with 47 additions and 17 deletions

View File

@ -43,6 +43,7 @@ InputConfDialog_t::InputConfDialog_t(QWidget *parent)
QPalette pal;
QColor color;
char stmp[256];
int fourscore;
pal = this->palette();
@ -56,6 +57,10 @@ InputConfDialog_t::InputConfDialog_t(QWidget *parent)
fourScoreEna = new QCheckBox( tr("Attach 4-Score (Implies four gamepads)") );
port2Mic = new QCheckBox( tr("Replace Port 2 Start with Microphone") );
g_config->getOption("SDL.FourScore", &fourscore);
fourScoreEna->setChecked( fourscore );
port2Mic->setChecked( replaceP2StartWithMicrophone );
hbox->addWidget( fourScoreEna );
hbox->addWidget( port2Mic );
vbox1->addLayout( hbox );
@ -108,11 +113,11 @@ 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( new QLabel( tr("File:") ) );
//hbox->addWidget( saveFileName = new QLineEdit() );
//saveFileName->setReadOnly(true);
hbox = new QHBoxLayout();
vbox->addLayout( hbox );
@ -158,7 +163,7 @@ InputConfDialog_t::InputConfDialog_t(QWidget *parent)
for (int j=0; j<nesPortComboxBox[i]->count(); j++)
{
if ( nesPortComboxBox[i]->itemData(j).toInt() == usrNesInput[i] )
if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] )
{
nesPortComboxBox[i]->setCurrentIndex( j );
}
@ -184,7 +189,7 @@ InputConfDialog_t::InputConfDialog_t(QWidget *parent)
for (int j=0; j<expPortComboxBox->count(); j++)
{
if ( expPortComboxBox->itemData(j).toInt() == usrNesInput[2] )
if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] )
{
expPortComboxBox->setCurrentIndex( j );
}
@ -194,6 +199,9 @@ 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( nesPortComboxBox[0], SIGNAL(activated(int)), this, SLOT(port1Select(int)) );
connect( nesPortComboxBox[1], SIGNAL(activated(int)), this, SLOT(port2Select(int)) );
connect( expPortComboxBox , SIGNAL(activated(int)), this, SLOT(expSelect(int)) );
@ -241,6 +249,8 @@ void InputConfDialog_t::setInputs(void)
g_config->getOption("SDL.FourScore", &fourscore);
microphone = port2Mic->isChecked();
idx[0] = nesPortComboxBox[0]->currentIndex();
idx[1] = nesPortComboxBox[1]->currentIndex();
idx[2] = expPortComboxBox->currentIndex();
@ -289,16 +299,18 @@ void InputConfDialog_t::updatePortComboBoxes(void)
for (int j=0; j<nesPortComboxBox[i]->count(); j++)
{
if ( nesPortComboxBox[i]->itemData(j).toInt() == usrNesInput[i] )
if ( nesPortComboxBox[i]->itemData(j).toInt() == curNesInput[i] )
{
nesPortComboxBox[i]->setCurrentIndex( j );
}
}
}
getInputSelection( 2, &curNesInput[2], &usrNesInput[2] );
for (int j=0; j<expPortComboxBox->count(); j++)
{
if ( expPortComboxBox->itemData(j).toInt() == usrNesInput[2] )
if ( expPortComboxBox->itemData(j).toInt() == curNesInput[2] )
{
expPortComboxBox->setCurrentIndex( j );
}
@ -326,6 +338,22 @@ void InputConfDialog_t::expSelect(int index)
updatePortLabels();
}
//----------------------------------------------------------------------------
void InputConfDialog_t::fourScoreChanged(int state)
{
int value = (state == Qt::Unchecked) ? 0 : 1;
//printf("Set 'SDL.FourScore' = %i\n", value);
g_config->setOption("SDL.FourScore", value);
setInputs();
updatePortLabels();
}
//----------------------------------------------------------------------------
void InputConfDialog_t::port2MicChanged(int state)
{
setInputs();
updatePortLabels();
}
//----------------------------------------------------------------------------
void InputConfDialog_t::openPortConfig(int portNum)
{
switch ( curNesInput[portNum] )

View File

@ -40,7 +40,7 @@ class InputConfDialog_t : public QDialog
QComboBox *expPortComboxBox;
QPushButton *loadConfigButton;
QPushButton *saveConfigButton;
QLineEdit *saveFileName;
//QLineEdit *saveFileName;
int curNesInput[3];
int usrNesInput[3];
@ -59,6 +59,8 @@ class InputConfDialog_t : public QDialog
void port1Select(int index);
void port2Select(int index);
void expSelect(int index);
void fourScoreChanged(int state);
void port2MicChanged(int state);
void openLoadPresetFile(void);
void openSavePresetFile(void);

View File

@ -267,14 +267,14 @@ int LoadGame(const char *path, bool silent)
CDLoggerROMChanged();
int state_to_load;
g_config->getOption("SDL.AutoLoadState", &state_to_load);
if (state_to_load >= 0 && state_to_load < 10){
FCEUI_SelectState(state_to_load, 0);
FCEUI_LoadState(NULL, false);
}
int state_to_load;
g_config->getOption("SDL.AutoLoadState", &state_to_load);
if (state_to_load >= 0 && state_to_load < 10){
FCEUI_SelectState(state_to_load, 0);
FCEUI_LoadState(NULL, false);
}
loadInputSettingsFromFile();
loadInputSettingsFromFile();
ParseGIInput(GameInfo);
RefreshThrottleFPS();