adds "join any game" button + translation strings update

This commit is contained in:
doitux
2007-11-23 00:57:40 +00:00
parent 4ff47b70bd
commit 6be04404a5
17 changed files with 4751 additions and 3679 deletions
+7
View File
@@ -402,6 +402,13 @@
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pushButton_joinAnyGame" >
<property name="text" >
<string>Join any game</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
@@ -40,10 +40,11 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) );
connect( treeWidget_GameList, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( gameSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
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( treeWidget_GameList, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( gameSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), this, SLOT( sendChatMessage() ) );
connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), this, SLOT( checkChatInputLength(QString) ) );
@@ -172,6 +173,25 @@ void gameLobbyDialogImpl::joinGame()
}
}
void gameLobbyDialogImpl::joinAnyGame() {
bool found = FALSE;
QTreeWidgetItemIterator it(treeWidget_GameList);
while (*it) {
if ((*it)->data(2, Qt::DisplayRole) == tr("open") && (*it)->data(3, Qt::UserRole) == 0)
{
treeWidget_GameList->setCurrentItem((*it));
found = TRUE;
break;
}
++it;
}
if(found) { joinGame(); }
}
void gameLobbyDialogImpl::refresh(int actionID) {
if (actionID == MSG_NET_GAME_CLIENT_START)
@@ -306,6 +326,9 @@ void gameLobbyDialogImpl::refreshGameStats() {
label_openGamesCounter->setText("| "+tr("running games: %1").arg(runningGamesCounter));
label_runningGamesCounter->setText("| "+tr("open games: %1").arg(openGamesCounter));
//refresh joinAnyGameButton state
joinAnyGameButtonRefresh();
}
void gameLobbyDialogImpl::refreshPlayerStats() {
@@ -398,6 +421,8 @@ void gameLobbyDialogImpl::clearDialog()
pushButton_CreateGame->show();
pushButton_JoinGame->show();
pushButton_JoinGame->setEnabled(false);
pushButton_joinAnyGame->show();
pushButton_joinAnyGame->setEnabled(false);
treeWidget_GameList->setColumnWidth(0,195);
treeWidget_GameList->setColumnWidth(1,70);
@@ -549,6 +574,7 @@ void gameLobbyDialogImpl::joinedGameDialogUpdate() {
treeWidget_connectedPlayers->clear();
pushButton_CreateGame->hide();
pushButton_JoinGame->hide();
pushButton_joinAnyGame->hide();
pushButton_Leave->show();
}
@@ -579,6 +605,8 @@ void gameLobbyDialogImpl::leftGameDialogUpdate() {
pushButton_CreateGame->show();
pushButton_JoinGame->show();
pushButton_JoinGame->setEnabled(false);
pushButton_joinAnyGame->show();
joinAnyGameButtonRefresh();
lineEdit_ChatInput->setFocus();
}
@@ -718,3 +746,18 @@ void gameLobbyDialogImpl::showWaitStartGameMsgBox() {
waitStartGameMsgBox->activateWindow();
}
void gameLobbyDialogImpl::joinAnyGameButtonRefresh() {
int openNonPrivateGamesCounter = 0;
QTreeWidgetItemIterator it(treeWidget_GameList);
while (*it) {
if ((*it)->data(2, Qt::DisplayRole) == tr("open") && (*it)->data(3, Qt::UserRole) == 0) { openNonPrivateGamesCounter++; }
++it;
}
if(openNonPrivateGamesCounter) pushButton_joinAnyGame->setEnabled(TRUE);
else pushButton_joinAnyGame->setEnabled(FALSE);
}
@@ -51,6 +51,7 @@ public slots:
void createGame();
void joinGame();
void joinAnyGame();
void gameSelected(QTreeWidgetItem*, QTreeWidgetItem*);
void updateGameItem(QTreeWidgetItem *item, unsigned gameId);
@@ -102,6 +103,8 @@ public slots:
void showWaitStartGameMsgBox();
void joinAnyGameButtonRefresh();
private: