Planeshift
chatwindow.h
Go to the documentation of this file.
1 /*
2  * chatwindow.h - Author: Andrew Craig
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 // chatwindow.h: interface for the pawsChatWindow class.
21 //
23 
24 #ifndef PAWS_CHAT_WINDOW
25 #define PAWS_CHAT_WINDOW
26 
27 // CS INCLUDES
28 #include <csutil/array.h>
29 #include <csutil/redblacktree.h>
30 #include <csutil/hashr.h>
31 
32 #include "net/cmdbase.h"
33 #include "util/stringarray.h"
34 
35 // Hunspell includes
36 #ifdef HUNSPELL
37 #include <hunspell.hxx>
38 #endif
39 
40 // PAWS INCLUDES
41 #include "paws/pawswidget.h"
42 #include "paws/pawsmenu.h"
43 #include "gui/pawsignore.h"
44 #include "gui/pawscontrolwindow.h"
45 
46 #define CONFIG_CHAT_FILE_NAME "/planeshift/userdata/options/chat.xml"
47 #define CONFIG_CHAT_FILE_NAME_DEF "/planeshift/data/options/chat_def.xml"
48 
57 };
58 
59 class pawsMessageTextBox;
60 //class pawsEditTextBox;
61 class pawsChatHistory;
62 class pawsTabWindow;
63 //struct iSoundManager;
64 
67 {
70  int chatColor;
73  int npcColor;
74  int tellColor;
79  int gmColor;
80  int yourColor;
83  int helpColor;
87  bool mouseFocus;
95  bool mainBrackets;
96  bool yourColorMix;
97  csArray<csString> badWords;
99  csArray<csString> goodWords;
100  csArray<csString> completionItems;
101  csHash<csString, csString> bindings;
103  csArray<csString> subNames;
106  int meFilters;
107  unsigned int tabSetting;
108 
114  void SetLogChannelFile(unsigned int type, csString newName)
115  {
116  if(type < CHAT_END && newName != logChannelFile[type])
117  {
118  dirtyLogChannelFile[type] = true;
119  logChannelFile[type] = newName;
120  }
121  }
122 };
123 
124 
125 //--------------------------------------------------------------------------
126 
127 
134 {
135 public:
136  pawsChatWindow();
137  virtual ~pawsChatWindow();
138 
141  void HandleMessage( MsgEntry* message );
142 
145  const char* HandleCommand( const char* cmd );
146 
147  bool OnMenuAction(pawsWidget * widget, const pawsMenuAction & action);
148  bool PostSetup();
149 
150  bool OnChildMouseEnter(pawsWidget* widget);
151  bool OnChildMouseExit(pawsWidget* widget);
152 
153  bool OnMouseDown( int button, int modifiers, int x , int y );
154 
155  bool OnKeyDown( utf32_char keyCode, utf32_char key, int modifiers );
156 
165  bool OnDoubleClick(int button, int modifiers, int x , int y) { return OnMouseDown(button, modifiers, x, y); }
166 
170  bool InputActive();
171 
172  virtual bool OnButtonPressed( int button, int keyModifier, pawsWidget* widget );
173  void SwitchChannel(const csString &name, pawsWidget* widget = NULL);
174 
175  void PerformAction( const char* action );
176 
178  void Clear(int mode = -2); // -2 means "/clear all"
179 
180  void SelectChatTab(int tab);
181 
182 
183  void AutoReply(void);
184 
186  void SetAway(const char* text);
187 
188  virtual void OnLostFocus();
189  virtual void Show();
190 
191  csString GetBracket(int type);
192 
194  void ChatOutput(const char* data, int colour = -1, int type = CHAT_SYSTEM, bool flashEnabled = true, bool hasCharName = false, int hotkeyChannel = 0);
195 
196  void AddAutoCompleteName(const char *name);
197  void RemoveAutoCompleteName(const char *name);
198 
199  ChatSettings& GetSettings() {return settings;}
200 
201  void SaveChatSettings();
202  void LoadChatSettings();
203 
204  void RefreshCommandList();
205 
206  pawsIgnoreWindow* GetIgnoredList() { return IgnoredList; }
207 
209  void BadWordsFilter(csString& s);
210 
212  int mixColours(int colour1, int colour2);
213 
215  bool LeaveChannel(int hotkeyChannel);
216 
218  void JoinChannel(csString name);
219 
220  /* returns the input text box widget
221  */
222  pawsEditTextBox* getInputTextBox() {return inputText;};
223 
224  void writeChatHistory();
225 
227  void ReloadChatWindow();
228 
232  char const * GetFontName()
233  {
234  return fontName.GetData();
235  }
236 
240  bool LoadSetting();
241 
245  void SetChatWindowFont(const char *FontName, int FontSize);
246 
247 
248 protected:
249 
250  void HandleSystemMessage( MsgEntry* message );
251 
260  void FormatMessage(csString &sText, csString &sPerson, csString prependingText, csString &buff, bool &hasCharName);
261 
263  void SendChatLine(csString& inputText);
264 
266  void SubscribeCommands();
267 
269  void TabCompleteCommand(const char *cmd);
270  void TabCompleteName(const char *cmd);
271 
272  void DetermineChatTabAndSelect(int chattype);
273 
274 
276  csString replyList[4];
278 
279  csString awayText;
280 
282  csArray<csString> autoCompleteNames;
284  csArray<csArray<csString> *> autoCompleteLists;
285 
287  csRedBlackTree<psString> commandList;
288  csArray<csString> systemTriggers;
289  csArray<csString> chatTriggers;
290 
293 
295 
298 
302 
305 
307  csString currLine;
308 
311 
313  csRef<iFile> logFile[CHAT_END];
315  csHash<csRef<iFile>, uint> openLogFiles;
316 
319 
326  void LogMessage(const char* message, int type = CHAT_SAY);
327 
328  void CreateSettingNode(iDocumentNode* mNode,int color,const char* name);
329 
333  void ReplayMessages(unsigned int reqLines);
334 
336  csHashReversible<uint32_t, csString> channelIDs;
338  csArray<uint16_t> channels;
339 };
340 
341 //--------------------------------------------------------------------------
342 
344 
345 
346 //--------------------------------------------------------------------------
352 {
353 public:
354  pawsChatHistory();
355  ~pawsChatHistory();
356 
360  void Insert(const char *str);
361 
366  csString* GetCommand(int n);
367 
369  csString* GetNext();
370 
372  csString* GetPrev();
373 
374  void SetGetLoc(unsigned int pos) { getLoc = pos; }
375  unsigned int curLoc() { return getLoc; };
376 
377 private:
379  unsigned int getLoc;
380 
382  csPDelArray<csString> buffer;
383 };
384 
385 #endif
CHAT_COMBAT_FILTERS
Definition: chatwindow.h:49
This is a window that is controlled by a button on the control bar.
bool isInChannel
Is already in default channel?
Definition: chatwindow.h:318
bool enabledLogging[CHAT_END]
Stores if a chat type should be put in the logs.
Definition: chatwindow.h:91
bool OnDoubleClick(int button, int modifiers, int x, int y)
Handle double click events.
Definition: chatwindow.h:165
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
csHashReversible< uint32_t, csString > channelIDs
Subscribed channel name to server channel ID reversible mapping.
Definition: chatwindow.h:336
csArray< csString > badWords
Definition: chatwindow.h:98
ChatSettings & GetSettings()
Definition: chatwindow.h:199
int guildColor
Definition: chatwindow.h:75
csString channelBracket[CHAT_END]
Stores the brackets to add for each chat type.
Definition: chatwindow.h:90
When pawsMenu is created, target of notification messages (OnMenuAction) must be set by SetNotify() m...
Definition: pawsmenu.h:96
int auctionColor
Definition: chatwindow.h:82
bool mouseFocus
Definition: chatwindow.h:87
csArray< csString > subNames
Definition: chatwindow.h:103
int shoutColor
Definition: chatwindow.h:77
bool echoScreenInSystem
Definition: chatwindow.h:94
std::ostream LogMessage
Definition: logging.h:77
csHash< csString, csString > bindings
Definition: chatwindow.h:102
Main Chat window for PlaneShift.
Definition: chatwindow.h:133
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
bool defaultlastchat
Definition: chatwindow.h:85
A player&#39;s ignore list window.
Definition: pawsignore.h:33
CREATE_PAWS_FACTORY(pawsChatWindow)
char const * GetFontName()
return the name of the font
Definition: chatwindow.h:232
int playerColor
Player Color.
Definition: chatwindow.h:69
bool dirtyLogChannelFile[CHAT_END]
Stores if the log file name was changed.
Definition: chatwindow.h:88
unsigned int tabSetting
The param&#39;s low 10 bits are used. Each of these 10 bits stands for the state of the corresponding cha...
Definition: chatwindow.h:107
An edit box widget/.
Definition: pawstextbox.h:409
pawsIgnoreWindow * GetIgnoredList()
Definition: chatwindow.h:206
csRedBlackTree< psString > commandList
list of last commands
Definition: chatwindow.h:287
bool joindefaultchannel
Definition: chatwindow.h:84
csHash< csRef< iFile >, uint > openLogFiles
Stores a reference to all opened log files for easy search.
Definition: chatwindow.h:315
bool enableBadWordsFilterOutgoing
Definition: chatwindow.h:93
csArray< csString > completionItems
List of items for autocompletion from xml file chat type to subscription name binding.
Definition: chatwindow.h:100
ChatSettings settings
Stores the settings for the chat.
Definition: chatwindow.h:310
bool enableBadWordsFilterIncoming
Definition: chatwindow.h:92
csString awayText
Definition: chatwindow.h:279
csString currLine
Current line, stored for when scrolling back in the chat history.
Definition: chatwindow.h:307
bool looseFocusOnSend
Definition: chatwindow.h:86
csArray< uint16_t > channels
Hotkeys for server channel IDs.
Definition: chatwindow.h:338
pawsTabWindow * tabs
Definition: chatwindow.h:294
csArray< csArray< csString > * > autoCompleteLists
Contains pointers to all the autocompletion lists (excluding command lists)
Definition: chatwindow.h:284
int vicinityFilters
Flags int.
Definition: chatwindow.h:105
void SetGetLoc(unsigned int pos)
Definition: chatwindow.h:374
csArray< csString > autoCompleteNames
list of names to auto-complete
Definition: chatwindow.h:282
This is a special type of text box that is used for messages.
Definition: pawstextbox.h:285
csArray< csString > systemTriggers
Definition: chatwindow.h:288
int adminColor
Definition: chatwindow.h:72
bool yourColorMix
If it&#39;s true the yourColor will be mixed with the Color of the destination Example: if you send a tel...
Definition: chatwindow.h:96
csString noCasePlayerForename
Definition: chatwindow.h:301
This stores the text the player has entered into their edit window.
Definition: chatwindow.h:351
pawsEditTextBox * getInputTextBox()
Definition: chatwindow.h:222
int channelColor
Definition: chatwindow.h:78
int meFilters
Flags int.
Definition: chatwindow.h:106
csString logChannelFile[CHAT_END]
Stores the log files to use for each chat type.
Definition: chatwindow.h:89
bool havePlayerName
Decides if we have a player name.
Definition: chatwindow.h:297
int selectTabStyle
Definition: chatwindow.h:104
This window is supposed to be a generic widget for using tabs to show and hide subwindows automatical...
Definition: pawstabwindow.h:33
Struct for returning and setting settings.
Definition: chatwindow.h:66
int systemColor
Definition: chatwindow.h:71
int allianceColor
Definition: chatwindow.h:76
pawsIgnoreWindow * IgnoredList
Definition: chatwindow.h:275
void SetLogChannelFile(unsigned int type, csString newName)
Helper function to set correctly the.
Definition: chatwindow.h:114
int groupColor
Definition: chatwindow.h:81
csArray< csString > goodWords
Definition: chatwindow.h:99
unsigned int curLoc()
Definition: chatwindow.h:375
csArray< csString > chatTriggers
Definition: chatwindow.h:289
pawsChatHistory * chatHistory
Chat history.
Definition: chatwindow.h:304
pawsEditTextBox * inputText
Input box for quick access.
Definition: chatwindow.h:292
csString noCasePlayerName
Player name, with no upercase.
Definition: chatwindow.h:300
bool mainBrackets
If it&#39;s true brackets like [guild] [tell] will be put in main tab.
Definition: chatwindow.h:95