Add debug setting to start local game on startup (#5408)

* new properties

* refactor

* start local game on startup

* disable autoconnect
This commit is contained in:
RickyRister 2025-01-02 06:51:59 -08:00 committed by GitHub
parent bb4214e28a
commit 8a427955e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 1 deletions

View file

@ -223,6 +223,11 @@ void MainWindow::actSinglePlayer()
if (!ok) if (!ok)
return; return;
startLocalGame(numberPlayers);
}
void MainWindow::startLocalGame(int numberPlayers)
{
aConnect->setEnabled(false); aConnect->setEnabled(false);
aRegister->setEnabled(false); aRegister->setEnabled(false);
aForgotPassword->setEnabled(false); aForgotPassword->setEnabled(false);
@ -881,6 +886,10 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::startupConfigCheck() void MainWindow::startupConfigCheck()
{ {
if (SettingsCache::instance().debug().getLocalGameOnStartup()) {
startLocalGame(SettingsCache::instance().debug().getLocalGamePlayerCount());
}
if (SettingsCache::instance().getCheckUpdatesOnStartup()) { if (SettingsCache::instance().getCheckUpdatesOnStartup()) {
actCheckClientUpdates(); actCheckClientUpdates();
} }
@ -1021,7 +1030,8 @@ void MainWindow::changeEvent(QEvent *event)
if (!connectTo.isEmpty()) { if (!connectTo.isEmpty()) {
qDebug() << "Command line connect to " << connectTo; qDebug() << "Command line connect to " << connectTo;
client->connectToServer(connectTo.host(), connectTo.port(), connectTo.userName(), connectTo.password()); client->connectToServer(connectTo.host(), connectTo.port(), connectTo.userName(), connectTo.password());
} else if (SettingsCache::instance().servers().getAutoConnect()) { } else if (SettingsCache::instance().servers().getAutoConnect() &&
!SettingsCache::instance().debug().getLocalGameOnStartup()) {
qDebug() << "Attempting auto-connect..."; qDebug() << "Attempting auto-connect...";
DlgConnect dlg(this); DlgConnect dlg(this);
client->connectToServer(dlg.getHost(), static_cast<unsigned int>(dlg.getPort()), dlg.getPlayerName(), client->connectToServer(dlg.getHost(), static_cast<unsigned int>(dlg.getPort()), dlg.getPlayerName(),

View file

@ -126,6 +126,8 @@ private:
}; };
void exitCardDatabaseUpdate(); void exitCardDatabaseUpdate();
void startLocalGame(int numberPlayers);
QList<QMenu *> tabMenus; QList<QMenu *> tabMenus;
QMenu *cockatriceMenu, *dbMenu, *helpMenu, *trayIconMenu; QMenu *cockatriceMenu, *dbMenu, *helpMenu, *trayIconMenu;
QAction *aConnect, *aDisconnect, *aSinglePlayer, *aWatchReplay, *aDeckEditor, *aFullScreen, *aSettings, *aExit, QAction *aConnect, *aDisconnect, *aSinglePlayer, *aWatchReplay, *aDeckEditor, *aFullScreen, *aSettings, *aExit,

View file

@ -15,3 +15,13 @@ bool DebugSettings::getShowCardId()
{ {
return getValue("showCardId", "debug").toBool(); return getValue("showCardId", "debug").toBool();
} }
bool DebugSettings::getLocalGameOnStartup()
{
return getValue("onStartup", "localgame").toBool();
}
int DebugSettings::getLocalGamePlayerCount()
{
return getValue("playerCount", "localgame").toInt();
}

View file

@ -12,6 +12,9 @@ class DebugSettings : public SettingsManager
public: public:
bool getShowCardId(); bool getShowCardId();
bool getLocalGameOnStartup();
int getLocalGamePlayerCount();
}; };
#endif // DEBUG_SETTINGS_H #endif // DEBUG_SETTINGS_H