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