2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/MissionUI/MissionBrief.cpp $
15 * C module that contains code to display the mission briefing to the player
18 * Revision 1.13 2005/10/03 11:25:42 taylor
19 * be sure to properly clean out old briefing entries when compacting
21 * Revision 1.12 2005/10/01 22:04:58 taylor
22 * fix FS1 (de)briefing voices, the directory names are different in FS1
23 * hard code the table values so that the fs1.vp file isn't needed
24 * hard code a mission fix for sm2-08a since a have no idea how to fix it otherwise
25 * generally cleanup some FS1 code
26 * fix volume sliders in the options screen that never went all the way up
28 * Revision 1.11 2005/08/12 08:58:41 taylor
29 * fix the strange mouse click issues on briefing, ship select and weapon select screens
31 * Revision 1.10 2005/03/29 02:18:47 taylor
32 * Various 64-bit platform fixes
33 * Fix compiler errors with MAKE_FS1 and fix gr_set_bitmap() too
34 * Make sure that turrets can fire at asteroids for FS1 (needed for a couple missions)
35 * Streaming audio support (big thanks to Pierre Willenbrock!!)
36 * Removed dependance on strings.tbl for FS1 since we don't actually need it now
38 * Revision 1.9 2004/09/20 01:31:44 theoddone33
41 * Revision 1.8 2004/07/04 11:31:43 taylor
42 * amd64 support, compiler warning fixes, don't use software rendering
44 * Revision 1.7 2003/05/25 02:30:43 taylor
47 * Revision 1.6 2003/01/30 19:55:33 relnev
48 * remove second bmpman.h include (Taylor Richards)
50 * Revision 1.5 2002/06/17 06:33:09 relnev
51 * ryan's struct patch for gcc 2.95
53 * Revision 1.4 2002/06/09 04:41:22 relnev
54 * added copyright header
56 * Revision 1.3 2002/06/02 04:26:34 relnev
59 * Revision 1.2 2002/05/07 03:16:46 theoddone33
60 * The Great Newline Fix
62 * Revision 1.1.1.1 2002/05/03 03:28:10 root
66 * 48 10/14/99 2:51p Jefff
69 * 47 10/13/99 3:23p Jefff
70 * fixed unnumbered XSTRs
72 * 46 9/12/99 8:09p Dave
73 * Fixed problem where skip-training button would cause mission messages
74 * not to get paged out for the current mission.
76 * 45 9/09/99 3:40p Jefff
77 * no exit loop outisde of campaign mode
79 * 44 9/07/99 6:53p Jefff
80 * functionality to break out of a loop
82 * 43 9/06/99 6:38p Dave
83 * Improved CD detection code.
85 * 42 9/03/99 10:57a Jefff
88 * 41 8/30/99 5:30p Jefff
89 * fixed "more" being cut off in d3d
91 * 40 8/30/99 10:29a Jefff
92 * added autocenter flag to closup rendering
94 * 39 8/19/99 11:33a Dave
97 * 38 8/19/99 10:59a Dave
98 * Packet loss detection.
100 * 37 8/16/99 4:05p Dave
101 * Big honking checkin.
103 * 36 8/16/99 9:48a Jefff
104 * all clicks on briefing icons should now register
106 * 35 8/10/99 7:29p Jefff
107 * added mission title to briefing screen
109 * 34 8/03/99 1:34a Andsager
110 * fix skip training mission (again)
112 * 33 8/02/99 12:01p Jefff
113 * fixed "skip training" text pos
115 * 32 7/30/99 5:42p Jasenw
116 * Fixed coords for skip training button.
118 * 31 7/29/99 10:50p Dave
119 * Oops. Accidentally blew away some interface text changes.
121 * 30 7/29/99 10:48p Dave
123 * 29 7/29/99 3:05p Andsager
124 * Add skip training text. and properly skip.
126 * 28 7/24/99 6:07p Jefff
127 * Added "lock" text to multiplayer lock button
129 * 27 7/21/99 10:51a Jefff
130 * added "more" indicator to briefing text box
132 * 26 7/19/99 3:01p Dave
133 * Fixed icons. Added single transport icon.
135 * 25 7/18/99 5:20p Dave
136 * Jump node icon. Fixed debris fogging. Framerate warning stuff.
138 * 24 7/16/99 1:49p Dave
139 * 8 bit aabitmaps. yay.
141 * 23 7/15/99 9:20a Andsager
142 * FS2_DEMO initial checkin
144 * 22 7/09/99 5:54p Dave
145 * Seperated cruiser types into individual types. Added tons of new
146 * briefing icons. Campaign screen.
148 * 21 6/29/99 7:39p Dave
149 * Lots of small bug fixes.
151 * 20 6/11/99 11:13a Dave
152 * last minute changes before press tour build.
154 * 19 6/04/99 1:18p Dave
155 * Fixed briefing model rendering problems. Made show background option in
156 * fred toggle nebula rendering.
158 * 18 5/07/99 10:34a Andsager
159 * Make red alert work in FS2
161 * 17 4/23/99 12:01p Johnson
162 * Added SIF_HUGE_SHIP
164 * 16 3/25/99 2:45p Neilk
167 * 15 2/11/99 3:08p Dave
168 * PXO refresh button. Very preliminary squad war support.
170 * 14 2/05/99 7:19p Neilk
171 * Removed black part from mission screen, fixed info text coords
173 * 13 2/02/99 4:35p Neilk
174 * fixed coordinate problem where primary goals was on top of interface in
177 * 12 2/01/99 5:55p Dave
178 * Removed the idea of explicit bitmaps for buttons. Fixed text
179 * highlighting for disabled gadgets.
181 * 11 1/30/99 7:32p Neilk
182 * Fixed coords problems for mission briefing screens
184 * 10 1/30/99 5:08p Dave
185 * More new hi-res stuff.Support for nice D3D textures.
187 * 9 1/30/99 1:29a Dave
188 * Fixed nebula thumbnail problem. Full support for 1024x768 choose pilot
189 * screen. Fixed beam weapon death messages.
191 * 8 1/29/99 4:17p Dave
192 * New interface screens.
194 * 7 1/13/99 7:19p Neilk
195 * Converted Mission Brief, Barracks, Synch to high res support
197 * 6 12/18/98 1:13a Dave
198 * Rough 1024x768 support for Direct3D. Proper detection and usage through
201 * 5 11/30/98 1:07p Dave
202 * 16 bit conversion, first run.
204 * 4 11/20/98 4:08p Dave
205 * Fixed flak effect in multiplayer.
207 * 3 10/13/98 9:28a Dave
208 * Started neatening up freespace.h. Many variables renamed and
209 * reorganized. Added AlphaColors.[h,cpp]
211 * 2 10/07/98 10:53a Dave
214 * 1 10/07/98 10:49a Dave
216 * 114 9/17/98 3:08p Dave
217 * PXO to non-pxo game warning popup. Player icon stuff in create and join
218 * game screens. Upped server count refresh time in PXO to 35 secs (from
221 * 113 6/19/98 3:52p Lawrance
222 * Don't use large text in popup, since it is missing large foreign chars
224 * 112 6/09/98 5:17p Lawrance
225 * French/German localization
227 * 111 6/09/98 10:31a Hoffoss
228 * Created index numbers for all xstr() references. Any new xstr() stuff
229 * added from here on out should be added to the end if the list. The
230 * current list count can be found in FreeSpace.cpp (search for
233 * 110 6/01/98 11:43a John
234 * JAS & MK: Classified all strings for localization.
236 * 109 5/22/98 10:44a Lawrance
237 * put in case label to suppress warning
239 * 108 5/19/98 11:35p Lawrance
240 * Play sound for briefing control button presses
242 * 107 5/19/98 8:47p Lawrance
243 * Set proper distance for jump nodes
245 * 106 5/19/98 8:35p Dave
246 * Revamp PXO channel listing system. Send campaign goals/events to
247 * clients for evaluation. Made lock button pressable on all screens.
249 * 105 5/12/98 2:16p Hoffoss
250 * Added debug code to switch models of closeup icon to more easily check
251 * positions and zooms.
253 * 104 5/06/98 11:50p Lawrance
254 * Clean up help overlay code for loadout screens
256 * 103 5/06/98 8:03p Allender
257 * AL: only free pointers in brief_compact_stages if non-null
259 * 102 5/05/98 4:48p Lawrance
260 * Fix bug with launching closeup icon when pause button is pressed
262 * 101 4/29/98 1:45p Lawrance
263 * Print out mission filename if debug build, or if INTERPLAY QA defined
265 * 100 4/29/98 12:15a Lawrance
266 * reset demo trailer timer when briefing moves to a new stage
268 * 98 4/25/98 11:55p Lawrance
269 * fix bug with the auto-advance button
271 * 97 4/25/98 3:49p Lawrance
272 * Save briefing auto-advance pref
274 * 96 4/25/98 12:00p Lawrance
275 * disable advance keypress for 1/2 second after autoadvance
277 * 95 4/22/98 7:24p Dave
278 * Made sure the "player/ships" locked button for multiplayer appears on
279 * all briefing screens.
281 * 94 4/20/98 3:53p Lawrance
282 * Fix various bugs with auto-advancing through briefings.
284 * 93 4/19/98 12:11p Lawrance
285 * add new art for pause button in the briefing
287 * 92 4/17/98 10:39p Andsager
288 * AL: Fix bug with auto-advance of briefing stages.
290 * 91 4/16/98 8:05p Lawrance
291 * Don't show closeup icon for planets
293 * 90 4/15/98 5:17p Lawrance
294 * fix bug with skip training
300 #include "freespace.h"
301 #include "missionload.h"
302 #include "missionscreencommon.h"
303 #include "missionshipchoice.h"
304 #include "missionparse.h"
305 #include "missiongoals.h"
306 #include "gamesequence.h"
315 #include "linklist.h"
320 #include "audiostr.h"
322 #include "eventmusic.h"
323 #include "missioncampaign.h"
326 #include "snazzyui.h"
328 #include "missionbrief.h"
329 #include "missionbriefcommon.h"
330 #include "missiongrid.h"
331 #include "multimsgs.h"
333 #include "contexthelp.h"
335 #include "multiteamselect.h"
337 #include "asteroid.h"
340 #include "alphacolors.h"
342 #include "missionmessage.h"
345 #define OBJECTIVES_X 65
346 #define OBJECTIVES_Y 137
347 #define OBJECTIVES_W 508
348 #define OBJECTIVES_H 233
351 static int Brief_goals_coords[GR_NUM_RESOLUTIONS][4] = {
356 65,152,508,211 // GR_640
360 104,243,813,332 // GR_1024
364 static int Current_brief_stage; // what stage of the briefing we're on
365 static int Last_brief_stage;
366 static int Num_brief_stages;
367 static int Brief_multiplayer = FALSE;
369 static int Brief_last_auto_advance = 0; // timestamp of last auto-advance
371 // for managing the scene cut transition
372 static int Quick_transition_stage;
373 static int Start_fade_up_anim, Start_fade_down_anim;
374 static int Brief_playing_fade_sound;
377 int Briefing_music_handle = -1;
378 int Briefing_music_begin_timestamp = 0;
380 // --------------------------------------------------------------------------------------
381 // Module scope globals
382 // --------------------------------------------------------------------------------------
384 static MENU_REGION Briefing_select_region[NUM_BREIFING_REGIONS];
385 static int Num_briefing_regions;
387 // For closeup display
388 #define ONE_REV_TIME 6 // time (sec) for one revolution
389 #define MAX_ANG_CHG 0.15f
391 static int Closeup_coords[GR_NUM_RESOLUTIONS][4] = {
393 203, 151, 200, 213 // GR_640
396 325, 241, 200, 213 // GR_1024
400 static int Brief_infobox_coords[GR_NUM_RESOLUTIONS][2] = {
413 static const char *Brief_infobox_filename[GR_NUM_RESOLUTIONS] = {
418 static const char *Brief_filename[GR_NUM_RESOLUTIONS] = {
423 static const char *Brief_multi_filename[GR_NUM_RESOLUTIONS] = {
425 "Brief", // use the standard bitmap and slap the chatbox on later
432 static const char *Brief_mask_filename[GR_NUM_RESOLUTIONS] = {
437 static const char *Brief_multi_mask_filename[GR_NUM_RESOLUTIONS] = {
443 static const char *Brief_win_filename[GR_NUM_RESOLUTIONS] = {
453 // coordinate inidices
454 #define BRIEF_X_COORD 0
455 #define BRIEF_Y_COORD 1
456 #define BRIEF_W_COORD 2
457 #define BRIEF_H_COORD 3
459 //static int Closeup_region[4] = {220,132,420,269};
460 int Closeup_region[GR_NUM_RESOLUTIONS][4] = {
469 const char *Closeup_background_filename[GR_NUM_RESOLUTIONS] = {
470 NOX("BriefPop"), // GR_640
471 NOX("2_BriefPop") // GR_1024
474 const char *Closeup_button_filename[GR_NUM_RESOLUTIONS] = {
475 NOX("BPB_00"), // GR_640
476 NOX("2_BPB_00"), // GR_1024
479 int Closeup_button_hotspot = 14;
481 //static int Closeup_button_coords[2] = {CLOSEUP_X+164,CLOSEUP_Y+227};
482 int Closeup_button_coords[GR_NUM_RESOLUTIONS][2] = {
486 { 374, 316 }, // GR_640
488 { 599, 506 } // GR_1024
491 UI_BUTTON Closeup_close_button;
492 int Closeup_bitmap=-1;
493 int Closeup_one_revolution_time=ONE_REV_TIME;
495 brief_icon *Closeup_icon;
496 angles Closeup_angles;
497 matrix Closeup_orient;
499 int Closeup_font_height;
500 int Closeup_x1, Closeup_y1;
502 // used for the 3d view of a closeup ship
504 vector Closeup_cam_pos;
506 // Mask bitmap pointer and Mask bitmap_id
507 bitmap* BriefingMaskPtr; // bitmap pointer to the briefing select mask bitmap
508 ubyte* BriefingMaskData; // pointer to actual bitmap data
509 int Briefing_mask_w, Briefing_mask_h;
510 int BriefingMaskBitmap; // bitmap id of the briefing mask bitmap
511 int Brief_inited = FALSE;
513 // --------------------------------------------------------------------------------------
514 // Briefing specific UI
515 // --------------------------------------------------------------------------------------
516 #define BRIEF_LAST_STAGE_MASK 7
517 #define BRIEF_NEXT_STAGE_MASK 8
518 #define BRIEF_PREV_STAGE_MASK 9
519 #define BRIEF_FIRST_STAGE_MASK 10
520 #define BRIEF_TEXT_SCROLL_UP_MASK 11
521 #define BRIEF_TEXT_SCROLL_DOWN_MASK 12
522 #define BRIEF_SKIP_TRAINING_MASK 15
523 #define BRIEF_PAUSE_MASK 16
526 static const char *Brief_mask_single[GR_NUM_RESOLUTIONS] = {
528 "2_brief-m" // GR_1024
531 static const char *Brief_mask_multi[GR_NUM_RESOLUTIONS] = {
532 "briefmulti-m", // GR_640
533 "2_briefmulti-m" // GR_1024
537 struct brief_buttons {
538 const char *filename;
543 UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
545 brief_buttons(const 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) {}
548 int Brief_grid_bitmap = -1;
549 int Brief_text_bitmap = -1;
551 int Brief_multitext_bitmap = -1;
552 int Brief_background_bitmap =-1;
555 static int MapWin01 = -1;
556 static int MapWin02 = -1;
557 static int MapWin03 = -1;
558 static int MapWin04 = -1;
561 UI_WINDOW Brief_ui_window;
563 // Briefing specific buttons
564 #define NUM_BRIEF_BUTTONS 10
566 brief_buttons Brief_buttons[GR_NUM_RESOLUTIONS][NUM_BRIEF_BUTTONS] = {
569 brief_buttons("BRB_08", 356, 351, -1, -1, 8), // vcr - fastforward
570 brief_buttons("BRB_09", 331, 351, -1, -1, 9), // vcr - play forwards
571 brief_buttons("BRB_10", 277, 351, -1, -1, 10), // vcr - play backwards
572 brief_buttons("BRB_11", 253, 351, -1, -1, 11), // vcr - reverse
573 brief_buttons("BRB_12", 0, 400, -1, -1, 12), // scroll up
574 brief_buttons("BRB_13", 0, 442, -1, -1, 13), // scroll down
575 brief_buttons("BRB_15", 562, 0, -1, -1, 15), // skip training
576 brief_buttons("BRB_16", 304, 351, -1, -1, 16), // vcr - pause
577 brief_buttons("TSB_34", 601, 344, -1, -1, 50), // multi lock
578 brief_buttons("BRB_15", 562, 0, -1, -1, 15) // exit loop
580 brief_buttons("BRB_08", 110, 116, 117, 157, 8),
581 brief_buttons("BRB_09", 84, 116, 117, 157, 9),
582 brief_buttons("BRB_10", 29, 116, 117, 157, 10),
583 brief_buttons("BRB_11", 4, 116, 117, 157, 11),
584 brief_buttons("BRB_12", 0, 405, 117, 157, 12),
585 brief_buttons("BRB_13", 0, 447, 117, 157, 13),
586 brief_buttons("BRB_15", 562, 0, 117, 157, 15), // skip training
587 brief_buttons("BRB_16", 56, 116, 117, 157, 16),
588 brief_buttons("TSB_34", 603, 374, 117, 157, 34),
589 brief_buttons("BRB_15", 562, 0, 117, 157, 15) // exit loop
593 brief_buttons("2_BRB_08", 175, 187, 117, 157, 8),
594 brief_buttons("2_BRB_09", 135, 187, 117, 157, 9),
595 brief_buttons("2_BRB_10", 47, 187, 117, 157, 10),
596 brief_buttons("2_BRB_11", 8, 187, 117, 157, 11),
597 brief_buttons("2_BRB_12", 0, 649, 117, 157, 12),
598 brief_buttons("2_BRB_13", 0, 716, 117, 157, 13),
599 brief_buttons("2_BRB_15", 900, 0, 117, 157, 15), // skip training
600 brief_buttons("2_BRB_16", 91, 187, 117, 157, 16),
601 brief_buttons("2_TSB_34", 966, 599, 117, 157, 34),
602 brief_buttons("2_BRB_15", 900, 0, 117, 157, 15) // exit loop
608 #define BRIEF_SELECT_NUM_TEXT 3
610 UI_XSTR Brief_select_text[GR_NUM_RESOLUTIONS][BRIEF_SELECT_NUM_TEXT] = {
612 { "Lock", 1270, 602, 364, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[0][BRIEF_BUTTON_MULTI_LOCK].button },
613 { "Skip Training", 1442, 467, 7, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[0][BRIEF_BUTTON_SKIP_TRAINING].button },
614 { "Exit Loop", 1477, 490, 7, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[0][BRIEF_BUTTON_EXIT_LOOP].button }
617 { "Lock", 1270, 964, 584, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[1][BRIEF_BUTTON_MULTI_LOCK].button },
618 { "Skip Training", 1442, 805, 12, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[1][BRIEF_BUTTON_SKIP_TRAINING].button },
619 { "Exit Loop", 1477, 830, 12, UI_XSTR_COLOR_GREEN, -1, &Brief_buttons[1][BRIEF_BUTTON_EXIT_LOOP].button }
624 // coordinates for briefing title -- the x value is for the RIGHT side of the text
625 static int Title_coords[GR_NUM_RESOLUTIONS][2] = {
629 {575, 117}, // GR_640
631 {918, 194} // GR_1024
634 // coordinates for briefing title in multiplayer briefings -- the x value is for the LEFT side of the text
635 // third coord is max width of area for it to fit into (it is force fit there)
636 static int Title_coords_multi[GR_NUM_RESOLUTIONS][3] = {
640 {1, 105, 190}, // GR_640
642 {1, 174, 304} // GR_1024
645 // briefing line widths
646 int Brief_max_line_width[GR_NUM_RESOLUTIONS] = {
647 MAX_BRIEF_LINE_W_640, MAX_BRIEF_LINE_W_1024
650 // --------------------------------------------------------------------------------------
651 // Forward declarations
652 // --------------------------------------------------------------------------------------
653 int brief_setup_closeup(brief_icon *bi);
654 void brief_maybe_blit_scene_cut(float frametime);
655 void brief_transition_reset();
657 const char *brief_tooltip_handler(const char *str)
659 if (!SDL_strcasecmp(str, NOX("@close"))) {
661 return XSTR( "Close", 428);
667 // brief_skip_training_pressed()
669 // called when the skip training button on the briefing screen is hit. When this happens,
670 // do a popup, then move to the next mission in the campaign.
671 void brief_skip_training_pressed()
675 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));
677 // val is 0 when we hit no (first on the list)
678 // AL: also, -1 is returned when ESC is hit
683 // page out mission messages
684 message_mission_shutdown();
686 if ( !(Game_mode & GM_CAMPAIGN_MODE) ){
687 gameseq_post_event( GS_EVENT_MAIN_MENU );
690 // tricky part. Need to move to the next mission in the campaign.
691 mission_goal_mark_objectives_complete();
692 mission_goal_fail_incomplete();
693 mission_campaign_store_goals_and_events();
695 mission_campaign_eval_next_mission();
696 mission_campaign_mission_over();
698 gameseq_post_event( GS_EVENT_START_GAME );
701 #if defined(FS2_DEMO) || defined(FS1_DEMO)
702 extern void demo_reset_trailer_timer();
704 // --------------------------------------------------------------------------------------
705 // brief_do_next_pressed()
708 void brief_do_next_pressed(int play_sound)
711 now = timer_get_milliseconds();
713 if ( (now - Brief_last_auto_advance) < 500 ) {
717 #if defined(FS2_DEMO) || defined(FS1_DEMO)
718 demo_reset_trailer_timer();
721 Current_brief_stage++;
722 if ( Current_brief_stage >= Num_brief_stages ) {
723 Current_brief_stage = Num_brief_stages - 1;
724 gamesnd_play_iface(SND_GENERAL_FAIL);
725 if ( Quick_transition_stage != -1 )
726 brief_transition_reset();
729 gamesnd_play_iface(SND_BRIEF_STAGE_CHG);
733 SDL_assert(Current_brief_stage >= 0);
736 // --------------------------------------------------------------------------------------
737 // brief_do_prev_pressed()
740 void brief_do_prev_pressed()
742 Current_brief_stage--;
743 if ( Current_brief_stage < 0 ) {
744 Current_brief_stage = 0;
745 gamesnd_play_iface(SND_GENERAL_FAIL);
746 if ( Quick_transition_stage != -1 )
747 brief_transition_reset();
749 gamesnd_play_iface(SND_BRIEF_STAGE_CHG);
751 SDL_assert(Current_brief_stage >= 0);
755 // --------------------------------------------------------------------------------------
756 // brief_do_start_pressed()
759 void brief_do_start_pressed()
761 if ( Current_brief_stage != 0 ) {
762 gamesnd_play_iface(SND_BRIEF_STAGE_CHG);
763 Current_brief_stage = 0;
764 if ( Quick_transition_stage != -1 )
765 brief_transition_reset();
767 gamesnd_play_iface(SND_GENERAL_FAIL);
769 SDL_assert(Current_brief_stage >= 0);
772 // --------------------------------------------------------------------------------------
773 // brief_do_end_pressed()
776 void brief_do_end_pressed()
778 if ( Current_brief_stage != Num_brief_stages - 1 ) {
779 gamesnd_play_iface(SND_BRIEF_STAGE_CHG);
780 Current_brief_stage = Num_brief_stages - 1;
781 if ( Quick_transition_stage != -1 )
782 brief_transition_reset();
785 gamesnd_play_iface(SND_GENERAL_FAIL);
787 SDL_assert(Current_brief_stage >= 0);
791 void brief_scroll_up_text()
793 Top_brief_text_line--;
794 if ( Top_brief_text_line < 0 ) {
795 Top_brief_text_line = 0;
796 gamesnd_play_iface(SND_GENERAL_FAIL);
798 gamesnd_play_iface(SND_SCROLL);
802 void brief_scroll_down_text()
804 Top_brief_text_line++;
805 if ( (Num_brief_text_lines[0] - Top_brief_text_line) < Brief_text_max_lines[gr_screen.res]) {
806 Top_brief_text_line--;
807 gamesnd_play_iface(SND_GENERAL_FAIL);
809 gamesnd_play_iface(SND_SCROLL);
814 // handles the exit loop option
815 void brief_exit_loop_pressed()
817 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));
819 // bail if esc hit or no clicked
824 // handle the details
825 // this also posts the start game event
826 mission_campaign_exit_loop();
830 // -------------------------------------------------------------------------------------
831 // brief_select_button_do() do the button action for the specified pressed button
833 void brief_button_do(int i)
836 case BRIEF_BUTTON_LAST_STAGE:
837 brief_do_end_pressed();
840 case BRIEF_BUTTON_NEXT_STAGE:
841 brief_do_next_pressed(1);
844 case BRIEF_BUTTON_PREV_STAGE:
845 brief_do_prev_pressed();
848 case BRIEF_BUTTON_FIRST_STAGE:
849 brief_do_start_pressed();
852 case BRIEF_BUTTON_SCROLL_UP:
853 brief_scroll_up_text();
856 case BRIEF_BUTTON_SCROLL_DOWN:
857 brief_scroll_down_text();
860 case BRIEF_BUTTON_PAUSE:
861 gamesnd_play_iface(SND_USER_SELECT);
862 Player->auto_advance ^= 1;
865 case BRIEF_BUTTON_SKIP_TRAINING:
866 brief_skip_training_pressed();
869 case BRIEF_BUTTON_EXIT_LOOP:
870 brief_exit_loop_pressed();
873 case BRIEF_BUTTON_MULTI_LOCK:
874 SDL_assert(Game_mode & GM_MULTIPLAYER);
875 // the "lock" button has been pressed
876 multi_ts_lock_pressed();
878 // disable the button if it is now locked
879 if(multi_ts_is_locked()){
880 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.disable();
886 // -------------------------------------------------------------------
887 // brief_check_buttons()
889 // Iterate through the briefing buttons, checking if they are pressed
891 void brief_check_buttons()
896 for (i=0; i<NUM_BRIEF_BUTTONS; i++) {
897 b = &Brief_buttons[gr_screen.res][i].button;
898 if ( b->pressed() ) {
899 common_flash_button_init();
904 if (Closeup_close_button.pressed()) {
905 brief_turn_off_closeup_icon();
909 // -------------------------------------------------------------------
910 // brief_redraw_pressed_buttons()
912 // Redraw any briefing buttons that are pressed down. This function is needed
913 // since we sometimes need to draw pressed buttons last to ensure the entire
914 // button gets drawn (and not overlapped by other buttons)
916 void brief_redraw_pressed_buttons()
921 common_redraw_pressed_buttons();
923 for ( i = 0; i < NUM_BRIEF_BUTTONS; i++ ) {
924 b = &Brief_buttons[gr_screen.res][i].button;
925 if ( b->button_down() ) {
930 if ( !Player->auto_advance ) {
931 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PAUSE].button.draw_forced(2);
935 void brief_buttons_init()
940 //if ( Briefing->num_stages <= 0 )
943 for ( i = 0; i < NUM_BRIEF_BUTTONS; i++ ) {
944 b = &Brief_buttons[gr_screen.res][i].button;
945 b->create( &Brief_ui_window, "", Brief_buttons[gr_screen.res][i].x, Brief_buttons[gr_screen.res][i].y, 60, 30, 0, 1 );
946 // set up callback for when a mouse first goes over a button
947 b->set_highlight_action( common_play_highlight_sound );
949 if ((i == BRIEF_BUTTON_SKIP_TRAINING) || (i == BRIEF_BUTTON_EXIT_LOOP)) {
950 b->set_bmaps(Brief_buttons[gr_screen.res][i].filename, 3, 0);
952 b->set_bmaps(Brief_buttons[gr_screen.res][i].filename);
954 b->link_hotspot(Brief_buttons[gr_screen.res][i].hotspot);
959 for(i=0; i<BRIEF_SELECT_NUM_TEXT; i++) {
960 Brief_ui_window.add_XSTR(&Brief_select_text[gr_screen.res][i]);
964 // Hide the 'skip training' button by default. Only enable and unhide if we are playing a training
966 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SKIP_TRAINING].button.disable();
967 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SKIP_TRAINING].button.hide();
968 if ( (Game_mode & GM_NORMAL) && (The_mission.game_type & MISSION_TYPE_TRAINING) ) {
969 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SKIP_TRAINING].button.enable();
970 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SKIP_TRAINING].button.unhide();
973 // Hide the 'exit loop' button by default. Only enable and unhide if we are playing a loop
975 Brief_buttons[gr_screen.res][BRIEF_BUTTON_EXIT_LOOP].button.disable();
976 Brief_buttons[gr_screen.res][BRIEF_BUTTON_EXIT_LOOP].button.hide();
977 if ( (Game_mode & GM_NORMAL) && (Campaign.loop_enabled) && (Game_mode & GM_CAMPAIGN_MODE) ) {
978 Brief_buttons[gr_screen.res][BRIEF_BUTTON_EXIT_LOOP].button.enable();
979 Brief_buttons[gr_screen.res][BRIEF_BUTTON_EXIT_LOOP].button.unhide();
982 // maybe disable the multi-lock button
983 if(!(Game_mode & GM_MULTIPLAYER)){
984 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.hide();
985 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.disable();
987 // if we're not the host of the game (or a tema captain in team vs. team mode), disable the lock button
988 if(Netgame.type_flags & NG_TYPE_TEAM){
989 if(!(Net_player->flags & NETINFO_FLAG_TEAM_CAPTAIN)){
990 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.disable();
993 if(!(Net_player->flags & NETINFO_FLAG_GAME_HOST)){
994 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.disable();
999 // create close button for closeup popup
1000 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 );
1001 Closeup_close_button.set_highlight_action( common_play_highlight_sound );
1002 Closeup_close_button.set_bmaps(Closeup_button_filename[gr_screen.res]);
1003 Closeup_close_button.link_hotspot(Closeup_button_hotspot);
1005 // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed
1006 Brief_buttons[gr_screen.res][BRIEF_BUTTON_LAST_STAGE].button.set_hotkey(KEY_SHIFTED|SDLK_RIGHT);
1007 Brief_buttons[gr_screen.res][BRIEF_BUTTON_NEXT_STAGE].button.set_hotkey(SDLK_RIGHT);
1008 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PREV_STAGE].button.set_hotkey(SDLK_LEFT);
1009 Brief_buttons[gr_screen.res][BRIEF_BUTTON_FIRST_STAGE].button.set_hotkey(KEY_SHIFTED|SDLK_LEFT);
1010 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_UP].button.set_hotkey(SDLK_UP);
1011 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_DOWN].button.set_hotkey(SDLK_DOWN);
1013 Closeup_close_button.disable();
1014 Closeup_close_button.hide();
1016 // if we have no briefing stages, hide and disable briefing buttons
1017 if(Num_brief_stages <= 0){
1018 Brief_buttons[gr_screen.res][BRIEF_BUTTON_LAST_STAGE].button.disable();
1019 Brief_buttons[gr_screen.res][BRIEF_BUTTON_LAST_STAGE].button.hide();
1020 Brief_buttons[gr_screen.res][BRIEF_BUTTON_NEXT_STAGE].button.disable();
1021 Brief_buttons[gr_screen.res][BRIEF_BUTTON_NEXT_STAGE].button.hide();
1022 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PREV_STAGE].button.disable();
1023 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PREV_STAGE].button.hide();
1024 Brief_buttons[gr_screen.res][BRIEF_BUTTON_FIRST_STAGE].button.disable();
1025 Brief_buttons[gr_screen.res][BRIEF_BUTTON_FIRST_STAGE].button.hide();
1026 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_UP].button.disable();
1027 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_UP].button.hide();
1028 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_DOWN].button.disable();
1029 Brief_buttons[gr_screen.res][BRIEF_BUTTON_SCROLL_DOWN].button.hide();
1030 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PAUSE].button.disable();
1031 Brief_buttons[gr_screen.res][BRIEF_BUTTON_PAUSE].button.hide();
1035 // --------------------------------------------------------------------------------------
1036 // brief_get_closeup_icon()
1039 brief_icon *brief_get_closeup_icon()
1041 return Closeup_icon;
1044 // stop showing the closeup view of an icon
1045 void brief_turn_off_closeup_icon()
1048 if ( Closeup_icon != NULL ) {
1049 gamesnd_play_iface(SND_BRIEF_ICON_SELECT);
1050 Closeup_icon = NULL;
1051 Closeup_close_button.disable();
1052 Closeup_close_button.hide();
1056 // --------------------------------------------------------------------------------------
1057 // brief_load_bitmaps()
1060 void brief_load_bitmaps()
1062 Brief_text_bitmap = bm_load(Brief_infobox_filename[gr_screen.res]);
1063 Brief_grid_bitmap = bm_load(Brief_win_filename[gr_screen.res]);
1065 if ( Closeup_bitmap == -1 ) {
1066 Closeup_bitmap = bm_load(Closeup_background_filename[gr_screen.res]);
1070 MapWin01 = bm_load(NOX("MapWin01"));
1071 MapWin02 = bm_load(NOX("MapWin02"));
1072 MapWin03 = bm_load(NOX("MapWin03"));
1073 MapWin04 = bm_load(NOX("MapWin04"));
1077 // --------------------------------------------------------------------------------------
1081 void brief_ui_init()
1083 if(Game_mode & GM_MULTIPLAYER) {
1084 Brief_background_bitmap = bm_load(Brief_multi_filename[gr_screen.res]);
1086 Brief_background_bitmap = bm_load(Brief_filename[gr_screen.res]);
1089 if ( Num_brief_stages <= 0 ){
1093 brief_load_bitmaps();
1097 // --------------------------------------------------------------------------------------
1098 // brief_set_default_closeup()
1101 void brief_set_default_closeup()
1106 bs = &Briefing->stages[0];
1108 if ( Briefing->num_stages <= 0 ) {
1109 Closeup_icon = NULL;
1113 if ( bs->num_icons <= 0 ) {
1114 Closeup_icon = NULL;
1118 // check for the first highlighted icons to have as the default closeup
1119 for ( i = 0; i < bs->num_icons; i++ ) {
1120 if ( bs->icons[i].flags & BI_HIGHLIGHT )
1124 if ( i == bs->num_icons ) {
1125 brief_setup_closeup(&bs->icons[0]);
1128 brief_setup_closeup(&bs->icons[i]);
1132 // funciton to evaluate the sexpressions of the briefing stages eliminating those stages
1133 // which shouldn't get shown
1134 void brief_compact_stages()
1136 int num, before, result, i;
1139 if((Game_mode & GM_MULTIPLAYER) && (Netgame.campaign_mode == MP_CAMPAIGN) && !(Net_player->flags & NETINFO_FLAG_AM_MASTER)){
1140 Game_mode |= GM_CAMPAIGN_MODE;
1144 before = Briefing->num_stages;
1147 while ( num < Briefing->num_stages ) {
1148 result = eval_sexp( Briefing->stages[num].formula );
1150 if ( Briefing->stages[num].new_text ) {
1151 free( Briefing->stages[num].new_text );
1152 Briefing->stages[num].new_text = NULL;
1155 if ( Briefing->stages[num].icons ) {
1156 free( Briefing->stages[num].icons );
1157 Briefing->stages[num].icons = NULL;
1161 if ( Briefing->stages[num].lines ) {
1162 free( Briefing->stages[num].lines );
1163 Briefing->stages[num].lines = NULL;
1166 Briefing->stages[num].num_icons = 0;
1167 for ( i = num+1; i < Briefing->num_stages; i++ ) {
1168 Briefing->stages[i-1] = Briefing->stages[i];
1170 Briefing->num_stages--;
1176 // completely clear out the old entries (if any) so we don't access them by mistake - taylor
1177 if (before > Briefing->num_stages) {
1178 for (i = Briefing->num_stages; i < before; i++) {
1179 memset( &Briefing->stages[i], 0, sizeof(brief_stage) );
1184 if((Game_mode & GM_MULTIPLAYER) && (Netgame.campaign_mode == MP_CAMPAIGN) && !(Net_player->flags & NETINFO_FLAG_AM_MASTER)){
1185 Game_mode &= ~(GM_CAMPAIGN_MODE);
1191 // --------------------------------------------------------------------------------------
1194 int red_alert_mission(void);
1198 // Since first stage of briefing can take some time to arrive and play,
1199 // reset the trailer timer on briefing init.
1200 #if defined(FS2_DEMO) || defined(FS1_DEMO)
1201 demo_reset_trailer_timer();
1204 // for multiplayer, change the state in my netplayer structure
1205 // and initialize the briefing chat area thingy
1206 if ( Game_mode & GM_MULTIPLAYER ){
1207 Net_player->state = NETPLAYER_STATE_BRIEFING;
1210 // Non standard briefing in red alert mission
1211 if ( red_alert_mission() ) {
1212 gameseq_post_event(GS_EVENT_RED_ALERT);
1216 // get a pointer to the appropriate briefing structure
1217 if((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_TEAM)){
1218 Briefing = &Briefings[Net_player->p_info.team];
1220 Briefing = &Briefings[0];
1223 Brief_last_auto_advance = 0;
1225 brief_compact_stages(); // compact the briefing array to eliminate unused stages
1227 common_set_interface_palette("BriefingPalette");
1229 ship_stop_animation();
1230 set_active_ui(&Brief_ui_window);
1231 Current_screen = ON_BRIEFING_SELECT;
1232 brief_restart_text_wipe();
1233 common_flash_button_init();
1234 common_music_init(SCORE_BRIEFING);
1237 help_overlay_set_state(BR_OVERLAY,0);
1239 if ( Brief_inited == TRUE ) {
1240 common_buttons_maybe_reload(&Brief_ui_window); // AL 11-21-97: this is necessary since we may returning from the hotkey
1241 // screen, which can release common button bitmaps.
1242 common_reset_buttons();
1243 nprintf(("Alan","brief_init() returning without doing anything\n"));
1247 if (The_mission.game_type & MISSION_TYPE_TRAINING)
1248 Num_brief_stages = Briefing->num_stages;
1250 Num_brief_stages = Briefing->num_stages + 1;
1252 Current_brief_stage = 0;
1253 Last_brief_stage = 0;
1255 // init the scene-cut data
1256 brief_transition_reset();
1258 #if !(defined(FS2_DEMO) || defined(FS1_DEMO))
1259 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]);
1260 hud_anim_load(&Fade_anim);
1263 nprintf(("Alan","Entering brief_init()\n"));
1264 common_select_init();
1266 if(Game_mode & GM_MULTIPLAYER) {
1267 BriefingMaskBitmap = bm_load(Brief_multi_mask_filename[gr_screen.res]);
1269 BriefingMaskBitmap = bm_load(Brief_mask_filename[gr_screen.res]);
1272 if (BriefingMaskBitmap < 0) {
1273 Error(LOCATION,"Could not load in 'brief-m'!");
1276 Briefing_mask_w = -1;
1277 Briefing_mask_h = -1;
1279 // get a pointer to bitmap by using bm_lock()
1280 BriefingMaskPtr = bm_lock(BriefingMaskBitmap, 8, BMP_AABITMAP);
1281 BriefingMaskData = (ubyte*)BriefingMaskPtr->data;
1282 bm_get_info(BriefingMaskBitmap, &Briefing_mask_w, &Briefing_mask_h);
1284 help_overlay_load(BR_OVERLAY);
1286 // Set up the mask regions
1287 // initialize the different regions of the menu that will react when the mouse moves over it
1288 Num_briefing_regions = 0;
1290 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_BRIEFING_REGION, 0);
1291 #ifndef FS1_DEMO // not available in demo
1292 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_SS_REGION, 0);
1293 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_WEAPON_REGION, 0);
1295 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_COMMIT_REGION, 0);
1296 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_HELP_REGION, 0);
1297 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", COMMON_OPTIONS_REGION, 0);
1299 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_LAST_STAGE_MASK, 0);
1300 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_NEXT_STAGE_MASK, 0);
1301 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_PREV_STAGE_MASK, 0);
1302 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_FIRST_STAGE_MASK, 0);
1303 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_TEXT_SCROLL_UP_MASK, 0);
1304 snazzy_menu_add_region(&Briefing_select_region[Num_briefing_regions++], "", BRIEF_TEXT_SCROLL_DOWN_MASK, 0);
1307 Brief_ui_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
1309 if(Game_mode & GM_MULTIPLAYER){
1310 Brief_ui_window.set_mask_bmap(Brief_mask_multi[gr_screen.res]);
1312 Brief_ui_window.set_mask_bmap(Brief_mask_single[gr_screen.res]);
1315 Brief_ui_window.tooltip_handler = brief_tooltip_handler;
1316 common_buttons_init(&Brief_ui_window);
1317 brief_buttons_init();
1319 // if multiplayer, initialize a few other systems
1320 if(Game_mode & GM_MULTIPLAYER){
1321 // again, should not be necessary, but we'll leave it for now
1324 // force the chatbox to be small
1325 chatbox_force_small();
1328 // set up the screen regions
1329 brief_init_screen(Brief_multiplayer);
1331 // init briefing specific UI
1334 // init the briefing map
1337 // init the briefing voice playback
1339 brief_voice_load_all();
1341 // init objectives display stuff
1342 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]);
1344 // set the camera target
1345 if ( Briefing->num_stages > 0 ) {
1346 brief_set_new_stage(&Briefing->stages[0].camera_pos, &Briefing->stages[0].camera_orient, 0, Current_brief_stage);
1347 brief_reset_icons(Current_brief_stage);
1350 Brief_playing_fade_sound = 0;
1351 Brief_mouse_up_flag = 0;
1352 Closeup_font_height = gr_get_font_height();
1353 Closeup_icon = NULL;
1354 Brief_inited = TRUE;
1357 // -------------------------------------------------------------------------------------
1358 // brief_render_closeup_text()
1361 #define CLOSEUP_TEXT_OFFSET 10
1362 void brief_render_closeup_text()
1366 char line[MAX_ICON_TEXT_LINE_LEN];
1367 int n_lines, i, render_x, render_y;
1368 int n_chars[MAX_ICON_TEXT_LINES];
1369 char *p_str[MAX_ICON_TEXT_LINES];
1371 if ( Closeup_icon == NULL ) {
1378 render_x = Closeup_region[0];
1379 render_y = Closeup_region[1] + CLOSEUP_IMG_H;
1381 gr_set_clip(render_x+CLOSEUP_TEXT_OFFSET, render_y, CLOSEUP_W,CLOSEUP_TEXT_H);
1382 gr_set_color_fast(&Color_white);
1384 // n_lines = split_str(bi->text, CLOSEUP_W - 2*CLOSEUP_TEXT_OFFSET, n_chars, p_str, MAX_ICON_TEXT_LINES);
1385 SDL_assert(n_lines != -1);
1387 for ( i = 0; i < n_lines; i++ ) {
1388 SDL_assert(n_chars[i] < MAX_ICON_TEXT_LINE_LEN);
1389 strncpy(line, p_str[i], n_chars[i]);
1390 line[n_chars[i]] = 0;
1391 gr_printf(0,0+i*Closeup_font_height,line);
1396 // -------------------------------------------------------------------------------------
1397 // brief_render_closeup()
1400 void brief_render_closeup(int ship_class, float frametime)
1402 matrix view_orient = IDENTITY_MATRIX;
1410 if (Closeup_bitmap < 0)
1413 ang = PI2 * frametime/Closeup_one_revolution_time;
1414 if ( ang > MAX_ANG_CHG )
1417 Closeup_angles.h += ang;
1418 if ( Closeup_angles.h > PI2 )
1419 Closeup_angles.h -= PI2;
1420 vm_angles_2_matrix(&temp_matrix, &Closeup_angles );
1421 Closeup_orient = temp_matrix;
1423 w = Closeup_region[gr_screen.res][2];
1424 h = Closeup_region[gr_screen.res][3];
1425 gr_set_clip(Closeup_region[gr_screen.res][0], Closeup_region[gr_screen.res][1], w, h);
1429 g3_set_view_matrix(&Closeup_cam_pos, &view_orient, Closeup_zoom);
1430 model_clear_instance( Closeup_icon->modelnum );
1431 model_set_detail_level(0);
1433 int is_neb = The_mission.flags & MISSION_FLAG_FULLNEB;
1435 // maybe switch off nebula rendering
1437 The_mission.flags &= ~MISSION_FLAG_FULLNEB;
1440 int model_render_flags;
1441 if ( Closeup_icon->type == ICON_JUMP_NODE ) {
1442 model_set_outline_color(HUD_color_red, HUD_color_green, HUD_color_blue);
1443 model_render_flags = MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_POLYS | MR_SHOW_OUTLINE;
1445 model_render_flags = MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER;
1448 model_render( Closeup_icon->modelnum, &Closeup_orient, &Closeup_pos, model_render_flags );
1451 The_mission.flags |= MISSION_FLAG_FULLNEB;
1456 gr_set_color_fast(&Color_bright_white);
1458 gr_printf(0x8000,2,Closeup_icon->closeup_label);
1459 // brief_render_closeup_text();
1461 Closeup_close_button.enable();
1462 Closeup_close_button.unhide();
1467 // -------------------------------------------------------------------------------------
1470 // frametime is in seconds
1471 void brief_render(float frametime)
1480 if ( Num_brief_stages <= 0 ) {
1481 gr_set_color_fast(&Color_white);
1482 SDL_assert( Game_current_mission_filename != NULL );
1483 gr_printf(0x8000,200,XSTR( "No Briefing exists for mission: %s", 430), Game_current_mission_filename);
1486 gr_get_string_size(&w, &h, The_mission.name);
1487 gr_set_color_fast(&Color_normal);
1488 gr_printf(0x8000, 230, NOX("[filename: %s, last mod: %s]"), Mission_filename, The_mission.modified);
1494 gr_set_bitmap(Brief_grid_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1495 gr_bitmap(Brief_bmap_coords[gr_screen.res][0], Brief_bmap_coords[gr_screen.res][1]);
1497 brief_render_map(Current_brief_stage, frametime);
1499 // draw the frame bitmaps
1500 gr_set_bitmap(Brief_text_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1501 gr_bitmap(Brief_infobox_coords[gr_screen.res][0], Brief_infobox_coords[gr_screen.res][1]);
1502 brief_blit_stage_num(Current_brief_stage, Num_brief_stages);
1504 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);
1506 brief_voice_play(Current_brief_stage);
1509 // maybe output the "more" indicator
1510 if ( (Brief_text_max_lines[gr_screen.res] + Top_brief_text_line + 2) < Num_brief_text_lines[0] ) {
1511 // can be scrolled down
1512 int more_txt_x = Brief_text_coords[gr_screen.res][0] + (Brief_max_line_width[gr_screen.res]/2) - 10;
1513 int more_txt_y = Brief_text_coords[gr_screen.res][1] + Brief_text_coords[gr_screen.res][3] - 2; // located below brief text, centered
1515 gr_get_string_size(&w, &h, XSTR("more", 1469), strlen(XSTR("more", 1469)));
1516 gr_set_color_fast(&Color_black);
1517 gr_rect(more_txt_x-2, more_txt_y, w+3, h);
1518 gr_set_color_fast(&Color_red);
1519 gr_string(more_txt_x, more_txt_y, XSTR("more", 1469)); // base location on the input x and y?
1522 brief_maybe_blit_scene_cut(frametime);
1525 if (MapWin01 != -1) {
1526 gr_set_bitmap(MapWin01, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1530 if (MapWin02 != -1) {
1531 gr_set_bitmap(MapWin02, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1532 gr_bitmap(575, 122);
1535 if (MapWin03 != -1) {
1536 gr_set_bitmap(MapWin03, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1540 if (MapWin04 != -1) {
1541 gr_set_bitmap(MapWin04, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1546 #if !defined(NDEBUG) || defined(INTERPLAYQA)
1547 gr_set_color_fast(&Color_normal);
1548 int title_y_offset = (Game_mode & GM_MULTIPLAYER) ? 20 : 10;
1549 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);
1552 // output mission title
1554 gr_set_color_fast(&Color_bright_white);
1556 gr_set_color_fast(&Color_bright_blue);
1558 if (Game_mode & GM_MULTIPLAYER) {
1560 strncpy(buf, The_mission.name, 256);
1561 gr_force_fit_string(buf, 255, Title_coords_multi[gr_screen.res][2]);
1563 // align from the end of the string instead of the beginning
1564 gr_get_string_size(&w, NULL, buf);
1565 gr_string(Title_coords_multi[gr_screen.res][0] - w, Title_coords_multi[gr_screen.res][1], buf);
1567 gr_string(Title_coords_multi[gr_screen.res][0], Title_coords_multi[gr_screen.res][1], buf);
1570 gr_get_string_size(&w, NULL, The_mission.name);
1571 gr_string(Title_coords[gr_screen.res][0] - w, Title_coords[gr_screen.res][1], The_mission.name);
1574 // maybe do objectives
1575 if (Current_brief_stage == Briefing->num_stages) {
1576 ML_objectives_do_frame(0);
1580 // -------------------------------------------------------------------------------------
1581 // brief_set_closeup_pos()
1584 #define CLOSEUP_OFFSET 20
1585 void brief_set_closeup_pos(brief_icon *bi)
1588 Closeup_x1 = fl2i(320 - Closeup_coords[gr_screen.res][BRIEF_W_COORD]/2.0f + 0.5f);
1591 void brief_get_closeup_ship_modelnum(brief_icon *ci)
1596 // find the model number for the ship to display
1597 for ( objp = GET_FIRST(&obj_used_list); objp !=END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) ) {
1599 if ( objp == &obj_used_list || objp->type != OBJ_SHIP ) {
1603 sp = &Ships[objp->instance];
1604 if ( sp->ship_info_index == ci->ship_class ) {
1605 ci->ship_class = sp->ship_info_index;
1606 ci->modelnum = sp->modelnum;
1607 ci->radius = objp->radius;
1613 // cut any text off after (and including) '#' char
1614 void brief_truncate_label(char *src)
1616 char *pointer_to_last_char;
1618 pointer_to_last_char = strstr(src, NOX("#"));
1620 if ( pointer_to_last_char ) {
1621 *pointer_to_last_char = 0;
1625 // -------------------------------------------------------------------------------------
1626 // brief_setup_closeup()
1628 // exit: 0 => set-up icon sucessfully
1629 // -1 => could not setup closeup icon
1630 int brief_setup_closeup(brief_icon *bi)
1632 char pof_filename[NAME_LENGTH];
1633 ship_info *sip=NULL;
1637 Closeup_icon->ship_class = bi->ship_class;
1638 Closeup_icon->modelnum = -1;
1640 Closeup_one_revolution_time = ONE_REV_TIME;
1642 switch(Closeup_icon->type) {
1644 Closeup_icon = NULL;
1647 strcpy(pof_filename, NOX("planet.pof"));
1648 strcpy(Closeup_icon->closeup_label, XSTR("planet",-1));
1649 vm_vec_make(&Closeup_cam_pos, 0.0f, 0.0f, -8300.0f);
1650 Closeup_zoom = 0.5f;
1651 Closeup_one_revolution_time = ONE_REV_TIME * 3;
1654 case ICON_ASTEROID_FIELD:
1655 #if !(defined(FS2_DEMO) || defined(FS1_DEMO))
1656 strcpy(pof_filename, Asteroid_info[ASTEROID_TYPE_BIG].pof_files[0]);
1657 strcpy(Closeup_icon->closeup_label, XSTR( "asteroid", 431));
1658 (void) vm_vec_make(&Closeup_cam_pos, 0.0f, 0.0f, -334.0f);
1659 Closeup_zoom = 0.5f;
1662 case ICON_JUMP_NODE:
1663 strcpy(pof_filename, NOX("subspacenode.pof"));
1664 strcpy(Closeup_icon->closeup_label, XSTR( "jump node", 432));
1665 (void) vm_vec_make(&Closeup_cam_pos, 0.0f, 0.0f, -2700.0f);
1666 Closeup_zoom = 0.5f;
1667 Closeup_one_revolution_time = ONE_REV_TIME * 3;
1670 case ICON_UNKNOWN_WING:
1671 strcpy(pof_filename, NOX("unknownship.pof"));
1672 strcpy(Closeup_icon->closeup_label, XSTR( "unknown", 433));
1673 (void) vm_vec_make(&Closeup_cam_pos, 0.0f, 0.0f, -22.0f);
1674 Closeup_zoom = 0.5f;
1677 brief_get_closeup_ship_modelnum(Closeup_icon);
1678 SDL_assert( Closeup_icon->ship_class != -1 );
1679 sip = &Ship_info[Closeup_icon->ship_class];
1681 strcpy(Closeup_icon->closeup_label,sip->name);
1683 // cut any text off after (and including) '#' char
1684 brief_truncate_label(Closeup_icon->closeup_label);
1686 if ( sip->flags & (SIF_SMALL_SHIP|SIF_BIG_SHIP|SIF_HUGE_SHIP|SIF_SENTRYGUN) ) {
1687 strcat(Closeup_icon->closeup_label, XSTR( " class", 434));
1692 if ( Closeup_icon->modelnum == -1 ) {
1693 if ( sip == NULL ) {
1694 Closeup_icon->modelnum = model_load(pof_filename, 0, NULL);
1696 Closeup_icon->modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]);
1698 Closeup_icon->radius = model_get_radius(Closeup_icon->modelnum);
1701 vm_set_identity(&Closeup_orient);
1702 (void) vm_vec_make(&tvec, 0.0f, 0.0f, -1.0f);
1703 Closeup_orient.v.fvec = tvec;
1704 vm_vec_zero(&Closeup_pos);
1705 Closeup_angles.p = 0.0f;
1706 Closeup_angles.b = 0.0f;
1707 Closeup_angles.h = PI;
1709 brief_set_closeup_pos(bi);
1712 Closeup_cam_pos = sip->closeup_pos;
1713 Closeup_zoom = sip->closeup_zoom;
1719 // -------------------------------------------------------------------------------------
1720 // brief_update_closeup_icon()
1722 // input: mode => how to update the closeup view
1725 void brief_update_closeup_icon(int mode)
1729 int i, closeup_index;
1733 // mode 0 means disable the closeup icon
1734 if ( Closeup_icon != NULL ) {
1735 brief_turn_off_closeup_icon();
1740 if ( Closeup_icon == NULL )
1743 bs = &Briefing->stages[Current_brief_stage];
1746 // see if any icons are being highlighted this stage
1747 for ( i = 0; i < bs->num_icons; i++ ) {
1749 if ( bi->flags & BI_HIGHLIGHT ) {
1755 if ( closeup_index != -1 ) {
1756 bi = &bs->icons[closeup_index];
1757 brief_setup_closeup(bi);
1760 Closeup_icon = NULL;
1765 // -------------------------------------------------------------------------------------
1766 // brief_check_for_anim()
1769 void brief_check_for_anim()
1771 int mx, my, i, iw, ih, x, y;
1773 brief_icon *bi = NULL;
1775 bs = &Briefing->stages[Current_brief_stage];
1776 mouse_get_pos( &mx, &my );
1778 // if mouse click is over the VCR controls, don't launch an icon
1779 // FIXME - should prolly push these into defines instead of hardcoding this
1780 // if ( mx >= 0 && mx <= 115 && my >= 136 && my <= 148 ) {
1784 // same as above but without the hardcoded values, which were wrong anyway. don't know
1785 // how this will work longterm but will hopefully keep things working well - taylor
1786 for (i = 0; i <= BRIEF_BUTTON_FIRST_STAGE; i++) {
1787 Brief_buttons[gr_screen.res][i].button.get_dimensions(&x, &y, &iw, &ih);
1789 if (mx >= x && mx <= (x+iw) && my >= y && my <= (y+ih)) {
1794 // if mouse coords are outside the briefing screen, then go away
1795 my -= bscreen.map_y1;
1796 mx -= bscreen.map_x1;
1797 if ( my < 0 || mx < 0 || mx > (bscreen.map_x2-bscreen.map_x1+1) || my > (bscreen.map_y2-bscreen.map_y1+1) )
1800 for ( i = 0; i < bs->num_icons; i++ ) {
1802 brief_common_get_icon_dimensions(&iw, &ih, bi->type, bi->ship_class);
1803 if ( mx < bi->x ) continue;
1804 if ( mx > (bi->x + iw) ) continue;
1805 if ( my < bi->y ) continue;
1806 if ( my > (bi->y + ih) ) continue;
1807 // if we've got here, must be a hit
1811 if ( i == bs->num_icons ) {
1812 brief_turn_off_closeup_icon();
1816 if ( brief_setup_closeup(bi) == 0 ) {
1817 gamesnd_play_iface(SND_BRIEF_ICON_SELECT);
1819 gamesnd_play_iface(SND_GENERAL_FAIL);
1823 // maybe flash a button if player hasn't done anything for a while
1824 void brief_maybe_flash_button()
1828 if ( Num_brief_stages <= 0 )
1831 if ( Closeup_icon != NULL ) {
1832 common_flash_button_init();
1836 if ( common_flash_bright() ) {
1837 if ( Current_brief_stage == (Num_brief_stages-1) ) {
1839 // AL 4-4-98: Don't flash ship selection button on briefing in demo build
1840 #if defined(FS2_DEMO) || defined(FS1_DEMO)
1843 // AL 30-3-98: Don't flash ship selection button if in a training mission,
1844 if ( brief_only_allow_briefing() ) {
1848 b = &Common_buttons[Current_screen-1][gr_screen.res][1].button; // ship select button
1851 b = &Brief_buttons[gr_screen.res][1].button; // next stage button
1854 if ( b->button_hilighted() ) {
1855 common_flash_button_init();
1862 // -------------------------------------------------------------------------------------
1865 // frametime is in seconds
1867 void brief_do_frame(float frametime)
1869 int k, brief_choice;
1871 if ( red_alert_mission() ) {
1876 if ( !Brief_inited ){
1880 int snazzy_action = -1;
1881 brief_choice = snazzy_menu_do(BriefingMaskData, Briefing_mask_w, Briefing_mask_h, Num_briefing_regions, Briefing_select_region, &snazzy_action, 0);
1883 k = common_select_do(frametime);
1885 if ( Closeup_icon ) {
1886 Brief_mouse_up_flag = 0;
1889 if ( help_overlay_active(BR_OVERLAY) ) {
1890 common_flash_button_init();
1891 brief_turn_off_closeup_icon();
1894 // Check common keypresses
1895 common_check_keys(k);
1901 if ( Briefing->num_stages > 0 ) {
1903 // check for special keys
1907 case KEY_CTRLED | SDLK_PAGEUP: {
1908 if (Closeup_icon->ship_class) {
1909 Closeup_icon->ship_class--;
1911 ship_info *sip = &Ship_info[Closeup_icon->ship_class];
1912 if (sip->modelnum < 0)
1913 sip->modelnum = model_load(sip->pof_file, 0, NULL);
1915 mprintf(("Shiptype = %d (%s)\n", Closeup_icon->ship_class, sip->name));
1916 mprintf(("Modelnum = %d (%s)\n", sip->modelnum, sip->pof_file));
1917 brief_setup_closeup(Closeup_icon);
1923 case KEY_CTRLED | SDLK_PAGEDOWN: {
1924 if (Closeup_icon->ship_class < Num_ship_types - 1) {
1925 Closeup_icon->ship_class++;
1927 ship_info *sip = &Ship_info[Closeup_icon->ship_class];
1928 if (sip->modelnum < 0)
1929 sip->modelnum = model_load(sip->pof_file, 0, NULL);
1931 mprintf(("Shiptype = %d (%s)\n", Closeup_icon->ship_class, sip->name));
1932 mprintf(("Modelnum = %d (%s)\n", sip->modelnum, sip->pof_file));
1933 brief_setup_closeup(Closeup_icon);
1940 Closeup_cam_pos.xyz.z += 1;
1944 case SDLK_a + KEY_SHIFTED:
1945 Closeup_cam_pos.xyz.z += 10;
1950 Closeup_cam_pos.xyz.z -= 1;
1954 case SDLK_z + KEY_SHIFTED:
1955 Closeup_cam_pos.xyz.z -= 10;
1960 Closeup_cam_pos.xyz.y += 1;
1964 case SDLK_y + KEY_SHIFTED:
1965 Closeup_cam_pos.xyz.y += 10;
1970 Closeup_cam_pos.xyz.y -= 1;
1974 case SDLK_h + KEY_SHIFTED:
1975 Closeup_cam_pos.xyz.y -= 10;
1980 Closeup_zoom -= 0.1f;
1981 if ( Closeup_zoom < 0.1 )
1982 Closeup_zoom = 0.1f;
1986 case SDLK_COMMA+KEY_SHIFTED:
1987 Closeup_zoom -= 0.5f;
1988 if ( Closeup_zoom < 0.1 )
1989 Closeup_zoom = 0.1f;
1994 Closeup_zoom += 0.1f;
1998 case SDLK_PERIOD+KEY_SHIFTED:
1999 Closeup_zoom += 0.5f;
2003 case 1000: // need this to avoid warning about no case
2013 nprintf(("General","Camera pos: %.2f, %.2f %.2f // ", Closeup_cam_pos.xyz.x, Closeup_cam_pos.xyz.y, Closeup_cam_pos.xyz.z));
2014 nprintf(("General","Camera zoom: %.2f\n", Closeup_zoom));
2018 if ( brief_choice > -1 && snazzy_action == SNAZZY_OVER ) {
2019 Brief_mouse_up_flag = 0;
2024 common_check_buttons();
2025 // if ( Briefing->num_stages > 0 )
2026 brief_check_buttons();
2028 if ( brief_choice != -1 ) {
2029 Brief_mouse_up_flag = 0;
2034 common_render(frametime);
2036 if ( Current_brief_stage < (Num_brief_stages-1) ) {
2037 if ( !help_overlay_active(BR_OVERLAY) && brief_time_to_advance(Current_brief_stage, frametime) ) {
2038 brief_do_next_pressed(0);
2039 common_flash_button_init();
2040 Brief_last_auto_advance = timer_get_milliseconds();
2044 if ( !Background_playing ) {
2046 int check_jump_flag = 1;
2047 if ( Current_brief_stage != Last_brief_stage ) {
2049 // Check if we have a quick transition pending
2050 if ( Quick_transition_stage != -1 ) {
2051 Quick_transition_stage = -1;
2052 brief_reset_last_new_stage();
2054 check_jump_flag = 0;
2057 if ( check_jump_flag ) {
2058 if ( abs(Current_brief_stage - Last_brief_stage) > 1 ) {
2059 Quick_transition_stage = Current_brief_stage;
2060 Current_brief_stage = Last_brief_stage;
2061 SDL_assert(Current_brief_stage >= 0);
2062 Start_fade_up_anim = 1;
2063 goto Transition_done;
2068 if ( Current_brief_stage > Last_brief_stage ) {
2069 if ( Briefing->stages[Last_brief_stage].flags & BS_FORWARD_CUT ) {
2070 Quick_transition_stage = Current_brief_stage;
2071 Current_brief_stage = Last_brief_stage;
2072 SDL_assert(Current_brief_stage >= 0);
2073 Start_fade_up_anim = 1;
2074 goto Transition_done;
2076 time = Briefing->stages[Current_brief_stage].camera_time;
2080 if ( Briefing->stages[Last_brief_stage].flags & BS_BACKWARD_CUT ) {
2081 Quick_transition_stage = Current_brief_stage;
2082 Current_brief_stage = Last_brief_stage;
2083 SDL_assert(Current_brief_stage >= 0);
2084 Start_fade_up_anim = 1;
2085 goto Transition_done;
2087 time = Briefing->stages[Last_brief_stage].camera_time;
2092 brief_voice_stop(Last_brief_stage);
2094 if ( Current_brief_stage < 0 ) {
2096 Current_brief_stage=0;
2099 // set the camera target
2100 brief_set_new_stage(&Briefing->stages[Current_brief_stage].camera_pos,
2101 &Briefing->stages[Current_brief_stage].camera_orient,
2102 time, Current_brief_stage);
2104 Brief_playing_fade_sound = 0;
2105 Last_brief_stage = Current_brief_stage;
2106 brief_reset_icons(Current_brief_stage);
2107 brief_update_closeup_icon(0);
2112 if ( Brief_mouse_up_flag && !Closeup_icon) {
2113 brief_check_for_anim();
2116 brief_render(frametime);
2117 brief_camera_move(frametime, Current_brief_stage);
2119 if (Closeup_icon && (Closeup_bitmap >= 0)) {
2120 // blit closeup background
2121 gr_set_bitmap(Closeup_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
2122 gr_bitmap(Closeup_coords[gr_screen.res][BRIEF_X_COORD], Closeup_coords[gr_screen.res][BRIEF_Y_COORD]);
2125 Brief_ui_window.draw();
2126 brief_redraw_pressed_buttons();
2127 common_render_selected_screen_button();
2130 brief_render_closeup(Closeup_icon->ship_class, frametime);
2133 // render some extra stuff in multiplayer
2134 if (Game_mode & GM_MULTIPLAYER) {
2135 // should render this last so that it overlaps all controls
2138 // render the status indicator for the voice system
2139 multi_common_voice_display_status();
2141 // blit the "ships/players" locked button
2142 // multi_ts_blit_locked_button();
2144 // maybe blit the multiplayer "locked" button
2145 // if its locked, everyone blits it as such
2146 if(multi_ts_is_locked()){
2147 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.draw_forced(2);
2149 // anyone who can't hit the button sees it off, otherwise
2151 if( ((Netgame.type_flags & NG_TYPE_TEAM) && !(Net_player->flags & NETINFO_FLAG_TEAM_CAPTAIN)) ||
2152 ((Netgame.type_flags & NG_TYPE_TEAM) && !(Net_player->flags & NETINFO_FLAG_GAME_HOST)) ){
2153 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.draw_forced(0);
2155 Brief_buttons[gr_screen.res][BRIEF_BUTTON_MULTI_LOCK].button.draw();
2161 // maybe flash a button if player hasn't done anything for a while
2162 brief_maybe_flash_button();
2164 // blit help overlay if active
2165 help_overlay_maybe_blit(BR_OVERLAY);
2169 // If the commit button was pressed, do the commit button actions. Done at the end of the
2170 // loop so there isn't a skip in the animation (since ship_create() can take a long time if
2171 // the ship model is not in memory
2172 if (Commit_pressed) {
2173 if (Game_mode & GM_MULTIPLAYER) {
2174 multi_ts_commit_pressed();
2183 // --------------------------------------------------------------------------------------
2184 // brief_unload_bitmaps()
2187 void brief_unload_bitmaps()
2189 if ( BriefingMaskBitmap != -1 ) {
2190 bm_unload(BriefingMaskBitmap);
2191 BriefingMaskBitmap = -1;
2194 if ( Brief_text_bitmap != -1 ) {
2195 bm_unload(Brief_text_bitmap);
2196 Brief_text_bitmap = -1;
2199 if(Brief_grid_bitmap != -1){
2200 bm_unload(Brief_grid_bitmap);
2201 Brief_grid_bitmap = -1;
2204 if ( Brief_multitext_bitmap != -1 ) {
2205 bm_unload(Brief_multitext_bitmap);
2206 Brief_multitext_bitmap = -1;
2209 if ( Brief_background_bitmap != -1 ) {
2210 bm_unload(Brief_background_bitmap);
2211 Brief_background_bitmap = -1;
2215 if (MapWin01 != -1){
2216 bm_unload(MapWin01);
2220 if (MapWin02 != -1){
2221 bm_unload(MapWin02);
2225 if (MapWin03 != -1){
2226 bm_unload(MapWin03);
2230 if (MapWin04 != -1){
2231 bm_unload(MapWin04);
2236 help_overlay_unload(BR_OVERLAY);
2239 // ------------------------------------------------------------------------------------
2245 if ( Brief_inited == FALSE ) {
2246 nprintf(("Warning","brief_close() returning without doing anything\n"));
2250 nprintf(("Alan", "Entering brief_close()\n"));
2252 ML_objectives_close();
2254 // unload the audio streams used for voice playback
2255 brief_voice_unload_all();
2257 #if !(defined(FS2_DEMO) || defined(FS1_DEMO))
2258 hud_anim_release(&Fade_anim);
2261 // done mask bitmap, so unlock it
2262 bm_unlock(BriefingMaskBitmap);
2264 Brief_ui_window.destroy();
2268 common_free_interface_palette();
2271 // unload the bitmaps
2272 brief_unload_bitmaps();
2274 brief_common_close();
2276 Brief_inited = FALSE;
2279 void briefing_stop_music()
2281 if ( Briefing_music_handle != -1 ) {
2282 audiostream_close_file(Briefing_music_handle);
2283 Briefing_music_handle = -1;
2287 void briefing_load_music(const char* fname)
2289 if ( Cmdline_freespace_no_music ) {
2293 if ( Briefing_music_handle != -1 )
2297 Briefing_music_handle = audiostream_open( fname, ASF_EVENTMUSIC );
2300 void briefing_start_music()
2302 if ( Briefing_music_handle != -1 ) {
2303 if ( !audiostream_is_playing(Briefing_music_handle) )
2304 audiostream_play(Briefing_music_handle, Master_event_music_volume);
2307 nprintf(("Warning", "No music file exists to play music at this briefing!\n"));
2311 void brief_stop_voices()
2313 brief_voice_stop(Current_brief_stage);
2316 void brief_maybe_blit_scene_cut(float frametime)
2318 if ( Start_fade_up_anim ) {
2320 #if defined(FS2_DEMO) || defined(FS1_DEMO)
2321 Fade_anim.time_elapsed = 0.0f;
2322 Start_fade_up_anim = 0;
2323 Start_fade_down_anim = 1;
2324 Current_brief_stage = Quick_transition_stage;
2326 if ( Current_brief_stage < 0 ) {
2327 brief_transition_reset();
2328 Current_brief_stage = Last_brief_stage;
2330 goto Fade_down_anim_start;
2334 Fade_anim.time_elapsed += frametime;
2336 if ( !Brief_playing_fade_sound ) {
2337 gamesnd_play_iface(SND_BRIEFING_STATIC);
2338 Brief_playing_fade_sound = 1;
2341 if ( Fade_anim.time_elapsed > Fade_anim.total_time ) {
2342 Fade_anim.time_elapsed = 0.0f;
2343 Start_fade_up_anim = 0;
2344 Start_fade_down_anim = 1;
2345 Current_brief_stage = Quick_transition_stage;
2347 if ( Current_brief_stage < 0 ) {
2348 brief_transition_reset();
2349 Current_brief_stage = Last_brief_stage;
2352 SDL_assert(Current_brief_stage >= 0);
2353 goto Fade_down_anim_start;
2356 // draw the correct frame of animation
2357 framenum = fl2i( (Fade_anim.time_elapsed * Fade_anim.num_frames) / Fade_anim.total_time );
2360 if ( framenum >= Fade_anim.num_frames )
2361 framenum = Fade_anim.num_frames-1;
2363 // Blit the bitmap for this frame
2364 gr_set_bitmap(Fade_anim.first_frame + framenum, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
2365 gr_bitmap(Fade_anim.sx, Fade_anim.sy);
2370 Fade_down_anim_start:
2371 if ( Start_fade_down_anim ) {
2373 #if defined(FS2_DEMO) || defined(FS1_DEMO)
2374 Fade_anim.time_elapsed = 0.0f;
2375 Start_fade_up_anim = 0;
2376 Start_fade_down_anim = 0;
2382 Fade_anim.time_elapsed += frametime;
2384 if ( Fade_anim.time_elapsed > Fade_anim.total_time ) {
2385 Fade_anim.time_elapsed = 0.0f;
2386 Start_fade_up_anim = 0;
2387 Start_fade_down_anim = 0;
2391 // draw the correct frame of animation
2392 framenum = fl2i( (Fade_anim.time_elapsed * Fade_anim.num_frames) / Fade_anim.total_time );
2395 if ( framenum >= Fade_anim.num_frames )
2396 framenum = Fade_anim.num_frames-1;
2398 // Blit the bitmap for this frame
2399 gr_set_bitmap(Fade_anim.first_frame + (Fade_anim.num_frames-1) - framenum, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
2400 gr_bitmap(Fade_anim.sx, Fade_anim.sy);
2406 void brief_transition_reset()
2408 Quick_transition_stage = -1;
2409 Start_fade_up_anim = 0;
2410 Start_fade_down_anim = 0;
2411 Fade_anim.time_elapsed = 0.0f;
2414 // return 1 if this mission only allow players to use the briefing (and not ship or
2415 // weapon loadout). Otherwise return 0.
2416 int brief_only_allow_briefing()
2418 if ( The_mission.game_type & MISSION_TYPE_TRAINING ) {
2422 if ( The_mission.scramble || The_mission.red_alert) {