diff --git a/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp b/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp index f836e3bc..e72358c8 100644 --- a/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp +++ b/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp @@ -56,13 +56,20 @@ changeContentDialogImpl::changeContentDialogImpl(QWidget *parent, ConfigFile *co lineEdit->setMaxLength(12); } break; - case CHANGE_INET_GAME_NAME: { + case CHANGE_INET_GAME_NAME_IN_USE: { label_Message->setText(tr("There is already a game with your choosen game name.\nPlease choose another one!")); label_lineLabel->setText(tr("Game name:")); lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); lineEdit->setMaxLength(48); } break; + case CHANGE_INET_BAD_GAME_NAME: { + label_Message->setText(tr("There is a forbidden word in your choosen game name.\nPlease choose another one!")); + label_lineLabel->setText(tr("Game name:")); + lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); + lineEdit->setMaxLength(48); + } + break; } connect(this, SIGNAL(accepted ()), this, SLOT(saveContent())); @@ -88,7 +95,8 @@ void changeContentDialogImpl::saveContent() { } } break; - case CHANGE_INET_GAME_NAME: { + case CHANGE_INET_BAD_GAME_NAME: + case CHANGE_INET_GAME_NAME_IN_USE: { if(checkBox->isChecked()) { myConfig->writeConfigString("InternetGameName", lineEdit->text().toUtf8().constData()); } diff --git a/src/gui/qt/changecontentdialog/changecontentdialogimpl.h b/src/gui/qt/changecontentdialog/changecontentdialogimpl.h index a45d4f81..d8fca7e4 100644 --- a/src/gui/qt/changecontentdialog/changecontentdialogimpl.h +++ b/src/gui/qt/changecontentdialog/changecontentdialogimpl.h @@ -24,7 +24,7 @@ #include -enum DialogType { CHANGE_HUMAN_PLAYER_NAME=0, CHANGE_NICK_ALREADY_IN_USE, CHANGE_NICK_INVALID, CHANGE_INET_GAME_NAME }; +enum DialogType { CHANGE_HUMAN_PLAYER_NAME=0, CHANGE_NICK_ALREADY_IN_USE, CHANGE_NICK_INVALID, CHANGE_INET_BAD_GAME_NAME, CHANGE_INET_GAME_NAME_IN_USE }; class ConfigFile; diff --git a/src/gui/qt/gamelobbydialog.ui b/src/gui/qt/gamelobbydialog.ui index 16cd2986..3d208f27 100644 --- a/src/gui/qt/gamelobbydialog.ui +++ b/src/gui/qt/gamelobbydialog.ui @@ -159,10 +159,10 @@ - + - 0 + 252 174 diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 6fc2d26c..605cea6d 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -26,7 +26,7 @@ using namespace std; gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) - : 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) + : 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) { #ifdef __APPLE__ @@ -50,6 +50,8 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) waitStartGameMsgBoxTimer->setSingleShot(TRUE); blinkingButtonAnimationTimer = new QTimer(this); blinkingButtonAnimationTimer->setInterval(1000); + autoStartTimer = new QTimer(this); + autoStartTimer->setInterval(1000); showInfoMsgBoxTimer = new QTimer(this); showInfoMsgBoxTimer->setSingleShot(TRUE); @@ -63,6 +65,20 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) 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(180); + autoStartTimerOverlay->setMinimumWidth(180); + 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); + myGameListModel = new QStandardItemModel(this); myGameListSortFilterProxyModel = new MyGameListSortFilterProxyModel(this); @@ -125,6 +141,7 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) 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))); @@ -137,10 +154,12 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) lineEdit_ChatInput->installEventFilter(this); clearDialog(); + } void gameLobbyDialogImpl::exec() { + if(myConfig->readConfigInt("UseLobbyChat")) { groupBox_lobbyChat->show(); } @@ -162,7 +181,6 @@ void gameLobbyDialogImpl::exec() waitStartGameMsgBoxTimer->stop(); waitStartGameMsgBox->hide(); - } @@ -856,6 +874,7 @@ void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerNa } else { myW->getMySDLPlayer()->playSound("onlinegameready", 0); + showAutoStartTimer(); } } @@ -1526,3 +1545,25 @@ void gameLobbyDialogImpl::searchForPlayerRegExpChanged() myNickListSortFilterProxyModel->setFilterRegExp(regExp); } +void gameLobbyDialogImpl::showAutoStartTimer() +{ + + autoStartTimerOverlay->show(); + autoStartTimerOverlay->setGeometry(((scrollArea_gameInfos->geometry().width()-180)/2), ((scrollArea_gameInfos->geometry().height()-50)/2), 180, 50); + autoStartTimerOverlay->setText(tr("The game will start in
%1 seconds.").arg(6)); + autoStartTimerCounter = 6; + autoStartTimer->start(1000); + +} + +void gameLobbyDialogImpl::updateAutoStartTimer() +{ + --autoStartTimerCounter; + if(autoStartTimerCounter) { + autoStartTimerOverlay->setText(tr("The game will start in
%1 seconds.").arg(autoStartTimerCounter)); + } + else { + autoStartTimer->stop(); + autoStartTimerOverlay->hide(); + } +} diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index 9e297b1e..bfcbbd20 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -113,6 +113,8 @@ public slots: void putPlayerOnIgnoreList(); bool playerIsOnIgnoreList(unsigned playerid); void searchForPlayerRegExpChanged(); + void showAutoStartTimer(); + void updateAutoStartTimer(); private: @@ -132,6 +134,7 @@ private: QTimer *waitStartGameMsgBoxTimer; QTimer *blinkingButtonAnimationTimer; QTimer *showInfoMsgBoxTimer; + QTimer *autoStartTimer; bool blinkingButtonAnimationState; QColor defaultStartButtonColor; QColor defaultStartButtonTextColor; @@ -155,6 +158,9 @@ private: QItemSelectionModel *myNickListSelectionModel; MyNickListSortFilterProxyModel *myNickListSortFilterProxyModel; + QLabel *autoStartTimerOverlay; + int autoStartTimerCounter; + protected: bool eventFilter(QObject *obj, QEvent *event); diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp index 0bae03c2..5d266a20 100644 --- a/src/gui/qt/startwindow/startwindowimpl.cpp +++ b/src/gui/qt/startwindow/startwindowimpl.cpp @@ -863,8 +863,15 @@ void startWindowImpl::networkNotification(int notificationId) QMessageBox::Close); } break; case NTF_NET_JOIN_GAME_NAME_IN_USE: - case NTF_NET_JOIN_GAME_BAD_NAME: - { changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_GAME_NAME); + { changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_BAD_GAME_NAME); + dialog.exec(); + if(dialog.result() == QDialog::Accepted) { + myGameLobbyDialog->pushButton_CreateGame->click(); + } + } + break; + case NTF_NET_JOIN_GAME_BAD_NAME: + { changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_GAME_NAME_IN_USE); dialog.exec(); if(dialog.result() == QDialog::Accepted) { myGameLobbyDialog->pushButton_CreateGame->click();