diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-16 16:15:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-16 16:15:34 +0300 |
commit | fe6a120ea38daaad39f6952a886c20269cfedca6 (patch) | |
tree | 4595d63a2ab9764873657182fbf2ab2b985474bf | |
parent | 6279b10249efa59b3161b014899465fe4bb08da4 (diff) | |
download | manaplus-fe6a120ea38daaad39f6952a886c20269cfedca6.tar.gz manaplus-fe6a120ea38daaad39f6952a886c20269cfedca6.tar.bz2 manaplus-fe6a120ea38daaad39f6952a886c20269cfedca6.tar.xz manaplus-fe6a120ea38daaad39f6952a886c20269cfedca6.zip |
Move chatmsgtype into separate file.
-rw-r--r-- | src/actionmanager.cpp | 4 | ||||
-rw-r--r-- | src/actormanager.cpp | 4 | ||||
-rw-r--r-- | src/being/being.cpp | 5 | ||||
-rw-r--r-- | src/being/localplayer.cpp | 7 | ||||
-rw-r--r-- | src/commands.cpp | 41 | ||||
-rw-r--r-- | src/game.cpp | 10 | ||||
-rw-r--r-- | src/gui/chatlog.h | 6 | ||||
-rw-r--r-- | src/gui/chatmsgtype.h | 42 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chattab.cpp | 47 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chattab.h | 3 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 33 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.h | 22 | ||||
-rw-r--r-- | src/gui/windows/shopwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/socialwindow.cpp | 20 | ||||
-rw-r--r-- | src/gui/windows/tradewindow.cpp | 5 | ||||
-rw-r--r-- | src/net/ea/buysellhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/ea/chathandler.cpp | 10 | ||||
-rw-r--r-- | src/net/ea/gui/guildtab.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/gui/partytab.cpp | 26 | ||||
-rw-r--r-- | src/net/ea/guildhandler.cpp | 24 | ||||
-rw-r--r-- | src/notifymanager.cpp | 10 | ||||
-rw-r--r-- | src/statuseffect.cpp | 2 |
22 files changed, 192 insertions, 141 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index bfdf15b86..52f2c1a97 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -885,7 +885,7 @@ impHandler0(changeTrade) { // TRANSLATORS: disable trades message localChatTab->chatLog(_("Ignoring incoming trade requests"), - BY_SERVER); + ChatMsgType::BY_SERVER); } deflt &= ~PlayerRelation::TRADE; } @@ -895,7 +895,7 @@ impHandler0(changeTrade) { // TRANSLATORS: enable trades message localChatTab->chatLog(_("Accepting incoming trade requests"), - BY_SERVER); + ChatMsgType::BY_SERVER); } deflt |= PlayerRelation::TRADE; } diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 265c60e17..0ba29a774 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1275,7 +1275,7 @@ void ActorManager::printBeingsToChat(const ActorSprites &beings, debugChatTab->chatLog(strprintf("%s (%d,%d) %d", being->getName().c_str(), being->getTileX(), being->getTileY(), - being->getSubType()), BY_SERVER); + being->getSubType()), ChatMsgType::BY_SERVER); } debugChatTab->chatLog("---------------------------------------"); } @@ -1298,7 +1298,7 @@ void ActorManager::printBeingsToChat(const std::vector<Being*> &beings, debugChatTab->chatLog(strprintf("%s (%d,%d) %d", being->getName().c_str(), being->getTileX(), being->getTileY(), - being->getSubType()), BY_SERVER); + being->getSubType()), ChatMsgType::BY_SERVER); } debugChatTab->chatLog("---------------------------------------"); } diff --git a/src/being/being.cpp b/src/being/being.cpp index 0d72585f1..d3df414c5 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -562,14 +562,15 @@ void Being::takeDamage(Being *const attacker, const int amount, if (attacker->mType == ActorType::PLAYER || amount) { chatWindow->battleChatLog(strprintf("%s : Hit you -%d", - attacker->getName().c_str(), amount), BY_OTHER); + attacker->getName().c_str(), amount), + ChatMsgType::BY_OTHER); } } else if (attacker == player_node && amount) { chatWindow->battleChatLog(strprintf("%s : You hit %s -%d", attacker->getName().c_str(), getName().c_str(), amount), - BY_PLAYER); + ChatMsgType::BY_PLAYER); } } if (font && particleEngine) diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 8d921d8dd..08a74ad8b 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -853,7 +853,7 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, const int amount, break; } if (localChatTab && config.getBoolValue("showpickupchat")) - localChatTab->chatLog(gettext(msg), BY_SERVER); + localChatTab->chatLog(gettext(msg), ChatMsgType::BY_SERVER); if (mMap && config.getBoolValue("showpickupparticle")) { @@ -875,7 +875,8 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, const int amount, // [@@%d|%s@@] - here player can see link to item localChatTab->chatLog(strprintf(ngettext("You picked up %d " "[@@%d|%s@@].", "You picked up %d [@@%d|%s@@].", amount), - amount, itemInfo.getId(), str.c_str()), BY_SERVER); + amount, itemInfo.getId(), str.c_str()), + ChatMsgType::BY_SERVER); } if (mMap && config.getBoolValue("showpickupparticle")) @@ -3023,7 +3024,7 @@ void LocalPlayer::afkRespond(ChatTab *const tab, const std::string &nick) if (localChatTab) { localChatTab->chatLog(std::string(getName()).append( - " : ").append(msg), ACT_WHISPER, false); + " : ").append(msg), ChatMsgType::ACT_WHISPER, false); } } else diff --git a/src/commands.cpp b/src/commands.cpp index 737095480..e18d2e484 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -153,7 +153,7 @@ static void changeRelation(const std::string &args, if (args.empty()) { // TRANSLATORS: change relation - tab->chatLog(_("Please specify a name."), BY_SERVER); + tab->chatLog(_("Please specify a name."), ChatMsgType::BY_SERVER); return; } @@ -161,7 +161,7 @@ static void changeRelation(const std::string &args, { // TRANSLATORS: change relation tab->chatLog(strprintf(_("Player already %s!"), - relationText.c_str()), BY_SERVER); + relationText.c_str()), ChatMsgType::BY_SERVER); return; } else @@ -173,13 +173,13 @@ static void changeRelation(const std::string &args, { // TRANSLATORS: change relation tab->chatLog(strprintf(_("Player successfully %s!"), - relationText.c_str()), BY_SERVER); + relationText.c_str()), ChatMsgType::BY_SERVER); } else { // TRANSLATORS: change relation tab->chatLog(strprintf(_("Player could not be %s!"), - relationText.c_str()), BY_SERVER); + relationText.c_str()), ChatMsgType::BY_SERVER); } } @@ -293,7 +293,7 @@ impHandler2(where) where << Game::instance()->getCurrentMapName() << ", coordinates: " << ((player_node->getPixelX() - mapTileSize / 2) / mapTileSize) << ", " << ((player_node->getPixelY() - mapTileSize) / mapTileSize); - tab->chatLog(where.str(), BY_SERVER); + tab->chatLog(where.str(), ChatMsgType::BY_SERVER); } impHandler0(who) @@ -345,12 +345,12 @@ impHandler(msg) if (tempNick.compare(playerName) == 0 || args.empty()) return; - chatWindow->addWhisper(recvnick, msg, BY_PLAYER); + chatWindow->addWhisper(recvnick, msg, ChatMsgType::BY_PLAYER); } else { // TRANSLATORS: whisper send - tab->chatLog(_("Cannot send empty whispers!"), BY_SERVER); + tab->chatLog(_("Cannot send empty whispers!"), ChatMsgType::BY_SERVER); } } @@ -370,7 +370,7 @@ impHandler(query) // TRANSLATORS: new whisper query tab->chatLog(strprintf(_("Cannot create a whisper tab for nick " "\"%s\"! It either already exists, or is you."), - args.c_str()), BY_SERVER); + args.c_str()), ChatMsgType::BY_SERVER); } } @@ -410,7 +410,7 @@ impHandler(createParty) if (args.empty()) { // TRANSLATORS: create party message - tab->chatLog(_("Party name is missing."), BY_SERVER); + tab->chatLog(_("Party name is missing."), ChatMsgType::BY_SERVER); } else { @@ -426,7 +426,7 @@ impHandler(createGuild) if (args.empty()) { // TRANSLATORS: create guild message - tab->chatLog(_("Guild name is missing."), BY_SERVER); + tab->chatLog(_("Guild name is missing."), ChatMsgType::BY_SERVER); } else { @@ -446,7 +446,7 @@ impHandler(party) else { // TRANSLATORS: party invite message - tab->chatLog(_("Please specify a name."), BY_SERVER); + tab->chatLog(_("Please specify a name."), ChatMsgType::BY_SERVER); } } @@ -533,7 +533,7 @@ impHandler(unignore) if (tab) { // TRANSLATORS: unignore command - tab->chatLog(_("Please specify a name."), BY_SERVER); + tab->chatLog(_("Please specify a name."), ChatMsgType::BY_SERVER); } return; } @@ -548,7 +548,7 @@ impHandler(unignore) if (tab) { // TRANSLATORS: unignore command - tab->chatLog(_("Player wasn't ignored!"), BY_SERVER); + tab->chatLog(_("Player wasn't ignored!"), ChatMsgType::BY_SERVER); } return; } @@ -558,12 +558,13 @@ impHandler(unignore) if (player_relations.getRelation(args) == PlayerRelation::NEUTRAL) { // TRANSLATORS: unignore command - tab->chatLog(_("Player no longer ignored!"), BY_SERVER); + tab->chatLog(_("Player no longer ignored!"), ChatMsgType::BY_SERVER); } else { // TRANSLATORS: unignore command - tab->chatLog(_("Player could not be unignored!"), BY_SERVER); + tab->chatLog(_("Player could not be unignored!"), + ChatMsgType::BY_SERVER); } } } @@ -587,7 +588,7 @@ impHandler(erase) if (tab) { // TRANSLATORS: erase command - tab->chatLog(_("Please specify a name."), BY_SERVER); + tab->chatLog(_("Please specify a name."), ChatMsgType::BY_SERVER); } return; } @@ -597,7 +598,7 @@ impHandler(erase) if (tab) { // TRANSLATORS: erase command - tab->chatLog(_("Player already erased!"), BY_SERVER); + tab->chatLog(_("Player already erased!"), ChatMsgType::BY_SERVER); } return; } @@ -611,12 +612,14 @@ impHandler(erase) if (player_relations.getRelation(args) == PlayerRelation::ERASED) { // TRANSLATORS: erase command - tab->chatLog(_("Player successfully erased!"), BY_SERVER); + tab->chatLog(_("Player successfully erased!"), + ChatMsgType::BY_SERVER); } else { // TRANSLATORS: erase command - tab->chatLog(_("Player could not be erased!"), BY_SERVER); + tab->chatLog(_("Player could not be erased!"), + ChatMsgType::BY_SERVER); } } } diff --git a/src/game.cpp b/src/game.cpp index 241f15a6a..6b265424a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -579,7 +579,7 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot) // TRANSLATORS: save file message std::string str = strprintf(_("Screenshot saved as %s"), fileNameStr.c_str()); - localChatTab->chatLog(str, BY_SERVER); + localChatTab->chatLog(str, ChatMsgType::BY_SERVER); } } else @@ -588,7 +588,7 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot) { // TRANSLATORS: save file message localChatTab->chatLog(_("Saving screenshot failed!"), - BY_SERVER); + ChatMsgType::BY_SERVER); } logger->log1("Error: could not save screenshot."); } @@ -759,7 +759,7 @@ void Game::adjustPerfomance() if (localChatTab) { localChatTab->chatLog("Auto disable Show " - "beings transparency", BY_SERVER); + "beings transparency", ChatMsgType::BY_SERVER); } } else @@ -776,7 +776,7 @@ void Game::adjustPerfomance() if (localChatTab) { localChatTab->chatLog("Auto lower Particle " - "effects", BY_SERVER); + "effects", ChatMsgType::BY_SERVER); } } else @@ -793,7 +793,7 @@ void Game::adjustPerfomance() if (localChatTab) { localChatTab->chatLog("Auto enable opacity cache", - BY_SERVER); + ChatMsgType::BY_SERVER); } } break; diff --git a/src/gui/chatlog.h b/src/gui/chatlog.h index c39146ff2..25bcd10d5 100644 --- a/src/gui/chatlog.h +++ b/src/gui/chatlog.h @@ -23,7 +23,7 @@ #ifndef GUI_CHATLOG_H #define GUI_CHATLOG_H -#include "gui/windows/chatwindow.h" +#include "gui/chatmsgtype.h" #include <string> @@ -35,7 +35,7 @@ struct CHATLOG final CHATLOG() : nick(), text(), - own(BY_UNKNOWN) + own(ChatMsgType::BY_UNKNOWN) { } @@ -43,6 +43,6 @@ struct CHATLOG final std::string nick; std::string text; - Own own; + ChatMsgType::Type own; }; #endif // GUI_CHATLOG_H diff --git a/src/gui/chatmsgtype.h b/src/gui/chatmsgtype.h new file mode 100644 index 000000000..5c1cf5589 --- /dev/null +++ b/src/gui/chatmsgtype.h @@ -0,0 +1,42 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 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 GUI_CHATMSGTYPE_H +#define GUI_CHATMSGTYPE_H + +namespace 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 + }; +} + +#endif // GUI_CHATMSGTYPE_H diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 12632e89d..47d5b3906 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -94,7 +94,7 @@ ChatTab::~ChatTab() delete2(mScrollArea); } -void ChatTab::chatLog(std::string line, Own own, +void ChatTab::chatLog(std::string line, ChatMsgType::Type own, const bool ignoreRecord, const bool tryRemoveColors) { // Trim whitespace @@ -103,7 +103,7 @@ void ChatTab::chatLog(std::string line, Own own, if (line.empty()) return; - if (tryRemoveColors && own == BY_OTHER && + if (tryRemoveColors && own == ChatMsgType::BY_OTHER && config.getBoolValue("removeColors")) { line = removeColors(line); @@ -136,23 +136,23 @@ void ChatTab::chatLog(std::string line, Own own, { // Fix the owner of welcome message. if (line.length() > 7 && line.substr(0, 7) == "Welcome") - own = BY_SERVER; + own = ChatMsgType::BY_SERVER; } // *implements actions in a backwards compatible way* - if ((own == BY_PLAYER || own == BY_OTHER) && + if ((own == ChatMsgType::BY_PLAYER || own == ChatMsgType::BY_OTHER) && tmp.text.at(0) == '*' && tmp.text.at(tmp.text.length()-1) == '*') { tmp.text[0] = ' '; tmp.text.erase(tmp.text.length() - 1); - own = ACT_IS; + own = ChatMsgType::ACT_IS; } std::string lineColor("##C"); switch (own) { - case BY_GM: + case ChatMsgType::BY_GM: if (tmp.nick.empty()) { // TRANSLATORS: chat message @@ -167,34 +167,34 @@ void ChatTab::chatLog(std::string line, Own own, lineColor = "##g"; // Equiv. to BrowserBox::RED } break; - case BY_PLAYER: + case ChatMsgType::BY_PLAYER: tmp.nick.append(": "); lineColor = "##Y"; break; - case BY_OTHER: - case BY_UNKNOWN: + case ChatMsgType::BY_OTHER: + case ChatMsgType::BY_UNKNOWN: tmp.nick.append(": "); lineColor = "##C"; break; - case BY_SERVER: + case ChatMsgType::BY_SERVER: // TRANSLATORS: chat message tmp.nick.clear(); tmp.text = line; lineColor = "##S"; break; - case BY_CHANNEL: + case ChatMsgType::BY_CHANNEL: tmp.nick.clear(); lineColor = "##2"; // Equiv. to BrowserBox::GREEN break; - case ACT_WHISPER: + case ChatMsgType::ACT_WHISPER: // TRANSLATORS: chat message tmp.nick = strprintf(_("%s whispers: %s"), tmp.nick.c_str(), ""); lineColor = "##W"; break; - case ACT_IS: + case ChatMsgType::ACT_IS: lineColor = "##I"; break; - case BY_LOGGER: + case ChatMsgType::BY_LOGGER: tmp.nick.clear(); tmp.text = line; lineColor = "##L"; @@ -211,10 +211,10 @@ void ChatTab::chatLog(std::string line, Own own, // if configured, move magic messages log to debug chat tab if (localChatTab && this == localChatTab - && ((config.getBoolValue("showMagicInDebug") && own == BY_PLAYER + && ((config.getBoolValue("showMagicInDebug") && own == ChatMsgType::BY_PLAYER && tmp.text.length() > 1 && tmp.text.at(0) == '#' && tmp.text.at(1) != '#') - || (config.getBoolValue("serverMsgInDebug") && (own == BY_SERVER + || (config.getBoolValue("serverMsgInDebug") && (own == ChatMsgType::BY_SERVER || tmp.nick.empty())))) { if (debugChatTab) @@ -278,9 +278,9 @@ void ChatTab::chatLog(std::string line, Own own, chatWindow->addToAwayLog(line); mScrollArea->logic(); - if (own != BY_PLAYER) + if (own != ChatMsgType::BY_PLAYER) { - if (own == BY_SERVER && (getType() == ChatTabType::PARTY + if (own == ChatMsgType::BY_SERVER && (getType() == ChatTabType::PARTY || getType() == ChatTabType::GUILD)) { return; @@ -311,18 +311,18 @@ void ChatTab::chatLog(std::string line, Own own, } } - if ((getAllowHighlight() || own == BY_GM) + if ((getAllowHighlight() || own == ChatMsgType::BY_GM) && (this != tabArea->getSelectedTab() || (client->getIsMinimized() || (!client->getMouseFocused() && !client->getInputFocused())))) { - if (own == BY_GM) + if (own == ChatMsgType::BY_GM) { if (chatWindow) chatWindow->unHideWindow(); soundManager.playGuiSound(SOUND_GLOBAL); } - else if (own != BY_SERVER) + else if (own != ChatMsgType::BY_SERVER) { if (chatWindow) chatWindow->unHideWindow(); @@ -338,8 +338,9 @@ void ChatTab::chatLog(const std::string &nick, std::string msg) if (!player_node) return; - const Own byWho = (nick == player_node->getName() ? BY_PLAYER : BY_OTHER); - if (byWho == BY_OTHER && config.getBoolValue("removeColors")) + const ChatMsgType::Type byWho = (nick == player_node->getName() + ? ChatMsgType::BY_PLAYER : ChatMsgType::BY_OTHER); + if (byWho == ChatMsgType::BY_OTHER && config.getBoolValue("removeColors")) msg = removeColors(msg); chatLog(std::string(nick).append(" : ").append(msg), byWho, false, false); } diff --git a/src/gui/widgets/tabs/chattab.h b/src/gui/widgets/tabs/chattab.h index da17f1501..b7c76494d 100644 --- a/src/gui/widgets/tabs/chattab.h +++ b/src/gui/widgets/tabs/chattab.h @@ -58,7 +58,8 @@ class ChatTab : public Tab * @param ignoreRecord should this not be recorded? * @param removeColors try remove color if configured */ - void chatLog(std::string line, Own own = BY_SERVER, + void chatLog(std::string line, + ChatMsgType::Type own = ChatMsgType::BY_SERVER, const bool ignoreRecord = false, const bool tryRemoveColors = true); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index bd40d8084..bcfcf65f7 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -636,7 +636,7 @@ void ChatWindow::doPresent() const response.c_str(), playercount); if (getFocused()) - getFocused()->chatLog(log, BY_SERVER); + getFocused()->chatLog(log, ChatMsgType::BY_SERVER); } void ChatWindow::scroll(const int amount) const @@ -974,7 +974,8 @@ void ChatWindow::setVisible(bool visible) } void ChatWindow::addWhisper(const std::string &restrict nick, - const std::string &restrict mes, const Own own) + const std::string &restrict mes, + const ChatMsgType::Type own) { if (mes.empty() || !player_node) return; @@ -1004,11 +1005,11 @@ void ChatWindow::addWhisper(const std::string &restrict nick, if (tab) { - if (own == BY_PLAYER) + if (own == ChatMsgType::BY_PLAYER) { tab->chatInput(mes); } - else if (own == BY_SERVER) + else if (own == ChatMsgType::BY_SERVER) { tab->chatLog(mes); } @@ -1033,7 +1034,7 @@ void ChatWindow::addWhisper(const std::string &restrict nick, { if (config.getBoolValue("removeColors")) msg = removeColors(msg); - tab->chatLog(msg, BY_SERVER); + tab->chatLog(msg, ChatMsgType::BY_SERVER); } } else @@ -1045,18 +1046,18 @@ void ChatWindow::addWhisper(const std::string &restrict nick, } else if (localChatTab) { - if (own == BY_PLAYER) + if (own == ChatMsgType::BY_PLAYER) { Net::getChatHandler()->privateMessage(nick, mes); // TRANSLATORS: chat message localChatTab->chatLog(strprintf(_("Whispering to %s: %s"), - nick.c_str(), mes.c_str()), BY_PLAYER); + nick.c_str(), mes.c_str()), ChatMsgType::BY_PLAYER); } else { localChatTab->chatLog(std::string(nick).append( - " : ").append(mes), ACT_WHISPER, false); + " : ").append(mes), ChatMsgType::ACT_WHISPER, false); if (player_node) player_node->afkRespond(nullptr, nick); } @@ -1353,13 +1354,13 @@ std::string ChatWindow::autoCompleteHistory(const std::string &partName) const return autoComplete(nameList, partName); } -bool ChatWindow::resortChatLog(std::string line, Own own, +bool ChatWindow::resortChatLog(std::string line, ChatMsgType::Type own, const std::string &channel, const bool ignoreRecord, const bool tryRemoveColors) { - if (own == BY_UNKNOWN) - own = BY_SERVER; + if (own == ChatMsgType::BY_UNKNOWN) + own = ChatMsgType::BY_SERVER; std::string prefix; if (!channel.empty()) @@ -1466,12 +1467,12 @@ bool ChatWindow::resortChatLog(std::string line, Own own, return true; } -void ChatWindow::battleChatLog(const std::string &line, Own own, +void ChatWindow::battleChatLog(const std::string &line, ChatMsgType::Type own, const bool ignoreRecord, const bool tryRemoveColors) { - if (own == BY_UNKNOWN) - own = BY_SERVER; + if (own == ChatMsgType::BY_UNKNOWN) + own = ChatMsgType::BY_SERVER; if (battleChatTab) battleChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors); else if (debugChatTab) @@ -1837,9 +1838,9 @@ void ChatWindow::logicChildren() void ChatWindow::addGlobalMessage(const std::string &line) { if (debugChatTab && findI(line, mGlobalsFilter) != std::string::npos) - debugChatTab->chatLog(line, BY_OTHER); + debugChatTab->chatLog(line, ChatMsgType::BY_OTHER); else - localChatTab->chatLog(line, BY_GM); + localChatTab->chatLog(line, ChatMsgType::BY_GM); } bool ChatWindow::isTabPresent(const ChatTab *const tab) const diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 98b1eb73e..b90b15b45 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -23,6 +23,8 @@ #ifndef GUI_WINDOWS_CHATWINDOW_H #define GUI_WINDOWS_CHATWINDOW_H +#include "gui/chatmsgtype.h" + #include "gui/widgets/window.h" #include "listeners/actionlistener.h" @@ -46,19 +48,6 @@ class WhisperTab; const int DEFAULT_CHAT_WINDOW_SCROLL = 7; -enum Own -{ - 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 -}; - /** * The chat window. * @@ -202,7 +191,7 @@ class ChatWindow final : public Window, void addWhisper(const std::string &restrict nick, const std::string &restrict mes, - const Own own = BY_OTHER); + const ChatMsgType::Type own = ChatMsgType::BY_OTHER); WhisperTab *addWhisperTab(const std::string &nick, const bool switchTo = false) A_WARN_UNUSED; @@ -213,13 +202,14 @@ class ChatWindow final : public Window, void ignoreAllWhispers(); - bool resortChatLog(std::string line, Own own, + bool resortChatLog(std::string line, ChatMsgType::Type own, const std::string &channel, const bool ignoreRecord, const bool tryRemoveColors); static void battleChatLog(const std::string &line, - Own own = BY_UNKNOWN, + ChatMsgType::Type own + = ChatMsgType::BY_UNKNOWN, const bool ignoreRecord = false, const bool tryRemoveColors = true); diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 7e4f71e50..04e2f1511 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -633,7 +633,7 @@ void ShopWindow::sendMessage(const std::string &nick, if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else - chatWindow->addWhisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); } void ShopWindow::showList(const std::string &nick, std::string data) diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 0ff1d8866..28d27e82b 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -227,7 +227,7 @@ public: localChatTab->chatLog(strprintf( // TRANSLATORS: chat message _("Invited user %s to guild %s."), - name.c_str(), mGuild->getName().c_str()), BY_SERVER); + name.c_str(), mGuild->getName().c_str()), ChatMsgType::BY_SERVER); } mInviteDialog = nullptr; } @@ -242,7 +242,7 @@ public: { // TRANSLATORS: chat message localChatTab->chatLog(strprintf(_("Guild %s quit requested."), - mGuild->getName().c_str()), BY_SERVER); + mGuild->getName().c_str()), ChatMsgType::BY_SERVER); } mConfirmDialog = nullptr; } @@ -433,7 +433,7 @@ public: { // TRANSLATORS: chat message localChatTab->chatLog(strprintf(_("Invited user %s to party."), - name.c_str()), BY_SERVER); + name.c_str()), ChatMsgType::BY_SERVER); } mInviteDialog = nullptr; } @@ -448,7 +448,7 @@ public: { // TRANSLATORS: tab in social window localChatTab->chatLog(strprintf(_("Party %s quit requested."), - mParty->getName().c_str()), BY_SERVER); + mParty->getName().c_str()), ChatMsgType::BY_SERVER); } mConfirmDialog = nullptr; } @@ -1540,7 +1540,7 @@ void SocialWindow::action(const ActionEvent &event) { // TRANSLATORS: chat message localChatTab->chatLog(strprintf(_("Creating guild called %s."), - name.c_str()), BY_SERVER); + name.c_str()), ChatMsgType::BY_SERVER); } mGuildCreateDialog = nullptr; @@ -1561,7 +1561,7 @@ void SocialWindow::action(const ActionEvent &event) { // TRANSLATORS: chat message localChatTab->chatLog(strprintf(_("Creating party called %s."), - name.c_str()), BY_SERVER); + name.c_str()), ChatMsgType::BY_SERVER); } mPartyCreateDialog = nullptr; @@ -1594,7 +1594,7 @@ void SocialWindow::showGuildInvite(const std::string &restrict guildName, { // TRANSLATORS: chat message localChatTab->chatLog(_("Received guild request, but one already " - "exists."), BY_SERVER); + "exists."), ChatMsgType::BY_SERVER); } return; } @@ -1605,7 +1605,7 @@ void SocialWindow::showGuildInvite(const std::string &restrict guildName, inviterName.c_str(), guildName.c_str()); if (localChatTab) - localChatTab->chatLog(msg, BY_SERVER); + localChatTab->chatLog(msg, ChatMsgType::BY_SERVER); // TRANSLATORS: guild invite message mGuildAcceptDialog = new ConfirmDialog(_("Accept Guild Invite"), @@ -1625,7 +1625,7 @@ void SocialWindow::showPartyInvite(const std::string &restrict partyName, { // TRANSLATORS: chat message localChatTab->chatLog(_("Received party request, but one already " - "exists."), BY_SERVER); + "exists."), ChatMsgType::BY_SERVER); } return; } @@ -1662,7 +1662,7 @@ void SocialWindow::showPartyInvite(const std::string &restrict partyName, } if (localChatTab) - localChatTab->chatLog(msg, BY_SERVER); + localChatTab->chatLog(msg, ChatMsgType::BY_SERVER); // show invite // TRANSLATORS: party invite message diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 305106af8..a6300d060 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -389,7 +389,7 @@ void TradeWindow::action(const ActionEvent &event) { // TRANSLATORS: trade error localChatTab->chatLog(_("You don't have enough money."), - BY_SERVER); + ChatMsgType::BY_SERVER); } v = curMoney; } @@ -475,7 +475,8 @@ bool TradeWindow::checkItem(const Item *const item) const { // TRANSLATORS: trade error localChatTab->chatLog(_("Failed adding item. You can not " - "overlap one kind of item on the window."), BY_SERVER); + "overlap one kind of item on the window."), + ChatMsgType::BY_SERVER); } return false; } diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index 28ec4497e..47074d99c 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -68,7 +68,7 @@ void BuySellHandler::requestSellList(const std::string &nick) const else { if (chatWindow) - chatWindow->addWhisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); } } @@ -87,7 +87,7 @@ void BuySellHandler::requestBuyList(const std::string &nick) const else { if (chatWindow) - chatWindow->addWhisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); } } @@ -106,7 +106,7 @@ void BuySellHandler::sendBuyRequest(const std::string &nick, if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else - chatWindow->addWhisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); } void BuySellHandler::sendSellRequest(const std::string &nick, @@ -125,7 +125,7 @@ void BuySellHandler::sendSellRequest(const std::string &nick, if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else - chatWindow->addWhisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, ChatMsgType::BY_PLAYER); } void BuySellHandler::processNpcBuySellChoice(Net::MessageIn &msg) diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index cc43de8cd..c880de0f6 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -107,7 +107,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg) chatWindow->addWhisper(nick, // TRANSLATORS: chat message strprintf(_("Whisper could not be " - "sent, %s is offline."), nick.c_str()), BY_SERVER); + "sent, %s is offline."), nick.c_str()), ChatMsgType::BY_SERVER); } break; case 0x02: @@ -117,7 +117,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg) // TRANSLATORS: chat message strprintf(_("Whisper could not " "be sent, ignored by %s."), nick.c_str()), - BY_SERVER); + ChatMsgType::BY_SERVER); } break; default: @@ -256,7 +256,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) const } else { - localChatTab->chatLog(chatMsg, BY_SERVER); + localChatTab->chatLog(chatMsg, ChatMsgType::BY_SERVER); } } BLOCK_END("ChatHandler::processWhisper") @@ -329,7 +329,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg, PlayerRelation::SPEECH_LOG) && chatWindow) { allow = chatWindow->resortChatLog(removeColors(sender_name) - .append(" : ").append(chatMsg), BY_OTHER, channel, false, true); + .append(" : ").append(chatMsg), ChatMsgType::BY_OTHER, channel, false, true); } if (allow && player_relations.hasPermission(sender_name, @@ -367,7 +367,7 @@ void ChatHandler::processChat(Net::MessageIn &msg, const bool normalChat, bool allow(true); if (chatWindow) { - allow = chatWindow->resortChatLog(chatMsg, BY_PLAYER, + allow = chatWindow->resortChatLog(chatMsg, ChatMsgType::BY_PLAYER, channel, false, true); } diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index af8c3b8df..fbd3f0add 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -66,7 +66,7 @@ bool GuildTab::handleCommand(const std::string &restrict type, else if (type == "create" || type == "new") { if (args.empty()) - chatLog(_("Guild name is missing."), BY_SERVER); + chatLog(_("Guild name is missing."), ChatMsgType::BY_SERVER); else Net::getGuildHandler()->create(args); } diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index 79a9a8897..0395b3a94 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -75,7 +75,7 @@ bool PartyTab::handleCommand(const std::string &restrict type, if (args.empty()) { // TRANSLATORS: chat error message - chatLog(_("Party name is missing."), BY_SERVER); + chatLog(_("Party name is missing."), ChatMsgType::BY_SERVER); } else { @@ -102,19 +102,23 @@ bool PartyTab::handleCommand(const std::string &restrict type, { case PARTY_SHARE: // TRANSLATORS: chat message - chatLog(_("Item sharing enabled."), BY_SERVER); + chatLog(_("Item sharing enabled."), + ChatMsgType::BY_SERVER); return true; case PARTY_SHARE_NO: // TRANSLATORS: chat message - chatLog(_("Item sharing disabled."), BY_SERVER); + chatLog(_("Item sharing disabled."), + ChatMsgType::BY_SERVER); return true; case PARTY_SHARE_NOT_POSSIBLE: // TRANSLATORS: chat message - chatLog(_("Item sharing not possible."), BY_SERVER); + chatLog(_("Item sharing not possible."), + ChatMsgType::BY_SERVER); return true; case PARTY_SHARE_UNKNOWN: // TRANSLATORS: chat message - chatLog(_("Item sharing unknown."), BY_SERVER); + chatLog(_("Item sharing unknown."), + ChatMsgType::BY_SERVER); return true; default: break; @@ -146,19 +150,23 @@ bool PartyTab::handleCommand(const std::string &restrict type, { case PARTY_SHARE: // TRANSLATORS: chat message - chatLog(_("Experience sharing enabled."), BY_SERVER); + chatLog(_("Experience sharing enabled."), + ChatMsgType::BY_SERVER); return true; case PARTY_SHARE_NO: // TRANSLATORS: chat message - chatLog(_("Experience sharing disabled."), BY_SERVER); + chatLog(_("Experience sharing disabled."), + ChatMsgType::BY_SERVER); return true; case PARTY_SHARE_NOT_POSSIBLE: // TRANSLATORS: chat message - chatLog(_("Experience sharing not possible."), BY_SERVER); + chatLog(_("Experience sharing not possible."), + ChatMsgType::BY_SERVER); return true; case PARTY_SHARE_UNKNOWN: // TRANSLATORS: chat message - chatLog(_("Experience sharing unknown."), BY_SERVER); + chatLog(_("Experience sharing unknown."), + ChatMsgType::BY_SERVER); return true; default: break; diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 18877c686..efa94dce1 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -183,29 +183,31 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg) showBasicInfo = false; // TRANSLATORS: guild info message guildTab->chatLog(strprintf(_("Guild name: %s"), - name.c_str()), BY_SERVER); + name.c_str()), ChatMsgType::BY_SERVER); // TRANSLATORS: guild info message guildTab->chatLog(strprintf(_("Guild master: %s"), - master.c_str()), BY_SERVER); + master.c_str()), ChatMsgType::BY_SERVER); // TRANSLATORS: guild info message - guildTab->chatLog(strprintf(_("Guild level: %d"), level), BY_SERVER); + guildTab->chatLog(strprintf(_("Guild level: %d"), level), + ChatMsgType::BY_SERVER); // TRANSLATORS: guild info message guildTab->chatLog(strprintf(_("Online members: %d"), - members), BY_SERVER); + members), ChatMsgType::BY_SERVER); // TRANSLATORS: guild info message guildTab->chatLog(strprintf(_("Max members: %d"), - maxMembers), BY_SERVER); + maxMembers), ChatMsgType::BY_SERVER); // TRANSLATORS: guild info message guildTab->chatLog(strprintf(_("Average level: %d"), - avgLevel), BY_SERVER); + avgLevel), ChatMsgType::BY_SERVER); // TRANSLATORS: guild info message - guildTab->chatLog(strprintf(_("Guild exp: %d"), exp), BY_SERVER); + guildTab->chatLog(strprintf(_("Guild exp: %d"), exp), + ChatMsgType::BY_SERVER); // TRANSLATORS: guild info message guildTab->chatLog(strprintf(_("Guild next exp: %d"), - nextExp), BY_SERVER); + nextExp), ChatMsgType::BY_SERVER); // TRANSLATORS: guild info message guildTab->chatLog(strprintf(_("Guild castle: %s"), - castle.c_str()), BY_SERVER); + castle.c_str()), ChatMsgType::BY_SERVER); } Guild *const g = Guild::getGuild(static_cast<int16_t>(guildId)); @@ -400,8 +402,8 @@ void GuildHandler::processGuildNotice(Net::MessageIn &msg) const const std::string msg2 = msg.readString(120); // Mes2 if (guildTab) { - guildTab->chatLog(msg1, BY_SERVER); - guildTab->chatLog(msg2, BY_SERVER); + guildTab->chatLog(msg1, ChatMsgType::BY_SERVER); + guildTab->chatLog(msg2, ChatMsgType::BY_SERVER); } } diff --git a/src/notifymanager.cpp b/src/notifymanager.cpp index 07a9e9a8f..a5962006c 100644 --- a/src/notifymanager.cpp +++ b/src/notifymanager.cpp @@ -52,9 +52,9 @@ namespace NotifyManager static void chatLog(ChatTab *const tab, const std::string &str) { if (tab) - tab->chatLog(str, BY_SERVER); + tab->chatLog(str, ChatMsgType::BY_SERVER); else if (debugChatTab) - debugChatTab->chatLog(str, BY_SERVER); + debugChatTab->chatLog(str, ChatMsgType::BY_SERVER); } void notify(const unsigned int message) @@ -66,7 +66,7 @@ namespace NotifyManager { case EMPTY: localChatTab->chatLog(gettext(info.text), - BY_SERVER); + ChatMsgType::BY_SERVER); break; case GUILD: @@ -110,7 +110,7 @@ namespace NotifyManager if (info.flags == INT) { localChatTab->chatLog(strprintf(gettext(info.text), - num), BY_SERVER); + num), ChatMsgType::BY_SERVER); } soundManager.playSfx(SoundDB::getSound(message)); } @@ -125,7 +125,7 @@ namespace NotifyManager case STRING: { localChatTab->chatLog(strprintf(gettext(info.text), - str.c_str()), BY_SERVER); + str.c_str()), ChatMsgType::BY_SERVER); break; } case GUILD_STRING: diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index fd9f60851..3128e82c8 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -65,7 +65,7 @@ void StatusEffect::playSFX() const void StatusEffect::deliverMessage() const { if (!mMessage.empty() && localChatTab) - localChatTab->chatLog(mMessage, BY_SERVER); + localChatTab->chatLog(mMessage, ChatMsgType::BY_SERVER); } Particle *StatusEffect::getParticle() const |