diff --git a/src/gui/generic/serverguiwrapper.h b/src/gui/generic/serverguiwrapper.h index eba7eaa0..bdc1f2f3 100644 --- a/src/gui/generic/serverguiwrapper.h +++ b/src/gui/generic/serverguiwrapper.h @@ -28,142 +28,142 @@ class gameTableImpl; class ServerGuiWrapper : public GuiInterface { public: - ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb, IrcCallback *irccb); - ~ServerGuiWrapper(); + ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb, IrcCallback *irccb); + ~ServerGuiWrapper(); - void initGui(int speed); + void initGui(int speed); - boost::shared_ptr getSession(); - void setSession(boost::shared_ptr session); + boost::shared_ptr getSession(); + void setSession(boost::shared_ptr session); - gameTableImpl* getMyW() const {return NULL;} + gameTableImpl* getMyW() const {return NULL;} - void refreshSet() const; - void refreshCash() const; - void refreshAction(int =-1, int =-1) const; - void refreshChangePlayer() const; - void refreshPot() const; - void refreshGroupbox(int =-1, int =-1) const; - void refreshAll() const; - void refreshPlayerName() const; - void refreshButton() const; - void refreshGameLabels(GameState state) const; + void refreshSet() const; + void refreshCash() const; + void refreshAction(int =-1, int =-1) const; + void refreshChangePlayer() const; + void refreshPot() const; + void refreshGroupbox(int =-1, int =-1) const; + void refreshAll() const; + void refreshPlayerName() const; + void refreshButton() const; + void refreshGameLabels(GameState state) const; - void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const; + void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const; - void waitForGuiUpdateDone() const; + void waitForGuiUpdateDone() const; - void dealBeRoCards(int); - void dealHoleCards(); - void dealFlopCards(); - void dealTurnCard(); - void dealRiverCard(); + void dealBeRoCards(int); + void dealHoleCards(); + void dealFlopCards(); + void dealTurnCard(); + void dealRiverCard(); - void nextPlayerAnimation(); + void nextPlayerAnimation(); - void beRoAnimation2(int); + void beRoAnimation2(int); - void preflopAnimation1(); - void preflopAnimation2(); - - void flopAnimation1(); - void flopAnimation2(); + void preflopAnimation1(); + void preflopAnimation2(); - void turnAnimation1(); - void turnAnimation2(); + void flopAnimation1(); + void flopAnimation2(); - void riverAnimation1(); - void riverAnimation2(); + void turnAnimation1(); + void turnAnimation2(); - void postRiverAnimation1(); - void postRiverRunAnimation1(); + void riverAnimation1(); + void riverAnimation2(); - void flipHolecardsAllIn(); + void postRiverAnimation1(); + void postRiverRunAnimation1(); - void nextRoundCleanGui(); + void flipHolecardsAllIn(); - void meInAction(); - void updateMyButtonsState(); - void disableMyButtons(); - void startTimeoutAnimation(int playerNum, int timeoutSec); - void stopTimeoutAnimation(int playerNum); + void nextRoundCleanGui(); - void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); - void changeVoteOnKickButtonsState(bool showHide); - void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); - void endVoteOnKick(); + void meInAction(); + void updateMyButtonsState(); + void disableMyButtons(); + void startTimeoutAnimation(int playerNum, int timeoutSec); + void stopTimeoutAnimation(int playerNum); - void logPlayerActionMsg(std::string playerName, int action, int setValue) ; - void logNewGameHandMsg(int gameID, int handID) ; - void logPlayerWinsMsg(std::string playerName, int pot, bool main); - void logPlayerSitsOut(std::string playerName); - void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName); - void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) ; - void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") ; - void logPlayerWinGame(std::string playerName, int gameID); - void flushLogAtGame(int gameID); - void flushLogAtHand(); + void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); + void changeVoteOnKickButtonsState(bool showHide); + void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); + void endVoteOnKick(); - void SignalNetClientConnect(int actionID); - void SignalNetClientGameInfo(int actionID); - void SignalNetClientError(int errorID, int osErrorID); - void SignalNetClientNotification(int notificationId); - void SignalNetClientStatsUpdate(const ServerStats &stats); - void SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec); - void SignalNetClientRemovedFromGame(int notificationId); - void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); - void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); - void SignalNetClientPlayerChanged(unsigned playerId, const std::string &newPlayerName); - void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason); - void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName); - void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg); - void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg); - void SignalNetClientWaitDialog(); + void logPlayerActionMsg(std::string playerName, int action, int setValue) ; + void logNewGameHandMsg(int gameID, int handID) ; + void logPlayerWinsMsg(std::string playerName, int pot, bool main); + void logPlayerSitsOut(std::string playerName); + void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName); + void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) ; + void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") ; + void logPlayerWinGame(std::string playerName, int gameID); + void flushLogAtGame(int gameID); + void flushLogAtHand(); - void SignalNetClientGameListNew(unsigned gameId); - void SignalNetClientGameListRemove(unsigned gameId); - void SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode); - void SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); - void SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); - void SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); - void SignalNetClientGameStart(boost::shared_ptr game); - - void SignalNetClientServerListAdd(unsigned serverId); - void SignalNetClientServerListClear(); - void SignalNetClientServerListShow(); + void SignalNetClientConnect(int actionID); + void SignalNetClientGameInfo(int actionID); + void SignalNetClientError(int errorID, int osErrorID); + void SignalNetClientNotification(int notificationId); + void SignalNetClientStatsUpdate(const ServerStats &stats); + void SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec); + void SignalNetClientRemovedFromGame(int notificationId); + void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); + void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); + void SignalNetClientPlayerChanged(unsigned playerId, const std::string &newPlayerName); + void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason); + void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName); + void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientWaitDialog(); - void SignalNetClientLoginShow(); + void SignalNetClientGameListNew(unsigned gameId); + void SignalNetClientGameListRemove(unsigned gameId); + void SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode); + void SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); + void SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); + void SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); + void SignalNetClientGameStart(boost::shared_ptr game); - void SignalNetServerSuccess(int actionID); - void SignalNetServerError(int errorID, int osErrorID); + void SignalNetClientServerListAdd(unsigned serverId); + void SignalNetClientServerListClear(); + void SignalNetClientServerListShow(); - void SignalIrcConnect(const std::string &server); - void SignalIrcSelfJoined(const std::string &nickName, const std::string &channel); - void SignalIrcPlayerJoined(const std::string &nickName); - void SignalIrcPlayerChanged(const std::string &oldNick, const std::string &newNick); - void SignalIrcPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); - void SignalIrcPlayerLeft(const std::string &nickName); - void SignalIrcChatMsg(const std::string &nickName, const std::string &msg); - void SignalNetClientMsgBox(const std::string &msg); - void SignalIrcError(int errorCode); - void SignalIrcServerError(int errorCode); - void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName); - void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); - void SignalLobbyPlayerLeft(unsigned playerId); + void SignalNetClientLoginShow(); - void SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); - void SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); - void SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); + void SignalNetServerSuccess(int actionID); + void SignalNetServerError(int errorID, int osErrorID); + + void SignalIrcConnect(const std::string &server); + void SignalIrcSelfJoined(const std::string &nickName, const std::string &channel); + void SignalIrcPlayerJoined(const std::string &nickName); + void SignalIrcPlayerChanged(const std::string &oldNick, const std::string &newNick); + void SignalIrcPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); + void SignalIrcPlayerLeft(const std::string &nickName); + void SignalIrcChatMsg(const std::string &nickName, const std::string &msg); + void SignalNetClientMsgBox(const std::string &msg); + void SignalIrcError(int errorCode); + void SignalIrcServerError(int errorCode); + void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName); + void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); + void SignalLobbyPlayerLeft(unsigned playerId); + + void SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); + void SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); private: - boost::shared_ptr mySession; - ConfigFile *myConfig; + boost::shared_ptr mySession; + ConfigFile *myConfig; - ClientCallback *myClientcb; - ServerCallback *myServercb; - IrcCallback *myIrccb; + ClientCallback *myClientcb; + ServerCallback *myServercb; + IrcCallback *myIrccb; }; #endif diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index c5d2ea7a..77935fa5 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -33,82 +33,82 @@ class gameTableImpl; class GuiInterface : public ClientCallback, public ServerCallback, public IrcCallback { public: - virtual ~GuiInterface(); + virtual ~GuiInterface(); - virtual void initGui(int speed) =0; + virtual void initGui(int speed) =0; - virtual boost::shared_ptr getSession() =0; - virtual void setSession(boost::shared_ptr session) =0; + virtual boost::shared_ptr getSession() =0; + virtual void setSession(boost::shared_ptr session) =0; - virtual gameTableImpl *getMyW() const=0; + virtual gameTableImpl *getMyW() const=0; - //refresh-Funktionen - virtual void refreshSet() const=0; - virtual void refreshCash() const=0; - virtual void refreshAction(int =-1, int =-1) const=0; - virtual void refreshChangePlayer() const=0; - virtual void refreshPot() const=0; - virtual void refreshGroupbox(int =-1, int =-1) const=0; - virtual void refreshAll() const=0; - virtual void refreshPlayerName() const=0; - virtual void refreshButton() const =0; - virtual void refreshGameLabels(GameState state) const=0; - - virtual void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const=0; - virtual void waitForGuiUpdateDone() const=0; + //refresh-Funktionen + virtual void refreshSet() const=0; + virtual void refreshCash() const=0; + virtual void refreshAction(int =-1, int =-1) const=0; + virtual void refreshChangePlayer() const=0; + virtual void refreshPot() const=0; + virtual void refreshGroupbox(int =-1, int =-1) const=0; + virtual void refreshAll() const=0; + virtual void refreshPlayerName() const=0; + virtual void refreshButton() const =0; + virtual void refreshGameLabels(GameState state) const=0; - // Karten-Funktionen - virtual void dealBeRoCards(int) =0; - virtual void dealHoleCards()=0; - virtual void dealFlopCards()=0; - virtual void dealTurnCard()=0; - virtual void dealRiverCard()=0; + virtual void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const=0; + virtual void waitForGuiUpdateDone() const=0; - virtual void nextPlayerAnimation()=0; + // Karten-Funktionen + virtual void dealBeRoCards(int) =0; + virtual void dealHoleCards()=0; + virtual void dealFlopCards()=0; + virtual void dealTurnCard()=0; + virtual void dealRiverCard()=0; - virtual void beRoAnimation2(int)=0; + virtual void nextPlayerAnimation()=0; - virtual void preflopAnimation1()=0; - virtual void preflopAnimation2()=0; + virtual void beRoAnimation2(int)=0; - virtual void flopAnimation1()=0; - virtual void flopAnimation2()=0; + virtual void preflopAnimation1()=0; + virtual void preflopAnimation2()=0; - virtual void turnAnimation1()=0; - virtual void turnAnimation2()=0; + virtual void flopAnimation1()=0; + virtual void flopAnimation2()=0; - virtual void riverAnimation1()=0; - virtual void riverAnimation2()=0; + virtual void turnAnimation1()=0; + virtual void turnAnimation2()=0; - virtual void postRiverAnimation1()=0; - virtual void postRiverRunAnimation1()=0; - virtual void flipHolecardsAllIn()=0; + virtual void riverAnimation1()=0; + virtual void riverAnimation2()=0; - virtual void nextRoundCleanGui()=0; - virtual void meInAction()=0; - virtual void updateMyButtonsState()=0; - virtual void disableMyButtons()=0; - virtual void startTimeoutAnimation(int playerNum, int timeoutSec) =0; - virtual void stopTimeoutAnimation(int playerNum) =0; + virtual void postRiverAnimation1()=0; + virtual void postRiverRunAnimation1()=0; + virtual void flipHolecardsAllIn()=0; - virtual void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick) =0; - virtual void changeVoteOnKickButtonsState(bool showHide) =0; - virtual void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick) =0; - virtual void endVoteOnKick() =0; + virtual void nextRoundCleanGui()=0; + virtual void meInAction()=0; + virtual void updateMyButtonsState()=0; + virtual void disableMyButtons()=0; + virtual void startTimeoutAnimation(int playerNum, int timeoutSec) =0; + virtual void stopTimeoutAnimation(int playerNum) =0; + + virtual void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick) =0; + virtual void changeVoteOnKickButtonsState(bool showHide) =0; + virtual void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick) =0; + virtual void endVoteOnKick() =0; + + //log.cpp + virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0; + virtual void logNewGameHandMsg(int gameID, int HandID) =0; + virtual void logPlayerWinsMsg(std::string playerName, int pot, bool main) = 0; + virtual void logPlayerSitsOut(std::string playerName) = 0; + virtual void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName) =0; + virtual void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) = 0; + virtual void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") = 0; + virtual void logPlayerWinGame(std::string playerName, int gameID) =0; + virtual void flushLogAtGame(int gameID) =0; + virtual void flushLogAtHand() =0; - //log.cpp - virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0; - virtual void logNewGameHandMsg(int gameID, int HandID) =0; - virtual void logPlayerWinsMsg(std::string playerName, int pot, bool main) = 0; - virtual void logPlayerSitsOut(std::string playerName) = 0; - virtual void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName) =0; - virtual void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) = 0; - virtual void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") = 0; - virtual void logPlayerWinGame(std::string playerName, int gameID) =0; - virtual void flushLogAtGame(int gameID) =0; - virtual void flushLogAtHand() =0; - }; #endif diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index d0b967f5..862d1bed 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -22,731 +22,731 @@ #include "mymessagedialogimpl.h" gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) - : QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), myCurrentGameId(0), isGameAdministrator(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0), infoMsgToShowId(0), currentInvitationGameId(0), inviteDialogIsCurrentlyShown(false) + : QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), myCurrentGameId(0), isGameAdministrator(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0), infoMsgToShowId(0), currentInvitationGameId(0), inviteDialogIsCurrentlyShown(false) { #ifdef __APPLE__ - setWindowModality(Qt::ApplicationModal); - setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); + setWindowModality(Qt::ApplicationModal); + setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); #endif - setupUi(this); - - myChat = new ChatTools(lineEdit_ChatInput, myConfig, INET_LOBBY_CHAT, textBrowser_ChatDisplay, treeWidget_NickList, this); + setupUi(this); - myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); + myChat = new ChatTools(lineEdit_ChatInput, myConfig, INET_LOBBY_CHAT, textBrowser_ChatDisplay, treeWidget_NickList, this); - //wait start game message - waitStartGameMsgBox = new QMessageBox(this); - waitStartGameMsgBox->setText(tr("Starting game. Please wait ...")); - waitStartGameMsgBox->setWindowModality(Qt::NonModal); - #ifdef __APPLE__ - waitStartGameMsgBox->setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); - #endif - waitStartGameMsgBox->setStandardButtons(QMessageBox::NoButton); + myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - waitStartGameMsgBoxTimer = new QTimer(this); - waitStartGameMsgBoxTimer->setSingleShot(TRUE); - blinkingButtonAnimationTimer = new QTimer(this); - blinkingButtonAnimationTimer->setInterval(1000); - showInfoMsgBoxTimer = new QTimer(this); - showInfoMsgBoxTimer->setSingleShot(TRUE); + //wait start game message + waitStartGameMsgBox = new QMessageBox(this); + waitStartGameMsgBox->setText(tr("Starting game. Please wait ...")); + waitStartGameMsgBox->setWindowModality(Qt::NonModal); +#ifdef __APPLE__ + waitStartGameMsgBox->setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); +#endif + waitStartGameMsgBox->setStandardButtons(QMessageBox::NoButton); - //fetch button colors for blinking - groupBox_GameInfo->setEnabled(true); - pushButton_StartGame->setEnabled(true); - defaultStartButtonColor = pushButton_StartGame->palette().button().color(); - defaultStartButtonTextColor = pushButton_StartGame->palette().buttonText().color(); - pushButton_StartGame->setEnabled(false); - groupBox_GameInfo->setEnabled(false); - disabledStartButtonColor = pushButton_StartGame->palette().button().color(); - disabledStartButtonTextColor = pushButton_StartGame->palette().buttonText().color(); - - - myGameListModel = new QStandardItemModel(this); - myGameListSortFilterProxyModel = new MyGameListSortFilterProxyModel(this); - myGameListSortFilterProxyModel->setSourceModel(myGameListModel); - myGameListSortFilterProxyModel->setDynamicSortFilter(TRUE); - treeView_GameList->setModel(myGameListSortFilterProxyModel); - - myGameListSelectionModel = treeView_GameList->selectionModel(); - - QStringList headerList; - headerList << tr("Game") << tr("Players") << tr("State") << tr("R") << tr("P"); - myGameListModel->setHorizontalHeaderLabels(headerList); + waitStartGameMsgBoxTimer = new QTimer(this); + waitStartGameMsgBoxTimer->setSingleShot(TRUE); + blinkingButtonAnimationTimer = new QTimer(this); + blinkingButtonAnimationTimer->setInterval(1000); + showInfoMsgBoxTimer = new QTimer(this); + showInfoMsgBoxTimer->setSingleShot(TRUE); - treeView_GameList->setColumnWidth(0,220); - treeView_GameList->setColumnWidth(1,65); - treeView_GameList->setColumnWidth(2,65); - treeView_GameList->setColumnWidth(3,30); - treeView_GameList->setColumnWidth(4,30); + //fetch button colors for blinking + groupBox_GameInfo->setEnabled(true); + pushButton_StartGame->setEnabled(true); + defaultStartButtonColor = pushButton_StartGame->palette().button().color(); + defaultStartButtonTextColor = pushButton_StartGame->palette().buttonText().color(); + pushButton_StartGame->setEnabled(false); + groupBox_GameInfo->setEnabled(false); + disabledStartButtonColor = pushButton_StartGame->palette().button().color(); + disabledStartButtonTextColor = pushButton_StartGame->palette().buttonText().color(); - treeView_GameList->setStyleSheet("QTreeView {background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); - treeView_GameList->setAutoFillBackground(TRUE); - nickListContextMenu = new QMenu(); - nickListInviteAction = new QAction(QIcon(":/gfx/list_add_user.png"), tr("Invite player"), nickListContextMenu); - nickListContextMenu->addAction(nickListInviteAction); + myGameListModel = new QStandardItemModel(this); + myGameListSortFilterProxyModel = new MyGameListSortFilterProxyModel(this); + myGameListSortFilterProxyModel->setSourceModel(myGameListModel); + myGameListSortFilterProxyModel->setDynamicSortFilter(TRUE); + treeView_GameList->setModel(myGameListSortFilterProxyModel); - connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); - connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) ); - connect( pushButton_joinAnyGame, SIGNAL( clicked() ), this, SLOT( joinAnyGame() ) ); - connect( pushButton_StartGame, SIGNAL( clicked() ), this, SLOT( startGame() ) ); - connect( pushButton_Kick, SIGNAL( clicked() ), this, SLOT( kickPlayer() ) ); - connect( pushButton_Leave, SIGNAL( clicked() ), this, SLOT( leaveGame() ) ); - connect( myGameListSelectionModel, SIGNAL( currentChanged (const QModelIndex &, const QModelIndex &) ), this, SLOT( gameSelected(const QModelIndex &, const QModelIndex &) ) ); - connect( treeView_GameList, SIGNAL( doubleClicked (const QModelIndex &) ), this, SLOT( joinGame() ) ); - connect( treeView_GameList->header(), SIGNAL( sortIndicatorChanged ( int , Qt::SortOrder )), this, SLOT( changeGameListSorting() ) ); - connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) ); - connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), myChat, SLOT( sendMessage() ) ); - connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), myChat, SLOT( checkInputLength(QString) ) ); - connect( lineEdit_ChatInput, SIGNAL( textEdited (QString) ), myChat, SLOT( setChatTextEdited() ) ); - connect( waitStartGameMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showWaitStartGameMsgBox() )); - connect( blinkingButtonAnimationTimer, SIGNAL(timeout()), this, SLOT( blinkingStartButtonAnimation() )); - connect( showInfoMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showInfoMsgBox() )); - connect( comboBox_gameListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeGameListFilter(int))); - connect( treeWidget_NickList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT( showNickListContextMenu(QPoint) ) ); - connect( nickListInviteAction, SIGNAL(triggered()), this, SLOT( invitePlayerToCurrentGame() )); - - lineEdit_ChatInput->installEventFilter(this); + myGameListSelectionModel = treeView_GameList->selectionModel(); - clearDialog(); + QStringList headerList; + headerList << tr("Game") << tr("Players") << tr("State") << tr("R") << tr("P"); + myGameListModel->setHorizontalHeaderLabels(headerList); + + treeView_GameList->setColumnWidth(0,220); + treeView_GameList->setColumnWidth(1,65); + treeView_GameList->setColumnWidth(2,65); + treeView_GameList->setColumnWidth(3,30); + treeView_GameList->setColumnWidth(4,30); + + treeView_GameList->setStyleSheet("QTreeView {background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); + treeView_GameList->setAutoFillBackground(TRUE); + + nickListContextMenu = new QMenu(); + nickListInviteAction = new QAction(QIcon(":/gfx/list_add_user.png"), tr("Invite player"), nickListContextMenu); + nickListContextMenu->addAction(nickListInviteAction); + + connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); + connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) ); + connect( pushButton_joinAnyGame, SIGNAL( clicked() ), this, SLOT( joinAnyGame() ) ); + connect( pushButton_StartGame, SIGNAL( clicked() ), this, SLOT( startGame() ) ); + connect( pushButton_Kick, SIGNAL( clicked() ), this, SLOT( kickPlayer() ) ); + connect( pushButton_Leave, SIGNAL( clicked() ), this, SLOT( leaveGame() ) ); + connect( myGameListSelectionModel, SIGNAL( currentChanged (const QModelIndex &, const QModelIndex &) ), this, SLOT( gameSelected(const QModelIndex &, const QModelIndex &) ) ); + connect( treeView_GameList, SIGNAL( doubleClicked (const QModelIndex &) ), this, SLOT( joinGame() ) ); + connect( treeView_GameList->header(), SIGNAL( sortIndicatorChanged ( int , Qt::SortOrder )), this, SLOT( changeGameListSorting() ) ); + connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) ); + connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), myChat, SLOT( sendMessage() ) ); + connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), myChat, SLOT( checkInputLength(QString) ) ); + connect( lineEdit_ChatInput, SIGNAL( textEdited (QString) ), myChat, SLOT( setChatTextEdited() ) ); + connect( waitStartGameMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showWaitStartGameMsgBox() )); + connect( blinkingButtonAnimationTimer, SIGNAL(timeout()), this, SLOT( blinkingStartButtonAnimation() )); + connect( showInfoMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showInfoMsgBox() )); + connect( comboBox_gameListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeGameListFilter(int))); + connect( treeWidget_NickList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT( showNickListContextMenu(QPoint) ) ); + connect( nickListInviteAction, SIGNAL(triggered()), this, SLOT( invitePlayerToCurrentGame() )); + + lineEdit_ChatInput->installEventFilter(this); + + clearDialog(); } void gameLobbyDialogImpl::exec() { - if(myConfig->readConfigInt("UseLobbyChat")) { - groupBox_lobbyChat->show(); - } - else { - groupBox_lobbyChat->hide(); - } - readDialogSettings(); - - PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId())); - if(playerInfo.isGuest) { - guestUserMode(); - } - else { - registeredUserMode(); - } + if(myConfig->readConfigInt("UseLobbyChat")) { + groupBox_lobbyChat->show(); + } + else { + groupBox_lobbyChat->hide(); + } + readDialogSettings(); + + PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId())); + if(playerInfo.isGuest) { + guestUserMode(); + } + else { + registeredUserMode(); + } - QDialog::exec(); + QDialog::exec(); - waitStartGameMsgBoxTimer->stop(); - waitStartGameMsgBox->hide(); + waitStartGameMsgBoxTimer->stop(); + waitStartGameMsgBox->hide(); } gameLobbyDialogImpl::~gameLobbyDialogImpl() { - delete myChat; - myChat = NULL; + delete myChat; + myChat = NULL; } void gameLobbyDialogImpl::setSession(boost::shared_ptr session) { - mySession = session; - myChat->setSession(mySession); + mySession = session; + myChat->setSession(mySession); } void gameLobbyDialogImpl::createGame() { - assert(mySession); + assert(mySession); - myCreateInternetGameDialog = new createInternetGameDialogImpl(this, myConfig); - PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId())); - myCreateInternetGameDialog->exec(guestMode, QString::fromUtf8(playerInfo.playerName.c_str())); - - if (myCreateInternetGameDialog->result() == QDialog::Accepted ) { + myCreateInternetGameDialog = new createInternetGameDialogImpl(this, myConfig); + PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId())); + myCreateInternetGameDialog->exec(guestMode, QString::fromUtf8(playerInfo.playerName.c_str())); - GameData gameData; - // Set Game Data - gameData.maxNumberOfPlayers = myCreateInternetGameDialog->spinBox_quantityPlayers->value(); - gameData.startMoney = myCreateInternetGameDialog->spinBox_startCash->value(); - gameData.firstSmallBlind = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); - - if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { - gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; - gameData.raiseSmallBlindEveryHandsValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); - } - else { - gameData.raiseIntervalMode = RAISE_ON_MINUTES; - gameData.raiseSmallBlindEveryMinutesValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); - } - - if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { - gameData.raiseMode = DOUBLE_BLINDS; - } - else { - gameData.raiseMode = MANUAL_BLINDS_ORDER; - std::list tempBlindList; - int i; - bool ok = TRUE; - for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { - tempBlindList.push_back(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); - } - gameData.manualBlindsList = tempBlindList; - - if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } - else { - if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { - gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; - gameData.afterMBAlwaysRaiseValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); - } - else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } - } - } + if (myCreateInternetGameDialog->result() == QDialog::Accepted ) { - gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); - gameData.delayBetweenHandsSec = myCreateInternetGameDialog->spinBox_netDelayBetweenHands->value(); - gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value(); - gameData.gameType = GameType(myCreateInternetGameDialog->comboBox_gameType->itemData(myCreateInternetGameDialog->comboBox_gameType->currentIndex(), Qt::UserRole).toInt()); + GameData gameData; + // Set Game Data + gameData.maxNumberOfPlayers = myCreateInternetGameDialog->spinBox_quantityPlayers->value(); + gameData.startMoney = myCreateInternetGameDialog->spinBox_startCash->value(); + gameData.firstSmallBlind = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); - currentGameName = myCreateInternetGameDialog->lineEdit_gameName->text(); + if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { + gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; + gameData.raiseSmallBlindEveryHandsValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); + } + else { + gameData.raiseIntervalMode = RAISE_ON_MINUTES; + gameData.raiseSmallBlindEveryMinutesValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); + } - switch (gameData.gameType) { - case GAME_TYPE_NORMAL: { - label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png")); - label_typeText->setText(tr("Standard")); - } - break; - case GAME_TYPE_REGISTERED_ONLY: { - label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png")); - label_typeText->setText(tr("Registered players only")); - } - break; - case GAME_TYPE_INVITE_ONLY: { - label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png")); - label_typeText->setText(tr("Invited players only")); - } - break; - case GAME_TYPE_RANKING: { - label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png")); - label_typeText->setText(tr("Ranking game")); - } - break; + if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { + gameData.raiseMode = DOUBLE_BLINDS; + } + else { + gameData.raiseMode = MANUAL_BLINDS_ORDER; + std::list tempBlindList; + int i; + bool ok = TRUE; + for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { + tempBlindList.push_back(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); + } + gameData.manualBlindsList = tempBlindList; + + if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } + else { + if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { + gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; + gameData.afterMBAlwaysRaiseValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); } + else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } + } + } - hideShowGameDescription(TRUE); + gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); + gameData.delayBetweenHandsSec = myCreateInternetGameDialog->spinBox_netDelayBetweenHands->value(); + gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value(); + gameData.gameType = GameType(myCreateInternetGameDialog->comboBox_gameType->itemData(myCreateInternetGameDialog->comboBox_gameType->currentIndex(), Qt::UserRole).toInt()); - label_SmallBlind->setText(QString("%L1").arg(gameData.firstSmallBlind)); - label_StartCash->setText(QString("%L1").arg(gameData.startMoney)); + currentGameName = myCreateInternetGameDialog->lineEdit_gameName->text(); - QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); - header->setText(0, tr("Connected players - max. %1").arg(gameData.maxNumberOfPlayers)); - header->setData(0, Qt::UserRole, gameData.maxNumberOfPlayers); + switch (gameData.gameType) { + case GAME_TYPE_NORMAL: { + label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png")); + label_typeText->setText(tr("Standard")); + } + break; + case GAME_TYPE_REGISTERED_ONLY: { + label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png")); + label_typeText->setText(tr("Registered players only")); + } + break; + case GAME_TYPE_INVITE_ONLY: { + label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png")); + label_typeText->setText(tr("Invited players only")); + } + break; + case GAME_TYPE_RANKING: { + label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png")); + label_typeText->setText(tr("Ranking game")); + } + break; + } - updateDialogBlinds(gameData); + hideShowGameDescription(TRUE); - label_TimeoutForPlayerAction->setText(QString::number(gameData.playerActionTimeoutSec)); + label_SmallBlind->setText(QString("%L1").arg(gameData.firstSmallBlind)); + label_StartCash->setText(QString("%L1").arg(gameData.startMoney)); - mySession->clientCreateGame(gameData, currentGameName.toUtf8().constData(), myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData()); - - } + QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); + header->setText(0, tr("Connected players - max. %1").arg(gameData.maxNumberOfPlayers)); + header->setData(0, Qt::UserRole, gameData.maxNumberOfPlayers); + + updateDialogBlinds(gameData); + + label_TimeoutForPlayerAction->setText(QString::number(gameData.playerActionTimeoutSec)); + + mySession->clientCreateGame(gameData, currentGameName.toUtf8().constData(), myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData()); + + } } void gameLobbyDialogImpl::joinGame() { - assert(mySession); - QItemSelectionModel *selection = treeView_GameList->selectionModel(); - if (!inGame && selection->hasSelection()) - { - unsigned gameId = selection->selectedRows().first().data(Qt::UserRole).toUInt(); - myCurrentGameId = gameId; - GameInfo info(mySession->getClientGameInfo(gameId)); - bool ok = true; - QString password; - //if private ask for password - if (info.isPasswordProtected) { - password = QInputDialog::getText(this, tr("Joining a private Game"), - tr("You are about to join a private game. Please enter the password!"), QLineEdit::Password, (""), &ok); - } + assert(mySession); + QItemSelectionModel *selection = treeView_GameList->selectionModel(); + if (!inGame && selection->hasSelection()) + { + unsigned gameId = selection->selectedRows().first().data(Qt::UserRole).toUInt(); + myCurrentGameId = gameId; + GameInfo info(mySession->getClientGameInfo(gameId)); + bool ok = true; + QString password; + //if private ask for password + if (info.isPasswordProtected) { + password = QInputDialog::getText(this, tr("Joining a private Game"), + tr("You are about to join a private game. Please enter the password!"), QLineEdit::Password, (""), &ok); + } - if (ok) - mySession->clientJoinGame(gameId, password.toUtf8().constData()); - } + if (ok) + mySession->clientJoinGame(gameId, password.toUtf8().constData()); + } } void gameLobbyDialogImpl::joinAnyGame() { - if(comboBox_gameListFilter->currentIndex() != 3 && comboBox_gameListFilter->currentIndex() != 0) comboBox_gameListFilter->setCurrentIndex(0); - - bool found = FALSE; + if(comboBox_gameListFilter->currentIndex() != 3 && comboBox_gameListFilter->currentIndex() != 0) comboBox_gameListFilter->setCurrentIndex(0); - int it = 0; - int gameToJoinId = 0; - int mostConnectedPlayers = 0; - - while (myGameListModel->item(it)) { + bool found = FALSE; - int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt(); - int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt(); - if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) - { - if(players > mostConnectedPlayers) { - mostConnectedPlayers = players; - gameToJoinId = it; - } - found = TRUE; - } - it++; - } + int it = 0; + int gameToJoinId = 0; + int mostConnectedPlayers = 0; - if(found) { - treeView_GameList->setCurrentIndex(myGameListSortFilterProxyModel->mapFromSource(myGameListModel->item(gameToJoinId)->index())); - joinGame(); - } + while (myGameListModel->item(it)) { + + int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt(); + int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt(); + if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) + { + if(players > mostConnectedPlayers) { + mostConnectedPlayers = players; + gameToJoinId = it; + } + found = TRUE; + } + it++; + } + + if(found) { + treeView_GameList->setCurrentIndex(myGameListSortFilterProxyModel->mapFromSource(myGameListModel->item(gameToJoinId)->index())); + joinGame(); + } } void gameLobbyDialogImpl::refresh(int actionID) { - if (actionID == MSG_NET_GAME_CLIENT_START) - { - myGameListModel->clear(); - myGameListSelectionModel->clear(); - myGameListSelectionModel->clearSelection(); - myGameListSortFilterProxyModel->clear(); + if (actionID == MSG_NET_GAME_CLIENT_START) + { + myGameListModel->clear(); + myGameListSelectionModel->clear(); + myGameListSelectionModel->clearSelection(); + myGameListSortFilterProxyModel->clear(); - treeWidget_NickList->clear(); - - QStringList headerList; - headerList << tr("Game") << tr("Players") << tr("State") << tr("T") << tr("P"); - myGameListModel->setHorizontalHeaderLabels(headerList); - treeView_GameList->setColumnWidth(0,220); - treeView_GameList->setColumnWidth(1,65); - treeView_GameList->setColumnWidth(2,65); - treeView_GameList->setColumnWidth(3,30); - treeView_GameList->setColumnWidth(4,30); + treeWidget_NickList->clear(); - this->accept(); - myW->show(); - } + QStringList headerList; + headerList << tr("Game") << tr("Players") << tr("State") << tr("T") << tr("P"); + myGameListModel->setHorizontalHeaderLabels(headerList); + treeView_GameList->setColumnWidth(0,220); + treeView_GameList->setColumnWidth(1,65); + treeView_GameList->setColumnWidth(2,65); + treeView_GameList->setColumnWidth(3,30); + treeView_GameList->setColumnWidth(4,30); + + this->accept(); + myW->show(); + } } void gameLobbyDialogImpl::removedFromGame(int /*reason*/) { - inGame = false; - isGameAdministrator = false; - leftGameDialogUpdate(); + inGame = false; + isGameAdministrator = false; + leftGameDialogUpdate(); } void gameLobbyDialogImpl::gameSelected(const QModelIndex &index, const QModelIndex &) { - if (!inGame && index.isValid()) - { - pushButton_JoinGame->setEnabled(true); + if (!inGame && index.isValid()) + { + pushButton_JoinGame->setEnabled(true); - currentGameName = myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->text(); + currentGameName = myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->text(); - groupBox_GameInfo->setEnabled(true); - groupBox_GameInfo->setTitle(tr("Game Info") + " - " + currentGameName); + groupBox_GameInfo->setEnabled(true); + groupBox_GameInfo->setTitle(tr("Game Info") + " - " + currentGameName); - assert(mySession); - GameInfo info(mySession->getClientGameInfo(myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->data(Qt::UserRole).toUInt())); - - switch (info.data.gameType) { - case GAME_TYPE_NORMAL: { - label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png")); - label_typeText->setText(tr("Standard")); - } - break; - case GAME_TYPE_REGISTERED_ONLY: { - label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png")); - label_typeText->setText(tr("Registered players only")); - } - break; - case GAME_TYPE_INVITE_ONLY: { - label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png")); - label_typeText->setText(tr("Invited players only")); - } - break; - case GAME_TYPE_RANKING: { - label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png")); - label_typeText->setText(tr("Ranking game")); - } - break; - } - - hideShowGameDescription(TRUE); - label_SmallBlind->setText(QString("%L1").arg(info.data.firstSmallBlind)); - label_StartCash->setText(QString("%L1").arg(info.data.startMoney)); -// label_MaximumNumberOfPlayers->setText(QString::number(info.data.maxNumberOfPlayers));s - updateDialogBlinds(info.data); - - label_TimeoutForPlayerAction->setText(QString::number(info.data.playerActionTimeoutSec)); - - treeWidget_connectedPlayers->clear(); - PlayerIdList::const_iterator i = info.players.begin(); - PlayerIdList::const_iterator end = info.players.end(); - while (i != end) - { - bool admin = info.adminPlayerId == *i; - PlayerInfo playerInfo(mySession->getClientPlayerInfo(*i)); - addConnectedPlayer(*i, QString::fromUtf8(playerInfo.playerName.c_str()), admin); - ++i; - } - - QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); - header->setText(0, tr("Connected players - Max. %1").arg(info.data.maxNumberOfPlayers)); - header->setData(0, Qt::UserRole, info.data.maxNumberOfPlayers); -#ifdef __APPLE__ - // Dirty workaround for a Qt redraw bug on Mac OS. - treeWidget_connectedPlayers->setFocus(); - treeView_GameList->setFocus(); -#endif - } -} - -void gameLobbyDialogImpl::updateGameItem(QList itemList, unsigned gameId) -{ - assert(mySession); - GameInfo info(mySession->getClientGameInfo(gameId)); - - itemList.at(0)->setData(gameId, Qt::UserRole); - itemList.at(0)->setData(QString::fromUtf8(info.name.c_str()), Qt::DisplayRole); - - PlayerIdList::const_iterator i = info.players.begin(); - PlayerIdList::const_iterator end = info.players.end(); - - while (i != end) - { - if(myPlayerId == *i) { - itemList.at(0)->setData( "MeInThisGame", 16); - itemList.at(0)->setBackground(QBrush(QColor(0, 255, 0, 127))); - itemList.at(1)->setBackground(QBrush(QColor(0, 255, 0, 127))); - itemList.at(2)->setBackground(QBrush(QColor(0, 255, 0, 127))); - itemList.at(3)->setBackground(QBrush(QColor(0, 255, 0, 127))); - itemList.at(4)->setBackground(QBrush(QColor(0, 255, 0, 127))); - break; - } - else { - itemList.at(0)->setData( "", 16); - itemList.at(0)->setBackground(QBrush()); - itemList.at(1)->setBackground(QBrush()); - itemList.at(2)->setBackground(QBrush()); - itemList.at(3)->setBackground(QBrush()); - itemList.at(4)->setBackground(QBrush()); - } - ++i; - } - - QString playerStr; - playerStr.sprintf("%u/%u", (unsigned)info.players.size(), (unsigned)info.data.maxNumberOfPlayers); - itemList.at(1)->setData(playerStr, Qt::DisplayRole); - if((unsigned)info.players.size() == (unsigned)info.data.maxNumberOfPlayers) { itemList.at(1)->setData("totalfull", 16); } - else { itemList.at(1)->setData("nonfull", 16); }\ - - if (info.mode == GAME_MODE_STARTED) { - itemList.at(2)->setData(tr("running"), Qt::DisplayRole); - itemList.at(2)->setData("running", 16); - } - else { - itemList.at(2)->setData(tr("open"), Qt::DisplayRole); - itemList.at(2)->setData("open", 16); - } + assert(mySession); + GameInfo info(mySession->getClientGameInfo(myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->data(Qt::UserRole).toUInt())); switch (info.data.gameType) { - case GAME_TYPE_NORMAL: { - itemList.at(3)->setIcon(QIcon(":/gfx/player_play.png")); - itemList.at(3)->setData("", Qt::DisplayRole); - itemList.at(3)->setData("standard", 16); + case GAME_TYPE_NORMAL: { + label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png")); + label_typeText->setText(tr("Standard")); } break; - case GAME_TYPE_REGISTERED_ONLY: { - itemList.at(3)->setIcon(QIcon(":/gfx/registered.png")); - itemList.at(3)->setData(" ", Qt::DisplayRole); - itemList.at(3)->setData("registered", 16); + case GAME_TYPE_REGISTERED_ONLY: { + label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png")); + label_typeText->setText(tr("Registered players only")); } break; - case GAME_TYPE_INVITE_ONLY: { - itemList.at(3)->setIcon(QIcon(":/gfx/list_add_user.png")); - itemList.at(3)->setData(" ", Qt::DisplayRole); - itemList.at(3)->setData("invited", 16); + case GAME_TYPE_INVITE_ONLY: { + label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png")); + label_typeText->setText(tr("Invited players only")); } break; - case GAME_TYPE_RANKING: { - itemList.at(3)->setIcon(QIcon(":/gfx/cup.png")); - itemList.at(3)->setData(" ", Qt::DisplayRole); - itemList.at(3)->setData("ranking", 16); + case GAME_TYPE_RANKING: { + label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png")); + label_typeText->setText(tr("Ranking game")); } break; } - if (info.isPasswordProtected) { - itemList.at(4)->setIcon(QIcon(":/gfx/lock.png")); - itemList.at(4)->setData(" ", Qt::DisplayRole); - itemList.at(4)->setData("private", 16); - } - else { - itemList.at(4)->setData("", Qt::DisplayRole); - itemList.at(4)->setData("nonpriv", 16); - } + hideShowGameDescription(TRUE); + label_SmallBlind->setText(QString("%L1").arg(info.data.firstSmallBlind)); + label_StartCash->setText(QString("%L1").arg(info.data.startMoney)); + // label_MaximumNumberOfPlayers->setText(QString::number(info.data.maxNumberOfPlayers));s + updateDialogBlinds(info.data); -// treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") ); - refreshGameStats(); + label_TimeoutForPlayerAction->setText(QString::number(info.data.playerActionTimeoutSec)); + + treeWidget_connectedPlayers->clear(); + PlayerIdList::const_iterator i = info.players.begin(); + PlayerIdList::const_iterator end = info.players.end(); + while (i != end) + { + bool admin = info.adminPlayerId == *i; + PlayerInfo playerInfo(mySession->getClientPlayerInfo(*i)); + addConnectedPlayer(*i, QString::fromUtf8(playerInfo.playerName.c_str()), admin); + ++i; + } + + QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); + header->setText(0, tr("Connected players - Max. %1").arg(info.data.maxNumberOfPlayers)); + header->setData(0, Qt::UserRole, info.data.maxNumberOfPlayers); +#ifdef __APPLE__ + // Dirty workaround for a Qt redraw bug on Mac OS. + treeWidget_connectedPlayers->setFocus(); + treeView_GameList->setFocus(); +#endif + } +} + +void gameLobbyDialogImpl::updateGameItem(QList itemList, unsigned gameId) +{ + assert(mySession); + GameInfo info(mySession->getClientGameInfo(gameId)); + + itemList.at(0)->setData(gameId, Qt::UserRole); + itemList.at(0)->setData(QString::fromUtf8(info.name.c_str()), Qt::DisplayRole); + + PlayerIdList::const_iterator i = info.players.begin(); + PlayerIdList::const_iterator end = info.players.end(); + + while (i != end) + { + if(myPlayerId == *i) { + itemList.at(0)->setData( "MeInThisGame", 16); + itemList.at(0)->setBackground(QBrush(QColor(0, 255, 0, 127))); + itemList.at(1)->setBackground(QBrush(QColor(0, 255, 0, 127))); + itemList.at(2)->setBackground(QBrush(QColor(0, 255, 0, 127))); + itemList.at(3)->setBackground(QBrush(QColor(0, 255, 0, 127))); + itemList.at(4)->setBackground(QBrush(QColor(0, 255, 0, 127))); + break; + } + else { + itemList.at(0)->setData( "", 16); + itemList.at(0)->setBackground(QBrush()); + itemList.at(1)->setBackground(QBrush()); + itemList.at(2)->setBackground(QBrush()); + itemList.at(3)->setBackground(QBrush()); + itemList.at(4)->setBackground(QBrush()); + } + ++i; + } + + QString playerStr; + playerStr.sprintf("%u/%u", (unsigned)info.players.size(), (unsigned)info.data.maxNumberOfPlayers); + itemList.at(1)->setData(playerStr, Qt::DisplayRole); + if((unsigned)info.players.size() == (unsigned)info.data.maxNumberOfPlayers) { itemList.at(1)->setData("totalfull", 16); } + else { itemList.at(1)->setData("nonfull", 16); }\ + + if (info.mode == GAME_MODE_STARTED) { + itemList.at(2)->setData(tr("running"), Qt::DisplayRole); + itemList.at(2)->setData("running", 16); + } + else { + itemList.at(2)->setData(tr("open"), Qt::DisplayRole); + itemList.at(2)->setData("open", 16); + } + + switch (info.data.gameType) { + case GAME_TYPE_NORMAL: { + itemList.at(3)->setIcon(QIcon(":/gfx/player_play.png")); + itemList.at(3)->setData("", Qt::DisplayRole); + itemList.at(3)->setData("standard", 16); + } + break; + case GAME_TYPE_REGISTERED_ONLY: { + itemList.at(3)->setIcon(QIcon(":/gfx/registered.png")); + itemList.at(3)->setData(" ", Qt::DisplayRole); + itemList.at(3)->setData("registered", 16); + } + break; + case GAME_TYPE_INVITE_ONLY: { + itemList.at(3)->setIcon(QIcon(":/gfx/list_add_user.png")); + itemList.at(3)->setData(" ", Qt::DisplayRole); + itemList.at(3)->setData("invited", 16); + } + break; + case GAME_TYPE_RANKING: { + itemList.at(3)->setIcon(QIcon(":/gfx/cup.png")); + itemList.at(3)->setData(" ", Qt::DisplayRole); + itemList.at(3)->setData("ranking", 16); + } + break; + } + + if (info.isPasswordProtected) { + itemList.at(4)->setIcon(QIcon(":/gfx/lock.png")); + itemList.at(4)->setData(" ", Qt::DisplayRole); + itemList.at(4)->setData("private", 16); + } + else { + itemList.at(4)->setData("", Qt::DisplayRole); + itemList.at(4)->setData("nonpriv", 16); + } + + // treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") ); + refreshGameStats(); } void gameLobbyDialogImpl::addGame(unsigned gameId) { - QList itemList; - QStandardItem *item1 = new QStandardItem(); - QStandardItem *item2 = new QStandardItem(); - QStandardItem *item3 = new QStandardItem(); - QStandardItem *item4 = new QStandardItem(); - QStandardItem *item5 = new QStandardItem(); - itemList << item1 << item2 << item3 << item4 << item5; - - myGameListModel->appendRow(itemList); - - updateGameItem(itemList, gameId); - + QList itemList; + QStandardItem *item1 = new QStandardItem(); + QStandardItem *item2 = new QStandardItem(); + QStandardItem *item3 = new QStandardItem(); + QStandardItem *item4 = new QStandardItem(); + QStandardItem *item5 = new QStandardItem(); + itemList << item1 << item2 << item3 << item4 << item5; + + myGameListModel->appendRow(itemList); + + updateGameItem(itemList, gameId); + } void gameLobbyDialogImpl::updateGameMode(unsigned gameId, int /*newMode*/) { - int it = 0; - while (myGameListModel->item(it)) { - if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) - { - QList itemList; - itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); - updateGameItem(itemList, gameId); - break; - } - it++; - } + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) + { + QList itemList; + itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); + updateGameItem(itemList, gameId); + break; + } + it++; + } } void gameLobbyDialogImpl::updateGameAdmin(unsigned /*gameId*/, unsigned adminPlayerId) { - newGameAdmin(adminPlayerId, ""); + newGameAdmin(adminPlayerId, ""); } void gameLobbyDialogImpl::removeGame(unsigned gameId) { - int it = 0; - while (myGameListModel->item(it)) { - if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) - { - myGameListModel->removeRow(it); - break; - } - it++; - } - - refreshGameStats(); + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) + { + myGameListModel->removeRow(it); + break; + } + it++; + } + + refreshGameStats(); } void gameLobbyDialogImpl::refreshGameStats() { - int runningGamesCounter = 0; - int openGamesCounter = 0; + int runningGamesCounter = 0; + int openGamesCounter = 0; - int it = 0; - while (myGameListModel->item(it)) { - if (myGameListModel->item(it, 2)->data(16) == "running") { runningGamesCounter++; } - if (myGameListModel->item(it, 2)->data(16) == "open") { openGamesCounter++; } - ++it; - } + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 2)->data(16) == "running") { runningGamesCounter++; } + if (myGameListModel->item(it, 2)->data(16) == "open") { openGamesCounter++; } + ++it; + } - label_openGamesCounter->setText("| "+tr("running games: %1").arg(runningGamesCounter)); - label_runningGamesCounter->setText("| "+tr("open games: %1").arg(openGamesCounter)); + label_openGamesCounter->setText("| "+tr("running games: %1").arg(runningGamesCounter)); + label_runningGamesCounter->setText("| "+tr("open games: %1").arg(openGamesCounter)); + + //refresh joinAnyGameButton state + joinAnyGameButtonRefresh(); - //refresh joinAnyGameButton state - joinAnyGameButtonRefresh(); - } void gameLobbyDialogImpl::refreshPlayerStats() { - ServerStats stats = mySession->getClientStats(); - label_nickListCounter->setText("| "+tr("players in chat: %1").arg(treeWidget_NickList->topLevelItemCount())); - label_connectedPlayersCounter->setText(tr("connected players: %1").arg(stats.numberOfPlayersOnServer)); + ServerStats stats = mySession->getClientStats(); + label_nickListCounter->setText("| "+tr("players in chat: %1").arg(treeWidget_NickList->topLevelItemCount())); + label_connectedPlayersCounter->setText(tr("connected players: %1").arg(stats.numberOfPlayersOnServer)); } void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId) { - if (!inGame) - { - QItemSelectionModel *selection = treeView_GameList->selectionModel(); - if (selection->hasSelection()) { - if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) { - assert(mySession); - GameInfo info(mySession->getClientGameInfo(gameId)); - bool admin = info.adminPlayerId == playerId; - PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); - - addConnectedPlayer(playerId, QString::fromUtf8(playerInfo.playerName.c_str()), admin); - } - } - } + if (!inGame) + { + QItemSelectionModel *selection = treeView_GameList->selectionModel(); + if (selection->hasSelection()) { + if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) { + assert(mySession); + GameInfo info(mySession->getClientGameInfo(gameId)); + bool admin = info.adminPlayerId == playerId; + PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); - int it = 0; - while (myGameListModel->item(it)) { - if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) { - QList itemList; - itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); - - updateGameItem(itemList, gameId); - break; - } - it++; - } + addConnectedPlayer(playerId, QString::fromUtf8(playerInfo.playerName.c_str()), admin); + } + } + } + + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) { + QList itemList; + itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); + + updateGameItem(itemList, gameId); + break; + } + it++; + } } void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId) { - if (!inGame) - { - QItemSelectionModel *selection = treeView_GameList->selectionModel(); - if (selection->hasSelection()) { - if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) { - assert(mySession); - PlayerInfo info(mySession->getClientPlayerInfo(playerId)); - removePlayer(playerId, QString::fromUtf8(info.playerName.c_str())); - } - } - } + if (!inGame) + { + QItemSelectionModel *selection = treeView_GameList->selectionModel(); + if (selection->hasSelection()) { + if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) { + assert(mySession); + PlayerInfo info(mySession->getClientPlayerInfo(playerId)); + removePlayer(playerId, QString::fromUtf8(info.playerName.c_str())); + } + } + } - int it = 0; - while (myGameListModel->item(it)) { - if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) { - QList itemList; - itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); - - updateGameItem(itemList, gameId); - break; - } - ++it; - } + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) { + QList itemList; + itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); + + updateGameItem(itemList, gameId); + break; + } + ++it; + } } void gameLobbyDialogImpl::updateStats(ServerStats /*stats*/) { - refreshPlayerStats(); + refreshPlayerStats(); } void gameLobbyDialogImpl::clearDialog() { - groupBox_GameInfo->setTitle(tr("Game Info")); - groupBox_GameInfo->setEnabled(false); - currentGameName = ""; + groupBox_GameInfo->setTitle(tr("Game Info")); + groupBox_GameInfo->setEnabled(false); + currentGameName = ""; - QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); - header->setText(0, tr("Connected players")); - header->setData(0, Qt::UserRole, 0); + QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); + header->setText(0, tr("Connected players")); + header->setData(0, Qt::UserRole, 0); - hideShowGameDescription(FALSE); - label_typeIcon->setText(" "); - label_typeText->setText(" "); - label_SmallBlind->setText(""); - label_StartCash->setText(""); - label_blindsRaiseIntervall->setText(""); - label_blindsRaiseMode->setText(""); - label_blindsList->setText(""); - label_TimeoutForPlayerAction->setText(""); + hideShowGameDescription(FALSE); + label_typeIcon->setText(" "); + label_typeText->setText(" "); + label_SmallBlind->setText(""); + label_StartCash->setText(""); + label_blindsRaiseIntervall->setText(""); + label_blindsRaiseMode->setText(""); + label_blindsList->setText(""); + label_TimeoutForPlayerAction->setText(""); - myGameListModel->clear(); - myGameListSelectionModel->clear(); - myGameListSelectionModel->clearSelection(); - myGameListSortFilterProxyModel->clear(); - treeView_GameList->show(); - treeWidget_connectedPlayers->clear(); - - pushButton_Leave->hide(); - pushButton_Kick->hide(); - pushButton_Kick->setEnabled(false); - pushButton_StartGame->hide(); - checkBox_fillUpWithComputerOpponents->hide(); - pushButton_CreateGame->show(); - pushButton_JoinGame->show(); - pushButton_JoinGame->setEnabled(false); - pushButton_joinAnyGame->show(); - pushButton_joinAnyGame->setEnabled(false); + myGameListModel->clear(); + myGameListSelectionModel->clear(); + myGameListSelectionModel->clearSelection(); + myGameListSortFilterProxyModel->clear(); + treeView_GameList->show(); + treeWidget_connectedPlayers->clear(); - QStringList headerList; - headerList << tr("Game") << tr("Players") << tr("State") << tr("T") << tr("P"); - myGameListModel->setHorizontalHeaderLabels(headerList); - treeView_GameList->setColumnWidth(0,220); - treeView_GameList->setColumnWidth(1,65); - treeView_GameList->setColumnWidth(2,65); - treeView_GameList->setColumnWidth(3,30); - treeView_GameList->setColumnWidth(4,30); + pushButton_Leave->hide(); + pushButton_Kick->hide(); + pushButton_Kick->setEnabled(false); + pushButton_StartGame->hide(); + checkBox_fillUpWithComputerOpponents->hide(); + pushButton_CreateGame->show(); + pushButton_JoinGame->show(); + pushButton_JoinGame->setEnabled(false); + pushButton_joinAnyGame->show(); + pushButton_joinAnyGame->setEnabled(false); - pushButton_CreateGame->clearFocus(); - lineEdit_ChatInput->setFocus(); - myChat->clearChat(); - treeWidget_NickList->clear(); - inGame = false; - isGameAdministrator = false; - myPlayerId = 0; + QStringList headerList; + headerList << tr("Game") << tr("Players") << tr("State") << tr("T") << tr("P"); + myGameListModel->setHorizontalHeaderLabels(headerList); + treeView_GameList->setColumnWidth(0,220); + treeView_GameList->setColumnWidth(1,65); + treeView_GameList->setColumnWidth(2,65); + treeView_GameList->setColumnWidth(3,30); + treeView_GameList->setColumnWidth(4,30); - hideShowGameDescription(FALSE); + pushButton_CreateGame->clearFocus(); + lineEdit_ChatInput->setFocus(); + myChat->clearChat(); + treeWidget_NickList->clear(); + inGame = false; + isGameAdministrator = false; + myPlayerId = 0; - label_nickListCounter->setText("| "+tr("players in chat: %1").arg(0)); - label_connectedPlayersCounter->setText(tr("connected players: %1").arg(0)); - label_openGamesCounter->setText("| "+tr("running games: %1").arg(0)); - label_runningGamesCounter->setText("| "+tr("open games: %1").arg(0)); + hideShowGameDescription(FALSE); - readDialogSettings(); + label_nickListCounter->setText("| "+tr("players in chat: %1").arg(0)); + label_connectedPlayersCounter->setText(tr("connected players: %1").arg(0)); + label_openGamesCounter->setText("| "+tr("running games: %1").arg(0)); + label_runningGamesCounter->setText("| "+tr("open games: %1").arg(0)); + + readDialogSettings(); } void gameLobbyDialogImpl::checkPlayerQuantity() { - if(isGameAdministrator){ - pushButton_Kick->show(); - pushButton_StartGame->show(); - checkBox_fillUpWithComputerOpponents->show(); - - if (treeWidget_connectedPlayers->topLevelItemCount() >= 2) { - pushButton_StartGame->setEnabled(true); - - if(treeWidget_connectedPlayers->topLevelItemCount() == treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { - blinkingButtonAnimationTimer->start(); - } - else { - blinkingButtonAnimationTimer->stop(); - blinkingButtonAnimationState = false; - blinkingStartButtonAnimation(); - } - } - else { - pushButton_StartGame->setEnabled(false); - blinkingButtonAnimationTimer->stop(); - blinkingButtonAnimationState = false; - blinkingStartButtonAnimation(); - } - } + if(isGameAdministrator){ + pushButton_Kick->show(); + pushButton_StartGame->show(); + checkBox_fillUpWithComputerOpponents->show(); + + if (treeWidget_connectedPlayers->topLevelItemCount() >= 2) { + pushButton_StartGame->setEnabled(true); + + if(treeWidget_connectedPlayers->topLevelItemCount() == treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { + blinkingButtonAnimationTimer->start(); + } + else { + blinkingButtonAnimationTimer->stop(); + blinkingButtonAnimationState = false; + blinkingStartButtonAnimation(); + } + } + else { + pushButton_StartGame->setEnabled(false); + blinkingButtonAnimationTimer->stop(); + blinkingButtonAnimationState = false; + blinkingStartButtonAnimation(); + } + } } void gameLobbyDialogImpl::blinkingStartButtonAnimation() { - - if(blinkingButtonAnimationState) { - QPalette p = pushButton_StartGame->palette(); - p.setColor(QPalette::Button, QColor(Qt::red)); - p.setColor(QPalette::ButtonText, QColor(Qt::white)); - pushButton_StartGame->setPalette(p); - blinkingButtonAnimationState = false; - } - else { - if(pushButton_StartGame->isEnabled()) { - QPalette p = pushButton_StartGame->palette(); - p.setColor(QPalette::Button, defaultStartButtonColor); - p.setColor(QPalette::ButtonText, defaultStartButtonTextColor); - pushButton_StartGame->setPalette(p); - blinkingButtonAnimationState = true; - } - else { - QPalette p = pushButton_StartGame->palette(); - p.setColor(QPalette::Button, disabledStartButtonColor); - p.setColor(QPalette::ButtonText, disabledStartButtonTextColor); - pushButton_StartGame->setPalette(p); - blinkingButtonAnimationState = true; - } - } + + if(blinkingButtonAnimationState) { + QPalette p = pushButton_StartGame->palette(); + p.setColor(QPalette::Button, QColor(Qt::red)); + p.setColor(QPalette::ButtonText, QColor(Qt::white)); + pushButton_StartGame->setPalette(p); + blinkingButtonAnimationState = false; + } + else { + if(pushButton_StartGame->isEnabled()) { + QPalette p = pushButton_StartGame->palette(); + p.setColor(QPalette::Button, defaultStartButtonColor); + p.setColor(QPalette::ButtonText, defaultStartButtonTextColor); + pushButton_StartGame->setPalette(p); + blinkingButtonAnimationState = true; + } + else { + QPalette p = pushButton_StartGame->palette(); + p.setColor(QPalette::Button, disabledStartButtonColor); + p.setColor(QPalette::ButtonText, disabledStartButtonTextColor); + pushButton_StartGame->setPalette(p); + blinkingButtonAnimationState = true; + } + } } void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, bool isGameAdmin) { @@ -770,493 +770,493 @@ void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerNam void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerName, bool isGameAdmin) { - QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_connectedPlayers, 0); - item->setData(0, Qt::UserRole, playerId); - item->setData(0, Qt::DisplayRole, playerName); - - if(isGameAdmin) item->setBackground(0, QBrush(QColor(0, 255, 0, 127))); + QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_connectedPlayers, 0); + item->setData(0, Qt::UserRole, playerId); + item->setData(0, Qt::DisplayRole, playerName); - if(this->isVisible() && inGame && myConfig->readConfigInt("PlayNetworkGameNotification")) { - if(treeWidget_connectedPlayers->topLevelItemCount() < treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { - myW->getMySDLPlayer()->playSound("playerconnected", 0); - } - else { - myW->getMySDLPlayer()->playSound("onlinegameready", 0); - } - } + if(isGameAdmin) item->setBackground(0, QBrush(QColor(0, 255, 0, 127))); - checkPlayerQuantity(); + if(this->isVisible() && inGame && myConfig->readConfigInt("PlayNetworkGameNotification")) { + if(treeWidget_connectedPlayers->topLevelItemCount() < treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { + myW->getMySDLPlayer()->playSound("playerconnected", 0); + } + else { + myW->getMySDLPlayer()->playSound("onlinegameready", 0); + } + } - if (inGame) - refreshConnectedPlayerAvatars(); + checkPlayerQuantity(); + + if (inGame) + refreshConnectedPlayerAvatars(); } void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName) { - //rename player in connected players list - QTreeWidgetItemIterator it(treeWidget_connectedPlayers); - while (*it) { - if ((*it)->data(0, Qt::UserRole) == playerId) - { - (*it)->setData(0, Qt::DisplayRole, newPlayerName); - break; - } - ++it; - } + //rename player in connected players list + QTreeWidgetItemIterator it(treeWidget_connectedPlayers); + while (*it) { + if ((*it)->data(0, Qt::UserRole) == playerId) + { + (*it)->setData(0, Qt::DisplayRole, newPlayerName); + break; + } + ++it; + } - if (inGame) - refreshConnectedPlayerAvatars(); - - //also rename player in nick-list - QString oldNick; - QTreeWidgetItemIterator it1(treeWidget_NickList); - while (*it1) { - if ((*it1)->data(0, Qt::UserRole) == playerId) - { - oldNick = (*it1)->data(0, Qt::DisplayRole).toString(); - (*it1)->setData(0, Qt::DisplayRole, newPlayerName); - PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); - if(!playerInfo.isGuest) { - (*it1)->setIcon(0, QIcon(QString(":/cflags/cflags/%1.png").arg("de"))); - } - else { - (*it1)->setIcon(0, QIcon()); - } + if (inGame) + refreshConnectedPlayerAvatars(); - break; - } - ++it1; - } - - if (myChat->getMyNick() == oldNick) { - myChat->setMyNick(newPlayerName); - } + //also rename player in nick-list + QString oldNick; + QTreeWidgetItemIterator it1(treeWidget_NickList); + while (*it1) { + if ((*it1)->data(0, Qt::UserRole) == playerId) + { + oldNick = (*it1)->data(0, Qt::DisplayRole).toString(); + (*it1)->setData(0, Qt::DisplayRole, newPlayerName); + PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); + if(!playerInfo.isGuest) { + (*it1)->setIcon(0, QIcon(QString(":/cflags/cflags/%1.png").arg("de"))); + } + else { + (*it1)->setIcon(0, QIcon()); + } + + break; + } + ++it1; + } + + if (myChat->getMyNick() == oldNick) { + myChat->setMyNick(newPlayerName); + } } void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) { - QTreeWidgetItemIterator it(treeWidget_connectedPlayers); - while (*it) { - if ((*it)->data(0, Qt::UserRole) == playerId) - { - treeWidget_connectedPlayers->takeTopLevelItem(treeWidget_connectedPlayers->indexOfTopLevelItem(*it)); - break; - } - ++it; - } + QTreeWidgetItemIterator it(treeWidget_connectedPlayers); + while (*it) { + if ((*it)->data(0, Qt::UserRole) == playerId) + { + treeWidget_connectedPlayers->takeTopLevelItem(treeWidget_connectedPlayers->indexOfTopLevelItem(*it)); + break; + } + ++it; + } - checkPlayerQuantity(); + checkPlayerQuantity(); } void gameLobbyDialogImpl::playerLeftLobby(unsigned playerId) { - QTreeWidgetItemIterator it(treeWidget_NickList); - while (*it) { - if ((*it)->data(0, Qt::UserRole) == playerId) - { - treeWidget_NickList->takeTopLevelItem(treeWidget_NickList->indexOfTopLevelItem(*it)); - break; - } - ++it; - } - - treeWidget_NickList->sortItems(0, Qt::AscendingOrder); - refreshPlayerStats(); + QTreeWidgetItemIterator it(treeWidget_NickList); + while (*it) { + if ((*it)->data(0, Qt::UserRole) == playerId) + { + treeWidget_NickList->takeTopLevelItem(treeWidget_NickList->indexOfTopLevelItem(*it)); + break; + } + ++it; + } + + treeWidget_NickList->sortItems(0, Qt::AscendingOrder); + refreshPlayerStats(); } void gameLobbyDialogImpl::playerJoinedLobby(unsigned playerId, QString /*playerName TODO remove*/) { - PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); + PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); - QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_NickList, 0); - item->setData(0, Qt::DisplayRole, QString::fromUtf8(playerInfo.playerName.c_str())); - item->setData(0, Qt::UserRole, playerId); + QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_NickList, 0); + item->setData(0, Qt::DisplayRole, QString::fromUtf8(playerInfo.playerName.c_str())); + item->setData(0, Qt::UserRole, playerId); - treeWidget_NickList->sortItems(0, Qt::AscendingOrder); - refreshPlayerStats(); + treeWidget_NickList->sortItems(0, Qt::AscendingOrder); + refreshPlayerStats(); } void gameLobbyDialogImpl::newGameAdmin(unsigned playerId, QString) { - QTreeWidgetItemIterator it(treeWidget_connectedPlayers); - while (*it) { - if ((*it)->data(0, Qt::UserRole) == playerId) { - (*it)->setBackground(0, QBrush(QColor(0, 255, 0, 127))); - } - ++it; - } + QTreeWidgetItemIterator it(treeWidget_connectedPlayers); + while (*it) { + if ((*it)->data(0, Qt::UserRole) == playerId) { + (*it)->setBackground(0, QBrush(QColor(0, 255, 0, 127))); + } + ++it; + } - if (inGame && myPlayerId == playerId) - { - isGameAdministrator = true; - checkPlayerQuantity(); - } + if (inGame && myPlayerId == playerId) + { + isGameAdministrator = true; + checkPlayerQuantity(); + } } void gameLobbyDialogImpl::refreshConnectedPlayerAvatars() { - QTreeWidgetItemIterator it(treeWidget_connectedPlayers); - while (*it) { + QTreeWidgetItemIterator it(treeWidget_connectedPlayers); + while (*it) { - std::string myAvatarFileName; - PlayerInfo playerInfo(mySession->getClientPlayerInfo((*it)->data(0, Qt::UserRole).toUInt())); - - if(mySession->getAvatarFile(playerInfo.avatar, myAvatarFileName)) { + std::string myAvatarFileName; + PlayerInfo playerInfo(mySession->getClientPlayerInfo((*it)->data(0, Qt::UserRole).toUInt())); - QString myAvatarString(QString::fromUtf8(myAvatarFileName.c_str())); - if(QFile::QFile(myAvatarString).exists()) { - - QPixmap myAvatarPixmap(25,26); - myAvatarPixmap.fill(Qt::transparent); - QPixmap tempPixmap(myAvatarString); - QPainter p(&myAvatarPixmap); - p.drawPixmap (0,0,25,25,tempPixmap); - (*it)->setIcon(0, QIcon(myAvatarPixmap)); - } - } - ++it; - } + if(mySession->getAvatarFile(playerInfo.avatar, myAvatarFileName)) { + + QString myAvatarString(QString::fromUtf8(myAvatarFileName.c_str())); + if(QFile::QFile(myAvatarString).exists()) { + + QPixmap myAvatarPixmap(25,26); + myAvatarPixmap.fill(Qt::transparent); + QPixmap tempPixmap(myAvatarString); + QPainter p(&myAvatarPixmap); + p.drawPixmap (0,0,25,25,tempPixmap); + (*it)->setIcon(0, QIcon(myAvatarPixmap)); + } + } + ++it; + } } void gameLobbyDialogImpl::joinedGameDialogUpdate() { - groupBox_GameInfo->setEnabled(true); - groupBox_GameInfo->setTitle(currentGameName); - treeWidget_connectedPlayers->clear(); - pushButton_CreateGame->hide(); - pushButton_JoinGame->hide(); - pushButton_joinAnyGame->hide(); - pushButton_Leave->show(); + groupBox_GameInfo->setEnabled(true); + groupBox_GameInfo->setTitle(currentGameName); + treeWidget_connectedPlayers->clear(); + pushButton_CreateGame->hide(); + pushButton_JoinGame->hide(); + pushButton_joinAnyGame->hide(); + pushButton_Leave->show(); } void gameLobbyDialogImpl::leftGameDialogUpdate() { - // un-select current game. - treeView_GameList->clearSelection(); + // un-select current game. + treeView_GameList->clearSelection(); - groupBox_GameInfo->setTitle(tr("Game Info")); - groupBox_GameInfo->setEnabled(false); - currentGameName = ""; + groupBox_GameInfo->setTitle(tr("Game Info")); + groupBox_GameInfo->setEnabled(false); + currentGameName = ""; - QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); - header->setText(0, tr("Connected players")); - header->setData(0, Qt::UserRole, 0); + QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); + header->setText(0, tr("Connected players")); + header->setData(0, Qt::UserRole, 0); - hideShowGameDescription(FALSE); - label_typeIcon->setText(" "); - label_typeText->setText(" "); - label_SmallBlind->setText(""); - label_StartCash->setText(""); - label_blindsRaiseIntervall->setText(""); - label_blindsRaiseMode->setText(""); - label_blindsList->setText(""); - label_TimeoutForPlayerAction->setText(""); + hideShowGameDescription(FALSE); + label_typeIcon->setText(" "); + label_typeText->setText(" "); + label_SmallBlind->setText(""); + label_StartCash->setText(""); + label_blindsRaiseIntervall->setText(""); + label_blindsRaiseMode->setText(""); + label_blindsList->setText(""); + label_TimeoutForPlayerAction->setText(""); - treeWidget_connectedPlayers->clear(); - pushButton_StartGame->hide(); - pushButton_Leave->hide(); - pushButton_Kick->hide(); - pushButton_Kick->setEnabled(false); - checkBox_fillUpWithComputerOpponents->hide(); - pushButton_CreateGame->show(); - pushButton_JoinGame->show(); - pushButton_JoinGame->setEnabled(false); - pushButton_joinAnyGame->show(); - joinAnyGameButtonRefresh(); + treeWidget_connectedPlayers->clear(); + pushButton_StartGame->hide(); + pushButton_Leave->hide(); + pushButton_Kick->hide(); + pushButton_Kick->setEnabled(false); + checkBox_fillUpWithComputerOpponents->hide(); + pushButton_CreateGame->show(); + pushButton_JoinGame->show(); + pushButton_JoinGame->setEnabled(false); + pushButton_joinAnyGame->show(); + joinAnyGameButtonRefresh(); - lineEdit_ChatInput->setFocus(); + lineEdit_ChatInput->setFocus(); } void gameLobbyDialogImpl::updateDialogBlinds(const GameData &gameData) { - if(gameData.raiseIntervalMode == RAISE_ON_HANDNUMBER) { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryHandsValue)+" "+tr("hands")); } - else { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryMinutesValue)+" "+tr("minutes")); } - if(gameData.raiseMode == DOUBLE_BLINDS) { - label_blindsRaiseMode->setText(tr("double blinds")); - label_blindsList->hide(); - label_gameDesc6->hide(); - } - else { - label_blindsRaiseMode->setText(tr("manual blinds order")); - label_blindsList->show(); - label_gameDesc6->show(); - - QString blindsListString; - std::list::const_iterator it1; - for(it1= gameData.manualBlindsList.begin(); it1 != gameData.manualBlindsList.end(); it1++) { - blindsListString.append(QString("%L1").arg(*it1)).append(", "); - } - blindsListString.remove(blindsListString.length()-2,2); - label_blindsList->setText(blindsListString); - } + if(gameData.raiseIntervalMode == RAISE_ON_HANDNUMBER) { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryHandsValue)+" "+tr("hands")); } + else { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryMinutesValue)+" "+tr("minutes")); } + if(gameData.raiseMode == DOUBLE_BLINDS) { + label_blindsRaiseMode->setText(tr("double blinds")); + label_blindsList->hide(); + label_gameDesc6->hide(); + } + else { + label_blindsRaiseMode->setText(tr("manual blinds order")); + label_blindsList->show(); + label_gameDesc6->show(); + + QString blindsListString; + std::list::const_iterator it1; + for(it1= gameData.manualBlindsList.begin(); it1 != gameData.manualBlindsList.end(); it1++) { + blindsListString.append(QString("%L1").arg(*it1)).append(", "); + } + blindsListString.remove(blindsListString.length()-2,2); + label_blindsList->setText(blindsListString); + } } void gameLobbyDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*) { - if (item) - pushButton_Kick->setEnabled(isGameAdministrator); + if (item) + pushButton_Kick->setEnabled(isGameAdministrator); } void gameLobbyDialogImpl::startGame() { - assert(mySession); - mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked()); - waitStartGameMsgBoxTimer->start(1000); + assert(mySession); + mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked()); + waitStartGameMsgBoxTimer->start(1000); } void gameLobbyDialogImpl::leaveGame() { - assert(mySession); - mySession->sendLeaveCurrentGame(); + assert(mySession); + mySession->sendLeaveCurrentGame(); } void gameLobbyDialogImpl::kickPlayer() { - QTreeWidgetItem *item = treeWidget_connectedPlayers->currentItem(); - if (item) - { - QString playerName = item->text(0); - if(playerName == QString::fromUtf8(myConfig->readConfigString("MyName").c_str())) { - { QMessageBox::warning(this, tr("Server Error"), - tr("You should not kick yourself from this game!"), - QMessageBox::Close); } - } - else { - assert(mySession); - mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt()); - } - } - pushButton_Kick->setEnabled(false); + QTreeWidgetItem *item = treeWidget_connectedPlayers->currentItem(); + if (item) + { + QString playerName = item->text(0); + if(playerName == QString::fromUtf8(myConfig->readConfigString("MyName").c_str())) { + { QMessageBox::warning(this, tr("Server Error"), + tr("You should not kick yourself from this game!"), + QMessageBox::Close); } + } + else { + assert(mySession); + mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt()); + } + } + pushButton_Kick->setEnabled(false); } void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) { -// qDebug() << event->key() << "\n"; + // qDebug() << event->key() << "\n"; - if (event->key() == Qt::Key_Enter && lineEdit_ChatInput->hasFocus()) { myChat->sendMessage(); } + if (event->key() == Qt::Key_Enter && lineEdit_ChatInput->hasFocus()) { myChat->sendMessage(); } - if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) { - if((keyUpCounter + 1) <= myChat->getChatLinesHistorySize()) { keyUpCounter++; } -// std::cout << "Up keyUpCounter: " << keyUpCounter << "\n"; - myChat->showChatHistoryIndex(keyUpCounter); - } - else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) { - if((keyUpCounter - 1) >= 0) { keyUpCounter--; } -// std::cout << "Down keyUpCounter: " << keyUpCounter << "\n"; - myChat->showChatHistoryIndex(keyUpCounter); - } - else { keyUpCounter = 0; } + if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) { + if((keyUpCounter + 1) <= myChat->getChatLinesHistorySize()) { keyUpCounter++; } + // std::cout << "Up keyUpCounter: " << keyUpCounter << "\n"; + myChat->showChatHistoryIndex(keyUpCounter); + } + else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) { + if((keyUpCounter - 1) >= 0) { keyUpCounter--; } + // std::cout << "Down keyUpCounter: " << keyUpCounter << "\n"; + myChat->showChatHistoryIndex(keyUpCounter); + } + else { keyUpCounter = 0; } -// if (event->key() == Qt::Key_Tab) event->ignore(); else { /*blah*/ } + // if (event->key() == Qt::Key_Tab) event->ignore(); else { /*blah*/ } + + // if (event->key() == Qt::Key_N) showInvitationDialog(); + // if (event->key() == Qt::Key_M) guestUserMode(); -// if (event->key() == Qt::Key_N) showInvitationDialog(); -// if (event->key() == Qt::Key_M) guestUserMode(); - } bool gameLobbyDialogImpl::eventFilter(QObject *obj, QEvent *event) { - QKeyEvent *keyEvent = static_cast(event); + QKeyEvent *keyEvent = static_cast(event); - if (obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab) - { - myChat->nickAutoCompletition(); - return true; - } else { - // pass the event on to the parent class - return QDialog::eventFilter(obj, event); - } + if (obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab) + { + myChat->nickAutoCompletition(); + return true; + } else { + // pass the event on to the parent class + return QDialog::eventFilter(obj, event); + } } bool gameLobbyDialogImpl::event ( QEvent * event ) { - return QDialog::event(event); + return QDialog::event(event); } void gameLobbyDialogImpl::hideShowGameDescription(bool show) { - if(show) { - label_gameType->show(); - label_gameDesc2->show(); - label_gameDesc3->show(); - label_gameDesc4->show(); - label_gameDesc5->show(); - label_gameDesc6->show(); - label_gameDesc7->show(); - line->show(); - } - else { - label_gameType->hide(); - label_gameDesc2->hide(); - label_gameDesc3->hide(); - label_gameDesc4->hide(); - label_gameDesc5->hide(); - label_gameDesc6->hide(); - label_gameDesc7->hide(); - line->hide(); - } + if(show) { + label_gameType->show(); + label_gameDesc2->show(); + label_gameDesc3->show(); + label_gameDesc4->show(); + label_gameDesc5->show(); + label_gameDesc6->show(); + label_gameDesc7->show(); + line->show(); + } + else { + label_gameType->hide(); + label_gameDesc2->hide(); + label_gameDesc3->hide(); + label_gameDesc4->hide(); + label_gameDesc5->hide(); + label_gameDesc6->hide(); + label_gameDesc7->hide(); + line->hide(); + } } void gameLobbyDialogImpl::showWaitStartGameMsgBox() { - waitStartGameMsgBox->show(); - waitStartGameMsgBox->raise(); - waitStartGameMsgBox->activateWindow(); + waitStartGameMsgBox->show(); + waitStartGameMsgBox->raise(); + waitStartGameMsgBox->activateWindow(); } void gameLobbyDialogImpl::joinAnyGameButtonRefresh() { - int openNonPrivateNonFullGamesCounter = 0; + int openNonPrivateNonFullGamesCounter = 0; - int it = 0; - while (myGameListModel->item(it)) { + int it = 0; + while (myGameListModel->item(it)) { - int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt(); - int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt(); - if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) { - openNonPrivateNonFullGamesCounter++; - } - ++it; - } + int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt(); + int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt(); + if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) { + openNonPrivateNonFullGamesCounter++; + } + ++it; + } - if(openNonPrivateNonFullGamesCounter) pushButton_joinAnyGame->setEnabled(TRUE); - else pushButton_joinAnyGame->setEnabled(FALSE); + if(openNonPrivateNonFullGamesCounter) pushButton_joinAnyGame->setEnabled(TRUE); + else pushButton_joinAnyGame->setEnabled(FALSE); } void gameLobbyDialogImpl::reject() { - myStartWindow->show(); - QDialog::reject(); + myStartWindow->show(); + QDialog::reject(); } void gameLobbyDialogImpl::closeEvent(QCloseEvent *event) { - event->accept(); + event->accept(); } void gameLobbyDialogImpl::writeDialogSettings(int saveMode) { - switch(saveMode) { - case 0: { -// myConfig->writeConfigInt("DlgGameLobbyGameListSortingSection", myGameListSortFilterProxyModel->sortColumn()); -// myConfig->writeConfigInt("DldgGameLobbyGameListSortingOrder", myGameListSortFilterProxyModel->sortOrder()); -// qt 4.4.* compatibility - QHeaderView *header = treeView_GameList->header(); - myConfig->writeConfigInt("DlgGameLobbyGameListSortingSection", header->sortIndicatorSection()); - myConfig->writeConfigInt("DlgGameLobbyGameListSortingOrder", header->sortIndicatorOrder()); - } - break; - case 1: { - myConfig->writeConfigInt("DlgGameLobbyGameListFilterIndex", comboBox_gameListFilter->currentIndex()); - } - break; - default:; - } - myConfig->writeBuffer(); + switch(saveMode) { + case 0: { + // myConfig->writeConfigInt("DlgGameLobbyGameListSortingSection", myGameListSortFilterProxyModel->sortColumn()); + // myConfig->writeConfigInt("DldgGameLobbyGameListSortingOrder", myGameListSortFilterProxyModel->sortOrder()); + // qt 4.4.* compatibility + QHeaderView *header = treeView_GameList->header(); + myConfig->writeConfigInt("DlgGameLobbyGameListSortingSection", header->sortIndicatorSection()); + myConfig->writeConfigInt("DlgGameLobbyGameListSortingOrder", header->sortIndicatorOrder()); + } + break; + case 1: { + myConfig->writeConfigInt("DlgGameLobbyGameListFilterIndex", comboBox_gameListFilter->currentIndex()); + } + break; + default:; + } + myConfig->writeBuffer(); } void gameLobbyDialogImpl::readDialogSettings() { - comboBox_gameListFilter->setCurrentIndex(myConfig->readConfigInt("DlgGameLobbyGameListFilterIndex")); - treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") ); + comboBox_gameListFilter->setCurrentIndex(myConfig->readConfigInt("DlgGameLobbyGameListFilterIndex")); + treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") ); } void gameLobbyDialogImpl::changeGameListFilter(int index) { - switch(index) { - case 0: { - myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); - } - break; - case 1: { - myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); - } - break; - case 2: { - myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); - } - break; - case 3: { - myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("nonpriv", Qt::CaseInsensitive, QRegExp::FixedString)); - } - break; - case 4: { - myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); - } + switch(index) { + case 0: { + myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); + } + break; + case 1: { + myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); + } + break; + case 2: { + myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); + } + break; + case 3: { + myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("nonpriv", Qt::CaseInsensitive, QRegExp::FixedString)); + } + break; + case 4: { + myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); + } - break; -// case 5: { -// myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); -// myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); -// myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("nonpriv", Qt::CaseInsensitive, QRegExp::FixedString)); -// } -// break; -// case 6: { -// myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); -// myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); -// myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); -// } -// break; -// case 7: { -// myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); -// myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); -// myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); -// } -// break; -// case 8: { -// myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); -// myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); -// myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("nonpriv", Qt::CaseInsensitive, QRegExp::FixedString)); -// } -// break; -// case 9: { -// myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); -// myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); -// myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); -// } -// break; -// case 10: { -// myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); -// myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); -// myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("nonpriv", Qt::CaseInsensitive, QRegExp::FixedString)); -// } -// break; -// case 11: { -// myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); -// myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); -// myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); -// } -// break; - default:; - } - myGameListSortFilterProxyModel->setFilterRegExp(QString()); - myGameListSortFilterProxyModel->setFilterKeyColumn(0); - - writeDialogSettings(1); - - if(index) treeView_GameList->setStyleSheet("QTreeView { border-radius: 4px; border: 2px solid blue; background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); - else treeView_GameList->setStyleSheet("QTreeView { background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); + break; + // case 5: { + // myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); + // myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); + // myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("nonpriv", Qt::CaseInsensitive, QRegExp::FixedString)); + // } + // break; + // case 6: { + // myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); + // myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); + // myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); + // } + // break; + // case 7: { + // myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); + // myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); + // myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + // } + // break; + // case 8: { + // myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); + // myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); + // myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("nonpriv", Qt::CaseInsensitive, QRegExp::FixedString)); + // } + // break; + // case 9: { + // myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); + // myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); + // myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); + // } + // break; + // case 10: { + // myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); + // myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); + // myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("nonpriv", Qt::CaseInsensitive, QRegExp::FixedString)); + // } + // break; + // case 11: { + // myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); + // myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); + // myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); + // } + // break; + default:; + } + myGameListSortFilterProxyModel->setFilterRegExp(QString()); + myGameListSortFilterProxyModel->setFilterKeyColumn(0); + + writeDialogSettings(1); + + if(index) treeView_GameList->setStyleSheet("QTreeView { border-radius: 4px; border: 2px solid blue; background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); + else treeView_GameList->setStyleSheet("QTreeView { background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); } void gameLobbyDialogImpl::changeGameListSorting() { - - writeDialogSettings(0); + + writeDialogSettings(0); } // @@ -1317,7 +1317,7 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p) assert(mySession); if(inGame && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY && treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt() != mySession->getClientUniquePlayerId()) { - nickListContextMenu->popup(treeWidget_NickList->mapToGlobal(p)); + nickListContextMenu->popup(treeWidget_NickList->mapToGlobal(p)); } } } @@ -1332,12 +1332,12 @@ void gameLobbyDialogImpl::invitePlayerToCurrentGame() void gameLobbyDialogImpl::showInfoMsgBox() { switch(infoMsgToShowId) { - case 2: { + case 2: { myMessageDialogImpl dialog(myConfig, this); dialog.exec(2, tr("You've entered a game with invite-only type.\nYou can invite other players with right-click on their nick in the left available players list."), tr("PokerTH - Info Message"), QPixmap(":/gfx/ktip.png"), QDialogButtonBox::Ok); } break; - default:; + default:; break; } } @@ -1348,8 +1348,8 @@ void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerI inviteDialogIsCurrentlyShown = true; - myMessageDialogImpl dialog(myConfig, this); - if(dialog.exec(3, tr("You've been invited to the game %1 by %2.
Do you want to join this game?").arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str())), tr("PokerTH - Info Message"), QPixmap(":/gfx/list_add_user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false)) { + myMessageDialogImpl dialog(myConfig, this); + if(dialog.exec(3, tr("You've been invited to the game %1 by %2.
Do you want to join this game?").arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str())), tr("PokerTH - Info Message"), QPixmap(":/gfx/list_add_user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false)) { mySession->acceptGameInvitation(currentInvitationGameId); inviteDialogIsCurrentlyShown = false; @@ -1378,4 +1378,5 @@ void gameLobbyDialogImpl::chatInfoPlayerRejectedInviation(unsigned gameId, unsig if(reason == DENY_GAME_INVITATION_BUSY) string = tr("Player %1 can not join %2 because he is busy."); textBrowser_ChatDisplay->append(string.arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdWho).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str()))); + } diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index 346fe95d..9fc985f0 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -35,120 +35,120 @@ class MyGameListSortFilterProxyModel; */ class gameLobbyDialogImpl: public QDialog, public Ui::gameLobbyDialog { -Q_OBJECT + Q_OBJECT public: - gameLobbyDialogImpl(startWindowImpl *parent = 0, ConfigFile* = 0); + gameLobbyDialogImpl(startWindowImpl *parent = 0, ConfigFile* = 0); - ~gameLobbyDialogImpl(); + ~gameLobbyDialogImpl(); - void exec(); + void exec(); - ChatTools *getMyChat() { return myChat; } + ChatTools *getMyChat() { return myChat; } - void setSession(boost::shared_ptr session); - boost::shared_ptr getSession() { assert(mySession.get()); return mySession; } + void setSession(boost::shared_ptr session); + boost::shared_ptr getSession() { assert(mySession.get()); return mySession; } - void setMyW ( gameTableImpl* theValue ) { myW = theValue; } + void setMyW ( gameTableImpl* theValue ) { myW = theValue; } public slots: - void createGame(); - void joinGame(); - void joinAnyGame(); - void gameSelected(const QModelIndex &, const QModelIndex &); - void updateGameItem(QList , unsigned gameId); - void addGame(unsigned gameId); - void updateGameMode(unsigned gameId, int newMode); - void updateGameAdmin(unsigned gameId, unsigned adminPlayerId); - void removeGame(unsigned gameId); - void gameAddPlayer(unsigned gameId, unsigned playerId); - void gameRemovePlayer(unsigned gameId, unsigned playerId); - void playerJoinedLobby(unsigned playerId, QString playerName); - void playerLeftLobby(unsigned playerId); - void updateStats(ServerStats stats); - void refreshGameStats(); - void refreshPlayerStats(); - void setCurrentGameName ( const QString& theValue ) { currentGameName = theValue; } - QString getCurrentGameName() const { return currentGameName; } - gameTableImpl* getMyW() const { return myW; } - void checkPlayerQuantity(); - void blinkingStartButtonAnimation(); - void joinedNetworkGame(unsigned, QString, bool); - void addConnectedPlayer(unsigned, QString, bool); - void updatePlayer(unsigned, QString); - void removePlayer(unsigned, QString); - void newGameAdmin(unsigned, QString); - void refreshConnectedPlayerAvatars(); - void playerSelected(QTreeWidgetItem*, QTreeWidgetItem*); - void refresh(int actionID); - void removedFromGame(int reason); - void startGame(); - void leaveGame(); - void kickPlayer(); - void joinedGameDialogUpdate(); - void leftGameDialogUpdate(); - void updateDialogBlinds(const GameData &gameData); - void clearDialog(); - void keyPressEvent(QKeyEvent * keyEvent); - bool event(QEvent * event); - void hideShowGameDescription(bool show); - void showWaitStartGameMsgBox(); - void joinAnyGameButtonRefresh(); - void reject(); - void closeEvent(QCloseEvent *event); - void writeDialogSettings(int); - void readDialogSettings(); - void changeGameListFilter(int); - void changeGameListSorting(); - void registeredUserMode(); - void guestUserMode(); - void showNickListContextMenu(QPoint); - void invitePlayerToCurrentGame(); - void showInfoMsgBox(); - void showInvitationDialog(unsigned gameId, unsigned playerIdFrom); - void chatInfoPlayerInviation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); - void chatInfoPlayerRejectedInviation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); + void createGame(); + void joinGame(); + void joinAnyGame(); + void gameSelected(const QModelIndex &, const QModelIndex &); + void updateGameItem(QList , unsigned gameId); + void addGame(unsigned gameId); + void updateGameMode(unsigned gameId, int newMode); + void updateGameAdmin(unsigned gameId, unsigned adminPlayerId); + void removeGame(unsigned gameId); + void gameAddPlayer(unsigned gameId, unsigned playerId); + void gameRemovePlayer(unsigned gameId, unsigned playerId); + void playerJoinedLobby(unsigned playerId, QString playerName); + void playerLeftLobby(unsigned playerId); + void updateStats(ServerStats stats); + void refreshGameStats(); + void refreshPlayerStats(); + void setCurrentGameName ( const QString& theValue ) { currentGameName = theValue; } + QString getCurrentGameName() const { return currentGameName; } + gameTableImpl* getMyW() const { return myW; } + void checkPlayerQuantity(); + void blinkingStartButtonAnimation(); + void joinedNetworkGame(unsigned, QString, bool); + void addConnectedPlayer(unsigned, QString, bool); + void updatePlayer(unsigned, QString); + void removePlayer(unsigned, QString); + void newGameAdmin(unsigned, QString); + void refreshConnectedPlayerAvatars(); + void playerSelected(QTreeWidgetItem*, QTreeWidgetItem*); + void refresh(int actionID); + void removedFromGame(int reason); + void startGame(); + void leaveGame(); + void kickPlayer(); + void joinedGameDialogUpdate(); + void leftGameDialogUpdate(); + void updateDialogBlinds(const GameData &gameData); + void clearDialog(); + void keyPressEvent(QKeyEvent * keyEvent); + bool event(QEvent * event); + void hideShowGameDescription(bool show); + void showWaitStartGameMsgBox(); + void joinAnyGameButtonRefresh(); + void reject(); + void closeEvent(QCloseEvent *event); + void writeDialogSettings(int); + void readDialogSettings(); + void changeGameListFilter(int); + void changeGameListSorting(); + void registeredUserMode(); + void guestUserMode(); + void showNickListContextMenu(QPoint); + void invitePlayerToCurrentGame(); + void showInfoMsgBox(); + void showInvitationDialog(unsigned gameId, unsigned playerIdFrom); + void chatInfoPlayerInviation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void chatInfoPlayerRejectedInviation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); private: - - gameTableImpl* myW; - startWindowImpl* myStartWindow; - ConfigFile *myConfig; - boost::shared_ptr mySession; - createInternetGameDialogImpl *myCreateInternetGameDialog; - QString currentGameName; - unsigned myPlayerId; - unsigned myCurrentGameId; - bool isGameAdministrator; - bool inGame; - bool guestMode; - QString myAppDataPath; - QMessageBox *waitStartGameMsgBox; - QTimer *waitStartGameMsgBoxTimer; - QTimer *blinkingButtonAnimationTimer; - QTimer *showInfoMsgBoxTimer; - bool blinkingButtonAnimationState; - QColor defaultStartButtonColor; - QColor defaultStartButtonTextColor; - QColor disabledStartButtonColor; - QColor disabledStartButtonTextColor; - ChatTools *myChat; - int keyUpCounter; - QStandardItemModel *myGameListModel; - QItemSelectionModel *myGameListSelectionModel; - MyGameListSortFilterProxyModel *myGameListSortFilterProxyModel; - QMenu *nickListContextMenu; - QAction *nickListInviteAction; - QAction *ignorePlayerAction; - int infoMsgToShowId; - int currentInvitationGameId; - bool inviteDialogIsCurrentlyShown; - + gameTableImpl* myW; + startWindowImpl* myStartWindow; + ConfigFile *myConfig; + boost::shared_ptr mySession; + createInternetGameDialogImpl *myCreateInternetGameDialog; + QString currentGameName; + unsigned myPlayerId; + unsigned myCurrentGameId; + bool isGameAdministrator; + bool inGame; + bool guestMode; + + QString myAppDataPath; + QMessageBox *waitStartGameMsgBox; + QTimer *waitStartGameMsgBoxTimer; + QTimer *blinkingButtonAnimationTimer; + QTimer *showInfoMsgBoxTimer; + bool blinkingButtonAnimationState; + QColor defaultStartButtonColor; + QColor defaultStartButtonTextColor; + QColor disabledStartButtonColor; + QColor disabledStartButtonTextColor; + ChatTools *myChat; + int keyUpCounter; + QStandardItemModel *myGameListModel; + QItemSelectionModel *myGameListSelectionModel; + MyGameListSortFilterProxyModel *myGameListSortFilterProxyModel; + QMenu *nickListContextMenu; + QAction *nickListInviteAction; + QAction *ignorePlayerAction; + int infoMsgToShowId; + int currentInvitationGameId; + bool inviteDialogIsCurrentlyShown; + + +protected: + bool eventFilter(QObject *obj, QEvent *event); - protected: - bool eventFilter(QObject *obj, QEvent *event); - }; #endif diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index a1ce15e8..af5f1cf5 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -34,10 +34,10 @@ GuiWrapper::GuiWrapper(ConfigFile *c, startWindowImpl *s) : myLog(NULL), myW(NUL { - myW = new gameTableImpl(myConfig); - myLog = new Log(myW, myConfig); + myW = new gameTableImpl(myConfig); + myLog = new Log(myW, myConfig); - myW->setStartWindow(myStartWindow); + myW->setStartWindow(myStartWindow); } @@ -66,8 +66,8 @@ void GuiWrapper::setPlayerAvatar(int myUniqueID, const std::string &myAvatar) co void GuiWrapper::waitForGuiUpdateDone() const { - myW->signalGuiUpdateDone(); - myW->waitForGuiUpdateDone(); + myW->signalGuiUpdateDone(); + myW->waitForGuiUpdateDone(); } void GuiWrapper::dealBeRoCards(int myBeRoID) { myW->signalDealBeRoCards(myBeRoID); } @@ -138,21 +138,21 @@ void GuiWrapper::SignalNetClientSelfJoined(unsigned playerId, const string &play void GuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, bool isGameAdmin) { myStartWindow->signalNetClientPlayerJoined(playerId, QString::fromUtf8(playerName.c_str()), isGameAdmin); } void GuiWrapper::SignalNetClientPlayerChanged(unsigned playerId, const string &newPlayerName) { - myStartWindow->signalNetClientPlayerChanged(playerId, QString::fromUtf8(newPlayerName.c_str())); + myStartWindow->signalNetClientPlayerChanged(playerId, QString::fromUtf8(newPlayerName.c_str())); } void GuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &playerName, int removeReason) { - QString tmpName(QString::fromUtf8(playerName.c_str())); - myStartWindow->signalNetClientPlayerLeft(playerId, tmpName); - myW->signalNetClientPlayerLeft(playerId); - if (!playerName.empty() && playerName[0] != '#') - myLog->signalLogPlayerLeftMsg(tmpName, removeReason == NTF_NET_REMOVED_KICKED); + QString tmpName(QString::fromUtf8(playerName.c_str())); + myStartWindow->signalNetClientPlayerLeft(playerId, tmpName); + myW->signalNetClientPlayerLeft(playerId); + if (!playerName.empty() && playerName[0] != '#') + myLog->signalLogPlayerLeftMsg(tmpName, removeReason == NTF_NET_REMOVED_KICKED); } void GuiWrapper::SignalNetClientNewGameAdmin(unsigned playerId, const string &playerName) { - myStartWindow->signalNetClientNewGameAdmin(playerId, QString::fromUtf8(playerName.c_str())); - if (!playerName.empty() && playerName[0] != '#') - myLog->signalLogNewGameAdminMsg(QString::fromUtf8(playerName.c_str())); + myStartWindow->signalNetClientNewGameAdmin(playerId, QString::fromUtf8(playerName.c_str())); + if (!playerName.empty() && playerName[0] != '#') + myLog->signalLogNewGameAdminMsg(QString::fromUtf8(playerName.c_str())); } @@ -186,6 +186,11 @@ void GuiWrapper::SignalLobbyPlayerJoined(unsigned playerId, const string &nickNa void GuiWrapper::SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) { myStartWindow->signalLobbyPlayerKicked(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(byWhom.c_str()), QString::fromUtf8(reason.c_str())); } void GuiWrapper::SignalLobbyPlayerLeft(unsigned playerId) { myStartWindow->signalLobbyPlayerLeft(playerId); } -void GuiWrapper::SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom) { myStartWindow->signalSelfGameInvitation(gameId, playerIdFrom); } -void GuiWrapper::SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom) { myStartWindow->signalPlayerGameInvitation(gameId, playerIdWho, playerIdFrom); } -void GuiWrapper::SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason) { myStartWindow->signalRejectedGameInvitation(gameId, playerIdWho, reason); } +void GuiWrapper::SignalSelfGameInvitation(unsigned gameId, unsigned +playerIdFrom) { myStartWindow->signalSelfGameInvitation(gameId, playerIdFrom); +} void GuiWrapper::SignalPlayerGameInvitation(unsigned gameId, unsigned +playerIdWho, unsigned playerIdFrom) { +myStartWindow->signalPlayerGameInvitation(gameId, playerIdWho, playerIdFrom); } +void GuiWrapper::SignalRejectedGameInvitation(unsigned gameId, unsigned +playerIdWho, DenyGameInvitationReason reason) { +myStartWindow->signalRejectedGameInvitation(gameId, playerIdWho, reason); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index a1622772..ec0e0549 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -34,139 +34,139 @@ class ConfigFile; class GuiWrapper : public GuiInterface { public: - GuiWrapper(ConfigFile*, startWindowImpl*); + GuiWrapper(ConfigFile*, startWindowImpl*); - ~GuiWrapper(); + ~GuiWrapper(); - void initGui(int speed); + void initGui(int speed); - boost::shared_ptr getSession(); - void setSession(boost::shared_ptr session); + boost::shared_ptr getSession(); + void setSession(boost::shared_ptr session); - gameTableImpl* getMyW() const { return myW; } - - void refreshSet() const; - void refreshCash() const; - void refreshAction(int =-1, int =-1) const; - void refreshChangePlayer() const; - void refreshPot() const; - void refreshGroupbox(int =-1, int =-1) const; - void refreshAll() const; - void refreshPlayerName() const; - void refreshButton() const; - void refreshGameLabels(GameState state) const; + gameTableImpl* getMyW() const { return myW; } - void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const; + void refreshSet() const; + void refreshCash() const; + void refreshAction(int =-1, int =-1) const; + void refreshChangePlayer() const; + void refreshPot() const; + void refreshGroupbox(int =-1, int =-1) const; + void refreshAll() const; + void refreshPlayerName() const; + void refreshButton() const; + void refreshGameLabels(GameState state) const; - void waitForGuiUpdateDone() const; + void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const; - void dealBeRoCards(int myBeRoID); - void dealHoleCards(); - void dealFlopCards(); - void dealTurnCard(); - void dealRiverCard(); + void waitForGuiUpdateDone() const; - void nextPlayerAnimation(); + void dealBeRoCards(int myBeRoID); + void dealHoleCards(); + void dealFlopCards(); + void dealTurnCard(); + void dealRiverCard(); - void beRoAnimation2(int); - - void preflopAnimation1(); - void preflopAnimation2(); - - void flopAnimation1(); - void flopAnimation2(); + void nextPlayerAnimation(); - void turnAnimation1(); - void turnAnimation2(); + void beRoAnimation2(int); - void riverAnimation1(); - void riverAnimation2(); + void preflopAnimation1(); + void preflopAnimation2(); - void postRiverAnimation1(); - void postRiverRunAnimation1(); + void flopAnimation1(); + void flopAnimation2(); - void flipHolecardsAllIn(); + void turnAnimation1(); + void turnAnimation2(); - void nextRoundCleanGui(); + void riverAnimation1(); + void riverAnimation2(); - void meInAction(); - void disableMyButtons(); - void updateMyButtonsState(); - void startTimeoutAnimation(int playerNum, int timeoutSec); - void stopTimeoutAnimation(int playerNum); + void postRiverAnimation1(); + void postRiverRunAnimation1(); - void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); - void changeVoteOnKickButtonsState(bool showHide); - void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); - void endVoteOnKick(); + void flipHolecardsAllIn(); - void logPlayerActionMsg(std::string playerName, int action, int setValue) ; - void logNewGameHandMsg(int gameID, int handID) ; - void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName); - void logPlayerWinsMsg(std::string playerName, int pot, bool main); - void logPlayerSitsOut(std::string playerName); - void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1); - void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows"); - void logPlayerWinGame(std::string playerName, int gameID); - void flushLogAtGame(int gameID); - void flushLogAtHand(); + void nextRoundCleanGui(); - void SignalNetClientConnect(int actionID); - void SignalNetClientServerListAdd(unsigned serverId); - void SignalNetClientServerListShow(); - void SignalNetClientServerListClear(); - void SignalNetClientLoginShow(); - void SignalNetClientGameInfo(int actionID); - void SignalNetClientError(int errorID, int osErrorID); - void SignalNetClientNotification(int notificationId); - void SignalNetClientStatsUpdate(const ServerStats &stats); - void SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec); - void SignalNetClientRemovedFromGame(int notificationId); - void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); - void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); - void SignalNetClientPlayerChanged(unsigned playerId, const std::string &newPlayerName); - void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason); - void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName); - void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg); - void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg); - void SignalNetClientMsgBox(const std::string &msg); - void SignalNetClientWaitDialog(); + void meInAction(); + void disableMyButtons(); + void updateMyButtonsState(); + void startTimeoutAnimation(int playerNum, int timeoutSec); + void stopTimeoutAnimation(int playerNum); - void SignalNetClientGameListNew(unsigned gameId); - void SignalNetClientGameListRemove(unsigned gameId); - void SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode); - void SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); - void SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); - void SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); + void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); + void changeVoteOnKickButtonsState(bool showHide); + void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); + void endVoteOnKick(); - void SignalNetClientGameStart(boost::shared_ptr game); + void logPlayerActionMsg(std::string playerName, int action, int setValue) ; + void logNewGameHandMsg(int gameID, int handID) ; + void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName); + void logPlayerWinsMsg(std::string playerName, int pot, bool main); + void logPlayerSitsOut(std::string playerName); + void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1); + void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows"); + void logPlayerWinGame(std::string playerName, int gameID); + void flushLogAtGame(int gameID); + void flushLogAtHand(); - void SignalNetServerSuccess(int actionID); - void SignalNetServerError(int errorID, int osErrorID); + void SignalNetClientConnect(int actionID); + void SignalNetClientServerListAdd(unsigned serverId); + void SignalNetClientServerListShow(); + void SignalNetClientServerListClear(); + void SignalNetClientLoginShow(); + void SignalNetClientGameInfo(int actionID); + void SignalNetClientError(int errorID, int osErrorID); + void SignalNetClientNotification(int notificationId); + void SignalNetClientStatsUpdate(const ServerStats &stats); + void SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec); + void SignalNetClientRemovedFromGame(int notificationId); + void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); + void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); + void SignalNetClientPlayerChanged(unsigned playerId, const std::string &newPlayerName); + void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason); + void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName); + void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientMsgBox(const std::string &msg); + void SignalNetClientWaitDialog(); - void SignalIrcConnect(const std::string &server); - void SignalIrcSelfJoined(const std::string &nickName, const std::string &channel); - void SignalIrcPlayerJoined(const std::string &nickName); - void SignalIrcPlayerChanged(const std::string &oldNick, const std::string &newNick); - void SignalIrcPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); - void SignalIrcPlayerLeft(const std::string &nickName); - void SignalIrcChatMsg(const std::string &nickName, const std::string &msg); - void SignalIrcError(int errorCode); - void SignalIrcServerError(int errorCode); - void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName); - void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); - void SignalLobbyPlayerLeft(unsigned playerId); + void SignalNetClientGameListNew(unsigned gameId); + void SignalNetClientGameListRemove(unsigned gameId); + void SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode); + void SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); + void SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); + void SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); - void SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); - void SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); - void SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); + void SignalNetClientGameStart(boost::shared_ptr game); + + void SignalNetServerSuccess(int actionID); + void SignalNetServerError(int errorID, int osErrorID); + + void SignalIrcConnect(const std::string &server); + void SignalIrcSelfJoined(const std::string &nickName, const std::string &channel); + void SignalIrcPlayerJoined(const std::string &nickName); + void SignalIrcPlayerChanged(const std::string &oldNick, const std::string &newNick); + void SignalIrcPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); + void SignalIrcPlayerLeft(const std::string &nickName); + void SignalIrcChatMsg(const std::string &nickName, const std::string &msg); + void SignalIrcError(int errorCode); + void SignalIrcServerError(int errorCode); + void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName); + void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); + void SignalLobbyPlayerLeft(unsigned playerId); + + void SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); + void SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); private: - Log *myLog; - gameTableImpl *myW; - ConfigFile *myConfig; - startWindowImpl *myStartWindow; + Log *myLog; + gameTableImpl *myW; + ConfigFile *myConfig; + startWindowImpl *myStartWindow; }; diff --git a/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp b/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp index 310604e2..65ff5c57 100644 --- a/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp +++ b/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp @@ -33,10 +33,10 @@ myMessageDialogImpl::myMessageDialogImpl(ConfigFile *c, QWidget *parent) : QDialog(parent), myConfig(c), currentMsgId(0) { #ifdef __APPLE__ - setWindowModality(Qt::ApplicationModal); - setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); + setWindowModality(Qt::ApplicationModal); + setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); #endif - setupUi(this); + setupUi(this); } int myMessageDialogImpl::exec(int messageId, QString msg, QString title, QPixmap pix, QDialogButtonBox::StandardButtons buttons, bool showCheckBox) diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp index c57b4f21..a5913255 100644 --- a/src/gui/qt/startwindow/startwindowimpl.cpp +++ b/src/gui/qt/startwindow/startwindowimpl.cpp @@ -55,846 +55,846 @@ startWindowImpl::startWindowImpl(ConfigFile *c) : myConfig(c) { - myGuiInterface.reset(new GuiWrapper(myConfig, this)); - { - mySession.reset(new Session(myGuiInterface.get(), myConfig)); - mySession->init(); // TODO handle error -// myGuiInterface->setSession(session); - } + myGuiInterface.reset(new GuiWrapper(myConfig, this)); + { + mySession.reset(new Session(myGuiInterface.get(), myConfig)); + mySession->init(); // TODO handle error + // myGuiInterface->setSession(session); + } -// #ifdef __APPLE__ -// setWindowModality(Qt::ApplicationModal); -// setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -// #endif - setupUi(this); - this->setWindowTitle(QString(tr("PokerTH %1").arg(POKERTH_BETA_RELEASE_STRING))); + // #ifdef __APPLE__ + // setWindowModality(Qt::ApplicationModal); + // setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); + // #endif + setupUi(this); + this->setWindowTitle(QString(tr("PokerTH %1").arg(POKERTH_BETA_RELEASE_STRING))); - //Widgets Grafiken per Stylesheets setzen - QString myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - this->setWindowIcon(QIcon(myAppDataPath+"gfx/gui/misc/windowicon.png")); + //Widgets Grafiken per Stylesheets setzen + QString myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); + this->setWindowIcon(QIcon(myAppDataPath+"gfx/gui/misc/windowicon.png")); - this->setStatusBar(0); + this->setStatusBar(0); - centralwidget->setStyleSheet(".QWidget { background-image: url(\""+myAppDataPath+"gfx/gui/misc/startwindowbg.png\"); background-position: bottom center; background-origin: content; background-repeat: no-repeat;}"); - -// Dialogs - myNewGameDialog = new newGameDialogImpl(this, myConfig); - mySelectAvatarDialog = new selectAvatarDialogImpl(this, myConfig); - mySettingsDialog = new settingsDialogImpl(this, myConfig, mySelectAvatarDialog); - myChangeHumanPlayerNameDialog = new changeHumanPlayerNameDialogImpl(this, myConfig); - myJoinNetworkGameDialog = new joinNetworkGameDialogImpl(this, myConfig); - myConnectToServerDialog = new connectToServerDialogImpl(this); - myStartNetworkGameDialog = new startNetworkGameDialogImpl(this, myConfig); - myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, myConfig); - myAboutPokerthDialog = new aboutPokerthImpl(this, myConfig); - myGameLobbyDialog = new gameLobbyDialogImpl(this, myConfig); + centralwidget->setStyleSheet(".QWidget { background-image: url(\""+myAppDataPath+"gfx/gui/misc/startwindowbg.png\"); background-position: bottom center; background-origin: content; background-repeat: no-repeat;}"); - myStartNetworkGameDialog->setMyW(myGuiInterface->getMyW()); - myGameLobbyDialog->setMyW(myGuiInterface->getMyW()); - - myTimeoutDialog = new timeoutMsgBoxImpl(this); - myServerListDialog = new serverListDialogImpl(this, this, myConfig); - myInternetGameLoginDialog = new internetGameLoginDialogImpl(this, myConfig); + // Dialogs + myNewGameDialog = new newGameDialogImpl(this, myConfig); + mySelectAvatarDialog = new selectAvatarDialogImpl(this, myConfig); + mySettingsDialog = new settingsDialogImpl(this, myConfig, mySelectAvatarDialog); + myChangeHumanPlayerNameDialog = new changeHumanPlayerNameDialogImpl(this, myConfig); + myJoinNetworkGameDialog = new joinNetworkGameDialogImpl(this, myConfig); + myConnectToServerDialog = new connectToServerDialogImpl(this); + myStartNetworkGameDialog = new startNetworkGameDialogImpl(this, myConfig); + myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, myConfig); + myAboutPokerthDialog = new aboutPokerthImpl(this, myConfig); + myGameLobbyDialog = new gameLobbyDialogImpl(this, myConfig); - connect( actionStart_Local_Game, SIGNAL( triggered() ), this, SLOT( callNewGameDialog() ) ); - connect( pushButtonStart_Local_Game, SIGNAL( clicked() ), this, SLOT( callNewGameDialog() ) ); - connect( actionInternet_Game, SIGNAL( triggered() ), this, SLOT( joinGameLobby() ) ); - connect( pushButtonInternet_Game, SIGNAL( clicked() ), this, SLOT( joinGameLobby() ) ); - connect( actionCreate_Network_Game, SIGNAL( triggered() ), this, SLOT( callCreateNetworkGameDialog() ) ); - connect( pushButton_Create_Network_Game, SIGNAL( clicked() ), this, SLOT( callCreateNetworkGameDialog() ) ); - connect( actionJoin_Network_Game, SIGNAL( triggered() ), this, SLOT( callJoinNetworkGameDialog() ) ); - connect( pushButton_Join_Network_Game, SIGNAL( clicked() ), this, SLOT( callJoinNetworkGameDialog() ) ); - - connect( actionAbout_PokerTH, SIGNAL( triggered() ), this, SLOT( callAboutPokerthDialog() ) ); - connect( actionConfigure_PokerTH, SIGNAL( triggered() ), this, SLOT( callSettingsDialog() ) ); + myStartNetworkGameDialog->setMyW(myGuiInterface->getMyW()); + myGameLobbyDialog->setMyW(myGuiInterface->getMyW()); + + myTimeoutDialog = new timeoutMsgBoxImpl(this); + myServerListDialog = new serverListDialogImpl(this, this, myConfig); + myInternetGameLoginDialog = new internetGameLoginDialogImpl(this, myConfig); + + connect( actionStart_Local_Game, SIGNAL( triggered() ), this, SLOT( callNewGameDialog() ) ); + connect( pushButtonStart_Local_Game, SIGNAL( clicked() ), this, SLOT( callNewGameDialog() ) ); + connect( actionInternet_Game, SIGNAL( triggered() ), this, SLOT( joinGameLobby() ) ); + connect( pushButtonInternet_Game, SIGNAL( clicked() ), this, SLOT( joinGameLobby() ) ); + connect( actionCreate_Network_Game, SIGNAL( triggered() ), this, SLOT( callCreateNetworkGameDialog() ) ); + connect( pushButton_Create_Network_Game, SIGNAL( clicked() ), this, SLOT( callCreateNetworkGameDialog() ) ); + connect( actionJoin_Network_Game, SIGNAL( triggered() ), this, SLOT( callJoinNetworkGameDialog() ) ); + connect( pushButton_Join_Network_Game, SIGNAL( clicked() ), this, SLOT( callJoinNetworkGameDialog() ) ); + + connect( actionAbout_PokerTH, SIGNAL( triggered() ), this, SLOT( callAboutPokerthDialog() ) ); + connect( actionConfigure_PokerTH, SIGNAL( triggered() ), this, SLOT( callSettingsDialog() ) ); - connect(this, SIGNAL(signalShowClientDialog()), this, SLOT(showClientDialog())); + connect(this, SIGNAL(signalShowClientDialog()), this, SLOT(showClientDialog())); - connect(this, SIGNAL(signalNetClientConnect(int)), myConnectToServerDialog, SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientGameInfo(int)), myStartNetworkGameDialog, SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientGameInfo(int)), myGameLobbyDialog, SLOT(refresh(int))); + connect(this, SIGNAL(signalNetClientConnect(int)), myConnectToServerDialog, SLOT(refresh(int))); + connect(this, SIGNAL(signalNetClientGameInfo(int)), myStartNetworkGameDialog, SLOT(refresh(int))); + connect(this, SIGNAL(signalNetClientGameInfo(int)), myGameLobbyDialog, SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientServerListShow()), myServerListDialog, SLOT(exec())); - connect(this, SIGNAL(signalNetClientServerListClear()), myServerListDialog, SLOT(clearList())); - connect(this, SIGNAL(signalNetClientServerListAdd(unsigned)), myServerListDialog, SLOT(addServerItem(unsigned))); + connect(this, SIGNAL(signalNetClientServerListShow()), myServerListDialog, SLOT(exec())); + connect(this, SIGNAL(signalNetClientServerListClear()), myServerListDialog, SLOT(clearList())); + connect(this, SIGNAL(signalNetClientServerListAdd(unsigned)), myServerListDialog, SLOT(addServerItem(unsigned))); - connect(this, SIGNAL(signalNetClientLoginShow()), this, SLOT(callInternetGameLoginDialog())); - - connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, bool)), myStartNetworkGameDialog, SLOT(joinedNetworkGame(unsigned, QString, bool))); - connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, bool)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(unsigned, QString, bool))); - connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myStartNetworkGameDialog, SLOT(updatePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myStartNetworkGameDialog, SLOT(removePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myStartNetworkGameDialog, SLOT(newGameAdmin(unsigned, QString))); - connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myStartNetworkGameDialog, SLOT(gameCreated(unsigned))); + connect(this, SIGNAL(signalNetClientLoginShow()), this, SLOT(callInternetGameLoginDialog())); - connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, bool)), myGameLobbyDialog, SLOT(joinedNetworkGame(unsigned, QString, bool))); - connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, bool)), myGameLobbyDialog, SLOT(addConnectedPlayer(unsigned, QString, bool))); - connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myGameLobbyDialog, SLOT(updatePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myGameLobbyDialog, SLOT(removePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myGameLobbyDialog, SLOT(newGameAdmin(unsigned, QString))); + connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, bool)), myStartNetworkGameDialog, SLOT(joinedNetworkGame(unsigned, QString, bool))); + connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, bool)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(unsigned, QString, bool))); + connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myStartNetworkGameDialog, SLOT(updatePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myStartNetworkGameDialog, SLOT(removePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myStartNetworkGameDialog, SLOT(newGameAdmin(unsigned, QString))); + connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myStartNetworkGameDialog, SLOT(gameCreated(unsigned))); - connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myGameLobbyDialog, SLOT(addGame(unsigned))); - connect(this, SIGNAL(signalNetClientGameListRemove(unsigned)), myGameLobbyDialog, SLOT(removeGame(unsigned))); - connect(this, SIGNAL(signalNetClientGameListUpdateMode(unsigned, int)), myGameLobbyDialog, SLOT(updateGameMode(unsigned, int))); - connect(this, SIGNAL(signalNetClientGameListUpdateAdmin(unsigned, unsigned)), myGameLobbyDialog, SLOT(updateGameAdmin(unsigned, unsigned))); - connect(this, SIGNAL(signalNetClientGameListPlayerJoined(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameAddPlayer(unsigned, unsigned))); - connect(this, SIGNAL(signalNetClientGameListPlayerLeft(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameRemovePlayer(unsigned, unsigned))); - connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), myGameLobbyDialog, SLOT(removedFromGame(int))); - connect(this, SIGNAL(signalNetClientStatsUpdate(ServerStats)), myGameLobbyDialog, SLOT(updateStats(ServerStats))); + connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, bool)), myGameLobbyDialog, SLOT(joinedNetworkGame(unsigned, QString, bool))); + connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, bool)), myGameLobbyDialog, SLOT(addConnectedPlayer(unsigned, QString, bool))); + connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myGameLobbyDialog, SLOT(updatePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myGameLobbyDialog, SLOT(removePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myGameLobbyDialog, SLOT(newGameAdmin(unsigned, QString))); - connect(this, SIGNAL(signalNetClientGameChatMsg(QString, QString)), myStartNetworkGameDialog->getMyChat(), SLOT(receiveMessage(QString, QString))); - connect(this, SIGNAL(signalNetClientGameChatMsg(QString, QString)), myGuiInterface->getMyW()->getMyChat(), SLOT(receiveMessage(QString, QString))); - connect(this, SIGNAL(signalNetClientLobbyChatMsg(QString, QString)), myGameLobbyDialog->getMyChat(), SLOT(receiveMessage(QString, QString))); - connect(this, SIGNAL(signalNetClientMsgBox(QString)), this, SLOT(networkMessage(QString))); - connect(this, SIGNAL(signalNetClientShowTimeoutDialog(int, unsigned)), this, SLOT(showTimeoutDialog(int, unsigned))); - - connect(this, SIGNAL(signalLobbyPlayerJoined(unsigned, QString)), myGameLobbyDialog, SLOT(playerJoinedLobby(unsigned, QString))); -// connect(this, SIGNAL(signalLobbyPlayerKicked(QString, QString, QString)), myGameLobbyDialog, SLOT(playerKicked(QString, QString, QString))); - connect(this, SIGNAL(signalLobbyPlayerLeft(unsigned)), myGameLobbyDialog, SLOT(playerLeftLobby(unsigned))); + connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myGameLobbyDialog, SLOT(addGame(unsigned))); + connect(this, SIGNAL(signalNetClientGameListRemove(unsigned)), myGameLobbyDialog, SLOT(removeGame(unsigned))); + connect(this, SIGNAL(signalNetClientGameListUpdateMode(unsigned, int)), myGameLobbyDialog, SLOT(updateGameMode(unsigned, int))); + connect(this, SIGNAL(signalNetClientGameListUpdateAdmin(unsigned, unsigned)), myGameLobbyDialog, SLOT(updateGameAdmin(unsigned, unsigned))); + connect(this, SIGNAL(signalNetClientGameListPlayerJoined(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameAddPlayer(unsigned, unsigned))); + connect(this, SIGNAL(signalNetClientGameListPlayerLeft(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameRemovePlayer(unsigned, unsigned))); + connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), myGameLobbyDialog, SLOT(removedFromGame(int))); + connect(this, SIGNAL(signalNetClientStatsUpdate(ServerStats)), myGameLobbyDialog, SLOT(updateStats(ServerStats))); + + connect(this, SIGNAL(signalNetClientGameChatMsg(QString, QString)), myStartNetworkGameDialog->getMyChat(), SLOT(receiveMessage(QString, QString))); + connect(this, SIGNAL(signalNetClientGameChatMsg(QString, QString)), myGuiInterface->getMyW()->getMyChat(), SLOT(receiveMessage(QString, QString))); + connect(this, SIGNAL(signalNetClientLobbyChatMsg(QString, QString)), myGameLobbyDialog->getMyChat(), SLOT(receiveMessage(QString, QString))); + connect(this, SIGNAL(signalNetClientMsgBox(QString)), this, SLOT(networkMessage(QString))); + connect(this, SIGNAL(signalNetClientShowTimeoutDialog(int, unsigned)), this, SLOT(showTimeoutDialog(int, unsigned))); + + connect(this, SIGNAL(signalLobbyPlayerJoined(unsigned, QString)), myGameLobbyDialog, SLOT(playerJoinedLobby(unsigned, QString))); + connect(this, SIGNAL(signalLobbyPlayerKicked(QString, QString, QString)), myGameLobbyDialog, SLOT(playerKicked(QString, QString, QString))); + connect(this, SIGNAL(signalLobbyPlayerLeft(unsigned)), myGameLobbyDialog, SLOT(playerLeftLobby(unsigned))); - // Errors are handled globally, not within one dialog. - connect(this, SIGNAL(signalNetClientError(int, int)), this, SLOT(networkError(int, int))); - connect(this, SIGNAL(signalNetClientNotification(int)), this, SLOT(networkNotification(int))); - connect(this, SIGNAL(signalNetServerError(int, int)), this, SLOT(networkError(int, int))); - connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), this, SLOT(networkNotification(int))); - connect(this, SIGNAL(signalNetClientGameStart(boost::shared_ptr)), this, SLOT(networkStart(boost::shared_ptr))); + // Errors are handled globally, not within one dialog. + connect(this, SIGNAL(signalNetClientError(int, int)), this, SLOT(networkError(int, int))); + connect(this, SIGNAL(signalNetClientNotification(int)), this, SLOT(networkNotification(int))); + connect(this, SIGNAL(signalNetServerError(int, int)), this, SLOT(networkError(int, int))); + connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), this, SLOT(networkNotification(int))); + connect(this, SIGNAL(signalNetClientGameStart(boost::shared_ptr)), this, SLOT(networkStart(boost::shared_ptr))); - connect(this, SIGNAL(signalSelfGameInvitation(unsigned, unsigned)), myGameLobbyDialog, SLOT(showInvitationDialog(unsigned, unsigned))); - connect(this, SIGNAL(signalPlayerGameInvitation(unsigned, unsigned, unsigned)), myGameLobbyDialog, SLOT(chatInfoPlayerInviation(unsigned, unsigned, unsigned))); - connect(this, SIGNAL(signalRejectedGameInvitation(unsigned, unsigned, DenyGameInvitationReason)), myGameLobbyDialog, SLOT(chatInfoPlayerRejectedInviation(unsigned, unsigned, DenyGameInvitationReason))); - - this->show(); + connect(this, SIGNAL(signalSelfGameInvitation(unsigned, unsigned)), myGameLobbyDialog, SLOT(showInvitationDialog(unsigned, unsigned))); + connect(this, SIGNAL(signalPlayerGameInvitation(unsigned, unsigned, unsigned)), myGameLobbyDialog, SLOT(chatInfoPlayerInviation(unsigned, unsigned, unsigned))); + connect(this, SIGNAL(signalRejectedGameInvitation(unsigned, unsigned, DenyGameInvitationReason)), myGameLobbyDialog, SLOT(chatInfoPlayerRejectedInviation(unsigned, unsigned, DenyGameInvitationReason))); + + this->show(); } void startWindowImpl::callNewGameDialog() { - //wenn Dialogfenster gezeigt werden soll - if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){ + //wenn Dialogfenster gezeigt werden soll + if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){ - myNewGameDialog->exec(); - if (myNewGameDialog->result() == QDialog::Accepted ) { startNewLocalGame(myNewGameDialog); } - } - // sonst mit gespeicherten Werten starten - else { startNewLocalGame(); } + myNewGameDialog->exec(); + if (myNewGameDialog->result() == QDialog::Accepted ) { startNewLocalGame(myNewGameDialog); } + } + // sonst mit gespeicherten Werten starten + else { startNewLocalGame(); } } void startWindowImpl::startNewLocalGame(newGameDialogImpl *v) { - this->hide(); - myGuiInterface->getMyW()->show(); + 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"); - // Start new local game - terminate existing network game. - mySession->terminateNetworkClient(); - if (myServerGuiInterface.get()) - myServerGuiInterface->getSession()->terminateNetworkServer(); + 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"); + } - //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 = 4; - } - startData.startDealerPlayerId = static_cast(tmpDealerPos); + if(myConfig->readConfigInt("AlwaysDoubleBlinds")) { + gameData.raiseMode = DOUBLE_BLINDS; + } + else { + gameData.raiseMode = MANUAL_BLINDS_ORDER; + gameData.manualBlindsList = myConfig->readConfigIntList("ManualBlindsList"); - //some gui modifications - myGuiInterface->getMyW()->localGameModification(); + 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 = 4; + } + startData.startDealerPlayerId = static_cast(tmpDealerPos); - //Start Game!!! - mySession->startLocalGame(gameData, startData); + //some gui modifications + myGuiInterface->getMyW()->localGameModification(); + + //Start Game!!! + mySession->startLocalGame(gameData, startData); } void startWindowImpl::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(); + //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(); - } + if(myChangeHumanPlayerNameDialog->result() == QDialog::Accepted) { + joinGameLobby(); + } + } + else { + joinGameLobby(); + } } void startWindowImpl::joinGameLobby() { - // Stop local game. - myGuiInterface->getMyW()->stopTimer(); + // Stop local game. + myGuiInterface->getMyW()->stopTimer(); - mySession->terminateNetworkClient(); - if (myServerGuiInterface) - myServerGuiInterface->getSession()->terminateNetworkServer(); - - myGameLobbyDialog->setSession(getSession()); - myStartNetworkGameDialog->setSession(getSession()); + mySession->terminateNetworkClient(); + if (myServerGuiInterface) + myServerGuiInterface->getSession()->terminateNetworkServer(); - // Clear Lobby dialog. - myGameLobbyDialog->clearDialog(); + myGameLobbyDialog->setSession(getSession()); + myStartNetworkGameDialog->setSession(getSession()); - //start internet client with config values for user and pw TODO - mySession->startInternetClient(); - - //Dialog mit Statusbalken - myConnectToServerDialog->exec(); - if (myConnectToServerDialog->result() == QDialog::Accepted ) { - showLobbyDialog(); - } - else { - mySession->terminateNetworkClient(); - } + // Clear Lobby dialog. + myGameLobbyDialog->clearDialog(); + + //start internet client with config values for user and pw TODO + mySession->startInternetClient(); + + //Dialog mit Statusbalken + myConnectToServerDialog->exec(); + if (myConnectToServerDialog->result() == QDialog::Accepted ) { + showLobbyDialog(); + } + else { + mySession->terminateNetworkClient(); + } } void startWindowImpl::callInternetGameLoginDialog() { - //login - myInternetGameLoginDialog->exec(); - if(myInternetGameLoginDialog->result() == QDialog::Accepted) { - //send login infos - mySession->setLogin( - myConfig->readConfigString("MyName"), - myInternetGameLoginDialog->lineEdit_password->text().toUtf8().constData(), - myInternetGameLoginDialog->checkBox_guest->isChecked()); - } - else { - myConnectToServerDialog->reject(); - mySession->terminateNetworkClient(); - } + //login + myInternetGameLoginDialog->exec(); + if(myInternetGameLoginDialog->result() == QDialog::Accepted) { + //send login infos + mySession->setLogin( + myConfig->readConfigString("MyName"), + myInternetGameLoginDialog->lineEdit_password->text().toUtf8().constData(), + myInternetGameLoginDialog->checkBox_guest->isChecked()); + } + else { + myConnectToServerDialog->reject(); + mySession->terminateNetworkClient(); + } } void startWindowImpl::callCreateNetworkGameDialog() { - - myCreateNetworkGameDialog->exec(); -// - if (myCreateNetworkGameDialog->result() == QDialog::Accepted ) { - // Stop local game. - myGuiInterface->getMyW()->stopTimer(); + myCreateNetworkGameDialog->exec(); + // + if (myCreateNetworkGameDialog->result() == QDialog::Accepted ) { - if (!myServerGuiInterface) - { - // 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); - } - } + // Stop local game. + myGuiInterface->getMyW()->stopTimer(); - // Terminate existing network games. - mySession->terminateNetworkClient(); - myServerGuiInterface->getSession()->terminateNetworkServer(); + if (!myServerGuiInterface) + { + // 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); + } + } - 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; - std::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; } - } - } + // Terminate existing network games. + mySession->terminateNetworkClient(); + myServerGuiInterface->getSession()->terminateNetworkServer(); - gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); - gameData.delayBetweenHandsSec = myCreateNetworkGameDialog->spinBox_netDelayBetweenHands->value(); - gameData.playerActionTimeoutSec = myCreateNetworkGameDialog->spinBox_netTimeOutPlayerAction->value(); + GameData gameData; + gameData.maxNumberOfPlayers = myCreateNetworkGameDialog->spinBox_quantityPlayers->value(); + gameData.startMoney = myCreateNetworkGameDialog->spinBox_startCash->value(); + gameData.firstSmallBlind = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); - myGameLobbyDialog->setSession(getSession()); - myStartNetworkGameDialog->setSession(getSession()); + 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(); + } - // Clear network game dialog. - myStartNetworkGameDialog->clearDialog(); + if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { + gameData.raiseMode = DOUBLE_BLINDS; + } + else { + gameData.raiseMode = MANUAL_BLINDS_ORDER; + std::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; - myServerGuiInterface->getSession()->startNetworkServer(false); - mySession->startNetworkClientForLocalServer(gameData); + 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; } + } + } - myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers); + gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); + gameData.delayBetweenHandsSec = myCreateNetworkGameDialog->spinBox_netDelayBetweenHands->value(); + gameData.playerActionTimeoutSec = myCreateNetworkGameDialog->spinBox_netTimeOutPlayerAction->value(); - myStartNetworkGameDialog->setWindowTitle("Start Network Game"); + myGameLobbyDialog->setSession(getSession()); + myStartNetworkGameDialog->setSession(getSession()); - showNetworkStartDialog(); - } + // Clear network game dialog. + myStartNetworkGameDialog->clearDialog(); + + myServerGuiInterface->getSession()->startNetworkServer(false); + mySession->startNetworkClientForLocalServer(gameData); + + myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers); + + myStartNetworkGameDialog->setWindowTitle("Start Network Game"); + + showNetworkStartDialog(); + } } void startWindowImpl::callJoinNetworkGameDialog() { - myJoinNetworkGameDialog->exec(); + myJoinNetworkGameDialog->exec(); - if (myJoinNetworkGameDialog->result() == QDialog::Accepted ) { + if (myJoinNetworkGameDialog->result() == QDialog::Accepted ) { - // Stop local game. - myGuiInterface->getMyW()->stopTimer(); + // Stop local game. + myGuiInterface->getMyW()->stopTimer(); - mySession->terminateNetworkClient(); - if (myServerGuiInterface) - myServerGuiInterface->getSession()->terminateNetworkServer(); + mySession->terminateNetworkClient(); + if (myServerGuiInterface) + 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()); + 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()); - //Dialog mit Statusbalken - myConnectToServerDialog->exec(); + //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"); + 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(); - } - } + showNetworkStartDialog(); + } + } } void startWindowImpl::showClientDialog() { - if (mySession->getGameType() == Session::GAME_TYPE_NETWORK) - { - if (myGuiInterface->getMyW()->isVisible()) - myGuiInterface->getMyW()->hide(); - if (!this->isVisible()) - this->show(); - if (!myStartNetworkGameDialog->isVisible()) - showNetworkStartDialog(); - } - else if (mySession->getGameType() == Session::GAME_TYPE_INTERNET) - { - if (myGuiInterface->getMyW()->isVisible()) - myGuiInterface->getMyW()->hide(); - if (!this->isVisible()) - this->show(); - if (!myGameLobbyDialog->isVisible()) - showLobbyDialog(); - } + if (mySession->getGameType() == Session::GAME_TYPE_NETWORK) + { + if (myGuiInterface->getMyW()->isVisible()) + myGuiInterface->getMyW()->hide(); + if (!this->isVisible()) + this->show(); + if (!myStartNetworkGameDialog->isVisible()) + showNetworkStartDialog(); + } + else if (mySession->getGameType() == Session::GAME_TYPE_INTERNET) + { + if (myGuiInterface->getMyW()->isVisible()) + myGuiInterface->getMyW()->hide(); + if (!this->isVisible()) + this->show(); + if (!myGameLobbyDialog->isVisible()) + showLobbyDialog(); + } } void startWindowImpl::showLobbyDialog() { - myGameLobbyDialog->exec(); + myGameLobbyDialog->exec(); - if (myGameLobbyDialog->result() == QDialog::Accepted ) - { - this->hide(); - //some gui modifications - myGuiInterface->getMyW()->networkGameModification(); - } - else - { - myGameLobbyDialog->clearDialog(); - mySession->terminateNetworkClient(); - } + if (myGameLobbyDialog->result() == QDialog::Accepted ) + { + this->hide(); + //some gui modifications + myGuiInterface->getMyW()->networkGameModification(); + } + else + { + myGameLobbyDialog->clearDialog(); + mySession->terminateNetworkClient(); + } } void startWindowImpl::showNetworkStartDialog() { - myStartNetworkGameDialog->exec(); + myStartNetworkGameDialog->exec(); - if (myStartNetworkGameDialog->result() == QDialog::Accepted ) { - - this->hide(); - //some gui modifications - myGuiInterface->getMyW()->networkGameModification(); - } - else { - mySession->terminateNetworkClient(); - if (myServerGuiInterface) - myServerGuiInterface->getSession()->terminateNetworkServer(); - } + if (myStartNetworkGameDialog->result() == QDialog::Accepted ) { + + this->hide(); + //some gui modifications + myGuiInterface->getMyW()->networkGameModification(); + } + else { + mySession->terminateNetworkClient(); + if (myServerGuiInterface) + myServerGuiInterface->getSession()->terminateNetworkServer(); + } } void startWindowImpl::callAboutPokerthDialog() { myAboutPokerthDialog->exec(); } void startWindowImpl::callSettingsDialog() { - mySettingsDialog->exec(); - - if (mySettingsDialog->result() == QDialog::Accepted && mySettingsDialog->getSettingsCorrect()) { - myGuiInterface->getMyW()->applySettings(mySettingsDialog); - } + mySettingsDialog->exec(); + + if (mySettingsDialog->result() == QDialog::Accepted && mySettingsDialog->getSettingsCorrect()) { + myGuiInterface->getMyW()->applySettings(mySettingsDialog); + } } void startWindowImpl::showTimeoutDialog(int msgID, unsigned duration) { - if(myTimeoutDialog->isHidden()) { - myTimeoutDialog->setMySession(mySession); - myTimeoutDialog->setMsgID((NetTimeoutReason)msgID); - myTimeoutDialog->setTimeoutDuration(duration); - myTimeoutDialog->show(); - myTimeoutDialog->raise(); - myTimeoutDialog->activateWindow(); - myTimeoutDialog->startTimeout(); - } + if(myTimeoutDialog->isHidden()) { + myTimeoutDialog->setMySession(mySession); + myTimeoutDialog->setMsgID((NetTimeoutReason)msgID); + myTimeoutDialog->setTimeoutDuration(duration); + myTimeoutDialog->show(); + myTimeoutDialog->raise(); + myTimeoutDialog->activateWindow(); + myTimeoutDialog->startTimeout(); + } } void startWindowImpl::hideTimeoutDialog() { myTimeoutDialog->hide(); } void startWindowImpl::networkError(int errorID, int /*osErrorID*/) { - hideTimeoutDialog(); - switch (errorID) { - case ERR_SOCK_SERVERADDR_NOT_SET: - {QMessageBox::warning(this, tr("Network Error"), - tr("Server address was not set."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_PORT: - { QMessageBox::warning(this, tr("Network Error"), - tr("An invalid port was set (ports 0-1023 are not allowed)."), - QMessageBox::Close); } - break; - case ERR_SOCK_CREATION_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not create a socket for TCP communication."), - QMessageBox::Close); } - break; - case ERR_SOCK_SET_ADDR_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not set the IP address."), - QMessageBox::Close); } - break; - case ERR_SOCK_SET_PORT_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not set the port for this type of address."), - QMessageBox::Close); } - break; - case ERR_SOCK_RESOLVE_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("The server name could not be resolved."), - QMessageBox::Close); } - break; - case ERR_SOCK_BIND_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Bind failed - please choose a different port."), - QMessageBox::Close); } - break; - case ERR_SOCK_LISTEN_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal network error: \"listen\" failed."), - QMessageBox::Close); } - break; - case ERR_SOCK_ACCEPT_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Server execution was terminated."), - QMessageBox::Close); } - break; - case ERR_SOCK_CONNECT_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not connect to the server."), - QMessageBox::Close); } - break; - case ERR_SOCK_CONNECT_TIMEOUT: - { QMessageBox::warning(this, tr("Network Error"), - tr("Connection timed out.\nPlease check the server address.\n\nIf the server is behind a NAT-Router, make sure port forwarding has been set up on server side."), - QMessageBox::Close); } - break; - case ERR_SOCK_SELECT_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal network error: \"select\" failed."), - QMessageBox::Close); } - break; - case ERR_SOCK_SEND_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal network error: \"send\" failed."), - QMessageBox::Close); } - break; - case ERR_SOCK_RECV_FAILED: // Sometimes windows reports recv failed on close. - case ERR_SOCK_CONN_RESET: - { QMessageBox::warning(this, tr("Network Error"), - tr("Connection was closed by the server."), - QMessageBox::Close); } - break; - case ERR_SOCK_CONN_EXISTS: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal network error: Duplicate TCP connection."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_PACKET: - { QMessageBox::warning(this, tr("Network Error"), - tr("An invalid network packet was received.\nPlease make sure that all players use the same version of PokerTH."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_STATE: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal state error.\nPlease make sure that all players use the same version of PokerTH."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_SERVERLIST_URL: - case ERR_SOCK_TRANSFER_INVALID_URL: - { QMessageBox::warning(this, tr("Network Error"), - tr("Invalid server list URL.\nPlease correct the address in the settings."), - QMessageBox::Close); } - break; - case ERR_SOCK_OPEN_MD5_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not open the server list MD5 file.\nPlease make sure that the server list URL is correct."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_SERVERLIST_MD5: - { QMessageBox::warning(this, tr("Network Error"), - tr("Synchronization of the PokerTH internet server list has failed.\nPlease make sure that the server list URL is correct."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_SERVERLIST_XML: - { QMessageBox::warning(this, tr("Network Error"), - tr("The PokerTH internet server list contains invalid data.\nIf you use a custom server list, please make sure its format is correct."), - QMessageBox::Close); } - break; - case ERR_SOCK_UNZIP_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not unzip the PokerTH internet server list."), - QMessageBox::Close); } - break; - case ERR_SOCK_TRANSFER_INIT_FAILED: - case ERR_SOCK_TRANSFER_SELECT_FAILED: - case ERR_SOCK_TRANSFER_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not download the PokerTH internet server list.\nPlease make sure you are directly connected to the internet."), - QMessageBox::Close); } - break; - case ERR_SOCK_TRANSFER_OPEN_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not open the target file when downloading the server list."), - QMessageBox::Close); } - break; - case ERR_NET_VERSION_NOT_SUPPORTED: - { QMessageBox msgBox(QMessageBox::Warning, tr("Network Error"), - tr("The PokerTH server does not support this version of the game.
Please go to http://www.pokerth.net and download the latest version."), - QMessageBox::Close, this); - msgBox.setTextFormat(Qt::RichText); - msgBox.exec(); - } - break; - case ERR_NET_SERVER_FULL: - { QMessageBox::warning(this, tr("Network Error"), - tr("Sorry, this server is already full."), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_PASSWORD: - { QMessageBox::warning(this, tr("Network Error"), - tr("Invalid login.\nPlease check your username and password."), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_PASSWORD_STR: - { QMessageBox::warning(this, tr("Network Error"), - tr("The password is too long. Please choose another one."), - 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(); } - 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(); } - break; - case ERR_NET_INVALID_GAME_NAME: - { QMessageBox::warning(this, tr("Network Error"), - tr("The game name is either too short or too long. Please choose another one."), - QMessageBox::Close); } - break; - case ERR_NET_UNKNOWN_GAME: - { QMessageBox::warning(this, tr("Network Error"), - tr("The game could not be found."), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_CHAT_TEXT: - { QMessageBox::warning(this, tr("Network Error"), - tr("The chat text is invalid."), - QMessageBox::Close); } - break; - case ERR_NET_UNKNOWN_PLAYER_ID: - { QMessageBox::warning(this, tr("Network Error"), - tr("The server referred to an unknown player. Aborting."), - QMessageBox::Close); } - break; - case ERR_NET_NO_CURRENT_PLAYER: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal error: The current player could not be found."), - QMessageBox::Close); } - break; - case ERR_NET_PLAYER_NOT_ACTIVE: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal error: The current player is not active."), - QMessageBox::Close); } - break; - case ERR_NET_PLAYER_KICKED: - { mySession->terminateNetworkClient(); - QMessageBox::warning(this, tr("Network Error"), - tr("You were kicked from the server."), - QMessageBox::Close); } - break; - case ERR_NET_PLAYER_BANNED: - { mySession->terminateNetworkClient(); - QMessageBox::warning(this, tr("Network Error"), - tr("You were temporarily banned from the server."), - QMessageBox::Close); } - break; - case ERR_NET_SESSION_TIMED_OUT: - { mySession->terminateNetworkClient(); - QMessageBox::warning(this, tr("Network Error"), - tr("Your server connection timed out due to inactivity. You are very welcome to reconnect!"), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_PLAYER_COUNT: - { QMessageBox::warning(this, tr("Network Error"), - tr("The client player count is invalid."), - QMessageBox::Close); } - break; - case ERR_NET_TOO_MANY_MANUAL_BLINDS: - { QMessageBox::warning(this, tr("Network Error"), - tr("Too many manual blinds were set. Please reconfigure the manual blinds."), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_AVATAR_FILE: - case ERR_NET_WRONG_AVATAR_SIZE: - { QMessageBox::warning(this, tr("Network Error"), - tr("An invalid avatar file was configured. Please choose a different avatar."), - QMessageBox::Close); } - break; - case ERR_NET_AVATAR_TOO_LARGE: - { QMessageBox::warning(this, tr("Network Error"), - tr("The selected avatar file is too large. Please choose a different avatar."), - QMessageBox::Close); } - break; - case ERR_NET_INIT_BLOCKED: - { QMessageBox::warning(this, tr("Network Error"), - tr("You cannot login at this time. Please try again in a few seconds."), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_REQUEST_ID: - { QMessageBox::warning(this, tr("Network Error"), - tr("An internal avatar error occured. Please report this to an admin in the lobby chat."), - QMessageBox::Close); } - break; - case ERR_NET_START_TIMEOUT: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not start game: Synchronization failed."), - QMessageBox::Close); } - break; - case ERR_NET_SERVER_MAINTENANCE: - { QMessageBox::warning(this, tr("Network Error"), - tr("The server is down for maintenance. Please try again later."), - QMessageBox::Close); } - break; - default: { QMessageBox::warning(this, tr("Network Error"), - tr("An internal error occured."), - QMessageBox::Close); } - } - // close dialogs - myGameLobbyDialog->reject(); - myConnectToServerDialog->reject(); - myStartNetworkGameDialog->reject(); - myGuiInterface->getMyW()->close(); + hideTimeoutDialog(); + switch (errorID) { + case ERR_SOCK_SERVERADDR_NOT_SET: + {QMessageBox::warning(this, tr("Network Error"), + tr("Server address was not set."), + QMessageBox::Close); } + break; + case ERR_SOCK_INVALID_PORT: + { QMessageBox::warning(this, tr("Network Error"), + tr("An invalid port was set (ports 0-1023 are not allowed)."), + QMessageBox::Close); } + break; + case ERR_SOCK_CREATION_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Could not create a socket for TCP communication."), + QMessageBox::Close); } + break; + case ERR_SOCK_SET_ADDR_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Could not set the IP address."), + QMessageBox::Close); } + break; + case ERR_SOCK_SET_PORT_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Could not set the port for this type of address."), + QMessageBox::Close); } + break; + case ERR_SOCK_RESOLVE_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("The server name could not be resolved."), + QMessageBox::Close); } + break; + case ERR_SOCK_BIND_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Bind failed - please choose a different port."), + QMessageBox::Close); } + break; + case ERR_SOCK_LISTEN_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Internal network error: \"listen\" failed."), + QMessageBox::Close); } + break; + case ERR_SOCK_ACCEPT_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Server execution was terminated."), + QMessageBox::Close); } + break; + case ERR_SOCK_CONNECT_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Could not connect to the server."), + QMessageBox::Close); } + break; + case ERR_SOCK_CONNECT_TIMEOUT: + { QMessageBox::warning(this, tr("Network Error"), + tr("Connection timed out.\nPlease check the server address.\n\nIf the server is behind a NAT-Router, make sure port forwarding has been set up on server side."), + QMessageBox::Close); } + break; + case ERR_SOCK_SELECT_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Internal network error: \"select\" failed."), + QMessageBox::Close); } + break; + case ERR_SOCK_SEND_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Internal network error: \"send\" failed."), + QMessageBox::Close); } + break; + case ERR_SOCK_RECV_FAILED: // Sometimes windows reports recv failed on close. + case ERR_SOCK_CONN_RESET: + { QMessageBox::warning(this, tr("Network Error"), + tr("Connection was closed by the server."), + QMessageBox::Close); } + break; + case ERR_SOCK_CONN_EXISTS: + { QMessageBox::warning(this, tr("Network Error"), + tr("Internal network error: Duplicate TCP connection."), + QMessageBox::Close); } + break; + case ERR_SOCK_INVALID_PACKET: + { QMessageBox::warning(this, tr("Network Error"), + tr("An invalid network packet was received.\nPlease make sure that all players use the same version of PokerTH."), + QMessageBox::Close); } + break; + case ERR_SOCK_INVALID_STATE: + { QMessageBox::warning(this, tr("Network Error"), + tr("Internal state error.\nPlease make sure that all players use the same version of PokerTH."), + QMessageBox::Close); } + break; + case ERR_SOCK_INVALID_SERVERLIST_URL: + case ERR_SOCK_TRANSFER_INVALID_URL: + { QMessageBox::warning(this, tr("Network Error"), + tr("Invalid server list URL.\nPlease correct the address in the settings."), + QMessageBox::Close); } + break; + case ERR_SOCK_OPEN_MD5_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Could not open the server list MD5 file.\nPlease make sure that the server list URL is correct."), + QMessageBox::Close); } + break; + case ERR_SOCK_INVALID_SERVERLIST_MD5: + { QMessageBox::warning(this, tr("Network Error"), + tr("Synchronization of the PokerTH internet server list has failed.\nPlease make sure that the server list URL is correct."), + QMessageBox::Close); } + break; + case ERR_SOCK_INVALID_SERVERLIST_XML: + { QMessageBox::warning(this, tr("Network Error"), + tr("The PokerTH internet server list contains invalid data.\nIf you use a custom server list, please make sure its format is correct."), + QMessageBox::Close); } + break; + case ERR_SOCK_UNZIP_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Could not unzip the PokerTH internet server list."), + QMessageBox::Close); } + break; + case ERR_SOCK_TRANSFER_INIT_FAILED: + case ERR_SOCK_TRANSFER_SELECT_FAILED: + case ERR_SOCK_TRANSFER_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Could not download the PokerTH internet server list.\nPlease make sure you are directly connected to the internet."), + QMessageBox::Close); } + break; + case ERR_SOCK_TRANSFER_OPEN_FAILED: + { QMessageBox::warning(this, tr("Network Error"), + tr("Could not open the target file when downloading the server list."), + QMessageBox::Close); } + break; + case ERR_NET_VERSION_NOT_SUPPORTED: + { QMessageBox msgBox(QMessageBox::Warning, tr("Network Error"), + tr("The PokerTH server does not support this version of the game.
Please go to http://www.pokerth.net and download the latest version."), + QMessageBox::Close, this); + msgBox.setTextFormat(Qt::RichText); + msgBox.exec(); + } + break; + case ERR_NET_SERVER_FULL: + { QMessageBox::warning(this, tr("Network Error"), + tr("Sorry, this server is already full."), + QMessageBox::Close); } + break; + case ERR_NET_INVALID_PASSWORD: + { QMessageBox::warning(this, tr("Network Error"), + tr("Invalid login.\nPlease check your username and password."), + QMessageBox::Close); } + break; + case ERR_NET_INVALID_PASSWORD_STR: + { QMessageBox::warning(this, tr("Network Error"), + tr("The password is too long. Please choose another one."), + 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(); } + 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(); } + break; + case ERR_NET_INVALID_GAME_NAME: + { QMessageBox::warning(this, tr("Network Error"), + tr("The game name is either too short or too long. Please choose another one."), + QMessageBox::Close); } + break; + case ERR_NET_UNKNOWN_GAME: + { QMessageBox::warning(this, tr("Network Error"), + tr("The game could not be found."), + QMessageBox::Close); } + break; + case ERR_NET_INVALID_CHAT_TEXT: + { QMessageBox::warning(this, tr("Network Error"), + tr("The chat text is invalid."), + QMessageBox::Close); } + break; + case ERR_NET_UNKNOWN_PLAYER_ID: + { QMessageBox::warning(this, tr("Network Error"), + tr("The server referred to an unknown player. Aborting."), + QMessageBox::Close); } + break; + case ERR_NET_NO_CURRENT_PLAYER: + { QMessageBox::warning(this, tr("Network Error"), + tr("Internal error: The current player could not be found."), + QMessageBox::Close); } + break; + case ERR_NET_PLAYER_NOT_ACTIVE: + { QMessageBox::warning(this, tr("Network Error"), + tr("Internal error: The current player is not active."), + QMessageBox::Close); } + break; + case ERR_NET_PLAYER_KICKED: + { mySession->terminateNetworkClient(); + QMessageBox::warning(this, tr("Network Error"), + tr("You were kicked from the server."), + QMessageBox::Close); } + break; + case ERR_NET_PLAYER_BANNED: + { mySession->terminateNetworkClient(); + QMessageBox::warning(this, tr("Network Error"), + tr("You were temporarily banned from the server."), + QMessageBox::Close); } + break; + case ERR_NET_SESSION_TIMED_OUT: + { mySession->terminateNetworkClient(); + QMessageBox::warning(this, tr("Network Error"), + tr("Your server connection timed out due to inactivity. You are very welcome to reconnect!"), + QMessageBox::Close); } + break; + case ERR_NET_INVALID_PLAYER_COUNT: + { QMessageBox::warning(this, tr("Network Error"), + tr("The client player count is invalid."), + QMessageBox::Close); } + break; + case ERR_NET_TOO_MANY_MANUAL_BLINDS: + { QMessageBox::warning(this, tr("Network Error"), + tr("Too many manual blinds were set. Please reconfigure the manual blinds."), + QMessageBox::Close); } + break; + case ERR_NET_INVALID_AVATAR_FILE: + case ERR_NET_WRONG_AVATAR_SIZE: + { QMessageBox::warning(this, tr("Network Error"), + tr("An invalid avatar file was configured. Please choose a different avatar."), + QMessageBox::Close); } + break; + case ERR_NET_AVATAR_TOO_LARGE: + { QMessageBox::warning(this, tr("Network Error"), + tr("The selected avatar file is too large. Please choose a different avatar."), + QMessageBox::Close); } + break; + case ERR_NET_INIT_BLOCKED: + { QMessageBox::warning(this, tr("Network Error"), + tr("You cannot login at this time. Please try again in a few seconds."), + QMessageBox::Close); } + break; + case ERR_NET_INVALID_REQUEST_ID: + { QMessageBox::warning(this, tr("Network Error"), + tr("An internal avatar error occured. Please report this to an admin in the lobby chat."), + QMessageBox::Close); } + break; + case ERR_NET_START_TIMEOUT: + { QMessageBox::warning(this, tr("Network Error"), + tr("Could not start game: Synchronization failed."), + QMessageBox::Close); } + break; + case ERR_NET_SERVER_MAINTENANCE: + { QMessageBox::warning(this, tr("Network Error"), + tr("The server is down for maintenance. Please try again later."), + QMessageBox::Close); } + break; + default: { QMessageBox::warning(this, tr("Network Error"), + tr("An internal error occured."), + QMessageBox::Close); } + } + // close dialogs + myGameLobbyDialog->reject(); + myConnectToServerDialog->reject(); + myStartNetworkGameDialog->reject(); + myGuiInterface->getMyW()->close(); } void startWindowImpl::networkNotification(int notificationId) { - hideTimeoutDialog(); - switch (notificationId) - { - case NTF_NET_REMOVED_KICKED: - { QMessageBox::warning(this, tr("Network Notification"), - tr("You were kicked from the game."), - QMessageBox::Close); } - break; - case NTF_NET_REMOVED_GAME_FULL: - case NTF_NET_JOIN_GAME_FULL: - { QMessageBox::warning(this, tr("Network Notification"), - tr("Sorry, this game is already full."), - QMessageBox::Close); } - break; - case NTF_NET_REMOVED_ALREADY_RUNNING: - case NTF_NET_JOIN_ALREADY_RUNNING: - { QMessageBox::warning(this, tr("Network Notification"), - tr("Unable to join - the server has already started the game."), - QMessageBox::Close); } - break; - case NTF_NET_REMOVED_TIMEOUT: - { QMessageBox::warning(this, tr("Network Notification"), - tr("Your admin state timed out due to inactivity. Feel free to create a new game!"), - QMessageBox::Close); } - break; - case NTF_NET_JOIN_INVALID_PASSWORD: - { QMessageBox::warning(this, tr("Network Notification"), - tr("Invalid password when joining the game.\nPlease reenter the password and try again."), - QMessageBox::Close); } - break; - case NTF_NET_JOIN_GUEST_FORBIDDEN: - { QMessageBox::warning(this, tr("Network Notification"), - tr("You cannot join this type of game as guest."), - QMessageBox::Close); } - break; - case NTF_NET_NEW_RELEASE_AVAILABLE: - { QMessageBox msgBox(QMessageBox::Information, tr("Network Notification"), - tr("A new release of PokerTH is available.
Please go to http://www.pokerth.net and download the latest version."), - QMessageBox::Close, this); - msgBox.setTextFormat(Qt::RichText); - msgBox.exec(); - } - break; - case NTF_NET_OUTDATED_BETA: - { QMessageBox msgBox(QMessageBox::Information, tr("Network Notification"), - tr("This beta release of PokerTH is outdated.
Please go to http://www.pokerth.net and download the latest version."), - QMessageBox::Close, this); - msgBox.setTextFormat(Qt::RichText); - msgBox.exec(); - } - break; - } + hideTimeoutDialog(); + switch (notificationId) + { + case NTF_NET_REMOVED_KICKED: + { QMessageBox::warning(this, tr("Network Notification"), + tr("You were kicked from the game."), + QMessageBox::Close); } + break; + case NTF_NET_REMOVED_GAME_FULL: + case NTF_NET_JOIN_GAME_FULL: + { QMessageBox::warning(this, tr("Network Notification"), + tr("Sorry, this game is already full."), + QMessageBox::Close); } + break; + case NTF_NET_REMOVED_ALREADY_RUNNING: + case NTF_NET_JOIN_ALREADY_RUNNING: + { QMessageBox::warning(this, tr("Network Notification"), + tr("Unable to join - the server has already started the game."), + QMessageBox::Close); } + break; + case NTF_NET_REMOVED_TIMEOUT: + { QMessageBox::warning(this, tr("Network Notification"), + tr("Your admin state timed out due to inactivity. Feel free to create a new game!"), + QMessageBox::Close); } + break; + case NTF_NET_JOIN_INVALID_PASSWORD: + { QMessageBox::warning(this, tr("Network Notification"), + tr("Invalid password when joining the game.\nPlease reenter the password and try again."), + QMessageBox::Close); } + break; + case NTF_NET_JOIN_GUEST_FORBIDDEN: + { QMessageBox::warning(this, tr("Network Notification"), + tr("You cannot join this type of game as guest."), + QMessageBox::Close); } + break; + case NTF_NET_NEW_RELEASE_AVAILABLE: + { QMessageBox msgBox(QMessageBox::Information, tr("Network Notification"), + tr("A new release of PokerTH is available.
Please go to http://www.pokerth.net and download the latest version."), + QMessageBox::Close, this); + msgBox.setTextFormat(Qt::RichText); + msgBox.exec(); + } + break; + case NTF_NET_OUTDATED_BETA: + { QMessageBox msgBox(QMessageBox::Information, tr("Network Notification"), + tr("This beta release of PokerTH is outdated.
Please go to http://www.pokerth.net and download the latest version."), + QMessageBox::Close, this); + msgBox.setTextFormat(Qt::RichText); + msgBox.exec(); + } + break; + } } void startWindowImpl::networkMessage(QString msg) { - QMessageBox msgBox(QMessageBox::Information, tr("Server Message"), - msg, QMessageBox::Close, this); - msgBox.setTextFormat(Qt::RichText); - msgBox.exec(); + QMessageBox msgBox(QMessageBox::Information, tr("Server Message"), + msg, QMessageBox::Close, this); + msgBox.setTextFormat(Qt::RichText); + msgBox.exec(); } void startWindowImpl::networkStart(boost::shared_ptr game) { - mySession->startClientGame(game); + mySession->startClientGame(game); - //send playerNicksList to chat for nick-autocompletition - myGuiInterface->getMyW()->getMyChat()->setPlayerNicksList(getPlayerNicksList()); + //send playerNicksList to chat for nick-autocompletition + myGuiInterface->getMyW()->getMyChat()->setPlayerNicksList(getPlayerNicksList()); } QStringList startWindowImpl::getPlayerNicksList() { - QStringList list; - PlayerListConstIterator it_c; - - for (it_c=mySession->getCurrentGame()->getSeatsList()->begin(); it_c!=mySession->getCurrentGame()->getSeatsList()->end(); it_c++) { - list << QString::fromUtf8((*it_c)->getMyName().c_str()); - } - - return list; + QStringList list; + PlayerListConstIterator it_c; + + for (it_c=mySession->getCurrentGame()->getSeatsList()->begin(); it_c!=mySession->getCurrentGame()->getSeatsList()->end(); it_c++) { + list << QString::fromUtf8((*it_c)->getMyName().c_str()); + } + + return list; } diff --git a/src/gui/qt/startwindow/startwindowimpl.h b/src/gui/qt/startwindow/startwindowimpl.h index df1b9a73..62249ed9 100644 --- a/src/gui/qt/startwindow/startwindowimpl.h +++ b/src/gui/qt/startwindow/startwindowimpl.h @@ -47,115 +47,106 @@ class serverListDialogImpl; class internetGameLoginDialogImpl; class startWindowImpl: public QMainWindow, public Ui::startWindow { -Q_OBJECT + Q_OBJECT public: startWindowImpl(ConfigFile *c =0); - void setSession(boost::shared_ptr session) { mySession = session; } - boost::shared_ptr getSession() { assert(mySession.get()); return mySession; } - boost::shared_ptr< GuiInterface > getMyServerGuiInterface() const { return myServerGuiInterface; } - connectToServerDialogImpl* getMyConnectToServerDialog() const { return myConnectToServerDialog; } + void setSession(boost::shared_ptr session) { mySession = session; } + boost::shared_ptr getSession() { assert(mySession.get()); return mySession; } + boost::shared_ptr< GuiInterface > getMyServerGuiInterface() const { return myServerGuiInterface; } + connectToServerDialogImpl* getMyConnectToServerDialog() const { return myConnectToServerDialog; } + + // void keyPressEvent( QKeyEvent *); -// void keyPressEvent( QKeyEvent *); - signals: - void signalShowClientDialog(); - - void signalNetClientConnect(int actionID); - void signalNetClientServerListShow(); - void signalNetClientServerListClear(); - void signalNetClientServerListAdd(unsigned serverId); - void signalNetClientLoginShow(); - void signalNetClientGameInfo(int actionID); - void signalNetClientError(int errorID, int osErrorID); - void signalNetClientNotification(int notificationId); - void signalNetClientStatsUpdate(ServerStats stats); - void signalNetClientShowTimeoutDialog(int, unsigned); - void signalNetClientRemovedFromGame(int notificationId); - void signalNetServerError(int errorID, int osErrorID); - void signalNetClientSelfJoined(unsigned playerId, QString playerName, bool isGameAdmin); - void signalNetClientPlayerJoined(unsigned playerId, QString playerName, bool isGameAdmin); - void signalNetClientPlayerChanged(unsigned playerId, QString newPlayerName); - void signalNetClientPlayerLeft(unsigned playerId, QString playerName); - void signalNetClientNewGameAdmin(unsigned playerId, QString playerName); - void signalNetClientGameListNew(unsigned gameId); - void signalNetClientGameListRemove(unsigned gameId); - void signalNetClientGameListUpdateMode(unsigned gameId, int mode); - void signalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); - void signalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); - void signalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); - void signalNetClientGameStart(boost::shared_ptr game); - void signalNetClientGameChatMsg(QString nickName, QString msg); - void signalNetClientLobbyChatMsg(QString nickName, QString msg); - void signalNetClientMsgBox(QString msg); + void signalShowClientDialog(); -// void signalIrcConnect(QString server); -// void signalIrcSelfJoined(QString nickName, QString channel); -// void signalIrcPlayerJoined(QString nickName); -// void signalIrcPlayerChanged(QString oldNick, QString newNick); -// void signalIrcPlayerKicked(QString nickName, QString byWhom, QString reason); -// void signalIrcPlayerLeft(QString nickName); -// void signalIrcChatMessage(QString nickName, QString msg); -// void signalIrcError(int errorCode); -// void signalIrcServerError(int errorCode); - void signalLobbyPlayerJoined(unsigned playerId, QString nickName); - void signalLobbyPlayerKicked(QString nickName, QString byWhom, QString reason); - void signalLobbyPlayerLeft(unsigned playerId); + void signalNetClientConnect(int actionID); + void signalNetClientServerListShow(); + void signalNetClientServerListClear(); + void signalNetClientServerListAdd(unsigned serverId); + void signalNetClientLoginShow(); + void signalNetClientGameInfo(int actionID); + void signalNetClientError(int errorID, int osErrorID); + void signalNetClientNotification(int notificationId); + void signalNetClientStatsUpdate(ServerStats stats); + void signalNetClientShowTimeoutDialog(int, unsigned); + void signalNetClientRemovedFromGame(int notificationId); + void signalNetServerError(int errorID, int osErrorID); + void signalNetClientSelfJoined(unsigned playerId, QString playerName, bool isGameAdmin); + void signalNetClientPlayerJoined(unsigned playerId, QString playerName, bool isGameAdmin); + void signalNetClientPlayerChanged(unsigned playerId, QString newPlayerName); + void signalNetClientPlayerLeft(unsigned playerId, QString playerName); + void signalNetClientNewGameAdmin(unsigned playerId, QString playerName); + void signalNetClientGameListNew(unsigned gameId); + void signalNetClientGameListRemove(unsigned gameId); + void signalNetClientGameListUpdateMode(unsigned gameId, int mode); + void signalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); + void signalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); + void signalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); + void signalNetClientGameStart(boost::shared_ptr game); + void signalNetClientGameChatMsg(QString nickName, QString msg); + void signalNetClientLobbyChatMsg(QString nickName, QString msg); + void signalNetClientMsgBox(QString msg); - void signalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); - void signalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); - void signalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); + void signalLobbyPlayerJoined(unsigned playerId, QString nickName); + void signalLobbyPlayerKicked(QString nickName, QString byWhom, QString reason); + void signalLobbyPlayerLeft(unsigned playerId); + + void signalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); + void signalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void signalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); public slots: - void callAboutPokerthDialog(); - void callSettingsDialog(); - void callNewGameDialog(); - void callGameLobbyDialog(); - void callCreateNetworkGameDialog(); - void callJoinNetworkGameDialog(); - void showLobbyDialog(); - void callInternetGameLoginDialog(); - void joinGameLobby(); - void showClientDialog(); - void showNetworkStartDialog(); + void callAboutPokerthDialog(); + void callSettingsDialog(); + void callNewGameDialog(); + void callGameLobbyDialog(); + void callCreateNetworkGameDialog(); + void callJoinNetworkGameDialog(); + void showLobbyDialog(); + void callInternetGameLoginDialog(); + void joinGameLobby(); + void showClientDialog(); + void showNetworkStartDialog(); - void startNewLocalGame(newGameDialogImpl* =0); + void startNewLocalGame(newGameDialogImpl* =0); - void showTimeoutDialog(int msgID, unsigned duration); - void hideTimeoutDialog(); + void showTimeoutDialog(int msgID, unsigned duration); + void hideTimeoutDialog(); - void networkError(int, int); - void networkNotification(int); - void networkMessage(QString); + void networkError(int, int); + void networkNotification(int); + void networkMessage(QString); + + void networkStart(boost::shared_ptr game); + QStringList getPlayerNicksList(); - void networkStart(boost::shared_ptr game); - QStringList getPlayerNicksList(); - private: - ConfigFile *myConfig; + ConfigFile *myConfig; - boost::shared_ptr myGuiInterface; - boost::shared_ptr mySession; - boost::shared_ptr myServerGuiInterface; + boost::shared_ptr myGuiInterface; + boost::shared_ptr mySession; + boost::shared_ptr myServerGuiInterface; -// Dialogs - aboutPokerthImpl *myAboutPokerthDialog; - newGameDialogImpl *myNewGameDialog; - settingsDialogImpl *mySettingsDialog; - selectAvatarDialogImpl *mySelectAvatarDialog; - changeHumanPlayerNameDialogImpl *myChangeHumanPlayerNameDialog; - joinNetworkGameDialogImpl *myJoinNetworkGameDialog; - connectToServerDialogImpl *myConnectToServerDialog; - startNetworkGameDialogImpl *myStartNetworkGameDialog; - createNetworkGameDialogImpl *myCreateNetworkGameDialog; - gameLobbyDialogImpl *myGameLobbyDialog; - timeoutMsgBoxImpl *myTimeoutDialog; - startWindowImpl *myStartWindow; - serverListDialogImpl *myServerListDialog; - internetGameLoginDialogImpl *myInternetGameLoginDialog; - -friend class GuiWrapper; + // Dialogs + aboutPokerthImpl *myAboutPokerthDialog; + newGameDialogImpl *myNewGameDialog; + settingsDialogImpl *mySettingsDialog; + selectAvatarDialogImpl *mySelectAvatarDialog; + changeHumanPlayerNameDialogImpl *myChangeHumanPlayerNameDialog; + joinNetworkGameDialogImpl *myJoinNetworkGameDialog; + connectToServerDialogImpl *myConnectToServerDialog; + startNetworkGameDialogImpl *myStartNetworkGameDialog; + createNetworkGameDialogImpl *myCreateNetworkGameDialog; + gameLobbyDialogImpl *myGameLobbyDialog; + timeoutMsgBoxImpl *myTimeoutDialog; + startWindowImpl *myStartWindow; + serverListDialogImpl *myServerListDialog; + internetGameLoginDialogImpl *myInternetGameLoginDialog; + + friend class GuiWrapper; }; #endif diff --git a/src/session.cpp b/src/session.cpp index 7305dd6a..d9ec4cbf 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -44,495 +44,495 @@ using namespace std; Session::Session(GuiInterface *g, ConfigFile *c) -: currentGameNum(0), myGui(g), myConfig(c), myGameType(GAME_TYPE_NONE) + : currentGameNum(0), myGui(g), myConfig(c), myGameType(GAME_TYPE_NONE) { - myQtToolsInterface = CreateQtToolsWrapper(); + myQtToolsInterface = CreateQtToolsWrapper(); } Session::~Session() { - terminateNetworkClient(); - terminateNetworkServer(); - delete myConfig; - myConfig = 0; - delete myQtToolsInterface; - myQtToolsInterface = 0; + terminateNetworkClient(); + terminateNetworkServer(); + delete myConfig; + myConfig = 0; + delete myQtToolsInterface; + myQtToolsInterface = 0; } bool Session::init() { - myAvatarManager.reset(new AvatarManager( - myConfig->readConfigInt("ServerUsePutAvatars") == 1, - myConfig->readConfigString("ServerPutAvatarsAddress"), - myConfig->readConfigString("ServerPutAvatarsUser"), - myConfig->readConfigString("ServerPutAvatarsPassword") - )); - bool retVal = myAvatarManager->Init( - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("AppDataDir")), - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); - addOwnAvatar(myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("MyAvatar"))); - myAvatarManager->RemoveOldAvatarCacheEntries(); - return retVal; + myAvatarManager.reset(new AvatarManager( + myConfig->readConfigInt("ServerUsePutAvatars") == 1, + myConfig->readConfigString("ServerPutAvatarsAddress"), + myConfig->readConfigString("ServerPutAvatarsUser"), + myConfig->readConfigString("ServerPutAvatarsPassword") + )); + bool retVal = myAvatarManager->Init( + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("AppDataDir")), + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); + addOwnAvatar(myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("MyAvatar"))); + myAvatarManager->RemoveOldAvatarCacheEntries(); + return retVal; } void Session::init(boost::shared_ptr manager) { - myAvatarManager = manager; + myAvatarManager = manager; } void Session::addOwnAvatar(const std::string &avatarFile) { - myAvatarManager->AddSingleAvatar(avatarFile); + myAvatarManager->AddSingleAvatar(avatarFile); } void Session::startLocalGame(const GameData &gameData, const StartData &startData) { - myGameType = GAME_TYPE_LOCAL; + myGameType = GAME_TYPE_LOCAL; - currentGame.reset(); - currentGameNum++; + currentGame.reset(); + currentGameNum++; - myGui->initGui(gameData.guiSpeed); + myGui->initGui(gameData.guiSpeed); - PlayerDataList playerDataList; - for(int i = 0; i < startData.numberOfPlayers; i++) { + PlayerDataList playerDataList; + for(int i = 0; i < startData.numberOfPlayers; i++) { - //Namen und Avatarpfad abfragen - ostringstream myName; - if (i==0) { myName << "MyName"; } - else { myName << "Opponent" << i << "Name"; } - ostringstream myAvatar; - if (i==0) { myAvatar << "MyAvatar"; } - else { myAvatar << "Opponent" << i << "Avatar"; } + //Namen und Avatarpfad abfragen + ostringstream myName; + if (i==0) { myName << "MyName"; } + else { myName << "Opponent" << i << "Name"; } + ostringstream myAvatar; + if (i==0) { myAvatar << "MyAvatar"; } + else { myAvatar << "Opponent" << i << "Avatar"; } - //PlayerData erzeugen - // UniqueId = PlayerNumber for local games. - boost::shared_ptr playerData(new PlayerData(i, i, - i == 0 ? PLAYER_TYPE_HUMAN : PLAYER_TYPE_COMPUTER, - PLAYER_RIGHTS_NORMAL, - i == 0)); - playerData->SetName(myConfig->readConfigString(myName.str())); - playerData->SetAvatarFile(myConfig->readConfigString(myAvatar.str())); + //PlayerData erzeugen + // UniqueId = PlayerNumber for local games. + boost::shared_ptr playerData(new PlayerData(i, i, + i == 0 ? PLAYER_TYPE_HUMAN : PLAYER_TYPE_COMPUTER, + PLAYER_RIGHTS_NORMAL, + i == 0)); + playerData->SetName(myConfig->readConfigString(myName.str())); + playerData->SetAvatarFile(myConfig->readConfigString(myAvatar.str())); - playerDataList.push_back(playerData); - } - // EngineFactory erstellen - boost::shared_ptr factory(new LocalEngineFactory(myConfig)); // LocalEngine erstellen + playerDataList.push_back(playerData); + } + // EngineFactory erstellen + boost::shared_ptr factory(new LocalEngineFactory(myConfig)); // LocalEngine erstellen - currentGame.reset(new Game(myGui, factory, playerDataList, gameData, startData, currentGameNum)); + currentGame.reset(new Game(myGui, factory, playerDataList, gameData, startData, currentGameNum)); - //// SPIEL-SCHLEIFE - currentGame->initHand(); - currentGame->startHand(); - // SPIEL-SCHLEIFE + //// SPIEL-SCHLEIFE + currentGame->initHand(); + currentGame->startHand(); + // SPIEL-SCHLEIFE } void Session::startClientGame(boost::shared_ptr game) { - currentGameNum++; + currentGameNum++; - currentGame = game; + currentGame = game; } Game *Session::getCurrentGame() { - return currentGame.get(); + return currentGame.get(); } GuiInterface *Session::getGui() { - return myGui; + return myGui; } Session::GameType Session::getGameType() { - return myGameType; + return myGameType; } boost::shared_ptr Session::getAvatarManager() { - return myAvatarManager; + return myAvatarManager; } void Session::startInternetClient() { - if (myNetClient || !myGui) - { - assert(false); - return; - } - myGameType = GAME_TYPE_INTERNET; + if (myNetClient || !myGui) + { + assert(false); + return; + } + myGameType = GAME_TYPE_INTERNET; - myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); - bool useAvatarServer = myConfig->readConfigInt("UseAvatarServer") != 0; + myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); + bool useAvatarServer = myConfig->readConfigInt("UseAvatarServer") != 0; - myNetClient->Init( - myConfig->readConfigString("InternetServerAddress"), + myNetClient->Init( + myConfig->readConfigString("InternetServerAddress"), #ifdef POKERTH_IS_07BETA - "pokerth.net/serverlist07.xml.z", 1, + "pokerth.net/serverlist07.xml.z", 1, #else - myConfig->readConfigString("InternetServerListAddress"), - myConfig->readConfigInt("InternetServerConfigMode") == 0, + myConfig->readConfigString("InternetServerListAddress"), + myConfig->readConfigInt("InternetServerConfigMode") == 0, #endif - myConfig->readConfigInt("InternetServerPort"), - myConfig->readConfigInt("InternetServerUseIpv6") == 1, - myConfig->readConfigInt("InternetServerUseSctp") == 1, - useAvatarServer ? myConfig->readConfigString("AvatarServerAddress") : "", - myConfig->readConfigString("MyName"), - myConfig->readConfigString("MyAvatar"), - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); - myNetClient->Run(); + myConfig->readConfigInt("InternetServerPort"), + myConfig->readConfigInt("InternetServerUseIpv6") == 1, + myConfig->readConfigInt("InternetServerUseSctp") == 1, + useAvatarServer ? myConfig->readConfigString("AvatarServerAddress") : "", + myConfig->readConfigString("MyName"), + myConfig->readConfigString("MyAvatar"), + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); + myNetClient->Run(); } void Session::startNetworkClient(const string &serverAddress, unsigned serverPort, bool ipv6, bool sctp) { - if (myNetClient || !myGui) - { - assert(false); - return; - } - myGameType = GAME_TYPE_NETWORK; + if (myNetClient || !myGui) + { + assert(false); + return; + } + myGameType = GAME_TYPE_NETWORK; - myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); - myNetClient->Init( - serverAddress, - "", - false, - serverPort, - ipv6, - sctp, - "", // no avatar server - myConfig->readConfigString("MyName"), - myConfig->readConfigString("MyAvatar"), - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); - myNetClient->Run(); - myNetClient->SendJoinFirstGame(""); + myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); + myNetClient->Init( + serverAddress, + "", + false, + serverPort, + ipv6, + sctp, + "", // no avatar server + myConfig->readConfigString("MyName"), + myConfig->readConfigString("MyAvatar"), + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); + myNetClient->Run(); + myNetClient->SendJoinFirstGame(""); } void Session::startNetworkClientForLocalServer(const GameData &gameData) { - if (myNetClient || !myGui) - { - assert(false); - return; - } - myGameType = GAME_TYPE_NETWORK; + if (myNetClient || !myGui) + { + assert(false); + return; + } + myGameType = GAME_TYPE_NETWORK; - myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); - bool useIpv6 = myConfig->readConfigInt("ServerUseIpv6") == 1; - const char *loopbackAddr = useIpv6 ? "::1" : "127.0.0.1"; - myNetClient->Init( - loopbackAddr, - "", - false, - myConfig->readConfigInt("ServerPort"), - useIpv6, - myConfig->readConfigInt("ServerUseSctp") == 1, - "", // no avatar server - myConfig->readConfigString("MyName"), - myConfig->readConfigString("MyAvatar"), - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); - myNetClient->Run(); - myNetClient->SendCreateGame(gameData, NET_DEFAULT_GAME, ""); + myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); + bool useIpv6 = myConfig->readConfigInt("ServerUseIpv6") == 1; + const char *loopbackAddr = useIpv6 ? "::1" : "127.0.0.1"; + myNetClient->Init( + loopbackAddr, + "", + false, + myConfig->readConfigInt("ServerPort"), + useIpv6, + myConfig->readConfigInt("ServerUseSctp") == 1, + "", // no avatar server + myConfig->readConfigString("MyName"), + myConfig->readConfigString("MyAvatar"), + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); + myNetClient->Run(); + myNetClient->SendCreateGame(gameData, NET_DEFAULT_GAME, ""); } void Session::terminateNetworkClient() { - if (!myNetClient) - return; // already terminated - myNetClient->SignalTermination(); - // Give the threads some time to terminate. - if (myNetClient->Join(NET_CLIENT_TERMINATE_TIMEOUT_MSEC)) - myNetClient.reset(); + if (!myNetClient) + return; // already terminated + myNetClient->SignalTermination(); + // Give the threads some time to terminate. + if (myNetClient->Join(NET_CLIENT_TERMINATE_TIMEOUT_MSEC)) + myNetClient.reset(); - // If termination fails, leave a memory leak to prevent a crash. - myGameType = GAME_TYPE_NONE; + // If termination fails, leave a memory leak to prevent a crash. + myGameType = GAME_TYPE_NONE; } void Session::clientCreateGame(const GameData &gameData, const string &name, const string &password) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendCreateGame(gameData, name, password); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendCreateGame(gameData, name, password); } void Session::clientJoinGame(unsigned gameId, const std::string &password) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendJoinGame(gameId, password); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendJoinGame(gameId, password); } void Session::startNetworkServer(bool dedicated) { - if (myNetServer) - { - assert(false); - return; - } + if (myNetServer) + { + assert(false); + return; + } - myNetServer.reset(new ServerManager(*myGui, myConfig, *myAvatarManager)); + myNetServer.reset(new ServerManager(*myGui, myConfig, *myAvatarManager)); - boost::shared_ptr tmpIrcAdminThread; - boost::shared_ptr tmpIrcLobbyThread; - if (myConfig->readConfigInt("UseAdminIRC")) - { - tmpIrcAdminThread = boost::shared_ptr(new IrcThread(&myNetServer->GetAdminBot())); + boost::shared_ptr tmpIrcAdminThread; + boost::shared_ptr tmpIrcLobbyThread; + if (myConfig->readConfigInt("UseAdminIRC")) + { + tmpIrcAdminThread = boost::shared_ptr(new IrcThread(&myNetServer->GetAdminBot())); - tmpIrcAdminThread->Init( - myConfig->readConfigString("AdminIRCServerAddress"), - myConfig->readConfigInt("AdminIRCServerPort"), - myConfig->readConfigInt("AdminIRCServerUseIpv6") == 1, - myConfig->readConfigString("AdminIRCServerNick"), - myConfig->readConfigString("AdminIRCChannel"), - myConfig->readConfigString("AdminIRCChannelPassword")); - } - - if (myConfig->readConfigInt("UseLobbyIRC")) - { - tmpIrcLobbyThread = boost::shared_ptr(new IrcThread(&myNetServer->GetLobbyBot())); + tmpIrcAdminThread->Init( + myConfig->readConfigString("AdminIRCServerAddress"), + myConfig->readConfigInt("AdminIRCServerPort"), + myConfig->readConfigInt("AdminIRCServerUseIpv6") == 1, + myConfig->readConfigString("AdminIRCServerNick"), + myConfig->readConfigString("AdminIRCChannel"), + myConfig->readConfigString("AdminIRCChannelPassword")); + } - tmpIrcLobbyThread->Init( - myConfig->readConfigString("LobbyIRCServerAddress"), - myConfig->readConfigInt("LobbyIRCServerPort"), - myConfig->readConfigInt("LobbyIRCServerUseIpv6") == 1, - myConfig->readConfigString("LobbyIRCServerNick"), - myConfig->readConfigString("LobbyIRCChannel"), - myConfig->readConfigString("LobbyIRCChannelPassword")); - } + if (myConfig->readConfigInt("UseLobbyIRC")) + { + tmpIrcLobbyThread = boost::shared_ptr(new IrcThread(&myNetServer->GetLobbyBot())); - ServerMode mode; - if (dedicated) - { - #ifdef POKERTH_OFFICIAL_SERVER - mode = SERVER_MODE_INTERNET_AUTH; - #else - mode = SERVER_MODE_INTERNET_NOAUTH; - #endif - } - else - mode = SERVER_MODE_LAN; + tmpIrcLobbyThread->Init( + myConfig->readConfigString("LobbyIRCServerAddress"), + myConfig->readConfigInt("LobbyIRCServerPort"), + myConfig->readConfigInt("LobbyIRCServerUseIpv6") == 1, + myConfig->readConfigString("LobbyIRCServerNick"), + myConfig->readConfigString("LobbyIRCChannel"), + myConfig->readConfigString("LobbyIRCChannelPassword")); + } - myNetServer->Init( - myConfig->readConfigInt("ServerPort"), - myConfig->readConfigInt("ServerUseIpv6") == 1, - myConfig->readConfigInt("ServerUseSctp") == 1 ? TRANSPORT_PROTOCOL_TCP_SCTP : TRANSPORT_PROTOCOL_TCP, - mode, - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir")), - tmpIrcAdminThread, - tmpIrcLobbyThread - ); + ServerMode mode; + if (dedicated) + { +#ifdef POKERTH_OFFICIAL_SERVER + mode = SERVER_MODE_INTERNET_AUTH; +#else + mode = SERVER_MODE_INTERNET_NOAUTH; +#endif + } + else + mode = SERVER_MODE_LAN; - myNetServer->RunAll(); + myNetServer->Init( + myConfig->readConfigInt("ServerPort"), + myConfig->readConfigInt("ServerUseIpv6") == 1, + myConfig->readConfigInt("ServerUseSctp") == 1 ? TRANSPORT_PROTOCOL_TCP_SCTP : TRANSPORT_PROTOCOL_TCP, + mode, + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir")), + tmpIrcAdminThread, + tmpIrcLobbyThread + ); + + myNetServer->RunAll(); } void Session::terminateNetworkServer() { - if (!myNetServer) - return; // already terminated - myNetServer->SignalTerminationAll(); - // Give the thread some time to terminate. - if (myNetServer->JoinAll(true)) - myNetServer.reset(); - // If termination fails, leave a memory leak to prevent a crash. + if (!myNetServer) + return; // already terminated + myNetServer->SignalTerminationAll(); + // Give the thread some time to terminate. + if (myNetServer->JoinAll(true)) + myNetServer.reset(); + // If termination fails, leave a memory leak to prevent a crash. } bool Session::pollNetworkServerTerminated() { - bool retVal = false; - if (!myNetServer) - retVal = true; // already terminated - else - { - myNetServer->Process(); - if (myNetServer->JoinAll(false)) - retVal = true; - } - return retVal; + bool retVal = false; + if (!myNetServer) + retVal = true; // already terminated + else + { + myNetServer->Process(); + if (myNetServer->JoinAll(false)) + retVal = true; + } + return retVal; } void Session::sendLeaveCurrentGame() { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendLeaveCurrentGame(); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendLeaveCurrentGame(); } void Session::sendStartEvent(bool fillUpWithCpuPlayers) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendStartEvent(fillUpWithCpuPlayers); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendStartEvent(fillUpWithCpuPlayers); } void Session::sendClientPlayerAction() { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendPlayerAction(); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendPlayerAction(); } void Session::sendGameChatMessage(const std::string &message) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendGameChatMessage(message); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendGameChatMessage(message); } void Session::sendLobbyChatMessage(const std::string &message) { - if (!myNetClient) - return; - myNetClient->SendLobbyChatMessage(message); + if (!myNetClient) + return; + myNetClient->SendLobbyChatMessage(message); } void Session::kickPlayer(unsigned playerId) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendKickPlayer(playerId); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendKickPlayer(playerId); } void Session::resetNetworkTimeout() { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendResetTimeout(); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendResetTimeout(); } void Session::kickPlayer(const string &playerName) { - if (!myNetClient) - return; // only act if client is running. - unsigned playerId; - if (myNetClient->GetPlayerIdFromName(playerName, playerId)) - kickPlayer(playerId); + if (!myNetClient) + return; // only act if client is running. + unsigned playerId; + if (myNetClient->GetPlayerIdFromName(playerName, playerId)) + kickPlayer(playerId); } void Session::startVoteKickPlayer(unsigned playerId) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendAskKickPlayer(playerId); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendAskKickPlayer(playerId); } void Session::selectServer(unsigned serverId) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SelectServer(serverId); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SelectServer(serverId); } void -Session::setLogin(const std::string &userName, const std::string &password, bool isGuest) + Session::setLogin(const std::string &userName, const std::string &password, bool isGuest) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SetLogin(userName, password, isGuest); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SetLogin(userName, password, isGuest); } void -Session::invitePlayerToCurrentGame(unsigned playerId) + Session::invitePlayerToCurrentGame(unsigned playerId) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendInvitePlayerToCurrentGame(playerId); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendInvitePlayerToCurrentGame(playerId); } void -Session::acceptGameInvitation(unsigned gameId) + Session::acceptGameInvitation(unsigned gameId) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendJoinGame(gameId, ""); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendJoinGame(gameId, ""); } void -Session::rejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason) + Session::rejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendRejectGameInvitation(gameId, reason); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendRejectGameInvitation(gameId, reason); } void Session::voteKick(bool doKick) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendVoteKick(doKick); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendVoteKick(doKick); } bool Session::isNetworkClientRunning() const { - // This, and every place which calls this, is a HACK. - return myNetClient.get() != NULL; + // This, and every place which calls this, is a HACK. + return myNetClient.get() != NULL; } bool Session::isNetworkServerRunning() const { - // This, and every place which calls this, is a HACK. - return myNetServer.get() != NULL; + // This, and every place which calls this, is a HACK. + return myNetServer.get() != NULL; } ServerInfo Session::getClientServerInfo(unsigned serverId) const { - ServerInfo info; - if (myNetClient) - info = myNetClient->GetServerInfo(serverId); - return info; + ServerInfo info; + if (myNetClient) + info = myNetClient->GetServerInfo(serverId); + return info; } GameInfo Session::getClientGameInfo(unsigned playerId) const { - GameInfo info; - if (myNetClient) - info = myNetClient->GetGameInfo(playerId); - return info; + GameInfo info; + if (myNetClient) + info = myNetClient->GetGameInfo(playerId); + return info; } PlayerInfo Session::getClientPlayerInfo(unsigned playerId) const { - PlayerInfo info; - if (myNetClient) - info = myNetClient->GetPlayerInfo(playerId); - return info; + PlayerInfo info; + if (myNetClient) + info = myNetClient->GetPlayerInfo(playerId); + return info; } ServerStats Session::getClientStats() const { - ServerStats stats; - if (myNetClient) - stats = myNetClient->GetStatData(); - return stats; + ServerStats stats; + if (myNetClient) + stats = myNetClient->GetStatData(); + return stats; } unsigned Session::getClientCurrentGameId() const { - unsigned id = 0; - if (myNetClient) - id = myNetClient->GetGameId(); - return id; + unsigned id = 0; + if (myNetClient) + id = myNetClient->GetGameId(); + return id; } unsigned Session::getClientUniquePlayerId() const { - unsigned id = 0; - if (myNetClient) - id = myNetClient->GetGuiPlayerId(); - return id; + unsigned id = 0; + if (myNetClient) + id = myNetClient->GetGuiPlayerId(); + return id; } bool Session::getAvatarFile(const MD5Buf &avatarMD5, std::string &fileName) { - bool retVal = false; - if (myAvatarManager.get()) - { - string tmpFileName; - retVal = myAvatarManager->GetAvatarFileName(avatarMD5, tmpFileName); - if (retVal) - fileName = myQtToolsInterface->stringToUtf8(tmpFileName); - } - return retVal; + bool retVal = false; + if (myAvatarManager.get()) + { + string tmpFileName; + retVal = myAvatarManager->GetAvatarFileName(avatarMD5, tmpFileName); + if (retVal) + fileName = myQtToolsInterface->stringToUtf8(tmpFileName); + } + return retVal; } diff --git a/src/session.h b/src/session.h index 4870ae89..c57b1e76 100755 --- a/src/session.h +++ b/src/session.h @@ -41,85 +41,85 @@ class QtToolsInterface; class Session{ public: - Session(GuiInterface*, ConfigFile*); + Session(GuiInterface*, ConfigFile*); - ~Session(); + ~Session(); - enum GameType { GAME_TYPE_NONE, GAME_TYPE_LOCAL, GAME_TYPE_NETWORK, GAME_TYPE_INTERNET }; + enum GameType { GAME_TYPE_NONE, GAME_TYPE_LOCAL, GAME_TYPE_NETWORK, GAME_TYPE_INTERNET }; - // Only one of the two inits should be called. - bool init(); - void init(boost::shared_ptr manager); + // Only one of the two inits should be called. + bool init(); + void init(boost::shared_ptr manager); - void addOwnAvatar(const std::string &avatarFile); + void addOwnAvatar(const std::string &avatarFile); - void startLocalGame(const GameData &gameData, const StartData &startData); - void startClientGame(boost::shared_ptr game); + void startLocalGame(const GameData &gameData, const StartData &startData); + void startClientGame(boost::shared_ptr game); - Game *getCurrentGame(); - GuiInterface *getGui(); - GameType getGameType(); + Game *getCurrentGame(); + GuiInterface *getGui(); + GameType getGameType(); - boost::shared_ptr getAvatarManager(); + boost::shared_ptr getAvatarManager(); - void startInternetClient(); - void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, bool sctp); - void startNetworkClientForLocalServer(const GameData &gameData); - void terminateNetworkClient(); - void clientCreateGame(const GameData &gameData, const std::string &name, const std::string &password); - void clientJoinGame(unsigned gameId, const std::string &password); + void startInternetClient(); + void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, bool sctp); + void startNetworkClientForLocalServer(const GameData &gameData); + void terminateNetworkClient(); + void clientCreateGame(const GameData &gameData, const std::string &name, const std::string &password); + void clientJoinGame(unsigned gameId, const std::string &password); - void startNetworkServer(bool dedicated); - void sendLeaveCurrentGame(); - void sendStartEvent(bool fillUpWithCpuPlayers); - void terminateNetworkServer(); - bool pollNetworkServerTerminated(); + void startNetworkServer(bool dedicated); + void sendLeaveCurrentGame(); + void sendStartEvent(bool fillUpWithCpuPlayers); + void terminateNetworkServer(); + bool pollNetworkServerTerminated(); - void sendClientPlayerAction(); + void sendClientPlayerAction(); - void sendGameChatMessage(const std::string &message); - void sendLobbyChatMessage(const std::string &message); - void kickPlayer(unsigned playerId); - void kickPlayer(const std::string &playerName); - void startVoteKickPlayer(unsigned playerId); - void voteKick(bool doKick); - void selectServer(unsigned serverId); - void setLogin(const std::string &userName, const std::string &password, bool isGuest); + void sendGameChatMessage(const std::string &message); + void sendLobbyChatMessage(const std::string &message); + void kickPlayer(unsigned playerId); + void kickPlayer(const std::string &playerName); + void startVoteKickPlayer(unsigned playerId); + void voteKick(bool doKick); + void selectServer(unsigned serverId); + void setLogin(const std::string &userName, const std::string &password, bool isGuest); - void invitePlayerToCurrentGame(unsigned playerId); - void acceptGameInvitation(unsigned gameId); - void rejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason); + void invitePlayerToCurrentGame(unsigned playerId); + void acceptGameInvitation(unsigned gameId); + void rejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason); - void resetNetworkTimeout(); + void resetNetworkTimeout(); - bool isNetworkClientRunning() const; // TODO hack - bool isNetworkServerRunning() const; // TODO hack + bool isNetworkClientRunning() const; // TODO hack + bool isNetworkServerRunning() const; // TODO hack - ServerInfo getClientServerInfo(unsigned serverId) const; - GameInfo getClientGameInfo(unsigned gameId) const; - PlayerInfo getClientPlayerInfo(unsigned playerId) const; - ServerStats getClientStats() const; - unsigned getClientCurrentGameId() const; - unsigned getClientUniquePlayerId() const; + ServerInfo getClientServerInfo(unsigned serverId) const; + GameInfo getClientGameInfo(unsigned gameId) const; + PlayerInfo getClientPlayerInfo(unsigned playerId) const; + ServerStats getClientStats() const; + unsigned getClientCurrentGameId() const; + unsigned getClientUniquePlayerId() const; - bool getAvatarFile(const MD5Buf &avatarMD5, std::string &fileName); + bool getAvatarFile(const MD5Buf &avatarMD5, std::string &fileName); private: - int currentGameNum; + int currentGameNum; - std::string myIrcNick; + std::string myIrcNick; - boost::shared_ptr myNetClient; - boost::shared_ptr myNetServer; + boost::shared_ptr myNetClient; + boost::shared_ptr myNetServer; - boost::shared_ptr myAvatarManager; + boost::shared_ptr myAvatarManager; - boost::shared_ptr currentGame; - GuiInterface *myGui; - ConfigFile *myConfig; - GameType myGameType; - QtToolsInterface *myQtToolsInterface; + boost::shared_ptr currentGame; + GuiInterface *myGui; + ConfigFile *myConfig; + GameType myGameType; + QtToolsInterface *myQtToolsInterface; }; #endif