summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-18 22:33:28 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-18 22:33:28 +0300
commit71ba93abb9436eabc9fed8e4e49ab5cdee47bb38 (patch)
tree87f9fc99f15d84a8a63b3fbc68950650f9ebc0ed /src
parentbc39b3c006145c6db41e7fcfac9da512944774f3 (diff)
downloadmv-71ba93abb9436eabc9fed8e4e49ab5cdee47bb38.tar.gz
mv-71ba93abb9436eabc9fed8e4e49ab5cdee47bb38.tar.bz2
mv-71ba93abb9436eabc9fed8e4e49ab5cdee47bb38.tar.xz
mv-71ba93abb9436eabc9fed8e4e49ab5cdee47bb38.zip
Impliment away log in away mode.
Diffstat (limited to 'src')
-rw-r--r--src/gui/chatwindow.cpp26
-rw-r--r--src/gui/chatwindow.h8
-rw-r--r--src/gui/widgets/chattab.cpp19
-rw-r--r--src/gui/widgets/chattab.h2
-rw-r--r--src/localplayer.cpp8
5 files changed, 63 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;
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 2718b9fe0..ac113a54a 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -3092,6 +3092,9 @@ void LocalPlayer::changeAwayMode()
miniStatusWindow->updateStatus();
if (mAwayMode)
{
+ if (chatWindow)
+ chatWindow->clearAwayLog();
+
cancelFollow();
naviageClean();
if (outfitWindow)
@@ -3105,6 +3108,11 @@ void LocalPlayer::changeAwayMode()
{
mAwayDialog = 0;
sound.volumeRestore();
+ if (chatWindow)
+ {
+ chatWindow->displayAwayLog();
+ chatWindow->clearAwayLog();
+ }
}
}