diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chatwindow.cpp | 26 | ||||
-rw-r--r-- | src/gui/chatwindow.h | 8 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 19 | ||||
-rw-r--r-- | src/gui/widgets/chattab.h | 2 |
4 files changed, 55 insertions, 0 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 372461b29..472c2b531 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -1470,3 +1470,29 @@ void ChatWindow::loadCustomList() listFile.close(); } } + +void ChatWindow::addToAwayLog(std::string line) +{ + if (!player_node || !player_node->getAwayMode()) + return; + + if (mAwayLog.size() > 20) + mAwayLog.pop_front(); + + if (line.find(player_node->getName()) != std::string::npos) + mAwayLog.push_back("##9away:" + line); +} + +void ChatWindow::displayAwayLog() +{ + if (!localChatTab) + return; + + std::list<std::string>::iterator i = mAwayLog.begin(); + + while (i != mAwayLog.end()) + { + localChatTab->addNewRow(*i); + ++i; + } +} diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index d22aea64c..d68fa7671 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -248,6 +248,13 @@ class ChatWindow : public Window, void adjustTabSize(); + void addToAwayLog(std::string line); + + void displayAwayLog(); + + void clearAwayLog() + { mAwayLog.clear(); } + protected: friend class ChatTab; friend class WhisperTab; @@ -316,6 +323,7 @@ class ChatWindow : public Window, ColorListModel *mColorListModel; int mChatColor; unsigned int mChatHistoryIndex; + std::list<std::string> mAwayLog; }; extern ChatWindow *chatWindow; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 2fd7840f8..3c277fc8d 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -249,6 +249,9 @@ void ChatTab::chatLog(std::string line, Own own, addRow(line); } + if (chatWindow && this == localChatTab) + chatWindow->addToAwayLog(line); + mScrollArea->logic(); if (own != BY_PLAYER) { @@ -434,3 +437,19 @@ void ChatTab::loadFromLogFile(std::string name) } } } + +void ChatTab::addNewRow(std::string &line) +{ + if (mScrollArea->getVerticalScrollAmount() >= + mScrollArea->getVerticalMaxScroll()) + { + addRow(line); + mScrollArea->setVerticalScrollAmount( + mScrollArea->getVerticalMaxScroll()); + } + else + { + addRow(line); + } + mScrollArea->logic(); +}
\ No newline at end of file diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 66e9f637d..45e27797d 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -159,6 +159,8 @@ class ChatTab : public Tab void setNoAway(bool n) { mNoAway = n; } + void addNewRow(std::string &line); + protected: friend class ChatWindow; friend class WhisperWindow; |