Files
pokerth/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp
T

671 lines
20 KiB
C++
Raw Normal View History

2007-08-20 21:23:03 +00:00
//
// C++ Implementation: gamelobbydialogimpl
//
// Description:
//
//
// Author: FThauer FHammer LMay <webmaster@pokerth.net>, (C) 2007
2007-08-20 21:23:03 +00:00
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "gamelobbydialogimpl.h"
2007-09-07 20:26:13 +00:00
#include "lobbychat.h"
#include "changecompleteblindsdialogimpl.h"
#include "session.h"
#include "configfile.h"
#include "gamedata.h"
#include <net/socket_msg.h>
2007-08-20 21:23:03 +00:00
gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
: QDialog(parent), myW(NULL), myConfig(c), mySession(NULL), currentGameName(""), myPlayerId(0), isAdmin(false), inGame(false), myChat(NULL), keyUpCounter(0)
2007-08-20 21:23:03 +00:00
{
setupUi(this);
2007-09-29 22:25:33 +00:00
myChat = new LobbyChat(this, myConfig);
2007-09-07 20:26:13 +00:00
2007-09-29 22:50:20 +00:00
myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str());
2007-10-16 23:07:59 +00:00
//wait start game message
2007-10-18 20:10:01 +00:00
waitStartGameMsgBox = new QMessageBox(this);
waitStartGameMsgBox->setText(tr("Starting game. Please wait ..."));
waitStartGameMsgBox->setWindowModality(Qt::NonModal);
waitStartGameMsgBox->setStandardButtons(QMessageBox::NoButton);
2007-10-16 23:07:59 +00:00
waitStartGameMsgBoxTimer = new QTimer(this);
waitStartGameMsgBoxTimer->setSingleShot(TRUE);
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_StartGame, SIGNAL( clicked() ), this, SLOT( startGame() ) );
connect( pushButton_Kick, SIGNAL( clicked() ), this, SLOT( kickPlayer() ) );
connect( pushButton_Leave, SIGNAL( clicked() ), this, SLOT( leaveGame() ) );
connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) );
connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), this, SLOT( sendChatMessage() ) );
2007-09-07 20:26:13 +00:00
connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), this, SLOT( checkChatInputLength(QString) ) );
connect( lineEdit_ChatInput, SIGNAL( textEdited (QString) ), myChat, SLOT( setChatTextEdited() ) );
2007-10-16 23:07:59 +00:00
connect( waitStartGameMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showWaitStartGameMsgBox() ));
2007-10-10 10:06:09 +00:00
lineEdit_ChatInput->installEventFilter(this);
clearDialog();
2007-08-20 21:23:03 +00:00
}
void gameLobbyDialogImpl::exec()
{
if(myConfig->readConfigInt("UseIRCLobbyChat")) {
groupBox_lobbyChat->show();
}
else {
groupBox_lobbyChat->hide();
}
QDialog::exec();
2007-10-18 20:21:41 +00:00
waitStartGameMsgBoxTimer->stop();
2007-10-18 20:21:00 +00:00
waitStartGameMsgBox->hide();
2007-08-20 21:23:03 +00:00
}
gameLobbyDialogImpl::~gameLobbyDialogImpl()
{
2007-09-07 20:26:13 +00:00
delete myChat;
myChat = NULL;
2007-08-20 21:23:03 +00:00
}
void gameLobbyDialogImpl::setSession(Session *session)
{
mySession = session;
}
void gameLobbyDialogImpl::createGame()
{
assert(mySession);
2007-08-21 23:31:09 +00:00
myCreateInternetGameDialog = new createInternetGameDialogImpl(this, myConfig);
myCreateInternetGameDialog->exec();
if (myCreateInternetGameDialog->result() == QDialog::Accepted ) {
2007-08-21 23:31:09 +00:00
GameData gameData;
// Set Game Data
gameData.maxNumberOfPlayers = myCreateInternetGameDialog->spinBox_quantityPlayers->value();
gameData.startMoney = myCreateInternetGameDialog->spinBox_startCash->value();
2007-09-28 05:23:13 +00:00
gameData.firstSmallBlind = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value();
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) {
2007-09-29 19:23:14 +00:00
gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER;
2007-09-28 05:23:13 +00:00
gameData.raiseSmallBlindEveryHandsValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value();
}
else {
2007-09-29 19:23:14 +00:00
gameData.raiseIntervalMode = RAISE_ON_MINUTES;
2007-09-28 05:23:13 +00:00
gameData.raiseSmallBlindEveryMinutesValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value();
}
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) {
gameData.raiseMode = DOUBLE_BLINDS;
}
else {
gameData.raiseMode = MANUAL_BLINDS_ORDER;
std::list<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;
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; }
}
}
2007-08-21 23:31:09 +00:00
gameData.guiSpeed = myCreateInternetGameDialog->spinBox_gameSpeed->value();
gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value();
QString gameString(tr("game"));
currentGameName = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()) + QString("'s "+ gameString);
2007-09-30 00:42:14 +00:00
hideShowGameDescription(TRUE);
2007-10-11 09:06:06 +00:00
label_SmallBlind->setText(QString::number(gameData.firstSmallBlind));
label_StartCash->setText(QString::number(gameData.startMoney));
label_MaximumNumberOfPlayers->setText(QString::number(gameData.maxNumberOfPlayers));
2007-10-03 00:32:17 +00:00
2007-10-03 09:37:02 +00:00
updateDialogBlinds(gameData);
label_TimeoutForPlayerAction->setText(QString::number(gameData.playerActionTimeoutSec));
mySession->clientCreateGame(gameData, myConfig->readConfigString("MyName") + "'s "+ gameString.toUtf8().constData(), myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData());
2007-08-21 23:31:09 +00:00
}
}
void gameLobbyDialogImpl::joinGame()
{
2007-09-07 10:18:06 +00:00
assert(mySession);
QTreeWidgetItem *item = treeWidget_GameList->currentItem();
if (item)
{
2007-09-07 10:18:06 +00:00
unsigned gameId = item->data(0, Qt::UserRole).toUInt();
GameInfo info(mySession->getClientGameInfo(gameId));
bool ok = true;
QString password;
//if private ask for password
2007-09-07 10:18:06 +00:00
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 10:18:06 +00:00
if (ok)
mySession->clientJoinGame(gameId, password.toUtf8().constData());
}
}
void gameLobbyDialogImpl::refresh(int actionID) {
if (actionID == MSG_NET_GAME_CLIENT_START)
{
QTimer::singleShot(500, this, SLOT(accept()));
}
}
void gameLobbyDialogImpl::removedFromGame(int reason)
{
inGame = false;
isAdmin = false;
leftGameDialogUpdate();
}
void gameLobbyDialogImpl::gameSelected(QTreeWidgetItem* item, QTreeWidgetItem*)
{
if (!inGame && item)
{
pushButton_JoinGame->setEnabled(true);
currentGameName = item->text(0);
2007-08-26 12:45:37 +00:00
groupBox_GameInfo->setEnabled(true);
groupBox_GameInfo->setTitle(tr("Game Info") + " - " + currentGameName);
assert(mySession);
GameInfo info(mySession->getClientGameInfo(item->data(0, Qt::UserRole).toUInt()));
2007-09-30 00:42:14 +00:00
hideShowGameDescription(TRUE);
label_SmallBlind->setText(QString::number(info.data.firstSmallBlind));
label_StartCash->setText(QString::number(info.data.startMoney));
label_MaximumNumberOfPlayers->setText(QString::number(info.data.maxNumberOfPlayers));
2007-10-03 00:32:17 +00:00
2007-10-03 09:37:02 +00:00
updateDialogBlinds(info.data);
2007-10-03 00:32:17 +00:00
label_TimeoutForPlayerAction->setText(QString::number(info.data.playerActionTimeoutSec));
treeWidget_connectedPlayers->clear();
PlayerIdList::const_iterator i = info.players.begin();
PlayerIdList::const_iterator end = info.players.end();
while (i != end)
{
PlayerRights tmpRights = info.adminPlayerId == *i ? PLAYER_RIGHTS_ADMIN : PLAYER_RIGHTS_NORMAL;
PlayerInfo playerInfo(mySession->getClientPlayerInfo(*i));
addConnectedPlayer(*i, QString::fromUtf8(playerInfo.playerName.c_str()), tmpRights);
++i;
}
}
}
2007-08-20 21:23:03 +00:00
void gameLobbyDialogImpl::updateGameItem(QTreeWidgetItem *item, unsigned gameId)
{
assert(mySession);
GameInfo info(mySession->getClientGameInfo(gameId));
item->setData(0, Qt::UserRole, gameId);
item->setData(0, Qt::DisplayRole, QString::fromUtf8(info.name.c_str()));
QString playerStr;
playerStr.sprintf("%u/%u", info.players.size(), info.data.maxNumberOfPlayers);
item->setData(1, Qt::DisplayRole, playerStr);
if (info.mode == GAME_MODE_STARTED)
2007-09-29 22:25:33 +00:00
item->setData(2, Qt::DisplayRole, tr("running"));
else
item->setData(2, Qt::DisplayRole, tr("open"));
if (info.isPasswordProtected)
2007-09-29 22:44:16 +00:00
item->setIcon(3, QIcon(myAppDataPath+"gfx/gui/misc/lock.png"));
2007-10-17 22:27:11 +00:00
refreshGameStats();
}
void gameLobbyDialogImpl::addGame(unsigned gameId)
{
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_GameList, 0);
updateGameItem(item, gameId);
}
void gameLobbyDialogImpl::updateGameMode(unsigned gameId, int /*newMode*/)
{
QTreeWidgetItemIterator it(treeWidget_GameList);
while (*it) {
if ((*it)->data(0, Qt::UserRole) == gameId)
{
updateGameItem(*it, gameId);
break;
}
++it;
}
}
void gameLobbyDialogImpl::updateGameAdmin(unsigned /*gameId*/, unsigned adminPlayerId)
{
newGameAdmin(adminPlayerId, "");
}
void gameLobbyDialogImpl::removeGame(unsigned gameId)
{
QTreeWidgetItemIterator it(treeWidget_GameList);
while (*it) {
if ((*it)->data(0, Qt::UserRole) == gameId)
{
treeWidget_GameList->takeTopLevelItem(treeWidget_GameList->indexOfTopLevelItem(*it));
break;
}
++it;
}
2007-10-17 22:27:11 +00:00
refreshGameStats();
}
void gameLobbyDialogImpl::refreshGameStats() {
int runningGamesCounter = 0;
int openGamesCounter = 0;
QTreeWidgetItemIterator it(treeWidget_GameList);
while (*it) {
if ((*it)->data(2, Qt::DisplayRole) == tr("running")) { runningGamesCounter++; }
if ((*it)->data(2, Qt::DisplayRole) == tr("open")) { openGamesCounter++; }
++it;
}
label_openGamesCounter->setText("| "+tr("running games: %1").arg(runningGamesCounter));
label_runningGamesCounter->setText("| "+tr("open games: %1").arg(openGamesCounter));
}
void gameLobbyDialogImpl::refreshPlayerStats() {
label_nickListCounter->setText("| "+tr("players in chat: %1").arg(treeWidget_NickList->topLevelItemCount()));
2007-10-17 22:27:11 +00:00
label_connectedPlayersCounter->setText(tr("connected players: %1").arg(0));
}
void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId)
{
if (!inGame)
{
QTreeWidgetItem *item = treeWidget_GameList->currentItem();
if (item && item->data(0, Qt::UserRole) == gameId)
{
assert(mySession);
GameInfo info(mySession->getClientGameInfo(gameId));
PlayerRights tmpRights = info.adminPlayerId == playerId ? PLAYER_RIGHTS_ADMIN : PLAYER_RIGHTS_NORMAL;
PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId));
addConnectedPlayer(playerId, QString::fromUtf8(playerInfo.playerName.c_str()), tmpRights);
}
}
QTreeWidgetItemIterator it(treeWidget_GameList);
while (*it) {
if ((*it)->data(0, Qt::UserRole) == gameId)
{
updateGameItem(*it, gameId);
break;
}
++it;
}
}
void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId)
{
if (!inGame)
{
QTreeWidgetItem *item = treeWidget_GameList->currentItem();
if (item && item->data(0, Qt::UserRole) == gameId)
{
assert(mySession);
PlayerInfo info(mySession->getClientPlayerInfo(playerId));
removePlayer(playerId, QString::fromUtf8(info.playerName.c_str()));
}
}
QTreeWidgetItemIterator it(treeWidget_GameList);
while (*it) {
if ((*it)->data(0, Qt::UserRole) == gameId)
{
updateGameItem(*it, gameId);
break;
}
++it;
}
}
void gameLobbyDialogImpl::clearDialog()
{
groupBox_GameInfo->setTitle(tr("Game Info"));
groupBox_GameInfo->setEnabled(false);
currentGameName = "";
2007-09-30 00:42:14 +00:00
hideShowGameDescription(FALSE);
label_SmallBlind->setText("");
label_StartCash->setText("");
label_MaximumNumberOfPlayers->setText("");
2007-10-03 00:32:17 +00:00
label_blindsRaiseIntervall->setText("");
label_blindsRaiseMode->setText("");
label_blindsList->setText("");
label_TimeoutForPlayerAction->setText("");
treeWidget_GameList->clear();
treeWidget_GameList->show();
treeWidget_connectedPlayers->clear();
pushButton_Leave->hide();
pushButton_Kick->hide();
pushButton_Kick->setEnabled(false);
pushButton_StartGame->hide();
checkBox_fillUpWithComputerOpponents->hide();
pushButton_CreateGame->show();
pushButton_JoinGame->show();
pushButton_JoinGame->setEnabled(false);
treeWidget_GameList->setColumnWidth(0,195);
treeWidget_GameList->setColumnWidth(1,70);
treeWidget_GameList->setColumnWidth(2,70);
treeWidget_GameList->setColumnWidth(3,60);
2007-09-07 20:26:13 +00:00
pushButton_CreateGame->clearFocus();
lineEdit_ChatInput->setFocus();
myChat->clearChat();
inGame = false;
isAdmin = false;
myPlayerId = 0;
2007-10-09 20:41:57 +00:00
hideShowGameDescription(FALSE);
}
2007-08-29 22:30:18 +00:00
void gameLobbyDialogImpl::checkPlayerQuantity() {
if(isAdmin){
pushButton_Kick->show();
pushButton_StartGame->show();
checkBox_fillUpWithComputerOpponents->show();
if (treeWidget_connectedPlayers->topLevelItemCount() >= 2) {
pushButton_StartGame->setEnabled(true);
}
else {
pushButton_StartGame->setEnabled(false);
}
}
2007-08-29 22:30:18 +00:00
}
void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, int rights) {
2007-08-29 22:30:18 +00:00
// Update dialog
inGame = true;
joinedGameDialogUpdate();
myPlayerId = playerId;
2007-08-29 22:30:18 +00:00
isAdmin = rights == PLAYER_RIGHTS_ADMIN;
addConnectedPlayer(playerId, playerName, rights);
2007-08-29 22:30:18 +00:00
}
void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerName, int rights) {
2007-08-29 22:30:18 +00:00
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_connectedPlayers, 0);
item->setData(0, Qt::UserRole, playerId);
item->setData(0, Qt::DisplayRole, playerName);
2007-10-03 17:39:47 +00:00
if(rights == PLAYER_RIGHTS_ADMIN) item->setBackground(0, QBrush(QColor(169,255,140)));
2007-08-29 22:30:18 +00:00
2007-10-03 13:11:29 +00:00
if(this->isVisible() && inGame && myConfig->readConfigInt("PlayNetworkGameNotification")) {
2007-10-03 12:30:04 +00:00
if(treeWidget_connectedPlayers->topLevelItemCount() < label_MaximumNumberOfPlayers->text().toInt()) {
myW->getMySDLPlayer()->playSound("playerconnected", 0);
}
else {
myW->getMySDLPlayer()->playSound("onlinegameready", 0);
}
2007-08-29 22:30:18 +00:00
}
checkPlayerQuantity();
}
void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName) {
QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
while (*it) {
if ((*it)->data(0, Qt::UserRole) == playerId)
{
(*it)->setData(0, Qt::DisplayRole, newPlayerName);
break;
}
++it;
}
}
void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) {
QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
while (*it) {
if ((*it)->data(0, Qt::UserRole) == playerId)
{
treeWidget_connectedPlayers->takeTopLevelItem(treeWidget_connectedPlayers->indexOfTopLevelItem(*it));
break;
}
++it;
2007-08-29 22:30:18 +00:00
}
checkPlayerQuantity();
}
void gameLobbyDialogImpl::newGameAdmin(unsigned playerId, QString)
{
2007-10-03 23:30:41 +00:00
QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
while (*it) {
if ((*it)->data(0, Qt::UserRole) == playerId) {
(*it)->setBackground(0, QBrush(QColor(169,255,140)));
}
++it;
}
if (inGame && myPlayerId == playerId)
{
isAdmin = true;
checkPlayerQuantity();
}
}
void gameLobbyDialogImpl::joinedGameDialogUpdate() {
groupBox_GameInfo->setEnabled(true);
groupBox_GameInfo->setTitle(currentGameName);
treeWidget_connectedPlayers->clear();
pushButton_CreateGame->hide();
pushButton_JoinGame->hide();
pushButton_Leave->show();
}
void gameLobbyDialogImpl::leftGameDialogUpdate() {
// un-select current game.
treeWidget_GameList->clearSelection();
groupBox_GameInfo->setTitle(tr("Game Info"));
groupBox_GameInfo->setEnabled(false);
currentGameName = "";
2007-09-30 00:42:14 +00:00
hideShowGameDescription(FALSE);
label_SmallBlind->setText("");
label_StartCash->setText("");
label_MaximumNumberOfPlayers->setText("");
2007-10-03 00:32:17 +00:00
label_blindsRaiseIntervall->setText("");
label_blindsRaiseMode->setText("");
label_blindsList->setText("");
label_TimeoutForPlayerAction->setText("");
treeWidget_connectedPlayers->clear();
pushButton_StartGame->hide();
pushButton_Leave->hide();
pushButton_Kick->hide();
pushButton_Kick->setEnabled(false);
checkBox_fillUpWithComputerOpponents->hide();
pushButton_CreateGame->show();
pushButton_JoinGame->show();
pushButton_JoinGame->setEnabled(false);
lineEdit_ChatInput->setFocus();
}
2007-10-03 09:37:02 +00:00
void gameLobbyDialogImpl::updateDialogBlinds(const GameData &gameData) {
if(gameData.raiseIntervalMode == RAISE_ON_HANDNUMBER) { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryHandsValue)+" "+tr("hands")); }
else { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryMinutesValue)+" "+tr("minutes")); }
if(gameData.raiseMode == DOUBLE_BLINDS) {
label_blindsRaiseMode->setText(tr("double blinds"));
label_blindsList->hide();
label_gameDesc6->hide();
}
else {
label_blindsRaiseMode->setText(tr("manual blinds order"));
label_blindsList->show();
label_gameDesc6->show();
QString blindsListString;
std::list<int>::const_iterator it1;
for(it1= gameData.manualBlindsList.begin(); it1 != gameData.manualBlindsList.end(); it1++) {
blindsListString.append(QString::number(*it1,10)).append(", ");
}
blindsListString.remove(blindsListString.length()-2,2);
label_blindsList->setText(blindsListString);
}
}
void gameLobbyDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*) {
if (item)
pushButton_Kick->setEnabled(isAdmin);
}
void gameLobbyDialogImpl::startGame() {
assert(mySession);
mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked());
2007-10-18 21:44:56 +00:00
waitStartGameMsgBoxTimer->start(1000);
}
void gameLobbyDialogImpl::leaveGame() {
assert(mySession);
mySession->sendLeaveCurrentGame();
}
void gameLobbyDialogImpl::kickPlayer() {
QTreeWidgetItem *item = treeWidget_connectedPlayers->currentItem();
if (item)
{
QString playerName = item->text(0);
if(playerName == QString::fromUtf8(myConfig->readConfigString("MyName").c_str())) {
{ QMessageBox::warning(this, tr("Server Error"),
tr("You should not kick yourself from this game!"),
QMessageBox::Close); }
}
else {
assert(mySession);
mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt());
}
}
pushButton_Kick->setEnabled(false);
}
2007-09-07 20:26:13 +00:00
void gameLobbyDialogImpl::sendChatMessage() { myChat->sendMessage(); }
void gameLobbyDialogImpl::checkChatInputLength(QString string) { myChat->checkInputLength(string); }
void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) {
// std::cout << "key" << "\n";
if (event->key() == Qt::Key_Enter && lineEdit_ChatInput->hasFocus()) { myChat->sendMessage(); }
if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) {
if((keyUpCounter + 1) <= myChat->getChatLinesHistorySize()) { keyUpCounter++; }
// std::cout << "Up keyUpCounter: " << keyUpCounter << "\n";
myChat->showChatHistoryIndex(keyUpCounter);
}
else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) {
if((keyUpCounter - 1) >= 0) { keyUpCounter--; }
// std::cout << "Down keyUpCounter: " << keyUpCounter << "\n";
myChat->showChatHistoryIndex(keyUpCounter);
}
else { keyUpCounter = 0; }
2007-10-10 10:06:09 +00:00
// if (event->key() == Qt::Key_Tab) event->ignore(); else { /*blah*/ }
}
2007-10-10 10:06:09 +00:00
bool gameLobbyDialogImpl::eventFilter(QObject *obj, QEvent *event)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab)
{
myChat->nickAutoCompletition();
return true;
} else {
// pass the event on to the parent class
return QDialog::eventFilter(obj, event);
}
}
bool gameLobbyDialogImpl::event ( QEvent * event ) {
2007-10-09 16:12:10 +00:00
return QDialog::event(event);
}
2007-09-30 00:42:14 +00:00
void gameLobbyDialogImpl::hideShowGameDescription(bool show) {
if(show) {
label_gameDesc1->show();
label_gameDesc2->show();
label_gameDesc3->show();
label_gameDesc4->show();
label_gameDesc5->show();
2007-10-03 00:32:17 +00:00
label_gameDesc6->show();
label_gameDesc7->show();
2007-09-30 00:42:14 +00:00
}
else {
label_gameDesc1->hide();
label_gameDesc2->hide();
label_gameDesc3->hide();
label_gameDesc4->hide();
label_gameDesc5->hide();
2007-10-03 00:32:17 +00:00
label_gameDesc6->hide();
label_gameDesc7->hide();
2007-09-30 00:42:14 +00:00
}
2007-09-30 18:50:46 +00:00
}
2007-10-16 23:07:59 +00:00
2007-10-18 20:10:01 +00:00
void gameLobbyDialogImpl::showWaitStartGameMsgBox() {
waitStartGameMsgBox->show();
waitStartGameMsgBox->raise();
waitStartGameMsgBox->activateWindow();
}
2007-10-16 23:07:59 +00:00