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 the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef __MISSIONBRIEFCOMMON_H__
13 #define __MISSIONBRIEFCOMMON_H__
14 
15 #include "globalincs/globals.h"
16 
17 #include "anim/packunpack.h"
18 #include "graphics/generic.h"
19 #include "hud/hud.h"
20 #include "utils/unicode.h"
21 
22 #define MAX_TEXT_STREAMS	2		// how many concurrent streams of text can be displayed
23 
24 // ------------------------------------------------------------------------
25 // names for the icons that can appear in the briefing.  If you modify this list,
26 // update the Icons_names[] string array located in MissionParse.cpp
27 // ------------------------------------------------------------------------
28 #define MIN_BRIEF_ICONS						35		// keep up to date
29 
30 #define ICON_FIGHTER							0
31 #define ICON_FIGHTER_WING					1
32 #define ICON_CARGO							2
33 #define ICON_CARGO_WING						3
34 #define ICON_LARGESHIP						4
35 #define ICON_LARGESHIP_WING				5
36 #define ICON_CAPITAL							6
37 #define ICON_PLANET							7
38 #define ICON_ASTEROID_FIELD				8
39 #define ICON_WAYPOINT						9
40 #define ICON_SUPPORT_SHIP					10
41 #define ICON_FREIGHTER_NO_CARGO			11
42 #define ICON_FREIGHTER_WITH_CARGO		12
43 #define ICON_FREIGHTER_WING_NO_CARGO	13
44 #define ICON_FREIGHTER_WING_WITH_CARGO	14
45 #define ICON_INSTALLATION					15
46 #define ICON_BOMBER							16
47 #define ICON_BOMBER_WING					17
48 #define ICON_CRUISER							18
49 #define ICON_CRUISER_WING					19
50 #define ICON_UNKNOWN							20
51 #define ICON_UNKNOWN_WING					21
52 #define ICON_FIGHTER_PLAYER				22
53 #define ICON_FIGHTERW_PLAYER				23
54 #define ICON_BOMBER_PLAYER					24
55 #define ICON_BOMBERW_PLAYER				25
56 #define ICON_KNOSSOS_DEVICE				26
57 #define ICON_TRANSPORT_WING				27
58 #define ICON_CORVETTE						28
59 #define ICON_GAS_MINER						29
60 #define ICON_AWACS							30
61 #define ICON_SUPERCAP						31
62 #define ICON_SENTRYGUN						32
63 #define ICON_JUMP_NODE						33
64 #define ICON_TRANSPORT						34
65 
66 typedef struct briefing_icon_info {
67 	generic_anim	regular;
68 	hud_anim		fade;
69 	hud_anim		highlight;
70 } briefing_icon_type;
71 
72 extern SCP_vector<briefing_icon_info> Briefing_icon_info;
73 
74 struct brief_icon;
75 extern briefing_icon_info *brief_get_icon_info(brief_icon *bi);
76 
77 
78 
79 // Moving out of missionbriefcommon.cpp so it can be referenced elsewhere -MageKing17
80 extern const float		BRIEF_TEXT_WIPE_TIME;		// time in seconds for wipe to occur
81 
82 // ------------------------------------------------------------------------
83 // Structures to hold briefing data
84 // ------------------------------------------------------------------------
85 
86 #define	MAX_BRIEF_LINES		70
87 #define	MAX_BRIEF_LINE_LEN	512		// max number of chars in a briefing line. Increased to allow for multibyte characters to fill a briefing line
88 #define	MAX_BRIEF_LINE_W_640		375		// max width of line in pixels in 640x480 mode
89 #define	MAX_BRIEF_LINE_W_1024	600		// max width of line in pixels in 1024x768 mode
90 
91 #define	MAX_DEBRIEF_LINES		60
92 #define	MAX_DEBRIEF_LINE_LEN	512		// max number of chars in a debriefing line
93 #define	MAX_DEBRIEF_LINE_W	500		// max width of line in pixels
94 
95 #define	MAX_ICON_TEXT_LEN			1024		// max number of chars for icon info
96 #define	MAX_ICON_TEXT_LINES		30
97 #define	MAX_ICON_TEXT_LINE_LEN	512	// max number of chars in icon info line
98 #define	MAX_ICON_TEXT_LINE_W		170		// max width of line in pixels
99 
100 #define	MAX_STAGE_ICONS			20
101 #define	MAX_BRIEF_STAGES			15
102 #define	MAX_DEBRIEF_STAGES		40
103 #define	MAX_LABEL_LEN				64
104 
105 #define		BI_HIGHLIGHT		(1<<0)
106 #define		BI_SHOWHIGHLIGHT	(1<<1)
107 #define		BI_FADEIN			(1<<2)
108 #define		BI_MIRROR_ICON		(1<<3)	// mirror the briefing icon so it points the other way - phreak
109 #define		BI_USE_WING_ICON	(1<<4)	// use wing variant of briefing icon
110 #define		BI_USE_CARGO_ICON	(1<<5)	// use cargo variant of briefing icon
111 
112 typedef struct brief_icon {
113 	int		x,y,w,h;
114 	int		hold_x, hold_y;	// 2D screen position of icon, used to place animations
115 	int		ship_class;
116 	int		modelnum;
117 	int		model_instance_num;
118 	float		radius;
119 	int		type;					// ICON_* defines from MissionBriefCommon.h
120 	int		bitmap_id;
121 	int		id;
122 	int		team;
123 	vec3d	pos;
124 	char		label[MAX_LABEL_LEN];
125 	char		closeup_label[MAX_LABEL_LEN];
126 //	char		text[MAX_ICON_TEXT_LEN];
127 	hud_anim	fadein_anim;
128 	hud_anim	fadeout_anim;
129 	hud_anim	highlight_anim;
130 	int		flags;				// BI_* flags defined above
131 } brief_icon;
132 
133 #define MAX_BRIEF_STAGE_LINES		20
134 
135 typedef struct brief_line {
136 	int start_icon;		// index into icons[], where line starts
137 	int end_icon;		// index into icons[], where line ends
138 } brief_line;
139 
140 #define BS_FORWARD_CUT		(1<<0)
141 #define BS_BACKWARD_CUT		(1<<1)
142 
143 class brief_stage
144 {
145 public:
146 	SCP_string	text;
147 	char			voice[MAX_FILENAME_LEN];
148 	vec3d		camera_pos;
149 	matrix		camera_orient;
150 	int			camera_time;		// ms
151 	int			flags;				// see BS_ flags above
152 	int			formula;
153 	int			num_icons;
154 	brief_icon	*icons;
155 	int			num_lines;
156 	brief_line	*lines;
157 
brief_stage()158 	brief_stage( )
159 		: text( ), camera_time( 0 ), flags( 0 ), formula( -1 ),
160 		  num_icons( 0 ), icons( NULL ), num_lines( 0 ), lines( NULL )
161 	{
162 		voice[ 0 ] = 0;
163 		camera_pos = vmd_zero_vector;
164 		camera_orient = vmd_identity_matrix;
165 	}
166 };
167 
168 class debrief_stage
169 {
170 public:
171 	int			formula;
172 	SCP_string	text;
173 	char			voice[MAX_FILENAME_LEN];
174 	SCP_string	recommendation_text;
175 
debrief_stage()176 	debrief_stage( )
177 		: formula( -1 ), text( ),
178 		  recommendation_text( )
179 	{
180 		voice[ 0 ] = 0;
181 	}
182 };
183 
184 class briefing
185 {
186 public:
187 	int			num_stages;
188 	brief_stage	stages[MAX_BRIEF_STAGES];
189 	char		background[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN];
190 	char		ship_select_background[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN];
191 	char		weapon_select_background[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN];
192 
briefing()193 	briefing()
194 		: num_stages(0)
195 	{
196 		memset(background, 0, GR_NUM_RESOLUTIONS * MAX_FILENAME_LEN * sizeof(char));
197 	}
198 };
199 
200 class debriefing
201 {
202 public:
203 	int				num_stages;
204 	debrief_stage	stages[MAX_DEBRIEF_STAGES];
205 	char			background[GR_NUM_RESOLUTIONS][MAX_FILENAME_LEN];
206 
debriefing()207 	debriefing()
208 		: num_stages(0)
209 	{}
210 };
211 
212 
213 
214 // Code to free/init the above structures between levels:
215 
216 // --------------------------------------------------------------------------------------
217 // Does one time initialization of the briefing and debriefing structures.
218 // Namely setting all malloc'ble pointers to NULL.  Called once at game startup.
219 void mission_brief_common_init();
220 
221 //--------------------------------------------------------------------------------------
222 // Frees all the memory allocated in the briefing and debriefing structures
223 // and sets all pointers to NULL.
224 void mission_brief_common_reset();
225 void mission_debrief_common_reset();
226 
227 
228 // --------------------------------------------------------------------------------------
229 // briefing screen
230 // --------------------------------------------------------------------------------------
231 extern int Brief_bmap_coords[GR_NUM_RESOLUTIONS][2];
232 extern int Brief_grid_coords[GR_NUM_RESOLUTIONS][4];
233 extern int Brief_text_coords[GR_NUM_RESOLUTIONS][4];
234 extern int Brief_text_max_lines[GR_NUM_RESOLUTIONS];
235 extern const char *Brief_static_name[GR_NUM_RESOLUTIONS];
236 extern int Brief_static_coords[GR_NUM_RESOLUTIONS][2];
237 
238 // Needed for Fred
239 #define BRIEF_GRID3_X1						42
240 #define BRIEF_GRID3_Y1						122
241 #define BRIEF_GRID0_X2						585
242 #define BRIEF_GRID0_Y2						371
243 #define BRIEF_GRID_W							(BRIEF_GRID0_X2-BRIEF_GRID3_X1+1)
244 #define BRIEF_GRID_H							(BRIEF_GRID0_Y2-BRIEF_GRID3_Y1+1)
245 /*
246 #define BRIEF_GRID0_X1						63
247 #define BRIEF_GRID0_Y1						122
248 #define BRIEF_GRID1_X1						575
249 #define BRIEF_GRID1_Y1						122
250 #define BRIEF_GRID2_X1						63
251 #define BRIEF_GRID2_Y1						350
252 
253 #define BRIEF_TEXT_X1						0
254 #define BRIEF_TEXT_Y1						397
255 #define BRIEF_TEXT_X2						441
256 #define BRIEF_TEXT_Y2						477
257 #define BRIEF_TEXT_BEGIN_X					50
258 #define BRIEF_TEXT_BEGIN_Y					414
259 #define BRIEF_TEXT_H							54
260 
261 */
262 
263 typedef struct brief_screen
264 {
265 	int map_x1, map_x2, map_y1, map_y2;
266 /*	int btext_x1, btext_x2, btext_y1, btext_y2;
267 	int cup_x1, cup_x2, cup_y1, cup_y2;
268 	int cupinfo_x1, cupinfo_x2, cupinfo_y1, cupinfo_y2;*/
269 } brief_sceen;
270 
271 extern brief_screen bscreen;
272 
273 // ------------------------------------------------------------------------
274 // Global briefing/debriefing data
275 // ------------------------------------------------------------------------
276 extern briefing		Briefings[MAX_TVT_TEAMS];
277 extern debriefing		Debriefings[MAX_TVT_TEAMS];
278 extern briefing		*Briefing;
279 extern debriefing		*Debriefing;
280 extern float			Brief_text_wipe_time_elapsed;
281 
282 extern int Cur_brief_id;
283 extern bool Briefing_voice_enabled;
284 
285 extern int Num_brief_text_lines[MAX_TEXT_STREAMS];
286 extern int Top_brief_text_line;
287 extern int Current_screen;
288 
289 // ------------------------------------------------------------------------
290 // External interface
291 // ------------------------------------------------------------------------
292 void brief_reset();
293 void debrief_reset();
294 void brief_init_screen(int multiplayer_flag);
295 void brief_render_map(int stage_num, float frametime);
296 void brief_set_new_stage(vec3d *pos, matrix *orient, int time, int stage_num);
297 void brief_camera_move(float frametime, int stage_num);
298 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);
299 void brief_render_icon_line(int stage_num, int line_num);
300 void brief_init_map();
301 void brief_icons_init();
302 void brief_common_close();
303 void brief_reset_icons(int stage_num);
304 void brief_restart_text_wipe();
305 void brief_reset_last_new_stage();
306 void brief_blit_stage_num(int stage_num, int stage_max);
307 
308 void brief_common_get_icon_dimensions(int *w, int *h, brief_icon *bi);
309 
310 // voice streaming interface
311 void brief_voice_init();
312 void brief_voice_load_all();
313 void brief_voice_unload_all();
314 void brief_voice_play(int stage_num);
315 void brief_voice_stop(int stage_num);
316 void brief_voice_pause(int stage_num);
317 void brief_voice_unpause(int stage_num);
318 
319 // fancy briefing style text functions for use in other modules.
320 int brief_color_text_init(const char *src, int w, const char default_color = '\0', int instance = 0, int max_lines = MAX_BRIEF_LINES, const bool append = false);
321 int brief_render_text(int line_offset, int x, int y, int h, float frametime, int instance = 0, int line_spacing = 0);
322 
323 void cmd_brief_reset();
324 
325 int brief_time_to_advance(int stage_num);
326 
327 bool brief_verify_color_tag(unicode::codepoint_t color_tag);
328 
329 #endif
330