diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-10-13 01:48:00 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-10-13 14:43:43 +0300 |
commit | 00345798a405d4e28f489d01a2dea6afb01a6c18 (patch) | |
tree | 812a27fa935e41602b4bbbea059b762e77e7388b | |
parent | 9ee88d0b1068599f60710a13551257f044722a9d (diff) | |
download | plus-00345798a405d4e28f489d01a2dea6afb01a6c18.tar.gz plus-00345798a405d4e28f489d01a2dea6afb01a6c18.tar.bz2 plus-00345798a405d4e28f489d01a2dea6afb01a6c18.tar.xz plus-00345798a405d4e28f489d01a2dea6afb01a6c18.zip |
Autojoin channels on open channel tab.
-rw-r--r-- | src/actions/chat.cpp | 2 | ||||
-rw-r--r-- | src/game.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 22 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.h | 5 |
4 files changed, 26 insertions, 5 deletions
diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp index 379d7d49c..655aa01ae 100644 --- a/src/actions/chat.cpp +++ b/src/actions/chat.cpp @@ -226,7 +226,7 @@ impHandler(query) const std::string &args = event.args; if (chatWindow) { - if (chatWindow->addChatTab(args, true)) + if (chatWindow->addChatTab(args, true, true)) { chatWindow->saveState(); return true; diff --git a/src/game.cpp b/src/game.cpp index 767dfff5f..ad6c04a28 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -391,6 +391,8 @@ Game::Game() : initEngines(); + chatWindow->postConnection(); + // Initialize beings if (actorManager) actorManager->setPlayer(localPlayer); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 357c76911..4abc70561 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1203,12 +1203,16 @@ ChannelTab *ChatWindow::addChannelTab(const std::string &name, } ChatTab *ChatWindow::addChatTab(const std::string &name, - const bool switchTo) + const bool switchTo, + const bool join) { if (serverFeatures->haveChatChannels() && name.size() > 1 && name[0] == '#') { - return addChannelTab(name, switchTo); + ChatTab *const tab = addChannelTab(name, switchTo); + if (tab && join) + chatHandler->joinChannel(name); + return tab; } else { @@ -1216,6 +1220,17 @@ ChatTab *ChatWindow::addChatTab(const std::string &name, } } +void ChatWindow::postConnection() +{ + FOR_EACH (ChannelMap::const_iterator, iter, mChannels) + { + ChatTab *const tab = iter->second; + if (!tab) + return; + chatHandler->joinChannel(tab->getChannelName()); + } +} + #define changeColor(fun) \ { \ msg = removeColors(msg); \ @@ -1699,10 +1714,11 @@ void ChatWindow::loadState() if (nick.empty()) break; + const int flags = serverConfig.getValue( "chatWhisperFlags" + toString(num), 1); - ChatTab *const tab = addChatTab(nick, false); + ChatTab *const tab = addChatTab(nick, false, false); if (tab) { tab->setAllowHighlight(flags & 1); diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index acecdcaf2..068ec4111 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -203,7 +203,8 @@ class ChatWindow final : public Window, const bool switchTo = false) A_WARN_UNUSED; ChatTab *addChatTab(const std::string &name, - const bool switchTo = false) A_WARN_UNUSED; + const bool switchTo, + const bool join) A_WARN_UNUSED; void removeAllWhispers(); @@ -289,6 +290,8 @@ class ChatWindow final : public Window, static void localPetEmote(const std::string &nick, const uint8_t emoteId); + void postConnection(); + #ifdef USE_PROFILER void logicChildren(); #endif |