ManaPlus
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Friends

#include <chatwindow.h>

Inheritance diagram for ChatWindow:
Window ActionListener KeyListener ConfigListener AttributeListener DebugMessageListener BasicContainer2 MouseListener WidgetListener BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 ChatWindow (const std::string &name)
 
 ~ChatWindow ()
 
ChatTabgetFocused () const
 
void clearTab () const
 
void prevTab ()
 
void nextTab ()
 
void closeTab () const
 
void defaultTab ()
 
void action (const ActionEvent &event)
 
bool requestChatFocus ()
 
bool isInputFocused () const
 
void chatInput (const std::string &msg) const
 
void localChatInput (const std::string &msg) const
 
void keyPressed (KeyEvent &event)
 
void setInputText (const std::string &text)
 
void addInputText (const std::string &text, const bool space)
 
void addItemText (const std::string &item)
 
void setVisible (Visible visible)
 
void mouseDragged (MouseEvent &event)
 
void mousePressed (MouseEvent &event)
 
void scroll (const int amount) const
 
void setRecordingFile (const std::string &msg)
 
bool getReturnTogglesChat () const
 
void setReturnTogglesChat (const bool toggles)
 
void doPresent () const
 
void addWhisper (const std::string &nick, const std::string &mes, const ChatMsgTypeT own)
 
WhisperTabaddWhisperTab (const std::string &caption, const std::string &nick, const bool switchTo)
 
WhisperTabgetWhisperTab (const std::string &nick) const
 
ChatTabaddChannelTab (const std::string &name, const bool switchTo)
 
ChatTabaddSpecialChannelTab (const std::string &name, const bool switchTo)
 
ChatTabaddChatTab (const std::string &name, const bool switchTo, const bool join)
 
void joinRoom (const bool isJoin)
 
void removeAllWhispers ()
 
void removeAllChannels ()
 
void ignoreAllWhispers ()
 
bool resortChatLog (std::string line, ChatMsgTypeT own, const std::string &channel, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
 
void channelChatLog (const std::string &channel, const std::string &line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
 
void updateOnline (const std::set< std::string > &onlinePlayers) const
 
void loadState ()
 
void saveState () const
 
void loadCustomList ()
 
void loadGMCommands ()
 
void adjustTabSize ()
 
void addToAwayLog (const std::string &line)
 
void displayAwayLog () const
 
void clearAwayLog ()
 
void parseHighlights ()
 
void parseGlobalsFilter ()
 
bool findHighlight (const std::string &str)
 
void copyToClipboard (const int x, const int y) const
 
void optionChanged (const std::string &name)
 
void mouseEntered (MouseEvent &event)
 
void mouseMoved (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void updateVisibility ()
 
void unHideWindow ()
 
void widgetResized (const Event &event)
 
void addGlobalMessage (const std::string &line)
 
void postInit ()
 
bool isTabPresent (const ChatTab *const tab) const
 
void selectTabByType (const ChatTabTypeT &type)
 
void attributeChanged (const AttributesT id, const int64_t oldVal, const int64_t newVal)
 
void postConnection ()
 
void showGMTab ()
 
void debugMessage (const std::string &msg)
 
void scheduleDelete ()
 
- Public Member Functions inherited from Window
 Window (const std::string &caption, const Modal modal, Window *const parent, std::string skin)
 
 ~Window ()
 
void setContentSize (int width, int height)
 
void setLocationRelativeTo (const Widget *const widget)
 
void setLocationHorisontallyRelativeTo (const Widget *const widget)
 
void setLocationRelativeTo (const ImagePosition::Type &position, int offsetX, int offsetY)
 
void setResizable (const bool resize)
 
void redraw ()
 
void widgetMoved (const Event &event)
 
void widgetHidden (const Event &event)
 
void setCloseButton (const bool flag)
 
bool getCloseButton () const
 
void setAllowClose (const bool b)
 
bool getAlowClose () const
 
bool isResizable () const
 
void setMinWidth (const int width)
 
int getMinWidth () const
 
void setMinHeight (const int height)
 
int getMinHeight () const
 
void setMaxWidth (const int width)
 
int getMaxWidth () const
 
void setMaxHeight (const int height)
 
int getMaxHeight () const
 
void setShowTitle (bool flag)
 
void setStickyButton (const bool flag)
 
void setSticky (const bool sticky)
 
bool isSticky () const
 
void setStickyButtonLock (const bool sticky)
 
bool isStickyButtonLock () const
 
void setVisible (const Visible visible, const bool forceSticky)
 
bool isDefaultVisible () const
 
void setDefaultVisible (const bool save)
 
bool willSaveVisible () const
 
void setSaveVisible (const bool save)
 
WindowgetParentWindow () const
 
void mouseReleased (MouseEvent &event)
 
void updateResizeHandler (MouseEvent &event)
 
void setWindowName (const std::string &name)
 
const std::string & getWindowName () const
 
void loadWindowState ()
 
void saveWindowState ()
 
void setDefaultSize (const int defaultX, const int defaultY, int defaultWidth, int defaultHeight)
 
void setDefaultSize ()
 
void setDefaultSize (const int defaultWidth, const int defaultHeight, const ImagePosition::Type &position, const int offsetx, const int offsetY)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w, int h)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w, const int h)
 
ContainerPlacer getPlacer (const int x, const int y)
 
void center ()
 
void centerHorisontally ()
 
virtual void close ()
 
void setModal (const Modal modal)
 
Rect getWindowArea () const
 
bool isResizeAllowed (const MouseEvent &event) const
 
void setCaptionFont (Font *font)
 
void enableVisibleSound (bool b)
 
bool isWindowVisible () const
 
void setPadding (int padding)
 
int getPadding () const
 
void setTitleBarHeight (unsigned int height)
 
unsigned int getTitleBarHeight () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void setAlignment (Graphics::Alignment alignment)
 
Graphics::Alignment getAlignment () const
 
void setMovable (Move movable)
 
bool isMovable () const
 
Rect getChildrenArea ()
 
virtual void resizeToContent ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
 ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget * > &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetShown (const Event &event)
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 
- Public Member Functions inherited from KeyListener
virtual ~KeyListener ()
 
virtual void keyReleased (KeyEvent &event)
 
- Public Member Functions inherited from ConfigListener
 ConfigListener ()
 
virtual ~ConfigListener ()
 
- Public Member Functions inherited from AttributeListener
 AttributeListener ()
 
virtual ~ AttributeListener ()
 
- Public Member Functions inherited from DebugMessageListener
 DebugMessageListener ()
 
virtual ~ DebugMessageListener ()
 

Static Public Member Functions

static void clearTab (ChatTab *const tab)
 
static void battleChatLog (const std::string &line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
 
static bool saveTab (const int num, const ChatTab *const tab)
 
static std::string doReplace (const std::string &msg)
 
- Static Public Member Functions inherited from Window
static void setWindowContainer (WindowContainer *const windowContainer)
 
- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Static Public Member Functions inherited from AttributeListener
static void distributeEvent (const AttributesT id, const int64_t oldVal, const int64_t newVal)
 
static void addListener (AttributeListener *const listener)
 
static void removeListener (const AttributeListener *const listener)
 
- Static Public Member Functions inherited from DebugMessageListener
static void distributeEvent (const std::string &msg)
 
static void addListener (DebugMessageListener *const listener)
 
static void removeListener (const DebugMessageListener *const listener)
 

Protected Types

typedef std::list< std::string > History
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 

Protected Member Functions

void removeTab (ChatTab *const tab)
 
void addTab (ChatTab *const tab)
 
void removeWhisper (const std::string &nick)
 
void removeChannel (const std::string &nick)
 
void autoComplete ()
 
std::string addColors (std::string &msg)
 
std::string autoCompleteHistory (const std::string &partName) const
 
void initTradeFilter ()
 
void toggleChatFocus ()
 
- Protected Member Functions inherited from Window
bool canMove () const
 
int getOption (const std::string &name, const int def) const
 
bool getOptionBool (const std::string &name, const bool def) const
 
void setTitlePadding (const int p)
 
int getTitlePadding () const
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Member Functions inherited from KeyListener
 KeyListener ()
 

Static Protected Member Functions

static std::string autoComplete (const std::string &partName, const History *const words)
 
static std::string autoComplete (const StringVect &names, std::string partName)
 

Protected Attributes

ItemLinkHandlermItemLinkHandler
 
TabbedAreamChatTabs
 
ChatInputmChatInput
 
unsigned int mRainbowColor
 
- Protected Attributes inherited from Window
std::string mCaption
 
Graphics::Alignment mAlignment
 
int mPadding
 
unsigned int mTitleBarHeight
 
Move mMovable
 
int mDragOffsetX
 
int mDragOffsetY
 
bool mMoved
 
SkinmSkin
 
int mDefaultX
 
int mDefaultY
 
int mDefaultWidth
 
int mDefaultHeight
 
int mCaptionOffsetX
 
int mCaptionOffsetY
 
bool mShowTitle
 
bool mLastRedraw
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 

Private Types

typedef std::map< const std::string, WhisperTab * > TabMap
 
typedef std::map< const std::string, ChannelTab * > ChannelMap
 
typedef History::iterator HistoryIterator
 
typedef std::list< std::string > ChatCommands
 
typedef ChatCommands::iterator ChatCommandsIterator
 

Private Member Functions

void fillCommands ()
 
void loadCommandsFile (const std::string &name)
 
void updateTabsMargin ()
 
bool addCurrentToHistory ()
 

Private Attributes

TabMap mWhispers
 
ChannelMap mChannels
 
History mHistory
 
HistoryIterator mCurHist
 
History mCommands
 
History mCustomWords
 
StringVect mTradeFilter
 
ColorListModelmColorListModel
 
DropDownmColorPicker
 
ButtonmChatButton
 
std::list< std::string > mAwayLog
 
StringVect mHighlights
 
StringVect mGlobalsFilter
 
int mChatColor
 
int mEmoteButtonSpacing
 
int mEmoteButtonY
 
unsigned int mChatHistoryIndex
 
bool mReturnToggles
 
bool mGMLoaded
 
bool mHaveMouse
 
bool mAutoHide
 
bool mShowBattleEvents
 
bool mShowAllLang
 
bool mEnableTradeFilter
 
bool mTmpVisible
 

Friends

class ChannelTab
 
class ChatTab
 
class WhisperTab
 
class PopupMenu
 

Additional Inherited Members

- Data Fields inherited from Widget
Visible mVisible
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

The chat window.

Definition at line 55 of file chatwindow.h.

Member Typedef Documentation

◆ ChannelMap

typedef std::map<const std::string, ChannelTab*> ChatWindow::ChannelMap
private

Definition at line 365 of file chatwindow.h.

◆ ChatCommands

typedef std::list<std::string> ChatWindow::ChatCommands
private

Definition at line 375 of file chatwindow.h.

◆ ChatCommandsIterator

typedef ChatCommands::iterator ChatWindow::ChatCommandsIterator
private

Definition at line 376 of file chatwindow.h.

◆ History

typedef std::list<std::string> ChatWindow::History
protected

Definition at line 316 of file chatwindow.h.

◆ HistoryIterator

typedef History::iterator ChatWindow::HistoryIterator
private

Definition at line 371 of file chatwindow.h.

◆ TabMap

typedef std::map<const std::string, WhisperTab*> ChatWindow::TabMap
private

Definition at line 364 of file chatwindow.h.

Constructor & Destructor Documentation

◆ ChatWindow()

ChatWindow::ChatWindow ( const std::string &  name)
explicit

Constructor.

Definition at line 98 of file chatwindow.cpp.

98  :
99  // TRANSLATORS: chat window name
100  Window(_("Chat"), Modal_false, nullptr, "chat.xml"),
101  ActionListener(),
102  KeyListener(),
106  mChatInput(new ChatInput(this)),
107  mRainbowColor(0U),
108  mWhispers(),
109  mChannels(),
110  mHistory(),
111  mCurHist(),
112  mCommands(),
113  mCustomWords(),
114  mTradeFilter(),
117  false, Modal_false, nullptr, std::string())),
118  mChatButton(new Button(this, ":)", "openemote", BUTTON_SKIN, this)),
119  mAwayLog(),
120  mHighlights(),
121  mGlobalsFilter(),
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),
128  mReturnToggles(config.getBoolValue("ReturnToggles")),
129  mGMLoaded(false),
130  mHaveMouse(false),
131  mAutoHide(config.getBoolValue("autohideChat")),
132  mShowBattleEvents(config.getBoolValue("showBattleEvents")),
133  mShowAllLang(serverConfig.getValue("showAllLang", 0) != 0),
134  mEnableTradeFilter(config.getBoolValue("enableTradeFilter")),
135  mTmpVisible(false)
136 {
137  setWindowName(name);
138 
139  if (setupWindow != nullptr)
141 
142  setShowTitle(false);
143  setResizable(true);
144  setDefaultVisible(true);
145  setSaveVisible(true);
146  setStickyButtonLock(true);
147 
148  int w = 600;
149 #ifdef ANDROID
150  if (mainGraphics->getWidth() < 710)
151  w = mainGraphics->getWidth() - 110;
152  if (w < 100)
153  w = 100;
154  if (mainGraphics->getHeight() < 480)
155  setDefaultSize(w, 90, ImagePosition::UPPER_LEFT, -110, -35);
156  else
157  setDefaultSize(w, 123, ImagePosition::UPPER_LEFT, -110, -35);
158 #else // ANDROID
159 
160  if (mainGraphics->getWidth() < 600)
161  w = mainGraphics->getWidth() - 10;
162  if (w < 100)
163  w = 100;
165 #endif // ANDROID
166 
167  setMinWidth(150);
168  setMinHeight(90);
169 
171 
172  if (emoteWindow != nullptr)
173  emoteWindow->addListeners(this);
174 
176 
179  mChatTabs->setResizeHeight(false);
180 
181  mChatInput->setActionEventId("chatinput");
184 
188 
190 
191  loadWindowState();
192 
194  - 2 * mPadding - 8 - 16, mPadding);
195 
196  // Add key listener to chat input to be able to respond to up/down
197  mChatInput->addKeyListener(this);
198  mCurHist = mHistory.end();
200  "showChatColorsList"), Visible));
202 
203  fillCommands();
204  if ((localPlayer != nullptr) && localPlayer->isGM())
205  loadGMCommands();
206  initTradeFilter();
207  loadCustomList();
208  parseHighlights();
210 
211  config.addListener("autohideChat", this);
212  config.addListener("showBattleEvents", this);
213  config.addListener("globalsFilter", this);
214  config.addListener("enableTradeFilter", this);
215 
216  enableVisibleSound(true);
217 }
#define fromBool(val, name)
Definition: booldefines.h:49
const std::string BUTTON_SKIN
Definition: button.h:89
static const char *const ACTION_COLOR_PICKER
Definition: chatwindow.cpp:96
bool isGM() const
Definition: being.h:659
Definition: button.h:102
void adjustSize()
Definition: button.cpp:799
bool mReturnToggles
Definition: chatwindow.h:392
StringVect mTradeFilter
Definition: chatwindow.h:380
unsigned int mRainbowColor
Definition: chatwindow.h:353
bool mEnableTradeFilter
Definition: chatwindow.h:399
void parseGlobalsFilter()
unsigned int mChatHistoryIndex
Definition: chatwindow.h:391
void initTradeFilter()
void fillCommands()
Definition: chatwindow.cpp:258
ChatInput * mChatInput
Definition: chatwindow.h:347
ChannelMap mChannels
Definition: chatwindow.h:369
TabbedArea * mChatTabs
Definition: chatwindow.h:344
StringVect mHighlights
Definition: chatwindow.h:386
bool mShowAllLang
Definition: chatwindow.h:398
ColorListModel * mColorListModel
Definition: chatwindow.h:382
bool mTmpVisible
Definition: chatwindow.h:400
bool mHaveMouse
Definition: chatwindow.h:395
void loadCustomList()
Button * mChatButton
Definition: chatwindow.h:384
void parseHighlights()
StringVect mGlobalsFilter
Definition: chatwindow.h:387
DropDown * mColorPicker
Definition: chatwindow.h:383
HistoryIterator mCurHist
Definition: chatwindow.h:373
TabMap mWhispers
Definition: chatwindow.h:368
ItemLinkHandler * mItemLinkHandler
Definition: chatwindow.h:341
int mChatColor
Definition: chatwindow.h:388
bool mShowBattleEvents
Definition: chatwindow.h:397
bool mGMLoaded
Definition: chatwindow.h:394
void updateTabsMargin()
Definition: chatwindow.cpp:273
bool mAutoHide
Definition: chatwindow.h:396
std::list< std::string > mAwayLog
Definition: chatwindow.h:385
History mCommands
Definition: chatwindow.h:377
void loadGMCommands()
Definition: chatwindow.cpp:264
int mEmoteButtonSpacing
Definition: chatwindow.h:389
History mCustomWords
Definition: chatwindow.h:378
int mEmoteButtonY
Definition: chatwindow.h:390
History mHistory
Definition: chatwindow.h:372
std::string getValue(const std::string &key, const std::string &deflt) const
bool getBoolValue(const std::string &key) const
void addListener(const std::string &key, ConfigListener *const listener)
int getIntValue(const std::string &key) const
void setSelected(int selected)
Definition: dropdown.cpp:514
void addListeners(ActionListener *const listener)
int getHeight() const
Definition: graphics.cpp:648
int getWidth() const
Definition: graphics.cpp:643
void setAllowCommands(const bool b)
void registerWindowForReset(Window *const window)
int getOption(const std::string &name) const
Definition: skin.h:106
void setFollowDownScroll(const bool n)
Definition: tabbedarea.h:211
void setResizeHeight(bool b)
Definition: tabbedarea.h:232
void enableScrollButtons(const bool enable)
Definition: tabbedarea.cpp:150
void setAllowSpecialActions(const bool b)
Definition: textfield.h:204
void setVisible(Visible visible)
Definition: widget.cpp:225
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:272
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
void setPosition(const int x, const int y)
Definition: widget.cpp:161
int getWidth() const
Definition: widget.h:221
void setSaveVisible(const bool save)
Definition: window.h:300
void setResizable(const bool resize)
Definition: window.cpp:627
Skin * mSkin
Definition: window.h:649
int getTitlePadding() const
Definition: window.h:602
void setWindowName(const std::string &name)
Definition: window.h:355
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:109
void setMinHeight(const int height)
Definition: window.cpp:604
void setMinWidth(const int width)
Definition: window.cpp:591
int getPadding() const
Definition: window.h:504
void enableVisibleSound(bool b)
Definition: window.h:481
void setShowTitle(bool flag)
Definition: window.h:235
int mPadding
Definition: window.h:618
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:772
void setDefaultVisible(const bool save)
Definition: window.h:288
void setDefaultSize()
Definition: window.cpp:1198
void loadWindowState()
Definition: window.cpp:1087
void setTitleBarHeight(unsigned int height)
Definition: window.h:513
Configuration config
Configuration serverConfig
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36
EmoteWindow * emoteWindow
Definition: emotewindow.cpp:49
#define _(s)
Definition: gettext.h:35
Graphics * mainGraphics
Definition: graphics.cpp:109
LocalPlayer * localPlayer
const bool Modal_false
Definition: modal.h:30
SetupWindow * setupWindow
Definition: setupwindow.cpp:64
bool Visible
Definition: visible.h:30

