-
Notifications
You must be signed in to change notification settings - Fork 57
/
chat.h
318 lines (283 loc) · 7.82 KB
/
chat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/*!
* \file
* \ingroup chat_window
* \brief Declare the functions used to display the chat console.
*/
#ifndef __CHAT_H__
#define __CHAT_H__
#include "elwindows.h"
#include "queue.h"
#include "text.h"
#include "widgets.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_TEXT_MESSAGE_LENGTH 160 /*!< The server will disconnect us when we send longer messages */
#define INPUT_MARGIN 4
#define INPUT_DEFAULT_FLAGS (TEXT_FIELD_EDITABLE|TEXT_FIELD_NO_KEYPRESS|WIDGET_CLICK_TRANSPARENT)
#define MAX_CHANNEL_COLORS 64
typedef struct
{
Uint32 nr;
int color;
} channelcolor;
typedef struct
{
int value;
const int lower;
const int upper;
} max_chat_lines_def;
extern max_chat_lines_def max_chat_lines;
extern int use_windowed_chat; /*!< flag indicating whether we use the channel selection bar, the chat window, or neither */
//extern int highlight_tab_on_nick; /*!< flag indicating whether we want to highligh chat tab on nick or not */
extern int console_input_at_top; /*!< locate the input widget at the top of the screen */
extern int chat_win; /*!< handler for the chat window */
extern int local_chat_separate; /*!< if non-zero, show local chat in a separate tab */
extern int personal_chat_separate; /*!< if non-zero, show PMs in a different tab */
extern int guild_chat_separate; /*!< if non-zero, show GMs in a different tab */
extern int server_chat_separate; /*!< if non-zero, show game messages in a different tab */
extern int mod_chat_separate; /*!< for moderators and newbie helpers only: if non-zero, show mod chat in a different tab */
extern int tab_bar_win; /*!< handler for the tab bar window */
extern int enable_chat_show_hide; /*!< config option to enable show/hide of the chat system */
/*!
* \brief Moves the chat input widget to a different window
*
* Moves the chat input widget to a different window
*
* \param window_id ID of the window to move the widget to.
* \callgraph
*/
void input_widget_move_to_win(int window_id);
/*!
* \ingroup chat_window
* \brief Sets the channels that the player is currently subscribed to
*
* Sets the channels that the player is currently subscribed to
*
* \param active The index of the currently active channel
* \param channels The channel numbers
* \param nchan The number of channels
*
* \callgraph
*/
void set_active_channels (Uint8 active, const Uint32 *channels, int nchan);
/*!
* \ingroup chat_window
* \brief give the channel number of channel \a idx
*
* give the channel number of channel \a idx
*
* \param idx The channel index
*
* \retval Uint32 The channel number if \a idx is a valid channel index, 0 otherwise
* \callgraph
*/
Uint32 get_active_channel (Uint8 idx);
/*!
* \ingroup chat_window
* \brief Clears the text from chat history
*
* Clears the text from chat history
*
* \callgraph
*/
void clear_chat_wins (void);
/*!
* \ingroup chat_window
* \brief Parse text as console input
*
* A common routine to parse input. Input can be local chat,
* #commands, %options channel or personal chat.
*
* \param data the input text
* \param len the length of the input text
* \callgraph
*/
void parse_input(char *data, int len);
// /*!
// * \brief Highlights a channel in the channel selection tab
// *
// * Highlights a channel's tab in red. Used when a message with player's name arrives.
// *
// * \param channel channel to highlight
// *
// * \retval int 1 if highlighted, 0 otherwise
// * \callgraph
// */
//int highlight_tab(const Uint8 channel);
/*!
* \ingroup chat_window
* \brief Initializes the structures for the chat channels
*
* Initializes the structures for the chat channels.
*
* \callgraph
*/
void init_chat_channels (void);
/*!
* \ingroup chat_window
* \brief clear_input_line
*
* Detail
*
* \callgraph
*/
void clear_input_line (void);
/*!
* \ingroup chat_window
* \brief Handle a keypress of the root window
*
* Handles a keypress in the root window as if it were pressed in the chat window input field.
*
* \param key
* \param unikey
*
* \retval int 1 if handled, 0 otherwise
* \callgraph
*/
int root_key_to_input_field (SDL_Keycode key_code, Uint32 key_unicode, Uint16 key_mod);
/*!
* \ingroup chat_window
* \brief Paste a text into the input field
*
* Pastes a text line at the current cursor position in the input field
*
* \param text the text to paste
*
* \callgraph
*/
void paste_in_input_field (const Uint8 *text);
/*!
* \ingroup chat_window
* \brief Displays the chat window
*
* Displays the chat window
*
* \callgraph
*/
void display_chat (void);
/*!
* \ingroup chat_bar
* \brief Show the channel selection bar
*
* Show the channel selection bar
*
* \callgraph
*/
void display_tab_bar (void);
/*!
* \ingroup chat
* \brief Switch focused channel
*
* Switch focus to channel using the start of the line for selection #@/ etc.
*
* \param line text line to pass
* \callgraph
*/
void change_to_channel_tab(const char *line);
/*!
* \ingroup chat_window
* \brief Convert from chat window to tab bar, or vice versa
*
* Convert the chat window's tabs into tab bar buttons, or vice versa
*
* \param new_wc the new value of use_windowed_chat
* \callgraph
*/
void convert_tabs (int new_wc);
/*!
* \brief Read channel names from file
*
* Open and parse file of names and descriptions for each chat channel
*
* \callgraph
*/
void init_channel_names (void);
/*!
* \ingroup chat_window
* \brief Put a text line in the input field
*
* Removes the content of the input field and inserts a new text line
*
* \param text the text to insert
*
* \callgraph
*/
void put_string_in_input_field(const Uint8 *text);
/*!
* \brief checks if message fits the filter.
*
* \param[in] msg message to test.
* \param[in] filter filter.
*
* \return 1 if message doesnt fit filter (should be skipped), 0 otherwise.
*/
int skip_message (const text_message *msg, Uint8 filter);
int command_jlc(char * text, int len);
void update_chat_win_buffers(void);
void cleanup_chan_names(void);
void load_channel_colors();
void save_channel_colors();
int command_channel_colors(char * text, int len);
void next_channel_tab(void);
void prev_channel_tab(void);
void update_text_windows (text_message * pmsg);
void recolour_messages(text_message *msgs);
void recolour_message(text_message *msg);
void reset_tab_channel_colours(void);
void set_first_tab_channel(void);
const char * get_tab_channel_name(void);
void set_next_tab_channel(void);
int get_tab_bar_x(void);
int get_tab_bar_y(void);
int get_tabbed_chat_end_x(void);
/* Consolidate all the input widget usage into functions for this module. */
int get_input_default_height(void);
int get_input_at_top_height(void);
int get_input_at_bottom_height(void);
void show_console_input(void);
void check_owned_and_show_console_input(int window_id);
int get_console_input_cursor(void);
void set_console_input_cursor(int new_value);
void update_console_input_zoom(void);
void update_console_input_size_and_position(void);
void check_and_get_console_input(int window_id);
void move_console_input_on_input_resize(void);
int have_console_input(void);
void create_console_input(int window_id, int widget_id, int pos_x, int pos_y, int len_x, int len_y, Uint32 flags);
void set_console_input_onkey(void);
int console_input_active_at_top(void);
void open_chat(void);
void toggle_chat(void);
void enable_chat_shown(void);
int is_chat_shown(void);
/*!
* \ingroup chat_window
*
* \brief Get the current number of chat lines shown.
*
* \retval the number of lines
*
* \callgraph
*/
int get_lines_to_show(void);
/*!
* \ingroup chat_window
*
* \brief Decrement the number of chat lines shown.
*
* \callgraph
*/
void dec_lines_to_show(void);
/*!
* \ingroup chat_window
*
* \brief Set the number of chat lines shown to zero.
*
* \callgraph
*/
void clear_lines_to_show(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // def __CHAT_H__