FS2_Open
Open source remastering of the Freespace 2 engine
hudmessage.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #include <stdlib.h>
13 #include <stdarg.h>
14 
15 
16 #include "anim/animplay.h"
17 #include "freespace2/freespace.h"
19 #include "gamesnd/gamesnd.h"
20 #include "globalincs/alphacolors.h"
21 #include "globalincs/linklist.h"
22 #include "hud/hudconfig.h"
23 #include "hud/hudmessage.h"
24 #include "iff_defs/iff_defs.h"
25 #include "io/key.h"
26 #include "io/timer.h"
27 #include "mission/missiongoals.h"
28 #include "mission/missionlog.h"
29 #include "mission/missionmessage.h" // for MAX_MISSION_MESSAGES
31 #include "network/multi.h"
32 #include "parse/parselo.h"
33 #include "parse/scripting.h"
34 #include "playerman/player.h"
35 #include "ship/ship.h"
36 #include "sound/audiostr.h"
37 #include "ui/ui.h"
38 #include "weapon/weapon.h"
39 
40 
41 /* replaced with those static ints that follow
42 #define LIST_X 46
43 #define LIST_X2 108 // second column x start position
44 #define LIST_Y 60
45 #define LIST_W 558 // total width including both columns
46 #define LIST_W2 (LIST_W + LIST_X - LIST_X2) // width of second column
47 #define LIST_H 297
48 #define LIST_H_O 275 // applies only to objectives mode
49 */
50 
51 // 1st column, width includes both columns
52 static int Hud_mission_log_list_coords[GR_NUM_RESOLUTIONS][4] = {
53  {
54  46,60,558,269 // GR_640
55  },
56  {
57  74,96,558,297 // GR_1024
58  }
59 };
60 
61 // 2nd column, width is just of second column
62 static int Hud_mission_log_list2_coords[GR_NUM_RESOLUTIONS][4] = {
63  {
64  108, 60, 496, 297 // GR_640
65  },
66  {
67  136, 96, 496, 436 // GR_1024
68  }
69 };
70 
71 static int Hud_mission_log_list_objective_x_coord[GR_NUM_RESOLUTIONS] = {
72  275, // GR_640
73  440 // GR_1024
74 };
75 
76 static int Hud_mission_log_time_coords[GR_NUM_RESOLUTIONS][2] = {
77  {
78  41, 372 // GR_640
79  },
80  {
81  66, 595 // GR_1024
82  }
83 };
84 
85 static int Hud_mission_log_time2_coords[GR_NUM_RESOLUTIONS][2] = {
86  {
87  103, 372 // GR_640
88  },
89  {
90  128, 595 // GR_1024
91  }
92 };
93 
94 
95 #define SCROLLBACK_MODE_MSGS_LOG 0
96 #define SCROLLBACK_MODE_EVENT_LOG 1
97 #define SCROLLBACK_MODE_OBJECTIVES 2
98 
99 #define NUM_BUTTONS 6
100 
101 #define SCROLL_UP_BUTTON 0
102 #define SCROLL_DOWN_BUTTON 1
103 #define SHOW_MSGS_BUTTON 2
104 #define SHOW_EVENTS_BUTTON 3
105 #define SHOW_OBJS_BUTTON 4
106 #define ACCEPT_BUTTON 5
107 
108 #define HUD_MSG_LENGTH_MAX 2048
109 //#define HUD_MSG_MAX_PIXEL_W 439 // maximum number of pixels wide message display area is
110 //#define HUD_MSG_MAX_PIXEL_W 619 // maximum number of pixels wide message display area is
111 
112 /* not used anymore
113 static int Hud_mission_log_status_coords[GR_NUM_RESOLUTIONS][2] = {
114  {
115  170, 339 // GR_640
116  },
117  {
118  361, 542 // GR_1024
119  }
120 };
121 */
122 
124  char *filename;
125  int x, y;
126  int xt, yt;
127  int hotspot;
128  UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
129 
130  scrollback_buttons(char *name, int x1, int y1, int x2, int y2, int h) : filename(name), x(x1), y(y1), xt(x2), yt(y2), hotspot(h) {}
131 };
132 
134 
136 
137 // There is a maximum number of lines that will be stored in the message scrollback. Oldest
138 // messages are deleted to make way for newest messages.
139 #define MAX_MSG_SCROLLBACK_LINES 1000
141 
144 
145 #define MAX_HUD_FT 1
146 
147 typedef struct HUD_ft {
148  int end_time; // Timestamp at which this message will go away.
149  char text[MAX_HUD_LINE_LEN]; // Text to display.
150  int color; // 0rgb color, 8 bit fields.
151 } HUD_ft;
152 
154 
155 static int Num_obj_lines;
156 static int Scroll_offset;
157 static int Scroll_max;
158 static int Scrollback_mode = SCROLLBACK_MODE_OBJECTIVES;
159 // static int Status_bitmap;
160 static int Background_bitmap;
161 static UI_WINDOW Ui_window;
162 
163 static char* Hud_mission_log_fname[GR_NUM_RESOLUTIONS] = {
164  "MissionLog", // GR_640
165  "2_MissionLog" // GR_1024
166 };
167 
168 /* not used anymore
169 static char* Hud_mission_log_status_fname[GR_NUM_RESOLUTIONS] = {
170  "MLStatus", // GR_640
171  "MLStatus" // GR_1024
172 };
173 */
174 
175 static char* Hud_mission_log_mask_fname[GR_NUM_RESOLUTIONS] = {
176  "MissionLog-m", // GR_640
177  "2_MissionLog-m" // GR_1024
178 };
179 
181  { // GR_640
182  //XSTR:OFF
183  scrollback_buttons("LB_00", 1, 67, -1, -1, 0),
184  scrollback_buttons("LB_01", 1, 307, -1, -1, 1),
185  scrollback_buttons("LB_02", 111, 376, 108, 413, 2),
186  scrollback_buttons("LB_03", 209, 376, 205, 413, 3),
187  scrollback_buttons("LB_04", 12, 376, 7, 413, 4),
188  scrollback_buttons("CB_05a", 571, 425, 564, 413, 5)
189  //XSTR:ON
190  },
191  { // GR_1024
192  //XSTR:OFF
193  scrollback_buttons("2_LB_00", 1, 108, -1, -1, 0),
194  scrollback_buttons("2_LB_01", 1, 492, -1, -1, 1),
195  scrollback_buttons("2_LB_02", 177, 602, 173, 661, 2),
196  scrollback_buttons("2_LB_03", 335, 602, 335, 661, 3),
197  scrollback_buttons("2_LB_04", 20, 602, 11, 661, 4),
198  scrollback_buttons("2_CB_05a",914, 681, 946, 661, 5)
199  //XSTR:ON
200  }
201 }
202 ;
203 
204 // ----------------------------------------------------------------------
205 // HUD_init_fixed_text()
206 //
208 {
209  int i;
210 
211  for (i=0; i<MAX_HUD_FT; i++)
212  HUD_fixed_text[i].end_time = timestamp(0);
213 }
214 
215 // ----------------------------------------------------------------------
216 // hud_init_msg_window()
217 //
218 // Called from HUD_init(), which is called from game_level_init()
219 //
221 {
222  int i;
223 
224  // starting a mission, free the scroll-back buffers, but only if we've been
225  // through this function once already
226  if ( HUD_msg_inited == TRUE ) {
228  }
229 
230  list_init( &Msg_scrollback_free_list );
231  list_init( &Msg_scrollback_used_list );
232 
233  // first slot is reserved for dummy node
234  for (i=1; i < MAX_MSG_SCROLLBACK_LINES; i++) {
235  Msg_scrollback_lines[i].text = NULL;
236  list_append(&Msg_scrollback_free_list, &Msg_scrollback_lines[i]);
237  }
238 
241 }
242 
244 {
245  HUD_msg_buffer.clear();
246 }
247 
250 {
251 }
252 
254 {
255  Max_lines = lines + 1; // One additional line that's not displayed to scroll offscreen.
256 }
257 
259 {
261 }
262 
264 {
265  Scroll_time = ms;
266 }
267 
269 {
270  Step_size = h;
271 }
272 
274 {
275  Total_life = ms;
276 }
277 
279 {
280  Line_h = h;
281 }
282 
284 {
285  Hidden_by_comms_menu = hide;
286 }
287 
289 {
290  // calculate the window height based on the number of lines, and line height
292 
293  active_messages.clear();
294  pending_messages = SCP_queue<HUD_message_data>(); // there's no clear() method for queues :/
295 
296  Scroll_needed = false;
297  Scroll_in_progress = false;
298  Scroll_time_id = 1;
299 
301 }
302 
304 {
305 }
306 
308 {
309  int sw, x, offset = 0;
310  size_t i;
311  char *msg;
312  char *split_str, *ptr;
313 
314  for ( i = 0; i < HUD_msg_buffer.size(); i++ ) {
315  msg = new char [HUD_msg_buffer[i].text.size()+1];
316  strcpy(msg, HUD_msg_buffer[i].text.c_str());
317 
318  ptr = strstr(msg, NOX(": ")) + 2;
319 
320  if ( ptr ) {
321  gr_get_string_size(&sw, NULL, msg, ptr - msg);
322  offset = sw;
323  }
324 
325  x = 0;
326  split_str = msg;
327 
328  while ((ptr = split_str_once(split_str, Max_width - x - 7)) != NULL) { // the 7 is a fudge hack
329  // make sure that split went ok, if not then bail
330  if (ptr == split_str) {
331  break;
332  }
333 
334  addPending(split_str, HUD_msg_buffer[i].source, x);
335  split_str = ptr;
336  x = offset;
337  }
338 
339  addPending(split_str, HUD_msg_buffer[i].source, x);
340 
341  delete[] msg;
342  }
343 }
344 
345 void HudGaugeMessages::addPending(const char *text, int source, int x)
346 {
347  Assert(text != NULL);
348 
349  HUD_message_data new_message;
350 
351  new_message.text = text;
352  new_message.source = source;
353  new_message.x = x;
354 
355  pending_messages.push(new_message);
356 }
357 
359 {
360  // check if there is a message to display on the HUD, and if there is room to display it
361  if ( !pending_messages.empty() && !Scroll_needed ) {
362  Hud_display_info new_active_msg;
363 
364  new_active_msg.msg = pending_messages.front();
365  new_active_msg.total_life = timestamp(Total_life);
366 
367  pending_messages.pop();
368 
370  // determine if there are any existing messages, if so need to scroll them up
371  if ( !timestamp_elapsed(m->total_life) ) {
372  m->target_y -= Line_h;
373  Scroll_needed = true;
374  }
375  }
376 
377  if (Scroll_needed) {
378  new_active_msg.y = (Max_lines-1)*Line_h;
379  new_active_msg.target_y = new_active_msg.y - Line_h;
380  } else {
381  new_active_msg.y = (Max_lines-2)*Line_h;
382  new_active_msg.target_y = new_active_msg.y;
383  }
384 
385  active_messages.push_back(new_active_msg);
386  }
387 
388  Scroll_in_progress = false;
389  Scroll_needed = false;
390 
392  if ( !timestamp_elapsed(m->total_life) ) {
393  if ( m->y > m->target_y ) {
394  Scroll_needed = true;
395 
397  m->y -= Step_size;
398 
399  if ( m->y < m->target_y ) {
400  m->y = m->target_y;
401  }
402 
403  Scroll_in_progress = true;
404  }
405  }
406  } else {
407  bool at_end = m == (active_messages.end() - 1);
408 
409  if (at_end) {
410  // Iterator will be invalid
411  active_messages.pop_back();
412  break;
413  }
414 
415  *m = active_messages.back();
416  active_messages.pop_back();
417 
418  continue;
419  }
420 
421  ++m;
422  }
423 
424  if (Scroll_in_progress) {
426  }
427 }
428 
430 {
431  active_messages.clear();
432 }
433 
435 {
436  setFont();
438  scrollMessages();
439 }
440 
445 void HudGaugeMessages::render(float frametime)
446 {
448 
449  // dependant on max_width, max_lines, and line_height
451 
453  if ( !timestamp_elapsed(m->total_life) ) {
455  // set the appropriate color
456  if ( m->msg.source ) {
458  } else {
459  setGaugeColor();
460  }
461 
462  // print the message out
463  renderPrintf(m->msg.x, m->y, "%s", m->msg.text.c_str());
464  }
465  }
466  }
467 }
468 
469 // Similar to HUD printf, but shows only one message at a time, at a fixed location.
470 void HUD_fixed_printf(float duration, color col, const char *format, ...)
471 {
472  va_list args;
473  char tmp[HUD_MSG_LENGTH_MAX];
474  int msg_length;
475 
476  // make sure we only print these messages if we're in the correct state
478  nprintf(("Network","HUD_fixed_printf bailing because not in multiplayer game play state\n"));
479  return;
480  }
481 
482  va_start(args, format);
483  vsnprintf(tmp, sizeof(tmp)-1, format, args);
484  va_end(args);
485  tmp[sizeof(tmp)-1] = '\0';
486 
487  msg_length = strlen(tmp);
488 
489  if ( !msg_length ) {
490  nprintf(("Warning", "HUD_fixed_printf ==> attempt to print a 0 length string in msg window\n"));
491  return;
492 
493  } else if (msg_length > MAX_HUD_LINE_LEN - 1){
494  nprintf(("Warning", "HUD_fixed_printf ==> Following string truncated to %d chars: %s\n", MAX_HUD_LINE_LEN - 1, tmp));
495  tmp[MAX_HUD_LINE_LEN-1] = '\0';
496  }
497 
498  strcpy_s(HUD_fixed_text[0].text, tmp);
499 
500  if (duration == 0.0f){
501  HUD_fixed_text[0].end_time = timestamp(-1);
502  } else {
503  HUD_fixed_text[0].end_time = timestamp((int) (1000.0f * duration));
504  }
505  HUD_fixed_text[0].color = col.red << 16 | col.green << 8 | col.blue;
506 }
507 
508 // Clear all pending text.
510 {
512 }
513 
514 // converts a TEAM_* define to a HUD_SOURCE_* define
516 {
517  return team + HUD_SOURCE_TEAM_OFFSET;
518 }
519 
520 // converts a HUD_SOURCE_* define to a TEAM_* define
522 {
523  return source - HUD_SOURCE_TEAM_OFFSET;
524 }
525 
526 
527 void HUD_printf(const char *format, ...)
528 {
529  va_list args;
530  char tmp[HUD_MSG_LENGTH_MAX];
531 
532  // make sure we only print these messages if we're in the correct state
534  nprintf(("Network","HUD_printf bailing because not in multiplayer game play state\n"));
535  return;
536  }
537 
538  va_start(args, format);
539  vsnprintf(tmp, sizeof(tmp)-1, format, args);
540  va_end(args);
541  tmp[sizeof(tmp)-1] = '\0';
542 
544 }
545 
546 void HUD_ship_sent_printf(int sh, const char *format, ...)
547 {
548  va_list args;
549  char tmp[HUD_MSG_LENGTH_MAX];
550  tmp[sizeof(tmp)-1] = '\0';
551  int len;
552 
553  snprintf(tmp, sizeof(tmp)-1, NOX("%s: "), Ships[sh].ship_name);
554  len = strlen(tmp);
555 
556  va_start(args, format);
557  vsnprintf(tmp + len, sizeof(tmp)-1-len, format, args);
558  va_end(args);
559 
560  Assert(strlen(tmp) < HUD_MSG_LENGTH_MAX); // If greater than this, probably crashed anyway.
562 }
563 
564 // --------------------------------------------------------------------------------------
565 // HUD_sourced_printf()
566 //
567 // HUD_sourced_printf() has the same parameters as printf(), but displays the text as a scrolling
568 // message on the HUD. Text is split into multiple lines if width exceeds msg display area
569 // width. 'source' is used to indicate who send the message, and is used to color code text.
570 //
571 void HUD_sourced_printf(int source, const char *format, ...)
572 {
573  va_list args;
574  char tmp[HUD_MSG_LENGTH_MAX];
575 
576  // make sure we only print these messages if we're in the correct state
578  nprintf(("Network","HUD_sourced_printf bailing because not in multiplayer game play state\n"));
579  return;
580  }
581 
582  va_start(args, format);
583  vsnprintf(tmp, sizeof(tmp)-1, format, args);
584  va_end(args);
585  tmp[sizeof(tmp)-1] = '\0';
586 
587  hud_sourced_print(source, tmp);
588 }
589 
590 void hud_sourced_print(int source, const char *msg)
591 {
592  if ( !strlen(msg) ) {
593  nprintf(("Warning", "HUD ==> attempt to print a 0 length string in msg window\n"));
594  return;
595  }
596 
597  // add message to the scrollback log first
599 
600  HUD_message_data new_msg;
601 
602  new_msg.text = SCP_string(msg);
603  new_msg.source = source;
604  new_msg.x = 0;
605 
606  HUD_msg_buffer.push_back(new_msg);
607 
608  // Invoke the scripting hook
609  Script_system.SetHookVar("Text", 's', const_cast<char*>(msg));
610  Script_system.SetHookVar("SourceType", 'i', &source);
611 
613 
614  Script_system.RemHookVars(2, "Text", "SourceType");
615 
616 }
617 
619 {
620  int count = 0, y_add = 0;
621  int font_height = gr_get_font_height();
622  line_node *ptr;
623 
624  if (EMPTY(&Msg_scrollback_used_list) || !HUD_msg_inited)
625  return 0;
626 
627  ptr = GET_FIRST(&Msg_scrollback_used_list);
628  while (ptr != END_OF_LIST(&Msg_scrollback_used_list)) {
629  if (ptr->source != HUD_SOURCE_HIDDEN) {
630  y_add = ptr->y;
631  count += font_height + ptr->y;
632  }
633 
634  ptr = GET_NEXT(ptr);
635  }
636 
637  count -= y_add;
638  return count;
639 }
640 
641 // add text directly to the hud scrollback log, without displaying on the hud
642 void HUD_add_to_scrollback(const char *text, int source)
643 {
644  if (!strlen(text)) {
645  nprintf(("Warning", "HUD ==> attempt to print a 0 length string in msg window\n"));
646  return;
647  }
648 
649  hud_add_msg_to_scrollback(text, source, Missiontime);
650 }
651 
652 // hud_add_msg_to_scrollback() adds the new_msg to the scroll-back message list. If there
653 // are no more free slots, the first slot is released to make room for the new message.
654 //
655 void hud_add_line_to_scrollback(char *text, int source, int t, int x, int y, int underline_width)
656 {
657  line_node *new_line;
658 
660  if (!text || !strlen(text))
661  return;
662 
663  if ( EMPTY(&Msg_scrollback_free_list) ) {
664  new_line = GET_FIRST(&Msg_scrollback_used_list);
665  list_remove(&Msg_scrollback_used_list, new_line);
666  vm_free(new_line->text);
667 
668  } else {
669  new_line = GET_FIRST(&Msg_scrollback_free_list);
670  list_remove(&Msg_scrollback_free_list, new_line);
671  }
672 
673  new_line->x = x;
674  new_line->y = y;
675  new_line->underline_width = underline_width;
676  new_line->time = t;
677  new_line->source = source;
678  new_line->text = (char *) vm_malloc( strlen(text) + 1 );
679  strcpy(new_line->text, text);
680  list_append(&Msg_scrollback_used_list, new_line);
681 }
682 
683 void hud_add_msg_to_scrollback(const char *text, int source, int t)
684 {
685  char buf[HUD_MSG_LENGTH_MAX], *ptr, *str;
686  int msg_len, w, max_width, x, offset = 0;
687 
688  max_width = Hud_mission_log_list2_coords[gr_screen.res][2];
689  msg_len = strlen(text);
690  if (msg_len == 0)
691  return;
692 
693  w = 0;
694  Assert(msg_len < HUD_MSG_LENGTH_MAX);
695  strcpy_s(buf, text);
696  ptr = strstr(buf, NOX(": "));
697  if (ptr) {
698  gr_get_string_size(&w, NULL, buf, ptr - buf);
699  }
700 
701 // if (ptr) {
702 // gr_get_string_size(&w, NULL, buf, ptr - buf + 2);
703 // if (w < max_width - 20)
704 // offset = w;
705 // }
706 
707  x = 0;
708  str = buf;
709  while ((ptr = split_str_once(str, max_width - x)) != NULL) {
710  hud_add_line_to_scrollback(str, source, t, x, 1, w);
711  if ( str == ptr )
712  break;
713  str = ptr;
714  x = offset;
715  t = w = 0;
716  }
717 
718  hud_add_line_to_scrollback(str, source, t, x, 3, w);
719 }
720 
721 // hud_free_scrollback_list() will free the memory that was allocated to store the messages
722 // for the scroll-back list
723 //
725 {
726  line_node *A;
727 
728  // check if the list has been inited yet. If not, return with doing nothing.
729  if ( Msg_scrollback_used_list.next == NULL || Msg_scrollback_used_list.prev == NULL )
730  return;
731 
732  A = GET_FIRST(&Msg_scrollback_used_list);
733  while( A !=END_OF_LIST(&Msg_scrollback_used_list) ) {
734  if ( A->text != NULL ) {
735  vm_free(A->text);
736  A->text = NULL;
737  }
738 
739  A = GET_NEXT(A);
740  }
741 }
742 
743 // how many lines to skip
745 {
746  int max = 0, font_height = gr_get_font_height();
747 
748  if (Scrollback_mode == SCROLLBACK_MODE_MSGS_LOG) {
749  int count = 0;
750  line_node *ptr;
751  // number of pixels in excess of what can be displayed
752  int excess = Scroll_max - Hud_mission_log_list_coords[gr_screen.res][3];
753 
754  if (EMPTY(&Msg_scrollback_used_list) || !HUD_msg_inited) {
755  max = 0;
756 
757  } else {
758  ptr = GET_FIRST(&Msg_scrollback_used_list);
759  while (ptr != END_OF_LIST(&Msg_scrollback_used_list)) {
760  if (ptr->source != HUD_SOURCE_HIDDEN) {
761 
762  if (excess > 0) {
763  excess -= font_height;
764  count++;
765  }
766 
767  if (excess <= 0) {
768  max = count;
769  break;
770  }
771 
772  // spacing between lines
773  excess -= ptr->y;
774 
775  }
776 
777  ptr = GET_NEXT(ptr);
778  }
779  }
780 
781  } else {
782  max = (Scroll_max - Hud_mission_log_list_coords[gr_screen.res][3]) / font_height;
783  }
784 
785  if (max < 0)
786  max = 0;
787 
788  return max;
789 }
790 
792 {
793  if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) {
794  Scroll_offset = 0;
795 
796  } else {
797  Scroll_offset = hud_get_scroll_max_pos();
798  }
799 }
800 
801 void hud_scroll_list(int dir)
802 {
803  if (dir) {
804  if (Scroll_offset) {
805  Scroll_offset--;
807 
808  } else
810 
811  } else {
812  if (Scroll_offset < hud_get_scroll_max_pos()) {
813  Scroll_offset++;
815 
816  } else
818  }
819 }
820 
822 {
823  int pos=0, font_height = gr_get_font_height();
824 
825  if (Scrollback_mode == SCROLLBACK_MODE_MSGS_LOG) {
826  int count = 0, y = 0;
827  line_node *ptr;
828 
829  if (EMPTY(&Msg_scrollback_used_list) || !HUD_msg_inited)
830  return;
831 
832  ptr = GET_FIRST(&Msg_scrollback_used_list);
833  while (ptr != END_OF_LIST(&Msg_scrollback_used_list)) {
834  if (ptr->source != HUD_SOURCE_HIDDEN) {
835  if (count == Scroll_offset) {
836  pos = y;
837  break;
838  }
839 
840  y += font_height + ptr->y;
841  count++;
842  }
843 
844  ptr = GET_NEXT(ptr);
845  }
846 
847  Scroll_offset = count = y = 0;
848  ptr = GET_FIRST(&Msg_scrollback_used_list);
849  while (ptr != END_OF_LIST(&Msg_scrollback_used_list)) {
850  if (ptr->source != HUD_SOURCE_HIDDEN) {
851  if (y <= pos + delta)
852  Scroll_offset = count;
853 
854  y += font_height + ptr->y;
855  count++;
856  }
857 
858  ptr = GET_NEXT(ptr);
859  }
860 
861  } else {
862  pos = Scroll_offset * font_height;
863  pos += delta;
864  Scroll_offset = pos / font_height;
865  }
866 }
867 
868 void hud_page_scroll_list(int dir)
869 {
870  int max = hud_get_scroll_max_pos();
871 
872  if (dir) {
873  if (Scroll_offset) {
874  hud_goto_pos(-Hud_mission_log_list_coords[gr_screen.res][3]);
875  if (Scroll_offset < 0)
876  Scroll_offset = 0;
877 
879 
880  } else
882 
883  } else {
884  if (Scroll_offset < max) {
885  hud_goto_pos(Hud_mission_log_list_coords[gr_screen.res][3]);
886  if (Scroll_offset > max)
887  Scroll_offset = max;
888 
890 
891  } else
893  }
894 }
895 
897 {
898  switch (n) {
899  case SCROLL_UP_BUTTON:
900  hud_scroll_list(1);
901  break;
902 
903  case SCROLL_DOWN_BUTTON:
904  hud_scroll_list(0);
905  break;
906 
907  case SHOW_MSGS_BUTTON:
908  Scrollback_mode = SCROLLBACK_MODE_MSGS_LOG;
909  Scroll_max = hud_query_scrollback_size();
911  break;
912 
913  case SHOW_EVENTS_BUTTON:
914  Scrollback_mode = SCROLLBACK_MODE_EVENT_LOG;
915  Scroll_max = Num_log_lines * gr_get_font_height();
917  break;
918 
919  case SHOW_OBJS_BUTTON:
920  Scrollback_mode = SCROLLBACK_MODE_OBJECTIVES;
921  Scroll_max = Num_obj_lines * gr_get_font_height();
922  Scroll_offset = 0;
923  break;
924 
925  case ACCEPT_BUTTON:
927  break;
928  }
929 }
930 
932 {
933  int i;
935 
936  // pause all game sounds
939 
940  common_set_interface_palette("BriefingPalette"); // set the interface palette
942  Ui_window.set_mask_bmap(Hud_mission_log_mask_fname[gr_screen.res]);
943 
944  for (i=0; i<NUM_BUTTONS; i++) {
945  b = &Buttons[gr_screen.res][i];
946 
947  b->button.create(&Ui_window, "", b->x, b->y, 60, 30, (i < 2), 1);
948  // set up callback for when a mouse first goes over a button
950  b->button.set_bmaps(b->filename);
951  b->button.link_hotspot(b->hotspot);
952  }
953 
954  // add all strings
955  Ui_window.add_XSTR("Continue", 1069, Buttons[gr_screen.res][ACCEPT_BUTTON].xt, Buttons[gr_screen.res][ACCEPT_BUTTON].yt, &Buttons[gr_screen.res][ACCEPT_BUTTON].button, UI_XSTR_COLOR_PINK);
956  Ui_window.add_XSTR("Events", 1070, Buttons[gr_screen.res][SHOW_EVENTS_BUTTON].xt, Buttons[gr_screen.res][SHOW_EVENTS_BUTTON].yt, &Buttons[gr_screen.res][SHOW_EVENTS_BUTTON].button, UI_XSTR_COLOR_GREEN);
957  Ui_window.add_XSTR("Objectives", 1071, Buttons[gr_screen.res][SHOW_OBJS_BUTTON].xt, Buttons[gr_screen.res][SHOW_OBJS_BUTTON].yt, &Buttons[gr_screen.res][SHOW_OBJS_BUTTON].button, UI_XSTR_COLOR_GREEN);
958  Ui_window.add_XSTR("Messages", 1072, Buttons[gr_screen.res][SHOW_MSGS_BUTTON].xt, Buttons[gr_screen.res][SHOW_MSGS_BUTTON].yt, &Buttons[gr_screen.res][SHOW_MSGS_BUTTON].button, UI_XSTR_COLOR_GREEN);
959 
960  // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed
963 
964  Background_bitmap = bm_load(Hud_mission_log_fname[gr_screen.res]);
965  // Status_bitmap = bm_load(Hud_mission_log_status_fname[gr_screen.res]);
966 
967  message_log_init_scrollback(Hud_mission_log_list_coords[gr_screen.res][2]);
968  if (Scrollback_mode == SCROLLBACK_MODE_EVENT_LOG)
969  Scroll_max = Num_log_lines * gr_get_font_height();
970  else if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES)
971  Scroll_max = Num_obj_lines * gr_get_font_height();
972  else
973  Scroll_max = hud_query_scrollback_size();
974 
975  Num_obj_lines = ML_objectives_init(Hud_mission_log_list_coords[gr_screen.res][0], Hud_mission_log_list_coords[gr_screen.res][1], Hud_mission_log_list_coords[gr_screen.res][2], Hud_mission_log_list_objective_x_coord[gr_screen.res]);
977 }
978 
980 {
983  if (Background_bitmap >= 0)
984  bm_release(Background_bitmap);
985  //if (Status_bitmap >= 0)
986  // bm_unload(Status_bitmap);
987 
988  Ui_window.destroy();
989  common_free_interface_palette(); // restore game palette
990  game_flush();
991 
992  // unpause all game sounds
995 
996 }
997 
998 void hud_scrollback_do_frame(float frametime)
999 {
1000  int i, k, x, y;
1001  int font_height = gr_get_font_height();
1002 
1003  k = Ui_window.process();
1004  switch (k) {
1005  case KEY_RIGHT:
1006  case KEY_TAB:
1007  if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) {
1008  Scrollback_mode = SCROLLBACK_MODE_MSGS_LOG;
1009  Scroll_max = hud_query_scrollback_size();
1010  hud_scroll_reset();
1011 
1012  } else if (Scrollback_mode == SCROLLBACK_MODE_MSGS_LOG) {
1013  Scrollback_mode = SCROLLBACK_MODE_EVENT_LOG;
1014  Scroll_max = Num_log_lines * gr_get_font_height();
1015  hud_scroll_reset();
1016 
1017  } else {
1018  Scrollback_mode = SCROLLBACK_MODE_OBJECTIVES;
1019  Scroll_max = Num_obj_lines * gr_get_font_height();
1020  Scroll_offset = 0;
1021  }
1022 
1023  break;
1024 
1025  case KEY_LEFT:
1026  case KEY_SHIFTED | KEY_TAB:
1027  if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) {
1028  Scrollback_mode = SCROLLBACK_MODE_EVENT_LOG;
1029  Scroll_max = Num_log_lines * gr_get_font_height();
1030  hud_scroll_reset();
1031 
1032  } else if (Scrollback_mode == SCROLLBACK_MODE_MSGS_LOG) {
1033  Scrollback_mode = SCROLLBACK_MODE_OBJECTIVES;
1034  Scroll_max = Num_obj_lines * gr_get_font_height();
1035  Scroll_offset = 0;
1036 
1037  } else {
1038  Scrollback_mode = SCROLLBACK_MODE_MSGS_LOG;
1039  Scroll_max = hud_query_scrollback_size();
1040  hud_scroll_reset();
1041  }
1042 
1043  break;
1044 
1045  case KEY_PAGEUP:
1047  break;
1048 
1049  case KEY_PAGEDOWN:
1051  break;
1052 
1053  case KEY_ENTER:
1054  case KEY_CTRLED | KEY_ENTER:
1055  case KEY_ESC:
1057  break;
1058 
1059  case KEY_F1: // show help overlay
1060  break;
1061 
1062  case KEY_F2: // goto options screen
1064  break;
1065  } // end switch
1066 
1067  for (i=0; i<NUM_BUTTONS; i++){
1068  if (Buttons[gr_screen.res][i].button.pressed()){
1070  }
1071  }
1072 
1073  GR_MAYBE_CLEAR_RES(Background_bitmap);
1074  if (Background_bitmap >= 0) {
1075  gr_set_bitmap(Background_bitmap);
1076  gr_bitmap(0, 0, GR_RESIZE_MENU);
1077  }
1078 
1079  /*
1080  if ((Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) && (Status_bitmap >= 0)) {
1081  gr_set_bitmap(Status_bitmap);
1082  gr_bitmap(Hud_mission_log_status_coords[gr_screen.res][0], Hud_mission_log_status_coords[gr_screen.res][1], GR_RESIZE_MENU);
1083  }
1084  */
1085 
1086  // draw the objectives key at the bottom of the ingame objectives screen
1087  if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) {
1089  }
1090 
1091  Ui_window.draw();
1092 
1093  if (Scrollback_mode == SCROLLBACK_MODE_EVENT_LOG) {
1095  mission_log_scrollback(Scroll_offset, Hud_mission_log_list_coords[gr_screen.res][0], Hud_mission_log_list_coords[gr_screen.res][1], Hud_mission_log_list_coords[gr_screen.res][2], Hud_mission_log_list_coords[gr_screen.res][3]);
1096 
1097  } else if (Scrollback_mode == SCROLLBACK_MODE_OBJECTIVES) {
1099  ML_objectives_do_frame(Scroll_offset);
1100 
1101  } else {
1102  line_node *node_ptr;
1103 
1105 // y = ((LIST_H / font_height) - 1) * font_height;
1106  y = 0;
1107  if ( !EMPTY(&Msg_scrollback_used_list) && HUD_msg_inited ) {
1108  node_ptr = GET_FIRST(&Msg_scrollback_used_list);
1109  i = 0;
1110  while ( node_ptr != END_OF_LIST(&Msg_scrollback_used_list) ) {
1111  if ((node_ptr->source == HUD_SOURCE_HIDDEN) || (i++ < Scroll_offset)) {
1112  node_ptr = GET_NEXT(node_ptr);
1113 
1114  } else {
1115  int team = HUD_source_get_team(node_ptr->source);
1116 
1117  if (team >= 0)
1118  {
1120  }
1121  else
1122  {
1123  switch (node_ptr->source)
1124  {
1125  case HUD_SOURCE_TRAINING:
1127  break;
1128 
1129  case HUD_SOURCE_TERRAN_CMD:
1131  break;
1132 
1133  case HUD_SOURCE_IMPORTANT:
1134  case HUD_SOURCE_FAILED:
1135  case HUD_SOURCE_SATISFIED:
1137  break;
1138 
1139  default:
1141  break;
1142  }
1143  }
1144 
1145  if (node_ptr->time)
1146  gr_print_timestamp(Hud_mission_log_list_coords[gr_screen.res][0], Hud_mission_log_list_coords[gr_screen.res][1] + y, node_ptr->time, GR_RESIZE_MENU);
1147 
1148  x = Hud_mission_log_list2_coords[gr_screen.res][0] + node_ptr->x;
1149  gr_printf_menu(x, Hud_mission_log_list_coords[gr_screen.res][1] + y, "%s", node_ptr->text);
1150  if (node_ptr->underline_width)
1151  gr_line(x, Hud_mission_log_list_coords[gr_screen.res][1] + y + font_height - 1, x + node_ptr->underline_width, Hud_mission_log_list_coords[gr_screen.res][1] + y + font_height - 1, GR_RESIZE_MENU);
1152 
1153  if ((node_ptr->source == HUD_SOURCE_FAILED) || (node_ptr->source == HUD_SOURCE_SATISFIED)) {
1154  // draw goal icon
1155  if (node_ptr->source == HUD_SOURCE_FAILED)
1157  else
1159 
1160  i = Hud_mission_log_list_coords[gr_screen.res][1] + y + font_height / 2 - 1;
1161  gr_circle(Hud_mission_log_list2_coords[gr_screen.res][0] - 6, i, 5, GR_RESIZE_MENU);
1162 
1164  gr_line(Hud_mission_log_list2_coords[gr_screen.res][0] - 10, i, Hud_mission_log_list2_coords[gr_screen.res][0] - 8, i, GR_RESIZE_MENU);
1165  gr_line(Hud_mission_log_list2_coords[gr_screen.res][0] - 6, i - 4, Hud_mission_log_list2_coords[gr_screen.res][0] - 6, i - 2, GR_RESIZE_MENU);
1166  gr_line(Hud_mission_log_list2_coords[gr_screen.res][0] - 4, i, Hud_mission_log_list2_coords[gr_screen.res][0] - 2, i, GR_RESIZE_MENU);
1167  gr_line(Hud_mission_log_list2_coords[gr_screen.res][0] - 6, i + 2, Hud_mission_log_list2_coords[gr_screen.res][0] - 6, i + 4, GR_RESIZE_MENU);
1168  }
1169 
1170  y += font_height + node_ptr->y;
1171  node_ptr = GET_NEXT(node_ptr);
1172  if (y + font_height > Hud_mission_log_list_coords[gr_screen.res][3])
1173  break;
1174  }
1175  }
1176  }
1177  }
1178 
1180  gr_print_timestamp(Hud_mission_log_time_coords[gr_screen.res][0], Hud_mission_log_time_coords[gr_screen.res][1] - font_height, Missiontime, GR_RESIZE_MENU);
1181  gr_string(Hud_mission_log_time2_coords[gr_screen.res][0], Hud_mission_log_time_coords[gr_screen.res][1] - font_height, XSTR( "Current time", 289), GR_RESIZE_MENU);
1182  gr_flip();
1183 }
1184 
1186 {
1188 }
1189 
1192 {
1193 }
1194 
1196 {
1197  head_anim = NULL;
1198  msg_id = -1;
1199 
1201 }
1202 
1204 {
1205  Header_offsets[0] = x;
1206  Header_offsets[1] = y;
1207 }
1208 
1210 {
1211  Anim_offsets[0] = x;
1212  Anim_offsets[1] = y;
1213 }
1214 
1216 {
1217  Anim_size[0] = w;
1218  Anim_size[1] = h;
1219 }
1220 
1221 void HudGaugeTalkingHead::initBitmaps(const char *fname)
1222 {
1223  Head_frame.first_frame = bm_load_animation(fname, &Head_frame.num_frames);
1224  if ( Head_frame.first_frame == -1 ) {
1225  Warning(LOCATION, "Could not load in ani: %s\n", fname);
1226  }
1227 }
1228 
1232 anim_instance* HudGaugeTalkingHead::createAnim(int anim_start_frame, anim* anim_data)
1233 {
1234  anim_play_struct aps;
1235 
1236  float scale_x = i2fl(Anim_size[0]) / i2fl(anim_data->width);
1237  float scale_y = i2fl(Anim_size[1]) / i2fl(anim_data->height);
1238  anim_play_init(&aps, anim_data, fl2ir((position[0] + Anim_offsets[0] + HUD_offset_x) / scale_x), fl2ir((position[1] + Anim_offsets[1] + HUD_offset_y) / scale_y), base_w, base_h);
1239  aps.start_at = anim_start_frame;
1240 
1241  // aps.color = &HUD_color_defaults[HUD_color_alpha];
1243  // I'd much rather use gr_init_color and retrieve the colors from this object but no, aps.color just happens to be a pointer.
1244  // So, just give it the address from the player's HUD configuration. You win, aps.color. I'll take care of you next time. (Swifty)
1245 
1246  return anim_play(&aps);
1247 }
1248 
1253 void HudGaugeTalkingHead::render(float frametime)
1254 {
1255  if ( Head_frame.first_frame == -1 ){
1256  return;
1257  }
1258 
1259  if(msg_id != -1 && head_anim != NULL) {
1260  if(!head_anim->done_playing) {
1261  // draw frame
1262  // hud_set_default_color();
1263  setGaugeColor();
1264 
1265  // clear
1266  setClip(position[0] + Anim_offsets[0], position[1] + Anim_offsets[1], Anim_size[0], Anim_size[1]);
1267  gr_clear();
1268  resetClip();
1269 
1270  renderBitmap(Head_frame.first_frame, position[0], position[1]); // head ani border
1271  float scale_x = i2fl(Anim_size[0]) / i2fl(head_anim->width);
1272  float scale_y = i2fl(Anim_size[1]) / i2fl(head_anim->height);
1273  gr_set_screen_scale(fl2ir(base_w / scale_x), fl2ir(base_h / scale_y));
1274  setGaugeColor();
1275  generic_anim_render(head_anim,frametime, fl2ir((position[0] + Anim_offsets[0] + HUD_offset_x) / scale_x), fl2ir((position[1] + Anim_offsets[1] + HUD_offset_y) / scale_y));
1276  // draw title
1278  renderString(position[0] + Header_offsets[0], position[1] + Header_offsets[1], XSTR("message", 217));
1279  } else {
1280  for (int j = 0; j < Num_messages_playing; ++j) {
1281  if (Playing_messages[j].id == msg_id) {
1282  Playing_messages[j].play_anim = false;
1283  break; // only one head ani plays at a time
1284  }
1285  }
1286  msg_id = -1; // allow repeated messages to display a new head ani
1287  head_anim = NULL; // Nothing to see here anymore, move along
1288  }
1289  }
1290  // check playing messages to see if we have any messages with talking animations that need to be created.
1291  for (int i = 0; i < Num_messages_playing; i++ ) {
1292  if(Playing_messages[i].play_anim && Playing_messages[i].id != msg_id ) {
1293  msg_id = Playing_messages[i].id;
1294  if (Playing_messages[i].anim_data)
1295  head_anim = Playing_messages[i].anim_data;
1296  else
1297  head_anim = NULL;
1298 
1299  return;
1300  }
1301  }
1302 }
1303 
1305 {
1306  bm_page_in_aabitmap( Head_frame.first_frame, Head_frame.num_frames );
1307 }
1308 
1310 {
1311  if (sexp_override) {
1312  return false;
1313  }
1314 
1316  return false;
1317  }
1318 
1319  if(!active)
1320  return false;
1321 
1322  if ( !(Game_detail_flags & DETAIL_FLAG_HUD) ) {
1323  return false;
1324  }
1325 
1326  if ((Viewer_mode & disabled_views)) {
1327  return false;
1328  }
1329 
1330  if(pop_up) {
1331  if(!popUpActive()) {
1332  return false;
1333  }
1334  }
1335 
1336  return true;
1337 }
1338 
1341 {
1342 }
1343 
1344 void HudGaugeFixedMessages::render(float frametime) {
1345  HUD_ft *hp;
1346 
1347  hp = &HUD_fixed_text[0];
1348 
1349  if (!timestamp_elapsed(hp->end_time)) {
1350  gr_set_color((hp->color >> 16) & 0xff, (hp->color >> 8) & 0xff, hp->color & 0xff);
1351 
1352  renderString(position[0], position[1], hp->text);
1353  //renderString(0x8000, MSG_WINDOW_Y_START + MSG_WINDOW_HEIGHT + 8, hp->text);
1354  }
1355 }
1356 
1358 {
1359 }
int source
Definition: hudmessage.h:42
void game_flush()
Definition: fredstubs.cpp:83
GLenum GLsizei GLenum format
Definition: Gl.h:1509
void render(float frametime)
Definition: hudmessage.cpp:445
HUD_message_data msg
Definition: hudmessage.h:52
virtual void initialize()
Definition: hud.cpp:1049
void set_highlight_action(void(*_user_function)(void))
Definition: button.cpp:375
void * color
Definition: animplay.h:35
int timestamp(int delta_ms)
Definition: timer.cpp:226
int height
Definition: packunpack.h:44
#define MAX_MSG_SCROLLBACK_LINES
Definition: hudmessage.cpp:139
int i
Definition: multi_pxo.cpp:466
SCP_queue< HUD_message_data > pending_messages
Definition: hudmessage.h:96
fix Missiontime
Definition: systemvars.cpp:19
#define vm_free(ptr)
Definition: pstypes.h:548
void hud_clear_msg_buffer()
Definition: hudmessage.cpp:243
void add_XSTR(char *string, int _xstr_id, int _x, int _y, UI_GADGET *_assoc, int _color_type, int _font_id=-1)
Definition: window.cpp:476
#define gr_clear
Definition: 2d.h:749
#define NETPLAYER_STATE_IN_MISSION
Definition: multi.h:686
int team
Definition: ship.h:606
int disabled_views
Definition: hud.h:221
#define HUD_TALKING_HEAD
Definition: hudgauges.h:43
#define HUD_C_BRIGHT
Definition: hud.h:162
#define KEY_DOWN
Definition: key.h:180
int flags
Definition: player.h:104
int Game_mode
Definition: systemvars.cpp:24
int ML_objectives_init(int x, int y, int w, int h)
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
#define KEY_LEFT
Definition: key.h:181
void gr_flip()
Definition: 2d.cpp:2113
void hud_add_line_to_scrollback(char *text, int source, int t, int x, int y, int underline_width)
Definition: hudmessage.cpp:655
color * iff_get_color_by_team(int team, int seen_from_team, int is_bright)
Definition: iff_defs.cpp:644
line_node Msg_scrollback_used_list
Definition: hudmessage.cpp:143
#define KEY_PAGEDOWN
Definition: key.h:178
line_node Msg_scrollback_free_list
Definition: hudmessage.cpp:142
#define GR_RESIZE_MENU
Definition: 2d.h:684
net_player * Net_player
Definition: multi.cpp:94
int HUD_msg_inited
Definition: hudmessage.cpp:135
#define VM_WARP_CHASE
Definition: systemvars.h:37
#define KEY_RIGHT
Definition: key.h:182
__inline void gr_circle(int xc, int yc, int d, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:774
void setGaugeColor(int bright_index=-4)
Definition: hud.cpp:445
unsigned char done_playing
Definition: generic.h:26
void message_log_init_scrollback(int pw)
Definition: missionlog.cpp:645
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
void initMaxLines(int lines)
Definition: hudmessage.cpp:253
Assert(pm!=NULL)
#define fl2ir(fl)
Definition: floating.h:34
#define GR_NUM_RESOLUTIONS
Definition: 2d.h:651
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:769
int popUpActive()
Definition: hud.cpp:578
general failure sound for any event
Definition: gamesnd.h:297
Definition: 2d.h:95
int res
Definition: 2d.h:370
int max_h_unscaled
Definition: 2d.h:361
void HUD_printf(const char *format,...)
Definition: hudmessage.cpp:527
CButton * team
int base_h
Definition: hud.h:205
GLclampf f
Definition: Glext.h:7097
void ML_render_objectives_key()
void message_log_shutdown_scrollback()
Definition: missionlog.cpp:839
#define SCROLLBACK_MODE_OBJECTIVES
Definition: hudmessage.cpp:97
#define TRUE
Definition: pstypes.h:399
color clr[NUM_HUD_GAUGES]
Definition: hudconfig.h:60
#define ACCEPT_BUTTON
Definition: hudmessage.cpp:106
#define GR_MAYBE_CLEAR_RES(bmap)
Definition: 2d.h:639
int hud_query_scrollback_size()
Definition: hudmessage.cpp:618
void gr_print_timestamp(int x, int y, fix timestamp, int resize_mode)
Definition: font.cpp:143
void gr_set_screen_scale(int w, int h, int zoom_w, int zoom_h, int max_w, int max_h, int center_w, int center_h, bool force_stretch)
Definition: 2d.cpp:104
void gr_set_color_fast(color *dst)
Definition: 2d.cpp:1197
#define KEY_PAGEUP
Definition: key.h:175
ubyte blue
Definition: 2d.h:102
Definition: ui.h:195
int width
Definition: generic.h:45
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
Definition: vmallocator.h:21
void hud_scrollback_close()
Definition: hudmessage.cpp:979
void hud_page_scroll_list(int dir)
Definition: hudmessage.cpp:868
void hud_scroll_list(int dir)
Definition: hudmessage.cpp:801
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
Definition: 2d.cpp:2105
int max_w_unscaled
Definition: 2d.h:361
void HUD_sourced_printf(int source, const char *format,...)
Definition: hudmessage.cpp:571
scrollback_buttons(char *name, int x1, int y1, int x2, int y2, int h)
Definition: hudmessage.cpp:130
int height
Definition: generic.h:44
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: Glext.h:7308
void hud_set_default_color()
Set the current color to the default HUD color (with default alpha)
Definition: hud.cpp:2918
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
Definition: bmpman.cpp:2603
#define MAX_HUD_FT
Definition: hudmessage.cpp:145
script_state Script_system("FS2_Open Scripting")
void setClip(int x, int y, int w, int h)
Definition: hud.cpp:942
int game_state
Definition: multi.h:498
char * text
Definition: hudmessage.h:46
int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *keyframe, int can_drop_frames, int dir_type)
Loads a bitmap sequance so we can draw with it.
Definition: bmpman.cpp:1420
void HUD_init_fixed_text()
Definition: hudmessage.cpp:207
GLint GLsizei width
Definition: Gl.h:1505
Definition: hud.h:201
ubyte green
Definition: 2d.h:101
#define SCROLL_UP_BUTTON
Definition: hudmessage.cpp:101
void gr_set_color(int r, int g, int b)
Definition: 2d.cpp:1188
void common_set_interface_palette(char *filename)
int Num_messages_playing
void draw_forced(int frame_num)
Definition: button.cpp:104
char text[MAX_HUD_LINE_LEN]
Definition: hudmessage.cpp:149
void destroy()
Definition: window.cpp:189
void set_mask_bmap(char *fname)
Definition: window.cpp:75
int set_bmaps(char *ani_filename, int nframes=3, int start_frame=1)
Definition: gadget.cpp:71
HUD_ft HUD_fixed_text[MAX_HUD_FT]
Definition: hudmessage.cpp:153
#define SCROLL_DOWN_BUTTON
Definition: hudmessage.cpp:102
GLintptr offset
Definition: Glext.h:5497
#define VM_DEAD_VIEW
Definition: systemvars.h:33
void initAnimOffsets(int x, int y)
void common_free_interface_palette()
void HUD_ship_sent_printf(int sh, const char *format,...)
Definition: hudmessage.cpp:546
SCP_vector< HUD_message_data > HUD_msg_buffer
Definition: hudmessage.cpp:133
#define SHOW_MSGS_BUTTON
Definition: hudmessage.cpp:103
void weapon_pause_sounds()
Definition: weapons.cpp:7248
color Color_bright
Definition: alphacolors.cpp:28
#define HUD_SOURCE_IMPORTANT
Definition: hudmessage.h:24
#define HUD_SOURCE_COMPUTER
Definition: hudmessage.h:21
#define HUD_MESSAGE_LINES
Definition: hudgauges.h:45
color Color_bright_green
Definition: alphacolors.cpp:31
void processMessageBuffer()
Definition: hudmessage.cpp:307
int state
Definition: multi.h:464
void ML_objectives_close()
#define nprintf(args)
Definition: pstypes.h:239
#define SHOW_EVENTS_BUTTON
Definition: hudmessage.cpp:104
#define GM_MULTIPLAYER
Definition: systemvars.h:18
#define SHOW_OBJS_BUTTON
Definition: hudmessage.cpp:105
bool Scroll_in_progress
Definition: hudmessage.h:99
int num_frames
Definition: hud.h:34
#define HUD_OBJECT_TALKING_HEAD
Definition: hudparse.h:94
netgame_info Netgame
Definition: multi.cpp:97
int pressed()
Definition: button.cpp:325
void initHiddenByCommsMenu(bool hide)
Definition: hudmessage.cpp:283
#define HUD_SOURCE_TEAM_OFFSET
Definition: hudmessage.h:30
#define KEY_SHIFTED
Definition: key.h:62
bool sexp_override
Definition: hud.h:217
int base_w
Definition: hud.h:205
void generic_anim_render(generic_anim *ga, float frametime, int x, int y, bool menu)
Definition: generic.cpp:437
#define w(p)
Definition: modelsinc.h:68
#define HUD_OBJECT_FIXED_MESSAGES
Definition: hudparse.h:214
#define KEY_ENTER
Definition: key.h:125
ubyte red
Definition: 2d.h:100
void addPending(const char *text, int source, int x=0)
Definition: hudmessage.cpp:345
int width
Definition: packunpack.h:43
#define HUD_SOURCE_HIDDEN
Definition: hudmessage.h:23
#define HUD_OBJECT_MESSAGES
Definition: hudparse.h:70
int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str, int max_lines, char ignore_char)
Definition: parselo.cpp:3412
int Num_log_lines
Definition: missionlog.cpp:62
#define DETAIL_FLAG_HUD
Definition: systemvars.h:114
#define CHA_HUDMSGRECEIVED
Definition: scripting.h:78
#define delta
Definition: fvi.cpp:418
void resetClip()
Definition: hud.cpp:978
GLdouble GLdouble t
Definition: Glext.h:5329
void initBitmaps(const char *fname)
void renderString(int x, int y, const char *str)
Definition: hud.cpp:665
#define HUD_SOURCE_TRAINING
Definition: hudmessage.h:22
int color
Definition: hudmessage.cpp:150
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
GLclampd n
Definition: Glext.h:7286
int hud_disabled()
Checks if HUD disabled.
Definition: hud.cpp:1306
void hud_free_scrollback_list()
Definition: hudmessage.cpp:724
const char * XSTR(const char *str, int index)
Definition: localize.cpp:851
void setFont()
Definition: hud.cpp:440
void render(float frametime)
ship * Player_ship
Definition: ship.cpp:124
color Color_bright_red
Definition: alphacolors.cpp:34
#define NOX(s)
Definition: pstypes.h:473
#define HUD_SOURCE_FAILED
Definition: hudmessage.h:25
#define KEY_F1
Definition: key.h:143
anim_instance * anim_play(anim_play_struct *aps)
Will add an anim instance to the anim_render_list. This will cause the anim to be played at the x...
Definition: animplay.cpp:143
void hud_scrollback_exit()
generic_anim * anim_data
#define vm_malloc(size)
Definition: pstypes.h:547
void set_hotkey(int keycode)
Definition: gadget.cpp:280
#define NETGAME_STATE_IN_MISSION
Definition: multi.h:666
GLuint const GLchar * name
Definition: Glext.h:5608
__inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:791
int RunCondition(int condition, char format='\0', void *data=NULL, class object *objp=NULL, int more_data=0)
Definition: scripting.cpp:924
SCP_string text
Definition: hudmessage.h:33
int first_frame
Definition: hud.h:33
pmessage Playing_messages[MAX_PLAYING_MESSAGES]
void weapon_unpause_sounds()
Definition: weapons.cpp:7257
void initAnimSizes(int w, int h)
void hud_add_msg_to_scrollback(const char *text, int source, int t)
Definition: hudmessage.cpp:683
void hud_scrollback_init()
Definition: hudmessage.cpp:931
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
Definition: bmpman.cpp:1119
GLboolean GLboolean GLboolean b
Definition: Glext.h:5781
ship Ships[MAX_SHIPS]
Definition: ship.cpp:122
void mission_log_scrollback(int line, int list_x, int list_y, int list_w, int list_h)
Definition: missionlog.cpp:851
uint Game_detail_flags
Definition: systemvars.cpp:52
void HUD_fixed_printf_reset()
Definition: hudmessage.cpp:509
int HUD_team_get_source(int team)
Definition: hudmessage.cpp:515
color Color_bright_white
Definition: alphacolors.cpp:32
void hud_scrollback_button_pressed(int n)
Definition: hudmessage.cpp:896
scroll pressed (and scroll)
Definition: gamesnd.h:296
void anim_play_init(anim_play_struct *aps, anim *a_info, int x, int y, int base_w, int base_h)
Setup an anim_play_struct for passing into anim_play().
Definition: animplay.cpp:117
void HUD_add_to_scrollback(const char *text, int source)
Definition: hudmessage.cpp:642
void link_hotspot(int num)
Definition: gadget.cpp:50
#define SCROLLBACK_MODE_MSGS_LOG
Definition: hudmessage.cpp:95
void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus=0)
Definition: button.cpp:26
#define KEY_ESC
Definition: key.h:124
GLubyte GLubyte GLubyte GLubyte w
Definition: Glext.h:5679
int position[2]
Definition: hud.h:204
#define UI_XSTR_COLOR_PINK
Definition: ui.h:161
void bm_page_in_aabitmap(int bitmapnum, int nframes)
Marks a texture as being used for this level, and is anti-aliased.
Definition: bmpman.cpp:2354
#define NUM_BUTTONS
Definition: hudmessage.cpp:99
void create(int _x, int _y, int _w, int _h, int _flags, int _f_id=-1)
Definition: window.cpp:140
#define HUD_SOURCE_TERRAN_CMD
Definition: hudmessage.h:27
player * Player
void audiostream_unpause_all(bool via_sexp_or_script=false)
Definition: audiostr.cpp:1990
void hud_scrollback_do_frame(float frametime)
Definition: hudmessage.cpp:998
bool active
Definition: hud.h:215
Definition: ui.h:584
bool play_anim
screen gr_screen
Definition: 2d.cpp:46
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
Definition: font.cpp:196
char * split_str_once(char *src, int max_pixel_w)
Definition: parselo.cpp:3330
#define KEY_F2
Definition: key.h:144
int gr_get_font_height()
Definition: font.cpp:187
int hud_get_scroll_max_pos()
Definition: hudmessage.cpp:744
void RemHookVars(unsigned int num,...)
Definition: scripting.cpp:754
void initMaxWidth(int width)
Definition: hudmessage.cpp:258
int underline_width
Definition: hudmessage.h:45
HUD_CONFIG_TYPE HUD_config
Definition: hudconfig.cpp:49
#define LOCATION
Definition: pstypes.h:245
void common_play_highlight_sound()
Definition: gamesnd.cpp:1151
#define VM_PADLOCK_ANY
Definition: systemvars.h:46
void hud_init_msg_window()
Definition: hudmessage.cpp:220
#define HUD_SOURCE_SATISFIED
Definition: hudmessage.h:26
int Viewer_mode
Definition: systemvars.cpp:28
#define timestamp_elapsed(stamp)
Definition: timer.h:102
#define MAX_HUD_LINE_LEN
Definition: hudmessage.h:19
void SetHookVar(char *name, char format, void *data=NULL)
Definition: scripting.cpp:650
hull_check pos
Definition: lua.cpp:5050
const GLfloat * m
Definition: Glext.h:10319
float HUD_offset_x
Definition: hud.cpp:90
void ML_objectives_do_frame(int scroll_offset)
#define KEY_CTRLED
Definition: key.h:64
#define KEY_TAB
Definition: key.h:127
bool pop_up
Definition: hud.h:218
void renderPrintf(int x, int y, const char *format,...)
Definition: hud.cpp:724
#define i2fl(i)
Definition: floating.h:32
GLint GLsizei count
Definition: Gl.h:1491
GLsizei GLsizei GLchar * source
Definition: Glext.h:5625
void gr_bitmap(int _x, int _y, int resize_mode)
Definition: 2d.cpp:1303
#define KEY_UP
Definition: key.h:179
matrix * A
Definition: lua.cpp:444
#define UI_XSTR_COLOR_GREEN
Definition: ui.h:160
struct HUD_ft HUD_ft
void HUD_fixed_printf(float duration, color col, const char *format,...)
Definition: hudmessage.cpp:470
GLenum GLsizei len
Definition: Glext.h:6283
color Color_text_normal
Definition: alphacolors.cpp:26
bool Hidden_by_comms_menu
Definition: hudmessage.h:90
void initTotalLife(int ms)
Definition: hudmessage.cpp:273
void initStepSize(int h)
Definition: hudmessage.cpp:268
void initHeaderOffsets(int x, int y)
float HUD_offset_y
Definition: hud.cpp:91
color Color_text_heading
Definition: alphacolors.cpp:28
#define HUD_MSG_LENGTH_MAX
Definition: hudmessage.cpp:108
void hud_sourced_print(int source, const char *msg)
Definition: hudmessage.cpp:590
false
Definition: lua.cpp:6789
line_node Msg_scrollback_lines[MAX_MSG_SCROLLBACK_LINES]
Definition: hudmessage.cpp:140
color Color_bright_blue
Definition: alphacolors.cpp:31
void gamesnd_play_iface(int n)
Definition: gamesnd.cpp:260
void audiostream_pause_all(bool via_sexp_or_script=false)
Definition: audiostr.cpp:1978
void hud_scroll_reset()
Definition: hudmessage.cpp:791
void draw()
Definition: window.cpp:220
line_node * prev
Definition: hudmessage.h:40
int hud_disabled_except_messages()
Like hud_disabled(), except messages are still drawn.
Definition: hud.cpp:1297
#define FALSE
Definition: pstypes.h:400
int process(int key_in=-1, int process_mouse=1)
Definition: window.cpp:401
void _cdecl gr_printf_menu(int x, int y, const char *format,...)
Definition: font.cpp:314
void gameseq_post_event(int event)
int HUD_source_get_team(int source)
Definition: hudmessage.cpp:521
void initLineHeight(int h)
Definition: hudmessage.cpp:278
#define PLAYER_FLAGS_MSG_MODE
Definition: player.h:37
void render(float frametime)
void initScrollTime(int ms)
Definition: hudmessage.cpp:263
void hud_goto_pos(int delta)
Definition: hudmessage.cpp:821
int end_time
Definition: hudmessage.cpp:148
anim_instance * createAnim(int anim_start_frame, anim *anim_data)
fix time
Definition: hudmessage.h:41
SCP_vector< Hud_display_info > active_messages
Definition: hudmessage.h:95
line_node * next
Definition: hudmessage.h:39
GLint y
Definition: Gl.h:1505
#define SCROLLBACK_MODE_EVENT_LOG
Definition: hudmessage.cpp:96
#define strcpy_s(...)
Definition: safe_strings.h:67
void renderBitmap(int x, int y)
Definition: hud.cpp:782