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