add autostart timer display, bad word game name check gui

This commit is contained in:
doitux
2010-09-05 02:00:23 +00:00
parent 8a83a1dd07
commit ec46f06d61
6 changed files with 71 additions and 9 deletions
@@ -56,13 +56,20 @@ changeContentDialogImpl::changeContentDialogImpl(QWidget *parent, ConfigFile *co
lineEdit->setMaxLength(12); lineEdit->setMaxLength(12);
} }
break; 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_Message->setText(tr("There is already a game with your choosen game name.\nPlease choose another one!"));
label_lineLabel->setText(tr("Game name:")); label_lineLabel->setText(tr("Game name:"));
lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str()));
lineEdit->setMaxLength(48); lineEdit->setMaxLength(48);
} }
break; 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())); connect(this, SIGNAL(accepted ()), this, SLOT(saveContent()));
@@ -88,7 +95,8 @@ void changeContentDialogImpl::saveContent() {
} }
} }
break; break;
case CHANGE_INET_GAME_NAME: { case CHANGE_INET_BAD_GAME_NAME:
case CHANGE_INET_GAME_NAME_IN_USE: {
if(checkBox->isChecked()) { if(checkBox->isChecked()) {
myConfig->writeConfigString("InternetGameName", lineEdit->text().toUtf8().constData()); myConfig->writeConfigString("InternetGameName", lineEdit->text().toUtf8().constData());
} }
@@ -24,7 +24,7 @@
#include <QtCore> #include <QtCore>
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; class ConfigFile;
+2 -2
View File
@@ -159,10 +159,10 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QScrollArea" name="scrollArea"> <widget class="QScrollArea" name="scrollArea_gameInfos">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>252</width>
<height>174</height> <height>174</height>
</size> </size>
</property> </property>
@@ -26,7 +26,7 @@
using namespace std; using namespace std;
gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) 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__ #ifdef __APPLE__
@@ -50,6 +50,8 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
waitStartGameMsgBoxTimer->setSingleShot(TRUE); waitStartGameMsgBoxTimer->setSingleShot(TRUE);
blinkingButtonAnimationTimer = new QTimer(this); blinkingButtonAnimationTimer = new QTimer(this);
blinkingButtonAnimationTimer->setInterval(1000); blinkingButtonAnimationTimer->setInterval(1000);
autoStartTimer = new QTimer(this);
autoStartTimer->setInterval(1000);
showInfoMsgBoxTimer = new QTimer(this); showInfoMsgBoxTimer = new QTimer(this);
showInfoMsgBoxTimer->setSingleShot(TRUE); showInfoMsgBoxTimer->setSingleShot(TRUE);
@@ -63,6 +65,20 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c)
disabledStartButtonColor = pushButton_StartGame->palette().button().color(); disabledStartButtonColor = pushButton_StartGame->palette().button().color();
disabledStartButtonTextColor = pushButton_StartGame->palette().buttonText().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); myGameListModel = new QStandardItemModel(this);
myGameListSortFilterProxyModel = new MyGameListSortFilterProxyModel(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( 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( blinkingButtonAnimationTimer, SIGNAL(timeout()), this, SLOT( blinkingStartButtonAnimation() ));
connect( autoStartTimer, SIGNAL(timeout()), this, SLOT( updateAutoStartTimer() ));
connect( showInfoMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showInfoMsgBox() )); connect( showInfoMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showInfoMsgBox() ));
connect( comboBox_gameListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeGameListFilter(int))); connect( comboBox_gameListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeGameListFilter(int)));
connect( comboBox_nickListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeNickListFilter(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); lineEdit_ChatInput->installEventFilter(this);
clearDialog(); clearDialog();
} }
void gameLobbyDialogImpl::exec() void gameLobbyDialogImpl::exec()
{ {
if(myConfig->readConfigInt("UseLobbyChat")) { if(myConfig->readConfigInt("UseLobbyChat")) {
groupBox_lobbyChat->show(); groupBox_lobbyChat->show();
} }
@@ -162,7 +181,6 @@ void gameLobbyDialogImpl::exec()
waitStartGameMsgBoxTimer->stop(); waitStartGameMsgBoxTimer->stop();
waitStartGameMsgBox->hide(); waitStartGameMsgBox->hide();
} }
@@ -856,6 +874,7 @@ void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerNa
} }
else { else {
myW->getMySDLPlayer()->playSound("onlinegameready", 0); myW->getMySDLPlayer()->playSound("onlinegameready", 0);
showAutoStartTimer();
} }
} }
@@ -1526,3 +1545,25 @@ void gameLobbyDialogImpl::searchForPlayerRegExpChanged()
myNickListSortFilterProxyModel->setFilterRegExp(regExp); 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<br><b>%1</b> seconds.").arg(6));
autoStartTimerCounter = 6;
autoStartTimer->start(1000);
}
void gameLobbyDialogImpl::updateAutoStartTimer()
{
--autoStartTimerCounter;
if(autoStartTimerCounter) {
autoStartTimerOverlay->setText(tr("The game will start in<br><b>%1</b> seconds.").arg(autoStartTimerCounter));
}
else {
autoStartTimer->stop();
autoStartTimerOverlay->hide();
}
}
@@ -113,6 +113,8 @@ public slots:
void putPlayerOnIgnoreList(); void putPlayerOnIgnoreList();
bool playerIsOnIgnoreList(unsigned playerid); bool playerIsOnIgnoreList(unsigned playerid);
void searchForPlayerRegExpChanged(); void searchForPlayerRegExpChanged();
void showAutoStartTimer();
void updateAutoStartTimer();
private: private:
@@ -132,6 +134,7 @@ private:
QTimer *waitStartGameMsgBoxTimer; QTimer *waitStartGameMsgBoxTimer;
QTimer *blinkingButtonAnimationTimer; QTimer *blinkingButtonAnimationTimer;
QTimer *showInfoMsgBoxTimer; QTimer *showInfoMsgBoxTimer;
QTimer *autoStartTimer;
bool blinkingButtonAnimationState; bool blinkingButtonAnimationState;
QColor defaultStartButtonColor; QColor defaultStartButtonColor;
QColor defaultStartButtonTextColor; QColor defaultStartButtonTextColor;
@@ -155,6 +158,9 @@ private:
QItemSelectionModel *myNickListSelectionModel; QItemSelectionModel *myNickListSelectionModel;
MyNickListSortFilterProxyModel *myNickListSortFilterProxyModel; MyNickListSortFilterProxyModel *myNickListSortFilterProxyModel;
QLabel *autoStartTimerOverlay;
int autoStartTimerCounter;
protected: protected:
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event);
+9 -2
View File
@@ -863,8 +863,15 @@ void startWindowImpl::networkNotification(int notificationId)
QMessageBox::Close); } QMessageBox::Close); }
break; break;
case NTF_NET_JOIN_GAME_NAME_IN_USE: case NTF_NET_JOIN_GAME_NAME_IN_USE:
case NTF_NET_JOIN_GAME_BAD_NAME: { changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_BAD_GAME_NAME);
{ changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_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(); dialog.exec();
if(dialog.result() == QDialog::Accepted) { if(dialog.result() == QDialog::Accepted) {
myGameLobbyDialog->pushButton_CreateGame->click(); myGameLobbyDialog->pushButton_CreateGame->click();