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/Hud/HUD.h $
15 * Header file for functions that contain HUD functions at a high level
18 * Revision 1.3 2004/09/20 01:31:44 theoddone33
21 * Revision 1.2 2002/06/09 04:41:13 relnev
22 * added copyright header
24 * Revision 1.1.1.1 2002/05/03 03:28:12 root
28 * 9 8/09/99 3:14p Dave
29 * Make "launch" warning gauge draw in code.
31 * 8 8/01/99 12:39p Dave
32 * Added HUD contrast control key (for nebula).
34 * 7 7/24/99 1:54p Dave
35 * Hud text flash gauge. Reworked dead popup to use 4 buttons in red-alert
38 * 6 6/10/99 3:43p Dave
39 * Do a better job of syncing text colors to HUD gauges.
41 * 5 6/07/99 4:20p Andsager
42 * Add HUD color for tagged object. Apply to target and radar.
44 * 4 5/21/99 1:44p Andsager
45 * Add engine wash gauge
47 * 3 10/13/98 9:28a Dave
48 * Started neatening up freespace.h. Many variables renamed and
49 * reorganized. Added AlphaColors.[h,cpp]
51 * 2 10/07/98 10:53a Dave
54 * 1 10/07/98 10:49a Dave
56 * 64 8/28/98 3:28p Dave
57 * EMP effect done. AI effects may need some tweaking as required.
59 * 63 8/25/98 1:48p Dave
60 * First rev of EMP effect. Player side stuff basically done. Next comes
63 * 62 5/04/98 6:12p Lawrance
64 * Write generic function hud_end_string_at_first_hash_symbol(), to use in
65 * various spots on the HUD
67 * 61 4/30/98 6:04p Lawrance
68 * Make subspace gauge report "aborted" when ESC pressed while starting
71 * 60 4/23/98 1:49a Allender
72 * major rearm/repair fixes for multiplayer. Fixed respawning of AI ships
73 * to not respawn until 5 seconds after they die. Send escort information
76 * 59 4/20/98 12:36a Mike
77 * Make team vs. team work when player is hostile. Several targeting
80 * 58 4/13/98 12:50p Allender
81 * made rearm shortcut work more appropriately. Make countermeasure
82 * succeed work on clients in multiplayer
84 * 57 3/30/98 1:08a Lawrance
85 * Implement "blast" icon. Blink HUD icon when player ship is hit by a
88 * 56 3/19/98 5:05p Dave
89 * Put in support for targeted multiplayer text and voice messaging (all,
90 * friendly, hostile, individual).
92 * 55 3/17/98 12:29a Dave
93 * Put in hud support for rtvoice. Several ui interface changes.
95 * 54 3/14/98 4:59p Lawrance
96 * Totally rework HUD wingman status gauge to work with 5 arbitrary wings
98 * 53 3/11/98 12:13a Lawrance
99 * Pop up weapon gauge when rearm time is showing
101 * 52 3/09/98 4:22p Lawrance
102 * Don't do certain HUD functions when the hud is disabled
104 * 51 3/07/98 6:27p Lawrance
105 * Add support for disabled hud.
107 * 50 3/06/98 5:10p Allender
108 * made time to: field in extended targetbox use support time to dock code
109 * for all docking shpis. Only display for waypoints and docking (not
110 * undocking). Small fixups to message menu -- not allowing depart when
111 * disabled. Depart is now by default ignored for all non-small ships
113 * 49 2/23/98 6:49p Lawrance
114 * Use gr_aabitmap_ex() instead of clipping regions
116 * 48 2/12/98 4:58p Lawrance
117 * Change to new flashing method.
119 * 47 2/11/98 9:44p Allender
120 * rearm repair code fixes. hud support view shows abort status. New
121 * support ship killed message. More network stats
123 * 46 2/09/98 8:05p Lawrance
124 * Add new gauges: cmeasure success, warp-out, and missiontime
126 * 45 1/28/98 7:19p Lawrance
127 * Get fading/highlighting animations working
129 * 44 1/24/98 3:21p Lawrance
130 * Add flashing when hit, and correct association with the wingman status
133 * 43 1/21/98 7:20p Lawrance
134 * Make subsystem locking only work with line-of-sight, cleaned up locking
135 * code, moved globals to player struct.
137 * 42 1/20/98 12:52p Lawrance
138 * Draw talking head as alpha-color bitmap, black out region behind
141 * 41 1/19/98 10:01p Lawrance
142 * Implement "Electronics" missiles
144 * 40 1/15/98 5:23p Lawrance
145 * Add HUD gauge to indicate completed objectives.
147 * 39 1/14/98 11:07p Lawrance
148 * Hook in brightness slider to HUD config.
150 * 38 1/12/98 11:16p Lawrance
151 * Wonderful HUD config.
153 * 37 1/10/98 12:41a Lawrance
154 * start work on new HUD config
156 * 36 1/05/98 9:38p Lawrance
157 * Implement flashing HUD gauges.
159 * 35 1/02/98 9:10p Lawrance
160 * Big changes to how colors get set on the HUD.
162 * 34 12/18/97 8:46p Lawrance
163 * Move IFF_color definitions from HUD->ship, so FRED can use them.
165 * 33 12/01/97 12:27a Lawrance
166 * redo default alpha color for HUD, make it easy to modify in the future
168 * 32 11/17/97 6:37p Lawrance
169 * new gauges: extended target view, new lock triangles, support ship view
171 * 31 11/13/97 10:46p Lawrance
172 * implemented new escort view, damage view and weapons
174 * 30 11/13/97 6:15p Lawrance
175 * Add new weapons gauge
177 * 29 11/11/97 5:05p Lawrance
178 * use global value for target integrity, to avoid recalculation
180 * 28 11/11/97 11:06a Lawrance
181 * add function to convert a numbered string to use mono-spaced 1's
183 * 27 11/09/97 3:25p Lawrance
184 * increase default alpha color
186 * 26 11/05/97 11:19p Lawrance
187 * create an array of 16 HUD colors, that span the different alpha values
189 * 25 11/04/97 7:50p Lawrance
190 * supporting new HUD reticle and shield icons
192 * 24 10/11/97 6:38p Lawrance
193 * added functions to manage HUD animations
195 * 23 9/14/97 10:24p Lawrance
196 * add damage screen popup window
198 * 22 7/14/97 11:47a Lawrance
199 * add function to display hud messages (so navmap can call it)
201 * 21 6/11/97 1:12p John
202 * Started fixing all the text colors in the game.
204 * 20 6/06/97 4:41p John
205 * Fixed alpha colors to be smoothly integrated into gr_set_color_fast
208 * 19 6/05/97 6:47p John
209 * First pass at changing HUD translucency.
211 * 18 4/13/97 3:53p Lawrance
212 * separate out the non-rendering dependant portions of the HUD ( sounds,
213 * updating lock position, changing targets, etc) and put into
216 * 17 4/10/97 5:29p Lawrance
217 * hud rendering split up into hud_render_3d(), hud_render_2d() and
218 * hud_render_target_model()
220 * 16 4/07/97 3:50p Allender
221 * ability to assign > 1 ship to a hotkey. Enabled use of hotkeys in
222 * squadmate messaging
224 * 15 3/19/97 5:53p Lawrance
225 * integrating new Misc_sounds[] array (replaces old Game_sounds
228 * 14 1/13/97 5:36p Lawrance
229 * integrating new Game_sounds structure for general game sounds
231 * 13 1/07/97 6:56p Lawrance
234 * 12 1/02/97 7:12p Lawrance
235 * adding hooks for more sounds
237 * 11 11/26/96 2:35p John
238 * Made so you can change HUD colors.
240 * 10 11/19/96 10:16a Lawrance
241 * adding colors to header file
243 * 9 11/17/96 5:27p Lawrance
244 * added externs for globals that specify the HUD gauge colors
246 * 8 11/15/96 12:11a Lawrance
247 * took out old message scrolling and moved to HUDmessage
258 #include "hudmessage.h"
259 #include "hudgauges.h"
262 #define SCREEN_CENTER_X ((gr_screen.clip_left + gr_screen.clip_right) / 2.0f)
263 #define SCREEN_CENTER_Y ((gr_screen.clip_top + gr_screen.clip_bottom) / 2.0f)
267 typedef struct hud_anim
269 char name[MAX_FILENAME_LEN];
270 int first_frame; // the bitmap id for the first frame in the animation... note that
271 // all bitmap id's following this frame are numbered sequentially
272 int num_frames; // number of frames in the animation
273 int sx, sy; // screen (x,y) of top-left corner of animation
274 float total_time; // total time in seconds for the animation (depends on animation fps)
275 float time_elapsed; // time that has elapsed (in seconds) since animation started playing
278 typedef struct hud_frames
284 typedef struct hud_frames_info
290 #define HUD_NUM_COLOR_LEVELS 16
291 extern color HUD_color_defaults[HUD_NUM_COLOR_LEVELS];
293 // extern globals that will control the color of the HUD gauges
294 #define HUD_COLOR_ALPHA_USER_MAX 13 // max user-settable alpha, absolute max is 15
295 #define HUD_COLOR_ALPHA_USER_MIN 3 // min user-settable alpha, absolute min is 0
297 #define HUD_COLOR_ALPHA_MAX 15
298 #define HUD_COLOR_ALPHA_DEFAULT 8
300 #define HUD_BRIGHT_DELTA 7 // Level added to HUD_color_alpha to make brightness used for flashing
302 // hud macro for maybe flickering all gauges
303 #define GR_AABITMAP(a, b, c) { int jx, jy; if(emp_should_blit_gauge()) { gr_set_bitmap(a, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1); jx = b; jy = c; emp_hud_jitter(&jx, &jy); gr_aabitmap(jx, jy); } }
304 #define GR_AABITMAP_EX(a, b, c, d, e, f, g) { int jx, jy; if(emp_should_blit_gauge()) { gr_set_bitmap(a, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1); jx = b; jy = c; emp_hud_jitter(&jx, &jy); gr_aabitmap_ex(jx, jy, d, e, f, g); } }
306 extern int HUD_color_red;
307 extern int HUD_color_green;
308 extern int HUD_color_blue;
309 extern int HUD_color_alpha;
311 extern color HUD_color_debug;
313 // animations for damages gauges
314 extern hud_anim Target_static;
315 extern hud_anim Radar_static;
317 // Values used "wiggle" the HUD. In the 2D HUD case, the clip region accounts
318 // for these, but for the 3d-type hud stuff, you need to add these in manually.
319 extern float HUD_offset_x;
320 extern float HUD_offset_y;
322 // Global: integrity of player's target
323 extern float Pl_target_integrity;
325 void HUD_init_colors();
327 void hud_update_frame(); // updates hud systems not dependant on rendering
328 void HUD_render_3d(float frametime); // renders 3d dependant gauges
329 void HUD_render_2d(float frametime); // renders the 2d gauges
330 void hud_stop_looped_engine_sounds();
331 void hud_show_messages();
332 void hud_damage_popup_toggle();
334 // set the offset values for this render frame
335 void HUD_set_offsets(object *viewer_obj, int wiggedy_wack);
337 // Basically like gr_reset_clip only it accounts for hud jittering
338 void HUD_reset_clip();
340 // Basically like gr_set_clip only it accounts for hud jittering
341 void HUD_set_clip(int x, int y, int w, int h);
343 // do flashing text gauge
344 void hud_start_text_flash(char *txt, int t);
346 // convert a string to use mono spaced numbers
347 void hud_num_make_mono(char *num_str);
349 // cut any text off after (and including) '#' char
350 void hud_end_string_at_first_hash_symbol(char *src);
352 // functions for handling hud animations
353 void hud_anim_init(hud_anim *ha, int sx, int sy, char *filename);
354 int hud_anim_render(hud_anim *ha, float frametime, int draw_alpha=0, int loop=1, int hold_last=0, int reverse=0);
355 int hud_anim_load(hud_anim *ha);
356 void hud_anim_release(hud_anim *ha);
358 // flash text at the given y
359 void hud_show_text_flash_icon(char *txt, int y, int bright);
361 // functions for displaying the support view popup
362 void hud_support_view_start();
363 void hud_support_view_stop(int stop_now=0);
364 void hud_support_view_abort();
365 void hud_support_view_blit();
367 void HUD_init_hud_color_array();
369 // setting HUD colors
370 void hud_set_default_color();
371 void hud_set_iff_color(object *objp, int is_bright=0);
372 void hud_set_bright_color();
373 void hud_set_dim_color();
375 // HUD gauge functions
376 #define HUD_C_NONE -4
377 #define HUD_C_BRIGHT -3
379 #define HUD_C_NORMAL -1
380 void hud_set_gauge_color(int gauge_index, int bright_index = HUD_C_NONE);
381 int hud_gauge_active(int gauge_index);
382 void hud_gauge_start_flash(int gauge_index);
383 int hud_gauge_maybe_flash(int gauge_index);
386 void hud_init_popup_timers();
387 void hud_gauge_popup_start(int gauge_index, int time=4000);
388 int hud_gauge_is_popup(int gauge_index);
389 int hud_gauge_popup_active(int gauge_index);
391 // objective status gauge
392 void hud_add_objective_messsage(int type, int status);
394 int hud_team_matches_filter(int team_filter, int ship_team);
395 void hud_maybe_clear_head_area();
397 int hud_wing_index_from_ship(int shipnum);
398 int hud_wing_slot_from_name(char *name);
399 int hud_support_get_dock_time( int objnum );
400 void hud_show_radar();
401 void hud_show_target_model();
402 void hud_show_voice_status();
404 void hud_subspace_notify_abort();
406 // render multiplayer text message currently being entered if any
407 void hud_maybe_render_multi_text();
410 int hud_support_find_closest( int objnum );
413 void hud_toggle_contrast();
414 void hud_set_contrast(int high);
416 // Return mask of enemies.
417 // Works in team vs. team multiplayer.
418 int opposing_team_mask(int team_mask);
420 #endif /* __HUD_H__ */