2 * $Logfile: /Freespace2/code/Mission/MissionBriefCommon.cpp $
7 * C module for briefing code common to FreeSpace and FRED
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 * 19 11/02/99 3:23p Jefff
18 * translate briefing icon names
20 * 18 9/09/99 9:44a Jefff
21 * doh, fixed reversed brief text color thingy. i am stoopid.
23 * 17 9/08/99 11:14a Jefff
24 * toned down hostile/friendly colors in briefing text
26 * 16 9/07/99 12:20p Mikeb
27 * return pos of briefing icon even it does not fit on screen.
29 * 15 9/03/99 1:32a Dave
30 * CD checking by act. Added support to play 2 cutscenes in a row
31 * seamlessly. Fixed super low level cfile bug related to files in the
32 * root directory of a CD. Added cheat code to set campaign mission # in
35 * 14 8/10/99 7:28p Jefff
36 * shuffled some text around
38 * 13 7/30/99 3:05p Jefff
39 * Fixed briefing icon fades -- in and out were reversed.
41 * 12 7/26/99 1:52p Mikeb
42 * Fixed strange briefing bug where a NULL wasn't being checked for when
43 * copying briefing stage text. Odd.
45 * 11 7/24/99 6:15p Jefff
46 * moved "stage x of y" text in multiplayer mode so its not covered by the
49 * 10 7/20/99 7:09p Jefff
50 * briefing text occupies full window in 1024x768
52 * 9 7/09/99 5:54p Dave
53 * Seperated cruiser types into individual types. Added tons of new
54 * briefing icons. Campaign screen.
56 * 8 6/29/99 7:39p Dave
57 * Lots of small bug fixes.
59 * 7 2/05/99 7:19p Neilk
60 * Removed black part from mission screen, fixed info text coords
62 * 6 1/29/99 4:17p Dave
63 * New interface screens.
65 * 5 12/18/98 1:13a Dave
66 * Rough 1024x768 support for Direct3D. Proper detection and usage through
69 * 4 10/23/98 3:51p Dave
70 * Full support for tstrings.tbl and foreign languages. All that remains
71 * is to make it active in Fred.
73 * 3 10/13/98 9:28a Dave
74 * Started neatening up freespace.h. Many variables renamed and
75 * reorganized. Added AlphaColors.[h,cpp]
77 * 2 10/07/98 10:53a Dave
80 * 1 10/07/98 10:49a Dave
82 * 122 6/09/98 10:31a Hoffoss
83 * Created index numbers for all xstr() references. Any new xstr() stuff
84 * added from here on out should be added to the end if the list. The
85 * current list count can be found in FreeSpace.cpp (search for
88 * 121 6/05/98 9:54a Lawrance
91 * 120 6/01/98 11:43a John
92 * JAS & MK: Classified all strings for localization.
94 * 119 5/23/98 10:38p Lawrance
95 * Avoid doing a cfile refresh when running debug
97 * 118 5/23/98 6:49p Lawrance
98 * Fix problems with refreshing the file list when a CD is inserted
100 * 117 5/21/98 6:57p Lawrance
101 * Don't prompt for the CD if voice not found
103 * 116 5/21/98 12:35a Lawrance
104 * Tweak how CD is checked for
106 * 115 5/12/98 11:46a John
107 * Changed the way the "glowing movement" type text draw. Use Hoffoss's
108 * gr_get_string_size optional length parameter to determine length of
109 * string which accounts for kerning on the last character and then I only
110 * draw each character only once.
112 * 114 5/08/98 5:32p Lawrance
113 * prompt for CD if can't load animations or voice
115 * 113 5/06/98 5:30p John
116 * Removed unused cfilearchiver. Removed/replaced some unused/little used
117 * graphics functions, namely gradient_h and _v and pixel_sp. Put in new
118 * DirectX header files and libs that fixed the Direct3D alpha blending
121 * 112 4/27/98 9:08p Allender
122 * fix the debriefing stage problems when clients get to screen long after
125 * 111 4/25/98 3:49p Lawrance
126 * Save briefing auto-advance pref
128 * 110 4/20/98 3:53p Lawrance
129 * Fix various bugs with auto-advancing through briefings.
134 #include "freespace.h"
142 #include "linklist.h"
149 #include "missionbrief.h"
150 #include "missiongrid.h"
151 #include "missionbriefcommon.h"
152 #include "animplay.h"
158 #include "audiostr.h"
159 #include "missioncmdbrief.h"
160 #include "missiondebrief.h"
161 #include "alphacolors.h"
162 #include "localize.h"
164 // --------------------------------------------------------------------------------------
166 // --------------------------------------------------------------------------------------
167 hud_frames Icon_bitmaps[MAX_BRIEF_ICONS][MAX_SPECIES_NAMES];
168 hud_anim Icon_highlight_anims[MAX_BRIEF_ICONS][MAX_SPECIES_NAMES];
169 hud_anim Icon_fade_anims[MAX_BRIEF_ICONS][MAX_SPECIES_NAMES];
172 // --------------------------------------------------------------------------------------
174 // --------------------------------------------------------------------------------------
176 brief_screen bscreen;
178 // briefing screen sections
179 #define BRIEF_CUP_X1 400
180 #define BRIEF_CUP_Y1 70
181 #define BRIEF_CUP_X2 639
182 #define BRIEF_CUP_Y2 245
183 #define BRIEF_CUPINFO_X1 445
184 #define BRIEF_CUPINFO_Y1 247
185 #define BRIEF_CUPINFO_X2 639
186 #define BRIEF_CUPINFO_Y2 438
188 char *Brief_static_name[GR_NUM_RESOLUTIONS] = {
193 int Brief_static_coords[GR_NUM_RESOLUTIONS][2] = {
202 int Brief_bmap_coords[GR_NUM_RESOLUTIONS][2] = {
211 int Brief_grid_coords[GR_NUM_RESOLUTIONS][4] = {
220 int Brief_text_coords[GR_NUM_RESOLUTIONS][4] = {
229 int Brief_stage_text_coords[GR_NUM_RESOLUTIONS][2] = {
238 int Brief_stage_text_coords_multi[GR_NUM_RESOLUTIONS][2] = {
247 int Brief_text_max_lines[GR_NUM_RESOLUTIONS] = {
251 #define LOOKAT_DIST 500.0f
253 // --------------------------------------------------------------------------------------
254 // Game-wide global data
255 // --------------------------------------------------------------------------------------
256 briefing Briefings[MAX_TEAMS]; // there is exactly one briefing per mission
257 debriefing Debriefings[MAX_TEAMS]; // there can be multiple debriefings per mission
258 briefing *Briefing; // pointer used in code -- points to correct briefing
259 debriefing *Debriefing; // pointer to correct debriefing
261 int Briefing_voice_enabled=1; // flag which turn on/off voice playback of briefings/debriefings
263 // --------------------------------------------------------------------------------------
264 // Module global data
265 // --------------------------------------------------------------------------------------
267 static int Last_new_stage;
270 const char BRIEF_META_CHAR = '$';
272 // static int Brief_voice_ask_for_cd;
275 static vector Current_cam_pos; // current camera position
276 static vector Target_cam_pos; // desired camera position
277 static matrix Current_cam_orient; // current camera orientation
278 static matrix Target_cam_orient; // desired camera orientation
279 static matrix Start_cam_orient; // start camera orientation
280 static vector Start_cam_pos; // position of camera at the start of a translation
281 static vector Cam_vel; // camera velocity
282 static vector Current_lookat_pos; // lookat point
283 static vector Target_lookat_pos; // lookat point
284 static vector Start_lookat_pos;
285 static vector Lookat_vel; // lookat point velocity
287 static float Start_cam_move; // time at which camera started moving (seconds)
288 static float Total_move_time; // time in which camera should move from current pos to target pos (seconds)
289 static float Elapsed_time;
291 static float Start_dist;
292 static float End_dist;
293 static float Dist_change_rate;
295 static vector Acc_limit;
296 static vector Vel_limit;
298 static float Total_dist;
299 static float Peak_speed;
300 static float Cam_accel;
301 static float Last_dist;
302 static vector W_init;
304 // flag to indicate that the sound for a spinning highlight animation has played
305 static int Brief_stage_highlight_sound_handle = -1;
307 // used for scrolling briefing text ( if necessary )
308 int Num_brief_text_lines[MAX_TEXT_STREAMS];
309 int Top_brief_text_line;
310 static char Brief_text[MAX_BRIEF_LINES][MAX_BRIEF_LINE_LEN];
312 // Used to support drawing colored text for the briefing. Gets complicates since we
313 // need to be able to draw one character at a time as well when the briefing text
315 typedef struct colored_char
318 ubyte color; // index into Brief_text_colors[]
321 static colored_char Colored_text[MAX_TEXT_STREAMS][MAX_BRIEF_LINES][MAX_BRIEF_LINE_LEN];
322 static int Colored_text_len[MAX_TEXT_STREAMS][MAX_BRIEF_LINES];
324 #define MAX_BRIEF_TEXT_COLORS 9
325 #define BRIEF_TEXT_WHITE 0
326 #define BRIEF_TEXT_BRIGHT_WHITE 1
327 #define BRIEF_TEXT_RED 2
328 #define BRIEF_TEXT_GREEN 3
329 #define BRIEF_TEXT_YELLOW 4
330 #define BRIEF_TEXT_BLUE 5
331 #define BRIEF_IFF_FRIENDLY 6
332 #define BRIEF_IFF_HOSTILE 7
333 #define BRIEF_IFF_NEUTRAL 8
335 color Brief_color_red, Brief_color_green;
337 color *Brief_text_colors[MAX_BRIEF_TEXT_COLORS] =
347 &IFF_colors[IFF_COLOR_NEUTRAL][0],
350 #define BRIGHTEN_LEAD 2
352 float Brief_text_wipe_time_elapsed;
353 static int Max_briefing_line_len;
355 static int Brief_voice_ended;
356 static int Brief_textdraw_finished;
357 static int Brief_voice_started;
358 static int Brief_stage_time;
360 const float BRIEF_TEXT_WIPE_TIME = 1.5f; // time in seconds for wipe to occur
361 static int Brief_text_wipe_snd; // sound handle of sound effect for text wipe
362 static int Play_brief_voice;
365 static int Play_highlight_flag;
366 static int Cam_target_reached;
367 static int Cam_movement_done;
370 typedef struct icon_move_info
372 icon_move_info *next, *prev;
379 // used to move icons smoothly
383 float total_move_time;
389 #define MAX_MOVE_ICONS 10
390 icon_move_info Icon_movers[MAX_MOVE_ICONS];
391 icon_move_info Icon_move_list; // head of linked list
394 typedef struct fade_icon
396 hud_anim fade_anim; // anim info
401 #define MAX_FADE_ICONS 30
402 fade_icon Fading_icons[MAX_FADE_ICONS];
405 // voice id's for briefing text
406 int Brief_voices[MAX_BRIEF_STAGES];
408 cmd_brief *Cur_cmd_brief;
409 cmd_brief Cmd_briefs[MAX_TEAMS];
411 // --------------------------------------------------------------------------------------
412 // forward declarations
413 // --------------------------------------------------------------------------------------
414 void brief_render_elements(vector *pos, grid *gridp);
415 void brief_render_icons(int stage_num, float frametime);
416 void brief_parse_icon_tbl();
417 void brief_grid_read_camera_controls( control_info * ci, float frametime );
418 void brief_maybe_create_new_grid(grid *gridp, vector *pos, matrix *orient, int force = 0);
419 grid *brief_create_grid(grid *gridp, vector *forward, vector *right, vector *center, int nrows, int ncols, float square_size);
420 grid *brief_create_default_grid(void);
421 void brief_render_grid(grid *gridp);
422 void brief_modify_grid(grid *gridp);
423 void brief_rpd_line(vector *v0, vector *v1);
424 void brief_set_text_color(int color_index);
425 extern void get_camera_limits(matrix *start_camera, matrix *end_camera, float time, vector *acc_max, vector *w_max);
426 int brief_text_wipe_finished();
428 void brief_set_icon_color(int team)
431 case TEAM_FRIENDLY: SET_COLOR_FRIENDLY; break;
432 case TEAM_HOSTILE: SET_COLOR_HOSTILE; break;
433 case TEAM_NEUTRAL: SET_COLOR_NEUTRAL; break;
434 case TEAM_TRAITOR: SET_COLOR_HOSTILE; break;
436 SET_COLOR_HOSTILE; break;
440 // --------------------------------------------------------------------------------------
441 // brief_move_icon_reset()
444 void brief_move_icon_reset()
448 list_init(&Icon_move_list);
449 for ( i = 0; i < MAX_MOVE_ICONS; i++ )
450 Icon_movers[i].used = 0;
454 // --------------------------------------------------------------------------------------
455 // Does one time initialization of the briefing and debriefing structures.
456 // Namely setting all malloc'ble pointers to NULL. Called once at game startup.
457 void mission_brief_common_init()
461 // setup brief text colors
462 gr_init_alphacolor( &Brief_color_green, 50, 100, 50, 255 );
463 gr_init_alphacolor( &Brief_color_red, 140, 20, 20, 255 );
465 if ( Fred_running ) {
466 // If Fred is running malloc out max space
467 for (i=0; i<MAX_TEAMS; i++ ) {
468 for (j=0; j<MAX_BRIEF_STAGES; j++ ) {
469 Briefings[i].stages[j].new_text = (char *)malloc(MAX_BRIEF_LEN);
470 Assert(Briefings[i].stages[j].new_text!=NULL);
471 Briefings[i].stages[j].icons = (brief_icon *)malloc(sizeof(brief_icon)*MAX_STAGE_ICONS);
472 Assert(Briefings[i].stages[j].icons!=NULL);
473 Briefings[i].stages[j].lines = (brief_line *)malloc(sizeof(brief_line)*MAX_BRIEF_STAGE_LINES);
474 Assert(Briefings[i].stages[j].lines!=NULL);
475 Briefings[i].stages[j].num_icons = 0;
476 Briefings[i].stages[j].num_lines = 0;
480 for (i=0; i<MAX_TEAMS; i++ ) {
481 for (j=0; j<MAX_DEBRIEF_STAGES; j++ ) {
482 Debriefings[i].stages[j].new_text = (char *)malloc(MAX_DEBRIEF_LEN);
483 Assert(Debriefings[i].stages[j].new_text!=NULL);
484 Debriefings[i].stages[j].new_recommendation_text = (char *)malloc(MAX_RECOMMENDATION_LEN);
485 Assert(Debriefings[i].stages[j].new_recommendation_text!=NULL);
490 // If game is running don't malloc anything
491 for (i=0; i<MAX_TEAMS; i++ ) {
492 for (j=0; j<MAX_BRIEF_STAGES; j++ ) {
493 Briefings[i].stages[j].new_text = NULL;
494 Briefings[i].stages[j].num_icons = 0;
495 Briefings[i].stages[j].icons = NULL;
496 Briefings[i].stages[j].num_lines = 0;
497 Briefings[i].stages[j].lines = NULL;
501 for (i=0; i<MAX_TEAMS; i++ ) {
502 for (j=0; j<MAX_DEBRIEF_STAGES; j++ ) {
503 Debriefings[i].stages[j].new_text = NULL;
504 Debriefings[i].stages[j].new_recommendation_text = NULL;
513 //--------------------------------------------------------------------------------------
514 // Frees all the memory allocated in the briefing and debriefing structures
515 // and sets all pointers to NULL.
516 void mission_brief_common_reset()
520 if ( Fred_running ) {
521 return; // Don't free these under Fred.
524 for (i=0; i<MAX_TEAMS; i++ ) {
525 for (j=0; j<MAX_BRIEF_STAGES; j++ ) {
526 if ( Briefings[i].stages[j].new_text ) {
527 free(Briefings[i].stages[j].new_text);
528 Briefings[i].stages[j].new_text = NULL;
531 if ( Briefings[i].stages[j].icons ) {
532 free(Briefings[i].stages[j].icons);
533 Briefings[i].stages[j].icons = NULL;
536 if ( Briefings[i].stages[j].lines ) {
537 free(Briefings[i].stages[j].lines);
538 Briefings[i].stages[j].lines = NULL;
543 for (i=0; i<MAX_TEAMS; i++ ) {
544 for (j=0; j<MAX_DEBRIEF_STAGES; j++ ) {
545 if ( Debriefings[i].stages[j].new_text ) {
546 free(Debriefings[i].stages[j].new_text);
547 Debriefings[i].stages[j].new_text = NULL;
549 if ( Debriefings[i].stages[j].new_recommendation_text ) {
550 free(Debriefings[i].stages[j].new_recommendation_text);
551 Debriefings[i].stages[j].new_recommendation_text = NULL;
561 // --------------------------------------------------------------------------------------
570 for ( i = 0; i < MAX_TEAMS; i++ )
571 Briefings[i].num_stages = 0;
575 // --------------------------------------------------------------------------------------
584 for ( i = 0; i < MAX_TEAMS; i++ ) {
585 Debriefings[i].num_stages = 0;
586 for (j=0; j<MAX_DEBRIEF_STAGES; j++ ) {
587 if ( Debriefings[i].stages[j].new_recommendation_text ) {
588 Debriefings[i].stages[j].new_recommendation_text[0] = 0;
593 // MWA 4/27/98 -- must initialize this variable here since we cannot do it as debrief
594 // init time because race conditions between all players in the game make that type of
595 // initialization unsafe.
596 Debrief_multi_stages_loaded = 0;
599 // --------------------------------------------------------------------------------------
600 // brief_init_screen()
602 // Set up the screen regions. A mulitplayer briefing will look different than a single player
605 void brief_init_screen(int multiplayer_flag)
607 bscreen.map_x1 = Brief_grid_coords[gr_screen.res][0];
608 bscreen.map_x2 = Brief_grid_coords[gr_screen.res][0] + Brief_grid_coords[gr_screen.res][2];
609 bscreen.map_y1 = Brief_grid_coords[gr_screen.res][1];
610 bscreen.map_y2 = Brief_grid_coords[gr_screen.res][1] + Brief_grid_coords[gr_screen.res][3];
612 bscreen.map_x1 = BRIEF_GRID3_X1;
613 bscreen.map_x2 = BRIEF_GRID0_X2;
614 bscreen.map_y1 = BRIEF_GRID3_Y1;
615 bscreen.map_y2 = BRIEF_GRID0_Y2+4;
616 bscreen.btext_x1 = BRIEF_TEXT_X1;
617 bscreen.btext_x2 = BRIEF_TEXT_X2;
618 bscreen.btext_y1 = BRIEF_TEXT_Y1;
619 bscreen.btext_y2 = BRIEF_TEXT_Y2;
620 bscreen.cup_x1 = BRIEF_CUP_X1;
621 bscreen.cup_y1 = BRIEF_CUP_Y1;
622 bscreen.cup_x2 = BRIEF_CUP_X2;
623 bscreen.cup_y2 = BRIEF_CUP_Y2;
624 bscreen.cupinfo_x1 = BRIEF_CUPINFO_X1;
625 bscreen.cupinfo_y1 = BRIEF_CUPINFO_Y1;
626 bscreen.cupinfo_x2 = BRIEF_CUPINFO_X2;
627 bscreen.cupinfo_y2 = BRIEF_CUPINFO_Y2;
631 // --------------------------------------------------------------------------------------
632 // brief_init_icons()
635 void brief_init_icons()
637 if ( Fred_running ) {
638 gr_init_alphacolor( &IFF_colors[IFF_COLOR_HOSTILE][0], 0xff, 0x00, 0x00, 15*16 );
639 gr_init_alphacolor( &IFF_colors[IFF_COLOR_FRIENDLY][0], 0x00, 0xff, 0x00, 15*16 );
642 // Load in the bitmaps for the icons from icons.tbl
643 brief_parse_icon_tbl();
646 // Reset the highlight and fade anims... call before brief_parse_icon_tbl();
647 void brief_init_anims()
651 for (i=0; i<MAX_BRIEF_ICONS; i++) {
652 for(idx=0; idx<MAX_SPECIES_NAMES; idx++){
653 Icon_highlight_anims[i][idx].num_frames=0;
654 Icon_fade_anims[i][idx].num_frames=0;
659 // ------------------------------------------------------------------------
660 // brief_unload_icons()
663 void brief_unload_icons()
668 for ( i = 0; i < MAX_BRIEF_ICONS; i++ ) {
669 for(idx=0; idx<MAX_SPECIES_NAMES; idx++){
670 ib = &Icon_bitmaps[i][idx];
672 for ( j=0; j<ib->num_frames; j++ ) {
673 bm_unload(ib->first_frame+j);
679 // determine if icon type is used in the current briefing
680 int brief_icon_used_in_briefing(int icon_type)
682 int num_icons, num_stages, i, j;
684 num_stages = Briefing->num_stages;
686 for ( i = 0; i < num_stages; i++ ) {
687 num_icons = Briefing->stages[i].num_icons;
688 for ( j = 0; j < num_icons; j++ ) {
689 if ( Briefing->stages[i].icons[j].type == icon_type ) {
698 // --------------------------------------------------------------------------------------
699 // brief_parse_icon_tbl()
702 void brief_parse_icon_tbl()
705 char name[NAME_LENGTH];
713 if ((rval = setjmp(parse_abort)) != 0) {
714 Error(LOCATION, "Unable to parse icons.tbl! Code = %i.\n", rval);
717 read_file_text("icons.tbl");
722 required_string("#Start");
725 int load_this_icon = 0;
727 while (required_string_either("#End","$Name:")) {
728 for(idx=0; idx<MAX_SPECIES_NAMES; idx++){
729 Assert( num_icons < MAX_BRIEF_ICONS);
730 hf = &Icon_bitmaps[num_icons][idx];
732 // load in regular frames
733 required_string("$Name:");
734 stuff_string(name, F_NAME, NULL);
736 if ( Fred_running ) {
739 load_this_icon = brief_icon_used_in_briefing(num_icons);
742 if ( load_this_icon ) {
743 hf->first_frame = bm_load_animation(name, &hf->num_frames);
744 if ( hf->first_frame == -1 ) {
745 Int3(); // missing briefing icon
749 // load in fade frames
750 required_string("$Name:");
751 stuff_string(name, F_NAME, NULL);
752 ha = &Icon_fade_anims[num_icons][idx];
753 hud_anim_init(ha, 0, 0, name);
755 // load in highlighting frames
756 required_string("$Name:");
757 stuff_string(name, F_NAME, NULL);
758 ha = &Icon_highlight_anims[num_icons][idx];
759 hud_anim_init(ha, 0, 0, name);
765 required_string("#End");
767 // close localization
771 // --------------------------------------------------------------------------------------
775 void brief_close_map()
777 brief_unload_icons();
780 void brief_preload_highlight_anim(brief_icon *bi)
783 int species = ship_get_species_by_type(bi->ship_class);
789 ha = &Icon_highlight_anims[bi->type][species];
790 if ( !stricmp(NOX("none"), ha->name) ) {
794 // force read of data from disk, so we don't glitch on initial playback
795 if ( ha->first_frame == -1 ) {
797 Assert(ha->first_frame >= 0);
800 bi->highlight_anim = *ha;
802 gr_set_bitmap(ha->first_frame);
806 void brief_preload_fade_anim(brief_icon *bi)
809 int species = ship_get_species_by_type(bi->ship_class);
815 ha = &Icon_fade_anims[bi->type][species];
816 if ( !stricmp(NOX("none"), ha->name) ) {
820 // force read of data from disk, so we don't glitch on initial playback
821 if ( ha->first_frame == -1 ) {
823 Assert(ha->first_frame >= 0);
826 gr_set_bitmap(ha->first_frame);
830 // preload highlight, fadein and fadeout animations that are used in this stage
831 void brief_preload_anims()
833 int num_icons, num_stages, i, j;
836 num_stages = Briefing->num_stages;
838 for ( i = 0; i < num_stages; i++ ) {
839 num_icons = Briefing->stages[i].num_icons;
840 for ( j = 0; j < num_icons; j++ ) {
841 bi = &Briefing->stages[i].icons[j];
842 if ( bi->flags & BI_HIGHLIGHT ) {
843 brief_preload_highlight_anim(bi);
845 brief_preload_fade_anim(bi);
850 // --------------------------------------------------------------------------------------
854 void brief_init_map()
859 Assert( Briefing != NULL );
861 pos = &Briefing->stages[0].camera_pos;
862 orient = &Briefing->stages[0].camera_orient;
863 vm_vec_zero(&Current_lookat_pos);
864 vm_vec_zero(&Target_lookat_pos);
866 Total_move_time = 0.0f;
868 The_grid = brief_create_default_grid();
869 brief_maybe_create_new_grid(The_grid, pos, orient, 1);
873 brief_move_icon_reset();
874 brief_preload_anims();
876 Brief_text_wipe_snd = -1;
882 #pragma optimize("", off)
884 // render fade-out anim frame
885 static int Fade_frame_count[128]; // for debug
887 void brief_render_fade_outs(float frametime)
891 vertex tv; // temp vertex used to find screen position for text
895 for (i=0; i<Num_fade_icons; i++) {
896 fi = &Fading_icons[i];
898 g3_rotate_vertex(&tv, &fi->pos);
900 if (!(tv.flags & PF_PROJECTED))
901 g3_project_vertex(&tv);
903 if (!(tv.flags & PF_OVERFLOW) ) { // make sure point projected before drawing text
905 brief_set_icon_color(fi->team);
907 if ( fi->fade_anim.first_frame < 0 ) {
911 bm_get_info( fi->fade_anim.first_frame, &w, &h, NULL);
913 bxf = tv.sx - w / 2.0f + 0.5f;
914 byf = tv.sy - h / 2.0f + 0.5f;
918 if ( fi->fade_anim.first_frame >= 0 ) {
919 fi->fade_anim.sx = bx;
920 fi->fade_anim.sy = by;
921 hud_anim_render(&fi->fade_anim, frametime, 1, 0, 0, 0);
927 // figure out how far an icon should move based on the elapsed time
928 float brief_icon_get_dist_moved(icon_move_info *mi, float elapsed_time)
930 float time, dist_moved=0.0f;
932 // first half of movement
933 if ( elapsed_time < mi->total_move_time/2.0f ) {
934 dist_moved=0.5f*mi->accel*elapsed_time*elapsed_time; // d = 1/2at^2
938 // second half of movement
939 time=elapsed_time - mi->total_move_time/2.0f;
940 dist_moved=(mi->total_dist/2.0f)+(mi->peak_speed*time) - 0.5f*mi->accel*time*time;
944 // Draw a line between two icons on the briefing screen
945 void brief_render_icon_line(int stage_num, int line_num)
949 vertex icon_vertex[2];
950 int icon_status[2] = {0,0};
951 int icon_w, icon_h, i;
952 float icon_x[2], icon_y[2];
954 bl = &Briefing->stages[stage_num].lines[line_num];
955 icon[0] = &Briefing->stages[stage_num].icons[bl->start_icon];
956 icon[1] = &Briefing->stages[stage_num].icons[bl->end_icon];
959 for (i=0; i<2; i++) {
960 g3_rotate_vertex(&icon_vertex[i],&icon[i]->pos);
961 if (!(icon_vertex[i].flags&PF_PROJECTED))
962 g3_project_vertex(&icon_vertex[i]);
964 if (!(icon_vertex[i].flags & PF_OVERFLOW) ) { // make sure point projected before drawing text
969 if ( !icon_status[0] || !icon_status[1] ) {
973 // get screen (x,y) for icons
974 for (i=0; i<2; i++) {
975 brief_common_get_icon_dimensions(&icon_w, &icon_h, icon[i]->type, icon[i]->ship_class);
976 icon_x[i] = icon_vertex[i].sx;
977 icon_y[i] = icon_vertex[i].sy;
980 brief_set_icon_color(icon[0]->team);
982 gr_line(fl2i(icon_x[0]), fl2i(icon_y[0]), fl2i(icon_x[1]), fl2i(icon_y[1]));
985 // -------------------------------------------------------------------------------------
986 // Draw a briefing icon
988 // parameters: stage_num => briefing stage number (start at 0)
989 // icon_num => icon number in stage
990 // frametime => time elapsed in seconds
991 // selected => FRED only (will be 0 or non-zero)
992 // w_scale_factor => scale icon in width by this amount (default 1.0f)
993 // h_scale_factor => scale icon in height by this amount (default 1.0f)
994 void brief_render_icon(int stage_num, int icon_num, float frametime, int selected, float w_scale_factor, float h_scale_factor)
996 brief_icon *bi, *closeup_icon;
998 vertex tv; // temp vertex used to find screen position for text
1000 int bx,by,bc,w,h,icon_w,icon_h,icon_bitmap=-1;
1001 float bxf, byf, dist=0.0f;
1003 Assert( Briefing != NULL );
1005 bi = &Briefing->stages[stage_num].icons[icon_num];
1007 icon_move_info *mi, *next;
1008 int interp_pos_found = 0;
1010 mi = GET_FIRST(&Icon_move_list);
1012 while ( mi != &Icon_move_list ) {
1014 if ( ( mi->id != 0 ) && ( mi->id == bi->id ) ) {
1016 if ( !mi->reached_dest ) {
1017 dist = brief_icon_get_dist_moved(mi, Elapsed_time);
1018 if ( dist < mi->last_dist ) {
1025 if ( !mi->reached_dest ) {
1027 vm_vec_copy_scale(&dist_moved, &mi->direction, dist);
1028 vm_vec_add(&mi->current, &mi->start, &dist_moved);
1030 mi->current = mi->finish;
1034 interp_pos_found = 1;
1040 if ( !interp_pos_found )
1043 brief_render_elements(pos, The_grid);
1044 g3_rotate_vertex(&tv,pos);
1046 if (!(tv.flags&PF_PROJECTED))
1047 g3_project_vertex(&tv);
1049 if (!(tv.flags & PF_OVERFLOW) ) { // make sure point projected before drawing text
1051 brief_set_icon_color(bi->team);
1053 int species = ship_get_species_by_type(bi->ship_class);
1059 ib = &Icon_bitmaps[bi->type][species];
1060 if ( ib->first_frame < 0 ) {
1065 brief_common_get_icon_dimensions(&icon_w, &icon_h, bi->type, bi->ship_class);
1067 closeup_icon = (brief_icon*)brief_get_closeup_icon();
1068 if ( bi == closeup_icon || selected ) {
1069 icon_bitmap=ib->first_frame+1;
1070 // gr_set_bitmap(ib->first_frame+1);
1073 icon_bitmap=ib->first_frame;
1074 // gr_set_bitmap(ib->first_frame);
1077 // draw icon centered at draw position
1078 // bx = fl2i(tv.sx - ib->icon_w/2.0f);
1079 // by = fl2i(tv.sy - ib->icon_h/2.0f);
1080 // bc = bx + fl2i(ib->icon_w/2.0f);
1081 //gr_aabitmap(bx, by);
1083 float scaled_w, scaled_h;
1085 scaled_w = icon_w * w_scale_factor;
1086 scaled_h = icon_h * h_scale_factor;
1087 bxf = tv.sx - scaled_w / 2.0f + 0.5f;
1088 byf = tv.sy - scaled_h / 2.0f + 0.5f;
1093 if ( (bx < 0) || (bx > gr_screen.max_w) || (by < 0) || (by > gr_screen.max_h) && !Fred_running ) {
1105 vb.sx = bxf+scaled_w-1;
1106 vb.sy = byf+scaled_h-1;
1110 // render highlight anim frame
1111 if ( (bi->flags&BI_SHOWHIGHLIGHT) && (bi->flags&BI_HIGHLIGHT) ) {
1112 hud_anim *ha = &bi->highlight_anim;
1113 if ( ha->first_frame >= 0 ) {
1114 ha->sx = bi->hold_x;
1115 if ( strlen(bi->label) > 0 ) {
1116 ha->sy = bi->hold_y - fl2i(gr_get_font_height()/2.0f +0.5) - 2;
1118 ha->sy = bi->hold_y;
1121 //hud_set_iff_color(bi->team);
1122 brief_set_icon_color(bi->team);
1124 hud_anim_render(ha, frametime, 1, 0, 1);
1126 if ( Brief_stage_highlight_sound_handle < 0 ) {
1127 if ( !Fred_running) {
1128 Brief_stage_highlight_sound_handle = snd_play(&Snds_iface[SND_ICON_HIGHLIGHT]);
1134 // render fade-in anim frame
1135 if ( bi->flags & BI_FADEIN ) {
1136 hud_anim *ha = &bi->fadein_anim;
1137 if ( ha->first_frame >= 0 ) {
1140 // hud_set_iff_color(bi->team);
1141 brief_set_icon_color(bi->team);
1143 if ( hud_anim_render(ha, frametime, 1, 0, 0, 1) == 0 ) {
1144 bi->flags &= ~BI_FADEIN;
1147 bi->flags &= ~BI_FADEIN;
1151 if ( !(bi->flags & BI_FADEIN) ) {
1152 gr_set_bitmap(icon_bitmap);
1154 if ( Fred_running ) {
1155 gr_aascaler(&va, &vb);
1157 // Don't bother scaling for the game
1158 gr_aabitmap(bx, by);
1161 // draw text centered over the icon (make text darker)
1162 if ( bi->type == ICON_FIGHTER_PLAYER || bi->type == ICON_BOMBER_PLAYER ) {
1163 gr_get_string_size(&w,&h,Players[Player_num].callsign);
1164 gr_printf(bc - fl2i(w/2.0f), by - h, Players[Player_num].callsign);
1169 strcpy(buf, bi->label);
1170 lcl_translate_brief_icon_name(buf);
1171 gr_get_string_size(&w, &h, buf);
1172 gr_printf(bc - fl2i(w/2.0f), by - h, buf);
1174 gr_get_string_size(&w,&h,bi->label);
1175 gr_printf(bc - fl2i(w/2.0f), by - h, bi->label);
1179 // show icon as selected (FRED only)
1181 gr_get_string_size(&w,&h,NOX("(S)"));
1182 gr_printf(bc - fl2i(w/2.0f), by - h*2, NOX("(S)"));
1186 // store screen x,y,w,h
1189 bi->w = fl2i(scaled_w);
1190 bi->h = fl2i(scaled_h);
1192 } // end if vertex is projected
1195 #pragma optimize("", on)
1197 // -------------------------------------------------------------------------------------
1198 // brief_render_icons()
1200 void brief_render_icons(int stage_num, float frametime)
1202 int i, num_icons, num_lines;
1204 Assert( Briefing != NULL );
1206 num_icons = Briefing->stages[stage_num].num_icons;
1207 num_lines = Briefing->stages[stage_num].num_lines;
1209 if ( Cam_target_reached ) {
1210 for ( i = 0; i < num_lines; i++ ) {
1211 brief_render_icon_line(stage_num, i);
1215 for ( i = 0; i < num_icons; i++ ) {
1216 brief_render_icon(stage_num, i, frametime, 0);
1220 // ------------------------------------------------------------------------------------
1221 // brief_start_highlight_anims()
1223 // see if there are any highlight animations to play
1225 void brief_start_highlight_anims(int stage_num)
1229 int x,y,i,anim_w,anim_h;
1231 Assert( Briefing != NULL );
1232 bs = &Briefing->stages[stage_num];
1234 for ( i = 0; i < bs->num_icons; i++ ) {
1236 if ( bi->flags & BI_HIGHLIGHT ) {
1237 bi->flags &= ~BI_SHOWHIGHLIGHT;
1238 if ( bi->highlight_anim.first_frame < 0 ) {
1242 bi->highlight_anim.time_elapsed=0.0f;
1244 bm_get_info( bi->highlight_anim.first_frame, &anim_w, &anim_h, NULL);
1245 x = fl2i( i2fl(bi->x) + bi->w/2.0f - anim_w/2.0f );
1246 y = fl2i( i2fl(bi->y) + bi->h/2.0f - anim_h/2.0f );
1249 bi->flags |= BI_SHOWHIGHLIGHT;
1250 bi->highlight_anim.time_elapsed=0.0f;
1255 // -------------------------------------------------------------------------------------
1256 // brief_render_map()
1259 void brief_render_map(int stage_num, float frametime)
1263 gr_set_clip(bscreen.map_x1 + 1, bscreen.map_y1 + 1, bscreen.map_x2 - bscreen.map_x1 - 1, bscreen.map_y2 - bscreen.map_y1 - 2);
1265 // REMOVED by neilk: removed gr_clear for FS2 because interface no longer calls for black background on grid
1268 if (stage_num >= Briefing->num_stages) {
1274 bs = &Briefing->stages[stage_num];
1277 g3_set_view_matrix(&Current_cam_pos, &Current_cam_orient, 0.5f);
1279 brief_maybe_create_new_grid(The_grid, &Current_cam_pos, &Current_cam_orient);
1280 brief_render_grid(The_grid);
1282 brief_render_fade_outs(frametime);
1284 // go ahead and render everything that is in the active objects list
1285 brief_render_icons(stage_num, frametime);
1287 if ( Cam_target_reached && brief_text_wipe_finished() ) {
1289 if ( Brief_textdraw_finished == 0 ) {
1290 Brief_textdraw_finished = 1;
1291 Brief_stage_time = 0;
1294 if ( Play_highlight_flag ) {
1295 brief_start_highlight_anims(stage_num);
1296 Play_highlight_flag = 0;
1300 anim_render_all(ON_BRIEFING_SELECT, frametime);
1307 // -------------------------------------------------------------------------------------
1308 // brief_text_set_color()
1310 void brief_text_set_color(char c) {
1322 gr_set_color_fast(&Color_red);
1325 gr_set_color_fast(&Color_green);
1328 gr_set_color_fast(&Color_blue);
1331 Int3(); // unsupported meta-code
1336 // Display what stage of the briefing is active
1337 void brief_blit_stage_num(int stage_num, int stage_max)
1342 Assert( Briefing != NULL );
1343 gr_set_color_fast(&Color_text_heading);
1344 sprintf(buf, XSTR( "Stage %d of %d", 394), stage_num + 1, stage_max);
1345 if (Game_mode & GM_MULTIPLAYER) {
1346 gr_printf(Brief_stage_text_coords_multi[gr_screen.res][0], Brief_stage_text_coords_multi[gr_screen.res][1], buf);
1348 gr_printf(Brief_stage_text_coords[gr_screen.res][0], Brief_stage_text_coords[gr_screen.res][1], buf);
1351 // draw the title of the mission
1352 // if this goes above briefing text, it will need to be raised 10 pixels in multiplayer to make
1353 // room for stage num, which makes toom for chat box
1355 if (Game_mode & GM_MULTIPLAYER) {
1356 gr_get_string_size(&w,NULL,The_mission.name);
1357 gr_string(bscreen.map_x2 - w, bscreen.map_y2 + 5, The_mission.name);
1359 gr_get_string_size(&w,NULL,The_mission.name);
1360 gr_string(bscreen.map_x2 - w, bscreen.map_y2 + 5, The_mission.name);
1365 // Render a line of text for the briefings. Lines are drawn in as a wipe, with leading bright
1366 // white characters. Have to jump through some hoops since we support colored words. This means
1367 // that we need to process the line one character at a time.
1368 void brief_render_line(int line_num, int x, int y, int instance)
1370 int len, count, next, truncate_len, last_color, offset, w, h, bright_len, i;
1372 char line[MAX_BRIEF_LINE_LEN];
1374 src = &Colored_text[instance][line_num][0];
1375 len = Colored_text_len[instance][line_num];
1381 truncate_len = fl2i(Brief_text_wipe_time_elapsed / BRIEF_TEXT_WIPE_TIME * Max_briefing_line_len);
1382 if (truncate_len > len){
1387 if (truncate_len < len) {
1388 if (truncate_len <= BRIGHTEN_LEAD) {
1389 bright_len = truncate_len;
1393 bright_len = BRIGHTEN_LEAD;
1394 truncate_len -= BRIGHTEN_LEAD;
1402 gr_set_color_fast(&Color_white);
1403 last_color = BRIEF_TEXT_WHITE;
1404 for (i=0; i<truncate_len; i++) {
1405 if (count >= truncate_len){
1409 line[next] = src[count].letter;
1411 if (is_white_space(line[next])) {
1412 // end of word reached, blit it
1414 gr_string(x + offset, y, line);
1415 gr_get_string_size(&w, &h, line);
1420 if (last_color != BRIEF_TEXT_WHITE) {
1421 brief_set_text_color(BRIEF_TEXT_WHITE);
1422 last_color = BRIEF_TEXT_WHITE;
1429 if (src[count].color != last_color) {
1430 brief_set_text_color(src[count].color);
1431 last_color = src[count].color;
1439 gr_string(x + offset, y, line);
1442 // draw leading portion of the line bright white
1445 gr_set_color_fast(&Color_bright_white);
1446 for (i=0; i<truncate_len+bright_len; i++) {
1447 line[i] = src[i].letter;
1453 if ( truncate_len > 0 ) {
1454 int width_dim, height_dim;
1455 gr_get_string_size(&width_dim, &height_dim, line, truncate_len );
1456 gr_string(x+width_dim, y, &line[truncate_len]);
1458 gr_string(x, y, line);
1462 // // now erase the part we don't want to be bright white
1463 // gr_set_color_fast(&Color_black);
1464 // if (i > BRIGHTEN_LEAD) {
1465 // line[i - BRIGHTEN_LEAD] = 0;
1466 // gr_get_string_size(&w, &h, line);
1467 // gr_set_clip(x, y, w, gr_get_font_height());
1474 int brief_text_wipe_finished()
1476 if ( Brief_text_wipe_time_elapsed > (BRIEF_TEXT_WIPE_TIME+0.5f) ) {
1483 // -------------------------------------------------------------------------------------
1484 // brief_render_text()
1486 // input: frametime => Time in seconds of previous frame
1487 // instance => Optional parameter. Used to indicate which text stream is used.
1488 // This value is 0 unless multiple text streams are required
1489 int brief_render_text(int line_offset, int x, int y, int h, float frametime, int instance, int line_spacing)
1493 fh = gr_get_font_height();
1494 if (Brief_text_wipe_time_elapsed == 0) {
1495 if (snd_is_playing(Brief_text_wipe_snd)) {
1496 snd_stop(Brief_text_wipe_snd);
1498 gamesnd_play_iface(SND_BRIEF_TEXT_WIPE);
1499 Play_brief_voice = 1;
1502 Brief_text_wipe_time_elapsed += frametime;
1506 while (yy + fh <= h) {
1507 if (line >= Num_brief_text_lines[instance])
1510 brief_render_line(line, x, y + yy, instance);
1513 yy += fh + line_spacing;
1516 if ( brief_text_wipe_finished() && (Play_brief_voice) ) {
1517 Play_brief_voice = 0;
1524 // ------------------------------------------------------------------------------------
1525 // brief_render_elements()
1527 // Draw the lines that show objects positions on the grid
1529 void brief_render_elements(vector *pos, grid* gridp)
1531 vector gpos; // Location of point on grid.
1537 if ( pos->y < 1 && pos->y > -1 )
1540 tplane.A = gridp->gmatrix.uvec.x;
1541 tplane.B = gridp->gmatrix.uvec.y;
1542 tplane.C = gridp->gmatrix.uvec.z;
1543 tplane.D = gridp->planeD;
1545 compute_point_on_plane(&gpos, &tplane, pos);
1547 dxz = vm_vec_dist(pos, &gpos)/8.0f;
1549 gv = &gridp->gmatrix.uvec;
1550 if (gv->x * pos->x + gv->y * pos->y + gv->z * pos->z < -gridp->planeD)
1551 gr_set_color(127, 127, 127);
1553 gr_set_color(255, 255, 255); // white
1555 // AL 11-20-97: don't draw elevation lines.. they are confusing
1557 brief_rpd_line(&gpos, pos); // Line from grid to object center.
1561 vm_vec_scale_add2(&gpos, &gridp->gmatrix.rvec, -dxz/2);
1562 vm_vec_scale_add2(&gpos, &gridp->gmatrix.fvec, -dxz/2);
1564 vm_vec_scale_add2(&tpos, &gridp->gmatrix.rvec, dxz/2);
1565 vm_vec_scale_add2(&tpos, &gridp->gmatrix.fvec, dxz/2);
1567 brief_rpd_line(&gpos, &tpos);
1569 vm_vec_scale_add2(&gpos, &gridp->gmatrix.rvec, dxz);
1570 vm_vec_scale_add2(&tpos, &gridp->gmatrix.rvec, -dxz);
1572 brief_rpd_line(&gpos, &tpos);
1577 // ------------------------------------------------------------------------------------
1578 // brief_reset_icons()
1580 void brief_reset_icons(int stage_num)
1586 Assert( Briefing != NULL );
1587 bs = &Briefing->stages[stage_num];
1589 for ( i = 0; i < bs->num_icons; i++ ) {
1591 bi->flags &= ~BI_SHOWHIGHLIGHT;
1595 // ------------------------------------------------------------------------------------
1596 // brief_set_camera_target()
1598 // input: pos => target position for the camera
1599 // orient => target orientation for the camera
1600 // time => time in ms to reach target
1602 void brief_set_camera_target(vector *pos, matrix *orient, int time)
1604 float time_in_seconds;
1606 time_in_seconds = time / 1000.0f;
1609 Current_cam_pos = *pos;
1610 Current_cam_orient = *orient;
1613 Target_cam_pos = *pos;
1614 Target_cam_orient = *orient;
1615 Start_cam_orient = Current_cam_orient;
1616 Start_cam_pos = Current_cam_pos; // we need this when checking if camera movement complete
1617 Start_cam_move = timer_get_milliseconds()*1000.0f; // start time, convert to seconds
1618 Total_move_time = time_in_seconds;
1619 Elapsed_time = 0.0f;
1621 vm_vec_scale_add(&Start_lookat_pos, &Start_cam_pos, &Start_cam_orient.fvec, LOOKAT_DIST);
1622 vm_vec_scale_add(&Target_lookat_pos, &Target_cam_pos, &Target_cam_orient.fvec, LOOKAT_DIST);
1624 Play_highlight_flag = 1; // once target reached, play highlight anims
1625 Cam_target_reached = 0;
1626 Cam_movement_done=0;
1627 anim_release_all_instances(ON_BRIEFING_SELECT); // stop any briefing-specific anims
1629 // calculate camera velocity
1630 vm_vec_sub(&Cam_vel, pos, &Current_cam_pos);
1631 // vm_vec_scale(&Cam_vel, 1.0f/time_in_seconds);
1632 if ( !IS_VEC_NULL(&Cam_vel) ) {
1633 vm_vec_normalize(&Cam_vel);
1636 // calculate lookat point velocity
1637 vm_vec_sub(&Lookat_vel, &Target_lookat_pos, &Current_lookat_pos);
1638 vm_vec_scale(&Lookat_vel, 1.0f/time_in_seconds);
1640 Start_dist = vm_vec_dist(&Start_cam_pos, &Start_lookat_pos);
1641 End_dist = vm_vec_dist(&Target_cam_pos, &Target_lookat_pos);
1642 Dist_change_rate = (End_dist - Start_dist) / time_in_seconds;
1644 Total_dist=vm_vec_dist(&Start_cam_pos, &Target_cam_pos);
1646 // Peak_speed=Total_dist/Total_move_time*1.5f;
1647 // Cam_accel = Peak_speed/Total_move_time*3.0f;
1649 Peak_speed=Total_dist/Total_move_time*2.0f;
1650 Cam_accel = 4*Total_dist/(Total_move_time*Total_move_time);
1653 vm_vec_zero(&W_init);
1655 get_camera_limits(&Start_cam_orient, &Target_cam_orient, Total_move_time, &Acc_limit, &Vel_limit);
1659 ubyte brief_return_color_index(char c)
1663 return BRIEF_IFF_FRIENDLY;
1666 return BRIEF_IFF_HOSTILE;
1669 return BRIEF_IFF_NEUTRAL;
1672 return BRIEF_TEXT_RED;
1675 return BRIEF_TEXT_GREEN;
1678 return BRIEF_TEXT_BLUE;
1681 Int3(); // unsupported meta-code
1685 return BRIEF_TEXT_WHITE;
1688 void brief_set_text_color(int color_index)
1690 Assert(color_index < MAX_BRIEF_TEXT_COLORS);
1691 gr_set_color_fast(Brief_text_colors[color_index]);
1694 // Set up the Colored_text array.
1695 // input: index => Index into Brief_text[] for source text.
1696 // instance => Which instance of Colored_text[] to use.
1697 // Value is 0 unless multiple text streams are required.
1698 int brief_text_colorize(int index, int instance)
1701 int len, i, skip_to_next_word, dest_len;
1703 ubyte active_color_index;
1705 src = Brief_text[index];
1706 dest = &Colored_text[instance][index][0];
1709 skip_to_next_word = 0;
1711 active_color_index = BRIEF_TEXT_WHITE;
1712 for (i=0; i<len; i++) {
1713 if (skip_to_next_word) {
1714 if (is_white_space(src[i])) {
1715 skip_to_next_word = 0;
1721 if ( src[i] == BRIEF_META_CHAR && is_white_space(src[i + 2]) ) {
1722 active_color_index = brief_return_color_index(src[i + 1]);
1723 skip_to_next_word = 1;
1727 if (is_white_space(src[i])) {
1728 active_color_index = BRIEF_TEXT_WHITE;
1731 dest[dest_len].letter = src[i];
1732 dest[dest_len].color = active_color_index;
1736 dest[dest_len].letter = 0;
1737 Colored_text_len[instance][index] = dest_len;
1741 // ------------------------------------------------------------------------------------
1742 // brief_color_text_init()
1744 // input: src => paragraph of text to process
1745 // w => max width of line in pixels
1746 // instance => optional parameter, used when multiple text streams are required
1747 // (default value is 0)
1748 int brief_color_text_init(char *src, int w, int instance)
1750 int i, n_lines, len;
1751 int n_chars[MAX_BRIEF_LINES];
1752 char *p_str[MAX_BRIEF_LINES];
1755 n_lines = split_str(src, w, n_chars, p_str, MAX_BRIEF_LINES, BRIEF_META_CHAR);
1756 Assert(n_lines >= 0);
1758 Max_briefing_line_len = 1;
1759 for (i=0; i<n_lines; i++) {
1760 Assert(n_chars[i] < MAX_BRIEF_LINE_LEN);
1761 strncpy(Brief_text[i], p_str[i], n_chars[i]);
1762 Brief_text[i][n_chars[i]] = 0;
1763 drop_leading_white_space(Brief_text[i]);
1764 len = brief_text_colorize(i, instance);
1765 if (len > Max_briefing_line_len)
1766 Max_briefing_line_len = len;
1769 Brief_text_wipe_time_elapsed = 0.0f;
1770 Play_brief_voice = 0;
1772 Num_brief_text_lines[instance] = n_lines;
1776 // ------------------------------------------------------------------------------------
1777 // brief_get_free_move_icon()
1779 // returns: failure => -1
1780 // success => handle to a free move icon struct
1782 int brief_get_free_move_icon()
1786 for ( i = 0; i < MAX_MOVE_ICONS; i++ ) {
1787 if ( Icon_movers[i].used == 0 )
1791 if ( i == MAX_MOVE_ICONS )
1794 Icon_movers[i].used = 1;
1799 // ------------------------------------------------------------------------------------
1800 // brief_set_move_list()
1802 // input: new_stage => new stage number that briefing is now moving to
1803 // current_stage => current stage that the briefing is on
1804 // time => time in seconds
1806 int brief_set_move_list(int new_stage, int current_stage, float time)
1808 brief_stage *newb, *cb;
1809 icon_move_info *imi;
1810 int i,j,k,num_movers,is_gone=0;
1812 Assert(new_stage != current_stage);
1814 Assert( Briefing != NULL );
1815 newb = &Briefing->stages[new_stage];
1816 cb = &Briefing->stages[current_stage];
1819 for ( i = 0; i < cb->num_icons; i++ ) {
1821 for ( j = 0; j < newb->num_icons; j++ ) {
1822 if ( ( cb->icons[i].id != 0 ) && ( cb->icons[i].id == newb->icons[j].id ) ) {
1824 if ( vm_vec_cmp(&cb->icons[i].pos, &newb->icons[j].pos) ) {
1825 //nprintf(("Alan","We found a match in icon %s\n", cb->icons[i].label));
1826 k = brief_get_free_move_icon();
1828 Int3(); // should never happen, get Alan
1831 imi = &Icon_movers[k];
1832 imi->id = cb->icons[i].id;
1833 imi->start = cb->icons[i].pos;
1834 imi->finish = newb->icons[j].pos;
1835 imi->current = imi->start;
1836 list_append(&Icon_move_list, imi);
1838 imi->total_dist = vm_vec_dist(&imi->start, &imi->finish);
1839 imi->total_move_time = time;
1840 imi->peak_speed = imi->total_dist/imi->total_move_time*2.0f;
1841 imi->accel = 4*imi->total_dist/(time*time);
1842 imi->last_dist=0.0f;
1843 imi->reached_dest=0;
1846 vm_vec_sub(&imi->direction, &imi->finish, &imi->start);
1847 if ( !IS_VEC_NULL(&imi->direction) ) {
1848 vm_vec_normalize(&imi->direction);
1856 // Set up fading icon (to fade out)
1858 if ( Num_fade_icons >= MAX_FADE_ICONS ) {
1863 int species = ship_get_species_by_type(cb->icons[i].ship_class);
1868 Fading_icons[Num_fade_icons].fade_anim = Icon_fade_anims[cb->icons[i].type][species];
1869 Fading_icons[Num_fade_icons].pos = cb->icons[i].pos;
1870 Fading_icons[Num_fade_icons].team = cb->icons[i].team;
1875 // flag new icons for fading in
1876 for ( i=0; i<newb->num_icons; i++ ) {
1878 newb->icons[i].flags &= ~BI_FADEIN;
1879 for ( j=0; j<cb->num_icons; j++ ) {
1880 if ( ( cb->icons[j].id != 0 ) && ( cb->icons[j].id == newb->icons[i].id ) ) {
1885 int species = ship_get_species_by_type(newb->icons[i].ship_class);
1890 newb->icons[i].flags |= BI_FADEIN;
1891 newb->icons[i].fadein_anim = Icon_fade_anims[newb->icons[i].type][species];
1892 newb->icons[i].fadein_anim.time_elapsed = 0.0f;
1899 void brief_clear_fade_out_icons()
1905 // ------------------------------------------------------------------------------------
1906 // brief_set_new_stage()
1908 // input: pos => target position for the camera
1909 // orient => target orientation for the camera
1910 // time => time in ms to reach target
1911 // stage_num => stage number of briefing (start numbering at 0)
1914 void brief_set_new_stage(vector *pos, matrix *orient, int time, int stage_num)
1916 char msg[MAX_BRIEF_LEN];
1917 int num_movers, new_time, not_objv = 1;
1919 Assert( Briefing != NULL );
1922 if (stage_num >= Briefing->num_stages) {
1923 not_objv = 0; // turns out this is an objectives stage
1927 if ( stage_num == Last_new_stage ) {
1932 brief_move_icon_reset();
1933 brief_clear_fade_out_icons();
1934 if ( (Last_new_stage != -1) && not_objv ) {
1935 num_movers = brief_set_move_list(stage_num, Last_new_stage, new_time / 1000.0f);
1938 if ( (Last_new_stage != -1) && (num_movers == 0) && not_objv ) {
1939 if ( !vm_vec_cmp( &Briefing->stages[stage_num].camera_pos, &Briefing->stages[Last_new_stage].camera_pos) ) {
1940 if ( !vm_vec_cmp( &Briefing->stages[stage_num].camera_orient.fvec, &Briefing->stages[Last_new_stage].camera_orient.fvec) ){
1947 if(Briefing->stages[stage_num].new_text == NULL){
1950 strcpy(msg, Briefing->stages[stage_num].new_text);
1953 strcpy(msg, XSTR( "Please review your objectives for this mission.", 395));
1956 if (gr_screen.res == GR_640) {
1958 Num_brief_text_lines[0] = brief_color_text_init(msg, MAX_BRIEF_LINE_W_640);
1961 Num_brief_text_lines[0] = brief_color_text_init(msg, MAX_BRIEF_LINE_W_1024);
1963 Top_brief_text_line = 0;
1966 brief_set_camera_target(pos, orient, new_time);
1969 if ( snd_is_playing(Brief_stage_highlight_sound_handle) ) {
1970 snd_stop(Brief_stage_highlight_sound_handle);
1973 Brief_voice_ended = 0;
1974 Brief_textdraw_finished = 0;
1975 Brief_voice_started = 0;
1976 Brief_stage_time = 0;
1979 Brief_stage_highlight_sound_handle = -1;
1980 Last_new_stage = stage_num;
1983 // ------------------------------------------------------------------------------------
1984 // camera_pos_past_target()
1987 int camera_pos_past_target(vector *start, vector *current, vector *dest)
1992 vm_vec_sub(&num, current, start);
1993 vm_vec_sub(&den, start, dest);
1995 ratio = vm_vec_mag_quick(&num) / vm_vec_mag_quick(&den);
2002 // ------------------------------------------------------------------------------------
2003 // Interpolate between matrices.
2004 // elapsed_time/total_time gives percentage of interpolation between cur
2006 void interpolate_matrix(matrix *result, matrix *goal, matrix *start, float elapsed_time, float total_time)
2011 if ( !vm_matrix_cmp( goal, start ) ) {
2015 time0 = elapsed_time / total_time;
2016 time1 = (total_time - elapsed_time) / total_time;
2018 vm_vec_copy_scale(&fvec, &start->fvec, time1);
2019 vm_vec_scale_add2(&fvec, &goal->fvec, time0);
2021 vm_vec_copy_scale(&rvec, &start->rvec, time1);
2022 vm_vec_scale_add2(&rvec, &goal->rvec, time0);
2024 vm_vector_2_matrix(result, &fvec, NULL, &rvec);
2027 // calculate how far the camera should have moved
2028 float brief_camera_get_dist_moved(float elapsed_time)
2030 float time, dist_moved=0.0f;
2032 // first half of movement
2033 if ( elapsed_time < Total_move_time/2.0f ) {
2034 dist_moved=0.5f*Cam_accel*elapsed_time*elapsed_time; // d = 1/2at^2
2038 // second half of movement
2039 time=elapsed_time - Total_move_time/2.0f;
2040 dist_moved=(Total_dist/2.0f)+(Peak_speed*time) - 0.5f*Cam_accel*time*time;
2045 // ------------------------------------------------------------------------------------
2046 // Update the camera position
2047 void brief_camera_move(float frametime, int stage_num)
2054 Elapsed_time += frametime;
2056 if ( Cam_target_reached ) {
2057 // Current_cam_pos = Target_cam_pos;
2058 // Current_lookat_pos = Target_lookat_pos;
2059 // Current_cam_orient = Target_cam_orient;
2063 // Update orientation
2064 if ( (Elapsed_time < Total_move_time) ) {
2065 // interpolate_matrix(&Current_cam_orient, &Target_cam_orient, &Start_cam_orient, Elapsed_time, Total_move_time );
2066 vm_matrix_interpolate(&Target_cam_orient, &Current_cam_orient, &W_init, frametime, &result, &w_out, &Vel_limit, &Acc_limit);
2067 Current_cam_orient = result;
2072 // interpolate lookat position
2073 if ( vm_vec_cmp( &Current_lookat_pos, &Target_lookat_pos ) ) {
2074 vm_vec_copy_scale(&dist_moved, &Lookat_vel, Elapsed_time);
2075 vm_vec_add(&Current_lookat_pos, &Start_lookat_pos, &dist_moved);
2077 if ( camera_pos_past_target(&Start_lookat_pos, &Current_lookat_pos, &Target_lookat_pos) ) {
2078 Current_lookat_pos = Target_lookat_pos;
2082 cur_dist = Start_dist + Dist_change_rate * Elapsed_time;
2083 vm_vec_copy_scale(&dist_moved, &Current_cam_orient.fvec, -cur_dist);
2084 vm_vec_add(&Current_cam_pos, &Current_lookat_pos, &dist_moved);
2087 // use absolute pos to update position
2088 if ( vm_vec_cmp( &Current_cam_pos, &Target_cam_pos ) ) {
2089 dist = brief_camera_get_dist_moved(Elapsed_time);
2090 if ( dist < Last_dist ) {
2091 Cam_movement_done=1;
2096 if ( Cam_movement_done == 0 ) {
2097 vm_vec_copy_scale(&dist_moved, &Cam_vel, dist);
2098 vm_vec_add(&Current_cam_pos, &Start_cam_pos, &dist_moved);
2100 Current_cam_pos=Target_cam_pos;
2104 Cam_movement_done=1;
2105 Current_cam_pos=Target_cam_pos;
2108 if ( Cam_movement_done && (Elapsed_time >= Total_move_time) ) {
2109 Cam_target_reached=1;
2113 // Project the viewer's position onto the grid plane. If more than threshold distance
2114 // from grid center, move grid center.
2115 void brief_maybe_create_new_grid(grid* gridp, vector *pos, matrix *orient, int force)
2119 vector gpos, tmp, c;
2120 float dist_to_plane;
2121 float square_size, ux, uy, uz;
2123 ux = tplane.A = gridp->gmatrix.uvec.x;
2124 uy = tplane.B = gridp->gmatrix.uvec.y;
2125 uz = tplane.C = gridp->gmatrix.uvec.z;
2126 tplane.D = gridp->planeD;
2128 compute_point_on_plane(&c, &tplane, pos);
2129 dist_to_plane = fl_abs(vm_dist_to_plane(pos, &gridp->gmatrix.uvec, &c));
2132 while (dist_to_plane >= 25.0f)
2134 square_size *= 10.0f;
2135 dist_to_plane /= 10.0f;
2138 if (fvi_ray_plane(&gpos, &gridp->center, &gridp->gmatrix.uvec, pos, &orient->fvec, 0.0f)<0.0f) {
2140 vm_vec_scale_add(&p,pos,&orient->fvec, 100.0f );
2141 compute_point_on_plane(&gpos, &tplane, &p );
2144 if (vm_vec_dist(&gpos, &c) > 50.0f * square_size)
2146 vm_vec_sub(&tmp, &gpos, &c);
2147 vm_vec_normalize(&tmp);
2148 vm_vec_scale_add(&gpos, &c, &tmp, 50.0f * square_size);
2151 roundoff = (int) square_size * 10;
2153 gpos.x = fl_roundoff(gpos.x, roundoff);
2155 gpos.y = fl_roundoff(gpos.y, roundoff);
2157 gpos.z = fl_roundoff(gpos.z, roundoff);
2159 if ((square_size != gridp->square_size) ||
2160 (gpos.x != gridp->center.x) ||
2161 (gpos.y != gridp->center.y) ||
2162 (gpos.z != gridp->center.z) || force)
2164 gridp->square_size = square_size;
2165 gridp->center = gpos;
2166 brief_modify_grid(gridp);
2171 // *forward is vector pointing forward
2172 // *right is vector pointing right
2173 // *center is center point of grid
2174 // length is length of grid
2175 // width is width of grid
2176 // square_size is size of a grid square
2178 // *forward = (0.0, 0.0, 1.0)
2179 // *right = (1.0, 0.0, 0.0)
2180 // *center = (0.0, 0.0, 0.0)
2183 // square_size = 10.0
2184 // will generate a grid of squares 10 long by 5 wide.
2185 // Each grid square will be 10.0 x 10.0 units.
2186 // The center of the grid will be at the global origin.
2187 // The grid will be parallel to the xz plane (because the normal is 0,1,0).
2188 // (In fact, it will be the xz plane because it is centered on the origin.)
2190 // Stuffs grid in *gridp. If gridp == NULL, mallocs and returns a grid.
2191 grid *brief_create_grid(grid *gridp, vector *forward, vector *right, vector *center, int nrows, int ncols, float square_size)
2193 int i, ncols2, nrows2, d = 1;
2194 vector dfvec, drvec, cur, cur2, tvec, uvec, save, save2;
2196 Assert(square_size > 0.0);
2197 if (double_fine_gridlines)
2201 gridp = (grid *) malloc(sizeof(grid));
2205 gridp->center = *center;
2206 gridp->square_size = square_size;
2208 // Create the plane equation.
2209 Assert(!IS_VEC_NULL(forward));
2210 Assert(!IS_VEC_NULL(right));
2212 vm_vec_copy_normalize(&dfvec, forward);
2213 vm_vec_copy_normalize(&drvec, right);
2215 vm_vec_cross(&uvec, &dfvec, &drvec);
2217 Assert(!IS_VEC_NULL(&uvec));
2219 gridp->gmatrix.uvec = uvec;
2221 gridp->planeD = -(center->x * uvec.x + center->y * uvec.y + center->z * uvec.z);
2222 Assert(!_isnan(gridp->planeD));
2224 gridp->gmatrix.fvec = dfvec;
2225 gridp->gmatrix.rvec = drvec;
2227 vm_vec_scale(&dfvec, square_size);
2228 vm_vec_scale(&drvec, square_size);
2230 vm_vec_scale_add(&cur, center, &dfvec, (float) -nrows * d / 2);
2231 vm_vec_scale_add2(&cur, &drvec, (float) -ncols * d / 2);
2232 vm_vec_scale_add(&cur2, center, &dfvec, (float) -nrows * 5 / 2);
2233 vm_vec_scale_add2(&cur2, &drvec, (float) -ncols * 5 / 2);
2237 gridp->ncols = ncols;
2238 gridp->nrows = nrows;
2241 Assert(ncols < MAX_GRIDLINE_POINTS && nrows < MAX_GRIDLINE_POINTS);
2243 // Create the points along the edges of the grid, so we can just draw lines
2244 // between them to form the grid.
2245 for (i=0; i<=ncols*d; i++) {
2246 gridp->gpoints1[i] = cur; // small, dark gridline points
2247 vm_vec_scale_add(&tvec, &cur, &dfvec, (float) nrows * d);
2248 gridp->gpoints2[i] = tvec;
2249 vm_vec_add2(&cur, &drvec);
2252 for (i=0; i<=ncols2; i++) {
2253 gridp->gpoints5[i] = cur2; // large, brighter gridline points
2254 vm_vec_scale_add(&tvec, &cur2, &dfvec, (float) nrows2 * 10);
2255 gridp->gpoints6[i] = tvec;
2256 vm_vec_scale_add2(&cur2, &drvec, 10.0f);
2261 for (i=0; i<=nrows*d; i++) {
2262 gridp->gpoints3[i] = cur; // small, dark gridline points
2263 vm_vec_scale_add(&tvec, &cur, &drvec, (float) ncols * d);
2264 gridp->gpoints4[i] = tvec;
2265 vm_vec_add2(&cur, &dfvec);
2268 for (i=0; i<=nrows2; i++) {
2269 gridp->gpoints7[i] = cur2; // large, brighter gridline points
2270 vm_vec_scale_add(&tvec, &cur2, &drvec, (float) ncols2 * 10);
2271 gridp->gpoints8[i] = tvec;
2272 vm_vec_scale_add2(&cur2, &dfvec, 10.0f);
2278 // Create a nice grid -- centered at origin, 10x10, 10.0 size squares, in xz plane.
2279 grid *brief_create_default_grid(void)
2282 vector fvec, rvec, cvec;
2284 rgrid = brief_create_grid(&Global_grid, vm_vec_make(&fvec, 0.0f, 0.0f, 1.0f),
2285 vm_vec_make(&rvec, 1.0f, 0.0f, 0.0f),
2286 vm_vec_make(&cvec, 0.0f, -10.0f, 0.0f), 100, 100, 5.0f);
2288 physics_init(&rgrid->physics);
2289 rgrid->physics.flags |= (PF_ACCELERATES | PF_SLIDE_ENABLED);
2293 // Rotate and project points and draw a line.
2294 void brief_rpd_line(vector *v0, vector *v1)
2297 g3_rotate_vertex(&tv0, v0);
2298 g3_rotate_vertex(&tv1, v1);
2301 g3_project_vertex(&tv0);
2302 g3_project_vertex(&tv1);
2304 if ( (tv0.flags & PF_OVERFLOW) || (tv1.flags & PF_OVERFLOW) )
2308 gr_set_color_fast(&Color_grey);
2309 g3_draw_line(&tv0, &tv1);
2312 // Renders a grid defined in a grid struct
2313 void brief_render_grid(grid *gridp)
2315 int i, ncols, nrows;
2317 ncols = gridp->ncols;
2318 nrows = gridp->nrows;
2319 if (double_fine_gridlines)
2325 gr_set_color(30,30,30);
2328 // Draw the column lines.
2329 for (i=0; i<=ncols; i++)
2330 brief_rpd_line(&gridp->gpoints1[i], &gridp->gpoints2[i]);
2332 // Draw the row lines.
2333 for (i=0; i<=nrows; i++)
2334 brief_rpd_line(&gridp->gpoints3[i], &gridp->gpoints4[i]);
2336 ncols = gridp->ncols / 2;
2337 nrows = gridp->nrows / 2;
2339 // now draw the larger, brighter gridlines that is x10 the scale of smaller one.
2342 for (i=0; i<=ncols; i++)
2343 brief_rpd_line(&gridp->gpoints5[i], &gridp->gpoints6[i]);
2345 for (i=0; i<=nrows; i++)
2346 brief_rpd_line(&gridp->gpoints7[i], &gridp->gpoints8[i]);
2350 void brief_modify_grid(grid *gridp)
2352 brief_create_grid(gridp, &gridp->gmatrix.fvec, &gridp->gmatrix.rvec, &gridp->center,
2353 gridp->nrows, gridp->ncols, gridp->square_size);
2356 void brief_unload_anims()
2360 for (i=0; i<MAX_BRIEF_ICONS; i++) {
2361 for(idx=0; idx<MAX_SPECIES_NAMES; idx++){
2362 hud_anim_release(&Icon_highlight_anims[i][idx]);
2363 hud_anim_release(&Icon_fade_anims[i][idx]);
2368 void brief_common_close()
2371 brief_unload_anims();
2375 void brief_restart_text_wipe()
2377 Brief_stage_time = 0;
2378 Brief_voice_ended = 0;
2379 Brief_voice_started = 0;
2380 Brief_text_wipe_time_elapsed = 0.0f;
2383 // initialize the array of handles to the different voice streams
2384 void brief_voice_init()
2387 for ( i = 0; i < MAX_BRIEF_STAGES; i++ ) {
2388 Brief_voices[i] = -1;
2392 void brief_load_voice_file(int voice_num, char *name)
2394 int load_attempts = 0;
2397 if ( load_attempts++ > 5 ) {
2401 Brief_voices[voice_num] = audiostream_open( name, ASF_VOICE );
2402 if ( Brief_voices[voice_num] >= 0 ) {
2406 // Don't bother to ask for the CD in multiplayer
2407 if ( Game_mode & GM_MULTIPLAYER ) {
2411 // couldn't load animation, ask user to insert CD (if necessary)
2412 // if ( Brief_voice_ask_for_cd ) {
2413 // if ( game_do_cd_check() == 0 ) {
2414 // Brief_voice_ask_for_cd = 0;
2421 // open and pre-load the stream buffers for the different voice streams
2422 void brief_voice_load_all()
2427 // Brief_voice_ask_for_cd = 1;
2429 Assert( Briefing != NULL );
2430 for ( i = 0; i < Briefing->num_stages; i++ ) {
2431 bs = &Briefing->stages[i];
2432 if ( strnicmp(bs->voice, NOX("none"), 4) ) {
2433 brief_load_voice_file(i, bs->voice);
2434 // Brief_voices[i] = audiostream_open( bs->voice, ASF_VOICE );
2439 // close all the briefing voice streams
2440 void brief_voice_unload_all()
2444 for ( i = 0; i < MAX_BRIEF_STAGES; i++ ) {
2445 if ( Brief_voices[i] != -1 ) {
2446 audiostream_close_file(Brief_voices[i], 0);
2447 Brief_voices[i] = -1;
2452 // start playback of the voice for a particular briefing stage
2453 void brief_voice_play(int stage_num)
2455 if ( Brief_voices[stage_num] == -1 )
2456 return; // voice file doesn't exist
2458 if ( !Briefing_voice_enabled ) {
2462 if ( audiostream_is_playing( Brief_voices[stage_num]) )
2465 audiostream_play(Brief_voices[stage_num], Master_voice_volume, 0);
2466 Brief_voice_started = 1;
2469 // stop playback of the voice for a particular briefing stage
2470 void brief_voice_stop(int stage_num)
2472 if ( Brief_voices[stage_num] == -1 )
2475 audiostream_stop(Brief_voices[stage_num]); // stream is automatically rewound
2478 // pause playback of the voice for a particular briefing stage, to resume just
2479 // call brief_voice_unpause() again
2480 void brief_voice_pause(int stage_num)
2482 if ( Brief_voices[stage_num] == -1 )
2485 audiostream_pause(Brief_voices[stage_num]);
2488 void brief_voice_unpause(int stage_num)
2490 if ( Brief_voices[stage_num] == -1 )
2493 audiostream_unpause(Brief_voices[stage_num]);
2496 void brief_reset_last_new_stage()
2498 Last_new_stage = -1;
2501 // get the dimensions for a briefing icon
2502 void brief_common_get_icon_dimensions(int *w, int *h, int type, int ship_class)
2504 Assert(type >= 0 && type < MAX_BRIEF_ICONS);
2506 // in case anything goes wrong
2510 int species = ship_get_species_by_type(ship_class);
2515 if ( Icon_bitmaps[type][species].first_frame >= 0 ) {
2516 bm_get_info( Icon_bitmaps[type][species].first_frame, w, h, NULL);
2523 void cmd_brief_reset()
2526 static int inited = 0;
2529 for (i=0; i<MAX_TEAMS; i++) {
2530 for (j=0; j<Cmd_briefs[i].num_stages; j++) {
2531 if (Cmd_briefs[i].stage[j].text)
2532 free(Cmd_briefs[i].stage[j].text);
2538 for (i=0; i<MAX_TEAMS; i++)
2539 Cmd_briefs[i].num_stages = 0;
2542 #define STAGE_ADVANCE_DELAY 1000 // time in ms to wait after voice stops before advancing stage
2544 // should briefing advance to the next stage?
2545 int brief_time_to_advance(int stage_num, float frametime)
2547 int voice_active, advance = 0;
2548 brief_icon *closeup_icon;
2550 closeup_icon = (brief_icon*)brief_get_closeup_icon();
2551 if ( closeup_icon ) {
2555 if ( !Player->auto_advance ) {
2559 Brief_stage_time += fl2i(frametime*1000 + 0.5f);
2561 if ( (Brief_voices[stage_num] >= 0) && Briefing_voice_enabled ) {
2567 if ( voice_active && (Brief_voice_ended == 0) && Brief_voice_started) {
2568 if ( !audiostream_is_playing( Brief_voices[stage_num]) ) {
2569 Brief_voice_ended = 1;
2570 Brief_stage_time = 0;
2574 if ( Brief_voice_ended ) {
2575 if ( Brief_stage_time > STAGE_ADVANCE_DELAY ) {
2580 if ( !voice_active && (Brief_textdraw_finished > 0) ) {
2581 if ( Brief_stage_time > max(5000, Num_brief_text_lines[0] * 3500) ) {