summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-22 22:22:15 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-22 23:21:10 +0300
commit6b92425b46de741d4cda35027083fd988ac4e942 (patch)
tree4ea1b96d494d267ed3ceb835d611d4b095bc51f7 /src
parent0fcce97fe86721f4b426250a32f461ad951f6d99 (diff)
downloadmanaplus-6b92425b46de741d4cda35027083fd988ac4e942.tar.gz
manaplus-6b92425b46de741d4cda35027083fd988ac4e942.tar.bz2
manaplus-6b92425b46de741d4cda35027083fd988ac4e942.tar.xz
manaplus-6b92425b46de741d4cda35027083fd988ac4e942.zip
Add option to accept language messages in any languge.
This messages will be showed in language or general tab.
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp10
-rw-r--r--src/being.h4
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/chatwindow.cpp22
-rw-r--r--src/gui/chatwindow.h1
-rw-r--r--src/gui/setup_chat.cpp9
-rw-r--r--src/gui/setup_chat.h2
-rw-r--r--src/gui/widgets/setupitem.cpp6
-rw-r--r--src/gui/widgets/setupitem.h2
-rw-r--r--src/gui/widgets/setuptabscroll.cpp7
-rw-r--r--src/gui/widgets/setuptabscroll.h2
-rw-r--r--src/net/ea/chathandler.cpp7
-rw-r--r--src/net/ea/chathandler.h1
13 files changed, 66 insertions, 8 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 839999312..a30693d19 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -60,6 +60,7 @@
#include "resources/resourcemanager.h"
#include "gui/widgets/chattab.h"
+#include "gui/widgets/langtab.h"
#include "utils/gettext.h"
@@ -440,11 +441,18 @@ void Being::setPath(const Path &path)
}
}
-void Being::setSpeech(const std::string &text, int time)
+void Being::setSpeech(const std::string &text, const std::string &channel,
+ int time)
{
if (!userPalette)
return;
+ if (!channel.empty() && (langChatTab && langChatTab->getChannelName()
+ != channel))
+ {
+ return;
+ }
+
// Remove colors
mSpeech = removeColors(text);
diff --git a/src/being.h b/src/being.h
index 00dfbfe74..f41df41eb 100644
--- a/src/being.h
+++ b/src/being.h
@@ -253,7 +253,9 @@ class Being : public ActorSprite, public ConfigListener
* @param text The text that should appear.
* @param time The amount of time the text should stay in milliseconds.
*/
- void setSpeech(const std::string &text, int time = 0);
+ void setSpeech(const std::string &text,
+ const std::string &channel = "",
+ int time = 0);
/**
* Puts a damage bubble above this being.
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 273b37e61..5a51fa639 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -312,6 +312,7 @@ DefaultsData* getConfigDefaults()
AddDEF("rated", false);
AddDEF("weightMsg", true);
AddDEF("enableLangTab", true);
+ AddDEF("showAllLang", false);
return configData;
}
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 074ce2b81..f6035c5dc 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -267,6 +267,7 @@ ChatWindow::ChatWindow():
mAutoHide = config.getBoolValue("autohideChat");
mShowBattleEvents = config.getBoolValue("showBattleEvents");
+ mShowAllLang = serverConfig.getValue("showAllLang", 0);
enableVisibleSound(true);
}
@@ -1479,10 +1480,25 @@ void ChatWindow::resortChatLog(std::string line, Own own,
}
}
- if (langChatTab && !channel.empty()
- && langChatTab->getChannelName() == channel)
+ if (langChatTab && !channel.empty())
{
- langChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
+ if (langChatTab->getChannelName() == channel)
+ {
+ langChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
+ }
+ else if (mShowAllLang)
+ {
+ if (langChatTab)
+ {
+ langChatTab->chatLog(prefix + line, own,
+ ignoreRecord, tryRemoveColors);
+ }
+ else if (localChatTab)
+ {
+ localChatTab->chatLog(prefix + line, own,
+ ignoreRecord, tryRemoveColors);
+ }
+ }
}
else if (localChatTab && channel.empty())
{
diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h
index 7e2426467..1798ac63c 100644
--- a/src/gui/chatwindow.h
+++ b/src/gui/chatwindow.h
@@ -360,6 +360,7 @@ class ChatWindow final : public Window,
bool mHaveMouse;
bool mAutoHide;
bool mShowBattleEvents;
+ bool mShowAllLang;
};
extern ChatWindow *chatWindow;
diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp
index 45b9e8748..207ac7464 100644
--- a/src/gui/setup_chat.cpp
+++ b/src/gui/setup_chat.cpp
@@ -124,6 +124,9 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) :
new SetupItemCheckBox(_("Enable language tab"), "",
"enableLangTab", this, "enableLangTabEvent", false);
+ new SetupItemCheckBox(_("Show all languages messages"), "",
+ "showAllLang", this, "showAllLangEvent", false);
+
new SetupItemCheckBox(_("Enable battle tab"), "",
"enableBattleTab", this, "enableBattleTabEvent");
@@ -160,3 +163,9 @@ void Setup_Chat::apply()
chatWindow->parseHighlights();
}
}
+
+void Setup_Chat::externalUpdated()
+{
+ reread("enableLangTab");
+ reread("showAllLang");
+}
diff --git a/src/gui/setup_chat.h b/src/gui/setup_chat.h
index 6fc6e3896..2e519f11c 100644
--- a/src/gui/setup_chat.h
+++ b/src/gui/setup_chat.h
@@ -38,6 +38,8 @@ class Setup_Chat final : public SetupTabScroll
A_DELETE_COPY(Setup_Chat)
void apply();
+
+ void externalUpdated();
};
#endif
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 0e9fa993c..fbb24d2b6 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -180,6 +180,12 @@ void SetupItem::fixFirstItemSize(gcn::Widget *const widget)
widget->setWidth(maxSize);
}
+void SetupItem::rereadValue()
+{
+ load();
+ toWidget();
+}
+
SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description,
std::string keyName,
SetupTabScroll *const parent,
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
index f660500a8..d91f0ac2e 100644
--- a/src/gui/widgets/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -107,6 +107,8 @@ class SetupItem : public gcn::ActionListener,
void fixFirstItemSize(gcn::Widget *const widget);
+ void rereadValue();
+
protected:
std::string mText;
diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp
index 89077dd8c..ec8f36eba 100644
--- a/src/gui/widgets/setuptabscroll.cpp
+++ b/src/gui/widgets/setuptabscroll.cpp
@@ -124,3 +124,10 @@ void SetupTabScroll::widgetResized(const gcn::Event &event A_UNUSED)
mScroll->setWidth(getWidth() - 12);
mScroll->setHeight(getHeight() - 12 - 12);
}
+
+void SetupTabScroll::reread(const std::string &name)
+{
+ SetupItem *const item = mItems[name + "Event"];
+ if (item)
+ item->rereadValue();
+}
diff --git a/src/gui/widgets/setuptabscroll.h b/src/gui/widgets/setuptabscroll.h
index e90ce28c2..2417bd400 100644
--- a/src/gui/widgets/setuptabscroll.h
+++ b/src/gui/widgets/setuptabscroll.h
@@ -62,6 +62,8 @@ class SetupTabScroll : public SetupTab
void widgetResized(const gcn::Event &event) override;
+ void reread(const std::string &name);
+
protected:
VertContainer *mContainer;
ScrollArea *mScroll;
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index 0118e5071..36c79af77 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -42,7 +42,8 @@
namespace Ea
{
-ChatHandler::ChatHandler()
+ChatHandler::ChatHandler() :
+ mShowAllLang(serverConfig.getValue("showAllLang", 0))
{
}
@@ -314,7 +315,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg, const bool channels)
if (player_relations.hasPermission(sender_name,
PlayerRelation::SPEECH_FLOAT))
{
- being->setSpeech(chatMsg);
+ being->setSpeech(chatMsg, channel);
}
}
@@ -360,7 +361,7 @@ void ChatHandler::processChat(Net::MessageIn &msg, bool normalChat,
trim(chatMsg);
if (player_node)
- player_node->setSpeech(chatMsg);
+ player_node->setSpeech(chatMsg, channel);
}
else if (localChatTab)
{
diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h
index c9bdd3029..d46b10057 100644
--- a/src/net/ea/chathandler.h
+++ b/src/net/ea/chathandler.h
@@ -88,6 +88,7 @@ class ChatHandler : public Net::ChatHandler
protected:
typedef std::queue<std::string> WhisperQueue;
WhisperQueue mSentWhispers;
+ bool mShowAllLang;
};
} // namespace Ea