From 49b1efdcf1663f6eb7e50e698e3670ea1c8c55a0 Mon Sep 17 00:00:00 2001 From: doitux Date: Sat, 13 Sep 2008 20:40:08 +0000 Subject: [PATCH] next steps startwindow-integration --> UNSTABLE --- src/gui/qt/gametable.ui | 9 + src/gui/qt/gametable/gametableimpl.cpp | 456 ++------------------- src/gui/qt/gametable/gametableimpl.h | 43 +- src/gui/qt/gametable/myavatarlabel.cpp | 4 +- src/gui/qt/guiwrapper.cpp | 3 +- src/gui/qt/guiwrapper.h | 2 +- src/gui/qt/startwindow/startwindowimpl.cpp | 116 +++++- src/gui/qt/startwindow/startwindowimpl.h | 3 +- 8 files changed, 178 insertions(+), 458 deletions(-) diff --git a/src/gui/qt/gametable.ui b/src/gui/qt/gametable.ui index 7c4bd190..539f4863 100644 --- a/src/gui/qt/gametable.ui +++ b/src/gui/qt/gametable.ui @@ -2886,6 +2886,7 @@ + @@ -2998,6 +2999,14 @@ Configure PokerTH ... + + + Close + + + Ctrl+X + + diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index d530dd73..76c895fd 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -472,16 +472,14 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) } // Dialogs - myNewGameDialog = boost::shared_ptr(new newGameDialogImpl(this, myConfig)); - mySelectAvatarDialog = boost::shared_ptr(new selectAvatarDialogImpl(this, myConfig)); - mySettingsDialog = boost::shared_ptr(new settingsDialogImpl(this, myConfig, mySelectAvatarDialog.get())); - myChangeHumanPlayerNameDialog = boost::shared_ptr(new changeHumanPlayerNameDialogImpl(this, myConfig)); - myJoinNetworkGameDialog = boost::shared_ptr(new joinNetworkGameDialogImpl(this, myConfig)); - myConnectToServerDialog = boost::shared_ptr(new connectToServerDialogImpl(this)); - myStartNetworkGameDialog = boost::shared_ptr(new startNetworkGameDialogImpl(this, myConfig)); - myCreateNetworkGameDialog = boost::shared_ptr(new createNetworkGameDialogImpl(this, myConfig)); - - myStartNetworkGameDialog->setMyW(this); +// myNewGameDialog = boost::shared_ptr(new newGameDialogImpl(this, myConfig)); +// // mySelectAvatarDialog = boost::shared_ptr(new selectAvatarDialogImpl(this, myConfig)); +// // // mySettingsDialog = boost::shared_ptr(new settingsDialogImpl(this, myConfig, mySelectAvatarDialog.get())); +// // myChangeHumanPlayerNameDialog = boost::shared_ptr(new changeHumanPlayerNameDialogImpl(this, myConfig)); +// // myJoinNetworkGameDialog = boost::shared_ptr(new joinNetworkGameDialogImpl(this, myConfig)); +// // myConnectToServerDialog = boost::shared_ptr(new connectToServerDialogImpl(this)); +// // myStartNetworkGameDialog = boost::shared_ptr(new startNetworkGameDialogImpl(this, myConfig)); +// // myCreateNetworkGameDialog = boost::shared_ptr(new createNetworkGameDialogImpl(this, myConfig)); myTimeoutDialog.reset(new timeoutMsgBoxImpl(this)); @@ -530,8 +528,8 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) connect(blinkingStartButtonAnimationTimer, SIGNAL(timeout()), this, SLOT( blinkingStartButtonAnimationAction())); - connect( actionSettings, SIGNAL( triggered() ), this, SLOT( callSettingsDialog() ) ); - connect( actionQuit, SIGNAL( triggered() ), this, SLOT( quitPokerTH() ) ); + connect( actionConfigure_PokerTH, SIGNAL( triggered() ), this, SLOT( callSettingsDialog() ) ); + connect( actionClose, SIGNAL( triggered() ), this, SLOT( closeGameTable()) ); connect( actionFullScreen, SIGNAL( triggered() ), this, SLOT( switchFullscreen() ) ); connect( actionShowHideChat, SIGNAL( triggered() ), this, SLOT( switchChatWindow() ) ); connect( actionShowHideHelp, SIGNAL( triggered() ), this, SLOT( switchHelpWindow() ) ); @@ -561,7 +559,7 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) //Nachrichten Thread-Save connect(this, SIGNAL(signalInitGui(int)), this, SLOT(initGui(int))); - connect(this, SIGNAL(signalShowClientDialog()), this, SLOT(showClientDialog())); +// connect(this, SIGNAL(signalShowClientDialog()), this, SLOT(showClientDialog())); connect(this, SIGNAL(signalRefreshSet()), this, SLOT(refreshSet())); connect(this, SIGNAL(signalRefreshCash()), this, SLOT(refreshCash())); @@ -609,16 +607,16 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalNextRoundCleanGui()), this, SLOT(nextRoundCleanGui())); - connect(this, SIGNAL(signalNetClientConnect(int)), myConnectToServerDialog.get(), SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientGameInfo(int)), myStartNetworkGameDialog.get(), SLOT(refresh(int))); +// connect(this, SIGNAL(signalNetClientConnect(int)), myConnectToServerDialog.get(), SLOT(refresh(int))); +// connect(this, SIGNAL(signalNetClientGameInfo(int)), myStartNetworkGameDialog.get(), SLOT(refresh(int))); // connect(this, SIGNAL(signalNetClientGameInfo(int)), myGameLobbyDialog.get(), SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, int)), myStartNetworkGameDialog.get(), SLOT(joinedNetworkGame(unsigned, QString, int))); - connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, int)), myStartNetworkGameDialog.get(), SLOT(addConnectedPlayer(unsigned, QString, int))); - connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myStartNetworkGameDialog.get(), SLOT(updatePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myStartNetworkGameDialog.get(), SLOT(removePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myStartNetworkGameDialog.get(), SLOT(newGameAdmin(unsigned, QString))); - connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myStartNetworkGameDialog.get(), SLOT(gameCreated(unsigned))); +// connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, int)), myStartNetworkGameDialog.get(), SLOT(joinedNetworkGame(unsigned, QString, int))); +// connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, int)), myStartNetworkGameDialog.get(), SLOT(addConnectedPlayer(unsigned, QString, int))); +// connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myStartNetworkGameDialog.get(), SLOT(updatePlayer(unsigned, QString))); +// connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myStartNetworkGameDialog.get(), SLOT(removePlayer(unsigned, QString))); +// connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myStartNetworkGameDialog.get(), SLOT(newGameAdmin(unsigned, QString))); +// connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myStartNetworkGameDialog.get(), SLOT(gameCreated(unsigned))); // connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, int)), myGameLobbyDialog.get(), SLOT(joinedNetworkGame(unsigned, QString, int))); // connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, int)), myGameLobbyDialog.get(), SLOT(addConnectedPlayer(unsigned, QString, int))); @@ -644,8 +642,8 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalNetClientGameStart(boost::shared_ptr)), this, SLOT(networkStart(boost::shared_ptr))); //Chat Messages - connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myChat, SLOT(receiveMessage(QString, QString))); - connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myStartNetworkGameDialog.get(), SLOT(receiveChatMsg(QString, QString))); +// connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myChat, SLOT(receiveMessage(QString, QString))); +// connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myStartNetworkGameDialog.get(), SLOT(receiveChatMsg(QString, QString))); // connect(this, SIGNAL(signalIrcConnect(QString)), myGameLobbyDialog->getLobbyChat(), SLOT(connected(QString))); // connect(this, SIGNAL(signalIrcSelfJoined(QString, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(selfJoined(QString, QString))); @@ -666,333 +664,9 @@ gameTableImpl::~gameTableImpl() { } -void gameTableImpl::callNewGameDialog() { +void gameTableImpl::callSettingsDialog() { myStartWindow->callSettingsDialog(); } - //wenn Dialogfenster gezeigt werden soll - if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){ - - myNewGameDialog->exec(); - if (myNewGameDialog->result() == QDialog::Accepted ) { startNewLocalGame(myNewGameDialog.get()); } - } - // sonst mit gespeicherten Werten starten - else { startNewLocalGame(); } -} - -void gameTableImpl::startNewLocalGame(newGameDialogImpl *v) { - - myStartWindow->hide(); - this->show(); - - // Start new local game - terminate existing network game. - mySession->terminateNetworkClient(); - if (myServerGuiInterface.get()) - myServerGuiInterface->getSession().terminateNetworkServer(); - - //get values from local game dialog - GameData gameData; - if(v) { - // Set Game Data - gameData.maxNumberOfPlayers = v->spinBox_quantityPlayers->value(); - gameData.startMoney = v->spinBox_startCash->value(); - gameData.firstSmallBlind = v->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); - - if(v->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { - gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; - gameData.raiseSmallBlindEveryHandsValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); - } - else { - gameData.raiseIntervalMode = RAISE_ON_MINUTES; - gameData.raiseSmallBlindEveryMinutesValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); - } - - if(v->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { - gameData.raiseMode = DOUBLE_BLINDS; - } - else { - gameData.raiseMode = MANUAL_BLINDS_ORDER; - list tempBlindList; - int i; - bool ok = TRUE; - for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { - tempBlindList.push_back(v->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); - } - gameData.manualBlindsList = tempBlindList; - - if(v->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } - else { - if(v->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { - gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; - gameData.afterMBAlwaysRaiseValue = v->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); - } - else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } - } - } - - //Speeds - gameData.guiSpeed = v->spinBox_gameSpeed->value(); - } - // start with default values - else { - // Set Game Data - gameData.maxNumberOfPlayers = myConfig->readConfigInt("NumberOfPlayers"); - gameData.startMoney = myConfig->readConfigInt("StartCash"); - gameData.firstSmallBlind = myConfig->readConfigInt("FirstSmallBlind"); - - if(myConfig->readConfigInt("RaiseBlindsAtHands")) { - gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; - gameData.raiseSmallBlindEveryHandsValue = myConfig->readConfigInt("RaiseSmallBlindEveryHands"); - } - else { - gameData.raiseIntervalMode = RAISE_ON_MINUTES; - gameData.raiseSmallBlindEveryMinutesValue = myConfig->readConfigInt("RaiseSmallBlindEveryMinutes"); - } - - if(myConfig->readConfigInt("AlwaysDoubleBlinds")) { - gameData.raiseMode = DOUBLE_BLINDS; - } - else { - gameData.raiseMode = MANUAL_BLINDS_ORDER; - gameData.manualBlindsList = myConfig->readConfigIntList("ManualBlindsList"); - - if(myConfig->readConfigInt("AfterMBAlwaysDoubleBlinds")) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } - else { - if(myConfig->readConfigInt("AfterMBAlwaysRaiseAbout")) { - gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; - gameData.afterMBAlwaysRaiseValue = myConfig->readConfigInt("AfterMBAlwaysRaiseValue"); - } - else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } - } - } - //Speeds - gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); - } - // Set dealer pos. - StartData startData; - int tmpDealerPos = 0; - startData.numberOfPlayers = gameData.maxNumberOfPlayers; - Tools::getRandNumber(0, startData.numberOfPlayers-1, 1, &tmpDealerPos, 0); - if(DEBUG_MODE) { - tmpDealerPos = 1; - } - startData.startDealerPlayerId = static_cast(tmpDealerPos); - - //some gui modifications - localGameModification(); - - //Start Game!!! - mySession->startLocalGame(gameData, startData); -} - - -void gameTableImpl::callCreateNetworkGameDialog() { - - myCreateNetworkGameDialog->exec(); -// - if (myCreateNetworkGameDialog->result() == QDialog::Accepted ) { - - // Stop local game. - stopTimer(); - - if (!myServerGuiInterface.get()) - { - // Create pseudo Gui Wrapper for the server. - myServerGuiInterface.reset(new ServerGuiWrapper(myConfig, mySession->getGui(), mySession->getGui(), mySession->getGui())); - { - boost::shared_ptr session(new Session(myServerGuiInterface.get(), myConfig)); - session->init(mySession->getAvatarManager()); - myServerGuiInterface->setSession(session); - } - } - - // Terminate existing network games. - mySession->terminateNetworkClient(); - myServerGuiInterface->getSession().terminateNetworkServer(); - - GameData gameData; - gameData.maxNumberOfPlayers = myCreateNetworkGameDialog->spinBox_quantityPlayers->value(); - gameData.startMoney = myCreateNetworkGameDialog->spinBox_startCash->value(); - gameData.firstSmallBlind = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); - - if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { - gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; - gameData.raiseSmallBlindEveryHandsValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); - } - else { - gameData.raiseIntervalMode = RAISE_ON_MINUTES; - gameData.raiseSmallBlindEveryMinutesValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); - } - - if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { - gameData.raiseMode = DOUBLE_BLINDS; - } - else { - gameData.raiseMode = MANUAL_BLINDS_ORDER; - list tempBlindList; - int i; - bool ok = TRUE; - for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { - tempBlindList.push_back(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); - } - gameData.manualBlindsList = tempBlindList; - - if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } - else { - if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { - gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; - gameData.afterMBAlwaysRaiseValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); - } - else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } - } - } - - gameData.guiSpeed = myCreateNetworkGameDialog->spinBox_gameSpeed->value(); - gameData.playerActionTimeoutSec = myCreateNetworkGameDialog->spinBox_netTimeOutPlayerAction->value(); - -// myGameLobbyDialog->setSession(&getSession()); - myStartNetworkGameDialog->setSession(&getSession()); - - // Clear network game dialog. - myStartNetworkGameDialog->clearDialog(); - - myServerGuiInterface->getSession().startNetworkServer(); - mySession->startNetworkClientForLocalServer(gameData); - - myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers); - - myStartNetworkGameDialog->setWindowTitle("Start Network Game"); - - showNetworkStartDialog(); - } - -} - -void gameTableImpl::callJoinNetworkGameDialog() { - - myJoinNetworkGameDialog->exec(); - - if (myJoinNetworkGameDialog->result() == QDialog::Accepted ) { - - // Stop local game. - stopTimer(); - - mySession->terminateNetworkClient(); - if (myServerGuiInterface.get()) - myServerGuiInterface->getSession().terminateNetworkServer(); - -// myGameLobbyDialog->setSession(&getSession()); - myStartNetworkGameDialog->setSession(&getSession()); - // Clear network game dialog - myStartNetworkGameDialog->clearDialog(); - // Maybe use QUrl::toPunycode. - mySession->startNetworkClient( - myJoinNetworkGameDialog->lineEdit_ipAddress->text().toUtf8().constData(), - myJoinNetworkGameDialog->spinBox_port->value(), - myJoinNetworkGameDialog->checkBox_ipv6->isChecked(), - myJoinNetworkGameDialog->checkBox_sctp->isChecked(), - myJoinNetworkGameDialog->lineEdit_password->text().toUtf8().constData()); - - //Dialog mit Statusbalken - myConnectToServerDialog->exec(); - - if (myConnectToServerDialog->result() == QDialog::Rejected ) { - mySession->terminateNetworkClient(); - actionJoin_network_Game->trigger(); // re-trigger - } - else { - //needed for join and ready sounds - TODO - //myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers); - myStartNetworkGameDialog->setWindowTitle("Start Network Game"); - - showNetworkStartDialog(); - } - } -} - -void gameTableImpl::callGameLobbyDialog() { - - //Avoid join Lobby with "Human Player" nick - if(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()) == QString("Human Player")) { - myChangeHumanPlayerNameDialog->label_Message->setText(tr("You cannot join Internet-Game-Lobby with \"Human Player\" as nickname.\nPlease choose another one.")); - myChangeHumanPlayerNameDialog->exec(); - - if(myChangeHumanPlayerNameDialog->result() == QDialog::Accepted) { - joinGameLobby(); - } - } - else { - joinGameLobby(); - } -} - -void gameTableImpl::joinGameLobby() { - - // Stop local game. - stopTimer(); - -// Join Lobby - mySession->terminateNetworkClient(); - if (myServerGuiInterface.get()) - myServerGuiInterface->getSession().terminateNetworkServer(); -// myGameLobbyDialog->setSession(&getSession()); - myStartNetworkGameDialog->setSession(&getSession()); - - // Clear Lobby dialog. -// myGameLobbyDialog->clearDialog(); - - //set clean irc nick - QString myNick(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); - myNick.replace(QString::fromUtf8("ä"),"ae"); - myNick.replace(QString::fromUtf8("Ä"),"Ae"); - myNick.replace(QString::fromUtf8("ü"),"ue"); - myNick.replace(QString::fromUtf8("Ü"),"Ue"); - myNick.replace(QString::fromUtf8("ö"),"oe"); - myNick.replace(QString::fromUtf8("Ö"),"Oe"); - myNick.replace(QString::fromUtf8("é"),"e"); - myNick.replace(QString::fromUtf8("è"),"e"); - myNick.replace(QString::fromUtf8("á"),"a"); - myNick.replace(QString::fromUtf8("à"),"a"); - myNick.replace(QString::fromUtf8("ó"),"o"); - myNick.replace(QString::fromUtf8("ò"),"o"); - myNick.replace(QString::fromUtf8("ú"),"u"); - myNick.replace(QString::fromUtf8("ù"),"u"); - myNick.replace(QString::fromUtf8("É"),"E"); - myNick.replace(QString::fromUtf8("È"),"E"); - myNick.replace(QString::fromUtf8("Á"),"A"); - myNick.replace(QString::fromUtf8("À"),"A"); - myNick.replace(QString::fromUtf8("Ó"),"O"); - myNick.replace(QString::fromUtf8("Ò"),"O"); - myNick.replace(QString::fromUtf8("Ú"),"U"); - myNick.replace(QString::fromUtf8("Ù"),"U"); - myNick.remove(QRegExp("[^A-Z^a-z^0-9|\\-_\\\\^`]*")); - myNick = myNick.mid(0,16); - - mySession->setIrcNick(myNick.toUtf8().constData()); - - // Start client for dedicated server. - mySession->startInternetClient(); - - //Dialog mit Statusbalken - myConnectToServerDialog->exec(); - - if (myConnectToServerDialog->result() == QDialog::Rejected ) { - mySession->terminateNetworkClient(); - } - else - { - showLobbyDialog(); - } -} - -void gameTableImpl::callSettingsDialog() { - - mySettingsDialog->exec(); - - if (mySettingsDialog->result() == QDialog::Accepted && mySettingsDialog->getSettingsCorrect()) { - applySettings(); - } -} - -void gameTableImpl::applySettings() { +void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog) { //Toolbox verstecken? if (myConfig->readConfigInt("ShowLeftToolBox")) { groupBox_LeftToolBox->show(); } @@ -1117,51 +791,6 @@ void gameTableImpl::initGui(int speed) } } -void gameTableImpl::showClientDialog() -{ - if (mySession->getGameType() == Session::GAME_TYPE_NETWORK) - { - if (!myStartNetworkGameDialog->isVisible()) - showNetworkStartDialog(); - } - else if (mySession->getGameType() == Session::GAME_TYPE_INTERNET) - { -// if (!myGameLobbyDialog->isVisible()) -// showLobbyDialog(); - } -} - -void gameTableImpl::showNetworkStartDialog() -{ - myStartNetworkGameDialog->exec(); - - if (myStartNetworkGameDialog->result() == QDialog::Accepted ) { - - //some gui modifications - networkGameModification(); - } - else { - mySession->terminateNetworkClient(); - if (myServerGuiInterface) - myServerGuiInterface->getSession().terminateNetworkServer(); - } -} - -void gameTableImpl::showLobbyDialog() -{ -// myGameLobbyDialog->exec(); - -// if (myGameLobbyDialog->result() == QDialog::Accepted) -// { - //some gui modifications -// networkGameModification(); -// } -// else -// { -// mySession->terminateNetworkClient(); -// } -} - Session &gameTableImpl::getSession() { assert(mySession.get()); return *mySession; } void gameTableImpl::setSession(boost::shared_ptr session) { mySession = session; } @@ -2772,7 +2401,7 @@ void gameTableImpl::postRiverRunAnimation6() { } } else { - callNewGameDialog(); + myStartWindow->callNewGameDialog(); //Bei Cancel nichts machen!!! } return; @@ -3029,7 +2658,7 @@ void gameTableImpl::breakButtonClicked() { if(currentGameOver) { currentGameOver = FALSE; - callNewGameDialog(); + myStartWindow->callNewGameDialog(); //Bei Cancel nichts machen!!! } else { @@ -3038,21 +2667,6 @@ void gameTableImpl::breakButtonClicked() { } } -void gameTableImpl::paintStartSplash() { - -// StartSplash *mySplash = new StartSplash(this, myConfig); -// -// #ifdef __APPLE__ -// int offset = 305; -// #else -// int offset = 237; -// #endif -// mySplash->setGeometry(this->pos().x()+offset,this->pos().y()+210,400,250); -// // mySplash->setWindowFlags(Qt::SplashScreen); -// mySplash->show(); -} - - void gameTableImpl::networkError(int errorID, int /*osErrorID*/) { hideTimeoutDialog(); @@ -3205,12 +2819,12 @@ void gameTableImpl::networkError(int errorID, int /*osErrorID*/) { QMessageBox::Close); } break; case ERR_NET_PLAYER_NAME_IN_USE: - { myChangeHumanPlayerNameDialog->label_Message->setText(tr("Your player name is already used by another player.\nPlease choose a different name.")); - myChangeHumanPlayerNameDialog->exec(); } + { /*myChangeHumanPlayerNameDialog->label_Message->setText(tr("Your player name is already used by another player.\nPlease choose a different name.")); + myChangeHumanPlayerNameDialog->exec();*/ } break; case ERR_NET_INVALID_PLAYER_NAME: - { myChangeHumanPlayerNameDialog->label_Message->setText(tr("The player name is too short, too long or invalid. Please choose another one.")); - myChangeHumanPlayerNameDialog->exec(); } + { /*myChangeHumanPlayerNameDialog->label_Message->setText(tr("The player name is too short, too long or invalid. Please choose another one.")); + myChangeHumanPlayerNameDialog->exec();*/ } break; case ERR_NET_INVALID_GAME_NAME: { QMessageBox::warning(this, tr("Network Error"), @@ -3307,8 +2921,8 @@ void gameTableImpl::networkError(int errorID, int /*osErrorID*/) { } // close dialogs // myGameLobbyDialog->reject(); - myConnectToServerDialog->reject(); - myStartNetworkGameDialog->reject(); +// myConnectToServerDialog->reject(); +// myStartNetworkGameDialog->reject(); } void gameTableImpl::networkNotification(int notificationId) @@ -3471,7 +3085,7 @@ bool gameTableImpl::eventFilter(QObject *obj, QEvent *event) } else if (event->type() == QEvent::Close) { event->ignore(); - quitPokerTH(); + closeGameTable(); return true; } else { @@ -3723,13 +3337,13 @@ void gameTableImpl::myButtonsCheckable(bool state) { } -// // void gameTableImpl::closeEvent(QCloseEvent* /*event*/) { quitPokerTH(); } +// // void gameTableImpl::closeEvent(QCloseEvent* /*event*/) { closeGameTable(); } void gameTableImpl::showMaximized () { this->showFullScreen (); } -void gameTableImpl::quitPokerTH() { +void gameTableImpl::closeGameTable() { if (myServerGuiInterface.get() && myServerGuiInterface->getSession().isNetworkServerRunning()) { @@ -3740,7 +3354,6 @@ void gameTableImpl::quitPokerTH() { mySession->terminateNetworkClient(); stopTimer(); if (myServerGuiInterface.get()) myServerGuiInterface->getSession().terminateNetworkServer(); -// qApp->quit(); this->hide(); myStartWindow->show(); } @@ -3748,7 +3361,6 @@ void gameTableImpl::quitPokerTH() { else { mySession->terminateNetworkClient(); stopTimer(); -// qApp->quit(); this->hide(); myStartWindow->show(); } diff --git a/src/gui/qt/gametable/gametableimpl.h b/src/gui/qt/gametable/gametableimpl.h index 33896ed3..6eb8c88b 100755 --- a/src/gui/qt/gametable/gametableimpl.h +++ b/src/gui/qt/gametable/gametableimpl.h @@ -69,7 +69,7 @@ public: Session &getSession(); void setSession(boost::shared_ptr session); - void setStartWindow(boost::shared_ptr s) { myStartWindow = s; } + void setStartWindow(startWindowImpl* s) { myStartWindow = s; } void setLog(Log* l) { myLog = l; } @@ -165,10 +165,6 @@ public slots: void initGui(int speed); - void showClientDialog(); - void showNetworkStartDialog(); - void showLobbyDialog(); - //refresh-Funktionen void refreshSet(); void refreshCash(); @@ -199,13 +195,8 @@ public slots: void setGameSpeed(const int theValue) { guiGameSpeed = theValue; setSpeeds(); } // Achtung Faktor 10!!! - void callNewGameDialog() ; void callSettingsDialog(); - void applySettings(); - void callCreateNetworkGameDialog(); - void callJoinNetworkGameDialog(); - void callGameLobbyDialog(); - void joinGameLobby(); + void applySettings(settingsDialogImpl*); void pushButtonBetRaiseClicked(bool checked); void pushButtonCallCheckClicked(bool checked); @@ -287,7 +278,6 @@ public slots: void handSwitchRounds(); void startNewHand(); - void startNewLocalGame(newGameDialogImpl* =0); void stopTimer(); @@ -304,8 +294,6 @@ public slots: void switchAwayWindow(); void switchFullscreen(); - void paintStartSplash(); - void sendChatMessage(); void checkChatInputLength(QString); void tabSwitchAction(); @@ -315,8 +303,6 @@ public slots: void networkError(int, int); void networkNotification(int); void networkStart(boost::shared_ptr game); - -// void closeEvent(QCloseEvent*); void localGameModification(); void networkGameModification(); @@ -334,12 +320,13 @@ public slots: void lineEditBetValueChanged(QString); void showMaximized (); - void quitPokerTH(); + void closeGameTable(); void showTimeoutDialog(int msgID, unsigned duration); void hideTimeoutDialog(); -; -// void paintEvent(QPaintEvent *); + + Chat* getMyChat() const { return myChat; } + private: @@ -404,17 +391,17 @@ private: QPixmap *flipside; // Dialogs - boost::shared_ptr myNewGameDialog; - boost::shared_ptr mySettingsDialog; - boost::shared_ptr mySelectAvatarDialog; - boost::shared_ptr myChangeHumanPlayerNameDialog; - boost::shared_ptr myJoinNetworkGameDialog; - boost::shared_ptr myConnectToServerDialog; - boost::shared_ptr myStartNetworkGameDialog; - boost::shared_ptr myCreateNetworkGameDialog; +// boost::shared_ptr myNewGameDialog; +// boost::shared_ptr mySettingsDialog; +// boost::shared_ptr mySelectAvatarDialog; +// boost::shared_ptr myChangeHumanPlayerNameDialog; +// boost::shared_ptr myJoinNetworkGameDialog; +// boost::shared_ptr myConnectToServerDialog; +// boost::shared_ptr myStartNetworkGameDialog; +// boost::shared_ptr myCreateNetworkGameDialog; // boost::shared_ptr myGameLobbyDialog; boost::shared_ptr myTimeoutDialog; - boost::shared_ptr myStartWindow; + startWindowImpl *myStartWindow; //Sound SDLPlayer *mySDLPlayer; diff --git a/src/gui/qt/gametable/myavatarlabel.cpp b/src/gui/qt/gametable/myavatarlabel.cpp index ffbe3bfe..76bb4058 100644 --- a/src/gui/qt/gametable/myavatarlabel.cpp +++ b/src/gui/qt/gametable/myavatarlabel.cpp @@ -29,12 +29,12 @@ MyAvatarLabel::~MyAvatarLabel() { } -void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent * event ) { +void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent * /*event*/ ) { // showContextMenu(event->globalPos()); } -void MyAvatarLabel::showContextMenu(const QPoint &pos) { +void MyAvatarLabel::showContextMenu(const QPoint &/*pos*/) { // myContextMenu->popup(pos); } diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index 40e4b2a5..46d8f91e 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -164,7 +164,8 @@ void GuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned pla void GuiWrapper::SignalNetClientWaitDialog() { myStartWindow->signalShowClientDialog(); } -void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myW->signalNetClientChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } +void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myStartWindow->signalNetClientChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } + void GuiWrapper::SignalNetServerSuccess(int /*actionID*/) { } void GuiWrapper::SignalNetServerError(int errorID, int osErrorID) { myW->signalNetServerError(errorID, osErrorID); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index a96eeadc..0b9bfed4 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -151,7 +151,7 @@ private: Chat *myChat; gameTableImpl *myW; ConfigFile *myConfig; - boost::shared_ptr myStartWindow; + startWindowImpl *myStartWindow; }; diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp index 7f32ef37..357982b6 100644 --- a/src/gui/qt/startwindow/startwindowimpl.cpp +++ b/src/gui/qt/startwindow/startwindowimpl.cpp @@ -22,6 +22,7 @@ #include #include #include +#include "tools.h" #include "session.h" #include "game.h" @@ -43,6 +44,9 @@ #include "gamelobbydialogimpl.h" #include "timeoutmsgboximpl.h" #include "lobbychat.h" +#include "chat.h" + +using namespace std; startWindowImpl::startWindowImpl(ConfigFile *c) : myConfig(c) @@ -123,6 +127,7 @@ startWindowImpl::startWindowImpl(ConfigFile *c) connect(this, SIGNAL(signalNetClientStatsUpdate(ServerStats)), myGameLobbyDialog, SLOT(updateStats(ServerStats))); connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myStartNetworkGameDialog, SLOT(receiveChatMsg(QString, QString))); + connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myGuiInterface->getMyW()->getMyChat(), SLOT(receiveMessage(QString, QString))); connect(this, SIGNAL(signalIrcConnect(QString)), myGameLobbyDialog->getLobbyChat(), SLOT(connected(QString))); connect(this, SIGNAL(signalIrcSelfJoined(QString, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(selfJoined(QString, QString))); @@ -144,10 +149,115 @@ void startWindowImpl::callNewGameDialog() { if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){ myNewGameDialog->exec(); - if (myNewGameDialog->result() == QDialog::Accepted ) { myGuiInterface->getMyW()->startNewLocalGame(myNewGameDialog); } + if (myNewGameDialog->result() == QDialog::Accepted ) { startNewLocalGame(myNewGameDialog); } } // sonst mit gespeicherten Werten starten - else { myGuiInterface->getMyW()->startNewLocalGame(); } + else { startNewLocalGame(); } +} + +void startWindowImpl::startNewLocalGame(newGameDialogImpl *v) { + + this->hide(); + myGuiInterface->getMyW()->show(); + + // Start new local game - terminate existing network game. + mySession->terminateNetworkClient(); + if (myServerGuiInterface.get()) + myServerGuiInterface->getSession().terminateNetworkServer(); + + //get values from local game dialog + GameData gameData; + if(v) { + // Set Game Data + gameData.maxNumberOfPlayers = v->spinBox_quantityPlayers->value(); + gameData.startMoney = v->spinBox_startCash->value(); + gameData.firstSmallBlind = v->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); + + if(v->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { + gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; + gameData.raiseSmallBlindEveryHandsValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); + } + else { + gameData.raiseIntervalMode = RAISE_ON_MINUTES; + gameData.raiseSmallBlindEveryMinutesValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); + } + + if(v->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { + gameData.raiseMode = DOUBLE_BLINDS; + } + else { + gameData.raiseMode = MANUAL_BLINDS_ORDER; + list tempBlindList; + int i; + bool ok = TRUE; + for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { + tempBlindList.push_back(v->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); + } + gameData.manualBlindsList = tempBlindList; + + if(v->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } + else { + if(v->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { + gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; + gameData.afterMBAlwaysRaiseValue = v->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); + } + else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } + } + } + + //Speeds + gameData.guiSpeed = v->spinBox_gameSpeed->value(); + } + // start with default values + else { + // Set Game Data + gameData.maxNumberOfPlayers = myConfig->readConfigInt("NumberOfPlayers"); + gameData.startMoney = myConfig->readConfigInt("StartCash"); + gameData.firstSmallBlind = myConfig->readConfigInt("FirstSmallBlind"); + + if(myConfig->readConfigInt("RaiseBlindsAtHands")) { + gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; + gameData.raiseSmallBlindEveryHandsValue = myConfig->readConfigInt("RaiseSmallBlindEveryHands"); + } + else { + gameData.raiseIntervalMode = RAISE_ON_MINUTES; + gameData.raiseSmallBlindEveryMinutesValue = myConfig->readConfigInt("RaiseSmallBlindEveryMinutes"); + } + + if(myConfig->readConfigInt("AlwaysDoubleBlinds")) { + gameData.raiseMode = DOUBLE_BLINDS; + } + else { + gameData.raiseMode = MANUAL_BLINDS_ORDER; + gameData.manualBlindsList = myConfig->readConfigIntList("ManualBlindsList"); + + if(myConfig->readConfigInt("AfterMBAlwaysDoubleBlinds")) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } + else { + if(myConfig->readConfigInt("AfterMBAlwaysRaiseAbout")) { + gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; + gameData.afterMBAlwaysRaiseValue = myConfig->readConfigInt("AfterMBAlwaysRaiseValue"); + } + else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } + } + } + //Speeds + gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); + } + // Set dealer pos. + StartData startData; + int tmpDealerPos = 0; + startData.numberOfPlayers = gameData.maxNumberOfPlayers; + Tools::getRandNumber(0, startData.numberOfPlayers-1, 1, &tmpDealerPos, 0); + if(DEBUG_MODE) { + tmpDealerPos = 1; + } + startData.startDealerPlayerId = static_cast(tmpDealerPos); + + //some gui modifications + myGuiInterface->getMyW()->localGameModification(); + + //Start Game!!! + mySession->startLocalGame(gameData, startData); } void startWindowImpl::callGameLobbyDialog() { @@ -407,6 +517,6 @@ void startWindowImpl::callSettingsDialog() { mySettingsDialog->exec(); if (mySettingsDialog->result() == QDialog::Accepted && mySettingsDialog->getSettingsCorrect()) { - myGuiInterface->getMyW()->applySettings(); + myGuiInterface->getMyW()->applySettings(mySettingsDialog); } } diff --git a/src/gui/qt/startwindow/startwindowimpl.h b/src/gui/qt/startwindow/startwindowimpl.h index 01315e65..4b72edd4 100644 --- a/src/gui/qt/startwindow/startwindowimpl.h +++ b/src/gui/qt/startwindow/startwindowimpl.h @@ -100,7 +100,8 @@ public slots: void joinGameLobby(); void showClientDialog(); void showNetworkStartDialog(); - + + void startNewLocalGame(newGameDialogImpl* =0); private: ConfigFile *myConfig;