2 * $Logfile: /Freespace2/code/MissionUI/MissionBrief.cpp $
7 * C module that contains code to display the mission briefing to the player
10 * Revision 1.1 2002/05/03 03:28:10 root
14 * 48 10/14/99 2:51p Jefff
17 * 47 10/13/99 3:23p Jefff
18 * fixed unnumbered XSTRs
20 * 46 9/12/99 8:09p Dave
21 * Fixed problem where skip-training button would cause mission messages
22 * not to get paged out for the current mission.
24 * 45 9/09/99 3:40p Jefff
25 * no exit loop outisde of campaign mode
27 * 44 9/07/99 6:53p Jefff
28 * functionality to break out of a loop
30 * 43 9/06/99 6:38p Dave
31 * Improved CD detection code.
33 * 42 9/03/99 10:57a Jefff
36 * 41 8/30/99 5:30p Jefff
37 * fixed "more" being cut off in d3d
39 * 40 8/30/99 10:29a Jefff
40 * added autocenter flag to closup rendering
42 * 39 8/19/99 11:33a Dave
45 * 38 8/19/99 10:59a Dave
46 * Packet loss detection.
48 * 37 8/16/99 4:05p Dave
49 * Big honking checkin.
51 * 36 8/16/99 9:48a Jefff
52 * all clicks on briefing icons should now register
54 * 35 8/10/99 7:29p Jefff
55 * added mission title to briefing screen
57 * 34 8/03/99 1:34a Andsager
58 * fix skip training mission (again)
60 * 33 8/02/99 12:01p Jefff
61 * fixed "skip training" text pos
63 * 32 7/30/99 5:42p Jasenw
64 * Fixed coords for skip training button.
66 * 31 7/29/99 10:50p Dave
67 * Oops. Accidentally blew away some interface text changes.
69 * 30 7/29/99 10:48p Dave
71 * 29 7/29/99 3:05p Andsager
72 * Add skip training text. and properly skip.
74 * 28 7/24/99 6:07p Jefff
75 * Added "lock" text to multiplayer lock button
77 * 27 7/21/99 10:51a Jefff
78 * added "more" indicator to briefing text box
80 * 26 7/19/99 3:01p Dave
81 * Fixed icons. Added single transport icon.
83 * 25 7/18/99 5:20p Dave
84 * Jump node icon. Fixed debris fogging. Framerate warning stuff.
86 * 24 7/16/99 1:49p Dave
87 * 8 bit aabitmaps. yay.
89 * 23 7/15/99 9:20a Andsager
90 * FS2_DEMO initial checkin
92 * 22 7/09/99 5:54p Dave
93 * Seperated cruiser types into individual types. Added tons of new
94 * briefing icons. Campaign screen.
96 * 21 6/29/99 7:39p Dave
97 * Lots of small bug fixes.
99 * 20 6/11/99 11:13a Dave
100 * last minute changes before press tour build.
102 * 19 6/04/99 1:18p Dave
103 * Fixed briefing model rendering problems. Made show background option in
104 * fred toggle nebula rendering.
106 * 18 5/07/99 10:34a Andsager
107 * Make red alert work in FS2
109 * 17 4/23/99 12:01p Johnson
110 * Added SIF_HUGE_SHIP
112 * 16 3/25/99 2:45p Neilk
115 * 15 2/11/99 3:08p Dave
116 * PXO refresh button. Very preliminary squad war support.
118 * 14 2/05/99 7:19p Neilk
119 * Removed black part from mission screen, fixed info text coords
121 * 13 2/02/99 4:35p Neilk
122 * fixed coordinate problem where primary goals was on top of interface in
125 * 12 2/01/99 5:55p Dave
126 * Removed the idea of explicit bitmaps for buttons. Fixed text
127 * highlighting for disabled gadgets.
129 * 11 1/30/99 7:32p Neilk
130 * Fixed coords problems for mission briefing screens
132 * 10 1/30/99 5:08p Dave
133 * More new hi-res stuff.Support for nice D3D textures.
135 * 9 1/30/99 1:29a Dave
136 * Fixed nebula thumbnail problem. Full support for 1024x768 choose pilot
137 * screen. Fixed beam weapon death messages.
139 * 8 1/29/99 4:17p Dave
140 * New interface screens.
142 * 7 1/13/99 7:19p Neilk
143 * Converted Mission Brief, Barracks, Synch to high res support
145 * 6 12/18/98 1:13a Dave
146 * Rough 1024x768 support for Direct3D. Proper detection and usage through
149 * 5 11/30/98 1:07p Dave
150 * 16 bit conversion, first run.
152 * 4 11/20/98 4:08p Dave
153 * Fixed flak effect in multiplayer.
155 * 3 10/13/98 9:28a Dave
156 * Started neatening up freespace.h. Many variables renamed and
157 * reorganized. Added AlphaColors.[h,cpp]
159 * 2 10/07/98 10:53a Dave
162 * 1 10/07/98 10:49a Dave
164 * 114 9/17/98 3:08p Dave
165 * PXO to non-pxo game warning popup. Player icon stuff in create and join
166 * game screens. Upped server count refresh time in PXO to 35 secs (from
169 * 113 6/19/98 3:52p Lawrance
170 * Don't use large text in popup, since it is missing large foreign chars
172 * 112 6/09/98 5:17p Lawrance
173 * French/German localization
175 * 111 6/09/98 10:31a Hoffoss
176 * Created index numbers for all xstr() references. Any new xstr() stuff
177 * added from here on out should be added to the end if the list. The
178 * current list count can be found in FreeSpace.cpp (search for
181 * 110 6/01/98 11:43a John
182 * JAS & MK: Classified all strings for localization.
184 * 109 5/22/98 10:44a Lawrance
185 * put in case label to suppress warning
187 * 108 5/19/98 11:35p Lawrance
188 * Play sound for briefing control button presses
190 * 107 5/19/98 8:47p Lawrance
191 * Set proper distance for jump nodes
193 * 106 5/19/98 8:35p Dave
194 * Revamp PXO channel listing system. Send campaign goals/events to
195 * clients for evaluation. Made lock button pressable on all screens.
197 * 105 5/12/98 2:16p Hoffoss
198 * Added debug code to switch models of closeup icon to more easily check
199 * positions and zooms.
201 * 104 5/06/98 11:50p Lawrance
202 * Clean up help overlay code for loadout screens
204 * 103 5/06/98 8:03p Allender
205 * AL: only free pointers in brief_compact_stages if non-null
207 * 102 5/05/98 4:48p Lawrance
208 * Fix bug with launching closeup icon when pause button is pressed
210 * 101 4/29/98 1:45p Lawrance
211 * Print out mission filename if debug build, or if INTERPLAY QA defined
213 * 100 4/29/98 12:15a Lawrance
214 * reset demo trailer timer when briefing moves to a new stage
216 * 98 4/25/98 11:55p Lawrance
217 * fix bug with the auto-advance button
219 * 97 4/25/98 3:49p Lawrance
220 * Save briefing auto-advance pref
222 * 96 4/25/98 12:00p Lawrance
223 * disable advance keypress for 1/2 second after autoadvance
225 * 95 4/22/98 7:24p Dave
226 * Made sure the "player/ships" locked button for multiplayer appears on
227 * all briefing screens.
229 * 94 4/20/98 3:53p Lawrance
230 * Fix various bugs with auto-advancing through briefings.
232 * 93 4/19/98 12:11p Lawrance
233 * add new art for pause button in the briefing
235 * 92 4/17/98 10:39p Andsager
236 * AL: Fix bug with auto-advance of briefing stages.
238 * 91 4/16/98 8:05p Lawrance
239 * Don't show closeup icon for planets
241 * 90 4/15/98 5:17p Lawrance
242 * fix bug with skip training
248 #include "freespace.h"
249 #include "missionload.h"
250 #include "missionscreencommon.h"
251 #include "missionshipchoice.h"
252 #include "missionparse.h"
253 #include "missiongoals.h"
254 #include "gamesequence.h"
263 #include "linklist.h"
268 #include "audiostr.h"
270 #include "eventmusic.h"
271 #include "missioncampaign.h"
274 #include "snazzyui.h"
276 #include "missionbrief.h"
277 #include "missionbriefcommon.h"
278 #include "missiongrid.h"
280 #include "multimsgs.h"
282 #include "contexthelp.h"
284 #include "multiteamselect.h"
286 #include "asteroid.h"
289 #include "alphacolors.h"
291 #include "missionmessage.h"
294 #define OBJECTIVES_X 65
295 #define OBJECTIVES_Y 137
296 #define OBJECTIVES_W 508
297 #define OBJECTIVES_H 233
300 static int Brief_goals_coords[GR_NUM_RESOLUTIONS][4] = {
302 65,152,508,211 // GR_640
305 104,243,813,332 // GR_1024
309 static int Current_brief_stage; // what stage of the briefing we're on
310 static int Last_brief_stage;
311 static int Num_brief_stages;
312 static int Brief_multiplayer = FALSE;
314 static int Brief_last_auto_advance = 0; // timestamp of last auto-advance
316 // for managing the scene cut transition
317 static int Quick_transition_stage;
318 static int Start_fade_up_anim, Start_fade_down_anim;
319 static int Brief_playing_fade_sound;
322 int Briefing_music_handle = -1;
323 int Briefing_music_begin_timestamp = 0;
325 // --------------------------------------------------------------------------------------
326 // Module scope globals
327 // --------------------------------------------------------------------------------------
329 static MENU_REGION Briefing_select_region[NUM_BREIFING_REGIONS];
330 static int Num_briefing_regions;
332 // For closeup display
333 #define ONE_REV_TIME 6 // time (sec) for one revolution
334 #define MAX_ANG_CHG 0.15f
336 static int Closeup_coords[GR_NUM_RESOLUTIONS][4] = {
338 203, 151, 200, 213 // GR_640
341 325, 241, 200, 213 // GR_1024
345 static int Closeup_img_h[GR_NUM_RESOLUTIONS] = {
354 static int Closeup_text_h[GR_NUM_RESOLUTIONS][4] = {
363 static int Brief_infobox_coords[GR_NUM_RESOLUTIONS][2] = {
372 static char *Brief_infobox_filename[GR_NUM_RESOLUTIONS] = {
377 static char *Brief_filename[GR_NUM_RESOLUTIONS] = {
382 static char *Brief_multi_filename[GR_NUM_RESOLUTIONS] = {
387 static char *Brief_mask_filename[GR_NUM_RESOLUTIONS] = {
392 static char *Brief_multi_mask_filename[GR_NUM_RESOLUTIONS] = {
398 static char *Brief_win_filename[GR_NUM_RESOLUTIONS] = {
403 // coordinate inidices
404 #define BRIEF_X_COORD 0
405 #define BRIEF_Y_COORD 1
406 #define BRIEF_W_COORD 2
407 #define BRIEF_H_COORD 3
409 //static int Closeup_region[4] = {220,132,420,269};
410 int Closeup_region[GR_NUM_RESOLUTIONS][4] = {
419 char *Closeup_background_filename[GR_NUM_RESOLUTIONS] = {
420 NOX("BriefPop"), // GR_640
421 NOX("2_BriefPop") // GR_1024
424 char *Closeup_button_filename[GR_NUM_RESOLUTIONS] = {
425 NOX("BPB_00"), // GR_640
426 NOX("2_BPB_00"), // GR_1024
429 int Closeup_button_hotspot = 14;
431 //static int Closeup_button_coords[2] = {CLOSEUP_X+164,CLOSEUP_Y+227};
432 int Closeup_button_coords[GR_NUM_RESOLUTIONS][2] = {
433 { 374, 316 }, // GR_640
434 { 599, 506 } // GR_1024
437 UI_BUTTON Closeup_close_button;
438 int Closeup_bitmap=-1;
439 int Closeup_one_revolution_time=ONE_REV_TIME;
441 brief_icon *Closeup_icon;
442 angles Closeup_angles;
443 matrix Closeup_orient;
445 int Closeup_font_height;
446 int Closeup_x1, Closeup_y1;
448 // used for the 3d view of a closeup ship
450 vector Closeup_cam_pos;
452 // Mask bitmap pointer and Mask bitmap_id
453 bitmap* BriefingMaskPtr; // bitmap pointer to the briefing select mask bitmap
454 ubyte* BriefingMaskData; // pointer to actual bitmap data
455 int Briefing_mask_w, Briefing_mask_h;
456 int BriefingMaskBitmap; // bitmap id of the briefing mask bitmap
457 int Brief_inited = FALSE;
459 // --------------------------------------------------------------------------------------
460 // Briefing specific UI
461 // --------------------------------------------------------------------------------------
462 #define BRIEF_LAST_STAGE_MASK 7
463 #define BRIEF_NEXT_STAGE_MASK 8
464 #define BRIEF_PREV_STAGE_MASK 9
465 #define BRIEF_FIRST_STAGE_MASK 10
466 #define BRIEF_TEXT_SCROLL_UP_MASK 11
467 #define BRIEF_TEXT_SCROLL_DOWN_MASK 12
468 #define BRIEF_SKIP_TRAINING_MASK 15
469 #define BRIEF_PAUSE_MASK 16
472 static char *Brief_mask_single[GR_NUM_RESOLUTIONS] = {
474 "2_brief-m" // GR_1024
477 static char *Brief_mask_multi[GR_NUM_RESOLUTIONS] = {
478 "briefmulti-m", // GR_640
479 "2_briefmulti-m" // GR_1024
483 struct brief_buttons {
489 UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
491 brief_buttons(char *name, int x1, int y1, int xt1, int yt1, int h, int r = 0) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), repeat(r) {}
494 int Brief_grid_bitmap = -1;
495 int Brief_text_bitmap = -1;
497 int Brief_multitext_bitmap = -1;
498 int Brief_background_bitmap =-1;
500 UI_WINDOW Brief_ui_window;
502 // Briefing specific buttons
503 #define NUM_BRIEF_BUTTONS 10
505 brief_buttons Brief_buttons[GR_NUM_RESOLUTIONS][NUM_BRIEF_BUTTONS] = {
507 brief_buttons("BRB_08", 110, 116, 117, 157, 8),
508 brief_buttons("BRB_09", 84, 116, 117, 157, 9),
509 brief_buttons("BRB_10", 29, 116, 117, 157, 10),
510 brief_buttons("BRB_11", 4, 116, 117, 157, 11),
511 brief_buttons("BRB_12", 0, 405, 117, 157, 12),
512 brief_buttons("BRB_13", 0, 447, 117, 157, 13),
513 brief_buttons("BRB_15", 562, 0, 117, 157, 15), // skip training
514 brief_buttons("BRB_16", 56, 116, 117, 157, 16),
515 brief_buttons("TSB_34", 603, 374, 117, 157, 34),
516 brief_buttons("BRB_15", 562, 0, 117, 157, 15) // exit loop
519 brief_buttons("2_BRB_08", 175, 187, 117, 157, 8),
520 brief_buttons("2_BRB_09", 135, 187, 117, 157, 9),
521 brief_buttons("2_BRB_10", 47, 187, 117, 157, 10),
522 brief_buttons("2_BRB_11", 8, 187, 117, 157, 11),
523 brief_buttons("2_BRB_12", 0, 649, 117, 157, 12),
524 brief_buttons("2_BRB_13", 0, 716, 117, 157, 13),
525 brief_buttons("2_BRB_15", 900, 0, 117, 157, 15), // skip training
526 brief_buttons("2_BRB_16", 91, 187, 117, 157, 16),
527 brief_buttons("2_TSB_34", 966, 599, 117, 157, 34),
528 brief_buttons("2_BRB_15", 900, 0, 117, 157, 15) // exit loop
533 #define BRIEF_SELECT_NUM_TEXT 3
534 UI_XSTR Brief_select_text[GR_NUM_RESOLUTIONS][BRIEF_SELECT_NUM_TEXT] = {
536 { "Lock", 1270, 602, 364, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[0][BRIEF_BUTTON_MULTI_LOCK].button },
537 { "Skip Training", 1442, 467, 7, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[0][BRIEF_BUTTON_SKIP_TRAINING].button },
538 { "Exit Loop", 1477, 490, 7, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[0][BRIEF_BUTTON_EXIT_LOOP].button }
541 { "Lock", 1270, 964, 584, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[1][BRIEF_BUTTON_MULTI_LOCK].button },
542 { "Skip Training", 1442, 805, 12, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[1][BRIEF_BUTTON_SKIP_TRAINING].button },
543 { "Exit Loop", 1477, 830, 12, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[1][BRIEF_BUTTON_EXIT_LOOP].button }
547 // coordinates for briefing title -- the x value is for the RIGHT side of the text
548 static int Title_coords[GR_NUM_RESOLUTIONS][2] = {
549 {575, 117}, // GR_640
550 {918, 194} // GR_1024
553 // coordinates for briefing title in multiplayer briefings -- the x value is for the LEFT side of the text
554 // third coord is max width of area for it to fit into (it is force fit there)
555 static int Title_coords_multi[GR_NUM_RESOLUTIONS][3] = {
556 {1, 105, 190}, // GR_640
557 {1, 174, 304} // GR_1024
560 // briefing line widths
561 int Brief_max_line_width[GR_NUM_RESOLUTIONS] = {
562 MAX_BRIEF_LINE_W_640, MAX_BRIEF_LINE_W_1024
565 // --------------------------------------------------------------------------------------
566 // Forward declarations
567 // --------------------------------------------------------------------------------------
568 int brief_setup_closeup(brief_icon *bi);
569 void brief_maybe_blit_scene_cut(float frametime);
570 void brief_transition_reset();
572 char *brief_tooltip_handler(char *str)
574 if (!stricmp(str, NOX("@close"))) {
576 return XSTR( "Close", 428);
582 // brief_skip_training_pressed()
584 // called when the skip training button on the briefing screen is hit. When this happens,
585 // do a popup, then move to the next mission in the campaign.
586 void brief_skip_training_pressed()
590 val = popup(PF_USE_NEGATIVE_ICON | PF_USE_AFFIRMATIVE_ICON,2,POPUP_NO,POPUP_YES,XSTR( "Skip Training\n\n\n\nAre you sure you want to skip this training mission?", 429));
592 // val is 0 when we hit no (first on the list)
593 // AL: also, -1 is returned when ESC is hit
598 // page out mission messages
599 message_mission_shutdown();
601 if ( !(Game_mode & GM_CAMPAIGN_MODE) ){
602 gameseq_post_event( GS_EVENT_MAIN_MENU );
605 // tricky part. Need to move to the next mission in the campaign.
606 mission_goal_mark_objectives_complete();
607 mission_goal_fail_incomplete();
608 mission_campaign_store_goals_and_events();
610 mission_campaign_eval_next_mission();
611 mission_campaign_mission_over();
614 if(game_do_cd_mission_check(Game_current_mission_filename)){
615 gameseq_post_event( GS_EVENT_START_GAME );
617 gameseq_post_event( GS_EVENT_MAIN_MENU );
622 extern void demo_reset_trailer_timer();
624 // --------------------------------------------------------------------------------------
625 // brief_do_next_pressed()
628 void brief_do_next_pressed(int play_sound)
631 now = timer_get_milliseconds();
633 if ( (now - Brief_last_auto_advance) < 500 ) {
638 demo_reset_trailer_timer();
641 Current_brief_stage++;
642 if ( Current_brief_stage >= Num_brief_stages ) {
643 Current_brief_stage = Num_brief_stages - 1;
644 gamesnd_play_iface(SND_GENERAL_FAIL);
645 if ( Quick_transition_stage != -1 )
646 brief_transition_reset();
649 gamesnd_play_iface(SND_BRIEF_STAGE_CHG);
653 Assert(Current_brief_stage >= 0);
656 // --------------------------------------------------------------------------------------
657 // brief_do_prev_pressed()
660 void brief_do_prev_pressed()
662 Current_brief_stage--;
663 if ( Current_brief_stage < 0 ) {
664 Current_brief_stage = 0;
665 gamesnd_play_iface(SND_GENERAL_FAIL);
666 if ( Quick_transition_stage != -1 )
667 brief_transition_reset();
669 gamesnd_play_iface(SND_BRIEF_STAGE_CHG);
671 Assert(Current_brief_stage >= 0);
675 // --------------------------------------------------------------------------------------
676 // brief_do_start_pressed()
679 void brief_do_start_pressed()
681 if ( Current_brief_stage != 0 ) {
682 gamesnd_play_iface(SND_BRIEF_STAGE_CHG);
683 Current_brief_stage = 0;
684 if ( Quick_transition_stage != -1 )
685 brief_transition_reset();
687 gamesnd_play_iface(SND_GENERAL_FAIL);
689 Assert(Current_brief_stage >= 0);
692 // --------------------------------------------------------------------------------------
693 // brief_do_end_pressed()
696 void brief_do_end_pressed()
698 if ( Current_brief_stage != Num_brief_stages - 1 ) {
699 gamesnd_play_iface(SND_BRIEF_STAGE_CHG);
700 Current_brief_stage = Num_brief_stages - 1;
701 if ( Quick_transition_stage != -1 )
702 brief_transition_reset();
705 gamesnd_play_iface(SND_GENERAL_FAIL);
707 Assert(Current_brief_stage >= 0);
711 void brief_scroll_up_text()
713 Top_brief_text_line--;
714 if ( Top_brief_text_line < 0 ) {
715 Top_brief_text_line = 0;
716 gamesnd_play_iface(SND_GENERAL_FAIL);
718 gamesnd_play_iface(SND_SCROLL);
722 void brief_scroll_down_text()
724 Top_brief_text_line++;
725 if ( (Num_brief_text_lines[0] - Top_brief_text_line) < Brief_text_max_lines[gr_screen.res]) {
726 Top_brief_text_line--;
727 gamesnd_play_iface(SND_GENERAL_FAIL);
729 gamesnd_play_iface(SND_SCROLL);
734 // handles the exit loop option
735 void brief_exit_loop_pressed()
737 int val = popup(PF_USE_NEGATIVE_ICON | PF_USE_AFFIRMATIVE_ICON, 2, POPUP_NO, POPUP_YES, XSTR( "Exit Loop\n\n\n\nAre you sure you want to leave the mission loop?", 1489));
739 // bail if esc hit or no clicked
744 // handle the details
745 // this also posts the start game event
746 mission_campaign_exit_loop();
750 // -------------------------------------------------------------------------------------
751 // brief_select_button_do() do the button action for the specified pressed button
753 void brief_button_do(int i)
756 case BRIEF_BUTTON_LAST_STAGE:
757 brief_do_end_pressed();
760 case BRIEF_BUTTON_NEXT_STAGE:
761 brief_do_next_pressed(1);
764 case BRIEF_BUTTON_PREV_STAGE:
765 brief_do_prev_pressed();
768 case BRIEF_BUTTON_FIRST_STAGE:
769 brief_do_start_pressed();
772 case BRIEF_BUTTON_SCROLL_UP:
773 brief_scroll_up_text();
776 case BRIEF_BUTTON_SCROLL_DOWN:
777 brief_scroll_down_text();
780 case BRIEF_BUTTON_PAUSE:
781 gamesnd_play_iface(SND_USER_SELECT);
782 Player->auto_advance ^= 1;
785 case BRIEF_BUTTON_SKIP_TRAINING:
786 brief_skip_training_pressed();
789 case BRIEF_BUTTON_EXIT_LOOP:
790 brief_exit_loop_pressed();
793 case BRIEF_BUTTON_MULTI_LOCK:
794 Assert(Game_mode & GM_MULTIPLAYER);
795 // the "lock" button has been pressed
796 multi_ts_lock_pressed();
798 // disable the button if it is now locked
799 if(multi_ts_is_locked()){
800 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.disable();
806 // -------------------------------------------------------------------
807 // brief_check_buttons()
809 // Iterate through the briefing buttons, checking if they are pressed
811 void brief_check_buttons()
816 for (i=0; i<NUM_BRIEF_BUTTONS; i++) {
817 b = &Brief_buttons[gr_screen.res][i].button;
818 if ( b->pressed() ) {
819 common_flash_button_init();
824 if (Closeup_close_button.pressed()) {
825 brief_turn_off_closeup_icon();
829 // -------------------------------------------------------------------
830 // brief_redraw_pressed_buttons()
832 // Redraw any briefing buttons that are pressed down. This function is needed
833 // since we sometimes need to draw pressed buttons last to ensure the entire
834 // button gets drawn (and not overlapped by other buttons)
836 void brief_redraw_pressed_buttons()
841 common_redraw_pressed_buttons();
843 for ( i = 0; i < NUM_BRIEF_BUTTONS; i++ ) {
844 b = &Brief_buttons[gr_screen.res][i].button;
845 if ( b->button_down() ) {
850 if ( !Player->auto_advance ) {
851 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PAUSE].button.draw_forced(2);
855 void brief_buttons_init()
860 //if ( Briefing->num_stages <= 0 )
863 for ( i = 0; i < NUM_BRIEF_BUTTONS; i++ ) {
864 b = &Brief_buttons[gr_screen.res][i].button;
865 b->create( &Brief_ui_window, "", Brief_buttons[gr_screen.res][i].x, Brief_buttons[gr_screen.res][i].y, 60, 30, 0, 1 );
866 // set up callback for when a mouse first goes over a button
867 b->set_highlight_action( common_play_highlight_sound );
869 if ((i == BRIEF_BUTTON_SKIP_TRAINING) || (i == BRIEF_BUTTON_EXIT_LOOP)) {
870 b->set_bmaps(Brief_buttons[gr_screen.res][i].filename, 3, 0);
872 b->set_bmaps(Brief_buttons[gr_screen.res][i].filename);
874 b->link_hotspot(Brief_buttons[gr_screen.res][i].hotspot);
878 for(i=0; i<BRIEF_SELECT_NUM_TEXT; i++) {
879 Brief_ui_window.add_XSTR(&Brief_select_text[gr_screen.res][i]);
882 // Hide the 'skip training' button by default. Only enable and unhide if we are playing a training
884 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SKIP_TRAINING].button.disable();
885 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SKIP_TRAINING].button.hide();
886 if ( (Game_mode & GM_NORMAL) && (The_mission.game_type & MISSION_TYPE_TRAINING) ) {
887 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SKIP_TRAINING].button.enable();
888 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SKIP_TRAINING].button.unhide();
891 // Hide the 'exit loop' button by default. Only enable and unhide if we are playing a loop
893 Brief_buttons[gr_screen.res][BRIEF_BUTTON_EXIT_LOOP].button.disable();
894 Brief_buttons[gr_screen.res][BRIEF_BUTTON_EXIT_LOOP].button.hide();
895 if ( (Game_mode & GM_NORMAL) && (Campaign.loop_enabled) && (Game_mode & GM_CAMPAIGN_MODE) ) {
896 Brief_buttons[gr_screen.res][BRIEF_BUTTON_EXIT_LOOP].button.enable();
897 Brief_buttons[gr_screen.res][BRIEF_BUTTON_EXIT_LOOP].button.unhide();
900 // maybe disable the multi-lock button
901 if(!(Game_mode & GM_MULTIPLAYER)){
902 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.hide();
903 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.disable();
905 // if we're not the host of the game (or a tema captain in team vs. team mode), disable the lock button
906 if(Netgame.type_flags & NG_TYPE_TEAM){
907 if(!(Net_player->flags & NETINFO_FLAG_TEAM_CAPTAIN)){
908 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.disable();
911 if(!(Net_player->flags & NETINFO_FLAG_GAME_HOST)){
912 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.disable();
917 // create close button for closeup popup
918 Closeup_close_button.create( &Brief_ui_window, "", Closeup_button_coords[gr_screen.res][BRIEF_X_COORD], Closeup_button_coords[gr_screen.res][BRIEF_Y_COORD], 60, 30, 0, 1 );
919 Closeup_close_button.set_highlight_action( common_play_highlight_sound );
920 Closeup_close_button.set_bmaps(Closeup_button_filename[gr_screen.res]);
921 Closeup_close_button.link_hotspot(Closeup_button_hotspot);
923 // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed
924 Brief_buttons[gr_screen.res][BRIEF_BUTTON_LAST_STAGE].button.set_hotkey(KEY_SHIFTED|KEY_RIGHT);
925 Brief_buttons[gr_screen.res][BRIEF_BUTTON_NEXT_STAGE].button.set_hotkey(KEY_RIGHT);
926 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PREV_STAGE].button.set_hotkey(KEY_LEFT);
927 Brief_buttons[gr_screen.res][BRIEF_BUTTON_FIRST_STAGE].button.set_hotkey(KEY_SHIFTED|KEY_LEFT);
928 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_UP].button.set_hotkey(KEY_UP);
929 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_DOWN].button.set_hotkey(KEY_DOWN);
931 Closeup_close_button.disable();
932 Closeup_close_button.hide();
934 // if we have no briefing stages, hide and disable briefing buttons
935 if(Num_brief_stages <= 0){
936 Brief_buttons[gr_screen.res][BRIEF_BUTTON_LAST_STAGE].button.disable();
937 Brief_buttons[gr_screen.res][BRIEF_BUTTON_LAST_STAGE].button.hide();
938 Brief_buttons[gr_screen.res][BRIEF_BUTTON_NEXT_STAGE].button.disable();
939 Brief_buttons[gr_screen.res][BRIEF_BUTTON_NEXT_STAGE].button.hide();
940 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PREV_STAGE].button.disable();
941 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PREV_STAGE].button.hide();
942 Brief_buttons[gr_screen.res][BRIEF_BUTTON_FIRST_STAGE].button.disable();
943 Brief_buttons[gr_screen.res][BRIEF_BUTTON_FIRST_STAGE].button.hide();
944 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_UP].button.disable();
945 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_UP].button.hide();
946 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_DOWN].button.disable();
947 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_DOWN].button.hide();
948 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PAUSE].button.disable();
949 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PAUSE].button.hide();
953 // --------------------------------------------------------------------------------------
954 // brief_get_closeup_icon()
957 uint brief_get_closeup_icon()
959 return (uint)Closeup_icon;
962 // stop showing the closeup view of an icon
963 void brief_turn_off_closeup_icon()
966 if ( Closeup_icon != NULL ) {
967 gamesnd_play_iface(SND_BRIEF_ICON_SELECT);
969 Closeup_close_button.disable();
970 Closeup_close_button.hide();
974 // --------------------------------------------------------------------------------------
975 // brief_load_bitmaps()
978 void brief_load_bitmaps()
980 Brief_text_bitmap = bm_load(Brief_infobox_filename[gr_screen.res]);
981 Brief_grid_bitmap = bm_load(Brief_win_filename[gr_screen.res]);
983 if ( Closeup_bitmap == -1 ) {
984 Closeup_bitmap = bm_load(Closeup_background_filename[gr_screen.res]);
988 // --------------------------------------------------------------------------------------
994 if(Game_mode & GM_MULTIPLAYER) {
995 Brief_background_bitmap = bm_load(Brief_multi_filename[gr_screen.res]);
997 Brief_background_bitmap = bm_load(Brief_filename[gr_screen.res]);
1000 if ( Num_brief_stages <= 0 ){
1004 brief_load_bitmaps();
1008 // --------------------------------------------------------------------------------------
1009 // brief_set_default_closeup()
1012 void brief_set_default_closeup()
1017 bs = &Briefing->stages[0];
1019 if ( Briefing->num_stages <= 0 ) {
1020 Closeup_icon = NULL;
1024 if ( bs->num_icons <= 0 ) {
1025 Closeup_icon = NULL;
1029 // check for the first highlighted icons to have as the default closeup
1030 for ( i = 0; i < bs->num_icons; i++ ) {
1031 if ( bs->icons[i].flags & BI_HIGHLIGHT )
1035 if ( i == bs->num_icons ) {
1036 brief_setup_closeup(&bs->icons[0]);
1039 brief_setup_closeup(&bs->icons[i]);
1043 // funciton to evaluate the sexpressions of the briefing stages eliminating those stages
1044 // which shouldn't get shown
1045 void brief_compact_stages()
1050 if((Game_mode & GM_MULTIPLAYER) && (Netgame.campaign_mode == MP_CAMPAIGN) && !(Net_player->flags & NETINFO_FLAG_AM_MASTER)){
1051 Game_mode |= GM_CAMPAIGN_MODE;
1056 while ( num < Briefing->num_stages ) {
1057 result = eval_sexp( Briefing->stages[num].formula );
1059 if ( Briefing->stages[num].new_text ) {
1060 free( Briefing->stages[num].new_text );
1061 Briefing->stages[num].new_text = NULL;
1064 if ( Briefing->stages[num].icons ) {
1065 free( Briefing->stages[num].icons );
1066 Briefing->stages[num].icons = NULL;
1070 if ( Briefing->stages[num].lines ) {
1071 free( Briefing->stages[num].lines );
1072 Briefing->stages[num].lines = NULL;
1075 Briefing->stages[num].num_icons = 0;
1076 for ( i = num+1; i < Briefing->num_stages; i++ ) {
1077 Briefing->stages[i-1] = Briefing->stages[i];
1079 Briefing->num_stages--;
1086 if((Game_mode & GM_MULTIPLAYER) && (Netgame.campaign_mode == MP_CAMPAIGN) && !(Net_player->flags & NETINFO_FLAG_AM_MASTER)){
1087 Game_mode &= ~(GM_CAMPAIGN_MODE);
1093 // --------------------------------------------------------------------------------------
1096 int red_alert_mission(void);
1100 // Since first stage of briefing can take some time to arrive and play,
1101 // reset the trailer timer on briefing init.
1103 demo_reset_trailer_timer();
1106 // for multiplayer, change the state in my netplayer structure
1107 // and initialize the briefing chat area thingy
1108 if ( Game_mode & GM_MULTIPLAYER ){
1109 Net_player->state = NETPLAYER_STATE_BRIEFING;
1112 // Non standard briefing in red alert mission
1113 if ( red_alert_mission() ) {
1114 gameseq_post_event(GS_EVENT_RED_ALERT);
1118 // get a pointer to the appropriate briefing structure
1119 if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)){
1120 Briefing = &Briefings[Net_player->p_info.team];
1122 Briefing = &Briefings[0];
1125 Brief_last_auto_advance = 0;
1127 brief_compact_stages(); // compact the briefing array to eliminate unused stages
1129 common_set_interface_palette("BriefingPalette");
1131 ship_stop_animation();
1132 set_active_ui(&Brief_ui_window);
1133 Current_screen = ON_BRIEFING_SELECT;
1134 brief_restart_text_wipe();
1135 common_flash_button_init();
1136 common_music_init(SCORE_BRIEFING);
1139 help_overlay_set_state(BR_OVERLAY,0);
1141 if ( Brief_inited == TRUE ) {
1142 common_buttons_maybe_reload(&Brief_ui_window); // AL 11-21-97: this is necessary since we may returning from the hotkey
1143 // screen, which can release common button bitmaps.
1144 common_reset_buttons();
1145 nprintf(("Alan","brief_init() returning without doing anything\n"));
1149 if (The_mission.game_type & MISSION_TYPE_TRAINING)
1150 Num_brief_stages = Briefing->num_stages;
1152 Num_brief_stages = Briefing->num_stages + 1;
1154 Current_brief_stage = 0;
1155 Last_brief_stage = 0;
1157 // init the scene-cut data
1158 brief_transition_reset();
1161 hud_anim_init(&Fade_anim, Brief_static_coords[gr_screen.res][0], Brief_static_coords[gr_screen.res][1], Brief_static_name[gr_screen.res]);
1162 hud_anim_load(&Fade_anim);
1165 nprintf(("Alan","Entering brief_init()\n"));
1166 common_select_init();
1168 if(Game_mode & GM_MULTIPLAYER) {
1169 BriefingMaskBitmap = bm_load(Brief_multi_mask_filename[gr_screen.res]);
1171 BriefingMaskBitmap = bm_load(Brief_mask_filename[gr_screen.res]);
1174 if (BriefingMaskBitmap < 0) {
1175 Error(LOCATION,"Could not load in 'brief-m'!");
1178 Briefing_mask_w = -1;
1179 Briefing_mask_h = -1;
1181 // get a pointer to bitmap by using bm_lock()
1182 BriefingMaskPtr = bm_lock(BriefingMaskBitmap, 8, BMP_AABITMAP);
1183 BriefingMaskData = (ubyte*)BriefingMaskPtr->data;
1184 bm_get_info(BriefingMaskBitmap, &Briefing_mask_w, &Briefing_mask_h);
1186 help_overlay_load(BR_OVERLAY);
1188 // Set up the mask regions
1189 // initialize the different regions of the menu that will react when the mouse moves over it
1190 Num_briefing_regions = 0;
1192 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_BRIEFING_REGION, 0);
1193 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_SS_REGION, 0);
1194 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_WEAPON_REGION, 0);
1195 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_COMMIT_REGION, 0);
1196 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_HELP_REGION, 0);
1197 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_OPTIONS_REGION, 0);
1199 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_LAST_STAGE_MASK, 0);
1200 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_NEXT_STAGE_MASK, 0);
1201 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_PREV_STAGE_MASK, 0);
1202 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_FIRST_STAGE_MASK, 0);
1203 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_TEXT_SCROLL_UP_MASK, 0);
1204 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_TEXT_SCROLL_DOWN_MASK, 0);
1207 Brief_ui_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
1209 if(Game_mode & GM_MULTIPLAYER){
1210 Brief_ui_window.set_mask_bmap(Brief_mask_multi[gr_screen.res]);
1212 Brief_ui_window.set_mask_bmap(Brief_mask_single[gr_screen.res]);
1215 Brief_ui_window.tooltip_handler = brief_tooltip_handler;
1216 common_buttons_init(&Brief_ui_window);
1217 brief_buttons_init();
1219 // if multiplayer, initialize a few other systems
1220 if(Game_mode & GM_MULTIPLAYER){
1221 // again, should not be necessary, but we'll leave it for now
1224 // force the chatbox to be small
1225 chatbox_force_small();
1228 // set up the screen regions
1229 brief_init_screen(Brief_multiplayer);
1231 // init briefing specific UI
1234 // init the briefing map
1237 // init the briefing voice playback
1239 brief_voice_load_all();
1241 // init objectives display stuff
1242 ML_objectives_init(Brief_goals_coords[gr_screen.res][BRIEF_X_COORD], Brief_goals_coords[gr_screen.res][BRIEF_Y_COORD], Brief_goals_coords[gr_screen.res][BRIEF_W_COORD], Brief_goals_coords[gr_screen.res][BRIEF_H_COORD]);
1244 // set the camera target
1245 if ( Briefing->num_stages > 0 ) {
1246 brief_set_new_stage(&Briefing->stages[0].camera_pos, &Briefing->stages[0].camera_orient, 0, Current_brief_stage);
1247 brief_reset_icons(Current_brief_stage);
1250 Brief_playing_fade_sound = 0;
1251 Brief_mouse_up_flag = 0;
1252 Closeup_font_height = gr_get_font_height();
1253 Closeup_icon = NULL;
1254 Brief_inited = TRUE;
1257 // -------------------------------------------------------------------------------------
1258 // brief_render_closeup_text()
1261 #define CLOSEUP_TEXT_OFFSET 10
1262 void brief_render_closeup_text()
1266 char line[MAX_ICON_TEXT_LINE_LEN];
1267 int n_lines, i, render_x, render_y;
1268 int n_chars[MAX_ICON_TEXT_LINES];
1269 char *p_str[MAX_ICON_TEXT_LINES];
1271 if ( Closeup_icon == NULL ) {
1278 render_x = Closeup_region[0];
1279 render_y = Closeup_region[1] + CLOSEUP_IMG_H;
1281 gr_set_clip(render_x+CLOSEUP_TEXT_OFFSET, render_y, CLOSEUP_W,CLOSEUP_TEXT_H);
1282 gr_set_color_fast(&Color_white);
1284 // n_lines = split_str(bi->text, CLOSEUP_W - 2*CLOSEUP_TEXT_OFFSET, n_chars, p_str, MAX_ICON_TEXT_LINES);
1285 Assert(n_lines != -1);
1287 for ( i = 0; i < n_lines; i++ ) {
1288 Assert(n_chars[i] < MAX_ICON_TEXT_LINE_LEN);
1289 strncpy(line, p_str[i], n_chars[i]);
1290 line[n_chars[i]] = 0;
1291 gr_printf(0,0+i*Closeup_font_height,line);
1296 // -------------------------------------------------------------------------------------
1297 // brief_render_closeup()
1300 void brief_render_closeup(int ship_class, float frametime)
1302 matrix view_orient = IDENTITY_MATRIX;
1310 if (Closeup_bitmap < 0)
1313 ang = PI2 * frametime/Closeup_one_revolution_time;
1314 if ( ang > MAX_ANG_CHG )
1317 Closeup_angles.h += ang;
1318 if ( Closeup_angles.h > PI2 )
1319 Closeup_angles.h -= PI2;
1320 vm_angles_2_matrix(&temp_matrix, &Closeup_angles );
1321 Closeup_orient = temp_matrix;
1323 w = Closeup_region[gr_screen.res][2];
1324 h = Closeup_region[gr_screen.res][3];
1325 gr_set_clip(Closeup_region[gr_screen.res][0], Closeup_region[gr_screen.res][1], w, h);
1329 g3_set_view_matrix(&Closeup_cam_pos, &view_orient, Closeup_zoom);
1330 model_clear_instance( Closeup_icon->modelnum );
1331 model_set_detail_level(0);
1333 int is_neb = The_mission.flags & MISSION_FLAG_FULLNEB;
1335 // maybe switch off nebula rendering
1337 The_mission.flags &= ~MISSION_FLAG_FULLNEB;
1340 int model_render_flags;
1341 if ( Closeup_icon->type == ICON_JUMP_NODE ) {
1342 model_set_outline_color(HUD_color_red, HUD_color_green, HUD_color_blue);
1343 model_render_flags = MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_POLYS | MR_SHOW_OUTLINE;
1345 model_render_flags = MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER;
1348 model_render( Closeup_icon->modelnum, &Closeup_orient, &Closeup_pos, model_render_flags );
1351 The_mission.flags |= MISSION_FLAG_FULLNEB;
1356 gr_set_color_fast(&Color_bright_white);
1358 gr_printf(0x8000,2,Closeup_icon->closeup_label);
1359 // brief_render_closeup_text();
1361 Closeup_close_button.enable();
1362 Closeup_close_button.unhide();
1367 // -------------------------------------------------------------------------------------
1370 // frametime is in seconds
1371 void brief_render(float frametime)
1380 if ( Num_brief_stages <= 0 ) {
1381 gr_set_color_fast(&Color_white);
1382 Assert( Game_current_mission_filename != NULL );
1383 gr_printf(0x8000,200,XSTR( "No Briefing exists for mission: %s", 430), Game_current_mission_filename);
1386 gr_get_string_size(&w, &h, The_mission.name);
1387 gr_set_color_fast(&Color_normal);
1388 gr_printf(0x8000, 230, NOX("[filename: %s, last mod: %s]"), Mission_filename, The_mission.modified);
1394 gr_set_bitmap(Brief_grid_bitmap);
1395 gr_bitmap(Brief_bmap_coords[gr_screen.res][0], Brief_bmap_coords[gr_screen.res][1]);
1397 brief_render_map(Current_brief_stage, frametime);
1399 // draw the frame bitmaps
1400 gr_set_bitmap(Brief_text_bitmap);
1401 gr_bitmap(Brief_infobox_coords[gr_screen.res][0], Brief_infobox_coords[gr_screen.res][1]);
1402 brief_blit_stage_num(Current_brief_stage, Num_brief_stages);
1404 z = brief_render_text(Top_brief_text_line, Brief_text_coords[gr_screen.res][0], Brief_text_coords[gr_screen.res][1], Brief_text_coords[gr_screen.res][3], frametime);
1406 brief_voice_play(Current_brief_stage);
1409 // maybe output the "more" indicator
1410 if ( (Brief_text_max_lines[gr_screen.res] + Top_brief_text_line + 2) < Num_brief_text_lines[0] ) {
1411 // can be scrolled down
1412 int more_txt_x = Brief_text_coords[gr_screen.res][0] + (Brief_max_line_width[gr_screen.res]/2) - 10;
1413 int more_txt_y = Brief_text_coords[gr_screen.res][1] + Brief_text_coords[gr_screen.res][3] - 2; // located below brief text, centered
1415 gr_get_string_size(&w, &h, XSTR("more", 1469), strlen(XSTR("more", 1469)));
1416 gr_set_color_fast(&Color_black);
1417 gr_rect(more_txt_x-2, more_txt_y, w+3, h);
1418 gr_set_color_fast(&Color_red);
1419 gr_string(more_txt_x, more_txt_y, XSTR("more", 1469)); // base location on the input x and y?
1422 brief_maybe_blit_scene_cut(frametime);
1424 #if !defined(NDEBUG) || defined(INTERPLAYQA)
1425 gr_set_color_fast(&Color_normal);
1426 int title_y_offset = (Game_mode & GM_MULTIPLAYER) ? 20 : 10;
1427 gr_printf(Brief_bmap_coords[gr_screen.res][0], Brief_bmap_coords[gr_screen.res][1]-title_y_offset, NOX("[name: %s, mod: %s]"), Mission_filename, The_mission.modified);
1430 // output mission title
1431 gr_set_color_fast(&Color_bright_white);
1432 if (Game_mode & GM_MULTIPLAYER) {
1434 strncpy(buf, The_mission.name, 256);
1435 gr_force_fit_string(buf, 255, Title_coords_multi[gr_screen.res][2]);
1436 gr_string(Title_coords_multi[gr_screen.res][0], Title_coords_multi[gr_screen.res][1], buf);
1438 gr_get_string_size(&w, NULL, The_mission.name);
1439 gr_string(Title_coords[gr_screen.res][0] - w, Title_coords[gr_screen.res][1], The_mission.name);
1442 // maybe do objectives
1443 if (Current_brief_stage == Briefing->num_stages) {
1444 ML_objectives_do_frame(0);
1448 // -------------------------------------------------------------------------------------
1449 // brief_set_closeup_pos()
1452 #define CLOSEUP_OFFSET 20
1453 void brief_set_closeup_pos(brief_icon *bi)
1456 Closeup_x1 = fl2i(320 - Closeup_coords[gr_screen.res][BRIEF_W_COORD]/2.0f + 0.5f);
1459 void brief_get_closeup_ship_modelnum(brief_icon *ci)
1464 // find the model number for the ship to display
1465 for ( objp = GET_FIRST(&obj_used_list); objp !=END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) ) {
1467 if ( objp == &obj_used_list || objp->type != OBJ_SHIP ) {
1471 sp = &Ships[objp->instance];
1472 if ( sp->ship_info_index == ci->ship_class ) {
1473 ci->ship_class = sp->ship_info_index;
1474 ci->modelnum = sp->modelnum;
1475 ci->radius = objp->radius;
1481 // cut any text off after (and including) '#' char
1482 void brief_truncate_label(char *src)
1484 char *pointer_to_last_char;
1486 pointer_to_last_char = strstr(src, NOX("#"));
1488 if ( pointer_to_last_char ) {
1489 *pointer_to_last_char = 0;
1493 // -------------------------------------------------------------------------------------
1494 // brief_setup_closeup()
1496 // exit: 0 => set-up icon sucessfully
1497 // -1 => could not setup closeup icon
1498 int brief_setup_closeup(brief_icon *bi)
1500 char pof_filename[NAME_LENGTH];
1501 ship_info *sip=NULL;
1505 Closeup_icon->ship_class = bi->ship_class;
1506 Closeup_icon->modelnum = -1;
1508 Closeup_one_revolution_time = ONE_REV_TIME;
1510 switch(Closeup_icon->type) {
1512 Closeup_icon = NULL;
1515 strcpy(pof_filename, NOX("planet.pof"));
1516 strcpy(Closeup_icon->closeup_label, XSTR("planet",-1));
1517 vm_vec_make(&Closeup_cam_pos, 0.0f, 0.0f, -8300.0f);
1518 Closeup_zoom = 0.5f;
1519 Closeup_one_revolution_time = ONE_REV_TIME * 3;
1522 case ICON_ASTEROID_FIELD:
1524 strcpy(pof_filename, Asteroid_info[ASTEROID_TYPE_BIG].pof_files[0]);
1525 strcpy(Closeup_icon->closeup_label, XSTR( "asteroid", 431));
1526 vm_vec_make(&Closeup_cam_pos, 0.0f, 0.0f, -334.0f);
1527 Closeup_zoom = 0.5f;
1530 case ICON_JUMP_NODE:
1531 strcpy(pof_filename, NOX("subspacenode.pof"));
1532 strcpy(Closeup_icon->closeup_label, XSTR( "jump node", 432));
1533 vm_vec_make(&Closeup_cam_pos, 0.0f, 0.0f, -2700.0f);
1534 Closeup_zoom = 0.5f;
1535 Closeup_one_revolution_time = ONE_REV_TIME * 3;
1538 case ICON_UNKNOWN_WING:
1539 strcpy(pof_filename, NOX("unknownship.pof"));
1540 strcpy(Closeup_icon->closeup_label, XSTR( "unknown", 433));
1541 vm_vec_make(&Closeup_cam_pos, 0.0f, 0.0f, -22.0f);
1542 Closeup_zoom = 0.5f;
1545 brief_get_closeup_ship_modelnum(Closeup_icon);
1546 Assert( Closeup_icon->ship_class != -1 );
1547 sip = &Ship_info[Closeup_icon->ship_class];
1549 strcpy(Closeup_icon->closeup_label,sip->name);
1551 // cut any text off after (and including) '#' char
1552 brief_truncate_label(Closeup_icon->closeup_label);
1554 if ( sip->flags & (SIF_SMALL_SHIP|SIF_BIG_SHIP|SIF_HUGE_SHIP|SIF_SENTRYGUN) ) {
1555 strcat(Closeup_icon->closeup_label, XSTR( " class", 434));
1560 if ( Closeup_icon->modelnum == -1 ) {
1561 if ( sip == NULL ) {
1562 Closeup_icon->modelnum = model_load(pof_filename, NULL, NULL);
1564 Closeup_icon->modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]);
1566 Closeup_icon->radius = model_get_radius(Closeup_icon->modelnum);
1569 vm_set_identity(&Closeup_orient);
1570 vm_vec_make(&tvec, 0.0f, 0.0f, -1.0f);
1571 Closeup_orient.fvec = tvec;
1572 vm_vec_zero(&Closeup_pos);
1573 Closeup_angles.p = 0.0f;
1574 Closeup_angles.b = 0.0f;
1575 Closeup_angles.h = PI;
1577 brief_set_closeup_pos(bi);
1580 Closeup_cam_pos = sip->closeup_pos;
1581 Closeup_zoom = sip->closeup_zoom;
1587 // -------------------------------------------------------------------------------------
1588 // brief_update_closeup_icon()
1590 // input: mode => how to update the closeup view
1593 void brief_update_closeup_icon(int mode)
1597 int i, closeup_index;
1601 // mode 0 means disable the closeup icon
1602 if ( Closeup_icon != NULL ) {
1603 brief_turn_off_closeup_icon();
1608 if ( Closeup_icon == NULL )
1611 bs = &Briefing->stages[Current_brief_stage];
1614 // see if any icons are being highlighted this stage
1615 for ( i = 0; i < bs->num_icons; i++ ) {
1617 if ( bi->flags & BI_HIGHLIGHT ) {
1623 if ( closeup_index != -1 ) {
1624 bi = &bs->icons[closeup_index];
1625 brief_setup_closeup(bi);
1628 Closeup_icon = NULL;
1633 // -------------------------------------------------------------------------------------
1634 // brief_check_for_anim()
1637 void brief_check_for_anim()
1639 int mx, my, i, iw, ih;
1641 brief_icon *bi = NULL;
1643 bs = &Briefing->stages[Current_brief_stage];
1644 mouse_get_pos( &mx, &my );
1646 // if mouse click is over the VCR controls, don't launch an icon
1647 // FIXME - should prolly push these into defines instead of hardcoding this
1648 if ( mx >= 0 && mx <= 115 && my >= 136 && my <= 148 ) {
1652 // if mouse coords are outside the briefing screen, then go away
1653 my -= bscreen.map_y1;
1654 mx -= bscreen.map_x1;
1655 if ( my < 0 || mx < 0 || mx > (bscreen.map_x2-bscreen.map_x1+1) || my > (bscreen.map_y2-bscreen.map_y1+1) )
1658 for ( i = 0; i < bs->num_icons; i++ ) {
1660 brief_common_get_icon_dimensions(&iw, &ih, bi->type, bi->ship_class);
1661 if ( mx < bi->x ) continue;
1662 if ( mx > (bi->x + iw) ) continue;
1663 if ( my < bi->y ) continue;
1664 if ( my > (bi->y + ih) ) continue;
1665 // if we've got here, must be a hit
1669 if ( i == bs->num_icons ) {
1670 brief_turn_off_closeup_icon();
1674 if ( brief_setup_closeup(bi) == 0 ) {
1675 gamesnd_play_iface(SND_BRIEF_ICON_SELECT);
1677 gamesnd_play_iface(SND_GENERAL_FAIL);
1681 // maybe flash a button if player hasn't done anything for a while
1682 void brief_maybe_flash_button()
1686 if ( Num_brief_stages <= 0 )
1689 if ( Closeup_icon != NULL ) {
1690 common_flash_button_init();
1694 if ( common_flash_bright() ) {
1695 if ( Current_brief_stage == (Num_brief_stages-1) ) {
1697 // AL 4-4-98: Don't flash ship selection button on briefing in demo build
1701 // AL 30-3-98: Don't flash ship selection button if in a training mission,
1702 if ( brief_only_allow_briefing() ) {
1706 b = &Common_buttons[Current_screen-1][gr_screen.res][1].button; // ship select button
1709 b = &Brief_buttons[gr_screen.res][1].button; // next stage button
1712 if ( b->button_hilighted() ) {
1713 common_flash_button_init();
1720 // -------------------------------------------------------------------------------------
1723 // frametime is in seconds
1725 void brief_do_frame(float frametime)
1727 int k, brief_choice;
1729 if ( red_alert_mission() ) {
1734 if ( !Brief_inited ){
1738 int snazzy_action = -1;
1739 brief_choice = snazzy_menu_do(BriefingMaskData, Briefing_mask_w, Briefing_mask_h, Num_briefing_regions, Briefing_select_region, &snazzy_action, 0);
1741 k = common_select_do(frametime);
1743 if ( Closeup_icon ) {
1744 Brief_mouse_up_flag = 0;
1747 if ( help_overlay_active(BR_OVERLAY) ) {
1748 common_flash_button_init();
1749 brief_turn_off_closeup_icon();
1752 // Check common keypresses
1753 common_check_keys(k);
1759 if ( Briefing->num_stages > 0 ) {
1761 // check for special keys
1765 case KEY_CTRLED | KEY_PAGEUP: {
1766 if (Closeup_icon->ship_class) {
1767 Closeup_icon->ship_class--;
1769 ship_info *sip = &Ship_info[Closeup_icon->ship_class];
1770 if (sip->modelnum < 0)
1771 sip->modelnum = model_load(sip->pof_file, NULL, NULL);
1773 mprintf(("Shiptype = %d (%s)\n", Closeup_icon->ship_class, sip->name));
1774 mprintf(("Modelnum = %d (%s)\n", sip->modelnum, sip->pof_file));
1775 brief_setup_closeup(Closeup_icon);
1781 case KEY_CTRLED | KEY_PAGEDOWN: {
1782 if (Closeup_icon->ship_class < Num_ship_types - 1) {
1783 Closeup_icon->ship_class++;
1785 ship_info *sip = &Ship_info[Closeup_icon->ship_class];
1786 if (sip->modelnum < 0)
1787 sip->modelnum = model_load(sip->pof_file, NULL, NULL);
1789 mprintf(("Shiptype = %d (%s)\n", Closeup_icon->ship_class, sip->name));
1790 mprintf(("Modelnum = %d (%s)\n", sip->modelnum, sip->pof_file));
1791 brief_setup_closeup(Closeup_icon);
1798 Closeup_cam_pos.z += 1;
1802 case KEY_A + KEY_SHIFTED:
1803 Closeup_cam_pos.z += 10;
1808 Closeup_cam_pos.z -= 1;
1812 case KEY_Z + KEY_SHIFTED:
1813 Closeup_cam_pos.z -= 10;
1818 Closeup_cam_pos.y += 1;
1822 case KEY_Y + KEY_SHIFTED:
1823 Closeup_cam_pos.y += 10;
1828 Closeup_cam_pos.y -= 1;
1832 case KEY_H + KEY_SHIFTED:
1833 Closeup_cam_pos.y -= 10;
1838 Closeup_zoom -= 0.1f;
1839 if ( Closeup_zoom < 0.1 )
1840 Closeup_zoom = 0.1f;
1844 case KEY_COMMA+KEY_SHIFTED:
1845 Closeup_zoom -= 0.5f;
1846 if ( Closeup_zoom < 0.1 )
1847 Closeup_zoom = 0.1f;
1852 Closeup_zoom += 0.1f;
1856 case KEY_PERIOD+KEY_SHIFTED:
1857 Closeup_zoom += 0.5f;
1861 case 1000: // need this to avoid warning about no case
1871 nprintf(("General","Camera pos: %.2f, %.2f %.2f // ", Closeup_cam_pos.x, Closeup_cam_pos.y, Closeup_cam_pos.z));
1872 nprintf(("General","Camera zoom: %.2f\n", Closeup_zoom));
1876 if ( brief_choice > -1 && snazzy_action == SNAZZY_OVER ) {
1877 Brief_mouse_up_flag = 0;
1882 common_check_buttons();
1883 // if ( Briefing->num_stages > 0 )
1884 brief_check_buttons();
1886 if ( brief_choice != -1 ) {
1887 Brief_mouse_up_flag = 0;
1892 common_render(frametime);
1894 if ( Current_brief_stage < (Num_brief_stages-1) ) {
1895 if ( !help_overlay_active(BR_OVERLAY) && brief_time_to_advance(Current_brief_stage, frametime) ) {
1896 brief_do_next_pressed(0);
1897 common_flash_button_init();
1898 Brief_last_auto_advance = timer_get_milliseconds();
1902 if ( !Background_playing ) {
1904 int check_jump_flag = 1;
1905 if ( Current_brief_stage != Last_brief_stage ) {
1907 // Check if we have a quick transition pending
1908 if ( Quick_transition_stage != -1 ) {
1909 Quick_transition_stage = -1;
1910 brief_reset_last_new_stage();
1912 check_jump_flag = 0;
1915 if ( check_jump_flag ) {
1916 if ( abs(Current_brief_stage - Last_brief_stage) > 1 ) {
1917 Quick_transition_stage = Current_brief_stage;
1918 Current_brief_stage = Last_brief_stage;
1919 Assert(Current_brief_stage >= 0);
1920 Start_fade_up_anim = 1;
1921 goto Transition_done;
1926 if ( Current_brief_stage > Last_brief_stage ) {
1927 if ( Briefing->stages[Last_brief_stage].flags & BS_FORWARD_CUT ) {
1928 Quick_transition_stage = Current_brief_stage;
1929 Current_brief_stage = Last_brief_stage;
1930 Assert(Current_brief_stage >= 0);
1931 Start_fade_up_anim = 1;
1932 goto Transition_done;
1934 time = Briefing->stages[Current_brief_stage].camera_time;
1938 if ( Briefing->stages[Last_brief_stage].flags & BS_BACKWARD_CUT ) {
1939 Quick_transition_stage = Current_brief_stage;
1940 Current_brief_stage = Last_brief_stage;
1941 Assert(Current_brief_stage >= 0);
1942 Start_fade_up_anim = 1;
1943 goto Transition_done;
1945 time = Briefing->stages[Last_brief_stage].camera_time;
1950 brief_voice_stop(Last_brief_stage);
1952 if ( Current_brief_stage < 0 ) {
1954 Current_brief_stage=0;
1957 // set the camera target
1958 brief_set_new_stage(&Briefing->stages[Current_brief_stage].camera_pos,
1959 &Briefing->stages[Current_brief_stage].camera_orient,
1960 time, Current_brief_stage);
1962 Brief_playing_fade_sound = 0;
1963 Last_brief_stage = Current_brief_stage;
1964 brief_reset_icons(Current_brief_stage);
1965 brief_update_closeup_icon(0);
1970 if ( Brief_mouse_up_flag && !Closeup_icon) {
1971 brief_check_for_anim();
1974 brief_render(frametime);
1975 brief_camera_move(frametime, Current_brief_stage);
1977 if (Closeup_icon && (Closeup_bitmap >= 0)) {
1978 // blit closeup background
1979 gr_set_bitmap(Closeup_bitmap);
1980 gr_bitmap(Closeup_coords[gr_screen.res][BRIEF_X_COORD], Closeup_coords[gr_screen.res][BRIEF_Y_COORD]);
1983 Brief_ui_window.draw();
1984 brief_redraw_pressed_buttons();
1985 common_render_selected_screen_button();
1988 brief_render_closeup(Closeup_icon->ship_class, frametime);
1991 // render some extra stuff in multiplayer
1992 if (Game_mode & GM_MULTIPLAYER) {
1993 // should render this last so that it overlaps all controls
1996 // render the status indicator for the voice system
1997 multi_common_voice_display_status();
1999 // blit the "ships/players" locked button
2000 // multi_ts_blit_locked_button();
2002 // maybe blit the multiplayer "locked" button
2003 // if its locked, everyone blits it as such
2004 if(multi_ts_is_locked()){
2005 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.draw_forced(2);
2007 // anyone who can't hit the button sees it off, otherwise
2009 if( ((Netgame.type_flags & NG_TYPE_TEAM) && !(Net_player->flags & NETINFO_FLAG_TEAM_CAPTAIN)) ||
2010 ((Netgame.type_flags & NG_TYPE_TEAM) && !(Net_player->flags & NETINFO_FLAG_GAME_HOST)) ){
2011 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.draw_forced(0);
2013 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.draw();
2019 // maybe flash a button if player hasn't done anything for a while
2020 brief_maybe_flash_button();
2022 // blit help overlay if active
2023 help_overlay_maybe_blit(BR_OVERLAY);
2027 // If the commit button was pressed, do the commit button actions. Done at the end of the
2028 // loop so there isn't a skip in the animation (since ship_create() can take a long time if
2029 // the ship model is not in memory
2030 if (Commit_pressed) {
2031 if (Game_mode & GM_MULTIPLAYER) {
2032 multi_ts_commit_pressed();
2041 // --------------------------------------------------------------------------------------
2042 // brief_unload_bitmaps()
2045 void brief_unload_bitmaps()
2047 if ( BriefingMaskBitmap != -1 ) {
2048 bm_unload(BriefingMaskBitmap);
2049 BriefingMaskBitmap = -1;
2052 if ( Brief_text_bitmap != -1 ) {
2053 bm_unload(Brief_text_bitmap);
2054 Brief_text_bitmap = -1;
2057 if(Brief_grid_bitmap != -1){
2058 bm_unload(Brief_grid_bitmap);
2059 Brief_grid_bitmap = -1;
2062 if ( Brief_multitext_bitmap != -1 ) {
2063 bm_unload(Brief_multitext_bitmap);
2064 Brief_multitext_bitmap = -1;
2067 if ( Brief_background_bitmap != -1 ) {
2068 bm_unload(Brief_background_bitmap);
2069 Brief_background_bitmap = -1;
2072 help_overlay_unload(BR_OVERLAY);
2075 // ------------------------------------------------------------------------------------
2081 if ( Brief_inited == FALSE ) {
2082 nprintf(("Warning","brief_close() returning without doing anything\n"));
2086 nprintf(("Alan", "Entering brief_close()\n"));
2088 ML_objectives_close();
2090 // unload the audio streams used for voice playback
2091 brief_voice_unload_all();
2094 hud_anim_release(&Fade_anim);
2097 // done mask bitmap, so unlock it
2098 bm_unlock(BriefingMaskBitmap);
2100 Brief_ui_window.destroy();
2102 // unload the bitmaps
2103 brief_unload_bitmaps();
2105 brief_common_close();
2107 Brief_inited = FALSE;
2110 void briefing_stop_music()
2112 if ( Briefing_music_handle != -1 ) {
2113 audiostream_close_file(Briefing_music_handle);
2114 Briefing_music_handle = -1;
2118 void briefing_load_music(char* fname)
2120 if ( Cmdline_freespace_no_music ) {
2124 if ( Briefing_music_handle != -1 )
2128 Briefing_music_handle = audiostream_open( fname, ASF_EVENTMUSIC );
2131 void briefing_start_music()
2133 if ( Briefing_music_handle != -1 ) {
2134 if ( !audiostream_is_playing(Briefing_music_handle) )
2135 audiostream_play(Briefing_music_handle, Master_event_music_volume);
2138 nprintf(("Warning", "No music file exists to play music at this briefing!\n"));
2142 void brief_stop_voices()
2144 brief_voice_stop(Current_brief_stage);
2147 void brief_maybe_blit_scene_cut(float frametime)
2149 if ( Start_fade_up_anim ) {
2152 Fade_anim.time_elapsed = 0.0f;
2153 Start_fade_up_anim = 0;
2154 Start_fade_down_anim = 1;
2155 Current_brief_stage = Quick_transition_stage;
2157 if ( Current_brief_stage < 0 ) {
2158 brief_transition_reset();
2159 Current_brief_stage = Last_brief_stage;
2161 goto Fade_down_anim_start;
2165 Fade_anim.time_elapsed += frametime;
2167 if ( !Brief_playing_fade_sound ) {
2168 gamesnd_play_iface(SND_BRIEFING_STATIC);
2169 Brief_playing_fade_sound = 1;
2172 if ( Fade_anim.time_elapsed > Fade_anim.total_time ) {
2173 Fade_anim.time_elapsed = 0.0f;
2174 Start_fade_up_anim = 0;
2175 Start_fade_down_anim = 1;
2176 Current_brief_stage = Quick_transition_stage;
2178 if ( Current_brief_stage < 0 ) {
2179 brief_transition_reset();
2180 Current_brief_stage = Last_brief_stage;
2183 Assert(Current_brief_stage >= 0);
2184 goto Fade_down_anim_start;
2187 // draw the correct frame of animation
2188 framenum = fl2i( (Fade_anim.time_elapsed * Fade_anim.num_frames) / Fade_anim.total_time );
2191 if ( framenum >= Fade_anim.num_frames )
2192 framenum = Fade_anim.num_frames-1;
2194 // Blit the bitmap for this frame
2195 gr_set_bitmap(Fade_anim.first_frame + framenum);
2196 gr_bitmap(Fade_anim.sx, Fade_anim.sy);
2201 Fade_down_anim_start:
2202 if ( Start_fade_down_anim ) {
2205 Fade_anim.time_elapsed = 0.0f;
2206 Start_fade_up_anim = 0;
2207 Start_fade_down_anim = 0;
2213 Fade_anim.time_elapsed += frametime;
2215 if ( Fade_anim.time_elapsed > Fade_anim.total_time ) {
2216 Fade_anim.time_elapsed = 0.0f;
2217 Start_fade_up_anim = 0;
2218 Start_fade_down_anim = 0;
2222 // draw the correct frame of animation
2223 framenum = fl2i( (Fade_anim.time_elapsed * Fade_anim.num_frames) / Fade_anim.total_time );
2226 if ( framenum >= Fade_anim.num_frames )
2227 framenum = Fade_anim.num_frames-1;
2229 // Blit the bitmap for this frame
2230 gr_set_bitmap(Fade_anim.first_frame + (Fade_anim.num_frames-1) - framenum);
2231 gr_bitmap(Fade_anim.sx, Fade_anim.sy);
2237 void brief_transition_reset()
2239 Quick_transition_stage = -1;
2240 Start_fade_up_anim = 0;
2241 Start_fade_down_anim = 0;
2242 Fade_anim.time_elapsed = 0.0f;
2245 // return 1 if this mission only allow players to use the briefing (and not ship or
2246 // weapon loadout). Otherwise return 0.
2247 int brief_only_allow_briefing()
2249 if ( The_mission.game_type & MISSION_TYPE_TRAINING ) {
2253 if ( The_mission.scramble || The_mission.red_alert) {