From b42cc5c01d3bdd274d9b9e90aad574d865c4e67a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 30 May 2015 01:11:50 +0300 Subject: Convert ChatMsgType enum into strong typed enum. --- src/enums/gui/chatmsgtype.h | 28 ++++++++++++++-------------- src/gui/chatlog.h | 2 +- src/gui/widgets/tabs/chat/chattab.cpp | 4 ++-- src/gui/widgets/tabs/chat/chattab.h | 2 +- src/gui/windows/chatwindow.cpp | 8 ++++---- src/gui/windows/chatwindow.h | 8 ++++---- src/net/eathena/chathandler.cpp | 2 +- src/net/eathena/chathandler.h | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/enums/gui/chatmsgtype.h b/src/enums/gui/chatmsgtype.h index baacb57fd..947a83ff9 100644 --- a/src/enums/gui/chatmsgtype.h +++ b/src/enums/gui/chatmsgtype.h @@ -23,20 +23,20 @@ #ifndef ENUMS_GUI_CHATMSGTYPE_H #define ENUMS_GUI_CHATMSGTYPE_H -namespace ChatMsgType +#include "enums/simpletypes/enumdefines.h" + +enumStart(ChatMsgType) { - enum Type - { - BY_GM = 0, - BY_PLAYER, - BY_OTHER, - BY_SERVER, - BY_CHANNEL, - ACT_WHISPER, // getting whispered at - ACT_IS, // equivalent to "/me" on IRC - BY_LOGGER, - BY_UNKNOWN = -1 - }; -} // namespace ChatMsgType + BY_GM = 0, + BY_PLAYER, + BY_OTHER, + BY_SERVER, + BY_CHANNEL, + ACT_WHISPER, // getting whispered at + ACT_IS, // equivalent to "/me" on IRC + BY_LOGGER, + BY_UNKNOWN = -1 +} +enumEnd(ChatMsgType); #endif // ENUMS_GUI_CHATMSGTYPE_H diff --git a/src/gui/chatlog.h b/src/gui/chatlog.h index 8e8e70696..9383849cb 100644 --- a/src/gui/chatlog.h +++ b/src/gui/chatlog.h @@ -43,6 +43,6 @@ struct CHATLOG final std::string nick; std::string text; - ChatMsgType::Type own; + ChatMsgTypeT own; }; #endif // GUI_CHATLOG_H diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp index 58f8ec019..a795e8ea1 100644 --- a/src/gui/widgets/tabs/chat/chattab.cpp +++ b/src/gui/widgets/tabs/chat/chattab.cpp @@ -107,7 +107,7 @@ ChatTab::~ChatTab() } void ChatTab::chatLog(std::string line, - ChatMsgType::Type own, + ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors) { @@ -358,7 +358,7 @@ void ChatTab::chatLog(const std::string &nick, std::string msg) if (!localPlayer) return; - const ChatMsgType::Type byWho = (nick == localPlayer->getName() + const ChatMsgTypeT byWho = (nick == localPlayer->getName() ? ChatMsgType::BY_PLAYER : ChatMsgType::BY_OTHER); if (byWho == ChatMsgType::BY_OTHER && config.getBoolValue("removeColors")) msg = removeColors(msg); diff --git a/src/gui/widgets/tabs/chat/chattab.h b/src/gui/widgets/tabs/chat/chattab.h index df3c7913f..56d51b097 100644 --- a/src/gui/widgets/tabs/chat/chattab.h +++ b/src/gui/widgets/tabs/chat/chattab.h @@ -80,7 +80,7 @@ class ChatTab notfinal : public Tab * @param removeColors try remove color if configured */ void chatLog(std::string line, - ChatMsgType::Type own, + ChatMsgTypeT own, const IgnoreRecord ignoreRecord = IgnoreRecord_false, const TryRemoveColors tryRemoveColors = TryRemoveColors_true); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 31b874032..f79f8b45d 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1037,7 +1037,7 @@ void ChatWindow::setVisible(Visible visible) void ChatWindow::addWhisper(const std::string &restrict nick, const std::string &restrict mes, - const ChatMsgType::Type own) + const ChatMsgTypeT own) { if (mes.empty() || !localPlayer) return; @@ -1512,7 +1512,7 @@ std::string ChatWindow::autoCompleteHistory(const std::string &partName) const } bool ChatWindow::resortChatLog(std::string line, - ChatMsgType::Type own, + ChatMsgTypeT own, const std::string &channel, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors) @@ -1677,7 +1677,7 @@ bool ChatWindow::resortChatLog(std::string line, return true; } -void ChatWindow::battleChatLog(const std::string &line, ChatMsgType::Type own, +void ChatWindow::battleChatLog(const std::string &line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors) { @@ -1691,7 +1691,7 @@ void ChatWindow::battleChatLog(const std::string &line, ChatMsgType::Type own, void ChatWindow::channelChatLog(const std::string &channel, const std::string &line, - ChatMsgType::Type own, + ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors) { diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 76e932525..1952909d4 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -195,7 +195,7 @@ class ChatWindow final : public Window, void addWhisper(const std::string &restrict nick, const std::string &restrict mes, - const ChatMsgType::Type own = ChatMsgType::BY_OTHER); + const ChatMsgTypeT own = ChatMsgType::BY_OTHER); WhisperTab *addWhisperTab(const std::string &caption, const std::string &nick, @@ -223,13 +223,13 @@ class ChatWindow final : public Window, void ignoreAllWhispers(); - bool resortChatLog(std::string line, ChatMsgType::Type own, + bool resortChatLog(std::string line, ChatMsgTypeT own, const std::string &channel, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors); static void battleChatLog(const std::string &line, - ChatMsgType::Type own + ChatMsgTypeT own = ChatMsgType::BY_UNKNOWN, const IgnoreRecord ignoreRecord = IgnoreRecord_false, @@ -238,7 +238,7 @@ class ChatWindow final : public Window, void channelChatLog(const std::string &channel, const std::string &line, - ChatMsgType::Type own, + ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors); diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index d31afa3c9..3cade553c 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -548,7 +548,7 @@ std::string ChatHandler::extractChannelFromMessage(std::string &chatMsg) } void ChatHandler::processChatContinue(std::string chatMsg, - ChatMsgType::Type own) + ChatMsgTypeT own) { const std::string channel = extractChannelFromMessage(chatMsg); bool allow(true); diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h index c0807c37a..a1a86f20e 100644 --- a/src/net/eathena/chathandler.h +++ b/src/net/eathena/chathandler.h @@ -106,7 +106,7 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler static void processColorChat(Net::MessageIn &msg); static void processChatContinue(std::string chatMsg, - ChatMsgType::Type own); + ChatMsgTypeT own); static void processWhisper(Net::MessageIn &msg); -- cgit v1.2.3-60-g2f50