References ACTION_COLOR_PICKER, Widget::addActionListener(), Widget::addKeyListener(), Configuration::addListener(), EmoteWindow::addListeners(), Button::adjustSize(), config, emoteWindow, TabbedArea::enableScrollButtons(), Window::enableVisibleSound(), fillCommands(), fromBool, Configuration::getBoolValue(), Graphics::getHeight(), Window::getPadding(), Window::getTitlePadding(), Widget::getWidth(), Graphics::getWidth(), initTradeFilter(), Being::isGM(), loadCustomList(), loadGMCommands(), Window::loadWindowState(), localPlayer, ImagePosition::LOWER_LEFT, mainGraphics, mChatButton, mChatColor, mChatInput, mChatTabs, mColorPicker, mCurHist, mHistory, mItemLinkHandler, Window::mPadding, parseGlobalsFilter(), parseHighlights(), SetupWindow::registerWindowForReset(), Widget::setActionEventId(), ItemLinkHandler::setAllowCommands(), TextField::setAllowSpecialActions(), Window::setDefaultSize(), Window::setDefaultVisible(), TabbedArea::setFollowDownScroll(), Window::setMinHeight(), Window::setMinWidth(), Widget::setPosition(), Window::setResizable(), TabbedArea::setResizeHeight(), Window::setSaveVisible(), DropDown::setSelected(), Window::setShowTitle(), Window::setStickyButtonLock(), Window::setTitleBarHeight(), setupWindow, Widget::setVisible(), Window::setWindowName(), updateTabsMargin(), and ImagePosition::UPPER_LEFT.

◆ ~ChatWindow()

ChatWindow::~ChatWindow ( )

Destructor: used to write back values to the config file

Definition at line 219 of file chatwindow.cpp.

220 {
221  config.removeListeners(this);
223  saveState();
224  config.setValue("ReturnToggles", mReturnToggles);
230 }
void removeAllWhispers()
Definition: chatwindow.cpp:613
void saveState() const
void removeAllChannels()
Definition: chatwindow.cpp:629
void setValue(const std::string &key, const std::string &value)
void removeListeners(ConfigListener *const listener)
#define delete2(var)
Definition: delete2.h:25
#define CHECKLISTENERS
Definition: localconsts.h:277

References CHECKLISTENERS, config, delete2, mColorListModel, mColorPicker, mItemLinkHandler, mReturnToggles, removeAllChannels(), removeAllWhispers(), Configuration::removeListeners(), saveState(), and Configuration::setValue().

Member Function Documentation

◆ action()

void ChatWindow::action ( const ActionEvent event)
virtual

Performs action.

Implements ActionListener.

Definition at line 439 of file chatwindow.cpp.

440 {
441  const std::string &eventId = event.getId();
442  if (eventId == "chatinput")
443  {
444  std::string message = mChatInput->getText();
445 
446  if (!message.empty())
447  {
448  // If message different from previous, put it in the history
449  if (mHistory.empty() || message != mHistory.back())
450  mHistory.push_back(message);
451 
452  // Reset history iterator
453  mCurHist = mHistory.end();
454 
455  // Send the message to the server
456  chatInput(addColors(message));
457 
458  // Clear the text from the chat input
459  mChatInput->setText("");
460  }
461 
462  if (message.empty() || !mReturnToggles)
463  {
464  // Remove focus and hide input
466  if (mFocusHandler != nullptr)
468 
469  // If the chatWindow is shown up because you want to send a message
470  // It should hide now
471  if (mTmpVisible)
473  }
474  }
475  else if (eventId == "emote")
476  {
477  if (emoteWindow != nullptr)
478  {
479  const std::string str = emoteWindow->getSelectedEmote();
480  if (!str.empty())
481  {
482  addInputText(str, false);
484  }
485  }
486  }
487  else if (eventId == "openemote")
488  {
489  if (emoteWindow != nullptr)
490  {
492  emoteWindow->hide();
493  else
494  emoteWindow->show();
495  }
496  }
497  else if (eventId == "color")
498  {
499  if (emoteWindow != nullptr)
500  {
501  const std::string str = emoteWindow->getSelectedColor();
502  if (!str.empty())
503  {
504  addInputText(str, false);
506  }
507  }
508  }
509  else if (eventId == "font")
510  {
511  if (emoteWindow != nullptr)
512  {
513  const std::string str = emoteWindow->getSelectedFont();
514  if (!str.empty())
515  {
516  addInputText(str, false);
518  }
519  }
520  }
521  else if (eventId == "text")
522  {
523  if ((emoteWindow != nullptr) && (reverseDictionary != nullptr))
524  {
525  const int idx = emoteWindow->getSelectedTextIndex();
526  if (idx >= 0)
527  {
528  const std::string str = TextDb::getByIndex(idx);
529  const std::string enStr = reverseDictionary->getStr(str);
530  addInputText(enStr, false);
531  }
533  }
534  }
535  else if (eventId == ACTION_COLOR_PICKER)
536  {
537  if (mColorPicker != nullptr)
538  {
540  config.setValue("chatColor", mChatColor);
541  }
542  }
543 
544  if (mColorPicker != nullptr)
545  {
546  const Visible vis = fromBool(config.getBoolValue(
547  "showChatColorsList"), Visible);
548  if (mColorPicker->mVisible != vis)
549  mColorPicker->setVisible(vis);
550  }
551 }
void unprotectFocus()
Definition: chatinput.h:94
void chatInput(const std::string &msg) const
Definition: chatwindow.cpp:665
void setVisible(Visible visible)
void addInputText(const std::string &text, const bool space)
std::string addColors(std::string &msg)
int getSelected() const
Definition: dropdown.cpp:509
std::string getSelectedEmote() const
void clearFont()
std::string getSelectedFont() const
void clearEmote()
std::string getSelectedColor() const
void clearText()
void clearColor()
int getSelectedTextIndex() const
const std::string getStr(const std::string &str)
Definition: podict.cpp:45
const std::string & getText() const
Definition: textfield.h:224
void setText(const std::string &text)
Definition: textfield.cpp:803
FocusHandler * mFocusHandler
Definition: widget.h:1116
Visible mVisible
Definition: widget.h:963
std::string getByIndex(const int index)
Definition: textdb.cpp:97
PoDict * reverseDictionary
Definition: podict.cpp:30
const bool Visible_false
Definition: visible.h:30
const bool Visible_true
Definition: visible.h:30

References ACTION_COLOR_PICKER, addColors(), addInputText(), chatInput(), EmoteWindow::clearColor(), EmoteWindow::clearEmote(), EmoteWindow::clearFont(), EmoteWindow::clearText(), config, emoteWindow, FocusHandler::focusNone(), fromBool, Configuration::getBoolValue(), TextDb::getByIndex(), DropDown::getSelected(), EmoteWindow::getSelectedColor(), EmoteWindow::getSelectedEmote(), EmoteWindow::getSelectedFont(), EmoteWindow::getSelectedTextIndex(), PoDict::getStr(), TextField::getText(), EmoteWindow::hide(), mChatColor, mChatInput, mColorPicker, mCurHist, Widget::mFocusHandler, mHistory, mReturnToggles, mTmpVisible, Widget::mVisible, reverseDictionary, TextField::setText(), Configuration::setValue(), Widget::setVisible(), setVisible(), EmoteWindow::show(), ChatInput::unprotectFocus(), Visible_false, and Visible_true.

Referenced by keyPressed().

◆ addChannelTab()

ChatTab * ChatWindow::addChannelTab ( const std::string &  name,
const bool  switchTo 
)

Definition at line 1311 of file chatwindow.cpp.

1313 {
1314  std::string tempName = name;
1315  toLower(tempName);
1316 
1317  ChatTab *const tab = addSpecialChannelTab(name, switchTo);
1318  if (tab != nullptr)
1319  return tab;
1320 
1321  const ChannelMap::const_iterator i = mChannels.find(tempName);
1322  ChannelTab *ret = nullptr;
1323 
1324  if (i != mChannels.end())
1325  {
1326  ret = i->second;
1327  }
1328  else
1329  {
1330  ret = new ChannelTab(this, name);
1331  mChannels[tempName] = ret;
1332  ret->setAllowHighlight(false);
1333  if (config.getBoolValue("showChatHistory"))
1334  ret->loadFromLogFile(name);
1335  }
1336 
1337  if (switchTo)
1338  mChatTabs->setSelectedTab(ret);
1339 
1340  return ret;
1341 }
void setAllowHighlight(const bool n)
Definition: chattab.h:161
void loadFromLogFile(const std::string &name)
Definition: chattab.cpp:510
friend class ChannelTab
Definition: chatwindow.h:311
ChatTab * addSpecialChannelTab(const std::string &name, const bool switchTo)
void setSelectedTab(Tab *const tab)
Definition: tabbedarea.cpp:407
std::string toLower(std::string const &s)

References addSpecialChannelTab(), ChannelTab, config, Configuration::getBoolValue(), ChatTab::loadFromLogFile(), mChannels, mChatTabs, ChatTab::setAllowHighlight(), TabbedArea::setSelectedTab(), and Catch::toLower().

Referenced by addChatTab(), channelChatLog(), EAthena::ChatRecv::processColorChat(), and EAthena::ChatRecv::processJoinChannel().

◆ addChatTab()

ChatTab * ChatWindow::addChatTab ( const std::string &  name,
const bool  switchTo,
const bool  join 
)

Definition at line 1343 of file chatwindow.cpp.

1346 {
1348  name.size() > 1 &&
1349  name[0] == '#')
1350  {
1351  ChatTab *const tab = addChannelTab(name, switchTo);
1352  if ((tab != nullptr) && join)
1353  chatHandler->joinChannel(name);
1354  return tab;
1355  }
1356  return addWhisperTab(name, name, switchTo);
1357 }
Net::ChatHandler * chatHandler
Definition: net.cpp:86
WhisperTab * addWhisperTab(const std::string &caption, const std::string &nick, const bool switchTo)
ChatTab * addChannelTab(const std::string &name, const bool switchTo)
virtual void joinChannel(const std::string &channel) const =0
ServerTypeT getNetworkType()
Definition: net.cpp:189

References addChannelTab(), addWhisperTab(), chatHandler, Net::getNetworkType(), Net::ChatHandler::joinChannel(), and ServerType::TMWATHENA.

Referenced by loadState().

◆ addColors()

std::string ChatWindow::addColors ( std::string &  msg)
protected

Definition at line 1404 of file chatwindow.cpp.

1405 {
1406  // default color or chat command
1407  if (mChatColor == 0 || msg.length() == 0 || msg.at(0) == '#'
1408  || msg.at(0) == '/' || msg.at(0) == '@' || msg.at(0) == '!')
1409  {
1410  return msg;
1411  }
1412 
1413  std::string newMsg;
1414  const int cMap[] = {1, 4, 5, 2, 3, 6, 7, 9, 0, 8};
1415 
1416  // rainbow
1417  switch (mChatColor)
1418  {
1419  case 11:
1421  return newMsg;
1422  case 12:
1423  changeColor(cMap[mRainbowColor++])
1424  return newMsg;
1425  case 13:
1426  changeColor(cMap[9-mRainbowColor++])
1427  return newMsg;
1428  default:
1429  break;
1430  }
1431 
1432  // simple colors
1433  return std::string("##").append(toString(mChatColor - 1)).append(msg);
1434 }
#define changeColor(fun)
bool msg(InputEvent &event)
Definition: chat.cpp:39

