summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chatlog.h6
-rw-r--r--src/gui/chatmsgtype.h42
-rw-r--r--src/gui/widgets/tabs/chattab.cpp47
-rw-r--r--src/gui/widgets/tabs/chattab.h3
-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
9 files changed, 108 insertions, 72 deletions
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;
}