Minor cleanup of netplay main menu.

This commit is contained in:
harry 2024-04-07 15:11:27 -04:00
parent e032d65811
commit 9f8310bbe1
3 changed files with 65 additions and 31 deletions

View File

@ -1697,20 +1697,13 @@ void consoleWin_t::createMainMenu(void)
netPlayMenu->addAction(act); netPlayMenu->addAction(act);
// NetPlay -> End Game / Disconnect
act = new QAction(tr("&Disconnect/End Game"), this);
//act->setShortcut( QKeySequence(tr("Shift+F7")));
act->setStatusTip(tr("Disconnect Netplay Game"));
connect(act, SIGNAL(triggered()), this, SLOT(closeNetPlaySession(void)) );
netPlayDiscAct = act;
netPlayMenu->addAction(act);
// NetPlay -> Client Status Dialog // NetPlay -> Client Status Dialog
act = new QAction(tr("Host &Status"), this); act = new QAction(tr("Host &Status"), this);
//act->setShortcut( QKeySequence(tr("Shift+F7"))); //act->setShortcut( QKeySequence(tr("Shift+F7")));
act->setStatusTip(tr("Open Netplay Host Status Dialog")); act->setStatusTip(tr("Open Netplay Host Status Dialog"));
connect(act, SIGNAL(triggered()), this, SLOT(openNetPlayStatusWindow(void)) ); connect(act, SIGNAL(triggered()), this, SLOT(openNetPlayStatusWindow(void)) );
act->setEnabled(false);
act->setVisible(false);
netPlayHostStatAct = act; netPlayHostStatAct = act;
netPlayMenu->addAction(act); netPlayMenu->addAction(act);
@ -1720,10 +1713,27 @@ void consoleWin_t::createMainMenu(void)
//act->setShortcut( QKeySequence(tr("Shift+F7"))); //act->setShortcut( QKeySequence(tr("Shift+F7")));
act->setStatusTip(tr("Open Netplay Client Status Dialog")); act->setStatusTip(tr("Open Netplay Client Status Dialog"));
connect(act, SIGNAL(triggered()), this, SLOT(openNetPlayStatusWindow(void)) ); connect(act, SIGNAL(triggered()), this, SLOT(openNetPlayStatusWindow(void)) );
act->setEnabled(false);
act->setVisible(false);
netPlayClientStatAct = act; netPlayClientStatAct = act;
netPlayMenu->addAction(act); netPlayMenu->addAction(act);
netPlayMenu->addSeparator();
act = new QAction(tr(""), this);
act->setEnabled(false);
netPlayMenu->addAction(act);
// NetPlay -> End Game / Disconnect
act = new QAction(tr("&Disconnect/End Game"), this);
//act->setShortcut( QKeySequence(tr("Shift+F7")));
act->setStatusTip(tr("Disconnect Netplay Game"));
connect(act, SIGNAL(triggered()), this, SLOT(closeNetPlaySession(void)) );
act->setEnabled(false);
netPlayDiscAct = act;
netPlayMenu->addAction(act);
//netPlayMenu->setEnabled(false); //netPlayMenu->setEnabled(false);
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@ -4821,28 +4831,6 @@ void consoleWin_t::updatePeriodic(void)
recAsWavAct->setEnabled( FCEU_IsValidUI( FCEUI_RECORDMOVIE ) && !FCEUI_WaveRecordRunning() ); recAsWavAct->setEnabled( FCEU_IsValidUI( FCEUI_RECORDMOVIE ) && !FCEUI_WaveRecordRunning() );
stopWavAct->setEnabled( FCEUI_WaveRecordRunning() ); stopWavAct->setEnabled( FCEUI_WaveRecordRunning() );
tasEditorAct->setEnabled( FCEU_IsValidUI(FCEUI_TASEDITOR) ); tasEditorAct->setEnabled( FCEU_IsValidUI(FCEUI_TASEDITOR) );
const bool netPlayactv = NetPlayActive();
netPlayHostAct->setEnabled( !netPlayactv );
netPlayJoinAct->setEnabled( !netPlayactv );
netPlayDiscAct->setEnabled( netPlayactv );
if (netPlayactv)
{
const bool isHost = isNetPlayHost();
netPlayHostStatAct->setEnabled(isHost);
netPlayHostStatAct->setVisible(isHost);
netPlayClientStatAct->setEnabled(!isHost);
netPlayClientStatAct->setVisible(!isHost);
}
else
{
netPlayHostStatAct->setEnabled(false);
netPlayHostStatAct->setVisible(false);
netPlayClientStatAct->setEnabled(false);
netPlayClientStatAct->setVisible(false);
}
} }
if ( errorMsgValid ) if ( errorMsgValid )
@ -4875,6 +4863,31 @@ void consoleWin_t::updatePeriodic(void)
return; return;
} }
void consoleWin_t::onNetPlayChange(void)
{
const bool netPlayactv = NetPlayActive();
netPlayHostAct->setEnabled( !netPlayactv );
netPlayJoinAct->setEnabled( !netPlayactv );
netPlayDiscAct->setEnabled( netPlayactv );
if (netPlayactv)
{
const bool isHost = isNetPlayHost();
netPlayHostStatAct->setEnabled(isHost);
netPlayHostStatAct->setVisible(isHost);
netPlayClientStatAct->setEnabled(!isHost);
netPlayClientStatAct->setVisible(!isHost);
}
else
{
netPlayHostStatAct->setEnabled(false);
netPlayHostStatAct->setVisible(false);
netPlayClientStatAct->setEnabled(false);
netPlayClientStatAct->setVisible(false);
}
}
emulatorThread_t::emulatorThread_t( QObject *parent ) emulatorThread_t::emulatorThread_t( QObject *parent )
: QThread(parent) : QThread(parent)
{ {

View File

@ -340,6 +340,7 @@ class consoleWin_t : public QMainWindow
void toggleMenuVis(void); void toggleMenuVis(void);
void recordMovie(void); void recordMovie(void);
void winResizeIx(int iScale); void winResizeIx(int iScale);
void onNetPlayChange(void);
private slots: private slots:
void closeApp(void); void closeApp(void);
void openROMFile(void); void openROMFile(void);

View File

@ -220,6 +220,11 @@ int NetPlayServer::Create(QObject *parent)
traceRegistrationHandle = FCEUI_TraceInstructionRegister( NetPlayTraceInstruction ); traceRegistrationHandle = FCEUI_TraceInstructionRegister( NetPlayTraceInstruction );
} }
FCEU_WRAPPER_UNLOCK(); FCEU_WRAPPER_UNLOCK();
if (consoleWindow != nullptr)
{
consoleWindow->onNetPlayChange();
}
return 0; return 0;
} }
@ -241,6 +246,11 @@ int NetPlayServer::Destroy()
traceRegistrationHandle = nullptr; traceRegistrationHandle = nullptr;
} }
FCEU_WRAPPER_UNLOCK(); FCEU_WRAPPER_UNLOCK();
if (consoleWindow != nullptr)
{
consoleWindow->onNetPlayChange();
}
return 0; return 0;
} }
@ -1153,6 +1163,11 @@ int NetPlayClient::Create(QObject *parent)
traceRegistrationHandle = FCEUI_TraceInstructionRegister( NetPlayTraceInstruction ); traceRegistrationHandle = FCEUI_TraceInstructionRegister( NetPlayTraceInstruction );
} }
FCEU_WRAPPER_UNLOCK(); FCEU_WRAPPER_UNLOCK();
if (consoleWindow != nullptr)
{
consoleWindow->onNetPlayChange();
}
return 0; return 0;
} }
@ -1174,6 +1189,11 @@ int NetPlayClient::Destroy()
traceRegistrationHandle = nullptr; traceRegistrationHandle = nullptr;
} }
FCEU_WRAPPER_UNLOCK(); FCEU_WRAPPER_UNLOCK();
if (consoleWindow != nullptr)
{
consoleWindow->onNetPlayChange();
}
return 0; return 0;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------