46 #include "gui/viewport.h"
122 mChatColor(
config.getIntValue(
"chatColor")),
123 mEmoteButtonSpacing(mSkin !=
nullptr ?
124 mSkin->getOption(
"emoteButtonSpacing", 2) : 2),
125 mEmoteButtonY(mSkin !=
nullptr ?
126 mSkin->getOption(
"emoteButtonY", -2) : -2),
127 mChatHistoryIndex(0),
128 mReturnToggles(
config.getBoolValue(
"ReturnToggles")),
131 mAutoHide(
config.getBoolValue(
"autohideChat")),
132 mShowBattleEvents(
config.getBoolValue(
"showBattleEvents")),
134 mEnableTradeFilter(
config.getBoolValue(
"enableTradeFilter")),
200 "showChatColorsList"),
Visible));
251 const std::string str = *it;
285 const int aw = area.
width;
286 const int ah = area.
height;
290 int maxHeight = inputHeight;
294 if (buttonHeight > maxHeight)
295 maxHeight = buttonHeight;
297 const int frame2 = 2 * frame;
298 const int awFrame2 = aw - frame2;
299 int y = ah - maxHeight - frame;
302 const int height = ah - frame2 - (maxHeight + frame2);
317 int w = awFrame2 - chatButtonSize;
318 const int x = aw - frame - chatButtonSize;
335 if (content !=
nullptr)
407 for (
int f = 0; f < sz; f ++)
411 if ((tab !=
nullptr) && tab->
getType() == type)
441 const std::string &eventId =
event.getId();
442 if (eventId ==
"chatinput")
446 if (!message.empty())
475 else if (eventId ==
"emote")
487 else if (eventId ==
"openemote")
497 else if (eventId ==
"color")
509 else if (eventId ==
"font")
521 else if (eventId ==
"text")
547 "showChatColorsList"),
Visible);
600 std::string tempNick = nick;
607 std::string tempName = name;
615 std::list<ChatTab*> tabs;
618 tabs.push_back(iter->second);
620 for (std::list<ChatTab*>::iterator it = tabs.begin();
621 it != tabs.end(); ++it)
631 std::list<ChatTab*> tabs;
634 tabs.push_back(iter->second);
636 for (std::list<ChatTab*>::iterator it = tabs.begin();
637 it != tabs.end(); ++it)
647 for (TabMap::iterator iter =
mWhispers.begin();
668 std::string
msg = message;
673 && ((
msg.at(0) ==
'#' &&
msg.at(1) !=
'#') ||
msg.at(0) ==
'@')
705 std::string response;
712 if (!response.empty())
713 response.append(
", ");
724 _(
"Present: %s; %d players are present."),
725 response.c_str(), playercount);
761 std::string(), cTab);
780 const int clicks =
event.getClickCount();
787 else if (clicks == 1)
816 #define ifKey(key, str) \
817 else if (actionId == (key)) \
897 if ((tab !=
nullptr) && tab->
hasRows())
912 const std::list<std::string> &rows = tab->
getRows();
913 for (std::list<std::string>::const_iterator it = rows.begin(),
914 it_end = rows.end(); it != it_end; ++ it, f ++)
927 if ((tab !=
nullptr) && tab->
hasRows())
929 const std::list<std::string> &rows = tab->
getRows();
930 const size_t &tabSize = rows.size();
948 for (std::list<std::string>::const_iterator
949 it = rows.begin(), it_end = rows.end();
950 it != it_end; ++it, f++)
987 const size_t idx = inputText.rfind(
"##b");
988 if (idx == std::string::npos
1021 const int64_t oldVal,
1022 const int64_t newVal)
1027 PRAGMA45(GCC diagnostic ignored
"-Wswitch-enum")
1032 if (oldVal > newVal)
1034 const int64_t change = newVal - oldVal;
1057 if (oldVal > newVal ||
1063 const int64_t change = newVal - oldVal;
1067 change))).append(
" job"),
1086 std::ostringstream ss;
1087 ss << inputText.substr(0, caretPos) << text;
1091 ss << inputText.substr(caretPos);
1100 std::ostringstream text;
1101 text <<
"[" << item <<
"]";
1125 std::string tempNick = nick;
1130 if (tempNick == playerName)
1134 const TabMap::const_iterator i =
mWhispers.find(tempNick);
1164 std::string
msg = mes;
1165 const size_t idx = mes.find(
':');
1166 if (idx != std::string::npos && idx > 0)
1168 std::string nick2 =
msg.substr(0, idx);
1169 msg =
msg.substr(idx + 1);
1171 nick2 =
trim(nick2);
1202 nick.c_str(), mes.c_str()),
1221 const std::string &nick,
1222 const bool switchTo)
1228 std::string tempNick = nick;
1233 const TabMap::const_iterator i =
mWhispers.find(tempNick);
1236 if (tempNick == playerName)
1265 std::string tempNick = nick;
1270 const TabMap::const_iterator i =
mWhispers.find(tempNick);
1273 if (tempNick == playerName)
1283 const bool switchTo)
1312 const bool switchTo)
1314 std::string tempName = name;
1321 const ChannelMap::const_iterator i =
mChannels.find(tempName);
1344 const bool switchTo,
1352 if ((tab !=
nullptr) && join)
1363 ChatTab *
const tab = iter->second;
1372 #define changeColor(fun) \
1374 msg = removeColors(msg); \
1376 const size_t sz = msg.length(); \
1377 for (size_t f = 0; f < sz; f ++) \
1381 newMsg += msg.at(f); \
1385 const unsigned char ch = CAST_U8(msg.at(f)); \
1386 if (f + 2 < sz && msg.substr(f, 2) == "%%") \
1388 newMsg += msg.at(f); \
1391 else if (ch > 0xc0 || ch < 0x80) \
1393 newMsg += "##" + toString(fun) + msg.at(f); \
1394 if (mRainbowColor > 9U) \
1395 mRainbowColor = 0U; \
1399 newMsg += msg.at(f); \
1408 ||
msg.at(0) ==
'/' ||
msg.at(0) ==
'@' ||
msg.at(0) ==
'!')
1414 const int cMap[] = {1, 4, 5, 2, 3, 6, 7, 9, 0, 8};
1443 std::string name = inputText.substr(0, caretPos);
1445 for (
int f = caretPos - 1; f > -1; f --)
1450 name = inputText.substr(f + 1, caretPos - f);
1455 if (caretPos - 1 + 1 == startName)
1462 if (cTab !=
nullptr)
1465 if (!newName.empty() && (startName == 0))
1468 if ((cTab !=
nullptr) && newName.empty())
1478 if (!newName.empty() && (startName == 0))
1481 if (newName.empty())
1485 if (newName.empty())
1492 if (newName.empty())
1494 if (newName.empty())
1500 if (!newName.empty())
1503 .append(inputText.substr(caretPos,
1504 inputText.length() - caretPos)));
1506 const int len = caretPos -
CAST_S32(name.length())
1517 std::string partName)
1522 std::string newName;
1528 std::string name = *i;
1531 const size_t pos = name.find(partName, 0);
1534 if (!newName.empty())
1549 if (words ==
nullptr)
1552 ChatCommands::const_iterator i = words->begin();
1553 const ChatCommands::const_iterator i_end = words->end();
1558 const std::string line = *i;
1559 if (line.find(partName, 0) == 0)
1560 nameList.push_back(line);
1580 History::const_iterator i =
mHistory.begin();
1581 const History::const_iterator i_end =
mHistory.end();
1586 std::string line = *i;
1591 line = line.substr(0, f);
1593 nameList.push_back(line);
1602 const std::string &channel,
1608 const size_t pos = line.find(
" : ");
1609 if (pos != std::string::npos)
1611 if (line.length() <= pos + 3)
1625 if (!channel.empty())
1627 prefix = std::string(
"##3").append(channel).append(
"##0");
1642 line =
_(
"Your message was moved to trade tab");
1650 size_t idx2 = line.find(
": ");
1651 if (idx2 != std::string::npos)
1653 std::string tmpNick = line.substr(0, idx2);
1654 if (tmpNick.find(
'#') != std::string::npos ||
1655 tmpNick.find(
':') != std::string::npos ||
1656 tmpNick.find(
'%') != std::string::npos ||
1657 tmpNick.find(
'@') != std::string::npos ||
1658 tmpNick.size() < 5 ||
1659 tmpNick[0] ==
'@' ||
1660 tmpNick[0] ==
'/' ||
1667 line =
_(
"Broken nick detected: ") + line;
1670 const size_t idx = line.find(
": \302\202");
1673 if (line.find(
": \302\202\302") != std::string::npos)
1675 if (line.find(
": \302\202\302e") != std::string::npos)
1679 else if (line.find(
": \302\202\302m") != std::string::npos)
1683 else if (line.find(
": \302\202\302d") != std::string::npos)
1687 else if (line.find(
": \302\202\302a") != std::string::npos)
1696 if (line.find(
": \302\202\303 ") != std::string::npos)
1701 if (line.find(
": \302\202\304") != std::string::npos)
1708 line = line.erase(idx + 2, 2);
1716 line = line.erase(idx + 2, 2);
1726 if (!channel.empty())
1747 channelChatLog(channel, line, own, ignoreRecord, tryRemoveColors);
1778 const std::string &line,
1783 std::string tempChannel = channel;
1787 const ChannelMap::const_iterator i =
mChannels.find(tempChannel);
1801 tab->
chatLog(line, own, ignoreRecord, tryRemoveColors);
1807 +
"/tradefilter.txt";
1809 std::ifstream tradeFile;
1810 struct stat statbuf;
1812 if (stat(tradeListName.c_str(), &statbuf) == 0 &&
1813 S_ISREG(statbuf.st_mode))
1815 tradeFile.open(tradeListName.c_str(), std::ios::in);
1816 if (tradeFile.is_open())
1819 while (tradeFile.getline(line, 100))
1821 const std::string str = line;
1841 if (iter->second ==
nullptr)
1848 if (onlinePlayers.find(tab->
getNick()) != onlinePlayers.end())
1854 const std::string &nick = tab->
getNick();
1859 if (being !=
nullptr)
1865 if (
party !=
nullptr)
1874 if (
guild !=
nullptr)
1877 if ((
gm !=
nullptr) &&
gm->getOnline())
1894 "chatWhisper" +
toString(num),
"");
1903 "chatWhisperFlags" +
toString(num), 1);
1916 for (ChannelMap::const_iterator iter =
mChannels.begin(),
1917 iter_end =
mChannels.end(); iter != iter_end && num < 50; ++iter)
1919 if (iter->second ==
nullptr)
1921 if (!
saveTab(num, iter->second))
1926 for (TabMap::const_iterator iter =
mWhispers.begin(),
1927 iter_end =
mWhispers.end(); iter != iter_end && num < 50; ++iter)
1929 if (iter->second ==
nullptr)
1931 if (!
saveTab(num, iter->second))
1963 std::string str =
msg;
1970 std::ifstream listFile;
1971 struct stat statbuf;
1974 +
"/customwords.txt";
1976 if ((stat(listName.c_str(), &statbuf) == 0) && S_ISREG(statbuf.st_mode))
1978 listFile.open(listName.c_str(), std::ios::in);
1979 if (listFile.is_open())
1982 while (listFile.getline(line, 100))
1984 std::string str = line;
2002 mAwayLog.push_back(
"##aaway:" + line);
2010 std::list<std::string>::const_iterator i =
mAwayLog.begin();
2011 const std::list<std::string>::const_iterator i_end =
mAwayLog.end();
2015 std::string str = *i;
2028 "highlightWords"),
',');
2040 "globalsFilter"),
',');
2057 if (text ==
nullptr)
2066 if (name ==
"autohideChat")
2068 else if (name ==
"showBattleEvents")
2070 else if (name ==
"globalsFilter")
2072 else if (name ==
"enableTradeFilter")
2220 name =
_(
"General");
ActorManager * actorManager
std::set< ActorSprite * > ActorSprites
ActorSprites::iterator ActorSpritesIterator
Attributes ::T AttributesT
BattleTab * battleChatTab
#define fromBool(val, name)
Net::ChatHandler * chatHandler
ChatMsgType ::T ChatMsgTypeT
ChatTabType ::T ChatTabTypeT
static const char *const ACTION_COLOR_PICKER
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
void getMobNames(StringVect &names) const
const ActorSprites & getAll() const A_CONST
void getPlayerNames(StringVect &names, const NpcNames npcNames) const
virtual void add(Widget *const widget)
virtual void logicChildren()
const Guild * getGuild(const std::string &guildName) const
const std::string & getName() const
std::string getTextAtPos(const int x, const int y) const
void setRemoveNames(const bool n)
virtual void getAutoCompleteList(StringVect &names) const
bool getRemoveNames() const
virtual bool handleCommand(const std::string &type, const std::string &args)
ChatTabTypeT getType() const
void setAllowHighlight(const bool n)
virtual void getAutoCompleteCommands(StringVect &names) const
bool getAllowHighlight() const
void addNewRow(std::string &line)
void setNoAway(const bool n)
const std::list< std::string > & getRows() const
void scroll(const int amount)
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
void chatInput(const std::string &msg)
void loadFromLogFile(const std::string &name)
const std::string & getChannelName() const
void addWhisper(const std::string &nick, const std::string &mes, const ChatMsgTypeT own)
WhisperTab * addWhisperTab(const std::string &caption, const std::string &nick, const bool switchTo)
void channelChatLog(const std::string &channel, const std::string &line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
unsigned int mRainbowColor
void scroll(const int amount) const
ChatTab * addChannelTab(const std::string &name, const bool switchTo)
std::list< std::string > History
void chatInput(const std::string &msg) const
void optionChanged(const std::string &name)
void mousePressed(MouseEvent &event)
void parseGlobalsFilter()
unsigned int mChatHistoryIndex
std::string autoCompleteHistory(const std::string &partName) const
void addItemText(const std::string &item)
bool addCurrentToHistory()
bool resortChatLog(std::string line, ChatMsgTypeT own, const std::string &channel, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
void addTab(ChatTab *const tab)
void joinRoom(const bool isJoin)
bool isInputFocused() const
WhisperTab * getWhisperTab(const std::string &nick) const
void removeWhisper(const std::string &nick)
ColorListModel * mColorListModel
static bool saveTab(const int num, const ChatTab *const tab)
void draw(Graphics *const graphics)
void safeDraw(Graphics *const graphics)
void updateOnline(const std::set< std::string > &onlinePlayers) const
void localChatInput(const std::string &msg) const
History::iterator HistoryIterator
void mouseMoved(MouseEvent &event)
StringVect mGlobalsFilter
ItemLinkHandler * mItemLinkHandler
void keyPressed(KeyEvent &event)
void removeTab(ChatTab *const tab)
void displayAwayLog() const
static std::string doReplace(const std::string &msg)
void loadCommandsFile(const std::string &name)
bool isTabPresent(const ChatTab *const tab) const
bool findHighlight(const std::string &str)
ChatWindow(const std::string &name)
void setVisible(Visible visible)
std::list< std::string > mAwayLog
void copyToClipboard(const int x, const int y) const
void addGlobalMessage(const std::string &line)
void debugMessage(const std::string &msg)
void addToAwayLog(const std::string &line)
ChatTab * addSpecialChannelTab(const std::string &name, const bool switchTo)
void widgetResized(const Event &event)
static void battleChatLog(const std::string &line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
void mouseEntered(MouseEvent &event)
void mouseExited(MouseEvent &event)
void action(const ActionEvent &event)
void mouseDragged(MouseEvent &event)
void attributeChanged(const AttributesT id, const int64_t oldVal, const int64_t newVal)
void addInputText(const std::string &text, const bool space)
std::string addColors(std::string &msg)
ChatTab * getFocused() const
void removeChannel(const std::string &nick)
ChatTab * addChatTab(const std::string &name, const bool switchTo, const bool join)
void selectTabByType(const ChatTabTypeT &type)
std::string getValue(const std::string &key, const std::string &deflt) const
void deleteKey(const std::string &key)
bool getBoolValue(const std::string &key) const
std::string getStringValue(const std::string &key) const
void addListener(const std::string &key, ConfigListener *const listener)
void setValue(const std::string &key, const std::string &value)
void removeListeners(ConfigListener *const listener)
int getIntValue(const std::string &key) const
static void removeListener(const DebugMessageListener *const listener)
void setSelected(int selected)
void addListeners(ActionListener *const listener)
std::string getSelectedEmote() const
std::string getSelectedFont() const
std::string getSelectedColor() const
int getSelectedTextIndex() const
static uint8_t getMouseState(int &x, int &y)
Font * getSecureFont() const
void setAllowCommands(const bool b)
const Key & getKey() const
void afkRespond(ChatTab *const tab, const std::string &nick)
MouseButtonT getButton() const
virtual void partChannel(const std::string &channel) const =0
virtual void joinChannel(const std::string &channel) const =0
virtual void privateMessage(const std::string &recipient, const std::string &text) const =0
bool isGoodName(Being *const being) const
RelationT getRelation(const std::string &name) const
void setRelation(const std::string &name, const RelationT relation)
const std::string getStr(const std::string &str)
std::string serverConfigDir
void registerWindowForReset(Window *const window)
std::string autoComplete(const std::string &partName) const
void setCaption(const std::string &caption)
void setLabelFont(Font *const font)
void setFollowDownScroll(const bool n)
void setResizeHeight(bool b)
int getContainerHeight() const
bool isTabPresent(const Tab *const tab) const
void removeTab(Tab *const tab)
void setHeight(int height)
void setSelectedTab(Tab *const tab)
int getNumberOfTabs() const
void setRightMargin(const int n)
int getSelectedTabIndex() const
void addTab(Tab *const tab, Widget *const widget)
void setSelectedTabByIndex(const size_t index)
Tab * getSelectedTab() const
Tab * getTabByIndex(const int index) const
void enableScrollButtons(const bool enable)
void setAllowSpecialActions(const bool b)
const std::string & getText() const
void setText(const std::string &text)
unsigned int getCaretPosition() const
std::string getTextBeforeCaret() const
void setCaretPosition(unsigned int position)
void setWhisperTabOfflineColors()
void setWhisperTabColors()
bool handleCommand(const std::string &type, const std::string &args)
const std::string & getNick() const
void getPlayerNames(StringVect &names)
void safeDraw(Graphics *const graphics)
void setSaveVisible(const bool save)
void setResizable(const bool resize)
virtual void setVisible(Visible visible)
bool isWindowVisible() const
int getTitlePadding() const
void setWindowName(const std::string &name)
bool isResizeAllowed(const MouseEvent &event) const
void mouseExited(MouseEvent &event)
void mouseDragged(MouseEvent &event)
void mouseEntered(MouseEvent &event)
void setMinHeight(const int height)
void mouseMoved(MouseEvent &event)
void setMinWidth(const int width)
void mousePressed(MouseEvent &event)
void enableVisibleSound(bool b)
void widgetResized(const Event &event)
void draw(Graphics *const graphics)
void setShowTitle(bool flag)
virtual void scheduleDelete()
void setStickyButtonLock(const bool sticky)
void setDefaultVisible(const bool save)
void setTitleBarHeight(unsigned int height)
Configuration serverConfig
const std::string TRADE_CHANNEL
const std::string GM_CHANNEL
bool sendBuffer(const std::string &text)
EmoteWindow * emoteWindow
#define FOR_EACH(type, iter, array)
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wredundant-decls") PRAGMA45(GCC diagnostic pop) class TestMain
const bool IgnoreRecord_false
LocalPlayer * localPlayer
bool msg(InputEvent &event)
bool gm(InputEvent &event)
std::string trim(std::string const &str)
std::string toLower(std::string const &s)
std::string toString(T const &value)
converts any type to a string
ServerTypeT getNetworkType()
int32_t getAttribute(const AttributesT id)
std::string getRoomName()
std::string getByIndex(const int index)
bool loadTextFile(const std::string &fileName, StringVect &lines)
#define GLDEBUG_START(text)
#define BLOCK_START(name)
PlayerRelationsManager playerRelations
PoDict * reverseDictionary
SetupWindow * setupWindow
SpellManager * spellManager
std::string removeColors(std::string msg)
std::string & replaceAll(std::string &context, const std::string &from, const std::string &to)
std::string strprintf(const char *const format,...)
void splitToStringVector(StringVect &tokens, const std::string &text, const char separator)
size_t findI(std::string str, std::string subStr)
void secureChatCommand(std::string &str)
void replaceSpecialChars(std::string &text)
const std::string findSameSubstringI(const std::string &s1, const std::string &s2)
bool isWordSeparator(const signed char chr) A_CONST
StringVect::const_iterator StringVectCIter
std::vector< std::string > StringVect
const bool TryRemoveColors_true
WhoIsOnline * whoIsOnline