]> icculus.org git repositories - taylor/freespace2.git/blob - include/missionbriefcommon.h
byte-swapping changes for bigendian systems
[taylor/freespace2.git] / include / missionbriefcommon.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell 
5  * or otherwise commercially exploit the source or things you created based on
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/Mission/MissionBriefCommon.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Header file for briefing stuff common to FreeSpace and FRED
16  *
17  * $Log$
18  * Revision 1.3  2003/05/25 02:30:42  taylor
19  * Freespace 1 support
20  *
21  * Revision 1.2  2002/06/09 04:41:13  relnev
22  * added copyright header
23  *
24  * Revision 1.1.1.1  2002/05/03 03:28:12  root
25  * Initial import.
26  *
27  * 
28  * 10    8/24/99 11:30a Jefff
29  * Increased number of debriefing lines
30  * 
31  * 9     7/20/99 7:09p Jefff
32  * briefing text occupies full window in 1024x768
33  * 
34  * 8     7/19/99 3:01p Dave
35  * Fixed icons. Added single transport icon.
36  * 
37  * 7     7/18/99 5:20p Dave
38  * Jump node icon. Fixed debris fogging. Framerate warning stuff.
39  * 
40  * 6     7/09/99 5:54p Dave
41  * Seperated cruiser types into individual types. Added tons of new
42  * briefing icons. Campaign screen.
43  * 
44  * 5     6/29/99 7:39p Dave
45  * Lots of small bug fixes.
46  * 
47  * 4     1/30/99 4:03p Johnson
48  * Include #defines for Fred
49  * 
50  * 3     1/29/99 4:17p Dave
51  * New interface screens.
52  * 
53  * 2     10/07/98 10:53a Dave
54  * Initial checkin.
55  * 
56  * 1     10/07/98 10:49a Dave
57  * 
58  * 71    6/10/98 6:47p Lawrance
59  * increase MAX_RECOMMENDATION_LEN to 1024, to accommodate other languages
60  * 
61  * 70    4/25/98 3:49p Lawrance
62  * Save briefing auto-advance pref
63  * 
64  * 69    4/20/98 3:53p Lawrance
65  * Fix various bugs with auto-advancing through briefings.
66  * 
67  * 68    4/15/98 10:27a Sandeep
68  * 
69  * 67    4/13/98 7:06p Lawrance
70  * implement auto advance of briefing stages
71  * 
72  * 66    4/06/98 2:51p Hoffoss
73  * Added sexp for briefing to FreeSpace.
74  * 
75  * 65    4/03/98 5:22p Hoffoss
76  * Changes: training missions don't show objectives anymore, text for
77  * objective stage is different than last briefing stage now, and
78  * objectives have a black background now.
79  * 
80  * 64    4/03/98 10:31a John
81  * Made briefing and debriefing arrays be malloc'd
82  * 
83  * 63    4/01/98 8:38p Lawrance
84  * Add support for jump node icons in the briefings.
85  * 
86  * 62    3/26/98 5:47p Lawrance
87  * remove icon text functionality
88  * 
89  * 61    3/17/98 4:13p Hoffoss
90  * finessed the coordinates of the text window in the briefing screen a
91  * little to improve visual quality.
92  * 
93  * 60    3/12/98 4:04p Hoffoss
94  * Changed text window size and spaced text out an extra pixel.
95  * 
96  * 59    3/09/98 12:13a Lawrance
97  * Add support for Red Alert missions
98  * 
99  * 58    3/07/98 11:50a Lawrance
100  * Fix bug with displaying the closeup title
101  * 
102  * 57    3/05/98 9:38p Hoffoss
103  * Finished up command brief screen.
104  * 
105  * 56    3/05/98 10:39a Hoffoss
106  * Added command brief stuff.
107  * 
108  * 55    2/26/98 4:59p Allender
109  * groundwork for team vs team briefings.  Moved weaponry pool into the
110  * Team_data structure.  Added team field into the p_info structure.
111  * Allow for mutliple structures in the briefing code.
112  * 
113  * 54    2/24/98 6:21p Lawrance
114  * Fix up map grid region
115  * 
116  * 53    2/24/98 12:22a Lawrance
117  * New coords for revamped briefing graphics
118  * 
119  * 52    2/18/98 6:45p Hoffoss
120  * Added support for lines between icons in briefings for Fred.
121  * 
122  * 51    2/13/98 5:16p Lawrance
123  * Add support for icon lines in the briefing.
124  * 
125  * 50    2/09/98 9:25p Allender
126  * team v team support.  multiple pools and breifings
127  * 
128  * 49    2/06/98 4:32p Lawrance
129  * Allow briefing voices to be toggled on/off
130  * 
131  * 48    2/04/98 4:32p Allender
132  * support for multiple briefings and debriefings.  Changes to mission
133  * type (now a bitfield).  Bitfield defs for multiplayer modes
134  * 
135  * 47    1/28/98 7:22p Lawrance
136  * Put back in highlight member in brief_icon for FRED compatability.
137  * 
138  * 46    1/28/98 7:19p Lawrance
139  * Get fading/highlighting animations working
140  * 
141  * 45    10/19/97 5:14p Lawrance
142  * add flags member to brief_stage
143  * 
144  * 44    10/15/97 4:45p Lawrance
145  * implement scene cut in debriefing
146  * 
147  * 43    10/13/97 7:40p Lawrance
148  * implement new debriefing/recommendation format
149  * 
150  * 42    10/04/97 12:00a Lawrance
151  * grey out background when help overlay is activated
152  * 
153  * 41    10/03/97 8:25a Lawrance
154  * be able to pause brief narration
155  * 
156  * 40    10/01/97 4:39p Lawrance
157  * move chat code into Chatbox.cpp, simplify interface
158  *
159  * $NoKeywords: $
160  */
161
162 #ifndef __MISSIONBRIEFCOMMON_H__
163 #define __MISSIONBRIEFCOMMON_H__
164
165 #include "packunpack.h"
166 #include "hud.h"
167
168 #define MAX_TEXT_STREAMS        2               // how many concurrent streams of text can be displayed
169
170 // ------------------------------------------------------------------------
171 // names for the icons that can appear in the briefing.  If you modify this list,
172 // update the Icons_names[] string array located in MissionParse.cpp
173 // ------------------------------------------------------------------------
174 #ifdef MAKE_FS1
175 #define MAX_BRIEF_ICONS                                         27
176 #else
177 #define MAX_BRIEF_ICONS                                         35              // keep up to date
178 #endif
179
180 #define ICON_FIGHTER                                                    0
181 #define ICON_FIGHTER_WING                                       1
182 #define ICON_CARGO                                                      2
183 #define ICON_CARGO_WING                                         3
184 #define ICON_LARGESHIP                                          4
185 #define ICON_LARGESHIP_WING                             5
186 #define ICON_CAPITAL                                                    6
187 #define ICON_PLANET                                                     7
188 #define ICON_ASTEROID_FIELD                             8
189 #define ICON_WAYPOINT                                           9
190 #define ICON_SUPPORT_SHIP                                       10
191 #define ICON_FREIGHTER_NO_CARGO                 11
192 #define ICON_FREIGHTER_WITH_CARGO               12
193 #define ICON_FREIGHTER_WING_NO_CARGO    13
194 #define ICON_FREIGHTER_WING_WITH_CARGO  14
195 #define ICON_INSTALLATION                                       15
196 #define ICON_BOMBER                                                     16
197 #define ICON_BOMBER_WING                                        17
198 #define ICON_CRUISER                                                    18
199 #define ICON_CRUISER_WING                                       19
200 #define ICON_UNKNOWN                                                    20
201 #define ICON_UNKNOWN_WING                                       21
202 #define ICON_FIGHTER_PLAYER                             22
203 #define ICON_FIGHTERW_PLAYER                            23
204 #define ICON_BOMBER_PLAYER                                      24
205 #define ICON_BOMBERW_PLAYER                             25
206 #ifdef MAKE_FS1
207 #define ICON_JUMP_NODE                                  26
208 #else
209 #define ICON_KNOSSOS_DEVICE                             26
210 #define ICON_TRANSPORT_WING                             27
211 #define ICON_CORVETTE                                           28
212 #define ICON_GAS_MINER                                          29
213 #define ICON_AWACS                                                      30
214 #define ICON_SUPERCAP                                           31
215 #define ICON_SENTRYGUN                                          32
216 #define ICON_JUMP_NODE                                          33
217 #define ICON_TRANSPORT                                          34
218 #endif
219
220 // ------------------------------------------------------------------------
221 // Structures to hold briefing data
222 // ------------------------------------------------------------------------
223
224 #define MAX_BRIEF_LEN                   4096            // size of char array which holds briefing text
225 #define MAX_BRIEF_LINES         50
226 #define MAX_BRIEF_LINE_LEN      256             // max number of chars in a briefing line
227 #define MAX_BRIEF_LINE_W_640            375             // max width of line in pixels in 640x480 mode
228 #define MAX_BRIEF_LINE_W_1024   600             // max width of line in pixels in 1024x768 mode
229
230 #define MAX_DEBRIEF_LEN         2048            // size of char array which holds debriefing text
231 #define MAX_DEBRIEF_LINES               60
232 #define MAX_DEBRIEF_LINE_LEN    256             // max number of chars in a debriefing line
233 #define MAX_DEBRIEF_LINE_W      500             // max width of line in pixels
234
235 #define MAX_ICON_TEXT_LEN                       1024            // max number of chars for icon info
236 #define MAX_ICON_TEXT_LINES             30
237 #define MAX_ICON_TEXT_LINE_LEN  256             // max number of chars in icon info line
238 #define MAX_ICON_TEXT_LINE_W            170             // max width of line in pixels
239
240 #define MAX_STAGE_ICONS                 20
241 #define MAX_BRIEF_STAGES                        15
242 #define MAX_DEBRIEF_STAGES              20
243 #define MAX_LABEL_LEN                           64
244
245 #define MAX_RECOMMENDATION_LEN  1024
246
247 #define         BI_HIGHLIGHT            (1<<0)
248 #define         BI_SHOWHIGHLIGHT        (1<<1)
249 #define         BI_FADEIN                       (1<<2)
250
251 typedef struct brief_icon
252 {
253         int             x,y,w,h;
254         int             hold_x, hold_y; // 2D screen position of icon, used to place animations
255         int             ship_class;
256         int             modelnum;
257         float           radius;
258         int             type;                                   // ICON_* defines from MissionBriefCommon.h
259         int             bitmap_id;
260         int             id;
261         int             team;
262         vector  pos;
263         char            label[MAX_LABEL_LEN];
264         char            closeup_label[MAX_LABEL_LEN];
265 //      char            text[MAX_ICON_TEXT_LEN];
266         hud_anim        fadein_anim;
267         hud_anim        fadeout_anim;
268         hud_anim        highlight_anim;
269         int             flags;                          // BI_* flags defined above
270 } brief_icon;
271
272 #define MAX_BRIEF_STAGE_LINES           20
273
274 typedef struct brief_line
275 {
276         int start_icon;         // index into icons[], where line starts
277         int end_icon;                   // index into icons[], where line ends
278 } brief_line;
279
280 #define BS_FORWARD_CUT          (1<<0)
281 #define BS_BACKWARD_CUT         (1<<1)
282
283 typedef struct brief_stage
284 {
285         char                    *new_text;
286         char                    voice[MAX_FILENAME_LEN];
287         vector          camera_pos;
288         matrix          camera_orient;
289         int                     camera_time;            // ms
290         int                     flags;                          // see BS_ flags above
291         int                     formula;
292         int                     num_icons;
293         brief_icon      *icons;
294         int                     num_lines;
295         brief_line      *lines;
296 } brief_stage;
297
298 typedef struct debrief_stage
299 {
300         int                     formula;
301         char                    *new_text;
302         char                    voice[MAX_FILENAME_LEN];
303         char                    *new_recommendation_text;
304 } debrief_stage;
305
306 typedef struct briefing {
307         int                     num_stages;
308         brief_stage     stages[MAX_BRIEF_STAGES];
309 } briefing;
310
311 typedef struct debriefing {
312         int                             num_stages;
313         debrief_stage   stages[MAX_DEBRIEF_STAGES];
314 } debriefing;
315
316
317 // Code to free/init the above structures between levels:
318
319 // --------------------------------------------------------------------------------------
320 // Does one time initialization of the briefing and debriefing structures.
321 // Namely setting all malloc'ble pointers to NULL.  Called once at game startup.
322 void mission_brief_common_init();
323
324 //--------------------------------------------------------------------------------------
325 // Frees all the memory allocated in the briefing and debriefing structures
326 // and sets all pointers to NULL.
327 void mission_brief_common_reset();
328
329
330 // --------------------------------------------------------------------------------------
331 // briefing screen
332 // --------------------------------------------------------------------------------------
333 extern int Brief_bmap_coords[GR_NUM_RESOLUTIONS][2];
334 extern int Brief_grid_coords[GR_NUM_RESOLUTIONS][4];
335 extern int Brief_text_coords[GR_NUM_RESOLUTIONS][4];
336 extern int Brief_text_max_lines[GR_NUM_RESOLUTIONS];
337 extern char *Brief_static_name[GR_NUM_RESOLUTIONS];
338 extern int Brief_static_coords[GR_NUM_RESOLUTIONS][2];
339
340 // Needed for Fred
341 #define BRIEF_GRID3_X1                                          42
342 #define BRIEF_GRID3_Y1                                          122
343 #define BRIEF_GRID0_X2                                          585
344 #define BRIEF_GRID0_Y2                                          371
345 #define BRIEF_GRID_W                                                    (BRIEF_GRID0_X2-BRIEF_GRID3_X1+1)
346 #define BRIEF_GRID_H                                                    (BRIEF_GRID0_Y2-BRIEF_GRID3_Y1+1)
347 /*
348 #define BRIEF_GRID0_X1                                          63
349 #define BRIEF_GRID0_Y1                                          122
350 #define BRIEF_GRID1_X1                                          575
351 #define BRIEF_GRID1_Y1                                          122
352 #define BRIEF_GRID2_X1                                          63
353 #define BRIEF_GRID2_Y1                                          350
354
355 #define BRIEF_TEXT_X1                                           0
356 #define BRIEF_TEXT_Y1                                           397
357 #define BRIEF_TEXT_X2                                           441
358 #define BRIEF_TEXT_Y2                                           477
359 #define BRIEF_TEXT_BEGIN_X                                      50
360 #define BRIEF_TEXT_BEGIN_Y                                      414
361 #define BRIEF_TEXT_H                                                    54
362
363 */
364
365 typedef struct brief_screen
366 {
367         int map_x1, map_x2, map_y1, map_y2;
368         int btext_x1, btext_x2, btext_y1, btext_y2;
369         int cup_x1, cup_x2, cup_y1, cup_y2;
370         int cupinfo_x1, cupinfo_x2, cupinfo_y1, cupinfo_y2;
371 } brief_sceen;
372
373 extern brief_screen bscreen;
374
375 // ------------------------------------------------------------------------
376 // Global briefing/debriefing data
377 // ------------------------------------------------------------------------
378 extern briefing         Briefings[MAX_TEAMS];
379 extern debriefing               Debriefings[MAX_TEAMS];
380 extern briefing         *Briefing;
381 extern debriefing               *Debriefing;
382 extern float                    Brief_text_wipe_time_elapsed;
383
384 extern int Cur_brief_id;
385 extern int Briefing_voice_enabled;
386
387 extern int Num_brief_text_lines[MAX_TEXT_STREAMS];
388 extern int Top_brief_text_line;
389 extern int Current_screen;
390
391 // ------------------------------------------------------------------------
392 // External interface
393 // ------------------------------------------------------------------------
394 void brief_reset();
395 void debrief_reset(); 
396 void brief_close_map();
397 void brief_init_map();
398 void brief_init_screen(int multiplayer_flag);
399 void brief_render_map(int stage_num, float frametime);
400 void brief_set_new_stage(vector *pos, matrix *orient, int time, int stage_num);
401 void brief_camera_move(float frametime, int stage_num);
402 void brief_render_icon(int stage_num, int icon_num, float frametime, int selected = 0, float w_scale_factor = 1.0f, float h_scale_factor = 1.0f);
403 void brief_render_icon_line(int stage_num, int line_num);
404 void brief_init_icons();
405 void brief_load_icons();
406 void brief_unload_icons();
407 void brief_common_close();
408 void brief_reset_icons(int stage_num);
409 void brief_restart_text_wipe();
410 void brief_reset_last_new_stage();
411 void brief_blit_stage_num(int stage_num, int stage_max);
412
413 void brief_common_get_icon_dimensions(int *w, int *h, int type, int ship_class);
414
415 // voice streaming interface
416 void brief_voice_init();
417 void brief_voice_load_all();
418 void brief_voice_unload_all();
419 void brief_voice_play(int stage_num);
420 void brief_voice_stop(int stage_num);
421 void brief_voice_pause(int stage_num);
422 void brief_voice_unpause(int stage_num);
423
424 // fancy briefing style text functions for use in other modules.
425 int brief_color_text_init(char *src, int w, int instance = 0);
426 int brief_render_text(int line_offset, int x, int y, int h, float frametime, int instance = 0, int line_spacing = 0);
427
428 void cmd_brief_reset();
429
430 int brief_time_to_advance(int stage_num, float frametime);
431
432 #endif
433