gamelist show and markup the game where the player is joined into
(independent from filter); blinking start-button if game is full
This commit is contained in:
@@ -156,14 +156,14 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_StartGame">
|
<widget class="QPushButton" name="pushButton_StartGame">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Start Game</string>
|
<string>&Start Game</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_Kick">
|
<widget class="QPushButton" name="pushButton_Kick">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Kick Player</string>
|
<string>&Kick Player</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -359,7 +359,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Leave Game</string>
|
<string>&Leave Game</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -379,7 +379,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_joinAnyGame">
|
<widget class="QPushButton" name="pushButton_joinAnyGame">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Join any game</string>
|
<string>Join &any game</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -402,14 +402,14 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_CreateGame">
|
<widget class="QPushButton" name="pushButton_CreateGame">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Create Game</string>
|
<string>&Create Game</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_JoinGame">
|
<widget class="QPushButton" name="pushButton_JoinGame">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Join Game</string>
|
<string>&Join Game</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -561,6 +561,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>treeWidget_NickList</tabstop>
|
<tabstop>treeWidget_NickList</tabstop>
|
||||||
|
<tabstop>comboBox_gameListFilter</tabstop>
|
||||||
<tabstop>treeView_GameList</tabstop>
|
<tabstop>treeView_GameList</tabstop>
|
||||||
<tabstop>pushButton_joinAnyGame</tabstop>
|
<tabstop>pushButton_joinAnyGame</tabstop>
|
||||||
<tabstop>pushButton_CreateGame</tabstop>
|
<tabstop>pushButton_CreateGame</tabstop>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <net/socket_msg.h>
|
#include <net/socket_msg.h>
|
||||||
|
|
||||||
gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
|
gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
|
||||||
: QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), isAdmin(false), inGame(false), myChat(NULL), keyUpCounter(0)
|
: QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), myCurrentGameId(0), isAdmin(false), inGame(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@@ -44,6 +44,11 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
|
|||||||
|
|
||||||
waitStartGameMsgBoxTimer = new QTimer(this);
|
waitStartGameMsgBoxTimer = new QTimer(this);
|
||||||
waitStartGameMsgBoxTimer->setSingleShot(TRUE);
|
waitStartGameMsgBoxTimer->setSingleShot(TRUE);
|
||||||
|
blinkingButtonAnimationTimer = new QTimer(this);
|
||||||
|
blinkingButtonAnimationTimer->setInterval(1000);
|
||||||
|
|
||||||
|
defaultStartButtonColor = pushButton_StartGame->palette().button().color();
|
||||||
|
defaultStartButtonTextColor = pushButton_StartGame->palette().buttonText().color();
|
||||||
|
|
||||||
myGameListModel = new QStandardItemModel(this);
|
myGameListModel = new QStandardItemModel(this);
|
||||||
myGameListSortFilterProxyModel = new MyGameListSortFilterProxyModel(this);
|
myGameListSortFilterProxyModel = new MyGameListSortFilterProxyModel(this);
|
||||||
@@ -79,6 +84,7 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
|
|||||||
connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), myChat, SLOT( checkInputLength(QString) ) );
|
connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), myChat, SLOT( checkInputLength(QString) ) );
|
||||||
connect( lineEdit_ChatInput, SIGNAL( textEdited (QString) ), myChat, SLOT( setChatTextEdited() ) );
|
connect( lineEdit_ChatInput, SIGNAL( textEdited (QString) ), myChat, SLOT( setChatTextEdited() ) );
|
||||||
connect( waitStartGameMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showWaitStartGameMsgBox() ));
|
connect( waitStartGameMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showWaitStartGameMsgBox() ));
|
||||||
|
connect( blinkingButtonAnimationTimer, SIGNAL(timeout()), this, SLOT( blinkingStartButtonAnimation() ));
|
||||||
connect( comboBox_gameListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeGameListFilter(int)));
|
connect( comboBox_gameListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeGameListFilter(int)));
|
||||||
|
|
||||||
lineEdit_ChatInput->installEventFilter(this);
|
lineEdit_ChatInput->installEventFilter(this);
|
||||||
@@ -174,6 +180,7 @@ void gameLobbyDialogImpl::createGame()
|
|||||||
label_TimeoutForPlayerAction->setText(QString::number(gameData.playerActionTimeoutSec));
|
label_TimeoutForPlayerAction->setText(QString::number(gameData.playerActionTimeoutSec));
|
||||||
|
|
||||||
mySession->clientCreateGame(gameData, currentGameName.toUtf8().constData(), myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData());
|
mySession->clientCreateGame(gameData, currentGameName.toUtf8().constData(), myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +191,8 @@ void gameLobbyDialogImpl::joinGame()
|
|||||||
if (!inGame && selection->hasSelection())
|
if (!inGame && selection->hasSelection())
|
||||||
{
|
{
|
||||||
unsigned gameId = selection->selectedRows().first().data(Qt::UserRole).toUInt();
|
unsigned gameId = selection->selectedRows().first().data(Qt::UserRole).toUInt();
|
||||||
|
myCurrentGameId = gameId;
|
||||||
|
qDebug() << "joined game: " << myCurrentGameId;
|
||||||
GameInfo info(mySession->getClientGameInfo(gameId));
|
GameInfo info(mySession->getClientGameInfo(gameId));
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
QString password;
|
QString password;
|
||||||
@@ -299,6 +308,29 @@ void gameLobbyDialogImpl::updateGameItem(QList <QStandardItem*> itemList, unsign
|
|||||||
itemList.at(0)->setData(gameId, Qt::UserRole);
|
itemList.at(0)->setData(gameId, Qt::UserRole);
|
||||||
itemList.at(0)->setData(QString::fromUtf8(info.name.c_str()), Qt::DisplayRole);
|
itemList.at(0)->setData(QString::fromUtf8(info.name.c_str()), Qt::DisplayRole);
|
||||||
|
|
||||||
|
PlayerIdList::const_iterator i = info.players.begin();
|
||||||
|
PlayerIdList::const_iterator end = info.players.end();
|
||||||
|
|
||||||
|
while (i != end)
|
||||||
|
{
|
||||||
|
if(myPlayerId == *i) {
|
||||||
|
itemList.at(0)->setData( "MeInThisGame", 16);
|
||||||
|
itemList.at(0)->setBackground(QBrush(QColor(0, 255, 0, 127)));
|
||||||
|
itemList.at(1)->setBackground(QBrush(QColor(0, 255, 0, 127)));
|
||||||
|
itemList.at(2)->setBackground(QBrush(QColor(0, 255, 0, 127)));
|
||||||
|
itemList.at(3)->setBackground(QBrush(QColor(0, 255, 0, 127)));
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
QString playerStr;
|
QString playerStr;
|
||||||
playerStr.sprintf("%u/%u", (unsigned)info.players.size(), (unsigned)info.data.maxNumberOfPlayers);
|
playerStr.sprintf("%u/%u", (unsigned)info.players.size(), (unsigned)info.data.maxNumberOfPlayers);
|
||||||
itemList.at(1)->setData(playerStr, Qt::DisplayRole);
|
itemList.at(1)->setData(playerStr, Qt::DisplayRole);
|
||||||
@@ -340,7 +372,6 @@ void gameLobbyDialogImpl::addGame(unsigned gameId)
|
|||||||
myGameListModel->appendRow(itemList);
|
myGameListModel->appendRow(itemList);
|
||||||
|
|
||||||
updateGameItem(itemList, gameId);
|
updateGameItem(itemList, gameId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameLobbyDialogImpl::updateGameMode(unsigned gameId, int /*newMode*/)
|
void gameLobbyDialogImpl::updateGameMode(unsigned gameId, int /*newMode*/)
|
||||||
@@ -535,6 +566,33 @@ void gameLobbyDialogImpl::checkPlayerQuantity() {
|
|||||||
else {
|
else {
|
||||||
pushButton_StartGame->setEnabled(false);
|
pushButton_StartGame->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(treeWidget_connectedPlayers->topLevelItemCount() == label_MaximumNumberOfPlayers->text().toInt()) {
|
||||||
|
blinkingButtonAnimationTimer->start();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
blinkingButtonAnimationTimer->stop();
|
||||||
|
blinkingButtonAnimationState = false;
|
||||||
|
blinkingStartButtonAnimation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gameLobbyDialogImpl::blinkingStartButtonAnimation() {
|
||||||
|
|
||||||
|
if(blinkingButtonAnimationState) {
|
||||||
|
QPalette p = pushButton_StartGame->palette();
|
||||||
|
p.setColor(QPalette::Button, QColor(Qt::red));
|
||||||
|
p.setColor(QPalette::ButtonText, QColor(Qt::white));
|
||||||
|
pushButton_StartGame->setPalette(p);
|
||||||
|
blinkingButtonAnimationState = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QPalette p = pushButton_StartGame->palette();
|
||||||
|
p.setColor(QPalette::Button, defaultStartButtonColor);
|
||||||
|
p.setColor(QPalette::ButtonText, defaultStartButtonTextColor);
|
||||||
|
pushButton_StartGame->setPalette(p);
|
||||||
|
blinkingButtonAnimationState = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +614,7 @@ void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerNa
|
|||||||
item->setData(0, Qt::UserRole, playerId);
|
item->setData(0, Qt::UserRole, playerId);
|
||||||
item->setData(0, Qt::DisplayRole, playerName);
|
item->setData(0, Qt::DisplayRole, playerName);
|
||||||
|
|
||||||
if(rights == PLAYER_RIGHTS_ADMIN) item->setBackground(0, QBrush(QColor(169,255,140)));
|
if(rights == PLAYER_RIGHTS_ADMIN) item->setBackground(0, QBrush(QColor(0, 255, 0, 127)));
|
||||||
|
|
||||||
if(this->isVisible() && inGame && myConfig->readConfigInt("PlayNetworkGameNotification")) {
|
if(this->isVisible() && inGame && myConfig->readConfigInt("PlayNetworkGameNotification")) {
|
||||||
if(treeWidget_connectedPlayers->topLevelItemCount() < label_MaximumNumberOfPlayers->text().toInt()) {
|
if(treeWidget_connectedPlayers->topLevelItemCount() < label_MaximumNumberOfPlayers->text().toInt()) {
|
||||||
@@ -609,7 +667,7 @@ void gameLobbyDialogImpl::newGameAdmin(unsigned playerId, QString)
|
|||||||
QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
|
QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
|
||||||
while (*it) {
|
while (*it) {
|
||||||
if ((*it)->data(0, Qt::UserRole) == playerId) {
|
if ((*it)->data(0, Qt::UserRole) == playerId) {
|
||||||
(*it)->setBackground(0, QBrush(QColor(169,255,140)));
|
(*it)->setBackground(0, QBrush(QColor(0, 255, 0, 127)));
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
@@ -957,7 +1015,7 @@ void gameLobbyDialogImpl::changeGameListFilter(int index) {
|
|||||||
|
|
||||||
writeDialogSettings(1);
|
writeDialogSettings(1);
|
||||||
|
|
||||||
if(index) treeView_GameList->setStyleSheet("QTreeView { border: 2px solid red; background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}");
|
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;}");
|
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;}");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public slots:
|
|||||||
|
|
||||||
gameTableImpl* getMyW() const { return myW; }
|
gameTableImpl* getMyW() const { return myW; }
|
||||||
void checkPlayerQuantity();
|
void checkPlayerQuantity();
|
||||||
|
void blinkingStartButtonAnimation();
|
||||||
|
|
||||||
void joinedNetworkGame(unsigned, QString, int);
|
void joinedNetworkGame(unsigned, QString, int);
|
||||||
void addConnectedPlayer(unsigned, QString, int);
|
void addConnectedPlayer(unsigned, QString, int);
|
||||||
@@ -120,17 +121,24 @@ private:
|
|||||||
createInternetGameDialogImpl *myCreateInternetGameDialog;
|
createInternetGameDialogImpl *myCreateInternetGameDialog;
|
||||||
QString currentGameName;
|
QString currentGameName;
|
||||||
unsigned myPlayerId;
|
unsigned myPlayerId;
|
||||||
|
unsigned myCurrentGameId;
|
||||||
bool isAdmin;
|
bool isAdmin;
|
||||||
bool inGame;
|
bool inGame;
|
||||||
LobbyChat *myChat;
|
|
||||||
QString myAppDataPath;
|
QString myAppDataPath;
|
||||||
int keyUpCounter;
|
int keyUpCounter;
|
||||||
QMessageBox *waitStartGameMsgBox;
|
QMessageBox *waitStartGameMsgBox;
|
||||||
QTimer *waitStartGameMsgBoxTimer;
|
QTimer *waitStartGameMsgBoxTimer;
|
||||||
|
QTimer *blinkingButtonAnimationTimer;
|
||||||
|
bool blinkingButtonAnimationState;
|
||||||
|
QColor defaultStartButtonColor;
|
||||||
|
QColor defaultStartButtonTextColor;
|
||||||
|
LobbyChat *myChat;
|
||||||
QStandardItemModel *myGameListModel;
|
QStandardItemModel *myGameListModel;
|
||||||
QItemSelectionModel *myGameListSelectionModel;
|
QItemSelectionModel *myGameListSelectionModel;
|
||||||
MyGameListSortFilterProxyModel *myGameListSortFilterProxyModel;
|
MyGameListSortFilterProxyModel *myGameListSortFilterProxyModel;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ MyGameListSortFilterProxyModel::MyGameListSortFilterProxyModel(QObject *parent)
|
|||||||
|
|
||||||
bool MyGameListSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
|
bool MyGameListSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const {
|
||||||
|
|
||||||
|
QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent);
|
QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent);
|
||||||
QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent);
|
QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent);
|
||||||
QModelIndex index3 = sourceModel()->index(sourceRow, 3, sourceParent);
|
QModelIndex index3 = sourceModel()->index(sourceRow, 3, sourceParent);
|
||||||
|
|
||||||
return (sourceModel()->data(index1, 16).toString().contains(column1RegExp)
|
return ((sourceModel()->data(index1, 16).toString().contains(column1RegExp)
|
||||||
&& sourceModel()->data(index2, 16).toString().contains(column2RegExp)
|
&& sourceModel()->data(index2, 16).toString().contains(column2RegExp)
|
||||||
&& sourceModel()->data(index3, 16).toString().contains(column3RegExp));
|
&& sourceModel()->data(index3, 16).toString().contains(column3RegExp)) || sourceModel()->data(index0, 16) == "MeInThisGame");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user