diff --git a/src/gui/generic/serverguiwrapper.h b/src/gui/generic/serverguiwrapper.h index 1b869e36..8047a431 100644 --- a/src/gui/generic/serverguiwrapper.h +++ b/src/gui/generic/serverguiwrapper.h @@ -151,6 +151,11 @@ public: void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); void SignalLobbyPlayerLeft(unsigned playerId); + void SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); + void SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); + + private: boost::shared_ptr mySession; diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 10ea27f9..6ae70cc6 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -17,11 +17,12 @@ #include "session.h" #include "configfile.h" #include "gamedata.h" +#include "game_defs.h" #include #include "mymessagedialogimpl.h" gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) - : QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), myCurrentGameId(0), isGameAdministrator(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0), infoMsgToShowId(0) + : QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), myCurrentGameId(0), isGameAdministrator(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0), infoMsgToShowId(0), currentInvitationGameId(0) { #ifdef __APPLE__ @@ -1030,7 +1031,7 @@ void gameLobbyDialogImpl::kickPlayer() { void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) { -// std::cout << "key" << "\n"; +// qDebug() << event->key() << "\n"; if (event->key() == Qt::Key_Enter && lineEdit_ChatInput->hasFocus()) { myChat->sendMessage(); } @@ -1048,7 +1049,7 @@ void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) { // if (event->key() == Qt::Key_Tab) event->ignore(); else { /*blah*/ } -// if (event->key() == Qt::Key_N) registeredUserMode(); +// if (event->key() == Qt::Key_N) showInvitationDialog(); // if (event->key() == Qt::Key_M) guestUserMode(); } @@ -1323,7 +1324,9 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p) void gameLobbyDialogImpl::invitePlayerToCurrentGame() { - qDebug() << "invitePlayer"; + if(!treeWidget_NickList->selectedItems().isEmpty()) { + mySession->invitePlayerToCurrentGame(treeWidget_NickList->selectedItems().at(0)->data(0, Qt::UserRole).toUInt()); + }\ } void gameLobbyDialogImpl::showInfoMsgBox() @@ -1338,3 +1341,32 @@ void gameLobbyDialogImpl::showInfoMsgBox() break; } } + +void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerIdFrom) +{ + + myMessageDialogImpl dialog(myConfig, this); + if(dialog.exec(3, tr("You've been invited to the game %1 by %2.
Do you want to join this game?").arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str())), tr("PokerTH - Info Message"), QPixmap(":/gfx/list_add_user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false)) { + + mySession->acceptGameInvitation(currentInvitationGameId); + } + else { + mySession->rejectGameInvitation(currentInvitationGameId, DENY_GAME_INVITATION_NO); + } +} + + +void gameLobbyDialogImpl::chatInfoPlayerInviation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom) +{ + textBrowser_ChatDisplay->append(tr("Player %1 has been invited to %2 by %3.").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str()))); +} + +void gameLobbyDialogImpl::chatInfoPlayerRejectedInviation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason) +{ + QString string; + if(reason == DENY_GAME_INVITATION_NO) string = tr("Player %1 has rejected intivation to %2."); + + if(reason == DENY_GAME_INVITATION_BUSY) string = tr("Player %1 can not join %2 because he is busy."); + + textBrowser_ChatDisplay->append(string.arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdWho).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str()))); +} diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index 643d0ec0..ca61d0a3 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -105,6 +105,9 @@ public slots: void showNickListContextMenu(QPoint); void invitePlayerToCurrentGame(); void showInfoMsgBox(); + void showInvitationDialog(unsigned gameId, unsigned playerIdFrom); + void chatInfoPlayerInviation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void chatInfoPlayerRejectedInviation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); private: @@ -137,7 +140,9 @@ private: MyGameListSortFilterProxyModel *myGameListSortFilterProxyModel; QMenu *nickListContextMenu; QAction *nickListInviteAction; + QAction *ignorePlayerAction; int infoMsgToShowId; + int currentInvitationGameId; protected: diff --git a/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.cpp b/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.cpp index b23b1463..4942a196 100644 --- a/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.cpp +++ b/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.cpp @@ -15,6 +15,8 @@ bool MyGameListSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QMode QModelIndex index3 = sourceModel()->index(sourceRow, 3, sourceParent); QModelIndex index4 = sourceModel()->index(sourceRow, 4, sourceParent); + qDebug() << sourceModel()->data(index1, 16).toString() << sourceModel()->data(index2, 16).toString() << sourceModel()->data(index3, 16).toString() << sourceModel()->data(index4, 16).toString(); + return ((sourceModel()->data(index1, 16).toString().contains(column1RegExp) && sourceModel()->data(index2, 16).toString().contains(column2RegExp) && sourceModel()->data(index3, 16).toString().contains(column3RegExp) diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index efca8db0..a1ce15e8 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -185,3 +185,7 @@ void GuiWrapper::SignalIrcServerError(int /*errorCode*/) {/*myStartWindow->signa void GuiWrapper::SignalLobbyPlayerJoined(unsigned playerId, const string &nickName) { myStartWindow->signalLobbyPlayerJoined(playerId, QString::fromUtf8(nickName.c_str())); } void GuiWrapper::SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) { myStartWindow->signalLobbyPlayerKicked(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(byWhom.c_str()), QString::fromUtf8(reason.c_str())); } void GuiWrapper::SignalLobbyPlayerLeft(unsigned playerId) { myStartWindow->signalLobbyPlayerLeft(playerId); } + +void GuiWrapper::SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom) { myStartWindow->signalSelfGameInvitation(gameId, playerIdFrom); } +void GuiWrapper::SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom) { myStartWindow->signalPlayerGameInvitation(gameId, playerIdWho, playerIdFrom); } +void GuiWrapper::SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason) { myStartWindow->signalRejectedGameInvitation(gameId, playerIdWho, reason); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index 80c34505..a1622772 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -157,6 +157,9 @@ public: void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); void SignalLobbyPlayerLeft(unsigned playerId); + void SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); + void SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); private: diff --git a/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp b/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp index aac1b089..310604e2 100644 --- a/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp +++ b/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp @@ -39,8 +39,11 @@ myMessageDialogImpl::myMessageDialogImpl(ConfigFile *c, QWidget *parent) setupUi(this); } -int myMessageDialogImpl::exec(int messageId, QString msg, QString title, QPixmap pix, QDialogButtonBox::StandardButtons buttons) +int myMessageDialogImpl::exec(int messageId, QString msg, QString title, QPixmap pix, QDialogButtonBox::StandardButtons buttons, bool showCheckBox) { + if(showCheckBox) checkBox->show(); + else checkBox->hide(); + bool show = false; bool found = false; diff --git a/src/gui/qt/mymessagedialog/mymessagedialogimpl.h b/src/gui/qt/mymessagedialog/mymessagedialogimpl.h index 49c93897..f0024b62 100644 --- a/src/gui/qt/mymessagedialog/mymessagedialogimpl.h +++ b/src/gui/qt/mymessagedialog/mymessagedialogimpl.h @@ -33,7 +33,7 @@ public: public slots: bool checkIfMesssageWillBeDisplayed(int id); - int exec(int messageId, QString msg, QString title, QPixmap pix, QDialogButtonBox::StandardButtons buttons); + int exec(int messageId, QString msg, QString title, QPixmap pix, QDialogButtonBox::StandardButtons buttons, bool showCheckBox = false); void accept(); void reject(); void writeConfig(); diff --git a/src/gui/qt/resources/pokerth.qrc b/src/gui/qt/resources/pokerth.qrc index 366a5d51..cb84425c 100644 --- a/src/gui/qt/resources/pokerth.qrc +++ b/src/gui/qt/resources/pokerth.qrc @@ -42,6 +42,8 @@ player_play.png logoChip3D.png ktip.png + system_help_64.png + list_add_user_64.png cflags/ad.png diff --git a/src/gui/qt/resources/system_help_64.png b/src/gui/qt/resources/system_help_64.png new file mode 100644 index 00000000..072927c2 Binary files /dev/null and b/src/gui/qt/resources/system_help_64.png differ diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp index a1a8d36c..c57b4f21 100644 --- a/src/gui/qt/startwindow/startwindowimpl.cpp +++ b/src/gui/qt/startwindow/startwindowimpl.cpp @@ -160,6 +160,10 @@ startWindowImpl::startWindowImpl(ConfigFile *c) connect(this, SIGNAL(signalNetServerError(int, int)), this, SLOT(networkError(int, int))); connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), this, SLOT(networkNotification(int))); connect(this, SIGNAL(signalNetClientGameStart(boost::shared_ptr)), this, SLOT(networkStart(boost::shared_ptr))); + + connect(this, SIGNAL(signalSelfGameInvitation(unsigned, unsigned)), myGameLobbyDialog, SLOT(showInvitationDialog(unsigned, unsigned))); + connect(this, SIGNAL(signalPlayerGameInvitation(unsigned, unsigned, unsigned)), myGameLobbyDialog, SLOT(chatInfoPlayerInviation(unsigned, unsigned, unsigned))); + connect(this, SIGNAL(signalRejectedGameInvitation(unsigned, unsigned, DenyGameInvitationReason)), myGameLobbyDialog, SLOT(chatInfoPlayerRejectedInviation(unsigned, unsigned, DenyGameInvitationReason))); this->show(); diff --git a/src/gui/qt/startwindow/startwindowimpl.h b/src/gui/qt/startwindow/startwindowimpl.h index a4ad1aaa..df1b9a73 100644 --- a/src/gui/qt/startwindow/startwindowimpl.h +++ b/src/gui/qt/startwindow/startwindowimpl.h @@ -102,6 +102,10 @@ signals: void signalLobbyPlayerKicked(QString nickName, QString byWhom, QString reason); void signalLobbyPlayerLeft(unsigned playerId); + void signalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); + void signalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void signalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); + public slots: void callAboutPokerthDialog();