Skip to content

Commit

Permalink
Qt netplay host game UI dialog improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
thor2016 committed Mar 22, 2024
1 parent 5a0898c commit 2ff6084
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
28 changes: 24 additions & 4 deletions src/drivers/Qt/NetPlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,7 @@ NetPlayHostDialog::NetPlayHostDialog(QWidget *parent)

passwordEntry = new QLineEdit();
grid->addWidget( passwordEntry, 4, 1 );
passwordEntry->setEnabled( passwordRequiredCBox->isChecked() );

// Misc Settings
grid = new QGridLayout();
Expand All @@ -1540,6 +1541,10 @@ NetPlayHostDialog::NetPlayHostDialog(QWidget *parent)
g_config->getOption("SDL.NetPlayHostAllowClientStateLoadReq", &stateLoadReqEna);
allowClientStateReqCBox->setChecked(stateLoadReqEna);

connect(passwordRequiredCBox, SIGNAL(stateChanged(int)), this, SLOT(passwordRequiredChanged(int)));
connect(allowClientRomReqCBox, SIGNAL(stateChanged(int)), this, SLOT(allowClientRomReqChanged(int)));
connect(allowClientStateReqCBox, SIGNAL(stateChanged(int)), this, SLOT(allowClientStateReqChanged(int)));

startButton = new QPushButton( tr("Start") );
startButton->setIcon(style()->standardIcon(QStyle::SP_DialogApplyButton));
connect(startButton, SIGNAL(clicked(void)), this, SLOT(onStartClicked(void)));
Expand Down Expand Up @@ -1578,6 +1583,21 @@ void NetPlayHostDialog::closeWindow(void)
deleteLater();
}
//-----------------------------------------------------------------------------
void NetPlayHostDialog::passwordRequiredChanged(int state)
{
passwordEntry->setEnabled( state != Qt::Unchecked );
}
//-----------------------------------------------------------------------------
void NetPlayHostDialog::allowClientRomReqChanged(int state)
{
g_config->setOption("SDL.NetPlayHostAllowClientRomLoadReq", state != Qt::Unchecked);
}
//-----------------------------------------------------------------------------
void NetPlayHostDialog::allowClientStateReqChanged(int state)
{
g_config->setOption("SDL.NetPlayHostAllowClientStateLoadReq", state != Qt::Unchecked);
}
//-----------------------------------------------------------------------------
void NetPlayHostDialog::onStartClicked(void)
{
NetPlayServer *server = NetPlayServer::GetInstance();
Expand All @@ -1593,14 +1613,14 @@ void NetPlayHostDialog::onStartClicked(void)
server = NetPlayServer::GetInstance();
server->setRole( playerRoleBox->currentData().toInt() );
server->sessionName = sessionNameEntry->text();
server->sessionPasswd = passwordEntry->text();
server->setMaxLeadFrames( frameLeadSpinBox->value() );
server->setAllowClientRomLoadRequest( allowClientRomReqCBox->isChecked() );
server->setAllowClientStateLoadRequest( allowClientStateReqCBox->isChecked() );

g_config->setOption("SDL.NetPlayHostAllowClientRomLoadReq", allowClientRomReqCBox->isChecked() );
g_config->setOption("SDL.NetPlayHostAllowClientStateLoadReq", allowClientStateReqCBox->isChecked() );

if (passwordRequiredCBox->isChecked())
{
server->sessionPasswd = passwordEntry->text();
}
bool listenSucceeded = server->listen( QHostAddress::Any, netPort );

if (listenSucceeded)
Expand Down
4 changes: 3 additions & 1 deletion src/drivers/Qt/NetPlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ class NetPlayHostDialog : public QDialog
public slots:
void closeWindow(void);
void onStartClicked(void);

void passwordRequiredChanged(int state);
void allowClientRomReqChanged(int state);
void allowClientStateReqChanged(int state);
};

class NetPlayJoinDialog : public QDialog
Expand Down

0 comments on commit 2ff6084

Please sign in to comment.