diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-24 22:04:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-24 22:04:29 +0300 |
commit | 7ae8a11e0e99ab28730a8ca98388a6ec0ea1923e (patch) | |
tree | 6b440c246a9ed2c3d915c98f6b090a45673a2fb7 /src | |
parent | 860d3e8e1bbe99b77763d533aebba9fde01e74c6 (diff) | |
download | ManaVerse-7ae8a11e0e99ab28730a8ca98388a6ec0ea1923e.tar.gz ManaVerse-7ae8a11e0e99ab28730a8ca98388a6ec0ea1923e.tar.bz2 ManaVerse-7ae8a11e0e99ab28730a8ca98388a6ec0ea1923e.tar.xz ManaVerse-7ae8a11e0e99ab28730a8ca98388a6ec0ea1923e.zip |
Add strong typed bool type TryRemoveColors.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/enums/simpletypes/tryremovecolors.h | 28 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chat/chattab.cpp | 7 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chat/chattab.h | 4 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 34 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.h | 8 | ||||
-rw-r--r-- | src/net/eathena/chathandler.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 6 |
9 files changed, 71 insertions, 26 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 78b1e0196..bdea7491d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1075,6 +1075,7 @@ SET(SRCS enums/simpletypes/simpledefines.h enums/simpletypes/skiperror.h enums/simpletypes/trading.h + enums/simpletypes/tryremovecolors.h enums/simpletypes/useargs.h enums/simpletypes/useresman.h statuseffect.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 45962db50..01dc269f8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1203,6 +1203,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ enums/simpletypes/simpledefines.h \ enums/simpletypes/skiperror.h \ enums/simpletypes/trading.h \ + enums/simpletypes/tryremovecolors.h \ enums/simpletypes/useargs.h \ enums/simpletypes/useresman.h \ statuseffect.cpp \ diff --git a/src/enums/simpletypes/tryremovecolors.h b/src/enums/simpletypes/tryremovecolors.h new file mode 100644 index 000000000..e4ae07dff --- /dev/null +++ b/src/enums/simpletypes/tryremovecolors.h @@ -0,0 +1,28 @@ +/* + * The ManaPlus Client + * Copyright (C) 2015 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef ENUMS_SIMPLETYPES_TRYREMOVECOLORS_H +#define ENUMS_SIMPLETYPES_TRYREMOVECOLORS_H + +#include "enums/simpletypes/simpledefines.h" + +defBoolEnum(TryRemoveColors); + +#endif // ENUMS_SIMPLETYPES_TRYREMOVECOLORS_H diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp index 072ab677e..dd2ff9a54 100644 --- a/src/gui/widgets/tabs/chat/chattab.cpp +++ b/src/gui/widgets/tabs/chat/chattab.cpp @@ -109,7 +109,7 @@ ChatTab::~ChatTab() void ChatTab::chatLog(std::string line, ChatMsgType::Type own, const IgnoreRecord ignoreRecord, - const bool tryRemoveColors) + const TryRemoveColors tryRemoveColors) { // Trim whitespace trim(line); @@ -117,7 +117,8 @@ void ChatTab::chatLog(std::string line, if (line.empty()) return; - if (tryRemoveColors && own == ChatMsgType::BY_OTHER && + if (tryRemoveColors == TryRemoveColors_true && + own == ChatMsgType::BY_OTHER && config.getBoolValue("removeColors")) { line = removeColors(line); @@ -364,7 +365,7 @@ void ChatTab::chatLog(const std::string &nick, std::string msg) chatLog(std::string(nick).append(" : ").append(msg), byWho, IgnoreRecord_false, - false); + TryRemoveColors_false); } void ChatTab::chatInput(const std::string &message) diff --git a/src/gui/widgets/tabs/chat/chattab.h b/src/gui/widgets/tabs/chat/chattab.h index 7af3920ef..6eee19b9d 100644 --- a/src/gui/widgets/tabs/chat/chattab.h +++ b/src/gui/widgets/tabs/chat/chattab.h @@ -27,6 +27,7 @@ #include "enums/simpletypes/ignorerecord.h" #include "enums/simpletypes/online.h" +#include "enums/simpletypes/tryremovecolors.h" #include "gui/widgets/browserbox.h" @@ -81,7 +82,8 @@ class ChatTab notfinal : public Tab void chatLog(std::string line, ChatMsgType::Type own = ChatMsgType::BY_SERVER, const IgnoreRecord ignoreRecord = IgnoreRecord_false, - const bool tryRemoveColors = true); + const TryRemoveColors tryRemoveColors + = TryRemoveColors_true); /** * Adds the text to the message list diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 44053c50c..178f41c7e 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1509,7 +1509,7 @@ bool ChatWindow::resortChatLog(std::string line, ChatMsgType::Type own, const std::string &channel, const IgnoreRecord ignoreRecord, - const bool tryRemoveColors) + const TryRemoveColors tryRemoveColors) { if (own == ChatMsgType::BY_UNKNOWN) { @@ -1537,8 +1537,10 @@ bool ChatWindow::resortChatLog(std::string line, { if (tradeChatTab) { - tradeChatTab->chatLog(prefix + line, own, - ignoreRecord, tryRemoveColors); + tradeChatTab->chatLog(prefix + line, + own, + ignoreRecord, + tryRemoveColors); } return false; } @@ -1600,7 +1602,9 @@ bool ChatWindow::resortChatLog(std::string line, if (tradeChatTab) { line = line.erase(idx + 2, 2); - tradeChatTab->chatLog(prefix + line, own, ignoreRecord, + tradeChatTab->chatLog(prefix + line, + own, + ignoreRecord, tryRemoveColors); } return false; @@ -1620,8 +1624,10 @@ bool ChatWindow::resortChatLog(std::string line, { if (line.find("http", idx1) != idx1 + 2) { - tradeChatTab->chatLog(prefix + line, own, - ignoreRecord, tryRemoveColors); + tradeChatTab->chatLog(prefix + line, + own, + ignoreRecord, + tryRemoveColors); return false; } } @@ -1639,8 +1645,10 @@ bool ChatWindow::resortChatLog(std::string line, } else if (mShowAllLang) { - langChatTab->chatLog(prefix + line, own, - ignoreRecord, tryRemoveColors); + langChatTab->chatLog(prefix + line, + own, + ignoreRecord, + tryRemoveColors); } } else if (serverFeatures->haveChatChannels()) @@ -1650,8 +1658,10 @@ bool ChatWindow::resortChatLog(std::string line, } else if (mShowAllLang) { - localChatTab->chatLog(prefix + line, own, - ignoreRecord, tryRemoveColors); + localChatTab->chatLog(prefix + line, + own, + ignoreRecord, + tryRemoveColors); } } else if (localChatTab && channel.empty()) @@ -1663,7 +1673,7 @@ bool ChatWindow::resortChatLog(std::string line, void ChatWindow::battleChatLog(const std::string &line, ChatMsgType::Type own, const IgnoreRecord ignoreRecord, - const bool tryRemoveColors) + const TryRemoveColors tryRemoveColors) { if (own == ChatMsgType::BY_UNKNOWN) own = ChatMsgType::BY_SERVER; @@ -1677,7 +1687,7 @@ void ChatWindow::channelChatLog(const std::string &channel, const std::string &line, ChatMsgType::Type own, const IgnoreRecord ignoreRecord, - const bool tryRemoveColors) + const TryRemoveColors tryRemoveColors) { std::string tempChannel = channel; toLower(tempChannel); diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 766e5161e..3077b9e8b 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -26,6 +26,7 @@ #include "enums/gui/chatmsgtype.h" #include "enums/simpletypes/ignorerecord.h" +#include "enums/simpletypes/tryremovecolors.h" #include "gui/widgets/window.h" @@ -224,20 +225,21 @@ class ChatWindow final : public Window, bool resortChatLog(std::string line, ChatMsgType::Type own, const std::string &channel, const IgnoreRecord ignoreRecord, - const bool tryRemoveColors); + const TryRemoveColors tryRemoveColors); static void battleChatLog(const std::string &line, ChatMsgType::Type own = ChatMsgType::BY_UNKNOWN, const IgnoreRecord ignoreRecord = IgnoreRecord_false, - const bool tryRemoveColors = true); + const TryRemoveColors tryRemoveColors + = TryRemoveColors_true); void channelChatLog(const std::string &channel, const std::string &line, ChatMsgType::Type own, const IgnoreRecord ignoreRecord, - const bool tryRemoveColors); + const TryRemoveColors tryRemoveColors); void updateOnline(const std::set<std::string> &onlinePlayers) const; diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index 76603734c..9db670080 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -558,7 +558,7 @@ void ChatHandler::processChatContinue(std::string chatMsg, own, channel, IgnoreRecord_false, - true); + TryRemoveColors_true); } const size_t pos = chatMsg.find(" : ", 0); @@ -641,7 +641,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg) "%s is not exists."), nick.c_str()), ChatMsgType::BY_SERVER, IgnoreRecord_false, - false); + TryRemoveColors_false); if (!mSentWhispers.empty()) mSentWhispers.pop(); return; @@ -787,7 +787,7 @@ void ChatHandler::processJoinChannel(Net::MessageIn &msg) "%s is not exists."), channel.c_str()), ChatMsgType::BY_SERVER, IgnoreRecord_false, - false); + TryRemoveColors_false); break; case 1: @@ -881,7 +881,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg) ChatMsgType::BY_OTHER, GENERAL_CHANNEL, IgnoreRecord_false, - true); + TryRemoveColors_true); } if (allow && being && player_relations.hasPermission(sender_name, diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index be04b2964..98f6b2c18 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -335,7 +335,7 @@ void ChatHandler::processChatContinue(std::string chatMsg, ChatMsgType::BY_PLAYER, channel, IgnoreRecord_false, - true); + TryRemoveColors_true); } if (channel.empty()) @@ -406,7 +406,7 @@ void ChatHandler::processGmChat(Net::MessageIn &msg) ChatMsgType::BY_PLAYER, channel, IgnoreRecord_false, - true); + TryRemoveColors_true); } if (channel.empty()) @@ -678,7 +678,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg) ChatMsgType::BY_OTHER, channel, IgnoreRecord_false, - true); + TryRemoveColors_true); } if (allow && player_relations.hasPermission(sender_name, |