2 * $Logfile: /Freespace2/code/MissionUI/Chatbox.cpp $
7 * C module to handle all code for multiplayer chat windows
10 * Revision 1.2 2002/05/07 03:16:46 theoddone33
11 * The Great Newline Fix
13 * Revision 1.1.1.1 2002/05/03 03:28:10 root
17 * 12 8/05/99 4:05p Jefff
18 * fixed pause chatbox display coords
20 * 11 7/29/99 10:47p Dave
21 * Standardized D3D fogging using vertex fog. Shook out Savage 4 bugs.
23 * 10 5/22/99 5:35p Dave
24 * Debrief and chatbox screens. Fixed small hi-res HUD bug.
26 * 9 2/24/99 2:25p Dave
27 * Fixed up chatbox bugs. Made squad war reporting better. Fixed a respawn
28 * bug for dogfight more.
30 * 8 2/23/99 8:11p Dave
31 * Tidied up dogfight mode. Fixed TvT ship type problems for alpha wing.
32 * Small pass over todolist items.
34 * 7 2/11/99 3:08p Dave
35 * PXO refresh button. Very preliminary squad war support.
37 * 6 2/01/99 5:55p Dave
38 * Removed the idea of explicit bitmaps for buttons. Fixed text
39 * highlighting for disabled gadgets.
41 * 5 1/29/99 2:08a Dave
42 * Fixed beam weapon collisions with players. Reduced size of scoring
43 * struct for multiplayer. Disabled PXO.
45 * 4 1/28/99 7:09p Neilk
46 * Modified chatbox to use new interface graphics (only 640)
48 * 3 10/13/98 9:28a Dave
49 * Started neatening up freespace.h. Many variables renamed and
50 * reorganized. Added AlphaColors.[h,cpp]
52 * 2 10/07/98 10:53a Dave
55 * 1 10/07/98 10:49a Dave
57 * 57 9/17/98 3:08p Dave
58 * PXO to non-pxo game warning popup. Player icon stuff in create and join
59 * game screens. Upped server count refresh time in PXO to 35 secs (from
62 * 56 9/11/98 5:08p Dave
63 * More tweaks to kick notification system.
65 * 55 9/11/98 4:14p Dave
66 * Fixed file checksumming of < file_size. Put in more verbose kicking and
67 * PXO stats store reporting.
69 * 54 6/09/98 5:15p Lawrance
70 * French/German localization
72 * 53 6/09/98 10:31a Hoffoss
73 * Created index numbers for all xstr() references. Any new xstr() stuff
74 * added from here on out should be added to the end if the list. The
75 * current list count can be found in FreeSpace.cpp (search for
78 * 52 6/01/98 11:43a John
79 * JAS & MK: Classified all strings for localization.
81 * 51 5/22/98 9:35p Dave
82 * Put in channel based support for PXO. Put in "shutdown" button for
83 * standalone. UI tweaks for TvT
85 * 50 5/17/98 6:32p Dave
86 * Make sure clients/servers aren't kicked out of the debriefing when team
87 * captains leave a game. Fixed chatbox off-by-one error. Fixed image
88 * xfer/pilot info popup stuff.
90 * 49 5/17/98 1:43a Dave
91 * Eradicated chatbox problems. Remove speed match for observers. Put in
92 * help screens for PXO. Fix messaging and end mission privelges. Fixed
93 * team select screen bugs. Misc UI fixes.
95 * 48 5/15/98 9:52p Dave
96 * Added new stats for freespace. Put in artwork for viewing stats on PXO.
98 * 47 5/15/98 5:15p Dave
99 * Fix a standalone resetting bug.Tweaked PXO interface. Display captaincy
100 * status for team vs. team. Put in asserts to check for invalid team vs.
103 * 46 5/08/98 7:08p Dave
104 * Lots of UI tweaking.
106 * 45 5/07/98 6:26p Dave
107 * Fix strange boundary conditions which arise when players die/respawn
108 * while the game is being ended. Spiff up the chatbox doskey thing a bit.
110 * 44 5/04/98 10:39p Dave
111 * Put in endgame sequencing. Need to check campaign situations.
112 * Realigned ship info on team select screen.
114 * 43 5/02/98 5:38p Dave
115 * Put in new tracker API code. Put in ship information on mp team select
116 * screen. Make standalone server name permanent. Fixed standalone server
119 * 42 4/29/98 6:00p Dave
120 * Fixed chatbox font colors. Made observer offscreen indicators work.
121 * Numerous small UI fixes. Fix rank limitations for mp games.
123 * 41 4/25/98 3:14p Dave
124 * Fixed chatbox clipping problem.
126 * 40 4/16/98 6:34p Dave
127 * Fixed reversed team vs. team colors.
129 * 39 4/14/98 5:06p Dave
130 * Don't load or send invalid pilot pics. Fixed chatbox graphic errors.
131 * Made chatbox display team icons in a team vs. team game. Fixed up pause
132 * and endgame sequencing issues.
134 * 38 4/13/98 7:48p Dave
135 * Fixed chatbox overrun errors. Put in line recall function (4 deep).
137 * 37 4/12/98 2:09p Dave
138 * Make main hall door text less stupid. Make sure inputbox focus in the
139 * multi host options screen is managed more intelligently.
141 * 36 4/01/98 11:19p Dave
142 * Put in auto-loading of xferred pilot pic files. Grey out background
143 * behind pinfo popup. Put a chatbox message in when players are kicked.
144 * Moved mission title down in briefing. Other ui fixes.
146 * 35 3/31/98 4:42p Allender
147 * mission objective support for team v. team mode. Chatbox changes to
148 * make input box be correct length when typing
150 * 34 3/29/98 1:24p Dave
151 * Make chatbox not clear between multiplayer screens. Select player ship
152 * as default in mp team select and weapons select screens. Made create
153 * game mission list use 2 fixed size columns.
155 * 33 3/19/98 5:05p Dave
156 * Put in support for targeted multiplayer text and voice messaging (all,
157 * friendly, hostile, individual).
159 * 32 3/18/98 12:03p John
160 * Marked all the new strings as externalized or not.
162 * 31 3/17/98 12:30a Dave
163 * Put in hud support for rtvoice. Several ui interface changes.
165 * 30 3/10/98 10:59p Dave
166 * Fixed single player pause screen. Put in temporary fix for multiplayer
167 * version. Fixed several chatbox display and text string bugs.
169 * 29 2/27/98 9:41a Dave
170 * Made "up/down" arrows flip direction when toggling chatbox sizes.
172 * 28 2/26/98 4:21p Dave
173 * More robust multiplayer voice.
175 * 27 2/22/98 4:17p John
176 * More string externalization classification... 190 left to go!
178 * 26 2/22/98 12:19p John
179 * Externalized some strings
181 * 25 2/13/98 3:46p Dave
182 * Put in dynamic chatbox sizing. Made multiplayer file lookups use cfile
185 * 24 2/04/98 10:50p Allender
186 * zero out chat line before storing text
188 * 23 1/29/98 5:23p Dave
189 * Made ingame join handle bad packets gracefully.
191 * 22 1/23/98 5:43p Dave
192 * Finished bringing standalone up to speed. Coded in new host options
195 * 21 1/17/98 5:51p Dave
196 * Bug fixes for bugs generated by multiplayer testing.
198 * 20 1/16/98 5:23p Allender
199 * more chatbox changes
201 * 19 1/16/98 4:28p Allender
202 * automatically send line when close to end of chatbox.
204 * 18 1/16/98 2:34p Dave
205 * Made pause screen work properly (multiplayer). Changed how chat packets
208 * 17 1/15/98 6:12p Dave
209 * Fixed weapons loadout bugs with multiplayer respawning. Added
210 * multiplayer start screen. Fixed a few chatbox bugs.
212 * 16 1/15/98 5:10p Allender
213 * ton of interface changes. chatbox in multiplayer now behaves
214 * differently than before. It's always active in any screen that uses
215 * it. Only non-printatble characters will get passed back out from
218 * 15 1/12/98 5:17p Dave
219 * Put in a bunch of multiplayer sequencing code. Made weapon/ship select
220 * work through the standalone.
222 * 14 1/07/98 5:20p Dave
223 * Put in support for multiplayer campaigns with the new interface
226 * 13 1/05/98 5:06p Dave
227 * Fixed a chat packet bug. Fixed a few state save/restore bugs. Updated a
228 * few things for multiplayer server transfer.
230 * 12 12/29/97 3:15p Dave
231 * Put in auto-indenting for multiplayer chatbox. Tweaked some multiplayer
234 * 11 12/22/97 9:13p Allender
235 * fixed up a few minor issues with chatbox
237 * 10 12/19/97 7:08p Jasen
238 * Updated coords for new ChatBox (small)
240 * 9 12/18/97 8:59p Dave
241 * Finished putting in basic support for weapon select and ship select in
244 * 8 12/06/97 4:27p Dave
245 * Another load of interface and multiplayer bug fixes.
247 * 7 12/03/97 4:16p Hoffoss
248 * Changed sound stuff used in interface screens for interface purposes.
250 * 6 11/12/97 4:40p Dave
251 * Put in multiplayer campaign support parsing, loading and saving. Made
252 * command-line variables better named. Changed some things on the initial
253 * pilot select screen.
255 * 5 10/24/97 10:59p Hoffoss
256 * Added in create pilot popup window and barracks screen.
258 * 4 10/08/97 5:08p Lawrance
259 * use mask region for chat box inputbox, so getting focus is easier
261 * 3 10/01/97 4:47p Lawrance
262 * move some #defines out of header file into .cpp file
264 * 2 10/01/97 4:39p Lawrance
265 * move chat code into Chatbox.cpp, simplify interface
267 * 1 10/01/97 10:54a Lawrance
274 #include "freespace.h"
276 #include "missionscreencommon.h"
277 #include "multimsgs.h"
284 #include "multi_pmsg.h"
285 #include "alphacolors.h"
287 ///////////////////////////////////////////////////////////
289 ///////////////////////////////////////////////////////////
291 // a little extra spacing for the team vs. team icons
292 #define CHATBOX_TEAM_ICON_SPACE 18
294 // SMALL CHATBOX ----------------------------------------------------------------------------------
297 char* Chatbox_small_bitmap_fname[GR_NUM_RESOLUTIONS] = {
299 "2_Chatbox" // GR_1024
303 char* Chatbox_small_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = {
304 "Chatbox-m", // GR_640
305 "2_Chatbox-m" // GR_1024
309 int Chatbox_small_coords[GR_NUM_RESOLUTIONS][2] = {
318 // display area coods
319 int Chatbox_small_display_coords[GR_NUM_RESOLUTIONS][4] = {
321 196 + CHATBOX_TEAM_ICON_SPACE, 13, 410 - CHATBOX_TEAM_ICON_SPACE, 74
324 315 + CHATBOX_TEAM_ICON_SPACE, 22, 654 - CHATBOX_TEAM_ICON_SPACE, 116
329 int Chatbox_small_input_coords[GR_NUM_RESOLUTIONS][4] = {
339 int Chatbox_small_max_lines[GR_NUM_RESOLUTIONS] = {
344 // BIG CHATBOX ----------------------------------------------------------------------------------
347 char* Chatbox_big_bitmap_fname[GR_NUM_RESOLUTIONS] = {
348 "ChatboxBig", // GR_640
349 "2_ChatboxBig" // GR_1024
353 char* Chatbox_big_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = {
354 "Chatbox-m", // GR_640
355 "2_Chatbox-m" // GR_1024
359 int Chatbox_big_coords[GR_NUM_RESOLUTIONS][2] = {
368 // display area coords
369 int Chatbox_big_display_coords[GR_NUM_RESOLUTIONS][4] = {
371 196 + CHATBOX_TEAM_ICON_SPACE, 13, 410 - CHATBOX_TEAM_ICON_SPACE, 326
374 315 + CHATBOX_TEAM_ICON_SPACE, 22, 654 - CHATBOX_TEAM_ICON_SPACE, 519
379 int Chatbox_big_input_coords[GR_NUM_RESOLUTIONS][4] = {
389 int Chatbox_big_max_lines[GR_NUM_RESOLUTIONS] = {
394 // PAUSED CHATBOX ----------------------------------------------------------------------------------
397 char* Chatbox_p_bitmap_fname[GR_NUM_RESOLUTIONS] = {
399 "2_MPPause" // GR_1024
403 char* Chatbox_p_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = {
404 "MPPause-m", // GR_640
405 "2_MPPause-m" // GR_1024
409 int Chatbox_p_coords[GR_NUM_RESOLUTIONS][2] = {
418 // display area coords
419 int Chatbox_p_display_coords[GR_NUM_RESOLUTIONS][4] = {
421 103 + CHATBOX_TEAM_ICON_SPACE, 149, 380 - CHATBOX_TEAM_ICON_SPACE, 143
424 165 + CHATBOX_TEAM_ICON_SPACE, 244, 654 - CHATBOX_TEAM_ICON_SPACE, 263
429 int Chatbox_p_input_coords[GR_NUM_RESOLUTIONS][4] = {
439 int Chatbox_p_max_lines[GR_NUM_RESOLUTIONS] = {
444 // defines for location and other info of chat box MULTI_PAUSED
446 #define CHATBOX_MP_FNAME NOX("MPPause")
447 #define CHATBOX_MP_MASK NOX("MPPause-m")
448 #define CHATBOX_MP_X1 112
449 #define CHATBOX_MP_Y1 198
450 #define CHATBOX_MP_X2 477
451 #define CHATBOX_MP_Y2 308
452 #define CHATBOX_MP_ICON_X (CHATBOX_MP_X1)
453 #define CHATBOX_MP_W (CHATBOX_MP_X2 - CHATBOX_MP_X1 + 1)
454 #define CHATBOX_MP_H (CHATBOX_MP_Y2 - CHATBOX_MP_Y1 + 1)
455 #define CHATBOX_MP_BEGIN_X (CHATBOX_MP_X1 + 3 + CHATBOX_TEAM_ICON_SPACE)
456 #define CHATBOX_MP_BEGIN_Y CHATBOX_MP_Y1
457 #define CHATBOX_MP_DISP_W 365
458 #define CHATBOX_MP_MAX_LINES 11
459 #define CHATBOX_MP_INPUTBOX_X (CHATBOX_MP_X1 + 3)
460 #define CHATBOX_MP_INPUTBOX_W (CHATBOX_MP_W)
461 #define CHATBOX_MP_TEXTENTER_Y 329
464 // CHATBOX ----------------------------------------------------------------------------------
466 // the settings being used for this instance
467 char Chatbox_mask[50];
476 int Chatbox_max_lines;
477 int Chatbox_inputbox_x;
478 int Chatbox_inputbox_w;
479 int Chatbox_textenter_y;
480 int Chat_scroll_up_coord[2];
481 int Chat_scroll_down_coord[2];
483 // how many pixels to indent succesive lines of text from a given player
484 #define CHAT_LINE_INDENT 20
486 // what chars other than letters and number's we'll toss
487 #define CHATBOX_INVALID_CHARS NOX("~`") // this is primarily so that we don't interfere with the voice recording keys
489 // common defines and data
490 #define CHATBOX_STRING_LEN (CALLSIGN_LEN + CHATBOX_MAX_LEN + 32)
491 UI_WINDOW Chat_window;
492 UI_INPUTBOX Chat_inputbox;
493 UI_BUTTON Chat_enter_text;
496 #define CHATBOX_NUM_BUTTONS 3
497 #define CHATBOX_SCROLL_UP 0
498 #define CHATBOX_SCROLL_DOWN 1
499 #define CHATBOX_TOGGLE_SIZE 2 // used for both big and small
501 // coordinate indicies
502 #define CHATBOX_X_COORD 0
503 #define CHATBOX_Y_COORD 1
504 #define CHATBOX_W_COORD 2
505 #define CHATBOX_H_COORD 3
508 ui_button_info Chatbox_buttons[GR_NUM_RESOLUTIONS][CHATBOX_NUM_BUTTONS+1] = {
510 ui_button_info("CHB_00", 613, 3, -1, -1, 0),
511 ui_button_info("CHB_01", 613, 41, -1, -1, 1),
512 ui_button_info("CHB_02a", 607, 74, -1, -1, 2),
513 ui_button_info("CHB_02b", 607, 74, -1, -1, 2),
516 ui_button_info("2_CHB_00", 981, 5, -1, -1, 0),
517 ui_button_info("2_CHB_01", 981, 67, -1, -1, 1),
518 ui_button_info("2_CHB_02a", 971, 119, -1, -1, 2),
519 ui_button_info("2_CHB_02b", 971, 119, -1, -1, 2),
523 int Chatbox_mode_flags = 0;
525 int Chatbox_bitmap = -1;
526 int Chatbox_big_bitmap = -1;
527 int Chatbox_small_bitmap = -1;
528 int Chatbox_mp_bitmap = -1;
529 int Chatbox_created = 0;
531 ///////////////////////////////////////////////////////////
533 ///////////////////////////////////////////////////////////
534 #define MAX_BRIEF_CHAT_LINES 60 // how many lines we can store in the scrollback buffer
535 #define BRIEF_DISPLAY_SPACING 2 // pixel spacing between chat lines
537 // the first byte of the text string will be the net player id of the
538 char Brief_chat_lines[MAX_BRIEF_CHAT_LINES][CHATBOX_STRING_LEN];
539 int Brief_chat_indents[MAX_BRIEF_CHAT_LINES];
541 int Brief_chat_next_index[MAX_BRIEF_CHAT_LINES];
542 int Brief_chat_prev_index[MAX_BRIEF_CHAT_LINES];
543 int Num_brief_chat_lines;
544 int Brief_current_add_line;
545 int Brief_start_display_index;
547 // chatbox line recall data
548 #define CHATBOX_MAX_RECALL_LINES 10
549 int Chatbox_recall_count = 0;
550 int Chatbox_recall_index = 0;
551 int Chatbox_recall_last = -1;
552 char Chatbox_recall_lines[CHATBOX_MAX_RECALL_LINES][CHATBOX_MAX_LEN+2];
554 ///////////////////////////////////////////////////////////
555 // forward declarations
556 ///////////////////////////////////////////////////////////
557 void chatbox_chat_init();
558 void chatbox_render_chat_lines();
559 void chatbox_set_mode(int mode_flags);
560 void chatbox_toggle_size();
561 void chatbox_toggle_size_adjust_lines();
562 void chat_autosplit_line(char *msg,char *remainder);
563 int chatbox_num_displayed_lines();
564 void chatbox_recall_add(char *string);
565 void chatbox_recall_up();
566 void chatbox_recall_down();
568 // set the chatbox mode without checking for any previous modes which may need to be handled specially
569 void chatbox_set_mode(int mode_flags)
573 // set the stored mode
574 Chatbox_mode_flags = mode_flags;
576 // small pregame chatbox
577 if(Chatbox_mode_flags & CHATBOX_FLAG_SMALL){
580 // big pregame chatbox
581 else if(Chatbox_mode_flags & CHATBOX_FLAG_BIG){
584 // multiplayer paused
589 // set up the display/init variables based upon what mode we chode
592 strcpy(Chatbox_mask, Chatbox_small_bitmap_mask_fname[gr_screen.res]);
593 Chatbox_x1 = Chatbox_small_coords[gr_screen.res][CHATBOX_X_COORD];
594 Chatbox_y1 = Chatbox_small_coords[gr_screen.res][CHATBOX_Y_COORD];
595 Chatbox_icon_x = Chatbox_small_display_coords[gr_screen.res][CHATBOX_X_COORD] - CHATBOX_TEAM_ICON_SPACE;
596 Chatbox_w = Chatbox_small_display_coords[gr_screen.res][CHATBOX_W_COORD];
597 Chatbox_h = Chatbox_small_display_coords[gr_screen.res][CHATBOX_H_COORD];
598 Chatbox_begin_x = Chatbox_small_display_coords[gr_screen.res][CHATBOX_X_COORD];
599 Chatbox_begin_y = Chatbox_small_display_coords[gr_screen.res][CHATBOX_Y_COORD];
600 Chatbox_disp_w = Chatbox_small_display_coords[gr_screen.res][CHATBOX_W_COORD];
601 Chatbox_max_lines = Chatbox_small_max_lines[gr_screen.res];
602 Chatbox_inputbox_x = Chatbox_small_input_coords[gr_screen.res][CHATBOX_X_COORD];
603 Chatbox_inputbox_w = Chatbox_small_input_coords[gr_screen.res][CHATBOX_W_COORD];
604 Chatbox_textenter_y = Chatbox_small_input_coords[gr_screen.res][CHATBOX_Y_COORD];
608 strcpy(Chatbox_mask, Chatbox_big_bitmap_mask_fname[gr_screen.res]);
609 Chatbox_x1 = Chatbox_big_coords[gr_screen.res][CHATBOX_X_COORD];
610 Chatbox_y1 = Chatbox_big_coords[gr_screen.res][CHATBOX_Y_COORD];
611 Chatbox_icon_x = Chatbox_big_display_coords[gr_screen.res][CHATBOX_X_COORD] - CHATBOX_TEAM_ICON_SPACE;
612 Chatbox_w = Chatbox_big_display_coords[gr_screen.res][CHATBOX_W_COORD];
613 Chatbox_h = Chatbox_big_display_coords[gr_screen.res][CHATBOX_H_COORD];
614 Chatbox_begin_x = Chatbox_big_display_coords[gr_screen.res][CHATBOX_X_COORD];
615 Chatbox_begin_y = Chatbox_big_display_coords[gr_screen.res][CHATBOX_Y_COORD];
616 Chatbox_disp_w = Chatbox_big_display_coords[gr_screen.res][CHATBOX_W_COORD];
617 Chatbox_max_lines = Chatbox_big_max_lines[gr_screen.res];
618 Chatbox_inputbox_x = Chatbox_big_input_coords[gr_screen.res][CHATBOX_X_COORD];
619 Chatbox_inputbox_w = Chatbox_big_input_coords[gr_screen.res][CHATBOX_W_COORD];
620 Chatbox_textenter_y = Chatbox_big_input_coords[gr_screen.res][CHATBOX_Y_COORD];
624 Chatbox_x1 = Chatbox_p_coords[gr_screen.res][CHATBOX_X_COORD];
625 Chatbox_y1 = Chatbox_p_coords[gr_screen.res][CHATBOX_Y_COORD];
626 Chatbox_icon_x = Chatbox_p_display_coords[gr_screen.res][CHATBOX_X_COORD] - CHATBOX_TEAM_ICON_SPACE;
627 Chatbox_w = Chatbox_p_display_coords[gr_screen.res][CHATBOX_W_COORD];
628 Chatbox_h = Chatbox_p_display_coords[gr_screen.res][CHATBOX_H_COORD];
629 Chatbox_begin_x = Chatbox_p_display_coords[gr_screen.res][CHATBOX_X_COORD];
630 Chatbox_begin_y = Chatbox_p_display_coords[gr_screen.res][CHATBOX_Y_COORD];
631 Chatbox_disp_w = Chatbox_p_display_coords[gr_screen.res][CHATBOX_W_COORD];
632 Chatbox_max_lines = Chatbox_p_max_lines[gr_screen.res];
633 Chatbox_inputbox_x = Chatbox_p_input_coords[gr_screen.res][CHATBOX_X_COORD];
634 Chatbox_inputbox_w = Chatbox_p_input_coords[gr_screen.res][CHATBOX_W_COORD];
635 Chatbox_textenter_y = Chatbox_p_input_coords[gr_screen.res][CHATBOX_Y_COORD];
640 // automatically split up any input text, send it, and leave the remainder
641 void chatbox_autosplit_line()
643 char *remainder,msg[150];
646 // if the chat line is getting too long, fire off the message, putting the last
647 // word on the next input line.
649 Chat_inputbox.get_text(msg);
651 // determine if the width of the string in pixels is > than the inputbox width -- if so,
652 // then send the message
653 gr_get_string_size(&msg_pixel_width, NULL, msg);
654 // if ( msg_pixel_width >= (Chatbox_inputbox_w - Player->short_callsign_width) ) {
655 if ( msg_pixel_width >= (Chatbox_inputbox_w - 25)) {
656 remainder = strrchr(msg, ' ');
663 // if I'm the server, then broadcast the packet
664 chatbox_recall_add(msg);
665 send_game_chat_packet(Net_player, msg, MULTI_MSG_ALL,NULL);
666 chatbox_add_line(msg, MY_NET_PLAYER_NUM);
668 // display any remainder of text on the next line
669 Chat_inputbox.set_text(remainder);
670 } else if((Chat_inputbox.pressed() && (strlen(msg) > 0)) || (strlen(msg) >= CHATBOX_MAX_LEN)) {
671 // tack on the null terminator in the boundary case
673 if(x >= CHATBOX_MAX_LEN){
674 msg[CHATBOX_MAX_LEN-1] = '\0';
676 // if I'm the server, then broadcast the packet
677 chatbox_recall_add(msg);
678 send_game_chat_packet(Net_player, msg, MULTI_MSG_ALL,NULL);
679 chatbox_add_line(msg, MY_NET_PLAYER_NUM);
681 // display any remainder of text on the next line
682 Chat_inputbox.set_text(remainder);
686 // initialize all chatbox details with the given mode flags
687 int chatbox_create(int mode_flags)
691 // don't do anything if the chatbox is already initialized
692 if (Chatbox_created){
696 // probably shouldn't be using the chatbox in single player mode
697 Assert(Game_mode & GM_MULTIPLAYER);
699 // setup all data to correspond to our mode flags
700 chatbox_set_mode(mode_flags);
702 // initialize all low-level details related to chatting
705 // attempt to load in the chatbox background bitmap
706 if(Chatbox_mode_flags & CHATBOX_FLAG_DRAW_BOX){
707 Chatbox_big_bitmap = bm_load(Chatbox_big_bitmap_fname[gr_screen.res]);
708 Chatbox_small_bitmap = bm_load(Chatbox_small_bitmap_fname[gr_screen.res]);
709 Chatbox_mp_bitmap = bm_load(Chatbox_p_bitmap_fname[gr_screen.res]);
711 if(Chatbox_mode_flags & CHATBOX_FLAG_SMALL){
712 Chatbox_bitmap = Chatbox_small_bitmap;
713 } else if(Chatbox_mode_flags & CHATBOX_FLAG_BIG){
714 Chatbox_bitmap = Chatbox_big_bitmap;
716 Chatbox_bitmap = Chatbox_mp_bitmap;
719 if((Chatbox_bitmap == -1) || (Chatbox_small_bitmap == -1) || (Chatbox_big_bitmap == -1) || (Chatbox_mp_bitmap == -1)){
724 // attempt to create the ui window for the chatbox and assign the mask
725 Chat_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
726 Chat_window.set_mask_bmap(Chatbox_mask);
728 // create the chat text enter input area
729 Chat_inputbox.create( &Chat_window, Chatbox_inputbox_x, Chatbox_textenter_y, Chatbox_inputbox_w, CHATBOX_MAX_LEN, "", UI_INPUTBOX_FLAG_INVIS | UI_INPUTBOX_FLAG_ESC_CLR | UI_INPUTBOX_FLAG_KEYTHRU | UI_INPUTBOX_FLAG_EAT_USED, Chatbox_w, Color_netplayer[MY_NET_PLAYER_NUM]);
730 Chat_inputbox.set_focus();
731 Chat_inputbox.set_invalid_chars(CHATBOX_INVALID_CHARS);
733 // if we're supposed to supply and check for out own buttons
734 if((Chatbox_mode_flags & CHATBOX_FLAG_BUTTONS) && (Chatbox_mode_flags & CHATBOX_FLAG_DRAW_BOX)){
735 for(idx=0; idx<CHATBOX_NUM_BUTTONS; idx++){
737 Chatbox_buttons[gr_screen.res][idx].button.create(&Chat_window, "", Chatbox_buttons[gr_screen.res][idx].x, Chatbox_buttons[gr_screen.res][idx].y, 60, 30, (idx == CHATBOX_TOGGLE_SIZE) ? 0 : 1);
739 // set the highlight action
740 Chatbox_buttons[gr_screen.res][idx].button.set_highlight_action(common_play_highlight_sound);
743 Chatbox_buttons[gr_screen.res][idx].button.set_bmaps(Chatbox_buttons[gr_screen.res][idx].filename);
746 Chatbox_buttons[gr_screen.res][idx].button.link_hotspot(Chatbox_buttons[gr_screen.res][idx].hotspot);
749 // now create the toggle size button with the appropriate button
750 if(Chatbox_mode_flags & CHATBOX_FLAG_SMALL){
751 Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].button.set_bmaps(Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].filename);
753 Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].button.set_bmaps(Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE+1].filename);
757 // an invisible button that will set focus to input box when clicked on
758 Chat_enter_text.create( &Chat_window, "", 0, 0, 60, 30, 0);
759 Chat_enter_text.hide(); // button doesn't show up
760 Chat_enter_text.link_hotspot(50);
766 // process this frame for the chatbox
767 int chatbox_process(int key_in)
773 // if the chatbox hasn't explicitly been created, we can't do any processing
774 if(!Chatbox_created){
778 // process the incoming key appropriately
780 key_out = Chat_window.process();
782 key_out = Chat_window.process(key_in);
785 // look for special keypresses
787 // line recall up one
793 // line recall down one
795 chatbox_recall_down();
800 // if we're supposed to be checking our own scroll buttons
801 if((Chatbox_mode_flags & CHATBOX_FLAG_BUTTONS) && (Chatbox_mode_flags & CHATBOX_FLAG_DRAW_BOX)){
802 if ( Chatbox_buttons[gr_screen.res][CHATBOX_SCROLL_UP].button.pressed() ) {
806 if ( Chatbox_buttons[gr_screen.res][CHATBOX_SCROLL_DOWN].button.pressed() ) {
807 chatbox_scroll_down();
810 if ( Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].button.pressed() ){
811 chatbox_toggle_size();
815 // check to see if the enter text button has been pressed
816 if ( Chat_enter_text.pressed() ) {
817 Chat_inputbox.set_focus();
820 // check to see if the current input text needs to be split up and sent automaticall
821 chatbox_autosplit_line();
828 // destory the UI window
829 Chat_window.destroy();
831 // unload any bitmaps
832 if(Chatbox_small_bitmap != -1){
833 bm_unload(Chatbox_small_bitmap);
835 if(Chatbox_big_bitmap != -1){
836 bm_unload(Chatbox_big_bitmap);
838 if(Chatbox_mp_bitmap != -1){
839 bm_unload(Chatbox_mp_bitmap);
842 // clear all the text lines in the
847 // shutdown all chatbox functionality
850 // only do this if we have valid data
852 // clear all chat data
853 memset(Brief_chat_lines,0,(MAX_BRIEF_CHAT_LINES * (CHATBOX_MAX_LEN + 2)));
854 Brief_start_display_index=0;
855 Num_brief_chat_lines=0;
856 Brief_current_add_line=0;
858 // clear all line recall data
859 Chatbox_recall_count = 0;
860 Chatbox_recall_index = 0;
861 Chatbox_recall_last = -1;
862 memset(Chatbox_recall_lines,0,CHATBOX_MAX_RECALL_LINES * (CHATBOX_MAX_LEN + 2));
866 // render the chatbox for this frame
867 void chatbox_render()
869 if (!Chatbox_created){
873 // clear the multiplayer chat window
874 // gr_set_clip(Chatbox_x1, Chatbox_y1, Chatbox_w, Chatbox_h);
878 // draw the background bitmap if we're supposed to
879 if ( (Chatbox_bitmap != -1) && (Chatbox_mode_flags & CHATBOX_FLAG_DRAW_BOX)) {
880 gr_set_bitmap( Chatbox_bitmap );
881 gr_bitmap(Chatbox_x1, Chatbox_y1);
884 // render the chat lines
885 chatbox_render_chat_lines();
887 // render any UI window stuff
891 // try and scroll the chatbox up. return 0 or 1 on fail or success
892 int chatbox_scroll_up()
894 if(Num_brief_chat_lines > Chatbox_max_lines){
895 int prev = Brief_chat_prev_index[Brief_start_display_index];
897 // check to make sure we won't be going "up" above the "beginning" of the text array
898 if(Brief_chat_prev_index[Brief_current_add_line] != prev && !(Num_brief_chat_lines < MAX_BRIEF_CHAT_LINES && Brief_start_display_index==0)){
899 Brief_start_display_index = prev;
907 // try and scroll the chatbox down, return 0 or 1 on fail or success
908 int chatbox_scroll_down()
913 if(Num_brief_chat_lines > Chatbox_max_lines){
914 // yuck. There's got to be a better way to do this.
915 next = Brief_chat_next_index[Brief_start_display_index];
916 for(idx = 1;idx <= Chatbox_max_lines; idx++){
917 next = Brief_chat_next_index[next];
920 // check to make sure we won't be going "down" below the "bottom" of the text array
921 if(Brief_chat_next_index[Brief_current_add_line] != next){
922 Brief_start_display_index = Brief_chat_next_index[Brief_start_display_index];
929 // quick explanation as to how the scrolling works :
930 // Brief_chat_next_index is an array A of size n, where A[i] = i+1 and A[n] = 0
931 // Brief_chat_prev_index is an array A of size n, where A[i] = i-1 and A[0] = n
932 // in other words, if you increment an integer i = A[i], you get the next index (or the prev)
933 // with wrapping. In this way, as chat lines are entered, they are continuously wrapped
934 // around the Brief_chat_lines array so we can keep it at a fixed size. These arrays are used
935 // for both entering new chat strings as well as moving the Brief_start_display_index
936 // integer, which is self-explanatory
938 void chatbox_chat_init()
944 // setup the wraparound arrays
945 for(idx=0;idx<MAX_BRIEF_CHAT_LINES;idx++){
946 Brief_chat_next_index[idx] = idx+1;
948 Brief_chat_next_index[MAX_BRIEF_CHAT_LINES-1]=0;
950 for(idx=MAX_BRIEF_CHAT_LINES-1; idx > 0 ; idx--){
951 Brief_chat_prev_index[idx] = idx - 1;
953 Brief_chat_prev_index[0] = MAX_BRIEF_CHAT_LINES-1;
955 // initialize the line recall data
956 Chatbox_recall_count = 0;
957 Chatbox_recall_index = 0;
958 Chatbox_recall_last = -1;
959 memset(Chatbox_recall_lines,0,CHATBOX_MAX_RECALL_LINES * (CHATBOX_MAX_LEN + 2));
962 // int Test_color = 0;
963 void chatbox_add_line(char *msg, int pid, int add_id)
968 char *p_str[3]; // for the initial line (unindented)
969 char msg_extra[CHATBOX_STRING_LEN];
971 if(!Chatbox_created){
975 // maybe stick on who sent the message
977 if(MULTI_STANDALONE(Net_players[pid])){
978 sprintf(msg_extra, NOX("%s %s"), NOX("<SERVER>"), msg );
980 sprintf(msg_extra, NOX("%s: %s"), Net_players[pid].player->short_callsign, msg );
983 strcpy(msg_extra,msg);
985 Assert(strlen(msg_extra) < (CHATBOX_STRING_LEN - 2));
987 // split the text up into as many lines as necessary
988 n_lines = split_str(msg_extra, Chatbox_disp_w, n_chars, p_str, 3);
989 Assert(n_lines != -1);
991 // setup the first line -- be sure to clear out the line
992 memset( Brief_chat_lines[Brief_current_add_line], 0, CHATBOX_STRING_LEN );
994 // add the player id #
995 Brief_chat_lines[Brief_current_add_line][0] = (char)(pid % 16);
996 // Brief_chat_lines[Brief_current_add_line][0] = (char)Test_color;
997 // Test_color = (Test_color == MAX_PLAYERS - 1) ? 0 : Test_color++;
999 // set the indent to 0
1000 Brief_chat_indents[Brief_current_add_line] = 0;
1002 // copy in the chars
1003 strncpy(&Brief_chat_lines[Brief_current_add_line][1],p_str[0],CHATBOX_STRING_LEN - 1);
1004 if(n_chars[0] >= CHATBOX_STRING_LEN){
1005 Brief_chat_lines[Brief_current_add_line][CHATBOX_STRING_LEN - 1] = '\0';
1007 Brief_chat_lines[Brief_current_add_line][n_chars[0] + 1] = '\0';
1010 // increment the total line count if we haven't reached the max already
1011 if(Num_brief_chat_lines<MAX_BRIEF_CHAT_LINES){
1012 Num_brief_chat_lines++;
1015 // get the index of the next string to add text to
1016 Brief_current_add_line = Brief_chat_next_index[Brief_current_add_line];
1018 // if we have more than 1 line, re-split everything so that the rest are indented
1020 // split up the string after the first break-marker
1021 n_lines = split_str(msg_extra + n_chars[0],Chatbox_disp_w - CHAT_LINE_INDENT,n_chars,p_str,3);
1022 Assert(n_lines != -1);
1024 // setup these remaining lines
1025 for(idx=0;idx<n_lines;idx++){
1026 // add the player id#
1027 Brief_chat_lines[Brief_current_add_line][0] = (char)(pid % 16);
1029 // add the proper indent
1030 Brief_chat_indents[Brief_current_add_line] = CHAT_LINE_INDENT;
1032 // copy in the line text itself
1033 strncpy(&Brief_chat_lines[Brief_current_add_line][1],p_str[idx],CHATBOX_STRING_LEN-1);
1034 if(n_chars[idx] >= CHATBOX_STRING_LEN){
1035 Brief_chat_lines[Brief_current_add_line][CHATBOX_STRING_LEN - 1] = '\0';
1037 Brief_chat_lines[Brief_current_add_line][n_chars[idx] + 1] = '\0';
1040 // increment the total line count if we haven't reached the max already
1041 if(Num_brief_chat_lines<MAX_BRIEF_CHAT_LINES){
1042 Num_brief_chat_lines++;
1045 // get the index of the next line to add text to
1046 Brief_current_add_line = Brief_chat_next_index[Brief_current_add_line];
1050 // COMMAND LINE OPTION
1051 if(Cmdline_multi_stream_chat_to_file && Multi_chat_stream!=NULL && strlen(msg)>0){ // stream to the file if we're supposed to
1052 cfwrite_string(msg,Multi_chat_stream);
1053 cfwrite_char('\n',Multi_chat_stream);
1056 // if this line of text is from the player himself, automatically go to the bottom of
1058 if(pid == MY_NET_PLAYER_NUM){
1059 if(Num_brief_chat_lines > Chatbox_max_lines){
1060 Brief_start_display_index = Brief_current_add_line;
1061 for(backup = 1;backup <= Chatbox_max_lines;backup++){
1062 Brief_start_display_index = Brief_chat_prev_index[Brief_start_display_index];
1066 // if we have enough lines of text to require scrolling, scroll down by one.
1068 chatbox_scroll_down();
1072 void chatbox_render_chat_lines()
1074 int started_at,player_num,count,ly;
1076 started_at = Brief_start_display_index;
1078 ly = Chatbox_begin_y;
1079 while((count < Chatbox_max_lines) && (count < Num_brief_chat_lines)){
1080 // determine what player this chat line came from, and set the appropriate text color
1081 player_num = Brief_chat_lines[started_at][0];
1083 // print the line out
1084 gr_set_color_fast(Color_netplayer[player_num]);
1086 // draw the first line (no indent)
1087 gr_string(Chatbox_begin_x + Brief_chat_indents[started_at],ly,&Brief_chat_lines[started_at][1]);
1089 // if we're in a team vs. team game, blit the player color icon
1090 if(Netgame.type_flags & NG_TYPE_TEAM){
1091 switch(Net_players[player_num].p_info.team){
1093 // if he's a team captain
1094 if(Net_players[player_num].flags & NETINFO_FLAG_TEAM_CAPTAIN){
1095 if(Multi_common_icons[MICON_TEAM0_SELECT] != -1){
1096 gr_set_bitmap(Multi_common_icons[MICON_TEAM0_SELECT]);
1097 gr_bitmap(Chatbox_icon_x,ly-2);
1100 // just you're average peon
1102 if(Multi_common_icons[MICON_TEAM0] != -1){
1103 gr_set_bitmap(Multi_common_icons[MICON_TEAM0]);
1104 gr_bitmap(Chatbox_icon_x,ly-2);
1109 // if he's a team captain
1110 if(Net_players[player_num].flags & NETINFO_FLAG_TEAM_CAPTAIN){
1111 if(Multi_common_icons[MICON_TEAM1_SELECT] != -1){
1112 gr_set_bitmap(Multi_common_icons[MICON_TEAM1_SELECT]);
1113 gr_bitmap(Chatbox_icon_x,ly-2);
1116 // just your average peon
1118 if(Multi_common_icons[MICON_TEAM1] != -1){
1119 gr_set_bitmap(Multi_common_icons[MICON_TEAM1]);
1120 gr_bitmap(Chatbox_icon_x,ly-2);
1127 // increment the count and line position
1131 // increment the started at index
1132 started_at = Brief_chat_next_index[started_at];
1136 void chatbox_toggle_size()
1138 // if we're in "small" mode
1139 if(Chatbox_mode_flags & CHATBOX_FLAG_SMALL){
1140 chatbox_force_big();
1143 gamesnd_play_iface(SND_IFACE_MOUSE_CLICK);
1145 // if we're in "big" mode
1146 else if(Chatbox_mode_flags & CHATBOX_FLAG_BIG){
1147 chatbox_force_small();
1150 gamesnd_play_iface(SND_IFACE_MOUSE_CLICK);
1154 void chatbox_toggle_size_adjust_lines()
1158 // if the chatbox is now big, move the starting display index _up_ as far as possible
1159 if(Chatbox_mode_flags & CHATBOX_FLAG_BIG){
1160 // if we've wrapped around or we have more chatlines then we can display, move back as far as we can
1161 if((Num_brief_chat_lines > MAX_BRIEF_CHAT_LINES) || (Num_brief_chat_lines > Chatbox_max_lines)){
1162 count_diff = Chatbox_max_lines - chatbox_num_displayed_lines();
1163 while(count_diff > 0){
1164 Brief_start_display_index = Brief_chat_prev_index[Brief_start_display_index];
1168 // otherwise start displaying from position 0
1170 Brief_start_display_index = 0;
1173 // if the chatbox is now small, move the starting display index down as far as we need
1174 else if(Chatbox_mode_flags & CHATBOX_FLAG_SMALL){
1175 count_diff = chatbox_num_displayed_lines();
1176 // if we were displaying more lines than we can now
1177 if(count_diff > Chatbox_max_lines){
1178 count_diff -= Chatbox_max_lines;
1179 while(count_diff > 0){
1180 Brief_start_display_index = Brief_chat_next_index[Brief_start_display_index];
1187 int chatbox_num_displayed_lines()
1189 int idx = Brief_start_display_index;
1192 // count the lines up
1194 while(idx != Brief_current_add_line){
1195 idx = Brief_chat_next_index[idx];
1202 // force the chatbox to go into small mode (if its in large mode) - will not wotk if in multi paused chatbox mode
1203 void chatbox_force_small()
1207 // don't do anything unless we're currently in "big" mode
1208 if(!(Chatbox_mode_flags & CHATBOX_FLAG_BIG)){
1212 new_mode_flags = Chatbox_mode_flags;
1214 // switch to the appropriate mode
1215 new_mode_flags &= ~(CHATBOX_FLAG_SMALL | CHATBOX_FLAG_BIG);
1216 new_mode_flags |= CHATBOX_FLAG_SMALL;
1217 Chatbox_bitmap = Chatbox_small_bitmap;
1219 // flip the up/down arrow
1220 Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].button.set_bmaps(Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].filename);
1222 // call this to set everything up correctly
1223 chatbox_set_mode(new_mode_flags);
1225 // change the location of the input box
1226 Chat_inputbox.update_dimensions(Chatbox_inputbox_x, Chatbox_textenter_y, Chatbox_inputbox_w,15);
1227 Chat_inputbox.set_focus();
1229 // adjust what line we start displaying from based upon the new size of the window
1230 chatbox_toggle_size_adjust_lines();
1233 // force the chatbox to go into big mode (if its in small mode) - will not work if in multi paused chatbox mode
1234 void chatbox_force_big()
1238 // don't do anything unless we're currently in "small" mode
1239 if(!(Chatbox_mode_flags & CHATBOX_FLAG_SMALL)){
1243 new_mode_flags = Chatbox_mode_flags;
1245 // switch to the appropriate mode
1246 new_mode_flags &= ~(CHATBOX_FLAG_SMALL | CHATBOX_FLAG_BIG);
1247 new_mode_flags |= CHATBOX_FLAG_BIG;
1248 Chatbox_bitmap = Chatbox_big_bitmap;
1250 // flip the up/down arrow
1251 Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE].button.set_bmaps(Chatbox_buttons[gr_screen.res][CHATBOX_TOGGLE_SIZE+1].filename);
1253 // call this to set everything up correctly
1254 chatbox_set_mode(new_mode_flags);
1256 // change the location of the input box
1257 Chat_inputbox.update_dimensions(Chatbox_inputbox_x, Chatbox_textenter_y, Chatbox_inputbox_w,15);
1258 Chat_inputbox.set_focus();
1260 // adjust what line we start displaying from based upon the new size of the window
1261 chatbox_toggle_size_adjust_lines();
1264 // "lose" the focus on the chatbox inputbox
1265 void chatbox_lose_focus()
1267 if(!Chatbox_created){
1271 // clear the focus on the inputbox
1272 Chat_inputbox.clear_focus();
1275 // return if the inputbox for the chatbox currently has focus
1276 int chatbox_has_focus()
1278 return Chat_inputbox.has_focus();
1281 // grab the focus for the chatbox inputbox
1282 void chatbox_set_focus()
1284 Chat_inputbox.set_focus();
1287 // return if the inputbox was pressed - "clicked on"
1288 int chatbox_pressed()
1290 return Chat_inputbox.pressed();
1293 // add the string to the line recall list
1294 void chatbox_recall_add(char *string)
1298 // aleays reset the recall index when adding
1299 Chatbox_recall_index = 0;
1300 Chatbox_recall_last = -1;
1302 // if this string matches the last string we entered, don't add it again
1303 if(!strcmp(string,Chatbox_recall_lines[0])){
1307 // move all items up (this works fine for small #'s of recall lines
1308 for(idx=CHATBOX_MAX_RECALL_LINES-1;idx > 0;idx--){
1309 memcpy(&Chatbox_recall_lines[idx],&Chatbox_recall_lines[idx-1],CHATBOX_MAX_LEN+2);
1312 // copy the new item into spot 0
1313 strcpy(Chatbox_recall_lines[0],string);
1315 // increment the recall count if necessary
1316 if(Chatbox_recall_count < CHATBOX_MAX_RECALL_LINES){
1317 Chatbox_recall_count++;
1321 // user has pressed the "up" key
1322 void chatbox_recall_up()
1324 // if we've got no recall lines, do nothing
1325 if(Chatbox_recall_count <= 0){
1329 // if we can increment up
1330 if(Chatbox_recall_index < (Chatbox_recall_count - 1)){
1331 // if this is the last line we recalled, pre-increment
1332 if(Chatbox_recall_last == Chatbox_recall_index){
1333 Chat_inputbox.set_text(Chatbox_recall_lines[++Chatbox_recall_index]);
1334 Chatbox_recall_last = Chatbox_recall_index;
1336 // otherwise, post increment
1338 Chat_inputbox.set_text(Chatbox_recall_lines[Chatbox_recall_index++]);
1339 Chatbox_recall_last = Chatbox_recall_index - 1;
1342 // if we can't increment up
1344 Chat_inputbox.set_text(Chatbox_recall_lines[Chatbox_recall_index]);
1345 Chatbox_recall_last = Chatbox_recall_index;
1349 // user has pressed the "down" key
1350 void chatbox_recall_down()
1352 // if we've got no recall lines, do nothing
1353 if(Chatbox_recall_count <= 0){
1357 // if we can decrement down
1358 if(Chatbox_recall_index > 0){
1359 // if this is the last line we recalled, pre-decrement
1360 if(Chatbox_recall_last == Chatbox_recall_index){
1361 Chat_inputbox.set_text(Chatbox_recall_lines[--Chatbox_recall_index]);
1362 Chatbox_recall_last = Chatbox_recall_index;
1364 // otherwise post,decrement
1366 Chat_inputbox.set_text(Chatbox_recall_lines[Chatbox_recall_index--]);
1367 Chatbox_recall_last = Chatbox_recall_index + 1;
1370 // if we can't decrement down
1372 Chat_inputbox.set_text("");
1373 Chatbox_recall_last = -1;
1377 // reset all timestamps associated with the chatbox
1378 void chatbox_reset_timestamps()
1382 // if there is no chatbox created, do nothing
1383 if(!Chatbox_created){
1387 // otherwise clear all timestamps on all the buttons
1388 for(idx=0; idx<CHATBOX_NUM_BUTTONS+1; idx++){
1389 Chatbox_buttons[gr_screen.res][idx].button.reset_timestamps();