References changeColor, mChatColor, mRainbowColor, Actions::msg(), and Catch::toString().

Referenced by action().

◆ addCurrentToHistory()

bool ChatWindow::addCurrentToHistory ( )
private

Definition at line 1006 of file chatwindow.cpp.

1007 {
1008  const std::string &str = mChatInput->getText();
1009  if (str.empty())
1010  return false;
1012  {
1013  if (*it == str)
1014  return false;
1015  }
1016  mHistory.push_back(str);
1017  return true;
1018 }
History::iterator HistoryIterator
Definition: chatwindow.h:371
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25

References FOR_EACH, TextField::getText(), mChatInput, and mHistory.

Referenced by keyPressed().

◆ addGlobalMessage()

void ChatWindow::addGlobalMessage ( const std::string &  line)

Definition at line 2154 of file chatwindow.cpp.

2155 {
2156  if (debugChatTab != nullptr &&
2157  findI(line, mGlobalsFilter) != std::string::npos)
2158  {
2159  debugChatTab->chatLog(line,
2163  }
2164  else
2165  {
2166  localChatTab->chatLog(line,
2170  }
2171 }
ChatTab * debugChatTab
Definition: chattab.cpp:63
ChatTab * localChatTab
Definition: chattab.cpp:62
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:111
const bool IgnoreRecord_false
Definition: ignorerecord.h:30
size_t findI(std::string str, std::string subStr)
const bool TryRemoveColors_true

References ChatMsgType::BY_GM, ChatMsgType::BY_OTHER, ChatTab::chatLog(), debugChatTab, findI(), IgnoreRecord_false, localChatTab, mGlobalsFilter, and TryRemoveColors_true.

Referenced by EAthena::ChatRecv::processGmChat(), TmwAthena::ChatRecv::processGmChat(), and EAthena::ChatRecv::processGmChat2().

◆ addInputText()

void ChatWindow::addInputText ( const std::string &  text,
const bool  space 
)

Add the given text to the chat input.

Definition at line 1080 of file chatwindow.cpp.

1082 {
1083  const int caretPos = mChatInput->getCaretPosition();
1084  const std::string &inputText = mChatInput->getText();
1085 
1086  std::ostringstream ss;
1087  ss << inputText.substr(0, caretPos) << text;
1088  if (space)
1089  ss << " ";
1090 
1091  ss << inputText.substr(caretPos);
1092  mChatInput->setText(ss.str());
1093  mChatInput->setCaretPosition(caretPos + CAST_S32(
1094  text.length()) + CAST_S32(space));
1095  requestChatFocus();
1096 }
#define CAST_S32
Definition: cast.h:30
bool requestChatFocus()
Definition: chatwindow.cpp:553
unsigned int getCaretPosition() const
Definition: textfield.h:234
void setCaretPosition(unsigned int position)
Definition: textfield.cpp:752

References CAST_S32, TextField::getCaretPosition(), TextField::getText(), mChatInput, requestChatFocus(), TextField::setCaretPosition(), and TextField::setText().

Referenced by StatDebugTab::action(), action(), StatusWindow::action(), addItemText(), WhoIsOnline::handleLink(), and keyPressed().

◆ addItemText()

void ChatWindow::addItemText ( const std::string &  item)

Called to add item to chat

Definition at line 1098 of file chatwindow.cpp.

1099 {
1100  std::ostringstream text;
1101  text << "[" << item << "]";
1102  addInputText(text.str(),
1103  true);
1104 }

References addInputText().

Referenced by ItemContainer::mousePressed().

◆ addSpecialChannelTab()

ChatTab * ChatWindow::addSpecialChannelTab ( const std::string &  name,
const bool  switchTo 
)

Definition at line 1282 of file chatwindow.cpp.

1284 {
1285  ChatTab *ret = nullptr;
1286  if (name == TRADE_CHANNEL)
1287  {
1288  if (tradeChatTab == nullptr)
1289  {
1293  }
1294  ret = tradeChatTab;
1295  }
1296  else if (name == GM_CHANNEL)
1297  {
1298  if (gmChatTab == nullptr)
1299  {
1300  gmChatTab = new GmTab(chatWindow);
1302  }
1303  ret = gmChatTab;
1304  }
1305  if (switchTo)
1306  mChatTabs->setSelectedTab(ret);
1307 
1308  return ret;
1309 }
ChatWindow * chatWindow
Definition: chatwindow.cpp:94
const std::string & getChannelName() const
Definition: chattab.h:183
Definition: gmtab.h:31
const std::string TRADE_CHANNEL
Definition: chat.h:31
const std::string GM_CHANNEL
Definition: chat.h:30
GmTab * gmChatTab
Definition: gmtab.cpp:34
TradeTab * tradeChatTab
Definition: tradetab.cpp:36

References chatHandler, chatWindow, ChatTab::getChannelName(), GM_CHANNEL, gmChatTab, Net::ChatHandler::joinChannel(), mChatTabs, ChatTab::setAllowHighlight(), TabbedArea::setSelectedTab(), TRADE_CHANNEL, and tradeChatTab.

Referenced by addChannelTab(), createGuiWindows(), and showGMTab().

◆ addTab()

void ChatWindow::addTab ( ChatTab *const  tab)
protected

Add the tab to the window

Definition at line 589 of file chatwindow.cpp.

590 {
591  if (tab == nullptr)
592  return;
593 
594  mChatTabs->addTab(tab, tab->mScrollArea);
595  logic();
596 }
ScrollArea * mScrollArea
Definition: chattab.h:208
void addTab(Tab *const tab, Widget *const widget)
Definition: tabbedarea.cpp:238

References TabbedArea::addTab(), BasicContainer::logic(), mChatTabs, and ChatTab::mScrollArea.

Referenced by ChatTab::ChatTab().

◆ addToAwayLog()

void ChatWindow::addToAwayLog ( const std::string &  line)

Definition at line 1993 of file chatwindow.cpp.

1994 {
1995  if (!settings.awayMode)
1996  return;
1997 
1998  if (mAwayLog.size() > 20)
1999  mAwayLog.pop_front();
2000 
2001  if (findI(line, mHighlights) != std::string::npos)
2002  mAwayLog.push_back("##aaway:" + line);
2003 }
bool awayMode
Definition: settings.h:158
Settings settings
Definition: settings.cpp:32

References Settings::awayMode, findI(), mAwayLog, mHighlights, and settings.

Referenced by ChatTab::chatLog().

◆ addWhisper()

void ChatWindow::addWhisper ( const std::string &  nick,
const std::string &  mes,
const ChatMsgTypeT  own 
)

Definition at line 1117 of file chatwindow.cpp.

1120 {
1121  if (mes.empty() || (localPlayer == nullptr))
1122  return;
1123 
1124  std::string playerName = localPlayer->getName();
1125  std::string tempNick = nick;
1126 
1127  toLower(playerName);
1128  toLower(tempNick);
1129 
1130  if (tempNick == playerName)
1131  return;
1132 
1133  WhisperTab *tab = nullptr;
1134  const TabMap::const_iterator i = mWhispers.find(tempNick);
1135 
1136  if (i != mWhispers.end())
1137  {
1138  tab = i->second;
1139  }
1140  else if (config.getBoolValue("whispertab"))
1141  {
1142  tab = addWhisperTab(nick, nick, false);
1143  if (tab != nullptr)
1144  saveState();
1145  }
1146 
1147  if (tab != nullptr)
1148  {
1149  if (own == ChatMsgType::BY_PLAYER)
1150  {
1151  tab->chatInput(mes);
1152  }
1153  else if (own == ChatMsgType::BY_SERVER)
1154  {
1155  tab->chatLog(mes,
1159  }
1160  else
1161  {
1162  if (tab->getRemoveNames())
1163  {
1164  std::string msg = mes;
1165  const size_t idx = mes.find(':');
1166  if (idx != std::string::npos && idx > 0)
1167  {
1168  std::string nick2 = msg.substr(0, idx);
1169  msg = msg.substr(idx + 1);
1170  nick2 = removeColors(nick2);
1171  nick2 = trim(nick2);
1172  if (config.getBoolValue("removeColors"))
1173  msg = removeColors(msg);
1174  msg = trim(msg);
1175  tab->chatLog(nick2, msg);
1176  }
1177  else
1178  {
1179  if (config.getBoolValue("removeColors"))
1180  msg = removeColors(msg);
1181  tab->chatLog(msg,
1185  }
1186  }
1187  else
1188  {
1189  tab->chatLog(nick, mes);
1190  }
1191  localPlayer->afkRespond(tab, nick);
1192  }
1193  }
1194  else if (localChatTab != nullptr)
1195  {
1196  if (own == ChatMsgType::BY_PLAYER)
1197  {
1198  chatHandler->privateMessage(nick, mes);
1199 
1200  // TRANSLATORS: chat message
1201  localChatTab->chatLog(strprintf(_("Whispering to %s: %s"),
1202  nick.c_str(), mes.c_str()),
1206  }
1207  else
1208  {
1209  localChatTab->chatLog(std::string(nick).append(
1210  " : ").append(mes),
1214  if (localPlayer != nullptr)
1215  localPlayer->afkRespond(nullptr, nick);
1216  }
1217  }
1218 }
const std::string & getName() const
Definition: being.h:232
bool getRemoveNames() const
Definition: chattab.h:164
void chatInput(const std::string &msg)
Definition: chattab.cpp:382
void afkRespond(ChatTab *const tab, const std::string &nick)
virtual void privateMessage(const std::string &recipient, const std::string &text) const =0
std::string trim(std::string const &str)
std::string removeColors(std::string msg)
std::string strprintf(const char *const format,...)

References _, ChatMsgType::ACT_WHISPER, addWhisperTab(), LocalPlayer::afkRespond(), ChatMsgType::BY_PLAYER, ChatMsgType::BY_SERVER, chatHandler, ChatTab::chatInput(), ChatTab::chatLog(), config, Configuration::getBoolValue(), Being::getName(), ChatTab::getRemoveNames(), IgnoreRecord_false, localChatTab, localPlayer, Actions::msg(), mWhispers, Net::ChatHandler::privateMessage(), removeColors(), saveState(), strprintf(), Catch::toLower(), Catch::trim(), and TryRemoveColors_true.

Referenced by EAthena::ChatRecv::processWhisperContinue(), TmwAthena::ChatRecv::processWhisperContinue(), Ea::ChatRecv::processWhisperResponseContinue(), TmwAthena::BuySellHandler::requestBuyList(), TmwAthena::BuySellHandler::requestSellList(), TmwAthena::BuySellHandler::sendBuyRequest(), ShopWindow::sendMessage(), and TmwAthena::BuySellHandler::sendSellRequest().

◆ addWhisperTab()

WhisperTab * ChatWindow::addWhisperTab ( const std::string &  caption,
const std::string &  nick,
const bool  switchTo 
)

Definition at line 1220 of file chatwindow.cpp.

1223 {
1224  if (localPlayer == nullptr)
1225  return nullptr;
1226 
1227  std::string playerName = localPlayer->getName();
1228  std::string tempNick = nick;
1229 
1230  toLower(playerName);
1231  toLower(tempNick);
1232 
1233  const TabMap::const_iterator i = mWhispers.find(tempNick);
1234  WhisperTab *ret = nullptr;
1235 
1236  if (tempNick == playerName)
1237  return nullptr;
1238 
1239  if (i != mWhispers.end())
1240  {
1241  ret = i->second;
1242  }
1243  else
1244  {
1245  ret = new WhisperTab(this, caption, nick);
1246  if ((gui != nullptr) && !playerRelations.isGoodName(nick))
1247  ret->setLabelFont(gui->getSecureFont());
1248  mWhispers[tempNick] = ret;
1249  if (config.getBoolValue("showChatHistory"))
1250  ret->loadFromLogFile(nick);
1251  }
1252 
1253  if (switchTo)
1254  mChatTabs->setSelectedTab(ret);
1255 
1256  return ret;
1257 }
friend class WhisperTab
Definition: chatwindow.h:313
Font * getSecureFont() const
Definition: gui.h:172
bool isGoodName(Being *const being) const
void setLabelFont(Font *const font)
Definition: tab.cpp:414
Gui * gui
Definition: gui.cpp:111
PlayerRelationsManager playerRelations

References config, Configuration::getBoolValue(), Being::getName(), Gui::getSecureFont(), gui, PlayerRelationsManager::isGoodName(), ChatTab::loadFromLogFile(), localPlayer, mChatTabs, mWhispers, playerRelations, Tab::setLabelFont(), TabbedArea::setSelectedTab(), Catch::toLower(), and WhisperTab.

Referenced by addChatTab(), addWhisper(), and AvatarListBox::mousePressed().

◆ adjustTabSize()

void ChatWindow::adjustTabSize ( )

Definition at line 281 of file chatwindow.cpp.

282 {
283  const Rect area = getChildrenArea();
284 
285  const int aw = area.width;
286  const int ah = area.height;
287  const int frame = mChatInput->getFrameSize();
288  const int inputHeight = mChatInput->getHeight();
289  const bool showEmotes = config.getBoolValue("showEmotesButton");
290  int maxHeight = inputHeight;
291  if (showEmotes)
292  {
293  const int buttonHeight = mChatButton->getHeight();
294  if (buttonHeight > maxHeight)
295  maxHeight = buttonHeight;
296  }
297  const int frame2 = 2 * frame;
298  const int awFrame2 = aw - frame2;
299  int y = ah - maxHeight - frame;
300  mChatInput->setPosition(frame, y);
301  mChatTabs->setWidth(awFrame2);
302  const int height = ah - frame2 - (maxHeight + frame2);
303  if (mChatInput->mVisible == Visible_true ||
304  !config.getBoolValue("hideChatInput"))
305  {
306  mChatTabs->setHeight(height);
307  }
308  else
309  {
310  mChatTabs->setHeight(height + maxHeight);
311  }
313 
314  if (showEmotes)
315  {
316  const int chatButtonSize = mChatButton->getWidth();
317  int w = awFrame2 - chatButtonSize;
318  const int x = aw - frame - chatButtonSize;
319  w -= mEmoteButtonSpacing;
320  y += mEmoteButtonY;
321  mChatInput->setWidth(w);
324  }
325  else
326  {
327  mChatInput->setWidth(awFrame2);
329  }
330 
331  const ChatTab *const tab = getFocused();
332  if (tab != nullptr)
333  {
334  Widget *const content = tab->mScrollArea;
335  if (content != nullptr)
336  {
337  const int contentFrame2 = 2 * content->getFrameSize();
338  content->setSize(mChatTabs->getWidth() - contentFrame2,
339  mChatTabs->getContainerHeight() - contentFrame2);
340  content->logic();
341  }
342  }
343 
345  - 2 * mPadding - 8 - 16, mPadding);
346 
348 }
ChatTab * getFocused() const
Definition: chatwindow.cpp:357
Definition: rect.h:74
int width
Definition: rect.h:219
int height
Definition: rect.h:224
void adjustSize()
Definition: tabbedarea.cpp:569
void setWidth(int width)
Definition: tabbedarea.cpp:750
int getContainerHeight() const
Definition: tabbedarea.h:164
void setHeight(int height)
Definition: tabbedarea.cpp:757
Definition: widget.h:99
unsigned int getFrameSize() const
Definition: widget.h:184
void setWidth(const int width)
Definition: widget.cpp:133
void setSize(const int width, const int height)
Definition: widget.cpp:367
virtual void logic()
Definition: widget.h:193
int getHeight() const
Definition: widget.h:240
Rect getChildrenArea()
Definition: window.cpp:1473

References TabbedArea::adjustSize(), config, Configuration::getBoolValue(), Window::getChildrenArea(), TabbedArea::getContainerHeight(), getFocused(), Widget::getFrameSize(), Widget::getHeight(), Widget::getWidth(), Rect::height, Widget::logic(), mChatButton, mChatInput, mChatTabs, mColorPicker, mEmoteButtonSpacing, mEmoteButtonY, Window::mPadding, ChatTab::mScrollArea, Widget::mVisible, TabbedArea::setHeight(), Widget::setPosition(), Widget::setSize(), Widget::setVisible(), Widget::setWidth(), TabbedArea::setWidth(), updateTabsMargin(), Visible_false, Visible_true, Rect::width, x, and y.

Referenced by Setup_Chat::apply(), ChatInput::processVisible(), and widgetResized().

◆ attributeChanged()

void ChatWindow::attributeChanged ( const AttributesT  id,
const int64_t  oldVal,
const int64_t  newVal 
)
virtual

Implements AttributeListener.

Definition at line 1020 of file chatwindow.cpp.

1023 {
1024  if (!mShowBattleEvents)
1025  return;
1026  PRAGMA45(GCC diagnostic push)
1027  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
1028  switch (id)
1029  {
1031  {
1032  if (oldVal > newVal)
1033  break;
1034  const int64_t change = newVal - oldVal;
1035  if (change != 0)
1036  {
1037  battleChatLog(std::string("+").append(toString(
1038  CAST_U64(change))).append(" xp"),
1042  }
1043  break;
1044  }
1046  battleChatLog(std::string(
1047  "Level: ").append(toString(CAST_S32(
1048  newVal))),
1052  break;
1054  {
1055  if (!config.getBoolValue("showJobExp"))
1056  return;
1057  if (oldVal > newVal ||
1060  {
1061  return;
1062  }
1063  const int64_t change = newVal - oldVal;
1064  if (change != 0)
1065  {
1066  battleChatLog(std::string("+").append(toString(CAST_U64(
1067  change))).append(" job"),
1071  }
1072  break;
1073  }
1074  default:
1075  break;
1076  }
1077  PRAGMA45(GCC diagnostic pop)
1078 }
#define CAST_U64
Definition: cast.h:33
static void battleChatLog(const std::string &line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wredundant-decls") PRAGMA45(GCC diagnostic pop) class TestMain
@ PLAYER_BASE_LEVEL
Definition: attributes.h:31
@ PLAYER_JOB_EXP
Definition: attributes.h:66
@ PLAYER_JOB_EXP_NEEDED
Definition: attributes.h:67
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:102

References battleChatLog(), ChatMsgType::BY_SERVER, CAST_S32, CAST_U64, config, PlayerInfo::getAttribute(), Configuration::getBoolValue(), IgnoreRecord_false, mShowBattleEvents, Attributes::PLAYER_BASE_LEVEL, Attributes::PLAYER_EXP, Attributes::PLAYER_JOB_EXP, Attributes::PLAYER_JOB_EXP_NEEDED, PRAGMA45(), Catch::toString(), and TryRemoveColors_true.

◆ autoComplete() [1/3]

void ChatWindow::autoComplete ( )
protected

Definition at line 1438 of file chatwindow.cpp.

1439 {
1440  const int caretPos = mChatInput->getCaretPosition();
1441  int startName = 0;
1442  const std::string &inputText = mChatInput->getText();
1443  std::string name = inputText.substr(0, caretPos);
1444 
1445  for (int f = caretPos - 1; f > -1; f --)
1446  {
1447  if (isWordSeparator(inputText[f]))
1448  {
1449  startName = f + 1;
1450  name = inputText.substr(f + 1, caretPos - f);
1451  break;
1452  }
1453  }
1454 
1455  if (caretPos - 1 + 1 == startName)
1456  return;
1457 
1458  const ChatTab *const cTab = static_cast<ChatTab*>(
1460  StringVect nameList;
1461 
1462  if (cTab != nullptr)
1463  cTab->getAutoCompleteList(nameList);
1464  std::string newName = autoComplete(nameList, name);
1465  if (!newName.empty() && (startName == 0))
1466  secureChatCommand(newName);
1467 
1468  if ((cTab != nullptr) && newName.empty())
1469  {
1470  cTab->getAutoCompleteCommands(nameList);
1471  newName = autoComplete(nameList, name);
1472  }
1473 
1474  if (newName.empty() && (actorManager != nullptr))
1475  {
1477  newName = autoComplete(nameList, name);
1478  if (!newName.empty() && (startName == 0))
1479  secureChatCommand(newName);
1480  }
1481  if (newName.empty())
1482  newName = autoCompleteHistory(name);
1483  if (newName.empty() && (spellManager != nullptr))
1484  newName = spellManager->autoComplete(name);
1485  if (newName.empty())
1486  newName = autoComplete(name, &mCommands);
1487  if (newName.empty() && (actorManager != nullptr))
1488  {
1489  actorManager->getMobNames(nameList);
1490  newName = autoComplete(nameList, name);
1491  }
1492  if (newName.empty())
1493  newName = autoComplete(name, &mCustomWords);
1494  if (newName.empty())
1495  {
1496  whoIsOnline->getPlayerNames(nameList);
1497  newName = autoComplete(nameList, name);
1498  }
1499 
1500  if (!newName.empty())
1501  {
1502  mChatInput->setText(inputText.substr(0, startName).append(newName)
1503  .append(inputText.substr(caretPos,
1504  inputText.length() - caretPos)));
1505 
1506  const int len = caretPos - CAST_S32(name.length())
1507  + CAST_S32(newName.length());
1508 
1509  if (startName > 0)
1510  mChatInput->setCaretPosition(len + 1);
1511  else
1513  }
1514 }
ActorManager * actorManager
void getMobNames(StringVect &names) const
void getPlayerNames(StringVect &names, const NpcNames npcNames) const
virtual void getAutoCompleteList(StringVect &names) const
Definition: chattab.h:199
virtual void getAutoCompleteCommands(StringVect &names) const
Definition: chattab.h:202
std::string autoCompleteHistory(const std::string &partName) const
void autoComplete()
std::string autoComplete(const std::string &partName) const
Tab * getSelectedTab() const
Definition: tabbedarea.h:175
void getPlayerNames(StringVect &names)
const bool NpcNames_true
Definition: npcnames.h:30
SpellManager * spellManager
void secureChatCommand(std::string &str)
bool isWordSeparator(const signed char chr) A_CONST
Definition: stringutils.h:142
std::vector< std::string > StringVect
Definition: stringvector.h:29
WhoIsOnline * whoIsOnline
Definition: whoisonline.cpp:82

References actorManager, SpellManager::autoComplete(), autoCompleteHistory(), CAST_S32, ChatTab::getAutoCompleteCommands(), ChatTab::getAutoCompleteList(), TextField::getCaretPosition(), ActorManager::getMobNames(), WhoIsOnline::getPlayerNames(), ActorManager::getPlayerNames(), TabbedArea::getSelectedTab(), TextField::getText(), isWordSeparator(), mChatInput, mChatTabs, mCommands, mCustomWords, NpcNames_true, secureChatCommand(), TextField::setCaretPosition(), TextField::setText(), spellManager, and whoIsOnline.

Referenced by autoComplete(), autoCompleteHistory(), and keyPressed().

◆ autoComplete() [2/3]

std::string ChatWindow::autoComplete ( const std::string &  partName,
const History *const  words 
)
staticprotected

Definition at line 1546 of file chatwindow.cpp.

1548 {
1549  if (words == nullptr)
1550  return "";
1551 
1552  ChatCommands::const_iterator i = words->begin();
1553  const ChatCommands::const_iterator i_end = words->end();
1554  StringVect nameList;
1555 
1556  while (i != i_end)
1557  {
1558  const std::string line = *i;
1559  if (line.find(partName, 0) == 0)
1560  nameList.push_back(line);
1561  ++i;
1562  }
1563  return autoComplete(nameList, partName);
1564 }

References autoComplete().

◆ autoComplete() [3/3]

std::string ChatWindow::autoComplete ( const StringVect names,
std::string  partName 
)
staticprotected

Definition at line 1516 of file chatwindow.cpp.

1518 {
1519  StringVectCIter i = names.begin();
1520  const StringVectCIter i_end = names.end();
1521  toLower(partName);
1522  std::string newName;
1523 
1524  while (i != i_end)
1525  {
1526  if (!i->empty())
1527  {
1528  std::string name = *i;
1529  toLower(name);
1530 
1531  const size_t pos = name.find(partName, 0);
1532  if (pos == 0)
1533  {
1534  if (!newName.empty())
1535  newName = findSameSubstringI(*i, newName);
1536  else
1537  newName = *i;
1538  }
1539  }
1540  ++i;
1541  }
1542 
1543  return newName;
1544 }
const std::string findSameSubstringI(const std::string &s1, const std::string &s2)
StringVect::const_iterator StringVectCIter
Definition: stringvector.h:31

References findSameSubstringI(), and Catch::toLower().

◆ autoCompleteHistory()

std::string ChatWindow::autoCompleteHistory ( const std::string &  partName) const
protected

Definition at line 1578 of file chatwindow.cpp.

1579 {
1580  History::const_iterator i = mHistory.begin();
1581  const History::const_iterator i_end = mHistory.end();
1582  StringVect nameList;
1583 
1584  while (i != i_end)
1585  {
1586  std::string line = *i;
1587  unsigned int f = 0;
1588  while (f < line.length() && !isWordSeparator(line.at(f)))
1589  f++;
1590 
1591  line = line.substr(0, f);
1592  if (!line.empty())
1593  nameList.push_back(line);
1594 
1595  ++i;
1596  }
1597  return autoComplete(nameList, partName);
1598 }

References autoComplete(), isWordSeparator(), and mHistory.

Referenced by autoComplete().

◆ battleChatLog()

void ChatWindow::battleChatLog ( const std::string &  line,
ChatMsgTypeT  own,
const IgnoreRecord  ignoreRecord,
const TryRemoveColors  tryRemoveColors 
)
static

Definition at line 1765 of file chatwindow.cpp.

1768 {
1769  if (own == ChatMsgType::BY_UNKNOWN)
1770  own = ChatMsgType::BY_SERVER;
1771  if (battleChatTab != nullptr)
1772  battleChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
1773  else if (debugChatTab != nullptr)
1774  debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
1775 }
BattleTab * battleChatTab
Definition: battletab.cpp:32

References battleChatTab, ChatMsgType::BY_SERVER, ChatMsgType::BY_UNKNOWN, ChatTab::chatLog(), and debugChatTab.

Referenced by attributeChanged(), and Being::takeDamage().

◆ channelChatLog()

void ChatWindow::channelChatLog ( const std::string &  channel,
const std::string &  line,
ChatMsgTypeT  own,
const IgnoreRecord  ignoreRecord,
const TryRemoveColors  tryRemoveColors 
)

Definition at line 1777 of file chatwindow.cpp.

1782 {
1783  std::string tempChannel = channel;
1784  toLower(tempChannel);
1785 
1786  ChatTab *tab = nullptr;
1787  const ChannelMap::const_iterator i = mChannels.find(tempChannel);
1788 
1789  if (i != mChannels.end())
1790  {
1791  tab = i->second;
1792  }
1793  else
1794  {
1795  tab = addChannelTab(channel, false);
1796  if (tab != nullptr)
1797  saveState();
1798  }
1799 
1800  if (tab != nullptr)
1801  tab->chatLog(line, own, ignoreRecord, tryRemoveColors);
1802 }

References addChannelTab(), ChatTab::chatLog(), mChannels, saveState(), and Catch::toLower().

Referenced by EAthena::ChatRecv::processJoinChannel(), EAthena::ChatRecv::processWhisperResponse(), and resortChatLog().

◆ chatInput()

void ChatWindow::chatInput ( const std::string &  msg) const

Passes the text to the current tab as input

Parameters
msgThe message text which is to be sent.

Definition at line 665 of file chatwindow.cpp.

666 {
667  ChatTab *tab = nullptr;
668  std::string msg = message;
669  trim(msg);
670 
671  if (config.getBoolValue("allowCommandsInChatTabs")
672  && msg.length() > 1
673  && ((msg.at(0) == '#' && msg.at(1) != '#') || msg.at(0) == '@')
674  && (localChatTab != nullptr))
675  {
676  tab = localChatTab;
677  }
678  else
679  {
680  tab = getFocused();
681  if (tab == nullptr)
682  tab = localChatTab;
683  }
684  if (tab != nullptr)
685  tab->chatInput(msg);
686  Game *const game = Game::instance();
687  if (game != nullptr)
688  game->setValidSpeed();
689 }
Definition: game.h:64
static Game * instance()
Definition: game.h:82
void setValidSpeed()
Definition: game.cpp:1273

References ChatTab::chatInput(), config, Configuration::getBoolValue(), getFocused(), Game::instance(), localChatTab, Actions::msg(), Game::setValidSpeed(), and Catch::trim().

Referenced by action(), IPC::flush(), and localChatInput().

◆ clearAwayLog()

void ChatWindow::clearAwayLog ( )
inline

Definition at line 257 of file chatwindow.h.

258  { mAwayLog.clear(); }

References mAwayLog.

Referenced by GameModifiers::changeAwayMode().

◆ clearTab() [1/2]

void ChatWindow::clearTab ( ) const

Clear the current tab.

Definition at line 368 of file chatwindow.cpp.

369 {
370  clearTab(getFocused());
371 }
void clearTab() const
Definition: chatwindow.cpp:368

References getFocused().

◆ clearTab() [2/2]

void ChatWindow::clearTab ( ChatTab *const  tab)
static

Clear the given tab.

Definition at line 362 of file chatwindow.cpp.

363 {
364  if (tab != nullptr)
365  tab->clearText();
366 }
void clearText()
Definition: chattab.cpp:428

References ChatTab::clearText().

◆ closeTab()

void ChatWindow::closeTab ( ) const

Close current chat tab

Definition at line 419 of file chatwindow.cpp.

420 {
421  if (mChatTabs == nullptr)
422  return;
423 
424  ChatTab *const tab = dynamic_cast<ChatTab*>(mChatTabs->getTabByIndex(
426  if (tab == nullptr)
427  return;
428  const ChatTabTypeT &type = tab->getType();
429  if (type == ChatTabType::WHISPER || type == ChatTabType::CHANNEL)
430  tab->handleCommand("close", "");
431 }
ChatTabType ::T ChatTabTypeT
Definition: chattabtype.h:49
virtual bool handleCommand(const std::string &type, const std::string &args)
Definition: chattab.h:128
ChatTabTypeT getType() const
Definition: chattab.h:145
int getSelectedTabIndex() const
Definition: tabbedarea.cpp:449
Tab * getTabByIndex(const int index) const
Definition: tabbedarea.cpp:716

References ChatTabType::CHANNEL, TabbedArea::getSelectedTabIndex(), TabbedArea::getTabByIndex(), ChatTab::getType(), ChatTab::handleCommand(), mChatTabs, and ChatTabType::WHISPER.

◆ copyToClipboard()

void ChatWindow::copyToClipboard ( const int  x,
const int  y 
) const

Definition at line 2050 of file chatwindow.cpp.

2051 {
2052  const ChatTab *const tab = getFocused();
2053  if (tab == nullptr)
2054  return;
2055 
2056  const BrowserBox *const text = tab->mTextOutput;
2057  if (text == nullptr)
2058  return;
2059 
2060  std::string str = text->getTextAtPos(x, y);
2061  sendBuffer(str);
2062 }
std::string getTextAtPos(const int x, const int y) const
Definition: browserbox.cpp:870
BrowserBox * mTextOutput
Definition: chattab.h:207
bool sendBuffer(const std::string &text)
Definition: copynpaste.cpp:518

References getFocused(), BrowserBox::getTextAtPos(), ChatTab::mTextOutput, sendBuffer(), x, and y.

◆ debugMessage()

void ChatWindow::debugMessage ( const std::string &  msg)
virtual

Implements DebugMessageListener.

Definition at line 2178 of file chatwindow.cpp.

2179 {
2180  if (debugChatTab != nullptr)
2181  {
2186  }
2187 }

References ChatMsgType::BY_SERVER, ChatTab::chatLog(), debugChatTab, IgnoreRecord_false, Actions::msg(), and TryRemoveColors_true.

◆ defaultTab()

void ChatWindow::defaultTab ( )

Switch to the default tab

Definition at line 433 of file chatwindow.cpp.

434 {
435  if (mChatTabs != nullptr)
437 }
#define CAST_U32
Definition: cast.h:31
void setSelectedTabByIndex(const size_t index)
Definition: tabbedarea.cpp:315

References CAST_U32, mChatTabs, and TabbedArea::setSelectedTabByIndex().

Referenced by ChannelTab::handleCommand(), and WhisperTab::handleCommand().

◆ displayAwayLog()

void ChatWindow::displayAwayLog ( ) const

Definition at line 2005 of file chatwindow.cpp.

2006 {
2007  if (localChatTab == nullptr)
2008  return;
2009 
2010  std::list<std::string>::const_iterator i = mAwayLog.begin();
2011  const std::list<std::string>::const_iterator i_end = mAwayLog.end();
2012 
2013  while (i != i_end)
2014  {
2015  std::string str = *i;
2016  localChatTab->addNewRow(str);
2017  ++i;
2018  }
2019 }
void addNewRow(std::string &line)
Definition: chattab.cpp:526

References ChatTab::addNewRow(), localChatTab, and mAwayLog.

Referenced by GameModifiers::changeAwayMode().

◆ doPresent()

void ChatWindow::doPresent ( ) const

Definition at line 699 of file chatwindow.cpp.

700 {
701  if (actorManager == nullptr)
702  return;
703 
704  const ActorSprites &actors = actorManager->getAll();
705  std::string response;
706  int playercount = 0;
707 
708  FOR_EACH (ActorSpritesIterator, it, actors)
709  {
710  if ((*it)->getType() == ActorType::Player)
711  {
712  if (!response.empty())
713  response.append(", ");
714  response.append(static_cast<Being*>(*it)->getName());
715  playercount ++;
716  }
717  }
718 
719  ChatTab *const tab = getFocused();
720  if (tab != nullptr)
721  {
722  const std::string log = strprintf(
723  // TRANSLATORS: chat message
724  _("Present: %s; %d players are present."),
725  response.c_str(), playercount);
726  tab->chatLog(log,
730  }
731 }
std::set< ActorSprite * > ActorSprites
Definition: actormanager.h:57
ActorSprites::iterator ActorSpritesIterator
Definition: actormanager.h:60
const ActorSprites & getAll() const A_CONST
Definition: being.h:96

References _, actorManager, ChatMsgType::BY_SERVER, ChatTab::chatLog(), FOR_EACH, ActorManager::getAll(), getFocused(), Being::getName(), IgnoreRecord_false, ActorType::Player, strprintf(), and TryRemoveColors_true.

◆ doReplace()

std::string ChatWindow::doReplace ( const std::string &  msg)
static

Definition at line 1961 of file chatwindow.cpp.

1962 {
1963  std::string str = msg;
1964  replaceSpecialChars(str);
1965  return str;
1966 }
void replaceSpecialChars(std::string &text)

References Actions::msg(), and replaceSpecialChars().

Referenced by ChannelTab::handleInput(), ChatTab::handleInput(), ClanTab::handleInput(), EmulateGuildTab::handleInput(), GmTab::handleInput(), GuildTab::handleInput(), PartyTab::handleInput(), TradeTab::handleInput(), and WhisperTab::handleInput().

◆ draw()

void ChatWindow::draw ( Graphics *const  graphics)
virtual

Draws the window.

Reimplemented from Window.

Definition at line 2094 of file chatwindow.cpp.

2095 {
2096  BLOCK_START("ChatWindow::draw")
2097  if (!mAutoHide || mHaveMouse)
2098  {
2099  GLDEBUG_START("ChatWindow::draw");
2100  Window::draw(graphics);
2101  GLDEBUG_END();
2102  }
2103  BLOCK_END("ChatWindow::draw")
2104 }
void draw(Graphics *const graphics)
Definition: window.cpp:311
if(!vert) return
#define GLDEBUG_START(text)
Definition: opengldebug.h:35
#define GLDEBUG_END()
Definition: opengldebug.h:36
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References BLOCK_END, BLOCK_START, Window::draw(), GLDEBUG_END, GLDEBUG_START, mAutoHide, and mHaveMouse.

◆ fillCommands()

void ChatWindow::fillCommands ( )
private

Definition at line 258 of file chatwindow.cpp.

259 {
260  loadCommandsFile("chatcommands.txt");
262 }
void loadCommandsFile(const std::string &name)
Definition: chatwindow.cpp:242
static void addChatCommands(std::list< std::string > &arr)

References InputManager::addChatCommands(), loadCommandsFile(), and mCommands.

Referenced by ChatWindow().

◆ findHighlight()

bool ChatWindow::findHighlight ( const std::string &  str)

Definition at line 2045 of file chatwindow.cpp.

2046 {
2047  return findI(str, mHighlights) != std::string::npos;
2048 }

References findI(), and mHighlights.

Referenced by ChatTab::chatLog().

◆ getFocused()

ChatTab * ChatWindow::getFocused ( ) const

Gets the focused tab.

Definition at line 357 of file chatwindow.cpp.

358 {
359  return static_cast<ChatTab*>(mChatTabs->getSelectedTab());
360 }

References TabbedArea::getSelectedTab(), and mChatTabs.

Referenced by adjustTabSize(), chatInput(), clearTab(), copyToClipboard(), doPresent(), keyPressed(), mousePressed(), and scroll().

◆ getReturnTogglesChat()

bool ChatWindow::getReturnTogglesChat ( ) const
inline

Definition at line 184 of file chatwindow.h.

185  { return mReturnToggles; }

References mReturnToggles.

◆ getWhisperTab()

WhisperTab * ChatWindow::getWhisperTab ( const std::string &  nick) const

Definition at line 1259 of file chatwindow.cpp.

1260 {
1261  if (localPlayer == nullptr)
1262  return nullptr;
1263 
1264  std::string playerName = localPlayer->getName();
1265  std::string tempNick = nick;
1266 
1267  toLower(playerName);
1268  toLower(tempNick);
1269 
1270  const TabMap::const_iterator i = mWhispers.find(tempNick);
1271  WhisperTab *ret = nullptr;
1272 
1273  if (tempNick == playerName)
1274  return nullptr;
1275 
1276  if (i != mWhispers.end())
1277  ret = i->second;
1278 
1279  return ret;
1280 }

References Being::getName(), localPlayer, mWhispers, and Catch::toLower().

Referenced by LocalPlayer::checkNewName().

◆ ignoreAllWhispers()

void ChatWindow::ignoreAllWhispers ( )

Definition at line 645 of file chatwindow.cpp.

646 {
647  for (TabMap::iterator iter = mWhispers.begin();
648  iter != mWhispers.end();
649  ++ iter)
650  {
651  WhisperTab *const tab = iter->second;
652  if (tab != nullptr)
653  {
656  {
659  }
660  tab->handleCommand("close", "");
661  }
662  }
663 }
RelationT getRelation(const std::string &name) const
void setRelation(const std::string &name, const RelationT relation)
bool handleCommand(const std::string &type, const std::string &args)
Definition: whispertab.cpp:93
const std::string & getNick() const
Definition: whispertab.h:37
@ IGNORED
Definition: relation.h:34

References WhisperTab::getNick(), PlayerRelationsManager::getRelation(), WhisperTab::handleCommand(), Relation::IGNORED, mWhispers, playerRelations, and PlayerRelationsManager::setRelation().

◆ initTradeFilter()

void ChatWindow::initTradeFilter ( )
protected

Definition at line 1804 of file chatwindow.cpp.

1805 {
1806  const std::string tradeListName = settings.serverConfigDir
1807  + "/tradefilter.txt";
1808 
1809  std::ifstream tradeFile;
1810  struct stat statbuf;
1811 
1812  if (stat(tradeListName.c_str(), &statbuf) == 0 &&
1813  S_ISREG(statbuf.st_mode))
1814  {
1815  tradeFile.open(tradeListName.c_str(), std::ios::in);
1816  if (tradeFile.is_open())
1817  {
1818  char line[100];
1819  while (tradeFile.getline(line, 100))
1820  {
1821  const std::string str = line;
1822  if (!str.empty())
1823  mTradeFilter.push_back(str);
1824  }
1825  }
1826  tradeFile.close();
1827  }
1828 }
std::string serverConfigDir
Definition: settings.h:117

References mTradeFilter, Settings::serverConfigDir, and settings.

Referenced by ChatWindow().

◆ isInputFocused()

bool ChatWindow::isInputFocused ( ) const

Checks whether ChatWindow is Focused or not.

Definition at line 579 of file chatwindow.cpp.

580 {
581  return mChatInput->isFocused();
582 }
virtual bool isFocused() const
Definition: widget.cpp:184

References Widget::isFocused(), and mChatInput.

Referenced by Game::handleMove(), and InputManager::updateConditionMask().

◆ isTabPresent()

bool ChatWindow::isTabPresent ( const ChatTab *const  tab) const

Definition at line 2173 of file chatwindow.cpp.

2174 {
2175  return mChatTabs->isTabPresent(tab);
2176 }
bool isTabPresent(const Tab *const tab) const
Definition: tabbedarea.cpp:300

References TabbedArea::isTabPresent(), and mChatTabs.

Referenced by Actions::uploadUpdate().

◆ joinRoom()

void ChatWindow::joinRoom ( const bool  isJoin)

Definition at line 2207 of file chatwindow.cpp.

2208 {
2209  Tab *const tab = mChatTabs->getTabByIndex(0);
2210  if (tab != nullptr)
2211  {
2212  std::string name;
2213  if (isJoin)
2214  {
2215  name = PlayerInfo::getRoomName();
2216  }
2217  else
2218  {
2219  // TRANSLATORS: chat tab name
2220  name = _("General");
2221  }
2222  tab->setCaption(name);
2223  }
2224 }
Definition: tab.h:88
void setCaption(const std::string &caption)
Definition: tab.cpp:458
std::string getRoomName()
Definition: playerinfo.cpp:633

References _, PlayerInfo::getRoomName(), TabbedArea::getTabByIndex(), mChatTabs, and Tab::setCaption().

Referenced by EAthena::ChatRecv::processChatRoomCreateAck(), EAthena::ChatRecv::processChatRoomJoinAck(), EAthena::ChatRecv::processChatRoomLeave(), and EAthena::ChatRecv::processChatRoomSettings().

◆ keyPressed()

void ChatWindow::keyPressed ( KeyEvent event)
virtual

Called when key is pressed

Reimplemented from KeyListener.

Definition at line 822 of file chatwindow.cpp.

823 {
824  const InputActionT actionId = event.getActionId();
825  std::string temp;
826 #ifdef __SWITCH__
827  if (event.getKey().getValue() == KeyValue::TEXTINPUT)
828  {
829  action(ActionEvent(this, "chatinput"));
830  return;
831  }
832  else
833 #endif
834  if (actionId == InputAction::GUI_DOWN)
835  {
836  if (mCurHist != mHistory.end())
837  {
838  // Move forward through the history
839  const HistoryIterator prevHist = mCurHist++;
841 
842  if (mCurHist != mHistory.end())
843  {
846  mChatInput->getText().length()));
847  }
848  else
849  {
850  mChatInput->setText("");
851  mCurHist = prevHist;
852  }
853  }
854  else if (!mChatInput->getText().empty())
855  {
856  if (addCurrentToHistory())
857  mCurHist = mHistory.end();
858  mChatInput->setText("");
859  }
860  }
861  else if (actionId == InputAction::GUI_UP &&
862  mCurHist != mHistory.begin() &&
863  !mHistory.empty())
864  {
865  // Move backward through the history
866  --mCurHist;
870  mChatInput->getText().length()));
871  }
872  else if (actionId == InputAction::GUI_INSERT &&
873  !mChatInput->getText().empty())
874  {
875  const std::string str = mChatInput->getText();
876  // Add the current message to the history and clear the text
877  if (mHistory.empty() || str != mHistory.back())
878  mHistory.push_back(str);
879  mCurHist = mHistory.end();
880  mChatInput->setText(std::string());
881  }
882  else if (actionId == InputAction::GUI_TAB &&
883  !mChatInput->getText().empty())
884  {
885  autoComplete();
886  return;
887  }
888  else if (actionId == InputAction::GUI_CANCEL &&
890  {
892  }
893  else if (actionId == InputAction::CHAT_PREV_HISTORY &&
895  {
896  const ChatTab *const tab = getFocused();
897  if ((tab != nullptr) && tab->hasRows())
898  {
899  if (mChatHistoryIndex == 0U)
900  {
902  tab->getRows().size());
903 
904  mChatInput->setText("");
906  return;
907  }
908 
910 
911  unsigned int f = 0;
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 ++)
915  {
916  if (f == mChatHistoryIndex)
917  mChatInput->setText(*it);
918  }
920  mChatInput->getText().length()));
921  }
922  }
923  else if (actionId == InputAction::CHAT_NEXT_HISTORY &&
925  {
926  const ChatTab *const tab = getFocused();
927  if ((tab != nullptr) && tab->hasRows())
928  {
929  const std::list<std::string> &rows = tab->getRows();
930  const size_t &tabSize = rows.size();
931  if (CAST_SIZE(mChatHistoryIndex) + 1 < tabSize)
932  {
934  }
935  else if (CAST_SIZE(mChatHistoryIndex) < tabSize)
936  {
938  mChatInput->setText("");
940  return;
941  }
942  else
943  {
944  mChatHistoryIndex = 0;
945  }
946 
947  unsigned int f = 0;
948  for (std::list<std::string>::const_iterator
949  it = rows.begin(), it_end = rows.end();
950  it != it_end; ++it, f++)
951  {
952  if (f == mChatHistoryIndex)
953  mChatInput->setText(*it);
954  }
956  mChatInput->getText().length()));
957  }
958  }
959  else if (actionId == InputAction::GUI_F1)
960  {
961  if (emoteWindow != nullptr)
962  {
964  emoteWindow->hide();
965  else
966  emoteWindow->show();
967  }
968  }
969  ifKey(InputAction::GUI_F2, "\u2318")
970  ifKey(InputAction::GUI_F3, "\u263A")
971  ifKey(InputAction::GUI_F4, "\u2665")
972  ifKey(InputAction::GUI_F5, "\u266A")
973  ifKey(InputAction::GUI_F6, "\u266B")
974  ifKey(InputAction::GUI_F7, "\u26A0")
975  ifKey(InputAction::GUI_F8, "\u2622")
976  ifKey(InputAction::GUI_F9, "\u262E")
977  ifKey(InputAction::GUI_F10, "\u2605")
978  ifKey(InputAction::GUI_F11, "\u2618")
979  ifKey(InputAction::GUI_F12, "\u2592")
980 
981  if (inputManager.isActionActive(InputAction::GUI_CTRL))
982  {
983  if (actionId == InputAction::GUI_B)
984  {
985  std::string inputText = mChatInput->getTextBeforeCaret();
986  toLower(inputText);
987  const size_t idx = inputText.rfind("##b");
988  if (idx == std::string::npos
989  || mChatInput->getTextBeforeCaret().substr(idx, 3) == "##b")
990  {
991  temp = "##B";
992  }
993  else
994  {
995  temp = "##b";
996  }
997  }
998  }
999 
1000  if (!temp.empty())
1001  addInputText(temp, false);
1002 }
#define CAST_SIZE
Definition: cast.h:34
#define ifKey(key, str)
Definition: chatwindow.cpp:816
void processVisible(const Visible n)
Definition: chatinput.h:75
const std::list< std::string > & getRows() const
Definition: chattab.h:150
bool hasRows() const
Definition: chattab.h:153
bool addCurrentToHistory()
void action(const ActionEvent &event)
Definition: chatwindow.cpp:439
const Key & getKey() const
Definition: keyevent.h:124
int getValue() const
Definition: key.cpp:99
std::string getTextBeforeCaret() const
Definition: textfield.h:207
InputAction ::T InputActionT
Definition: inputaction.h:717
InputManager inputManager
@ TEXTINPUT
Definition: keyvalue.h:128

References action(), addCurrentToHistory(), addInputText(), autoComplete(), CAST_SIZE, CAST_U32, InputAction::CHAT_NEXT_HISTORY, InputAction::CHAT_PREV_HISTORY, emoteWindow, getFocused(), KeyEvent::getKey(), ChatTab::getRows(), TextField::getText(), TextField::getTextBeforeCaret(), Key::getValue(), InputAction::GUI_B, InputAction::GUI_CANCEL, InputAction::GUI_CTRL, InputAction::GUI_DOWN, InputAction::GUI_F1, InputAction::GUI_F10, InputAction::GUI_F11, InputAction::GUI_F12, InputAction::GUI_F2, InputAction::GUI_F3, InputAction::GUI_F4, InputAction::GUI_F5, InputAction::GUI_F6, InputAction::GUI_F7, InputAction::GUI_F8, InputAction::GUI_F9, InputAction::GUI_INSERT, InputAction::GUI_TAB, InputAction::GUI_UP, ChatTab::hasRows(), EmoteWindow::hide(), ifKey, inputManager, InputManager::isActionActive(), mChatHistoryIndex, mChatInput, mCurHist, mHistory, Widget::mVisible, ChatInput::processVisible(), TextField::setCaretPosition(), TextField::setText(), EmoteWindow::show(), KeyValue::TEXTINPUT, Catch::toLower(), Visible_false, and Visible_true.

◆ loadCommandsFile()

void ChatWindow::loadCommandsFile ( const std::string &  name)
private

Definition at line 242 of file chatwindow.cpp.

243 {
244  StringVect list;
245  VirtFs::loadTextFile(name, list);
246  StringVectCIter it = list.begin();
247  const StringVectCIter it_end = list.end();
248 
249  while (it != it_end)
250  {
251  const std::string str = *it;
252  if (!str.empty())
253  mCommands.push_back(str);
254  ++ it;
255  }
256 }
bool loadTextFile(const std::string &fileName, StringVect &lines)
Definition: tools.cpp:137

References VirtFs::loadTextFile(), and mCommands.

Referenced by fillCommands(), and loadGMCommands().

◆ loadCustomList()

void ChatWindow::loadCustomList ( )

Definition at line 1968 of file chatwindow.cpp.

1969 {
1970  std::ifstream listFile;
1971  struct stat statbuf;
1972 
1973  std::string listName = settings.serverConfigDir
1974  + "/customwords.txt";
1975 
1976  if ((stat(listName.c_str(), &statbuf) == 0) && S_ISREG(statbuf.st_mode))
1977  {
1978  listFile.open(listName.c_str(), std::ios::in);
1979  if (listFile.is_open())
1980  {
1981  char line[101];
1982  while (listFile.getline(line, 100))
1983  {
1984  std::string str = line;
1985  if (!str.empty())
1986  mCustomWords.push_back(str);
1987  }
1988  }
1989  listFile.close();
1990  }
1991 }

References mCustomWords, Settings::serverConfigDir, and settings.

Referenced by ChatWindow().

◆ loadGMCommands()

void ChatWindow::loadGMCommands ( )

Definition at line 264 of file chatwindow.cpp.

265 {
266  if (mGMLoaded)
267  return;
268 
269  loadCommandsFile("gmcommands.txt");
270  mGMLoaded = true;
271 }

References loadCommandsFile(), and mGMLoaded.

Referenced by ChatWindow(), and LocalPlayer::setGroupId().

◆ loadState()

void ChatWindow::loadState ( )

Definition at line 1888 of file chatwindow.cpp.

1889 {
1890  int num = 0;
1891  while (num < 50)
1892  {
1893  const std::string nick = serverConfig.getValue(
1894  "chatWhisper" + toString(num), "");
1895 
1896  if (nick.empty())
1897  break;
1898 
1899  ChatTab *const tab = addChatTab(nick, false, false);
1900  if (tab != nullptr)
1901  {
1902  const int flags = serverConfig.getValue(
1903  "chatWhisperFlags" + toString(num), 1);
1904 
1905  tab->setAllowHighlight((flags & 1) != 0);
1906  tab->setRemoveNames(((flags & 2) / 2) != 0);
1907  tab->setNoAway(((flags & 4) / 4) != 0);
1908  }
1909  num ++;
1910  }
1911 }
void setRemoveNames(const bool n)
Definition: chattab.h:167
void setNoAway(const bool n)
Definition: chattab.h:173
ChatTab * addChatTab(const std::string &name, const bool switchTo, const bool join)

References addChatTab(), ConfigurationObject::getValue(), serverConfig, ChatTab::setAllowHighlight(), ChatTab::setNoAway(), ChatTab::setRemoveNames(), and Catch::toString().

Referenced by createGuiWindows().

◆ localChatInput()

void ChatWindow::localChatInput ( const std::string &  msg) const

Passes the text to the local chat tab as input

Parameters
msgThe message text which is to be sent.

Definition at line 691 of file chatwindow.cpp.

692 {
693  if (localChatTab != nullptr)
695  else
696  chatInput(msg);
697 }

References ChatTab::chatInput(), chatInput(), localChatTab, and Actions::msg().

Referenced by WhoIsOnline::handleLink(), ActorManager::heal(), SpellManager::invokeCommand(), SpellManager::invokeSpell(), ActorManager::itenplz(), and LocalPlayer::tryMagic().

◆ mouseDragged()

void ChatWindow::mouseDragged ( MouseEvent event)
virtual

Handles mouse when dragged.

Reimplemented from Window.

Definition at line 799 of file chatwindow.cpp.

800 {
801  Window::mouseDragged(event);
802 
803  if (event.isConsumed())
804  return;
805 
806  if (canMove() && isMovable() && mMoved)
807  {
808  int newX = std::max(0, getX() + event.getX() - mDragOffsetX);
809  int newY = std::max(0, getY() + event.getY() - mDragOffsetY);
810  newX = std::min(mainGraphics->mWidth - getWidth(), newX);
811  newY = std::min(mainGraphics->mHeight - getHeight(), newY);
812  setPosition(newX, newY);
813  }
814 }
int mWidth
Definition: graphics.h:484
int mHeight
Definition: graphics.h:485
bool isConsumed() const
int getX() const
Definition: mouseevent.h:127
int getY() const
Definition: mouseevent.h:138
int getY() const
Definition: widget.h:288
int getX() const
Definition: widget.h:269
int mDragOffsetY
Definition: window.h:642
bool mMoved
Definition: window.h:647
void mouseDragged(MouseEvent &event)
Definition: window.cpp:982
int mDragOffsetX
Definition: window.h:635
bool canMove() const
Definition: window.cpp:977
bool isMovable() const
Definition: window.h:576

References Window::canMove(), Widget::getHeight(), Widget::getWidth(), MouseEvent::getX(), Widget::getX(), MouseEvent::getY(), Widget::getY(), InputGuiEvent::isConsumed(), Window::isMovable(), mainGraphics, Window::mDragOffsetX, Window::mDragOffsetY, Graphics::mHeight, Window::mMoved, Window::mouseDragged(), Graphics::mWidth, and Widget::setPosition().

◆ mouseEntered()

void ChatWindow::mouseEntered ( MouseEvent event)
virtual

Called when the mouse has entered into the widget area.

Parameters
eventDescribes the event.

Reimplemented from Window.

Definition at line 2082 of file chatwindow.cpp.

2083 {
2084  mHaveMouse = true;
2085  Window::mouseEntered(event);
2086 }
void mouseEntered(MouseEvent &event)
Definition: window.cpp:919

References mHaveMouse, and Window::mouseEntered().

◆ mouseExited()

void ChatWindow::mouseExited ( MouseEvent event)
virtual

When the mouse leaves the window this ensures that the custom cursor is restored back to it's standard image.

Reimplemented from Window.

Definition at line 2088 of file chatwindow.cpp.

2089 {
2090  updateVisibility();
2091  Window::mouseExited(event);
2092 }
void updateVisibility()
void mouseExited(MouseEvent &event)
Definition: window.cpp:924

References Window::mouseExited(), and updateVisibility().

◆ mouseMoved()

void ChatWindow::mouseMoved ( MouseEvent event)
virtual

Implements custom cursor image changing context, based on mouse relative position.

Reimplemented from Window.

Definition at line 2076 of file chatwindow.cpp.

2077 {
2078  mHaveMouse = true;
2079  Window::mouseMoved(event);
2080 }
void mouseMoved(MouseEvent &event)
Definition: window.cpp:967

References mHaveMouse, and Window::mouseMoved().

◆ mousePressed()

void ChatWindow::mousePressed ( MouseEvent event)
virtual

Handles mouse when pressed.

Reimplemented from Window.

Definition at line 743 of file chatwindow.cpp.

744 {
745  if (event.isConsumed())
746  return;
747 
748  if (event.getButton() == MouseButton::RIGHT)
749  {
750  if (popupMenu != nullptr)
751  {
752  ChatTab *const cTab = dynamic_cast<ChatTab*>(
754  if (cTab != nullptr)
755  {
756  event.consume();
758  {
761  std::string(), cTab);
762  }
763  else
764  {
766  viewport->mMouseY,
767  cTab);
768  }
769  }
770  }
771  }
772 
773  Window::mousePressed(event);
774 
775  if (event.isConsumed())
776  return;
777 
778  if (event.getButton() == MouseButton::LEFT)
779  {
780  const int clicks = event.getClickCount();
781  if (clicks == 2)
782  {
783  toggleChatFocus();
784  if (gui != nullptr)
785  gui->resetClickCount();
786  }
787  else if (clicks == 1)
788  {
789  const ChatTab *const tab = getFocused();
790  if (tab != nullptr)
791  mMoved = !isResizeAllowed(event);
792  }
793  }
794 
795  mDragOffsetX = event.getX();
796  mDragOffsetY = event.getY();
797 }
void toggleChatFocus()
void resetClickCount()
Definition: gui.cpp:980
bool executeChatCommand(const std::string &cmd, const std::string &args, ChatTab *const tab)
bool isActionActive(const InputActionT index) const
MouseButtonT getButton() const
Definition: mouseevent.h:116
void showChatPopup(const int x, const int y, ChatTab *const tab)
Definition: popupmenu.cpp:913
int mMouseX
Definition: viewport.h:154
int mMouseY
Definition: viewport.h:155
bool isResizeAllowed(const MouseEvent &event) const
Definition: window.cpp:1345
void mousePressed(MouseEvent &event)
Definition: window.cpp:836
Viewport * viewport
Definition: viewport.cpp:36
PopupMenu * popupMenu
Definition: popupmenu.cpp:103

References InputAction::CHAT_MOD, InputAction::CLOSE_CHAT_TAB, InputManager::executeChatCommand(), MouseEvent::getButton(), getFocused(), TabbedArea::getSelectedTab(), gui, inputManager, InputManager::isActionActive(), InputGuiEvent::isConsumed(), Window::isResizeAllowed(), MouseButton::LEFT, mChatTabs, Window::mDragOffsetX, Window::mDragOffsetY, Viewport::mMouseX, Viewport::mMouseY, Window::mMoved, Window::mousePressed(), popupMenu, Gui::resetClickCount(), MouseButton::RIGHT, PopupMenu::showChatPopup(), toggleChatFocus(), and viewport.

◆ nextTab()

void ChatWindow::nextTab ( )

Switch to the next tab in order

Definition at line 387 of file chatwindow.cpp.

388 {
389  if (mChatTabs == nullptr)
390  return;
391 
392  int tab = mChatTabs->getSelectedTabIndex();
393 
394  tab++;
395  if (tab == mChatTabs->getNumberOfTabs())
396  tab = 0;
397 
399 }
int getNumberOfTabs() const
Definition: tabbedarea.cpp:169

References TabbedArea::getNumberOfTabs(), TabbedArea::getSelectedTabIndex(), mChatTabs, and TabbedArea::setSelectedTabByIndex().

◆ optionChanged()

void ChatWindow::optionChanged ( const std::string &  name)
virtual

Called when an option changed. The config listener will have to be registered to the option name first.

Implements ConfigListener.

Definition at line 2064 of file chatwindow.cpp.

2065 {
2066  if (name == "autohideChat")
2067  mAutoHide = config.getBoolValue("autohideChat");
2068  else if (name == "showBattleEvents")
2069  mShowBattleEvents = config.getBoolValue("showBattleEvents");
2070  else if (name == "globalsFilter")
2072  else if (name == "enableTradeFilter")
2073  mEnableTradeFilter = config.getBoolValue("enableTradeFilter");
2074 }

References config, Configuration::getBoolValue(), mAutoHide, mEnableTradeFilter, mShowBattleEvents, and parseGlobalsFilter().

◆ parseGlobalsFilter()

void ChatWindow::parseGlobalsFilter ( )

Definition at line 2033 of file chatwindow.cpp.

2034 {
2035  mGlobalsFilter.clear();
2036  if (localPlayer == nullptr)
2037  return;
2038 
2040  "globalsFilter"), ',');
2041 
2042  mHighlights.push_back(localPlayer->getName());
2043 }
std::string getStringValue(const std::string &key) const
void splitToStringVector(StringVect &tokens, const std::string &text, const char separator)

References config, Being::getName(), Configuration::getStringValue(), localPlayer, mGlobalsFilter, mHighlights, and splitToStringVector().

Referenced by ChatWindow(), and optionChanged().

◆ parseHighlights()

void ChatWindow::parseHighlights ( )

Definition at line 2021 of file chatwindow.cpp.

2022 {
2023  mHighlights.clear();
2024  if (localPlayer == nullptr)
2025  return;
2026 
2028  "highlightWords"), ',');
2029 
2030  mHighlights.push_back(localPlayer->getName());
2031 }

References config, Being::getName(), Configuration::getStringValue(), localPlayer, mHighlights, and splitToStringVector().

Referenced by Setup_Chat::apply(), and ChatWindow().

◆ postConnection()

void ChatWindow::postConnection ( )

Definition at line 1359 of file chatwindow.cpp.

1360 {
1361  FOR_EACH (ChannelMap::const_iterator, iter, mChannels)
1362  {
1363  ChatTab *const tab = iter->second;
1364  if (tab == nullptr)
1365  return;
1367  }
1368  if (langChatTab != nullptr)
1370 }
LangTab * langChatTab
Definition: langtab.cpp:28

References chatHandler, FOR_EACH, ChatTab::getChannelName(), Net::ChatHandler::joinChannel(), langChatTab, and mChannels.

Referenced by Game::Game().

◆ postInit()

void ChatWindow::postInit ( )
virtual

Reimplemented from Window.

Definition at line 232 of file chatwindow.cpp.

233 {
235  add(mChatTabs);
236  add(mChatInput);
237  add(mColorPicker);
238  add(mChatButton);
240 }
virtual void add(Widget *const widget)
void postInit()
Definition: window.cpp:249

References BasicContainer2::add(), mChatButton, mChatInput, mChatTabs, mColorPicker, Window::postInit(), and updateVisibility().

◆ prevTab()

void ChatWindow::prevTab ( )

Switch to the previous tab in order

Definition at line 373 of file chatwindow.cpp.

374 {
375  if (mChatTabs == nullptr)
376  return;
377 
378  int tab = mChatTabs->getSelectedTabIndex();
379 
380  if (tab <= 0)
381  tab = mChatTabs->getNumberOfTabs();
382  tab--;
383 
385 }

References TabbedArea::getNumberOfTabs(), TabbedArea::getSelectedTabIndex(), mChatTabs, and TabbedArea::setSelectedTabByIndex().

◆ removeAllChannels()

void ChatWindow::removeAllChannels ( )

Definition at line 629 of file chatwindow.cpp.

630 {
631  std::list<ChatTab*> tabs;
632 
633  FOR_EACH (ChannelMap::iterator, iter, mChannels)
634  tabs.push_back(iter->second);
635 
636  for (std::list<ChatTab*>::iterator it = tabs.begin();
637  it != tabs.end(); ++it)
638  {
639  delete *it;
640  }
641 
642  mChannels.clear();
643 }

References FOR_EACH, and mChannels.

Referenced by ~ChatWindow().

◆ removeAllWhispers()

void ChatWindow::removeAllWhispers ( )

Definition at line 613 of file chatwindow.cpp.

614 {
615  std::list<ChatTab*> tabs;
616 
617  FOR_EACH (TabMap::iterator, iter, mWhispers)
618  tabs.push_back(iter->second);
619 
620  for (std::list<ChatTab*>::iterator it = tabs.begin();
621  it != tabs.end(); ++it)
622  {
623  delete *it;
624  }
625 
626  mWhispers.clear();
627 }

References FOR_EACH, and mWhispers.

Referenced by ~ChatWindow().

◆ removeChannel()

void ChatWindow::removeChannel ( const std::string &  nick)
protected

Definition at line 605 of file chatwindow.cpp.

606 {
607  std::string tempName = name;
608  toLower(tempName);
609  mChannels.erase(tempName);
610  chatHandler->partChannel(name);
611 }
virtual void partChannel(const std::string &channel) const =0

References chatHandler, mChannels, Net::ChatHandler::partChannel(), and Catch::toLower().

Referenced by ChannelTab::~ChannelTab().

◆ removeTab()

void ChatWindow::removeTab ( ChatTab *const  tab)
protected

Remove the given tab from the window

Definition at line 584 of file chatwindow.cpp.

585 {
586  mChatTabs->removeTab(tab);
587 }
void removeTab(Tab *const tab)
Definition: tabbedarea.cpp:323

References mChatTabs, and TabbedArea::removeTab().

Referenced by ChatTab::~ChatTab().

◆ removeWhisper()

void ChatWindow::removeWhisper ( const std::string &  nick)
protected

Definition at line 598 of file chatwindow.cpp.

599 {
600  std::string tempNick = nick;
601  toLower(tempNick);
602  mWhispers.erase(tempNick);
603 }

References mWhispers, and Catch::toLower().

Referenced by WhisperTab::~WhisperTab().

◆ requestChatFocus()

bool ChatWindow::requestChatFocus ( )

Request focus for typing chat message.

Returns
true if the input was shown false otherwise

Definition at line 553 of file chatwindow.cpp.

554 {
555  // Make sure chatWindow is visible
556  if (!isWindowVisible())
557  {
559 
560  /*
561  * This is used to hide chatWindow after sending the message. There is
562  * a trick here, because setVisible will set mTmpVisible to false, you
563  * have to put this sentence *after* setVisible, not before it
564  */
565  mTmpVisible = true;
566  }
567 
568  // Don't do anything else if the input is already visible and has focus
570  return false;
571 
572  // Give focus to the chat input
574  unHideWindow();
576  return true;
577 }
void unHideWindow()
virtual void requestFocus()
Definition: widget.cpp:204
bool isVisible() const
Definition: widget.h:378
bool isWindowVisible() const
Definition: window.h:484

References Widget::isFocused(), Widget::isVisible(), Window::isWindowVisible(), mChatInput, mTmpVisible, ChatInput::processVisible(), Widget::requestFocus(), setVisible(), unHideWindow(), and Visible_true.

Referenced by addInputText(), and toggleChatFocus().

◆ resortChatLog()

bool ChatWindow::resortChatLog ( std::string  line,
ChatMsgTypeT  own,
const std::string &  channel,
const IgnoreRecord  ignoreRecord,
const TryRemoveColors  tryRemoveColors 
)

Definition at line 1600 of file chatwindow.cpp.

1605 {
1606  if (own == ChatMsgType::BY_UNKNOWN)
1607  {
1608  const size_t pos = line.find(" : ");
1609  if (pos != std::string::npos)
1610  {
1611  if (line.length() <= pos + 3)
1612  own = ChatMsgType::BY_SERVER;
1613  else if (line.substr(0, pos) == localPlayer->getName())
1614  own = ChatMsgType::BY_PLAYER;
1615  else
1616  own = ChatMsgType::BY_OTHER;
1617  }
1618  else
1619  {
1620  own = ChatMsgType::BY_SERVER;
1621  }
1622  }
1623 
1624  std::string prefix;
1625  if (!channel.empty())
1626  {
1627  prefix = std::string("##3").append(channel).append("##0");
1628  }
1629  else if (mEnableTradeFilter &&
1630  (tradeChatTab != nullptr) &&
1631  findI(line, mTradeFilter) != std::string::npos)
1632  {
1633  // TRANSLATORS: prefix for moved message to trade tab.
1634  tradeChatTab->chatLog(std::string("##S") + _("Moved: ") + line,
1635  own,
1636  ignoreRecord,
1637  tryRemoveColors);
1638  if (own == ChatMsgType::BY_PLAYER)
1639  {
1640  own = ChatMsgType::BY_SERVER;
1641  // TRANSLATORS: moved message to trade tab warning.
1642  line = _("Your message was moved to trade tab");
1643  }
1644  else
1645  {
1646  return false;
1647  }
1648  }
1649 
1650  size_t idx2 = line.find(": ");
1651  if (idx2 != std::string::npos)
1652  {
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] == '/' ||
1661  tmpNick[0] == '!'
1662  )
1663  {
1664  replaceAll(tmpNick, "#", "_");
1665  replaceAll(tmpNick, "%", "_");
1666  // TRANSLATORS: error message
1667  line = _("Broken nick detected: ") + line;
1668  own = ChatMsgType::BY_SERVER;
1669  }
1670  const size_t idx = line.find(": \302\202");
1671  if (idx == idx2)
1672  {
1673  if (line.find(": \302\202\302") != std::string::npos)
1674  {
1675  if (line.find(": \302\202\302e") != std::string::npos)
1676  {
1677  // Do nothing. Before was local pet emote
1678  }
1679  else if (line.find(": \302\202\302m") != std::string::npos)
1680  {
1681  // Do nothing. Before was local pet move
1682  }
1683  else if (line.find(": \302\202\302d") != std::string::npos)
1684  {
1685  // Do nothing. Before was local pet direction
1686  }
1687  else if (line.find(": \302\202\302a") != std::string::npos)
1688  {
1689  // Do nothing. Before was local pet ai enable/disable
1690  }
1691  // ignore other special message formats.
1692  return false;
1693  }
1694 
1695  // pet talk message detected
1696  if (line.find(": \302\202\303 ") != std::string::npos)
1697  {
1698  // Do nothing. Before was local pet talk
1699  return false;
1700  }
1701  if (line.find(": \302\202\304") != std::string::npos)
1702  {
1703  replaceAll(line, ": \302\202\304", ": ");
1704  }
1705 
1706  if (tradeChatTab != nullptr)
1707  {
1708  line = line.erase(idx + 2, 2);
1709  tradeChatTab->chatLog(prefix + line,
1710  own,
1711  ignoreRecord,
1712  tryRemoveColors);
1713  }
1714  else if (localChatTab != nullptr)
1715  {
1716  line = line.erase(idx + 2, 2);
1717  localChatTab->chatLog(prefix + line,
1718  own,
1719  ignoreRecord,
1720  tryRemoveColors);
1721  }
1722  return false;
1723  }
1724  }
1725 
1726  if (!channel.empty())
1727  {
1728  if (langChatTab != nullptr)
1729  {
1730  if (langChatTab->getChannelName() == channel)
1731  {
1732  langChatTab->chatLog(line,
1733  own,
1734  ignoreRecord,
1735  tryRemoveColors);
1736  }
1737  else if (mShowAllLang)
1738  {
1739  langChatTab->chatLog(prefix + line,
1740  own,
1741  ignoreRecord,
1742  tryRemoveColors);
1743  }
1744  }
1746  {
1747  channelChatLog(channel, line, own, ignoreRecord, tryRemoveColors);
1748  return false;
1749  }
1750  else if (mShowAllLang)
1751  {
1752  localChatTab->chatLog(prefix + line,
1753  own,
1754  ignoreRecord,
1755  tryRemoveColors);
1756  }
1757  }
1758  else if (localChatTab != nullptr)
1759  {
1760  localChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
1761  }
1762  return true;
1763 }
void channelChatLog(const std::string &channel, const std::string &line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
std::string & replaceAll(std::string &context, const std::string &from, const std::string &to)

References _, ChatMsgType::BY_OTHER, ChatMsgType::BY_PLAYER, ChatMsgType::BY_SERVER, ChatMsgType::BY_UNKNOWN, channelChatLog(), ChatTab::chatLog(), findI(), ChatTab::getChannelName(), Being::getName(), Net::getNetworkType(), langChatTab, localChatTab, localPlayer, mEnableTradeFilter, mShowAllLang, mTradeFilter, replaceAll(), ServerType::TMWATHENA, and tradeChatTab.

Referenced by EAthena::ChatRecv::processBeingChat(), TmwAthena::ChatRecv::processBeingChat(), TmwAthena::ChatRecv::processChatContinue(), and EAthena::ChatRecv::processChatContinue().

◆ safeDraw()

void ChatWindow::safeDraw ( Graphics *const  graphics)
virtual

Reimplemented from Window.

Definition at line 2106 of file chatwindow.cpp.

2107 {
2108  BLOCK_START("ChatWindow::draw")
2109  if (!mAutoHide || mHaveMouse)
2110  {
2111  GLDEBUG_START("ChatWindow::draw");
2112  Window::safeDraw(graphics);
2113  GLDEBUG_END();
2114  }
2115  BLOCK_END("ChatWindow::draw")
2116 }
void safeDraw(Graphics *const graphics)
Definition: window.cpp:423

References BLOCK_END, BLOCK_START, GLDEBUG_END, GLDEBUG_START, mAutoHide, mHaveMouse, and Window::safeDraw().

◆ saveState()

void ChatWindow::saveState ( ) const

Definition at line 1913 of file chatwindow.cpp.

1914 {
1915  int num = 0;
1916  for (ChannelMap::const_iterator iter = mChannels.begin(),
1917  iter_end = mChannels.end(); iter != iter_end && num < 50; ++iter)
1918  {
1919  if (iter->second == nullptr)
1920  return;
1921  if (!saveTab(num, iter->second))
1922  continue;
1923  num ++;
1924  }
1925 
1926  for (TabMap::const_iterator iter = mWhispers.begin(),
1927  iter_end = mWhispers.end(); iter != iter_end && num < 50; ++iter)
1928  {
1929  if (iter->second == nullptr)
1930  return;
1931  if (!saveTab(num, iter->second))
1932  continue;
1933  num ++;
1934  }
1935 
1936  while (num < 50)
1937  {
1938  serverConfig.deleteKey("chatWhisper" + toString(num));
1939  serverConfig.deleteKey("chatWhisperFlags" + toString(num));
1940  num ++;
1941  }
1942 }
static bool saveTab(const int num, const ChatTab *const tab)
void deleteKey(const std::string &key)

References ConfigurationObject::deleteKey(), mChannels, mWhispers, saveTab(), serverConfig, and Catch::toString().

Referenced by SetupWindow::action(), addWhisper(), channelChatLog(), AvatarListBox::mousePressed(), and ~ChatWindow().

◆ saveTab()

bool ChatWindow::saveTab ( const int  num,
const ChatTab *const  tab 
)
static

Definition at line 1944 of file chatwindow.cpp.

1946 {
1947  if (tab == nullptr)
1948  return false;
1949 
1950  serverConfig.setValue("chatWhisper" + toString(num),
1951  tab->getChannelName());
1952 
1953  serverConfig.setValue("chatWhisperFlags" + toString(num),
1954  CAST_S32(tab->getAllowHighlight())
1955  + (2 * CAST_S32(tab->getRemoveNames()))
1956  + (4 * CAST_S32(tab->getNoAway())));
1957 
1958  return true;
1959 }
bool getAllowHighlight() const
Definition: chattab.h:158
bool getNoAway() const
Definition: chattab.h:170

References CAST_S32, ChatTab::getAllowHighlight(), ChatTab::getChannelName(), ChatTab::getNoAway(), ChatTab::getRemoveNames(), serverConfig, Configuration::setValue(), and Catch::toString().

Referenced by saveState().

◆ scheduleDelete()

void ChatWindow::scheduleDelete ( )
virtual

Schedule this window for deletion. It will be deleted at the start of the next logic update.

Reimplemented from Window.

Definition at line 2226 of file chatwindow.cpp.

2227 {
2230 }
static void removeListener(const DebugMessageListener *const listener)
virtual void scheduleDelete()
Definition: window.cpp:831

References DebugMessageListener::removeListener(), and Window::scheduleDelete().

Referenced by createGuiWindows(), and WindowManager::createWindows().

◆ scroll()

void ChatWindow::scroll ( const int  amount) const

Scrolls the chat window

Parameters
amountdirection and amount to scroll. Negative numbers scroll up, positive numbers scroll down. The absolute amount indicates the amount of 1/8ths of chat window real estate that should be scrolled.

Definition at line 733 of file chatwindow.cpp.

734 {
735  if (!isWindowVisible())
736  return;
737 
738  ChatTab *const tab = getFocused();
739  if (tab != nullptr)
740  tab->scroll(amount);
741 }
void scroll(const int amount)
Definition: chattab.cpp:419

References getFocused(), Window::isWindowVisible(), and ChatTab::scroll().

◆ selectTabByType()

void ChatWindow::selectTabByType ( const ChatTabTypeT type)

Definition at line 401 of file chatwindow.cpp.

402 {
403  if (mChatTabs == nullptr)
404  return;
405 
406  int sz = mChatTabs->getNumberOfTabs();
407  for (int f = 0; f < sz; f ++)
408  {
409  ChatTab *const tab = dynamic_cast<ChatTab*>(
411  if ((tab != nullptr) && tab->getType() == type)
412  {
414  break;
415  }
416  }
417 }

References TabbedArea::getNumberOfTabs(), TabbedArea::getTabByIndex(), ChatTab::getType(), mChatTabs, and TabbedArea::setSelectedTab().

◆ setInputText()

void ChatWindow::setInputText ( const std::string &  text)

Set the chat input as the given text.

◆ setRecordingFile()

void ChatWindow::setRecordingFile ( const std::string &  msg)

Sets the file being recorded to

Parameters
msgThe file to write out to. If null, then stop recording.

◆ setReturnTogglesChat()

void ChatWindow::setReturnTogglesChat ( const bool  toggles)
inline

Definition at line 187 of file chatwindow.h.

188  { mReturnToggles = toggles; }

References mReturnToggles.

◆ setVisible()

void ChatWindow::setVisible ( Visible  visible)
virtual

Override to reset mTmpVisible

Reimplemented from Window.

Definition at line 1106 of file chatwindow.cpp.

1107 {
1108  Window::setVisible(visible);
1109 
1110  /*
1111  * For whatever reason, if setVisible is called, the mTmpVisible effect
1112  * should be disabled.
1113  */
1114  mTmpVisible = false;
1115 }
virtual void setVisible(Visible visible)
Definition: window.cpp:778

References mTmpVisible, and Window::setVisible().

Referenced by action(), WindowManager::createWindows(), and requestChatFocus().

◆ showGMTab()

void ChatWindow::showGMTab ( )

Definition at line 2189 of file chatwindow.cpp.

2190 {
2191  if ((gmChatTab == nullptr) &&
2192  config.getBoolValue("enableGmTab") &&
2193  localPlayer->getGroupId() >= paths.getIntValue("gmTabMinimalLevel"))
2194  {
2196  }
2197 }
int getGroupId() const
Definition: being.h:1087
Configuration paths

References addSpecialChannelTab(), config, Configuration::getBoolValue(), Being::getGroupId(), Configuration::getIntValue(), GM_CHANNEL, gmChatTab, localPlayer, and paths.

Referenced by createGuiWindows(), and LocalPlayer::setGroupId().

◆ toggleChatFocus()

void ChatWindow::toggleChatFocus ( )
protected

◆ unHideWindow()

void ChatWindow::unHideWindow ( )

Definition at line 2140 of file chatwindow.cpp.

2141 {
2142  mHaveMouse = true;
2143 }

References mHaveMouse.

Referenced by ChatTab::chatLog(), and requestChatFocus().

◆ updateOnline()

void ChatWindow::updateOnline ( const std::set< std::string > &  onlinePlayers) const

Definition at line 1830 of file chatwindow.cpp.

1831 {
1832  const Party *party = nullptr;
1833  const Guild *guild = nullptr;
1834  if (localPlayer != nullptr)
1835  {
1836  party = localPlayer->getParty();
1837  guild = localPlayer->getGuild();
1838  }
1839  FOR_EACH (TabMap::const_iterator, iter, mWhispers)
1840  {
1841  if (iter->second == nullptr)
1842  return;
1843 
1844  WhisperTab *const tab = static_cast<WhisperTab*>(iter->second);
1845  if (tab == nullptr)
1846  continue;
1847 
1848  if (onlinePlayers.find(tab->getNick()) != onlinePlayers.end())
1849  {
1850  tab->setWhisperTabColors();
1851  }
1852  else
1853  {
1854  const std::string &nick = tab->getNick();
1855  if (actorManager != nullptr)
1856  {
1857  const Being *const being = actorManager->findBeingByName(
1858  nick, ActorType::Player);
1859  if (being != nullptr)
1860  {
1861  tab->setWhisperTabColors();
1862  continue;
1863  }
1864  }
1865  if (party != nullptr)
1866  {
1867  const PartyMember *const pm = party->getMember(nick);
1868  if ((pm != nullptr) && pm->getOnline())
1869  {
1870  tab->setWhisperTabColors();
1871  continue;
1872  }
1873  }
1874  if (guild != nullptr)
1875  {
1876  const GuildMember *const gm = guild->getMember(nick);
1877  if ((gm != nullptr) && gm->getOnline())
1878  {
1879  tab->setWhisperTabColors();
1880  continue;
1881  }
1882  }
1884  }
1885  }
1886 }
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
bool getOnline() const
Definition: avatar.h:81
Party * getParty() const
Definition: being.h:330
const Guild * getGuild(const std::string &guildName) const
Definition: being.cpp:1258
Definition: guild.h:70
Definition: party.h:63
void setWhisperTabOfflineColors()
Definition: whispertab.cpp:128
void setWhisperTabColors()
Definition: whispertab.cpp:123
uint32_t guild
uint32_t party
bool gm(InputEvent &event)
Definition: commands.cpp:75

References actorManager, ActorManager::findBeingByName(), FOR_EACH, Being::getGuild(), WhisperTab::getNick(), Avatar::getOnline(), Being::getParty(), Actions::gm(), guild, localPlayer, mWhispers, party, ActorType::Player, WhisperTab::setWhisperTabColors(), and WhisperTab::setWhisperTabOfflineColors().

Referenced by WhoIsOnline::loadList(), and WhoIsOnline::slowLogic().

◆ updateTabsMargin()

void ChatWindow::updateTabsMargin ( )
private

Definition at line 273 of file chatwindow.cpp.

274 {
277  else
279 }
void setRightMargin(const int n)
Definition: tabbedarea.h:205

References Widget::getWidth(), mChatTabs, mColorPicker, Widget::mVisible, TabbedArea::setRightMargin(), and Visible_true.

Referenced by adjustTabSize(), and ChatWindow().

◆ updateVisibility()

void ChatWindow::updateVisibility ( )

Definition at line 2118 of file chatwindow.cpp.

2119 {
2120  if (gui == nullptr)
2121  return;
2122 
2123  int mouseX = 0;
2124  int mouseY = 0;
2125  int x = 0;
2126  int y = 0;
2127  Gui::getMouseState(mouseX, mouseY);
2129  if (mChatInput->isVisible())
2130  {
2131  mHaveMouse = true;
2132  }
2133  else
2134  {
2135  mHaveMouse = mouseX >= x && mouseX <= x + getWidth()
2136  && mouseY >= y && mouseY <= y + getHeight();
2137  }
2138 }
static uint8_t getMouseState(int &x, int &y)
Definition: gui.cpp:1171
virtual void getAbsolutePosition(int &x, int &y) const
Definition: widget.cpp:312

References Widget::getAbsolutePosition(), Widget::getHeight(), Gui::getMouseState(), Widget::getWidth(), gui, Widget::isVisible(), mChatInput, mHaveMouse, x, and y.

Referenced by ChatInput::focusLost(), mouseExited(), and postInit().

◆ widgetResized()

void ChatWindow::widgetResized ( const Event event)
virtual

Called whenever the widget changes size.

Reimplemented from Window.

Definition at line 350 of file chatwindow.cpp.

351 {
352  Window::widgetResized(event);
353 
354  adjustTabSize();
355 }
void adjustTabSize()
Definition: chatwindow.cpp:281
void widgetResized(const Event &event)
Definition: window.cpp:655

References adjustTabSize(), and Window::widgetResized().

Friends And Related Function Documentation

◆ ChannelTab

friend class ChannelTab
friend

Definition at line 311 of file chatwindow.h.

Referenced by addChannelTab().

◆ ChatTab

friend class ChatTab
friend

Definition at line 312 of file chatwindow.h.

◆ PopupMenu

friend class PopupMenu
friend

Definition at line 314 of file chatwindow.h.

◆ WhisperTab

friend class WhisperTab
friend

Definition at line 313 of file chatwindow.h.

Referenced by addWhisperTab().

Field Documentation

◆ mAutoHide

bool ChatWindow::mAutoHide
private

Definition at line 396 of file chatwindow.h.

Referenced by draw(), optionChanged(), and safeDraw().

◆ mAwayLog

std::list<std::string> ChatWindow::mAwayLog
private

Definition at line 385 of file chatwindow.h.

Referenced by addToAwayLog(), clearAwayLog(), and displayAwayLog().

◆ mChannels

ChannelMap ChatWindow::mChannels
private

◆ mChatButton

Button* ChatWindow::mChatButton
private

Definition at line 384 of file chatwindow.h.

Referenced by adjustTabSize(), ChatWindow(), and postInit().

◆ mChatColor

int ChatWindow::mChatColor
private

Definition at line 388 of file chatwindow.h.

Referenced by action(), addColors(), and ChatWindow().

◆ mChatHistoryIndex

unsigned int ChatWindow::mChatHistoryIndex
private

Definition at line 391 of file chatwindow.h.

Referenced by keyPressed().

◆ mChatInput

ChatInput* ChatWindow::mChatInput
protected

◆ mChatTabs

TabbedArea* ChatWindow::mChatTabs
protected

◆ mColorListModel

ColorListModel* ChatWindow::mColorListModel
private

Definition at line 382 of file chatwindow.h.

Referenced by ~ChatWindow().

◆ mColorPicker

DropDown* ChatWindow::mColorPicker
private

Definition at line 383 of file chatwindow.h.

Referenced by action(), adjustTabSize(), ChatWindow(), postInit(), updateTabsMargin(), and ~ChatWindow().

◆ mCommands

History ChatWindow::mCommands
private

Command list.

Definition at line 377 of file chatwindow.h.

Referenced by autoComplete(), fillCommands(), and loadCommandsFile().

◆ mCurHist

HistoryIterator ChatWindow::mCurHist
private

History iterator.

Definition at line 373 of file chatwindow.h.

Referenced by action(), ChatWindow(), and keyPressed().

◆ mCustomWords

History ChatWindow::mCustomWords
private

Definition at line 378 of file chatwindow.h.

Referenced by autoComplete(), and loadCustomList().

◆ mEmoteButtonSpacing

int ChatWindow::mEmoteButtonSpacing
private

Definition at line 389 of file chatwindow.h.

Referenced by adjustTabSize().

◆ mEmoteButtonY

int ChatWindow::mEmoteButtonY
private

Definition at line 390 of file chatwindow.h.

Referenced by adjustTabSize().

◆ mEnableTradeFilter

bool ChatWindow::mEnableTradeFilter
private

Definition at line 399 of file chatwindow.h.

Referenced by optionChanged(), and resortChatLog().

◆ mGlobalsFilter

StringVect ChatWindow::mGlobalsFilter
private

Definition at line 387 of file chatwindow.h.

Referenced by addGlobalMessage(), and parseGlobalsFilter().

◆ mGMLoaded

bool ChatWindow::mGMLoaded
private

Definition at line 394 of file chatwindow.h.

Referenced by loadGMCommands().

◆ mHaveMouse

bool ChatWindow::mHaveMouse
private

Definition at line 395 of file chatwindow.h.

Referenced by draw(), mouseEntered(), mouseMoved(), safeDraw(), unHideWindow(), and updateVisibility().

◆ mHighlights

StringVect ChatWindow::mHighlights
private

Definition at line 386 of file chatwindow.h.

Referenced by addToAwayLog(), findHighlight(), parseGlobalsFilter(), and parseHighlights().

◆ mHistory

History ChatWindow::mHistory
private

Command history.

Definition at line 372 of file chatwindow.h.

Referenced by action(), addCurrentToHistory(), autoCompleteHistory(), ChatWindow(), and keyPressed().

◆ mItemLinkHandler

ItemLinkHandler* ChatWindow::mItemLinkHandler
protected

Used for showing item popup on clicking links

Definition at line 341 of file chatwindow.h.

Referenced by ChatTab::ChatTab(), ChatWindow(), and ~ChatWindow().

◆ mRainbowColor

unsigned int ChatWindow::mRainbowColor
protected

Definition at line 353 of file chatwindow.h.

Referenced by addColors().

◆ mReturnToggles

bool ChatWindow::mReturnToggles
private

Definition at line 392 of file chatwindow.h.

Referenced by action(), getReturnTogglesChat(), setReturnTogglesChat(), and ~ChatWindow().

◆ mShowAllLang

bool ChatWindow::mShowAllLang
private

Definition at line 398 of file chatwindow.h.

Referenced by resortChatLog().

◆ mShowBattleEvents

bool ChatWindow::mShowBattleEvents
private

Definition at line 397 of file chatwindow.h.

Referenced by attributeChanged(), and optionChanged().

◆ mTmpVisible

bool ChatWindow::mTmpVisible
private

Definition at line 400 of file chatwindow.h.

Referenced by action(), requestChatFocus(), and setVisible().

◆ mTradeFilter

StringVect ChatWindow::mTradeFilter
private

Definition at line 380 of file chatwindow.h.

Referenced by initTradeFilter(), and resortChatLog().

◆ mWhispers

TabMap ChatWindow::mWhispers
private

The documentation for this class was generated from the following files: