preparation gamelobby slots

This commit is contained in:
doitux
2007-08-29 22:30:18 +00:00
parent 0a255bfff4
commit a84f164b8a
6 changed files with 78 additions and 5 deletions
+1 -1
View File
@@ -144,7 +144,7 @@
</spacer> </spacer>
</item> </item>
<item row="0" column="0" > <item row="0" column="0" >
<widget class="QTreeWidget" name="treeWidget" > <widget class="QTreeWidget" name="treeWidget_connectedPlayers" >
<property name="minimumSize" > <property name="minimumSize" >
<size> <size>
<width>221</width> <width>221</width>
@@ -15,7 +15,7 @@
#include "gamedata.h" #include "gamedata.h"
gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c) gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
: QDialog(parent), myConfig(c), currentGameName("") : QDialog(parent), myW(NULL), myConfig(c), currentGameName(""), isAdmin(false)
{ {
setupUi(this); setupUi(this);
@@ -141,3 +141,55 @@ void gameLobbyDialogImpl::clearGames()
label_TimeoutForPlayerAction->setText(""); label_TimeoutForPlayerAction->setText("");
} }
void gameLobbyDialogImpl::checkPlayerQuantity() {
// if (treeWidget->topLevelItemCount() >= 2 && isAdmin) {
// pushButton_startGame->setEnabled(true);
// }
// else {
// pushButton_startGame->setEnabled(false);
// }
}
void gameLobbyDialogImpl::joinedNetworkGame(QString playerName, int rights) {
isAdmin = rights == PLAYER_RIGHTS_ADMIN;
addConnectedPlayer(playerName, rights);
}
void gameLobbyDialogImpl::addConnectedPlayer(QString playerName, int rights) {
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_connectedPlayers,0);
item->setData(0, 0, playerName);
GameInfo info = mySession->getClientGameInfo(currentGameName.toUtf8().constData());
if(treeWidget_connectedPlayers->topLevelItemCount() != info.data.maxNumberOfPlayers) {
myW->getMySDLPlayer()->playSound("playerconnected", 0);
}
else {
myW->getMySDLPlayer()->playSound("onlinegameready", 0);
}
checkPlayerQuantity();
}
void gameLobbyDialogImpl::updatePlayer(QString oldPlayerName, QString newPlayerName) {
QList<QTreeWidgetItem *> list = treeWidget_connectedPlayers->findItems(oldPlayerName, Qt::MatchExactly, 0);
if(!list.empty()) {
list[0]->setText(0, newPlayerName);
}
}
void gameLobbyDialogImpl::removePlayer(QString playerName) {
QList<QTreeWidgetItem *> list = treeWidget_connectedPlayers->findItems(playerName, Qt::MatchExactly, 0);
if(!list.empty()) {
treeWidget_connectedPlayers->takeTopLevelItem(treeWidget_connectedPlayers->indexOfTopLevelItem(list[0]));
}
}
@@ -18,6 +18,9 @@
#include <QtCore> #include <QtCore>
#include "createinternetgamedialogimpl.h" #include "createinternetgamedialogimpl.h"
#include "sdlplayer.h"
#include "mainwindowimpl.h"
class Session; class Session;
class ConfigFile; class ConfigFile;
@@ -35,7 +38,8 @@ public:
void exec(); void exec();
void setSession(Session *session); void setSession(Session *session);
void setMyW ( mainWindowImpl* theValue ) { myW = theValue; }
public slots: public slots:
void createGame(); void createGame();
@@ -50,15 +54,22 @@ public slots:
QString getCurrentGameName() const { return currentGameName; } QString getCurrentGameName() const { return currentGameName; }
void clearGames(); void clearGames();
void checkPlayerQuantity();
void joinedNetworkGame(QString, int);
void addConnectedPlayer(QString, int);
void updatePlayer(QString, QString);
void removePlayer(QString);
private: private:
mainWindowImpl* myW;
ConfigFile *myConfig; ConfigFile *myConfig;
Session *mySession; Session *mySession;
createInternetGameDialogImpl *myCreateInternetGameDialog; createInternetGameDialogImpl *myCreateInternetGameDialog;
QString currentGameName; QString currentGameName;
bool isAdmin;
}; };
#endif #endif
+1
View File
@@ -549,6 +549,7 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
myGameLobbyDialog = new gameLobbyDialogImpl(this, myConfig); myGameLobbyDialog = new gameLobbyDialogImpl(this, myConfig);
myStartNetworkGameDialog->setMyW(this); myStartNetworkGameDialog->setMyW(this);
myGameLobbyDialog->setMyW(this);
// //ShortCuts // //ShortCuts
// QShortcut *quitPokerTHKeys = new QShortcut(QKeySequence(Qt::Key_Control + Qt::Key_Q), this); // QShortcut *quitPokerTHKeys = new QShortcut(QKeySequence(Qt::Key_Control + Qt::Key_Q), this);
@@ -37,6 +37,14 @@ startNetworkGameDialogImpl::startNetworkGameDialogImpl(QWidget *parent, ConfigFi
pushButton_startGame->setEnabled(false); pushButton_startGame->setEnabled(false);
} }
void startNetworkGameDialogImpl::exec() {
GameInfo info = mySession->getClientGameInfo("default");
label_maxPlayerNumber->setText(QString::number(info.data.maxNumberOfPlayers));
QDialog::exec();
}
void startNetworkGameDialogImpl::startGame() { void startNetworkGameDialogImpl::startGame() {
assert(mySession); assert(mySession);
mySession->sendStartEvent(); mySession->sendStartEvent();
@@ -59,6 +59,7 @@ public slots:
void setMaxPlayerNumber ( int theValue ) { maxPlayerNumber = theValue; label_maxPlayerNumber->setText(QString::number(theValue,10)); } void setMaxPlayerNumber ( int theValue ) { maxPlayerNumber = theValue; label_maxPlayerNumber->setText(QString::number(theValue,10)); }
int getMaxPlayerNumber() const { return maxPlayerNumber; } int getMaxPlayerNumber() const { return maxPlayerNumber; }
void exec();
private: private: