summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-16 16:15:34 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-16 16:15:34 +0300
commitfe6a120ea38daaad39f6952a886c20269cfedca6 (patch)
tree4595d63a2ab9764873657182fbf2ab2b985474bf /src/gui/windows
parent6279b10249efa59b3161b014899465fe4bb08da4 (diff)
downloadmv-fe6a120ea38daaad39f6952a886c20269cfedca6.tar.gz
mv-fe6a120ea38daaad39f6952a886c20269cfedca6.tar.bz2
mv-fe6a120ea38daaad39f6952a886c20269cfedca6.tar.xz
mv-fe6a120ea38daaad39f6952a886c20269cfedca6.zip
Move chatmsgtype into separate file.
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/chatwindow.cpp33
-rw-r--r--src/gui/windows/chatwindow.h22
-rw-r--r--src/gui/windows/shopwindow.cpp2
-rw-r--r--src/gui/windows/socialwindow.cpp20
-rw-r--r--src/gui/windows/tradewindow.cpp5
5 files changed, 37 insertions, 45 deletions
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;
}