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