changing gui signals-slots for using new internal chat system instead of irc
This commit is contained in:
@@ -664,6 +664,7 @@ void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerNa
|
||||
|
||||
void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName) {
|
||||
|
||||
//rename player in connected players list
|
||||
QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
|
||||
while (*it) {
|
||||
if ((*it)->data(0, Qt::UserRole) == playerId)
|
||||
@@ -676,6 +677,9 @@ void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName)
|
||||
|
||||
if (inGame)
|
||||
refreshConnectedPlayerAvatars();
|
||||
|
||||
//also rename player in nick-list
|
||||
myChat->playerChanged(playerId, newPlayerName);
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) {
|
||||
|
||||
@@ -55,43 +55,33 @@ void LobbyChat::sendMessage() {
|
||||
}
|
||||
}
|
||||
|
||||
void LobbyChat::connected(QString server)
|
||||
{
|
||||
myLobby->textBrowser_ChatDisplay->append(tr("Successfully connected to") + " " + server + ".");
|
||||
}
|
||||
|
||||
void LobbyChat::selfJoined(QString ownName, QString channel)
|
||||
{
|
||||
myNick = ownName;
|
||||
myChatTools->setMyNick(myNick);
|
||||
myLobby->textBrowser_ChatDisplay->append(tr("Joined channel:") + " " + channel + " " + tr("as user") + " " + ownName + ".");
|
||||
myLobby->textBrowser_ChatDisplay->append("");
|
||||
myLobby->lineEdit_ChatInput->setEnabled(true);
|
||||
myLobby->lineEdit_ChatInput->setFocus();
|
||||
}
|
||||
|
||||
void LobbyChat::playerJoined(QString playerName)
|
||||
void LobbyChat::playerJoined(unsigned playerId, QString playerName)
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(myLobby->treeWidget_NickList, 0);
|
||||
item->setData(0, Qt::DisplayRole, playerName);
|
||||
item->setData(0, Qt::UserRole, playerId);
|
||||
|
||||
myLobby->treeWidget_NickList->sortItems(0, Qt::AscendingOrder);
|
||||
|
||||
myLobby->refreshPlayerStats();
|
||||
}
|
||||
|
||||
void LobbyChat::playerChanged(QString oldNick, QString newNick)
|
||||
void LobbyChat::playerChanged(unsigned playerId, QString newNick)
|
||||
{
|
||||
QList<QTreeWidgetItem *> tmpList(myLobby->treeWidget_NickList->findItems(oldNick, Qt::MatchExactly));
|
||||
if (!tmpList.empty())
|
||||
tmpList.front()->setData(0, Qt::DisplayRole, newNick);
|
||||
else
|
||||
{
|
||||
tmpList = myLobby->treeWidget_NickList->findItems("@" + oldNick, Qt::MatchExactly);
|
||||
if (!tmpList.empty())
|
||||
tmpList.front()->setData(0, Qt::DisplayRole, "@" + newNick);
|
||||
}
|
||||
|
||||
QString oldNick;
|
||||
QTreeWidgetItemIterator it(myLobby->treeWidget_NickList);
|
||||
while (*it) {
|
||||
if ((*it)->data(0, Qt::UserRole) == playerId)
|
||||
{
|
||||
oldNick = (*it)->data(0, Qt::DisplayRole).toString();
|
||||
(*it)->setData(0, Qt::DisplayRole, newNick);
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
|
||||
if (myNick == oldNick) {
|
||||
myNick = newNick;
|
||||
myChatTools->setMyNick(myNick);
|
||||
@@ -108,18 +98,18 @@ void LobbyChat::playerKicked(QString nickName, QString byWhom, QString reason)
|
||||
myLobby->textBrowser_ChatDisplay->append(nickName + " " + tr("was kicked from the server by") + " " + byWhom + " (" + reason + ")");
|
||||
}
|
||||
|
||||
void LobbyChat::playerLeft(QString playerName)
|
||||
void LobbyChat::playerLeft(unsigned playerId)
|
||||
{
|
||||
QList<QTreeWidgetItem *> tmpList(myLobby->treeWidget_NickList->findItems(playerName, Qt::MatchExactly));
|
||||
if (!tmpList.empty())
|
||||
myLobby->treeWidget_NickList->takeTopLevelItem(myLobby->treeWidget_NickList->indexOfTopLevelItem(tmpList.front()));
|
||||
else
|
||||
{
|
||||
tmpList = myLobby->treeWidget_NickList->findItems("@" + playerName, Qt::MatchExactly);
|
||||
if (!tmpList.empty())
|
||||
myLobby->treeWidget_NickList->takeTopLevelItem(myLobby->treeWidget_NickList->indexOfTopLevelItem(tmpList.front()));
|
||||
QTreeWidgetItemIterator it(myLobby->treeWidget_NickList);
|
||||
while (*it) {
|
||||
if ((*it)->data(0, Qt::UserRole) == playerId)
|
||||
{
|
||||
myLobby->treeWidget_NickList->takeTopLevelItem(myLobby->treeWidget_NickList->indexOfTopLevelItem(*it));
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
|
||||
myLobby->treeWidget_NickList->sortItems(0, Qt::AscendingOrder);
|
||||
|
||||
myLobby->refreshPlayerStats();
|
||||
|
||||
@@ -41,12 +41,10 @@ public:
|
||||
public slots:
|
||||
|
||||
void sendMessage();
|
||||
void connected(QString server);
|
||||
void selfJoined(QString ownName, QString channel);
|
||||
void playerJoined(QString playerName);
|
||||
void playerChanged(QString oldNick, QString newNick);
|
||||
void playerJoined(unsigned playerId, QString playerName);
|
||||
void playerChanged(unsigned playerId, QString newNick);
|
||||
void playerKicked(QString nickName, QString byWhom, QString reason);
|
||||
void playerLeft(QString playerName);
|
||||
void playerLeft(unsigned playerId);
|
||||
void displayMessage(QString playerName, QString msg);
|
||||
void checkInputLength(QString);
|
||||
void clearChat();
|
||||
@@ -67,6 +65,7 @@ private:
|
||||
ConfigFile *myConfig;
|
||||
|
||||
QString myNick;
|
||||
unsigned myLobbyPlayerId;
|
||||
ChatTools *myChatTools;
|
||||
// friend class GuiWrapper;
|
||||
};
|
||||
|
||||
@@ -181,3 +181,7 @@ void GuiWrapper::SignalIrcPlayerLeft(const std::string &nickName) { myStartWindo
|
||||
void GuiWrapper::SignalIrcChatMsg(const std::string &nickName, const std::string &msg) { myStartWindow->signalIrcChatMessage(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(msg.c_str())); }
|
||||
void GuiWrapper::SignalIrcError(int errorCode) { myStartWindow->signalIrcError(errorCode); }
|
||||
void GuiWrapper::SignalIrcServerError(int errorCode) {myStartWindow->signalIrcServerError(errorCode); }
|
||||
|
||||
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); }
|
||||
|
||||
@@ -153,6 +153,9 @@ public:
|
||||
void SignalIrcChatMsg(const std::string &nickName, const std::string &msg);
|
||||
void SignalIrcError(int errorCode);
|
||||
void SignalIrcServerError(int errorCode);
|
||||
void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName);
|
||||
void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason);
|
||||
void SignalLobbyPlayerLeft(unsigned playerId);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -164,6 +164,10 @@ startWindowImpl::startWindowImpl(ConfigFile *c)
|
||||
connect(this, SIGNAL(signalIrcChatMessage(QString, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(displayMessage(QString, QString)));
|
||||
connect(this, SIGNAL(signalIrcError(int)), myGameLobbyDialog->getLobbyChat(), SLOT(chatError(int)));
|
||||
connect(this, SIGNAL(signalIrcServerError(int)), myGameLobbyDialog->getLobbyChat(), SLOT(chatServerError(int)));
|
||||
connect(this, SIGNAL(signalLobbyPlayerJoined(unsigned, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(playerJoined(unsigned, QString)));
|
||||
connect(this, SIGNAL(signalLobbyPlayerKicked(QString, QString, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(playerKicked(QString, QString, QString)));
|
||||
connect(this, SIGNAL(signalLobbyPlayerLeft(unsigned)), myGameLobbyDialog->getLobbyChat(), SLOT(playerLeft(unsigned)));
|
||||
|
||||
|
||||
this->show();
|
||||
|
||||
|
||||
@@ -93,7 +93,9 @@ signals:
|
||||
void signalIrcChatMessage(QString nickName, QString msg);
|
||||
void signalIrcError(int errorCode);
|
||||
void signalIrcServerError(int errorCode);
|
||||
|
||||
void signalLobbyPlayerJoined(unsigned playerId, QString nickName);
|
||||
void signalLobbyPlayerKicked(QString nickName, QString byWhom, QString reason);
|
||||
void signalLobbyPlayerLeft(unsigned playerId);
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
@@ -65,7 +65,11 @@ public:
|
||||
virtual void SignalIrcChatMsg(const std::string &nickName, const std::string &msg);
|
||||
virtual void SignalIrcError(int errorCode);
|
||||
virtual void SignalIrcServerError(int errorCode);
|
||||
virtual void SignalLobbyPlayerJoined(unsigned, const std::string & /*nickName*/) {}
|
||||
virtual void SignalLobbyPlayerKicked(const std::string & /*nickName*/, const std::string & /*byWhom*/, const std::string & /*reason*/) {}
|
||||
virtual void SignalLobbyPlayerLeft(unsigned) {}
|
||||
|
||||
|
||||
protected:
|
||||
typedef std::list<boost::shared_ptr<ServerAcceptHelper> > AcceptHelperList;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user