summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-26 20:04:40 +0200
committerAndrei Karas <akaras@inbox.ru>2011-03-26 20:04:40 +0200
commitadfacb195ba653b63fec08200d0535604d45e20e (patch)
tree0222d33fd3e26b9e87cda7fa00119ac44acc94d4 /src
parentd1be68b99867261dc9298f3441acc09028897d6f (diff)
downloadplus-adfacb195ba653b63fec08200d0535604d45e20e.tar.gz
plus-adfacb195ba653b63fec08200d0535604d45e20e.tar.bz2
plus-adfacb195ba653b63fec08200d0535604d45e20e.tar.xz
plus-adfacb195ba653b63fec08200d0535604d45e20e.zip
Add option to chat context menu to remove nicks.
Usefull for example for tmw guild bot.
Diffstat (limited to 'src')
-rw-r--r--src/gui/chat.cpp23
-rw-r--r--src/gui/popupmenu.cpp21
-rw-r--r--src/gui/widgets/chattab.cpp3
-rw-r--r--src/gui/widgets/chattab.h7
4 files changed, 50 insertions, 4 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 8923b40f4..a72d562c2 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -904,7 +904,28 @@ void ChatWindow::whisper(const std::string &nick,
}
else
{
- tab->chatLog(nick, mes);
+ if (tab->getRemoveNames())
+ {
+ std::string msg = mes;
+ std::string nick2;
+ int idx = mes.find(":");
+ if (idx > 0)
+ {
+ nick2 = msg.substr(0, idx);
+ msg = msg.substr(idx + 1);
+ trim(nick2);
+ trim(msg);
+ tab->chatLog(nick2, msg);
+ }
+ else
+ {
+ tab->chatLog(nick, mes);
+ }
+ }
+ else
+ {
+ tab->chatLog(nick, mes);
+ }
player_node->afkRespond(tab, nick);
}
}
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 1850fbb68..1cca9daa6 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -476,14 +476,23 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
mBrowserBox->addRow(strprintf("@@disable highlight|%s@@",
_("Disable highlight")));
- mBrowserBox->addRow("##3---");
}
else
{
mBrowserBox->addRow(strprintf("@@enable highlight|%s@@",
_("Enable highlight")));
- mBrowserBox->addRow("##3---");
}
+ if (tab->getRemoveNames())
+ {
+ mBrowserBox->addRow(strprintf("@@dont remove name|%s@@",
+ _("Dont remove name")));
+ }
+ else
+ {
+ mBrowserBox->addRow(strprintf("@@remove name|%s@@",
+ _("Remove name")));
+ }
+ mBrowserBox->addRow("##3---");
if (tab->getType() == ChatTab::TAB_PARTY)
{
@@ -1084,6 +1093,14 @@ void PopupMenu::handleLink(const std::string &link,
{
mTab->setAllowHighlight(false);
}
+ else if (link == "dont remove name" && mTab)
+ {
+ mTab->setRemoveNames(false);
+ }
+ else if (link == "remove name" && mTab)
+ {
+ mTab->setRemoveNames(true);
+ }
else if (link == "guild-pos" && !mNick.empty())
{
showChangePos(getX(), getY());
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 9675eb621..40bde104e 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -50,7 +50,8 @@
ChatTab::ChatTab(const std::string &name) :
Tab(),
- mAllowHightlight(true)
+ mAllowHightlight(true),
+ mRemoveNames(false)
{
setCaption(name);
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index 52c122e65..998ad2e3d 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -147,6 +147,12 @@ class ChatTab : public Tab
void setAllowHighlight(bool n)
{ mAllowHightlight = n; }
+ bool getRemoveNames()
+ { return mRemoveNames; }
+
+ void setRemoveNames(bool n)
+ { mRemoveNames = n; }
+
protected:
friend class ChatWindow;
friend class WhisperWindow;
@@ -166,6 +172,7 @@ class ChatTab : public Tab
ScrollArea *mScrollArea;
BrowserBox *mTextOutput;
bool mAllowHightlight;
+ bool mRemoveNames;
};
extern ChatTab *localChatTab;