diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-12-27 17:56:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-12-27 17:56:43 +0300 |
commit | eee2f72b047262cbb6478c67f2e5293a85ce79e4 (patch) | |
tree | a5924ee55bd5570825dccd0a344dd9f986157e12 /src/gui/windows/chatwindow.cpp | |
parent | e068a57abf67381e4f58f90e40af3be6b386e240 (diff) | |
download | manaplus-eee2f72b047262cbb6478c67f2e5293a85ce79e4.tar.gz manaplus-eee2f72b047262cbb6478c67f2e5293a85ce79e4.tar.bz2 manaplus-eee2f72b047262cbb6478c67f2e5293a85ce79e4.tar.xz manaplus-eee2f72b047262cbb6478c67f2e5293a85ce79e4.zip |
allow to owner talk from own pet.
New chat command: /talkpet text
Diffstat (limited to 'src/gui/windows/chatwindow.cpp')
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index d658ae183..44024b7f1 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1482,6 +1482,20 @@ bool ChatWindow::resortChatLog(std::string line, Own own, // ignore special message formats. if (line.find(": \302\202\302") != std::string::npos) return false; + + // pet talk message detected + if (line.find(": \302\202\303 ") != std::string::npos) + { + if (actorManager && idx2 > 1) + { + const std::string nick = line.substr(0, idx2 - 1); + line = line.substr(idx2 + 6); + localPetSay(nick, line); + } + + return false; + } + line = line.erase(idx + 2, 2); tradeChatTab->chatLog(prefix + line, own, ignoreRecord, tryRemoveColors); @@ -1548,6 +1562,26 @@ void ChatWindow::battleChatLog(const std::string &line, Own own, debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors); } +void ChatWindow::localPetSay(const std::string &nick, const std::string &text) +{ + Being *const being = actorManager->findBeingByName( + nick, ActorSprite::PLAYER); + Being *pet = nullptr; + if (being) + { + pet = being->getPet(); + if (pet) + pet->setSpeech(text, GENERAL_CHANNEL); + } + + if (!localChatTab) + return; + if (pet) + localChatTab->chatLog(strprintf(_("%s's pet"), nick.c_str()), text); + else + localChatTab->chatLog(nick, text); +} + void ChatWindow::initTradeFilter() { const std::string tradeListName = client->getServerConfigDirectory() |