2011-07-02 23:03:18 +00:00
/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2011 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
2011-07-03 19:45:08 +00:00
*****************************************************************************/
#include "gamelobbydialogimpl.h"
2009-06-14 22:56:49 +00:00
#include "mygamelistsortfilterproxymodel.h"
2010-08-29 21:50:18 +00:00
#include "mynicklistsortfilterproxymodel.h"
2008-09-09 22:21:41 +00:00
#include "startwindowimpl.h"
2009-08-17 23:20:58 +00:00
#include "chattools.h"
2007-09-27 00:35:30 +00:00
#include "changecompleteblindsdialogimpl.h"
2007-08-21 12:34:33 +00:00
#include "session.h"
#include "configfile.h"
#include "gamedata.h"
2010-03-29 13:08:59 +00:00
#include "game_defs.h"
2007-09-05 19:14:34 +00:00
#include <net/socket_msg.h>
2010-03-28 22:17:18 +00:00
#include "mymessagedialogimpl.h"
2007-08-20 21:23:03 +00:00
2010-03-30 17:30:33 +00:00
using namespace std ;
2011-04-10 08:32:40 +00:00
2008-09-09 22:21:41 +00:00
gameLobbyDialogImpl :: gameLobbyDialogImpl ( startWindowImpl * parent , ConfigFile * c )
2011-02-11 20:02:08 +00:00
: QDialog ( parent ), myW ( NULL ), myStartWindow ( parent ), myConfig ( c ), currentGameName ( "" ), myPlayerId ( 0 ), isGameAdministrator ( false ), inGame ( false ), guestMode ( false ), blinkingButtonAnimationState ( true ), myChat ( NULL ), keyUpCounter ( 0 ), infoMsgToShowId ( 0 ), currentInvitationGameId ( 0 ), inviteDialogIsCurrentlyShown ( false ), autoStartTimerCounter ( 0 )
2007-08-20 21:23:03 +00:00
{
2007-11-28 22:00:42 +00:00
2007-12-04 01:37:43 +00:00
#ifdef __APPLE__
2011-02-11 20:02:08 +00:00
setWindowModality ( Qt :: ApplicationModal );
setWindowFlags ( Qt :: WindowSystemMenuHint | Qt :: CustomizeWindowHint | Qt :: Dialog );
2010-03-30 12:25:30 +00:00
#endif
2011-02-11 20:02:08 +00:00
setupUi ( this );
2010-03-28 22:17:18 +00:00
2011-02-11 20:02:08 +00:00
myAppDataPath = QString :: fromUtf8 ( myConfig -> readConfigString ( "AppDataDir" ). c_str ());
2010-03-27 21:55:34 +00:00
2011-02-11 20:02:08 +00:00
//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 );
2010-01-05 12:53:37 +00:00
2011-10-27 09:04:19 +00:00
//wait start game message for rejoin
waitRejoinStartGameMsgBox = new QMessageBox ( this );
2011-10-28 20:41:58 +00:00
waitRejoinStartGameMsgBox -> setText ( tr ( "Waiting for the start of the next hand to rejoin the game ..." ));
2011-10-27 09:04:19 +00:00
waitRejoinStartGameMsgBox -> setWindowModality ( Qt :: NonModal );
#ifdef __APPLE__
waitRejoinStartGameMsgBox -> setWindowFlags ( Qt :: WindowSystemMenuHint | Qt :: CustomizeWindowHint | Qt :: Dialog );
#endif
waitRejoinStartGameMsgBox -> setStandardButtons ( QMessageBox :: NoButton );
2011-11-06 00:30:34 +00:00
inviteOnlyInfoMsgBox = new myMessageDialogImpl ( myConfig , this );
2011-10-27 09:04:19 +00:00
2011-02-11 20:02:08 +00:00
waitStartGameMsgBoxTimer = new QTimer ( this );
waitStartGameMsgBoxTimer -> setSingleShot ( TRUE );
blinkingButtonAnimationTimer = new QTimer ( this );
blinkingButtonAnimationTimer -> setInterval ( 1000 );
autoStartTimer = new QTimer ( this );
autoStartTimer -> setInterval ( 1000 );
showInfoMsgBoxTimer = new QTimer ( this );
showInfoMsgBoxTimer -> setSingleShot ( TRUE );
//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 ();
//prepare overlay
autoStartTimerOverlay = new QLabel ( scrollArea_gameInfos );
autoStartTimerOverlay -> hide ();
autoStartTimerOverlay -> setWordWrap ( TRUE );
autoStartTimerOverlay -> setMaximumWidth ( 190 );
autoStartTimerOverlay -> setMinimumWidth ( 190 );
autoStartTimerOverlay -> setTextFormat ( Qt :: RichText );
autoStartTimerOverlay -> setAlignment ( Qt :: AlignCenter );
autoStartTimerOverlay -> setAutoFillBackground ( TRUE );
autoStartTimerOverlay -> setFrameStyle ( QFrame :: StyledPanel );
QPalette p ;
p . setColor ( QPalette :: Background , QColor ( 255 , 255 , 255 , 210 ));
autoStartTimerOverlay -> setPalette ( p );
2010-09-05 02:00:23 +00:00
2009-06-17 00:00:10 +00:00
2011-02-11 20:02:08 +00:00
myGameListModel = new QStandardItemModel ( this );
myGameListSortFilterProxyModel = new MyGameListSortFilterProxyModel ( this );
myGameListSortFilterProxyModel -> setSourceModel ( myGameListModel );
myGameListSortFilterProxyModel -> setDynamicSortFilter ( TRUE );
treeView_GameList -> setModel ( myGameListSortFilterProxyModel );
2010-03-27 21:55:34 +00:00
2011-02-11 20:02:08 +00:00
myGameListSelectionModel = treeView_GameList -> selectionModel ();
2007-10-10 10:06:09 +00:00
2011-02-11 20:02:08 +00:00
QStringList headerList ;
2011-03-04 21:03:42 +00:00
headerList << tr ( "Game" ) << tr ( "Players" ) << tr ( "State" ) << tr ( "T" ) << tr ( "P" );
2011-02-11 20:02:08 +00:00
myGameListModel -> setHorizontalHeaderLabels ( headerList );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
treeView_GameList -> setColumnWidth ( 0 , 190 );
treeView_GameList -> setColumnWidth ( 1 , 65 );
treeView_GameList -> setColumnWidth ( 2 , 65 );
treeView_GameList -> setColumnWidth ( 3 , 40 );
treeView_GameList -> setColumnWidth ( 4 , 40 );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
myNickListModel = new QStandardItemModel ( this );
myNickListSortFilterProxyModel = new MyNickListSortFilterProxyModel ( this );
myNickListSortFilterProxyModel -> setSourceModel ( myNickListModel );
myNickListSortFilterProxyModel -> setDynamicSortFilter ( TRUE );
myNickListSortFilterProxyModel -> setSortCaseSensitivity ( Qt :: CaseInsensitive );
2010-08-08 23:14:00 +00:00
2011-02-11 20:02:08 +00:00
treeView_NickList -> setModel ( myNickListSortFilterProxyModel );
myNickListSelectionModel = treeView_NickList -> selectionModel ();
2010-08-08 23:14:00 +00:00
2011-02-11 20:02:08 +00:00
QStringList headerList2 ;
headerList2 << tr ( "Available Players" );
myNickListModel -> setHorizontalHeaderLabels ( headerList2 );
treeView_NickList -> sortByColumn ( 0 , Qt :: AscendingOrder );
2010-08-08 23:14:00 +00:00
2011-02-11 20:02:08 +00:00
myChat = new ChatTools ( lineEdit_ChatInput , myConfig , INET_LOBBY_CHAT , textBrowser_ChatDisplay , myNickListModel , this );
2010-08-08 23:14:00 +00:00
2011-02-11 20:02:08 +00:00
nickListContextMenu = new QMenu ();
nickListInviteAction = new QAction ( QIcon ( ":/gfx/list_add_user.png" ), tr ( "Invite player" ), nickListContextMenu );
nickListContextMenu -> addAction ( nickListInviteAction );
nickListIgnorePlayerAction = new QAction ( QIcon ( ":/gfx/im-ban-user.png" ), tr ( "Ignore player" ), nickListContextMenu );
nickListContextMenu -> addAction ( nickListIgnorePlayerAction );
nickListPlayerInfoSubMenu = nickListContextMenu -> addMenu ( QIcon ( ":/gfx/dialog-information.png" ), tr ( "Player infos ..." ));
nickListPlayerInGameInfo = new QAction ( nickListContextMenu );
nickListPlayerInfoSubMenu -> addAction ( nickListPlayerInGameInfo );
2011-03-05 21:20:08 +00:00
nickListOpenPlayerStats = new QAction ( QIcon ( ":/gfx/view-statistics.png" ), tr ( "Show player stats" ), nickListContextMenu );
nickListContextMenu -> addAction ( nickListOpenPlayerStats );
connectedPlayersListPlayerInfoSubMenu = new QMenu ();
connectedPlayersListPlayerInfoSubMenu -> addAction ( nickListOpenPlayerStats );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 & ) ) );
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 ( autoStartTimer , SIGNAL ( timeout ()), this , SLOT ( updateAutoStartTimer () ));
connect ( showInfoMsgBoxTimer , SIGNAL ( timeout ()), this , SLOT ( showInfoMsgBox () ));
connect ( comboBox_gameListFilter , SIGNAL ( currentIndexChanged ( int )), this , SLOT ( changeGameListFilter ( int )));
connect ( comboBox_nickListFilter , SIGNAL ( currentIndexChanged ( int )), this , SLOT ( changeNickListFilter ( int )));
connect ( treeView_NickList , SIGNAL ( customContextMenuRequested ( QPoint )), this , SLOT ( showNickListContextMenu ( QPoint ) ) );
2011-03-05 21:20:08 +00:00
connect ( treeWidget_connectedPlayers , SIGNAL ( customContextMenuRequested ( QPoint )), this , SLOT ( showConnectedPlayersContextMenu ( QPoint ) ) );
2011-02-11 20:02:08 +00:00
connect ( nickListInviteAction , SIGNAL ( triggered ()), this , SLOT ( invitePlayerToCurrentGame () ));
connect ( nickListIgnorePlayerAction , SIGNAL ( triggered ()), this , SLOT ( putPlayerOnIgnoreList () ));
2011-03-05 21:20:08 +00:00
connect ( nickListOpenPlayerStats , SIGNAL ( triggered ()), this , SLOT ( openPlayerStats () ));
2011-02-11 20:02:08 +00:00
connect ( lineEdit_searchForPlayers , SIGNAL ( textChanged ( QString )), this , SLOT ( searchForPlayerRegExpChanged ()));
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
lineEdit_searchForPlayers -> installEventFilter ( this );
lineEdit_ChatInput -> installEventFilter ( this );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
clearDialog ();
2010-09-05 02:00:23 +00:00
2007-08-20 21:23:03 +00:00
}
void gameLobbyDialogImpl :: exec ()
{
2010-09-05 02:00:23 +00:00
2011-02-11 20:02:08 +00:00
if ( myConfig -> readConfigInt ( "UseLobbyChat" )) {
groupBox_lobbyChat -> show ();
} else {
groupBox_lobbyChat -> hide ();
}
readDialogSettings ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
PlayerInfo playerInfo ( mySession -> getClientPlayerInfo ( mySession -> getClientUniquePlayerId ()));
if ( playerInfo . isGuest ) {
guestUserMode ();
} else {
registeredUserMode ();
}
2010-03-24 21:17:03 +00:00
2011-02-11 20:02:08 +00:00
QDialog :: exec ();
2007-10-18 20:58:56 +00:00
2011-02-11 20:02:08 +00:00
waitStartGameMsgBoxTimer -> stop ();
2011-11-06 00:30:34 +00:00
closeAllChildDialogs ();
2007-08-20 21:23:03 +00:00
}
gameLobbyDialogImpl ::~ gameLobbyDialogImpl ()
{
2011-02-11 20:02:08 +00:00
delete myChat ;
myChat = NULL ;
2007-09-07 20:26:13 +00:00
2011-11-06 00:30:34 +00:00
delete inviteOnlyInfoMsgBox ;
inviteOnlyInfoMsgBox = NULL ;
2007-08-20 21:23:03 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: setSession ( boost :: shared_ptr < Session > session )
{
mySession = session ;
myChat -> setSession ( mySession );
2009-08-18 00:46:18 +00:00
}
2007-08-21 12:34:33 +00:00
void gameLobbyDialogImpl :: createGame ()
{
2011-02-11 20:02:08 +00:00
assert ( mySession );
2007-08-21 12:34:33 +00:00
2011-02-11 20:02:08 +00:00
myCreateInternetGameDialog = new createInternetGameDialogImpl ( this , myConfig );
PlayerInfo playerInfo ( mySession -> getClientPlayerInfo ( mySession -> getClientUniquePlayerId ()));
myCreateInternetGameDialog -> exec ( guestMode , QString :: fromUtf8 ( playerInfo . playerName . c_str ()));
2007-09-05 19:14:34 +00:00
2011-02-11 20:02:08 +00:00
if ( myCreateInternetGameDialog -> result () == QDialog :: Accepted ) {
2007-09-28 05:23:13 +00:00
2011-02-11 20:02:08 +00:00
GameData gameData ;
// Set Game Data
gameData . maxNumberOfPlayers = myCreateInternetGameDialog -> spinBox_quantityPlayers -> value ();
gameData . startMoney = myCreateInternetGameDialog -> spinBox_startCash -> value ();
gameData . firstSmallBlind = myCreateInternetGameDialog -> getChangeCompleteBlindsDialog () -> spinBox_firstSmallBlind -> value ();
2007-08-21 12:34:33 +00:00
2011-02-11 20:02:08 +00:00
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 ();
}
2007-08-22 20:03:19 +00:00
2011-02-11 20:02:08 +00:00
if ( myCreateInternetGameDialog -> getChangeCompleteBlindsDialog () -> radioButton_alwaysDoubleBlinds -> isChecked ()) {
gameData . raiseMode = DOUBLE_BLINDS ;
} else {
gameData . raiseMode = MANUAL_BLINDS_ORDER ;
std :: list < int > tempBlindList ;
int i ;
bool ok = TRUE ;
for ( i = 0 ; i < myCreateInternetGameDialog -> getChangeCompleteBlindsDialog () -> listWidget_blinds -> count (); i ++ ) {
tempBlindList . push_back ( myCreateInternetGameDialog -> getChangeCompleteBlindsDialog () -> listWidget_blinds -> item ( i ) -> text (). toInt ( & ok , 10 ));
}
gameData . manualBlindsList = tempBlindList ;
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
}
}
2010-03-27 13:18:54 +00:00
2011-02-11 20:02:08 +00:00
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 ());
2007-09-30 00:42:14 +00:00
2011-02-11 20:02:08 +00:00
currentGameName = myCreateInternetGameDialog -> lineEdit_gameName -> text ();
2010-03-27 09:52:49 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
2007-10-03 00:32:17 +00:00
2011-02-11 20:02:08 +00:00
showGameDescription ( TRUE );
2007-10-03 09:37:02 +00:00
2011-02-11 20:02:08 +00:00
label_SmallBlind -> setText ( QString ( "%L1" ). arg ( gameData . firstSmallBlind ));
label_StartCash -> setText ( QString ( "%L1" ). arg ( gameData . startMoney ));
2007-09-05 19:14:34 +00:00
2011-02-11 20:02:08 +00:00
QTreeWidgetItem * header = treeWidget_connectedPlayers -> headerItem ();
header -> setText ( 0 , tr ( "Connected players - max. %1" ). arg ( gameData . maxNumberOfPlayers ));
header -> setData ( 0 , Qt :: UserRole , gameData . maxNumberOfPlayers );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
updateDialogBlinds ( gameData );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
label_TimeoutForPlayerAction -> setText ( QString :: number ( gameData . playerActionTimeoutSec ));
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
mySession -> clientCreateGame ( gameData , currentGameName . toUtf8 (). constData (), myCreateInternetGameDialog -> lineEdit_Password -> text (). toUtf8 (). constData ());
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
}
2007-08-21 12:34:33 +00:00
}
void gameLobbyDialogImpl :: joinGame ()
{
2011-02-11 20:02:08 +00:00
assert ( mySession );
QItemSelectionModel * selection = treeView_GameList -> selectionModel ();
if ( ! inGame && selection -> hasSelection ()) {
unsigned gameId = selection -> selectedRows (). first (). data ( Qt :: UserRole ). toUInt ();
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 );
}
2007-09-07 08:58:36 +00:00
2011-02-11 20:02:08 +00:00
if ( ok )
mySession -> clientJoinGame ( gameId , password . toUtf8 (). constData ());
}
2007-09-05 19:14:34 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: joinAnyGame ()
{
2007-11-23 00:57:40 +00:00
2011-02-11 20:02:08 +00:00
if ( comboBox_gameListFilter -> currentIndex () != 3 && comboBox_gameListFilter -> currentIndex () != 0 ) comboBox_gameListFilter -> setCurrentIndex ( 0 );
2007-11-23 00:57:40 +00:00
2011-02-11 20:02:08 +00:00
bool found = FALSE ;
2007-11-24 00:37:33 +00:00
2011-02-11 20:02:08 +00:00
int it = 0 ;
int gameToJoinId = 0 ;
int mostConnectedPlayers = 0 ;
2007-11-23 00:57:40 +00:00
2011-02-11 20:02:08 +00:00
while ( myGameListModel -> item ( it )) {
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 ++ ;
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
if ( found ) {
treeView_GameList -> setCurrentIndex ( myGameListSortFilterProxyModel -> mapFromSource ( myGameListModel -> item ( gameToJoinId ) -> index ()));
joinGame ();
}
2007-11-23 00:57:40 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: refresh ( int actionID )
{
2007-09-05 19:14:34 +00:00
2011-02-11 20:02:08 +00:00
if ( actionID == MSG_NET_GAME_CLIENT_START ) {
myGameListModel -> clear ();
myGameListSelectionModel -> clear ();
myGameListSelectionModel -> clearSelection ();
myGameListSortFilterProxyModel -> clear ();
2010-08-08 23:14:00 +00:00
2011-02-11 20:02:08 +00:00
myNickListModel -> clear ();
myNickListSelectionModel -> clear ();
myNickListSelectionModel -> clearSelection ();;
2010-01-05 12:53:37 +00:00
2011-02-11 20:02:08 +00:00
QStringList headerList ;
headerList << tr ( "Game" ) << tr ( "Players" ) << tr ( "State" ) << tr ( "T" ) << tr ( "P" );
myGameListModel -> setHorizontalHeaderLabels ( headerList );
treeView_GameList -> setColumnWidth ( 0 , 190 );
treeView_GameList -> setColumnWidth ( 1 , 65 );
treeView_GameList -> setColumnWidth ( 2 , 65 );
treeView_GameList -> setColumnWidth ( 3 , 40 );
treeView_GameList -> setColumnWidth ( 4 , 40 );
2010-08-08 23:14:00 +00:00
2011-02-11 20:02:08 +00:00
QStringList headerList2 ;
headerList2 << tr ( "Available Players" );
myNickListModel -> setHorizontalHeaderLabels ( headerList2 );
2010-03-30 12:25:30 +00:00
2011-10-27 09:04:19 +00:00
//stop waitStartGameMsgBoxes
2011-02-11 20:02:08 +00:00
waitStartGameMsgBoxTimer -> stop ();
2011-11-06 00:30:34 +00:00
closeAllChildDialogs ();
2010-09-25 18:45:55 +00:00
2011-02-11 20:02:08 +00:00
this -> accept ();
myW -> show ();
} else if ( actionID == MSG_NET_GAME_CLIENT_SYNCSTART ) {
2010-09-25 12:25:21 +00:00
2011-02-11 20:02:08 +00:00
waitStartGameMsgBoxTimer -> start ( 2000 );
2011-10-27 09:04:19 +00:00
} else if ( actionID == MSG_NET_GAME_CLIENT_SYNCREJOIN ) {
if ( this -> isVisible ()) {
2011-11-06 00:30:34 +00:00
//break the autoStartTimer animation
autoStartTimer -> stop ();
autoStartTimerOverlay -> hide ();
//show msg dialog
2011-10-27 09:04:19 +00:00
waitRejoinStartGameMsgBox -> show ();
waitRejoinStartGameMsgBox -> raise ();
waitRejoinStartGameMsgBox -> activateWindow ();
2011-10-28 20:03:26 +00:00
pushButton_Leave -> setDisabled ( true );
2011-10-27 09:04:19 +00:00
}
2011-02-11 20:02:08 +00:00
}
2007-08-21 17:27:13 +00:00
}
2007-11-07 14:11:57 +00:00
void gameLobbyDialogImpl :: removedFromGame ( int /*reason*/ )
2007-09-06 19:09:05 +00:00
{
2011-02-11 20:02:08 +00:00
inGame = false ;
isGameAdministrator = false ;
leftGameDialogUpdate ();
2007-09-06 19:09:05 +00:00
}
2010-03-31 12:33:00 +00:00
void gameLobbyDialogImpl :: gameSelected ( const QModelIndex & index )
2007-08-21 17:27:13 +00:00
{
2008-03-03 10:25:32 +00:00
2011-02-11 20:02:08 +00:00
if ( ! inGame && index . isValid () ) {
pushButton_JoinGame -> setEnabled ( true );
2007-08-22 20:03:19 +00:00
2011-02-11 20:02:08 +00:00
currentGameName = myGameListModel -> item ( myGameListSortFilterProxyModel -> mapToSource ( index ). row (), 0 ) -> text ();
2007-08-26 12:45:37 +00:00
2011-02-11 20:02:08 +00:00
groupBox_GameInfo -> setEnabled ( true );
groupBox_GameInfo -> setTitle ( tr ( "Game Info" ) + " - " + currentGameName );
2007-08-27 09:57:51 +00:00
2011-02-11 20:02:08 +00:00
assert ( mySession );
GameInfo info ( mySession -> getClientGameInfo ( myGameListModel -> item ( myGameListSortFilterProxyModel -> mapToSource ( index ). row (), 0 ) -> data ( Qt :: UserRole ). toUInt ()));
2007-09-29 20:20:01 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
2010-03-23 19:58:19 +00:00
2011-02-11 20:02:08 +00:00
showGameDescription ( 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 );
2007-10-17 22:27:11 +00:00
2011-02-11 20:02:08 +00:00
label_TimeoutForPlayerAction -> setText ( QString :: number ( info . data . playerActionTimeoutSec ));
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 );
2010-03-30 12:25:30 +00:00
#ifdef __APPLE__
2011-02-11 20:02:08 +00:00
// Dirty workaround for a Qt redraw bug on Mac OS.
treeWidget_connectedPlayers -> setFocus ();
treeView_GameList -> setFocus ();
2010-03-30 12:25:30 +00:00
#endif
2011-02-11 20:02:08 +00:00
}
2010-03-30 12:25:30 +00:00
}
void gameLobbyDialogImpl :: updateGameItem ( QList < QStandardItem *> itemList , unsigned gameId )
{
2011-02-11 20:02:08 +00:00
assert ( mySession );
GameInfo info ( mySession -> getClientGameInfo ( gameId ));
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
itemList . at ( 0 ) -> setData ( gameId , Qt :: UserRole );
itemList . at ( 0 ) -> setData ( QString :: fromUtf8 ( info . name . c_str ()), Qt :: DisplayRole );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
PlayerIdList :: const_iterator i = info . players . begin ();
PlayerIdList :: const_iterator end = info . players . end ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 );
} \
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 );
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 );
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
// treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") );
refreshGameStats ();
2007-09-02 16:36:52 +00:00
}
2007-09-04 12:44:11 +00:00
void gameLobbyDialogImpl :: addGame ( unsigned gameId )
{
2011-02-11 20:02:08 +00:00
QList < QStandardItem *> 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 ;
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
myGameListModel -> appendRow ( itemList );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
updateGameItem ( itemList , gameId );
2010-03-30 12:25:30 +00:00
2007-09-04 12:44:11 +00:00
}
2007-09-29 20:20:01 +00:00
void gameLobbyDialogImpl :: updateGameMode ( unsigned gameId , int /*newMode*/ )
{
2011-02-11 20:02:08 +00:00
int it = 0 ;
while ( myGameListModel -> item ( it )) {
if ( myGameListModel -> item ( it , 0 ) -> data ( Qt :: UserRole ) == gameId ) {
QList < QStandardItem *> 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 ++ ;
}
2007-09-29 20:20:01 +00:00
}
2007-10-12 14:32:25 +00:00
void gameLobbyDialogImpl :: updateGameAdmin ( unsigned /*gameId*/ , unsigned adminPlayerId )
{
2011-02-11 20:02:08 +00:00
newGameAdmin ( adminPlayerId , "" );
2007-10-12 14:32:25 +00:00
}
2007-09-04 12:44:11 +00:00
void gameLobbyDialogImpl :: removeGame ( unsigned gameId )
2007-09-02 16:36:52 +00:00
{
2011-02-11 20:02:08 +00:00
int it = 0 ;
while ( myGameListModel -> item ( it )) {
if ( myGameListModel -> item ( it , 0 ) -> data ( Qt :: UserRole ) == gameId ) {
myGameListModel -> removeRow ( it );
break ;
}
it ++ ;
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
refreshGameStats ();
2007-10-17 22:27:11 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: refreshGameStats ()
{
2007-10-17 22:27:11 +00:00
2011-02-11 20:02:08 +00:00
int runningGamesCounter = 0 ;
int openGamesCounter = 0 ;
2007-10-17 22:27:11 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
2007-10-17 22:27:11 +00:00
2011-02-11 20:02:08 +00:00
label_openGamesCounter -> setText ( "| " + tr ( "running games: %1" ). arg ( runningGamesCounter ));
label_runningGamesCounter -> setText ( "| " + tr ( "open games: %1" ). arg ( openGamesCounter ));
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
//refresh joinAnyGameButton state
joinAnyGameButtonRefresh ();
2007-10-17 22:27:11 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: refreshPlayerStats ()
{
2011-10-03 14:44:09 +00:00
//ServerStats stats = mySession->getClientStats();
2011-02-11 20:02:08 +00:00
label_connectedPlayersCounter -> setText ( tr ( "connected players: %1" ). arg ( myNickListModel -> rowCount ()));
2007-09-02 16:36:52 +00:00
}
void gameLobbyDialogImpl :: gameAddPlayer ( unsigned gameId , unsigned playerId )
{
2011-02-11 20:02:08 +00:00
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 ));
2007-09-04 12:44:11 +00:00
2011-02-11 20:02:08 +00:00
addConnectedPlayer ( playerId , QString :: fromUtf8 ( playerInfo . playerName . c_str ()), admin );
}
}
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
int it = 0 ;
while ( myGameListModel -> item ( it )) {
if ( myGameListModel -> item ( it , 0 ) -> data ( Qt :: UserRole ) == gameId ) {
QList < QStandardItem *> itemList ;
itemList << myGameListModel -> item ( it , 0 ) << myGameListModel -> item ( it , 1 ) << myGameListModel -> item ( it , 2 ) << myGameListModel -> item ( it , 3 ) << myGameListModel -> item ( it , 4 );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
updateGameItem ( itemList , gameId );
break ;
}
it ++ ;
}
2010-08-30 08:31:42 +00:00
2011-02-11 20:02:08 +00:00
//mark player as active
int it1 = 0 ;
while ( myNickListModel -> item ( it1 )) {
if ( myNickListModel -> item ( it1 , 0 ) -> data ( Qt :: UserRole ) == playerId ) {
myNickListModel -> item ( it1 , 0 ) -> setData ( "active" , 34 );
break ;
}
++ it1 ;
}
2007-09-02 16:36:52 +00:00
}
void gameLobbyDialogImpl :: gameRemovePlayer ( unsigned gameId , unsigned playerId )
{
2011-02-11 20:02:08 +00:00
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 ()));
}
}
}
2007-09-04 12:44:11 +00:00
2011-02-11 20:02:08 +00:00
int it = 0 ;
while ( myGameListModel -> item ( it )) {
if ( myGameListModel -> item ( it , 0 ) -> data ( Qt :: UserRole ) == gameId ) {
QList < QStandardItem *> itemList ;
itemList << myGameListModel -> item ( it , 0 ) << myGameListModel -> item ( it , 1 ) << myGameListModel -> item ( it , 2 ) << myGameListModel -> item ( it , 3 ) << myGameListModel -> item ( it , 4 );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
updateGameItem ( itemList , gameId );
break ;
}
++ it ;
}
2010-08-30 08:31:42 +00:00
2011-02-11 20:02:08 +00:00
//mark player as idle again
int it1 = 0 ;
while ( myNickListModel -> item ( it1 )) {
if ( myNickListModel -> item ( it1 , 0 ) -> data ( Qt :: UserRole ) == playerId ) {
myNickListModel -> item ( it1 , 0 ) -> setData ( "idle" , 34 );
break ;
}
++ it1 ;
}
2007-09-02 16:36:52 +00:00
}
2007-10-20 22:22:11 +00:00
void gameLobbyDialogImpl :: updateStats ( ServerStats /*stats*/ )
{
2011-02-11 20:02:08 +00:00
refreshPlayerStats ();
2007-10-20 22:22:11 +00:00
}
2007-09-02 16:36:52 +00:00
void gameLobbyDialogImpl :: clearDialog ()
2007-08-27 09:57:51 +00:00
{
2011-02-11 20:02:08 +00:00
groupBox_GameInfo -> setTitle ( tr ( "Game Info" ));
groupBox_GameInfo -> setEnabled ( false );
currentGameName = "" ;
2007-08-27 09:57:51 +00:00
2011-02-11 20:02:08 +00:00
QTreeWidgetItem * header = treeWidget_connectedPlayers -> headerItem ();
header -> setText ( 0 , tr ( "Connected players" ));
header -> setData ( 0 , Qt :: UserRole , 0 );
2010-03-27 09:52:49 +00:00
2011-02-11 20:02:08 +00:00
showGameDescription ( 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 ( "" );
2007-09-02 16:36:52 +00:00
2011-02-11 20:02:08 +00:00
myGameListModel -> clear ();
myGameListSelectionModel -> clear ();
myGameListSelectionModel -> clearSelection ();
myGameListSortFilterProxyModel -> clear ();
treeView_GameList -> show ();
treeWidget_connectedPlayers -> clear ();
2007-09-02 16:36:52 +00:00
2011-02-11 20:02:08 +00:00
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 );
2007-09-02 16:36:52 +00:00
2011-02-11 20:02:08 +00:00
QStringList headerList ;
headerList << tr ( "Game" ) << tr ( "Players" ) << tr ( "State" ) << tr ( "T" ) << tr ( "P" );
myGameListModel -> setHorizontalHeaderLabels ( headerList );
treeView_GameList -> setColumnWidth ( 0 , 190 );
treeView_GameList -> setColumnWidth ( 1 , 65 );
treeView_GameList -> setColumnWidth ( 2 , 65 );
treeView_GameList -> setColumnWidth ( 3 , 40 );
treeView_GameList -> setColumnWidth ( 4 , 40 );
2007-10-09 20:41:57 +00:00
2011-02-11 20:02:08 +00:00
pushButton_CreateGame -> clearFocus ();
lineEdit_ChatInput -> setFocus ();
myChat -> clearChat ();
2010-08-08 23:14:00 +00:00
2011-02-11 20:02:08 +00:00
myNickListModel -> clear ();
myNickListSelectionModel -> clear ();
myNickListSelectionModel -> clearSelection ();;
QStringList headerList2 ;
headerList2 << tr ( "Available Players" );
myNickListModel -> setHorizontalHeaderLabels ( headerList2 );
myNickListModel -> sort ( 0 , treeView_NickList -> header () -> sortIndicatorOrder ());
2010-08-08 23:14:00 +00:00
2011-02-11 20:02:08 +00:00
inGame = false ;
isGameAdministrator = false ;
myPlayerId = 0 ;
2007-10-30 12:14:42 +00:00
2011-02-11 20:02:08 +00:00
showGameDescription ( FALSE );
2007-11-29 11:58:23 +00:00
2011-02-11 20:02:08 +00:00
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 ));
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
readDialogSettings ();
2007-08-27 09:57:51 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: checkPlayerQuantity ()
{
2007-08-29 22:30:18 +00:00
2011-02-11 20:02:08 +00:00
assert ( mySession );
GameInfo info ( mySession -> getClientGameInfo ( mySession -> getClientCurrentGameId ()));
2010-07-15 10:06:43 +00:00
2011-02-11 20:02:08 +00:00
if ( isGameAdministrator && info . data . gameType != GAME_TYPE_RANKING ) {
2010-07-15 10:06:43 +00:00
2011-02-11 20:02:08 +00:00
pushButton_Kick -> show ();
pushButton_StartGame -> show ();
checkBox_fillUpWithComputerOpponents -> show ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
if ( treeWidget_connectedPlayers -> topLevelItemCount () >= 2 ) {
pushButton_StartGame -> setEnabled ( true );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 ();
}
}
2010-09-05 13:35:09 +00:00
2011-02-11 20:02:08 +00:00
//general actions
if ( treeWidget_connectedPlayers -> topLevelItemCount () < treeWidget_connectedPlayers -> headerItem () -> data ( 0 , Qt :: UserRole ). toInt ()) {
autoStartTimerOverlay -> hide ();
autoStartTimer -> stop ();
}
2010-09-05 13:35:09 +00:00
2009-06-17 00:00:10 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: blinkingStartButtonAnimation ()
{
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
}
2007-08-29 22:30:18 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: joinedNetworkGame ( unsigned playerId , QString playerName , bool isGameAdmin )
{
2007-08-29 22:30:18 +00:00
2011-02-11 20:02:08 +00:00
// Update dialog
inGame = true ;
joinedGameDialogUpdate ();
2007-09-06 19:09:05 +00:00
2010-03-30 22:12:47 +00:00
2011-02-11 20:02:08 +00:00
myPlayerId = playerId ;
isGameAdministrator = isGameAdmin ;
addConnectedPlayer ( playerId , playerName , isGameAdmin );
2010-03-28 22:17:18 +00:00
2011-02-11 20:02:08 +00:00
//show msgBox about invite only game
assert ( mySession );
if ( mySession -> getClientGameInfo ( mySession -> getClientCurrentGameId ()). data . gameType == GAME_TYPE_INVITE_ONLY ) {
infoMsgToShowId = 2 ;
showInfoMsgBoxTimer -> start ( 1000 );
}
2010-03-30 22:12:47 +00:00
2011-02-11 20:02:08 +00:00
// if(!myGameListSelectionModel->hasSelection() && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY) {
// int it = 0;
// while (myGameListModel->item(it)) {
// if (myGameListModel->item(it, 0)->data(Qt::UserRole) == mySession->getClientCurrentGameId()) {
// gameSelected(treeView_GameList->model()->index(it,0), true);
// break;
// }
// it++;
// }
// }
2007-08-29 22:30:18 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: addConnectedPlayer ( unsigned playerId , QString playerName , bool isGameAdmin )
{
2007-08-29 22:30:18 +00:00
2011-02-11 20:02:08 +00:00
QTreeWidgetItem * item = new QTreeWidgetItem ( treeWidget_connectedPlayers , 0 );
item -> setData ( 0 , Qt :: UserRole , playerId );
item -> setData ( 0 , Qt :: DisplayRole , playerName );
2007-08-29 22:30:18 +00:00
2011-02-11 20:02:08 +00:00
if ( isGameAdmin ) item -> setBackground ( 0 , QBrush ( QColor ( 0 , 255 , 0 , 127 )));
2007-09-02 16:36:52 +00:00
2011-02-11 20:02:08 +00:00
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 );
showAutoStartTimer ();
}
}
2007-11-01 19:27:02 +00:00
2011-02-11 20:02:08 +00:00
checkPlayerQuantity ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
if ( inGame )
refreshConnectedPlayerAvatars ();
2007-09-02 16:36:52 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: updatePlayer ( unsigned playerId , QString newPlayerName )
{
2007-09-02 16:36:52 +00:00
2011-02-11 20:02:08 +00:00
//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 ;
}
2007-11-01 19:27:02 +00:00
2011-02-11 20:02:08 +00:00
if ( inGame )
refreshConnectedPlayerAvatars ();
2010-03-26 20:09:51 +00:00
2011-02-11 20:02:08 +00:00
//also rename player in nick-list
QString oldNick ;
int it1 = 0 ;
while ( myNickListModel -> item ( it1 )) {
if ( myNickListModel -> item ( it1 , 0 ) -> data ( Qt :: UserRole ) == playerId ) {
oldNick = myNickListModel -> item ( it1 , 0 ) -> text ();
myNickListModel -> item ( it1 , 0 ) -> setText ( newPlayerName );
2010-08-29 21:50:18 +00:00
2011-02-11 20:02:08 +00:00
PlayerInfo playerInfo ( mySession -> getClientPlayerInfo ( playerId ));
QString countryString = QString :: fromUtf8 ( playerInfo . countryCode . c_str ()). toLower ();
myNickListModel -> item ( it1 , 0 ) -> setData ( countryString , 33 );
if ( playerInfo . isGuest || countryString . isEmpty ()) {
myNickListModel -> item ( it1 , 0 ) -> setIcon ( QIcon ( ":/cflags/cflags/undefined.png" ));
2011-11-10 10:01:34 +00:00
myNickListModel -> item ( it1 , 0 ) -> setToolTip ( "" );
2011-02-11 20:02:08 +00:00
} else {
myNickListModel -> item ( it1 , 0 ) -> setIcon ( QIcon ( QString ( ":/cflags/cflags/%1.png" ). arg ( countryString )));
2011-03-05 22:08:57 +00:00
myNickListModel -> item ( it1 , 0 ) -> setToolTip ( getFullCountryString ( countryString . toUpper ()));
2011-02-11 20:02:08 +00:00
}
2010-08-30 08:31:42 +00:00
2011-02-11 20:02:08 +00:00
unsigned gameIdOfPlayer = mySession -> getGameIdOfPlayer ( playerId );
if ( gameIdOfPlayer ) {
myNickListModel -> item ( it1 , 0 ) -> setData ( "active" , 34 );
} else {
myNickListModel -> item ( it1 , 0 ) -> setData ( "idle" , 34 );
}
2010-08-30 08:31:42 +00:00
2011-02-11 20:02:08 +00:00
break ;
}
2010-08-08 23:14:00 +00:00
2011-02-11 20:02:08 +00:00
++ it1 ;
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
if ( myChat -> getMyNick () == oldNick ) {
myChat -> setMyNick ( newPlayerName );
}
2007-09-02 16:36:52 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: removePlayer ( unsigned playerId , QString )
{
2007-09-02 16:36:52 +00:00
2011-02-11 20:02:08 +00:00
QTreeWidgetItemIterator it ( treeWidget_connectedPlayers );
while ( * it ) {
if (( * it ) -> data ( 0 , Qt :: UserRole ) == playerId ) {
treeWidget_connectedPlayers -> takeTopLevelItem ( treeWidget_connectedPlayers -> indexOfTopLevelItem ( * it ));
break ;
}
++ it ;
}
2007-08-29 22:30:18 +00:00
2011-02-11 20:02:08 +00:00
checkPlayerQuantity ();
2010-08-30 08:31:42 +00:00
2007-08-29 22:30:18 +00:00
}
2009-08-17 23:20:58 +00:00
void gameLobbyDialogImpl :: playerLeftLobby ( unsigned playerId )
{
2011-02-11 20:02:08 +00:00
int it1 = 0 ;
while ( myNickListModel -> item ( it1 )) {
if ( myNickListModel -> item ( it1 , 0 ) -> data ( Qt :: UserRole ) == playerId ) {
myNickListModel -> removeRow ( it1 );;
break ;
}
++ it1 ;
}
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
refreshPlayerStats ();
2009-08-17 23:20:58 +00:00
}
2010-03-26 20:09:51 +00:00
void gameLobbyDialogImpl :: playerJoinedLobby ( unsigned playerId , QString /*playerName TODO remove*/ )
2009-08-17 23:20:58 +00:00
{
2011-02-11 20:02:08 +00:00
PlayerInfo playerInfo ( mySession -> getClientPlayerInfo ( playerId ));
QString countryString = QString :: fromUtf8 ( playerInfo . countryCode . c_str ()). toLower ();
2010-03-26 20:09:51 +00:00
2011-02-11 20:02:08 +00:00
QStandardItem * item = new QStandardItem ;
item -> setText ( QString :: fromUtf8 ( playerInfo . playerName . c_str ()));
item -> setData ( playerId , Qt :: UserRole );
item -> setData ( countryString , 33 );
if ( playerInfo . isGuest || countryString . isEmpty ()) {
item -> setIcon ( QIcon ( ":/cflags/cflags/undefined.png" ));
} else {
item -> setIcon ( QIcon ( QString ( ":/cflags/cflags/%1.png" ). arg ( countryString )));
2011-03-05 22:08:57 +00:00
item -> setToolTip ( getFullCountryString ( countryString . toUpper ()));
2011-02-11 20:02:08 +00:00
}
2010-08-29 21:50:18 +00:00
2011-02-11 20:02:08 +00:00
unsigned gameIdOfPlayer = mySession -> getGameIdOfPlayer ( playerId );
if ( gameIdOfPlayer ) {
item -> setData ( "active" , 34 );
} else {
item -> setData ( "idle" , 34 );
}
2010-08-30 08:31:42 +00:00
2011-02-11 20:02:08 +00:00
myNickListModel -> appendRow ( item );
2009-08-17 23:20:58 +00:00
2011-02-11 20:02:08 +00:00
refreshPlayerStats ();
2009-08-17 23:20:58 +00:00
}
2007-10-03 13:36:47 +00:00
void gameLobbyDialogImpl :: newGameAdmin ( unsigned playerId , QString )
{
2011-02-11 20:02:08 +00:00
QTreeWidgetItemIterator it ( treeWidget_connectedPlayers );
while ( * it ) {
if (( * it ) -> data ( 0 , Qt :: UserRole ) == playerId ) {
( * it ) -> setBackground ( 0 , QBrush ( QColor ( 0 , 255 , 0 , 127 )));
}
++ it ;
}
2007-10-03 23:30:41 +00:00
2011-02-11 20:02:08 +00:00
if ( inGame && myPlayerId == playerId ) {
isGameAdministrator = true ;
checkPlayerQuantity ();
}
2007-10-03 13:36:47 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: refreshConnectedPlayerAvatars ()
{
2007-11-01 12:21:34 +00:00
2011-02-11 20:02:08 +00:00
QTreeWidgetItemIterator it ( treeWidget_connectedPlayers );
while ( * it ) {
2007-11-01 12:21:34 +00:00
2011-02-11 20:02:08 +00:00
std :: string myAvatarFileName ;
PlayerInfo playerInfo ( mySession -> getClientPlayerInfo (( * it ) -> data ( 0 , Qt :: UserRole ). toUInt ()));
2007-11-01 16:51:59 +00:00
2011-02-11 20:02:08 +00:00
if ( mySession -> getAvatarFile ( playerInfo . avatar , myAvatarFileName )) {
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
QString myAvatarString ( QString :: fromUtf8 ( myAvatarFileName . c_str ()));
QFile myAvatarFile ( myAvatarString );
if ( myAvatarFile . exists ()) {
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
QPixmap tempAvatar ( myAvatarString );
QPixmap myAvatarPixmap ( 25 , 26 );
myAvatarPixmap . fill ( Qt :: transparent );
QPainter p ( & myAvatarPixmap );
p . drawPixmap ( 0 , 0 , 25 , 25 , tempAvatar . scaled ( 25 , 25 , Qt :: KeepAspectRatio , Qt :: SmoothTransformation ));
2010-12-10 22:44:28 +00:00
2011-02-11 20:02:08 +00:00
( * it ) -> setIcon ( 0 , QIcon ( myAvatarPixmap ));
}
}
++ it ;
}
2007-11-01 12:21:34 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: joinedGameDialogUpdate ()
{
2010-03-27 16:50:31 +00:00
2011-02-11 20:02:08 +00:00
groupBox_GameInfo -> setEnabled ( true );
groupBox_GameInfo -> setTitle ( currentGameName );
treeWidget_connectedPlayers -> clear ();
pushButton_CreateGame -> hide ();
pushButton_JoinGame -> hide ();
pushButton_joinAnyGame -> hide ();
pushButton_Leave -> show ();
2011-10-28 20:03:26 +00:00
pushButton_Leave -> setEnabled ( true );
2010-03-31 12:33:00 +00:00
2011-02-11 20:02:08 +00:00
//this was added to show game infos even if no game was selected (e.g. invite only game)
assert ( mySession );
GameInfo info ( mySession -> getClientGameInfo ( mySession -> getClientCurrentGameId ()));
2010-03-31 12:33:00 +00:00
2011-02-11 20:02:08 +00:00
groupBox_GameInfo -> setTitle ( tr ( "Game Info" ) + " - " + QString :: fromUtf8 ( info . name . c_str ()));
2010-03-31 12:33:00 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
2010-03-31 12:33:00 +00:00
2011-02-11 20:02:08 +00:00
showGameDescription ( TRUE );
label_SmallBlind -> setText ( QString ( "%L1" ). arg ( info . data . firstSmallBlind ));
label_StartCash -> setText ( QString ( "%L1" ). arg ( info . data . startMoney ));
updateDialogBlinds ( info . data );
label_TimeoutForPlayerAction -> setText ( QString :: number ( info . data . playerActionTimeoutSec ));
2010-10-08 20:30:52 +00:00
2011-02-11 20:02:08 +00:00
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 );
2007-09-05 19:14:34 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: leftGameDialogUpdate ()
{
2007-09-29 14:05:41 +00:00
2011-02-11 20:02:08 +00:00
// un-select current game.
treeView_GameList -> clearSelection ();
2007-09-29 14:05:41 +00:00
2011-02-11 20:02:08 +00:00
groupBox_GameInfo -> setTitle ( tr ( "Game Info" ));
groupBox_GameInfo -> setEnabled ( false );
currentGameName = "" ;
2007-09-29 14:05:41 +00:00
2011-02-11 20:02:08 +00:00
QTreeWidgetItem * header = treeWidget_connectedPlayers -> headerItem ();
header -> setText ( 0 , tr ( "Connected players" ));
header -> setData ( 0 , Qt :: UserRole , 0 );
2010-03-27 09:52:49 +00:00
2011-02-11 20:02:08 +00:00
showGameDescription ( 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 ( "" );
2007-09-29 14:05:41 +00:00
2011-02-11 20:02:08 +00:00
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 ();
2007-09-29 14:05:41 +00:00
2011-02-11 20:02:08 +00:00
lineEdit_ChatInput -> setFocus ();
2007-09-29 14:05:41 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: updateDialogBlinds ( const GameData & gameData )
{
2007-10-03 09:37:02 +00:00
2011-02-11 20:02:08 +00:00
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 ();
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
QString blindsListString ;
std :: list < int >:: const_iterator it1 ;
2011-02-09 14:33:39 +00:00
for ( it1 = gameData . manualBlindsList . begin (); it1 != gameData . manualBlindsList . end (); ++ it1 ) {
2011-02-11 20:02:08 +00:00
blindsListString . append ( QString ( "%L1" ). arg ( * it1 )). append ( ", " );
}
blindsListString . remove ( blindsListString . length () - 2 , 2 );
label_blindsList -> setText ( blindsListString );
}
2007-10-03 09:37:02 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: playerSelected ( QTreeWidgetItem * item , QTreeWidgetItem * )
{
2007-09-05 19:14:34 +00:00
2011-02-11 20:02:08 +00:00
if ( item )
pushButton_Kick -> setEnabled ( isGameAdministrator );
2007-09-05 19:14:34 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: startGame ()
{
2007-09-06 19:09:05 +00:00
2011-02-11 20:02:08 +00:00
assert ( mySession );
mySession -> sendStartEvent ( checkBox_fillUpWithComputerOpponents -> isChecked ());
2007-09-05 19:14:34 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: leaveGame ()
{
2007-09-06 19:09:05 +00:00
2011-02-11 20:02:08 +00:00
assert ( mySession );
mySession -> sendLeaveCurrentGame ();
2010-09-05 13:35:09 +00:00
2011-02-11 20:02:08 +00:00
//stop autoStartTimerOverlay
autoStartTimerOverlay -> hide ();
autoStartTimer -> stop ();
2010-09-25 18:34:45 +00:00
2011-10-27 09:04:19 +00:00
//stop waitStartGameMsgBoxes
2011-02-11 20:02:08 +00:00
waitStartGameMsgBoxTimer -> stop ();
waitStartGameMsgBox -> hide ();
2011-10-27 09:04:19 +00:00
waitRejoinStartGameMsgBox -> hide ();
2007-09-06 19:09:05 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: kickPlayer ()
{
2007-09-05 19:14:34 +00:00
2011-02-11 20:02:08 +00:00
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 );
2007-09-05 19:14:34 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: keyPressEvent ( QKeyEvent * event )
{
2007-09-07 20:26:13 +00:00
2011-02-11 20:02:08 +00:00
// qDebug() << event->key() << "\n";
2007-10-09 07:50:56 +00:00
2011-02-11 20:02:08 +00:00
if ( event -> key () == Qt :: Key_Enter && lineEdit_ChatInput -> hasFocus ()) {
myChat -> sendMessage ();
}
2007-10-09 07:50:56 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
2007-10-09 07:50:56 +00:00
2011-02-11 20:02:08 +00:00
// if (event->key() == Qt::Key_Tab) event->ignore(); else { /*blah*/ }
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
// if (event->key() == Qt::Key_N) showInvitationDialog();
// if (event->key() == Qt::Key_M) guestUserMode();
2007-10-10 10:06:09 +00:00
2007-10-09 07:50:56 +00:00
}
2007-10-10 10:06:09 +00:00
bool gameLobbyDialogImpl :: eventFilter ( QObject * obj , QEvent * event )
{
2011-02-11 20:02:08 +00:00
QKeyEvent * keyEvent = static_cast < QKeyEvent *> ( event );
QFocusEvent * focusEvent = static_cast < QFocusEvent *> ( event );
2007-10-10 10:06:09 +00:00
2011-02-11 20:02:08 +00:00
if ( obj == lineEdit_ChatInput && lineEdit_ChatInput -> text () != "" && event -> type () == QEvent :: KeyPress && keyEvent -> key () == Qt :: Key_Tab ) {
myChat -> nickAutoCompletition ();
return true ;
} else if ( obj == lineEdit_searchForPlayers && focusEvent -> gotFocus () && lineEdit_searchForPlayers -> text () == tr ( "search for player ..." )) {
lineEdit_searchForPlayers -> clear ();
return QDialog :: eventFilter ( obj , event );
} else {
// pass the event on to the parent class
return QDialog :: eventFilter ( obj , event );
}
2007-10-10 10:06:09 +00:00
}
2011-02-11 20:02:08 +00:00
bool gameLobbyDialogImpl :: event ( QEvent * event )
{
2007-10-09 07:50:56 +00:00
2011-02-11 20:02:08 +00:00
return QDialog :: event ( event );
2007-09-26 11:48:33 +00:00
}
2007-09-30 00:42:14 +00:00
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: showGameDescription ( bool show )
{
2007-09-30 00:42:14 +00:00
2011-02-11 20:02:08 +00:00
if ( show ) {
label_gameType -> show ();
label_gameDesc2 -> show ();
label_gameDesc3 -> show ();
label_gameDesc4 -> show ();
label_gameDesc5 -> show ();
label_gameDesc6 -> show ();
label_gameDesc7 -> show ();
} else {
label_gameType -> hide ();
label_gameDesc2 -> hide ();
label_gameDesc3 -> hide ();
label_gameDesc4 -> hide ();
label_gameDesc5 -> hide ();
label_gameDesc6 -> hide ();
label_gameDesc7 -> hide ();
}
2007-09-30 18:50:46 +00:00
}
2007-10-16 23:07:59 +00:00
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: showWaitStartGameMsgBox ()
{
2010-09-25 18:34:45 +00:00
2011-02-11 20:02:08 +00:00
if ( this -> isVisible ()) {
waitStartGameMsgBox -> show ();
waitStartGameMsgBox -> raise ();
waitStartGameMsgBox -> activateWindow ();
2011-10-28 20:03:26 +00:00
pushButton_Leave -> setDisabled ( true );
2011-02-11 20:02:08 +00:00
}
2007-10-18 20:58:56 +00:00
}
2007-10-16 23:07:59 +00:00
2011-08-21 06:32:28 +00:00
void gameLobbyDialogImpl :: hideWaitStartGameMsgBox ()
{
waitStartGameMsgBox -> hide ();
2011-10-27 09:04:19 +00:00
waitRejoinStartGameMsgBox -> hide ();
2011-08-21 06:32:28 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: joinAnyGameButtonRefresh ()
{
2007-11-23 00:57:40 +00:00
2011-02-11 20:02:08 +00:00
int openNonPrivateNonFullGamesCounter = 0 ;
2007-11-23 00:57:40 +00:00
2011-02-11 20:02:08 +00:00
int it = 0 ;
while ( myGameListModel -> item ( it )) {
2009-06-13 12:09:45 +00:00
2011-02-11 20:02:08 +00:00
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 ;
}
2007-11-23 00:57:40 +00:00
2011-02-11 20:02:08 +00:00
if ( openNonPrivateNonFullGamesCounter ) pushButton_joinAnyGame -> setEnabled ( TRUE );
else pushButton_joinAnyGame -> setEnabled ( FALSE );
2007-11-23 00:57:40 +00:00
}
2008-09-09 22:21:41 +00:00
void gameLobbyDialogImpl :: reject ()
{
2011-02-11 20:02:08 +00:00
myStartWindow -> show ();
QDialog :: reject ();
2008-09-09 22:21:41 +00:00
}
2009-01-11 22:36:43 +00:00
void gameLobbyDialogImpl :: closeEvent ( QCloseEvent * event )
{
2011-02-11 20:02:08 +00:00
event -> accept ();
2011-10-27 09:04:19 +00:00
//stop waitStartGameMsgBoxes
2011-02-11 20:02:08 +00:00
waitStartGameMsgBoxTimer -> stop ();
waitStartGameMsgBox -> hide ();
2011-10-27 09:04:19 +00:00
waitRejoinStartGameMsgBox -> hide ();
2011-12-29 22:43:42 +00:00
//enable leave button again - it was disabled during waitxyzMsgBoxes
pushButton_Leave -> setEnabled ( true );
2009-01-11 22:36:43 +00:00
}
2009-06-16 09:13:45 +00:00
void gameLobbyDialogImpl :: writeDialogSettings ( int saveMode )
2009-01-11 22:36:43 +00:00
{
2011-02-11 20:02:08 +00:00
switch ( saveMode ) {
case 0 : {
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 ;
case 2 : {
myConfig -> writeConfigInt ( "DlgGameLobbyNickListSortFilterIndex" , comboBox_nickListFilter -> currentIndex ());
}
break ;
default :
;
}
2010-08-30 10:41:56 +00:00
2011-02-11 20:02:08 +00:00
myConfig -> writeBuffer ();
2009-01-11 22:36:43 +00:00
}
void gameLobbyDialogImpl :: readDialogSettings ()
{
2011-02-11 20:02:08 +00:00
comboBox_gameListFilter -> setCurrentIndex ( myConfig -> readConfigInt ( "DlgGameLobbyGameListFilterIndex" ));
treeView_GameList -> sortByColumn ( myConfig -> readConfigInt ( "DlgGameLobbyGameListSortingSection" ), ( Qt :: SortOrder ) myConfig -> readConfigInt ( "DlgGameLobbyGameListSortingOrder" ) );
comboBox_nickListFilter -> setCurrentIndex ( myConfig -> readConfigInt ( "DlgGameLobbyNickListSortFilterIndex" ));
2009-01-11 22:36:43 +00:00
}
2009-06-14 22:56:49 +00:00
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: changeGameListFilter ( int index )
{
2009-06-14 22:56:49 +00:00
2011-02-11 20:02:08 +00:00
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 ;
2011-03-04 21:03:42 +00:00
case 5 : {
myGameListSortFilterProxyModel -> setColumn1RegExp ( QRegExp ( "nonfull" , Qt :: CaseInsensitive , QRegExp :: FixedString ));
myGameListSortFilterProxyModel -> setColumn2RegExp ( QRegExp ( "open" , Qt :: CaseInsensitive , QRegExp :: FixedString ));
myGameListSortFilterProxyModel -> setColumn3RegExp ( QRegExp ( "ranking" , Qt :: CaseInsensitive , QRegExp :: FixedString ));
myGameListSortFilterProxyModel -> setColumn4RegExp ( QRegExp ());
}
break ;
2011-02-11 20:02:08 +00:00
default :
;
}
myGameListSortFilterProxyModel -> setFilterRegExp ( QString ());
myGameListSortFilterProxyModel -> setFilterKeyColumn ( 0 );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
writeDialogSettings ( 1 );
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
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;}" );
2009-06-16 09:13:45 +00:00
2009-06-14 22:56:49 +00:00
}
2009-06-16 09:13:45 +00:00
2010-08-29 21:50:18 +00:00
void gameLobbyDialogImpl :: changeNickListFilter ( int state )
{
2011-02-11 20:02:08 +00:00
myNickListSortFilterProxyModel -> setFilterState ( state );
myNickListModel -> sort ( 0 , Qt :: DescendingOrder );
2010-08-29 21:50:18 +00:00
2011-02-11 20:02:08 +00:00
myNickListSortFilterProxyModel -> setFilterRegExp ( QString ());
myNickListSortFilterProxyModel -> setFilterKeyColumn ( 0 );
2010-08-30 08:31:42 +00:00
2011-02-11 20:02:08 +00:00
writeDialogSettings ( 2 );
2010-08-29 21:50:18 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: changeGameListSorting ()
{
2010-03-30 12:25:30 +00:00
2011-02-11 20:02:08 +00:00
writeDialogSettings ( 0 );
2009-06-16 09:13:45 +00:00
}
2010-01-05 12:53:37 +00:00
void gameLobbyDialogImpl :: registeredUserMode ()
{
2011-02-11 20:02:08 +00:00
lineEdit_ChatInput -> clear ();
lineEdit_ChatInput -> setEnabled ( true );
guestMode = false ;
2010-01-05 12:53:37 +00:00
}
void gameLobbyDialogImpl :: guestUserMode ()
{
2011-02-11 20:02:08 +00:00
lineEdit_ChatInput -> setText ( tr ( "Chat is only available to registered players." ));
lineEdit_ChatInput -> setDisabled ( true );
guestMode = true ;
2010-01-05 12:53:37 +00:00
}
2010-03-27 21:55:34 +00:00
void gameLobbyDialogImpl :: showNickListContextMenu ( QPoint p )
{
2011-02-11 20:02:08 +00:00
if ( myNickListModel -> rowCount () && myNickListSelectionModel -> currentIndex (). isValid ()) {
2010-03-27 21:55:34 +00:00
2011-02-11 20:02:08 +00:00
assert ( mySession );
2010-10-11 15:44:56 +00:00
unsigned playerUid = myNickListSelectionModel -> currentIndex (). data ( Qt :: UserRole ). toUInt ();
2010-07-15 10:55:09 +00:00
2011-02-11 20:02:08 +00:00
if ( inGame && mySession -> getClientGameInfo ( mySession -> getClientCurrentGameId ()). data . gameType == GAME_TYPE_INVITE_ONLY && playerUid != mySession -> getClientUniquePlayerId () && ! mySession -> getClientPlayerInfo ( playerUid ). isGuest ) {
2010-03-30 17:30:33 +00:00
2011-02-11 20:02:08 +00:00
nickListInviteAction -> setEnabled ( true );
nickListInviteAction -> setText ( tr ( "Invite %1" ). arg ( QString :: fromUtf8 ( mySession -> getClientPlayerInfo ( playerUid ). playerName . c_str ())));
2010-03-30 17:30:33 +00:00
2011-02-11 20:02:08 +00:00
} else {
nickListInviteAction -> setText ( tr ( "Invite player ..." ));
nickListInviteAction -> setEnabled ( false );
}
2010-03-30 17:30:33 +00:00
2011-02-11 20:02:08 +00:00
if ( playerUid != mySession -> getClientUniquePlayerId () && ! mySession -> getClientPlayerInfo ( playerUid ). isGuest ) {
2010-03-30 19:57:44 +00:00
2011-02-11 20:02:08 +00:00
nickListIgnorePlayerAction -> setEnabled ( true );
nickListIgnorePlayerAction -> setText ( tr ( "Ignore %1" ). arg ( QString :: fromUtf8 ( mySession -> getClientPlayerInfo ( playerUid ). playerName . c_str ())));
} else {
2010-03-30 19:57:44 +00:00
2011-02-11 20:02:08 +00:00
nickListIgnorePlayerAction -> setEnabled ( false );
nickListIgnorePlayerAction -> setText ( tr ( "Ignore player ..." ));
}
2010-03-30 19:57:44 +00:00
2011-02-11 20:02:08 +00:00
unsigned gameIdOfPlayer = mySession -> getGameIdOfPlayer ( playerUid );
QString playerInGameInfoString ;
if ( gameIdOfPlayer ) {
playerInGameInfoString = tr ( "%1 is playing in \" %2 \" ." ). arg ( QString :: fromUtf8 ( mySession -> getClientPlayerInfo ( playerUid ). playerName . c_str ())). arg ( QString :: fromUtf8 ( mySession -> getClientGameInfo ( gameIdOfPlayer ). name . c_str ()));
} else {
playerInGameInfoString = tr ( "%1 is not playing at the moment." ). arg ( QString :: fromUtf8 ( mySession -> getClientPlayerInfo ( playerUid ). playerName . c_str ()));
}
nickListPlayerInGameInfo -> setText ( playerInGameInfoString );
2010-07-15 10:55:09 +00:00
2011-02-11 20:02:08 +00:00
//popup a little more to the right to avaoid double click action
QPoint tempPoint = p ;
tempPoint . setX ( p . x () + 5 );
nickListContextMenu -> popup ( treeView_NickList -> mapToGlobal ( tempPoint ));
}
2010-03-27 21:55:34 +00:00
}
void gameLobbyDialogImpl :: invitePlayerToCurrentGame ()
{
2011-02-11 20:02:08 +00:00
if ( myNickListSelectionModel -> currentIndex (). isValid ()) {
mySession -> invitePlayerToCurrentGame ( myNickListSelectionModel -> currentIndex (). data ( Qt :: UserRole ). toUInt ());
}
2010-03-27 21:55:34 +00:00
}
2010-03-28 22:17:18 +00:00
void gameLobbyDialogImpl :: showInfoMsgBox ()
{
2011-02-11 20:02:08 +00:00
switch ( infoMsgToShowId ) {
case 2 : {
2011-11-06 00:30:34 +00:00
inviteOnlyInfoMsgBox -> setModal ( false );
inviteOnlyInfoMsgBox -> show ( 2 , tr ( "You have entered a game with type \" invite-only \" . \n Feel free to invite other players by right-clicking on their nick in the available players list." ), tr ( "PokerTH - Info Message" ), QPixmap ( ":/gfx/ktip.png" ), QDialogButtonBox :: Ok , true );
2011-02-11 20:02:08 +00:00
}
break ;
default :
;
break ;
}
2010-03-28 22:17:18 +00:00
}
2010-03-29 13:08:59 +00:00
void gameLobbyDialogImpl :: showInvitationDialog ( unsigned gameId , unsigned playerIdFrom )
{
2011-02-11 20:02:08 +00:00
if ( inviteDialogIsCurrentlyShown || playerIsOnIgnoreList ( playerIdFrom )) {
2010-03-31 12:33:00 +00:00
2011-02-11 20:02:08 +00:00
mySession -> rejectGameInvitation ( gameId , DENY_GAME_INVITATION_BUSY );
} else {
2010-03-29 13:08:59 +00:00
2011-02-11 20:02:08 +00:00
inviteDialogIsCurrentlyShown = true ;
2010-03-29 13:08:59 +00:00
2011-02-11 20:02:08 +00:00
myMessageDialogImpl dialog ( myConfig , this );
if ( dialog . exec ( 3 , tr ( "You have been invited to the game <b>%1</b> by <b>%2</b>.<br>Would you like 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 )) {
2010-03-30 12:12:22 +00:00
2011-02-11 20:02:08 +00:00
mySession -> acceptGameInvitation ( gameId );
inviteDialogIsCurrentlyShown = false ;
} else {
mySession -> rejectGameInvitation ( gameId , DENY_GAME_INVITATION_NO );
inviteDialogIsCurrentlyShown = false ;
}
}
2010-03-29 13:08:59 +00:00
}
2010-03-30 17:30:33 +00:00
void gameLobbyDialogImpl :: chatInfoPlayerInvitation ( unsigned gameId , unsigned playerIdWho , unsigned playerIdFrom )
2010-03-29 13:08:59 +00:00
{
2011-02-11 20:02:08 +00:00
textBrowser_ChatDisplay -> append ( tr ( "<span style='color:blue;'>%1 has been invited to %2 by %3.</span>" ). arg ( QString :: fromUtf8 ( mySession -> getClientPlayerInfo ( playerIdWho ). playerName . c_str ())). arg ( QString :: fromUtf8 ( mySession -> getClientGameInfo ( gameId ). name . c_str ())). arg ( QString :: fromUtf8 ( mySession -> getClientPlayerInfo ( playerIdFrom ). playerName . c_str ())));
2010-03-29 13:08:59 +00:00
}
2010-03-30 17:30:33 +00:00
void gameLobbyDialogImpl :: chatInfoPlayerRejectedInvitation ( unsigned gameId , unsigned playerIdWho , DenyGameInvitationReason reason )
2010-03-29 13:08:59 +00:00
{
2010-03-30 17:30:33 +00:00
2011-02-11 20:02:08 +00:00
QString string ;
if ( reason == DENY_GAME_INVITATION_NO ) string = tr ( "<span style='color:red;'>%1 has rejected the invitation to %2.</span>" );
2010-03-29 13:08:59 +00:00
2011-02-11 20:02:08 +00:00
if ( reason == DENY_GAME_INVITATION_BUSY ) string = tr ( "<span style='color:red;'>%1 cannot join %2 because he is busy.</span>" );
2010-03-29 13:08:59 +00:00
2011-02-11 20:02:08 +00:00
textBrowser_ChatDisplay -> append ( string . arg ( QString :: fromUtf8 ( mySession -> getClientPlayerInfo ( playerIdWho ). playerName . c_str ())). arg ( QString :: fromUtf8 ( mySession -> getClientGameInfo ( gameId ). name . c_str ())));
2010-03-30 12:25:30 +00:00
2010-03-29 13:08:59 +00:00
}
2010-03-30 17:30:33 +00:00
2011-02-11 20:02:08 +00:00
bool gameLobbyDialogImpl :: playerIsOnIgnoreList ( unsigned playerId )
{
2010-03-30 17:30:33 +00:00
2011-02-11 20:02:08 +00:00
list < std :: string > playerIgnoreList = myConfig -> readConfigStringList ( "PlayerIgnoreList" );
list < std :: string >:: iterator it1 ;
2011-02-09 14:33:39 +00:00
for ( it1 = playerIgnoreList . begin (); it1 != playerIgnoreList . end (); ++ it1 ) {
2010-03-30 17:30:33 +00:00
2011-02-11 20:02:08 +00:00
if ( QString :: fromUtf8 ( mySession -> getClientPlayerInfo ( playerId ). playerName . c_str ()) == QString :: fromUtf8 ( it1 -> c_str ())) {
return true ;
}
}
return false ;
2010-03-30 17:30:33 +00:00
}
2011-02-11 20:02:08 +00:00
void gameLobbyDialogImpl :: putPlayerOnIgnoreList ()
{
2010-03-30 17:30:33 +00:00
2011-02-11 20:02:08 +00:00
if ( myNickListSelectionModel -> currentIndex (). isValid ()) {
2010-03-30 17:30:33 +00:00
2011-02-11 20:02:08 +00:00
unsigned playerId = myNickListSelectionModel -> currentIndex (). data ( Qt :: UserRole ). toUInt ();
2010-03-30 17:30:33 +00:00
2011-02-11 20:02:08 +00:00
if ( ! playerIsOnIgnoreList ( playerId )) {
2010-03-30 19:38:14 +00:00
2011-02-11 20:02:08 +00:00
myMessageDialogImpl dialog ( myConfig , this );
if ( dialog . exec ( 4 , tr ( "You will no longer receive chat messages or game invitations from this user.<br>Do you really want to put player <b>%1</b> on your ignore list?" ). arg ( QString :: fromUtf8 ( mySession -> getClientPlayerInfo ( playerId ). playerName . c_str ())), tr ( "PokerTH - Question" ), QPixmap ( ":/gfx/im-ban-user_64.png" ), QDialogButtonBox :: Yes | QDialogButtonBox :: No , false ) == QDialog :: Accepted ) {
2010-03-30 19:38:14 +00:00
2011-02-11 20:02:08 +00:00
list < std :: string > playerIgnoreList = myConfig -> readConfigStringList ( "PlayerIgnoreList" );
playerIgnoreList . push_back ( QString ( "%1" ). arg ( QString :: fromUtf8 ( mySession -> getClientPlayerInfo ( playerId ). playerName . c_str ())). toUtf8 (). constData ());
myConfig -> writeConfigStringList ( "PlayerIgnoreList" , playerIgnoreList );
myConfig -> writeBuffer ();
2010-03-31 12:33:00 +00:00
2011-02-11 20:02:08 +00:00
myChat -> refreshIgnoreList ();
}
}
}
2010-03-30 17:30:33 +00:00
}
2010-08-08 23:14:00 +00:00
void gameLobbyDialogImpl :: searchForPlayerRegExpChanged ()
{
2011-02-11 20:02:08 +00:00
QRegExp regExp ( lineEdit_searchForPlayers -> text (), Qt :: CaseInsensitive );
myNickListSortFilterProxyModel -> setFilterRegExp ( regExp );
2010-08-08 23:14:00 +00:00
}
2010-09-05 02:00:23 +00:00
void gameLobbyDialogImpl :: showAutoStartTimer ()
{
2011-02-11 20:02:08 +00:00
autoStartTimerOverlay -> show ();
autoStartTimerOverlay -> setGeometry ((( scrollArea_gameInfos -> geometry (). width () - 190 ) / 2 ), (( scrollArea_gameInfos -> geometry (). height () - 50 ) / 2 ), 190 , 50 );
2010-09-05 12:26:36 +00:00
2011-02-11 20:02:08 +00:00
QString string ( tr ( "The game will start in<br><b>%1</b> seconds." ). arg ( 6 ));
autoStartTimerOverlay -> setText ( "<span style='color:#008B00; font-size:9pt;'>" + string + "</span>" );
autoStartTimerCounter = 6 ;
autoStartTimer -> start ( 1000 );
2010-09-05 02:00:23 +00:00
}
void gameLobbyDialogImpl :: updateAutoStartTimer ()
{
2011-02-11 20:02:08 +00:00
-- autoStartTimerCounter ;
if ( autoStartTimerCounter ) {
QString string ( tr ( "The game will start in<br><b>%1</b> seconds." ). arg ( autoStartTimerCounter ));
autoStartTimerOverlay -> setText ( "<span style='color:#008B00; font-size:9pt;'>" + string + "</span>" );
} else {
autoStartTimer -> stop ();
autoStartTimerOverlay -> hide ();
}
2010-09-05 02:00:23 +00:00
}
2011-03-05 21:20:08 +00:00
void gameLobbyDialogImpl :: openPlayerStats ()
{
if ( myNickListSelectionModel -> currentIndex (). isValid ()) {
unsigned playerId = myNickListSelectionModel -> currentIndex (). data ( Qt :: UserRole ). toUInt ();
if ( ! mySession -> getClientPlayerInfo ( playerId ). isGuest ) {
QUrl url ( "http://pokerth.net/redirect_user_profile.php?nick=" + QUrl :: toPercentEncoding ( myNickListSelectionModel -> currentIndex (). data ( Qt :: DisplayRole ). toString ()));
QDesktopServices :: openUrl ( url );
}
}
}
void gameLobbyDialogImpl :: showConnectedPlayersContextMenu ( QPoint p )
{
if ( treeWidget_connectedPlayers -> currentItem ()) {
assert ( mySession );
unsigned playerUid = treeWidget_connectedPlayers -> currentItem () -> data ( 0 , Qt :: UserRole ). toUInt ();
if ( ! mySession -> getClientPlayerInfo ( playerUid ). isGuest ) {
//popup a little more to the right to avaoid double click action
QPoint tempPoint = p ;
tempPoint . setX ( p . x () + 5 );
connectedPlayersListPlayerInfoSubMenu -> popup ( treeWidget_connectedPlayers -> mapToGlobal ( tempPoint ));
}
}
}
2011-03-05 22:08:57 +00:00
QString gameLobbyDialogImpl :: getFullCountryString ( QString cs )
{
2011-04-10 08:32:40 +00:00
// Initialise map of country strings, if needed.
if ( countryStringMap . empty ()) {
countryStringMap . insert ( CountryStringMap :: value_type ( "AF" , tr ( "Afghanistan" )));
2011-04-10 10:04:42 +00:00
countryStringMap . insert ( CountryStringMap :: value_type ( "AX" , tr ( "ALand Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AL" , tr ( "Albania" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "DZ" , tr ( "Algeria" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AS" , tr ( "American Samoa" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AD" , tr ( "Andorra" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AO" , tr ( "Angola" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AI" , tr ( "Anguilla" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AQ" , tr ( "Antarctica" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AG" , tr ( "Antigua And Barbuda" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AR" , tr ( "Argentina" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AM" , tr ( "Armenia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AW" , tr ( "Aruba" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AU" , tr ( "Australia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AT" , tr ( "Austria" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AZ" , tr ( "Azerbaijan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BS" , tr ( "Bahamas" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BH" , tr ( "Bahrain" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BD" , tr ( "Bangladesh" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BB" , tr ( "Barbados" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BY" , tr ( "Belarus" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BE" , tr ( "Belgium" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BZ" , tr ( "Belize" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BJ" , tr ( "Benin" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BM" , tr ( "Bermuda" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BT" , tr ( "Bhutan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BO" , tr ( "Bolivia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BA" , tr ( "Bosnia And Herzegovina" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BW" , tr ( "Botswana" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BV" , tr ( "Bouvet Island" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BR" , tr ( "Brazil" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "IO" , tr ( "British Indian Ocean Territory" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BN" , tr ( "Brunei Darussalam" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BG" , tr ( "Bulgaria" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BF" , tr ( "Burkina Faso" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "BI" , tr ( "Burundi" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KH" , tr ( "Cambodia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CM" , tr ( "Cameroon" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CA" , tr ( "Canada" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CV" , tr ( "Cape Verde" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KY" , tr ( "Cayman Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CF" , tr ( "Central African Republic" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TD" , tr ( "Chad" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CL" , tr ( "Chile" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CN" , tr ( "China" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CX" , tr ( "Christmas Island" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CC" , tr ( "Cocos (Keeling) Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CO" , tr ( "Colombia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KM" , tr ( "Comoros" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CG" , tr ( "Congo" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CD" , tr ( "Congo, The Democratic Republic Of The" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CK" , tr ( "Cook Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CR" , tr ( "Costa Rica" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CI" , tr ( "Cote D'Ivoire" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "HR" , tr ( "Croatia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CU" , tr ( "Cuba" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CY" , tr ( "Cyprus" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CZ" , tr ( "Czech Republic" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "DK" , tr ( "Denmark" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "DJ" , tr ( "Djibouti" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "DM" , tr ( "Dominica" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "DO" , tr ( "Dominican Republic" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "EC" , tr ( "Ecuador" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "EG" , tr ( "Egypt" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SV" , tr ( "El Salvador" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GQ" , tr ( "Equatorial Guinea" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "ER" , tr ( "Eritrea" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "EE" , tr ( "Estonia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "ET" , tr ( "Ethiopia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "FK" , tr ( "Falkland Islands (Malvinas)" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "FO" , tr ( "Faroe Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "FJ" , tr ( "Fiji" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "FI" , tr ( "Finland" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "FR" , tr ( "France" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GF" , tr ( "French Guiana" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PF" , tr ( "French Polynesia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TF" , tr ( "French Southern Territories" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GA" , tr ( "Gabon" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GM" , tr ( "Gambia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GE" , tr ( "Georgia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "DE" , tr ( "Germany" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GH" , tr ( "Ghana" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GI" , tr ( "Gibraltar" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GR" , tr ( "Greece" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GL" , tr ( "Greenland" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GD" , tr ( "Grenada" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GP" , tr ( "Guadeloupe" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GU" , tr ( "Guam" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GT" , tr ( "Guatemala" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GG" , tr ( "Guernsey" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GN" , tr ( "Guinea" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GW" , tr ( "Guinea-Bissau" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GY" , tr ( "Guyana" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "HT" , tr ( "Haiti" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "HM" , tr ( "Heard Island And Mcdonald Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "VA" , tr ( "Holy See (Vatican City State)" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "HN" , tr ( "Honduras" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "HK" , tr ( "Hong Kong" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "HU" , tr ( "Hungary" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "IS" , tr ( "Iceland" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "IN" , tr ( "India" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "ID" , tr ( "Indonesia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "IR" , tr ( "Iran, Islamic Republic Of" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "IQ" , tr ( "Iraq" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "IE" , tr ( "Ireland" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "IM" , tr ( "Isle Of Man" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "IL" , tr ( "Israel" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "IT" , tr ( "Italy" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "JM" , tr ( "Jamaica" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "JP" , tr ( "Japan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "JE" , tr ( "Jersey" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "JO" , tr ( "Jordan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KZ" , tr ( "Kazakhstan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KE" , tr ( "Kenya" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KI" , tr ( "Kiribati" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KP" , tr ( "Korea, Democratic People'S Republic Of" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KR" , tr ( "Korea, Republic Of" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KW" , tr ( "Kuwait" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KG" , tr ( "Kyrgyzstan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LA" , tr ( "Lao People'S Democratic Republic" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LV" , tr ( "Latvia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LB" , tr ( "Lebanon" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LS" , tr ( "Lesotho" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LR" , tr ( "Liberia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LY" , tr ( "Libyan Arab Jamahiriya" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LI" , tr ( "Liechtenstein" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LT" , tr ( "Lithuania" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LU" , tr ( "Luxembourg" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MO" , tr ( "Macao" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MK" , tr ( "Macedonia, The Former Yugoslav Republic Of" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MG" , tr ( "Madagascar" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MW" , tr ( "Malawi" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MY" , tr ( "Malaysia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MV" , tr ( "Maldives" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "ML" , tr ( "Mali" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MT" , tr ( "Malta" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MH" , tr ( "Marshall Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MQ" , tr ( "Martinique" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MR" , tr ( "Mauritania" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MU" , tr ( "Mauritius" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "YT" , tr ( "Mayotte" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MX" , tr ( "Mexico" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "FM" , tr ( "Micronesia, Federated States Of" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MD" , tr ( "Moldova, Republic Of" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MC" , tr ( "Monaco" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MN" , tr ( "Mongolia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MS" , tr ( "Montserrat" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MA" , tr ( "Morocco" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MZ" , tr ( "Mozambique" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MM" , tr ( "Myanmar" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NA" , tr ( "Namibia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NR" , tr ( "Nauru" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NP" , tr ( "Nepal" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NL" , tr ( "Netherlands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AN" , tr ( "Netherlands Antilles" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NC" , tr ( "New Caledonia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NZ" , tr ( "New Zealand" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NI" , tr ( "Nicaragua" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NE" , tr ( "Niger" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NG" , tr ( "Nigeria" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NU" , tr ( "Niue" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NF" , tr ( "Norfolk Island" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "MP" , tr ( "Northern Mariana Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "NO" , tr ( "Norway" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "OM" , tr ( "Oman" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PK" , tr ( "Pakistan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PW" , tr ( "Palau" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PS" , tr ( "Palestinian Territory, Occupied" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PA" , tr ( "Panama" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PG" , tr ( "Papua New Guinea" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PY" , tr ( "Paraguay" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PE" , tr ( "Peru" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PH" , tr ( "Philippines" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PN" , tr ( "Pitcairn" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PL" , tr ( "Poland" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PT" , tr ( "Portugal" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PR" , tr ( "Puerto Rico" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "QA" , tr ( "Qatar" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "RE" , tr ( "Reunion" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "RO" , tr ( "Romania" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "RU" , tr ( "Russian Federation" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "RW" , tr ( "Rwanda" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SH" , tr ( "Saint Helena" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "KN" , tr ( "Saint Kitts And Nevis" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LC" , tr ( "Saint Lucia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "PM" , tr ( "Saint Pierre And Miquelon" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "VC" , tr ( "Saint Vincent And The Grenadines" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "WS" , tr ( "Samoa" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SM" , tr ( "San Marino" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "ST" , tr ( "Sao Tome And Principe" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SA" , tr ( "Saudi Arabia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SN" , tr ( "Senegal" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CS" , tr ( "Serbia And Montenegro" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SC" , tr ( "Seychelles" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SL" , tr ( "Sierra Leone" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SG" , tr ( "Singapore" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SK" , tr ( "Slovakia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SI" , tr ( "Slovenia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SB" , tr ( "Solomon Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SO" , tr ( "Somalia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "ZA" , tr ( "South Africa" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GS" , tr ( "South Georgia And The South Sandwich Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "ES" , tr ( "Spain" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "LK" , tr ( "Sri Lanka" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SD" , tr ( "Sudan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SR" , tr ( "Suriname" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SJ" , tr ( "Svalbard And Jan Mayen" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SZ" , tr ( "Swaziland" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SE" , tr ( "Sweden" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "CH" , tr ( "Switzerland" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "SY" , tr ( "Syrian Arab Republic" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TW" , tr ( "Taiwan, Province Of China" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TJ" , tr ( "Tajikistan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TZ" , tr ( "Tanzania, United Republic Of" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TH" , tr ( "Thailand" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TL" , tr ( "Timor-Leste" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TG" , tr ( "Togo" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TK" , tr ( "Tokelau" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TO" , tr ( "Tonga" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TT" , tr ( "Trinidad And Tobago" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TN" , tr ( "Tunisia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TR" , tr ( "Turkey" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TM" , tr ( "Turkmenistan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TC" , tr ( "Turks And Caicos Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "TV" , tr ( "Tuvalu" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "UG" , tr ( "Uganda" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "UA" , tr ( "Ukraine" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "AE" , tr ( "United Arab Emirates" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "GB" , tr ( "United Kingdom" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "US" , tr ( "United States" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "UM" , tr ( "United States Minor Outlying Islands" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "UY" , tr ( "Uruguay" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "UZ" , tr ( "Uzbekistan" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "VU" , tr ( "Vanuatu" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "VE" , tr ( "Venezuela" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "VN" , tr ( "Viet Nam" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "VG" , tr ( "Virgin Islands, British" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "VI" , tr ( "Virgin Islands, U.S." )));
countryStringMap . insert ( CountryStringMap :: value_type ( "WF" , tr ( "Wallis And Futuna" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "EH" , tr ( "Western Sahara" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "YE" , tr ( "Yemen" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "ZM" , tr ( "Zambia" )));
countryStringMap . insert ( CountryStringMap :: value_type ( "ZW" , tr ( "Zimbabwe" )));
2011-04-10 08:32:40 +00:00
}
2011-03-05 22:08:57 +00:00
2011-04-10 08:32:40 +00:00
QString fullString ( "" );
if ( ! cs . isEmpty ()) {
CountryStringMap :: const_iterator pos = countryStringMap . find ( cs );
if ( pos != countryStringMap . end ()) {
fullString = pos -> second ;
}
}
2011-03-05 22:08:57 +00:00
return fullString ;
}
2011-08-21 18:15:42 +00:00
void gameLobbyDialogImpl :: stopWaitStartGameMsgBoxTimer ()
{
waitStartGameMsgBoxTimer -> stop ();
}
2011-11-06 00:30:34 +00:00
void gameLobbyDialogImpl :: closeAllChildDialogs ()
{
inviteOnlyInfoMsgBox -> hide ();
waitStartGameMsgBox -> hide ();
waitRejoinStartGameMsgBox -> hide ();
}