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/HUDconfig.cpp $
15 * C module to handle HUD configuration
18 * Revision 1.7 2005/03/29 02:18:47 taylor
19 * Various 64-bit platform fixes
20 * Fix compiler errors with MAKE_FS1 and fix gr_set_bitmap() too
21 * Make sure that turrets can fire at asteroids for FS1 (needed for a couple missions)
22 * Streaming audio support (big thanks to Pierre Willenbrock!!)
23 * Removed dependance on strings.tbl for FS1 since we don't actually need it now
25 * Revision 1.6 2004/09/20 01:31:44 theoddone33
28 * Revision 1.5 2003/05/25 02:30:42 taylor
31 * Revision 1.4 2002/06/09 04:41:21 relnev
32 * added copyright header
34 * Revision 1.3 2002/06/01 07:12:33 relnev
35 * a few NDEBUG updates.
37 * removed a few warnings.
39 * Revision 1.2 2002/05/07 03:16:45 theoddone33
40 * The Great Newline Fix
42 * Revision 1.1.1.1 2002/05/03 03:28:09 root
46 * 19 10/25/99 5:43p Jefff
47 * reassigned some xstr ids
49 * 18 10/14/99 2:50p Jefff
52 * 17 9/02/99 5:09p Jefff
53 * disabled options now draw as a dark gray color
55 * 16 9/01/99 11:16a Dave
56 * Reverse direction of HUD config RGB sliders.
58 * 15 8/19/99 3:17p Dave
59 * Fixed talking head disappearing.
61 * 14 8/19/99 2:33p Dave
62 * Make sure support gauge and net lag gauge are configurable.
64 * 13 8/16/99 5:25p Dave
65 * New hud config. Whee!
67 * 12 8/16/99 4:04p Dave
68 * Big honking checkin.
70 * 11 7/30/99 10:31p Dave
71 * Added comm menu to the configurable hud files.
73 * 10 7/30/99 11:05a Jasenw
74 * Fixed hud config for new text warning gauge,
76 * 9 7/24/99 1:54p Dave
77 * Hud text flash gauge. Reworked dead popup to use 4 buttons in red-alert
80 * 8 7/15/99 9:20a Andsager
81 * FS2_DEMO initial checkin
83 * 7 6/08/99 2:33p Dave
84 * Fixed release build warning. Put in hud config stuff.
86 * 6 6/08/99 1:14a Dave
87 * Multi colored hud test.
89 * 5 1/30/99 5:08p Dave
90 * More new hi-res stuff.Support for nice D3D textures.
92 * 4 10/13/98 9:28a Dave
93 * Started neatening up freespace.h. Many variables renamed and
94 * reorganized. Added AlphaColors.[h,cpp]
96 * 3 10/07/98 11:28a Dave
97 * Removed wacky pragma.
99 * 2 10/07/98 10:53a Dave
102 * 1 10/07/98 10:49a Dave
104 * 72 8/25/98 1:48p Dave
105 * First rev of EMP effect. Player side stuff basically done. Next comes
108 * 71 6/09/98 10:31a Hoffoss
109 * Created index numbers for all xstr() references. Any new xstr() stuff
110 * added from here on out should be added to the end if the list. The
111 * current list count can be found in FreeSpace.cpp (search for
114 * 70 6/01/98 11:43a John
115 * JAS & MK: Classified all strings for localization.
117 * 69 5/24/98 9:01p Lawrance
118 * Add commit sounds when accept is pressed
120 * 68 5/23/98 3:31p Dave
121 * Tweaked pxo code. Fixed observer HUD stuff.
123 * 67 5/08/98 10:12a Lawrance
124 * play sound for auto-target toggle, don't display HUD message
126 * 66 4/29/98 6:00p Dave
127 * Fixed chatbox font colors. Made observer offscreen indicators work.
128 * Numerous small UI fixes. Fix rank limitations for mp games.
130 * 65 4/20/98 12:04a Lawrance
131 * tweak how button light up
133 * 64 4/16/98 4:07p Hoffoss
134 * Fixed bug with palette reseting when loading a new pilot. Also made
135 * barracks default to palette merging mode.
137 * 63 4/16/98 10:48a Lawrance
138 * reposition a couple of gauges
140 * 62 4/14/98 6:16p Lawrance
141 * Fix bug that was preventing non-green HUD color from getting set.
143 * 61 4/12/98 5:32p Lawrance
144 * don't show talking head in demo version of hud config
146 * 60 4/10/98 12:07a Lawrance
147 * Fix up talking head gauge.
149 * 59 4/08/98 10:15a Lawrance
150 * allow kills gauge to be popup
152 * 58 4/08/98 1:18a Lawrance
153 * Add in kills gauge art to HUD config.
155 * 57 4/05/98 7:42p Lawrance
158 * 56 4/03/98 3:13p Dave
159 * More work on udp reliable transport. Fixed observer hud offset problem.
160 * Made observer join and ingame join work again. Put subnet broadcasting
163 * 55 4/01/98 6:46p Lawrance
164 * default damage popup to on
166 * 54 3/31/98 11:47p Lawrance
167 * Add popup functionality for the countermeasure gauge.
169 * 53 3/30/98 4:48p Lawrance
170 * Turn on offscreen indicator range by default
172 * 52 3/26/98 5:45p Lawrance
173 * Added new gauges to HUD config
175 * 51 3/15/98 4:17p Dave
176 * Fixed oberver hud problems. Put in handy netplayer macros. Reduced size
177 * of network orientation matrices.
179 * 50 3/12/98 5:45p Dave
180 * Put in new observer HUD. Made it possible for observers to join at the
181 * beginning of a game and follow it around as an observer full-time.
183 * 49 3/11/98 12:13a Lawrance
184 * redraw pressed buttons
186 * 48 3/05/98 12:39a Lawrance
187 * show comma in 10000
189 * 47 2/22/98 4:30p John
190 * More string externalization classification
192 * 46 2/22/98 4:17p John
193 * More string externalization classification... 190 left to go!
195 * 45 2/22/98 12:19p John
196 * Externalized some strings
198 * 44 1/23/98 6:24p Lawrance
199 * Implement wingman status gauge
201 * 43 1/22/98 10:45p Lawrance
202 * Add coutermeasures and objective display to hud config.
204 * 42 1/19/98 11:37p Lawrance
205 * Fixing Optimization build warnings
207 * 41 1/17/98 10:02p Lawrance
208 * Fix bug with damage popup that would sometimes display with <none>.
210 * 40 1/17/98 1:30a Lawrance
211 * Add countermeasure gauge
213 * 39 1/15/98 5:10p Allender
214 * ton of interface changes. chatbox in multiplayer now behaves
215 * differently than before. It's always active in any screen that uses
216 * it. Only non-printatble characters will get passed back out from
219 * 38 1/14/98 11:07p Lawrance
220 * Hook in brightness slider to HUD config.
222 * 37 1/14/98 6:42p Hoffoss
223 * Massive changes to UI code. A lot cleaner and better now. Did all
224 * this to get the new UI_DOT_SLIDER to work properly, which the old code
225 * wasn't flexible enough to handle.
227 * 36 1/14/98 12:25p Lawrance
228 * center gauge text, use correct game palette.
230 * 35 1/13/98 5:33p Lawrance
231 * Tweaking HUD config.
233 * 34 1/13/98 2:20p John
234 * Added code to load palette based on hud color. Added code to turn off
235 * nebulas using detail. Added code in WinMain to time out after waiting
236 * too long for window creation.
238 * 33 1/13/98 10:22a Lawrance
239 * Integrate new art changes.
241 * 32 1/12/98 11:16p Lawrance
242 * Wonderful HUD config.
244 * 31 1/10/98 12:41a Lawrance
245 * start work on new HUD config
247 * 30 1/05/98 9:38p Lawrance
248 * Implement flashing HUD gauges.
250 * 29 1/02/98 9:10p Lawrance
251 * Big changes to how colors get set on the HUD.
253 * 28 12/16/97 9:13p Lawrance
254 * Integrate new gauges into HUD config.
256 * 27 12/01/97 12:27a Lawrance
257 * redo default alpha color for HUD, make it easy to modify in the future
265 #include "hudconfig.h"
266 #include "freespace.h"
267 #include "gamesequence.h"
278 #include "hudobserver.h"
280 #include "missionshipchoice.h"
282 #include "alphacolors.h"
286 //////////////////////////////////////////////////////////////////////////////
288 //////////////////////////////////////////////////////////////////////////////
290 #define MAX_HCF_FILES 30
291 int HC_num_files = -1; // num known hcf files
292 int HC_current_file = -1; // current hcf file
293 char *HC_filenames[MAX_HCF_FILES];
295 char HC_fname[MAX_FILENAME_LEN+1] = "";
296 UI_INPUTBOX HC_fname_input;
297 int HC_fname_coords[GR_NUM_RESOLUTIONS][4] = {
306 HUD_CONFIG_TYPE HUD_config; // Player HUD configuration
308 // specify the max distance that the radar should detect objects
309 // See RR_ #defines in HUDconfig.h.
310 float Radar_ranges[RR_MAX_RANGES] = {
313 10000000.0f, // infinity
316 const char *Radar_range_text(int n)
318 #if RR_MAX_RANGES != 3
319 #error Number of ranges is wrong!
324 return XSTR( "2000 M", 246);
326 return XSTR( "10,000 M", 247);
328 return XSTR( "infinity", 248);
333 // default flags for observer HUD
334 int HUD_observer_default_flags =
336 (1<<HUD_CENTER_RETICLE) |
337 (1<<HUD_OFFSCREEN_INDICATOR) |
338 (1<<HUD_MESSAGE_LINES) |
339 (1<<HUD_HOSTILE_TRIANGLE) |
340 (1<<HUD_TARGET_TRIANGLE) |
341 (1<<HUD_TARGET_MINI_ICON) |
342 (1<<HUD_TARGET_MONITOR)
345 int HUD_observer_default_flags2 = {
346 (1<<(HUD_OFFSCREEN_RANGE - 32))
349 // default flags for regular HUD
350 int HUD_config_default_flags =
352 (1<<HUD_LEAD_INDICATOR) |
353 (1<<HUD_ORIENTATION_TEE) |
354 (1<<HUD_HOSTILE_TRIANGLE) |
355 (1<<HUD_TARGET_TRIANGLE) |
356 (1<<HUD_MISSION_TIME) |
357 (1<<HUD_RETICLE_CIRCLE) |
358 (1<<HUD_THROTTLE_GAUGE) |
360 (1<<HUD_TARGET_MONITOR) |
361 (1<<HUD_CENTER_RETICLE) |
362 (1<<HUD_TARGET_MONITOR_EXTRA_DATA) |
363 (1<<HUD_TARGET_SHIELD_ICON) |
364 (1<<HUD_PLAYER_SHIELD_ICON) |
366 (1<<HUD_AUTO_TARGET) |
367 (1<<HUD_AUTO_SPEED) |
368 (1<<HUD_WEAPONS_GAUGE) |
369 (1<<HUD_ESCORT_VIEW) |
370 (1<<HUD_DIRECTIVES_VIEW) |
371 (1<<HUD_THREAT_GAUGE) |
372 (1<<HUD_AFTERBURNER_ENERGY) |
373 (1<<HUD_WEAPONS_ENERGY) |
374 (1<<HUD_WEAPON_LINKING_GAUGE) |
375 (1<<HUD_TARGET_MINI_ICON) |
376 (1<<HUD_OFFSCREEN_INDICATOR) |
377 (1<<HUD_TALKING_HEAD) |
378 (1<<HUD_DAMAGE_GAUGE) |
379 (1<<HUD_MESSAGE_LINES) |
380 (1<<HUD_MISSILE_WARNING_ARROW) |
381 (1<<HUD_CMEASURE_GAUGE) |
382 (1<<HUD_OBJECTIVES_NOTIFY_GAUGE) |
383 (1<<HUD_WINGMEN_STATUS)
386 int HUD_config_default_flags2 =
388 (1<<(HUD_OFFSCREEN_RANGE-32)) |
389 (1<<(HUD_KILLS_GAUGE-32)) |
390 (1<<(HUD_ATTACKING_TARGET_COUNT-32)) |
391 (1<<(HUD_SUPPORT_GAUGE-32)) |
392 (1<<(HUD_LAG_GAUGE-32))
395 // bits to tell whether a given gauge should be treated as pop-up or not
396 int HUD_default_popup_mask =
398 0 | // (1<<HUD_LEAD_INDICATOR) |
399 0 | // (1<<HUD_ORIENTATION_TEE) |
400 0 | // (1<<HUD_HOSTILE_TRIANGLE) |
401 0 | // (1<<HUD_TARGET_TRIANGLE) |
402 0 | // (1<<HUD_MISSION_TIME) |
403 0 | // (1<<HUD_RETICLE_CIRCLE) |
404 0 | // (1<<HUD_THROTTLE_GAUGE) |
405 0 | // (1<<HUD_RADAR) |
406 0 | // (1<<HUD_TARGET_MONITOR) |
407 0 | // (1<<HUD_CENTER_RETICLE) |
408 0 | // (1<<HUD_TARGET_MONITOR_EXTRA_DATA) |
409 0 | // (1<<HUD_TARGET_SHIELD_ICON) |
410 0 | // (1<<HUD_PLAYER_SHIELD_ICON) |
411 0 | // (1<<HUD_ETS_GAUGE) |
412 0 | // (1<<HUD_AUTO_TARGET) |
413 0 | // (1<<HUD_AUTO_SPEED) |
414 0 | // (1<<HUD_WEAPONS_GAUGE) |
415 0 | // (1<<HUD_ESCORT_VIEW) |
416 0 | // (1<<HUD_DIRECTIVES_VIEW) |
417 0 | // (1<<HUD_THREAT_GAUGE) |
418 0 | // (1<<HUD_AFTERBURNER_ENERGY) |
419 0 | // (1<<HUD_WEAPONS_ENERGY) |
420 0 | // (1<<HUD_WEAPON_LINKING_GAUGE) |
421 0 | // (1<<HUD_TARGET_MINI_ICON) |
422 0 | //(1<<HUD_OFFSCREEN_INDICATOR)
426 0 | // missile warning arrow
427 0 | // countermeasures
431 int HUD_default_popup_mask2 =
433 0 | // offscreen indicator range
438 void hud_config_color_save(const char *name);
439 void hud_config_select_all_toggle(int toggle);
441 int HC_select_all = 0;
443 //////////////////////////////////////////////////////////////////////////////
445 //////////////////////////////////////////////////////////////////////////////
447 const char *Hud_config_fname[GR_NUM_RESOLUTIONS] = {
452 const char *Hud_config_mask_fname[GR_NUM_RESOLUTIONS] = {
457 struct HC_gauge_region
459 const char *filename;
469 HC_gauge_region(const char *name, int x1, int y1, int h, int iff, int cp, int b, int nf, int cl) : filename(name), x(x1), y(y1), hotspot(h), use_iff(iff), can_popup(cp), bitmap(b), nframes(nf), color(cl){}
473 struct HC_gauge_region HC_gauge_regions[GR_NUM_RESOLUTIONS][NUM_HUD_GAUGES] =
478 HC_gauge_region("HG_07", 377, 106, 7, 1, 0, -1, 4, 2), // lead indicator
479 HC_gauge_region("HG_08", 288, 153, 8, 1, 0, -1, 4, 2), // orientation tee
480 HC_gauge_region("HG_09", 312, 141, 9, 1, 0, -1, 4, 1), // hostile triangle
481 HC_gauge_region("HG_11", 362, 141, 11, 1, 0, -1, 4, 2), // target triangle
482 HC_gauge_region("HG_41", 530, 364, 41, 0, 0, -1, 0, 0), // mission time
483 HC_gauge_region("none", -1, -1, 0, 0, 0, -1, 0, 0), // reticle circle?
484 HC_gauge_region("HG_14", 272, 218, 14, 0, 0, -1, 0, 0), // throttle gauge
485 HC_gauge_region("HG_20", 301, 307, 20, 0, 0, -1, 0, 0), // radar
486 HC_gauge_region("HG_04", 126, 271, 4, 0, 0, -1, 0, 0), // target monitor
487 HC_gauge_region("HG_12", 335, 212, 12, 0, 0, -1, 0, 0), // center of reticle
488 HC_gauge_region("HG_03", 126, 246, 3, 0, 0, -1, 0, 0), // extra target data
489 HC_gauge_region("HG_19", 224, 322, 19, 0, 0, -1, 0, 0), // target shield icon
490 HC_gauge_region("HG_21", 403, 322, 21, 0, 0, -1, 0, 0), // player shield icon
491 HC_gauge_region("HG_24", 485, 315, 24, 0, 1, -1, 0, 0), // ets gauge
492 HC_gauge_region("HG_25", 523, 315, 25, 0, 1, -1, 0, 0), // auto target
493 HC_gauge_region("HG_26", 523, 332, 26, 0, 1, -1, 0, 0), // auto speed
494 HC_gauge_region("HG_23", 467, 241, 23, 0, 1, -1, 0, 0), // weapons gauge
495 HC_gauge_region("HG_22", 460, 196, 22, 0, 1, -1, 0, 0), // escort view
496 HC_gauge_region("HG_02", 126, 175, 2, 0, 0, -1, 0, 0), // directives view
497 HC_gauge_region("HG_10", 331, 149, 10, 0, 0, -1, 0, 0), // threat gauge
498 HC_gauge_region("HG_13", 241, 235, 13, 0, 0, -1, 0, 0), // afterburner energy
499 HC_gauge_region("HG_17", 412, 235, 17, 0, 0, -1, 0, 0), // weapons energy
500 HC_gauge_region("HG_16", 396, 226, 16, 0, 0, -1, 0, 0), // weapon linking
501 HC_gauge_region("HG_15", 333, 253, 15, 0, 1, -1, 0, 0), // target mini icon (shield)
502 HC_gauge_region("HG_05", 405, 52, 5, 1, 0, -1, 4, 2), // offscreen indicator
503 HC_gauge_region("HG_01", 126, 76, 1, 0, 0, -1, 0, 0), // talking head
504 HC_gauge_region("HG_06", 292, 78, 6, 0, 1, -1, 0, 0), // damage gauge
505 HC_gauge_region("HG_00", 126, 63, 0, 0, 0, -1, 0, 0), // message lines
506 HC_gauge_region("HG_18", 313, 283, 18, 1, 0, -1, 4, 3), // locked missile direction
507 HC_gauge_region("HG_40", 467, 291, 40, 0, 1, -1, 0, 0), // cmeasure gauge
508 HC_gauge_region("none", -1, -1, -1, 0, 0, -1, 0, 0), // objectives notify gauge
509 HC_gauge_region("HG_39", 504, 153, 39, 0, 0, -1, 0, 0), // wingman status gauge
510 HC_gauge_region("HG_38", 405, 59, 38, 1, 0, -1, 4, 2), // offscreen indicator range
511 HC_gauge_region("HG_42", 467, 303, 42, 0, 1, -1, 0, 0), // kills gauge
512 HC_gauge_region("HG_45", 317, 106, 45, 1, 0, -1, 4, 1), // attacking target count
513 HC_gauge_region("none", -1, -1, -1, 0, 0, -1, 0, 0), // text flash gauge
514 HC_gauge_region("none", -1, -1, -1, 0, 0, -1, 0, 0), // comm menu
515 HC_gauge_region("none", -1, -1, -1, 0, 0, -1, 0, 0), // support view gauge
516 HC_gauge_region("none", -1, -1, -1, 0, 0, -1, 0, 0), // netlag icon gauge
518 HC_gauge_region("HCB_35", 407, 69, 35, 1, 0, -1, 0, 2), // lead indicator
519 HC_gauge_region("HCB_36", 305, 119, 36, 1, 0, -1, 0, 2), // orientation tee
520 HC_gauge_region("none", 1, 1, -1, 1, 0, -1, 0, 0), // hostile triangle
521 HC_gauge_region("HCB_37", 391, 107, 37, 1, 0, -1, 0, 2), // target triangle
522 HC_gauge_region("HCB_63", 575, 352, 63, 0, 0, -1, 0, 0), // mission time
523 HC_gauge_region("none", 1, 1, 1, 0, 0, -1, 0, 0), // reticle circle?
524 HC_gauge_region("HCB_40", 285, 146, 40, 0, 0, -1, 0, 0), // throttle gauge
525 HC_gauge_region("HCB_50", 317, 291, 50, 0, 0, -1, 0, 0), // radar
526 HC_gauge_region("HCB_31", 123, 249, 31, 0, 0, -1, 0, 0), // target monitor
527 HC_gauge_region("HCB_41", 361, 188, 41, 0, 0, -1, 0, 0), // center of reticle
528 HC_gauge_region("HCB_30", 123, 221, 30, 0, 0, -1, 0, 0), // extra target data
529 HC_gauge_region("HCB_49", 237, 303, 49, 0, 0, -1, 0, 0), // target shield icon
530 HC_gauge_region("HCB_51", 435, 304, 51, 0, 0, -1, 0, 0), // player shield icon
531 HC_gauge_region("HCB_58", 524, 299, 58, 0, 1, -1, 0, 0), // ets gauge
532 HC_gauge_region("HCB_61", 566, 299, 61, 0, 1, -1, 0, 0), // auto target
533 HC_gauge_region("HCB_62", 566, 317, 62, 0, 1, -1, 0, 0), // auto speed
534 HC_gauge_region("HCB_55", 504, 216, 55, 0, 1, -1, 0, 0), // weapons gauge
535 HC_gauge_region("HCB_54", 496, 166, 54, 0, 1, -1, 0, 0), // escort view
536 HC_gauge_region("HCB_29", 123, 142, 29, 0, 0, -1, 0, 0), // directives view
537 HC_gauge_region("HCB_43", 398, 147, 43, 0, 0, -1, 0, 0), // threat gauge
538 HC_gauge_region("HCB_39", 250, 212, 39, 0, 0, -1, 0, 0), // afterburner energy
539 HC_gauge_region("HCB_44", 449, 212, 44, 0, 0, -1, 0, 0), // weapons energy
540 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // weapon linking
541 HC_gauge_region("HCB_42", 356, 232, 42, 0, 1, -1, 0, 0), // target mini icon (shield)
542 HC_gauge_region("HCB_34", 438, 5, 34, 1, 0, -1, 0, 2), // offscreen indicator
543 HC_gauge_region("HCB_28", 123, 31, 28, 0, 0, -1, 0, 0), // talking head
544 HC_gauge_region("HCB_32", 309, 33, 32, 0, 1, -1, 0, 0), // damage gauge
545 HC_gauge_region("HCB_27", 124, 19, 27, 0, 0, -1, 0, 0), // message lines
546 HC_gauge_region("HCB_45", 307, 249, 45, 1, 0, -1, 0, 1), // missile warnings
547 HC_gauge_region("HCB_56", 505, 271, 56, 0, 1, -1, 0, 0), // cmeasure gauge
548 HC_gauge_region("HCB_33", 309, 87, 33, 0, 0, -1, 0, 0), // objectives notify gauge
549 HC_gauge_region("HCB_53", 546, 117, 53, 0, 0, -1, 0, 0), // wingman status gauge
550 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // offscreen indicator range
551 HC_gauge_region("HCB_57", 505, 285, 57, 0, 1, -1, 0, 0), // kills gauge
552 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // attacking target count
553 HC_gauge_region("HCB_38", 342, 138, 38, 0, 0, -1, 0, 0), // text flash gauge
554 HC_gauge_region("HCB_52", 465, 8, 52, 0, 0, -1, 0, 0), // comm menu
555 HC_gauge_region("HCB_46", 324, 264, 46, 0, 0, -1, 0, 0), // support view gauge
556 HC_gauge_region("HCB_47", 418, 262, 47, 0, 0, -1, 0, 0), // netlag icon gauge
562 HC_gauge_region("2_HCB_35", 652, 112, 35, 1, 0, -1, 0, 2), // lead indicator
563 HC_gauge_region("2_HCB_36", 489, 191, 36, 1, 0, -1, 0, 2), // orientation tee
564 HC_gauge_region("none", 1, 1, -1, 1, 0, -1, 0, 0), // hostile triangle
565 HC_gauge_region("2_HCB_37", 626, 173, 37, 1, 0, -1, 0, 2), // target triangle
566 HC_gauge_region("2_HCB_63", 920, 564, 63, 0, 0, -1, 0, 0), // mission time
567 HC_gauge_region("none", 1, 1, 1, 0, 0, -1, 0, 0), // reticle circle?
568 HC_gauge_region("2_HCB_40", 456, 235, 40, 0, 0, -1, 0, 0), // throttle gauge
569 HC_gauge_region("2_HCB_50", 508, 466, 50, 0, 0, -1, 0, 0), // radar
570 HC_gauge_region("2_HCB_31", 198, 399, 31, 0, 0, -1, 0, 0), // target monitor
571 HC_gauge_region("2_HCB_41", 578, 302, 41, 0, 0, -1, 0, 0), // center of reticle
572 HC_gauge_region("2_HCB_30", 198, 354, 30, 0, 0, -1, 0, 0), // extra target data
573 HC_gauge_region("2_HCB_49", 380, 485, 49, 0, 0, -1, 0, 0), // target shield icon
574 HC_gauge_region("2_HCB_51", 696, 486, 51, 0, 0, -1, 0, 0), // player shield icon
575 HC_gauge_region("2_HCB_58", 839, 479, 58, 0, 1, -1, 0, 0), // ets gauge
576 HC_gauge_region("2_HCB_61", 906, 479, 61, 0, 1, -1, 0, 0), // auto target
577 HC_gauge_region("2_HCB_62", 906, 508, 62, 0, 1, -1, 0, 0), // auto speed
578 HC_gauge_region("2_HCB_55", 807, 346, 55, 0, 1, -1, 0, 0), // weapons gauge
579 HC_gauge_region("2_HCB_54", 794, 265, 54, 0, 1, -1, 0, 0), // escort view
580 HC_gauge_region("2_HCB_29", 198, 228, 29, 0, 0, -1, 0, 0), // directives view
581 HC_gauge_region("2_HCB_43", 637, 237, 43, 0, 0, -1, 0, 0), // threat gauge
582 HC_gauge_region("2_HCB_39", 403, 339, 39, 0, 0, -1, 0, 0), // afterburner energy
583 HC_gauge_region("2_HCB_44", 719, 339, 44, 0, 0, -1, 0, 0), // weapons energy
584 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // weapon linking
585 HC_gauge_region("2_HCB_42", 569, 371, 42, 0, 1, -1, 0, 0), // target mini icon (shield)
586 HC_gauge_region("2_HCB_34", 701, 9, 34, 1, 0, -1, 0, 2), // offscreen indicator
587 HC_gauge_region("2_HCB_28", 198, 50, 28, 0, 0, -1, 0, 0), // talking head
588 HC_gauge_region("2_HCB_32", 495, 55, 32, 0, 1, -1, 0, 0), // damage gauge
589 HC_gauge_region("2_HCB_27", 199, 30, 27, 0, 0, -1, 0, 0), // message lines
590 HC_gauge_region("2_HCB_45", 491, 399, 45, 1, 0, -1, 0, 1), // missile warnings
591 HC_gauge_region("2_HCB_56", 808, 433, 56, 0, 1, -1, 0, 0), // cmeasure gauge
592 HC_gauge_region("2_HCB_33", 495, 141, 33, 0, 0, -1, 0, 0), // objectives notify gauge
593 HC_gauge_region("2_HCB_53", 873, 188, 53, 0, 0, -1, 0, 0), // wingman status gauge
594 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // offscreen indicator range
595 HC_gauge_region("2_HCB_57", 808, 456, 57, 0, 1, -1, 0, 0), // kills gauge
596 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // attacking target count
597 HC_gauge_region("2_HCB_38", 548, 222, 38, 0, 0, -1, 0, 0), // text flash gauge
598 HC_gauge_region("2_HCB_52", 744, 14, 52, 0, 0, -1, 0, 0), // comm menu
599 HC_gauge_region("2_HCB_46", 520, 422, 46, 0, 0, -1, 0, 0), // support view gauge
600 HC_gauge_region("2_HCB_47", 670, 419, 47, 0, 0, -1, 0, 0), // netlag icon gauge
605 int HC_gauge_description_coords[GR_NUM_RESOLUTIONS][3] = {
618 const char *HC_gauge_descriptions(int n)
622 return XSTR( "lead indicator", 249);
624 return XSTR( "target orientation", 250);
626 return XSTR( "closest attacking hostile", 251);
628 return XSTR( "current target direction", 252);
630 return XSTR( "mission time", 253);
632 return XSTR( "reticle", 254);
634 return XSTR( "throttle", 255);
636 return XSTR( "radar", 256);
638 return XSTR( "target monitor", 257);
640 return XSTR( "center of reticle", 258);
642 return XSTR( "extra target info", 259);
644 return XSTR( "target shield", 260);
646 return XSTR( "player shield", 261);
648 return XSTR( "power management", 262);
650 return XSTR( "auto-target icon", 263);
652 return XSTR( "auto-speed-match icon", 264);
654 return XSTR( "weapons display", 265);
656 return XSTR( "monitoring view", 266);
658 return XSTR( "directives view", 267);
660 return XSTR( "threat gauge", 268);
662 return XSTR( "afterburner energy", 269);
664 return XSTR( "weapons energy", 270);
666 return XSTR( "weapon linking", 271);
668 return XSTR( "target hull/shield icon", 272);
670 return XSTR( "offscreen indicator", 273);
672 return XSTR( "comm video", 274);
674 return XSTR( "damage display", 275);
676 return XSTR( "message output", 276);
678 return XSTR( "locked missile direction", 277);
680 return XSTR( "countermeasures", 278);
682 return XSTR( "objective notify", 279);
684 return XSTR( "wingmen status", 280);
686 return XSTR( "offscreen range", 281);
688 return XSTR( "kills gauge", 282);
690 return XSTR( "attacking target count", 283);
692 return XSTR("warning flash", 1459);
694 return XSTR("comm menu", 1460);
696 return XSTR("support gauge", 1461);
698 return XSTR("lag gauge", 1462);
704 #define NUM_HUD_BUTTONS 8
706 #define NUM_HUD_BUTTONS 20
711 #define HCB_GREEN_UP 1
712 #define HCB_BLUE_UP 2
714 #define HCB_RED_DOWN 4
715 #define HCB_GREEN_DOWN 5
716 #define HCB_BLUE_DOWN 6
721 #define HCB_SAVE_HCF 11
722 #define HCB_PREV_HCF 12
723 #define HCB_NEXT_HCF 13
727 #define HCB_SELECT_ALL 17
729 #define HCB_ACCEPT 19
742 ui_button_info HC_buttons[GR_NUM_RESOLUTIONS][NUM_HUD_BUTTONS] = {
745 ui_button_info("HG_27", 31, 92, -1, -1, 27), // amber
746 ui_button_info("HG_28", 31, 113, -1, -1, 28), // blue
747 ui_button_info("HG_29", 31, 133, -1, -1, 29), // green
748 ui_button_info("HG_30", 31, 385, -1, -1, 30), // on
749 ui_button_info("HG_31", 31, 405, -1, -1, 31), // off
750 ui_button_info("HG_32", 31, 424, -1, -1, 32), // popup
751 ui_button_info("HG_36", 504, 411, -1, -1, 36), // reset
752 ui_button_info("HG_37", 561, 411, -1, -1, 37), // accept
754 ui_button_info("HCB_00", 6, 27, -1, -1, 0),
755 ui_button_info("HCB_01", 30, 27, -1, -1, 1),
756 ui_button_info("HCB_02", 55, 27, -1, -1, 2),
757 ui_button_info("HCB_03", 80, 27, -1, -1, 3),
758 ui_button_info("HCB_08", 6, 291, -1, -1, 8),
759 ui_button_info("HCB_09", 30, 291, -1, -1, 9),
760 ui_button_info("HCB_10", 55, 291, -1, -1, 10),
761 ui_button_info("HCB_11", 80, 291, -1, -1, 11),
762 ui_button_info("HCB_12", 4, 329, -1, -1, 12),
763 ui_button_info("HCB_13", 4, 348, -1, -1, 13),
764 ui_button_info("HCB_14", 4, 367, -1, -1, 14),
765 ui_button_info("HCB_15", 2, 439, -1, -1, 15),
766 ui_button_info("HCB_16", 266, 456, -1, -1, 16),
767 ui_button_info("HCB_17", 292, 456, -1, -1, 17),
768 ui_button_info("HCB_18", 327, 421, -1, -1, 18),
769 ui_button_info("HCB_19", 327, 440, -1, -1, 19),
770 ui_button_info("HCB_20", 327, 459, -1, -1, 20),
771 ui_button_info("HCB_24", 472, 436, -1, -1, 24),
772 ui_button_info("HCB_25", 523, 433, -1, -1, 25),
773 ui_button_info("HCB_26", 576, 434, -1, -1, 26),
777 ui_button_info("2_HCB_00", 9, 44, -1, -1, 0),
778 ui_button_info("2_HCB_01", 48, 44, -1, -1, 1),
779 ui_button_info("2_HCB_02", 88, 44, -1, -1, 2),
780 ui_button_info("2_HCB_03", 127, 44, -1, -1, 3),
781 ui_button_info("2_HCB_08", 9, 466, -1, -1, 8),
782 ui_button_info("2_HCB_09", 48, 466, -1, -1, 9),
783 ui_button_info("2_HCB_10", 88, 466, -1, -1, 10),
784 ui_button_info("2_HCB_11", 127, 466, -1, -1, 11),
786 ui_button_info("2_HCB_12", 6, 526, -1, -1, 12),
787 ui_button_info("2_HCB_13", 6, 556, -1, -1, 13),
788 ui_button_info("2_HCB_14", 6, 586, -1, -1, 14),
789 ui_button_info("2_HCB_15", 3, 703, -1, -1, 15),
790 ui_button_info("2_HCB_16", 426, 730, -1, -1, 16),
791 ui_button_info("2_HCB_17", 467, 730, -1, -1, 17),
792 ui_button_info("2_HCB_18", 524, 674, -1, -1, 18),
793 ui_button_info("2_HCB_19", 524, 704, -1, -1, 19),
794 ui_button_info("2_HCB_20", 524, 734, -1, -1, 20),
795 ui_button_info("2_HCB_24", 755, 698, -1, -1, 24),
796 ui_button_info("2_HCB_25", 837, 693, -1, -1, 25),
797 ui_button_info("2_HCB_26", 922, 695, -1, -1, 26),
804 #define NUM_HUD_TEXT 15
806 UI_XSTR HC_text[GR_NUM_RESOLUTIONS][NUM_HUD_TEXT] = {
808 { "R", 1512, 14, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
809 { "G", 1513, 37, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
810 { "B", 1514, 62, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
811 { "I", 1515, 90, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
812 { "On", 1285, 36, 334, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_ON].button },
813 { "Off", 1286, 36, 353, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_OFF].button },
814 { "Popup", 1453, 36, 372, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_POPUP].button },
815 { "Save", 1454, 51, 428, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SAVE_HCF].button },
816 { "Amber", 1455, 364, 426, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_AMBER].button },
817 { "Blue", 1456, 364, 445, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_BLUE].button },
818 { "Green", 1457, 364, 464, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_GREEN].button },
819 { "Select", 1550, 442, 413, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SELECT_ALL].button },
820 { "All", 1551, 442, 424, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SELECT_ALL].button },
821 { "Reset", 1337, 515, 413, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_RESET].button },
822 { "Accept", 1035, 573, 413, UI_XSTR_COLOR_PINK, -1, &HC_buttons[0][HCB_ACCEPT].button },
825 { "R", 1512, 23, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
826 { "G", 1513, 60, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
827 { "B", 1514, 100, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
828 { "I", 1515, 144, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
829 { "On", 1285, 58, 536, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_ON].button },
830 { "Off", 1286, 58, 566, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_OFF].button },
831 { "Popup", 1453, 58, 596, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_POPUP].button },
832 { "Save", 1454, 82, 688, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SAVE_HCF].button },
833 { "Amber", 1455, 582, 685, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_AMBER].button },
834 { "Blue", 1456, 582, 715, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_BLUE].button },
835 { "Green", 1457, 582, 745, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_GREEN].button },
836 { "Select", 1550, 760, 671, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SELECT_ALL].button },
837 { "All", 1551, 760, 682, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SELECT_ALL].button },
838 { "Reset", 1337, 850, 669, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_RESET].button },
839 { "Accept", 1035, 930, 670, UI_XSTR_COLOR_PINK, -1, &HC_buttons[1][HCB_ACCEPT].button },
844 void hud_config_set_rgb(int gauge, int r, int g, int b);
845 void hud_config_set_alpha(int gauge, int a);
848 #define NUM_HC_SPECIAL_BITMAPS 2
849 #define HC_SPECIAL_RETICLE 0
850 #define HC_SPECIAL_TEXT 1
851 typedef struct HC_special_bitmap
853 const char *filename;
858 HC_special_bitmap HC_special_bitmaps[NUM_HC_SPECIAL_BITMAPS] =
861 {"HG_00a", 272, 146, -1},
862 {"HG_04a", 132, 271, -1},
867 static int HC_background_bitmap;
868 static UI_WINDOW HC_ui_window;
870 static int HC_gauge_hot; // mouse is over this gauge
871 static int HC_gauge_selected; // gauge is selected
875 #define HC_NUM_SLIDERS 1
876 #define HC_BRIGHTNESS_SLIDER 0
879 const char *filename;
885 // left and right buttons
886 const char *left_filename;
887 int left_mask, left_x, left_y;
888 const char *right_filename;
889 int right_mask, right_x, right_y;
892 UI_DOT_SLIDER_NEW slider; // because we have a class inside this struct, we need the constructor below..
894 hc_sliders(const char *name, int x1, int y1, int xt1, int yt1, int h, int _dot_w, int _dots, const char *_left_filename, int _left_mask, int _left_x, int _left_y, const char *_right_filename, int _right_mask, int _right_x, int _right_y) :
895 filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h), dot_w(_dot_w), dots(_dots), left_filename(_left_filename), left_mask(_left_mask), left_x(_left_x), left_y(_left_y), right_filename(_right_filename), right_mask(_right_mask), right_x(_right_x), right_y(_right_y) {}
898 hc_sliders HC_sliders[GR_NUM_RESOLUTIONS][HC_NUM_SLIDERS] = {
901 hc_sliders( "HCB_22", 419, 379, -1, -1, 22, 20, 10,
902 "HCB_23", 23, 611, 379,
903 "HCB_21", 21, 391, 379)
905 // ten dots but 11 frames, use frame count
906 hc_sliders( "HG_34", 373, 21, -1, -1, 34, 20, 11,
907 "HG_35", 35, 565, 20,
908 "HG_33", 33, 349, 20)
911 hc_sliders( "2_HCB_22", 670, 606, -1, -1, 22, 32, 10,
912 "2_HCB_23", 23, 698, 606,
913 "2_HCB_21", 21, 625, 606),
920 typedef struct hc_col {
924 hc_col HC_colors[3] =
926 {0, 255, 0}, // Green - get RGB from Adam so it matches palette?-??.pcx
927 {67, 123, 203}, // Blue - get RGB from Adam so it matches palette?-??.pcx
928 {255, 197, 0}, // Amber - get RGB from Adam so it matches palette?-??.pcx
931 static HUD_CONFIG_TYPE HUD_config_backup; // backup HUD config, used to restore old config if changes not applied
932 static int HUD_config_inited = 0;
935 void hud_config_red_slider();
936 void hud_config_green_slider();
937 void hud_config_blue_slider();
938 void hud_config_alpha_slider_up();
939 void hud_config_alpha_slider_down();
940 void hud_config_recalc_alpha_slider();
941 void hud_config_process_colors();
942 void hud_config_color_init();
943 void hud_config_color_close();
944 #define NUM_HC_SLIDERS 4
949 UI_SLIDER2 HC_color_sliders[NUM_HC_SLIDERS];
950 int HC_slider_coords[GR_NUM_RESOLUTIONS][NUM_HC_SLIDERS][4] = {
961 { 133, 85, 32, 350 },
964 #define HCS_CONV(__v) ( 255 - (__v) )
966 const char *HC_slider_fname[GR_NUM_RESOLUTIONS] = {
972 void hud_config_synch_sliders(int i)
976 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HUD_config.clr[i].red) );
977 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HUD_config.clr[i].green) );
978 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HUD_config.clr[i].blue) );
979 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(HUD_config.clr[i].alpha) );
984 // reset some ui components based on HUD config data
985 void hud_config_synch_ui()
990 HUD_init_hud_color_array();
992 HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos = HUD_color_alpha -3; // convert to value from 0-10
995 // sync sliders to currently selected gauge
996 hud_config_synch_sliders(HC_gauge_selected);
1000 // Init the UI components
1001 void hud_config_init_ui()
1004 struct HC_gauge_region *hg;
1005 struct ui_button_info *hb;
1008 common_set_interface_palette("HUDConfigPalette"); // set the interface palette
1010 hud_config_synch_ui();
1011 HC_background_bitmap = bm_load(Hud_config_fname[gr_screen.res]);
1013 HC_ui_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
1014 HC_ui_window.set_mask_bmap(Hud_config_mask_fname[gr_screen.res]);
1016 for (i=0; i<NUM_HUD_GAUGES; i++) {
1017 hg = &HC_gauge_regions[gr_screen.res][i];
1018 if ( !SDL_strcasecmp(hg->filename, NOX("none")) ) {
1021 hg->button.create(&HC_ui_window, "", hg->x, hg->y, 60, 30, 0, 1);
1022 // set up callback for when a mouse first goes over a button
1023 // hg->button.set_highlight_action(common_play_highlight_sound);
1025 hg->button.link_hotspot(hg->hotspot);
1028 if ( hg->use_iff ) {
1029 hg->bitmap = bm_load_animation(hg->filename, &hg->nframes);
1031 hg->bitmap = bm_load(hg->filename);
1035 hg->bitmap = bm_load(hg->filename);
1042 for(i=0; i<NUM_HUD_TEXT; i++){
1043 HC_ui_window.add_XSTR(&HC_text[gr_screen.res][i]);
1046 // initialize sliders
1047 HC_color_sliders[HCS_RED].create(&HC_ui_window, HC_slider_coords[gr_screen.res][HCS_RED][0], HC_slider_coords[gr_screen.res][HCS_RED][1], HC_slider_coords[gr_screen.res][HCS_RED][2], HC_slider_coords[gr_screen.res][HCS_RED][3],
1048 255, HC_slider_fname[gr_screen.res], hud_config_red_slider, hud_config_red_slider, hud_config_red_slider);
1050 HC_color_sliders[HCS_GREEN].create(&HC_ui_window, HC_slider_coords[gr_screen.res][HCS_GREEN][0], HC_slider_coords[gr_screen.res][HCS_GREEN][1], HC_slider_coords[gr_screen.res][HCS_GREEN][2], HC_slider_coords[gr_screen.res][HCS_GREEN][3],
1051 255, HC_slider_fname[gr_screen.res], hud_config_green_slider, hud_config_green_slider, hud_config_green_slider);
1053 HC_color_sliders[HCS_BLUE].create(&HC_ui_window, HC_slider_coords[gr_screen.res][HCS_BLUE][0], HC_slider_coords[gr_screen.res][HCS_BLUE][1], HC_slider_coords[gr_screen.res][HCS_BLUE][2], HC_slider_coords[gr_screen.res][HCS_BLUE][3],
1054 255, HC_slider_fname[gr_screen.res], hud_config_blue_slider, hud_config_blue_slider, hud_config_blue_slider);
1056 HC_color_sliders[HCS_ALPHA].create(&HC_ui_window, HC_slider_coords[gr_screen.res][HCS_ALPHA][0], HC_slider_coords[gr_screen.res][HCS_ALPHA][1], HC_slider_coords[gr_screen.res][HCS_ALPHA][2], HC_slider_coords[gr_screen.res][HCS_ALPHA][3],
1057 255, HC_slider_fname[gr_screen.res], hud_config_alpha_slider_up, hud_config_alpha_slider_down, NULL);
1060 hud_config_color_init();
1062 for (i=0; i<NUM_HUD_BUTTONS; i++) {
1063 hb = &HC_buttons[gr_screen.res][i];
1064 hb->button.create(&HC_ui_window, "", hb->x, hb->y, 60, 30, 0, 1);
1065 // set up callback for when a mouse first goes over a button
1066 hb->button.set_bmaps(hb->filename);
1067 hb->button.set_highlight_action(common_play_highlight_sound);
1068 hb->button.link_hotspot(hb->hotspot);
1071 // config file input name
1072 HC_fname_input.create(&HC_ui_window, HC_fname_coords[gr_screen.res][0], HC_fname_coords[gr_screen.res][1], HC_fname_coords[gr_screen.res][2], MAX_FILENAME_LEN, "", UI_INPUTBOX_FLAG_INVIS | UI_INPUTBOX_FLAG_ESC_FOC);
1073 HC_fname_input.set_text("");
1076 for (i=0; i<NUM_HC_SPECIAL_BITMAPS; i++) {
1077 HC_special_bitmaps[i].bitmap = bm_load(HC_special_bitmaps[i].filename);
1081 for(i=0; i<HC_NUM_SLIDERS; i++){
1082 HC_sliders[gr_screen.res][i].slider.create(&HC_ui_window, HC_sliders[gr_screen.res][i].x, HC_sliders[gr_screen.res][i].y,
1083 HC_sliders[gr_screen.res][i].dots, HC_sliders[gr_screen.res][i].filename,
1084 HC_sliders[gr_screen.res][i].hotspot, HC_sliders[gr_screen.res][i].right_filename, HC_sliders[gr_screen.res][i].right_mask, HC_sliders[gr_screen.res][i].right_x, HC_sliders[gr_screen.res][i].right_y,
1085 HC_sliders[gr_screen.res][i].left_filename, HC_sliders[gr_screen.res][i].left_mask, HC_sliders[gr_screen.res][i].left_x, HC_sliders[gr_screen.res][i].left_y,
1086 HC_sliders[gr_screen.res][i].dot_w);
1088 HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos = HUD_color_alpha - 3;
1093 HC_gauge_selected = -1;
1097 SDL_strlcpy(HC_fname, "", sizeof(HC_fname));
1100 int hud_config_show_flag_is_set(int i)
1105 show_flag_set = HUD_config.show_flags & (1<<i);
1107 show_flag_set = HUD_config.show_flags2 & (1<<(i-32));
1110 return show_flag_set;
1113 void hud_config_show_flag_set(int i)
1116 HUD_config.show_flags |= (1<<i);
1118 HUD_config.show_flags2 |= (1<<(i-32));
1122 void hud_config_show_flag_clear(int i)
1125 HUD_config.show_flags &= ~(1<<i);
1127 HUD_config.show_flags2 &= ~(1<<(i-32));
1131 int hud_config_popup_flag_is_set(int i)
1136 popup_flag_set = HUD_config.popup_flags & (1<<i);
1138 popup_flag_set = HUD_config.popup_flags2 & (1<<(i-32));
1141 return popup_flag_set;
1144 void hud_config_popup_flag_set(int i)
1147 HUD_config.popup_flags |= (1<<i);
1149 HUD_config.popup_flags2 |= (1<<(i-32));
1153 void hud_config_popup_flag_clear(int i)
1156 HUD_config.popup_flags &= ~(1<<i);
1158 HUD_config.popup_flags2 &= ~(1<<(i-32));
1162 // render all the hud config gauges
1163 void hud_config_render_gauges()
1171 for ( i=0; i<NUM_HUD_GAUGES; i++ ) {
1172 if ( (hud_config_show_flag_is_set(i)) ) {
1173 // set the correct color
1174 if(!HC_gauge_regions[gr_screen.res][i].use_iff){
1175 use_color = HUD_config.clr[i];
1178 if(HC_gauge_regions[gr_screen.res][i].color == 1){
1179 use_color = IFF_colors[IFF_COLOR_TAGGED][0];
1181 use_color = IFF_colors[IFF_COLOR_HOSTILE][0];
1185 if ( (HC_gauge_selected == i) || HC_select_all ) {
1187 } else if ( HC_gauge_hot == i ) {
1192 gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha, AC_TYPE_HUD);
1193 gr_set_color_fast(&use_color);
1195 // set correct frame if using iff
1196 if ( HC_gauge_regions[gr_screen.res][i].use_iff ) {
1199 if ( HC_gauge_selected == i ) {
1201 } else if ( HC_gauge_hot == i ) {
1205 // If gauge is disabled, then draw disabled frame
1206 if ( !(hud_config_show_flag_is_set(i)) ) {
1210 if ( HC_gauge_regions[gr_screen.res][i].bitmap >= 0 ) {
1211 SDL_assert(offset < HC_gauge_regions[gr_screen.res][i].nframes);
1212 gr_set_bitmap(HC_gauge_regions[gr_screen.res][i].bitmap+offset, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1213 gr_bitmap(HC_gauge_regions[gr_screen.res][i].x, HC_gauge_regions[gr_screen.res][i].y);
1219 // if its off, make it dark gray
1220 gr_init_alphacolor(&use_color, 127, 127, 127, 64, AC_TYPE_HUD);
1221 gr_set_color_fast(&use_color);
1225 if ( HC_gauge_regions[gr_screen.res][i].bitmap >= 0 ) {
1226 gr_set_bitmap(HC_gauge_regions[gr_screen.res][i].bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1227 gr_aabitmap(HC_gauge_regions[gr_screen.res][i].x, HC_gauge_regions[gr_screen.res][i].y);
1234 // set correct frame if using iff
1235 if ( HC_gauge_regions[i].use_iff ) {
1236 if ( HC_gauge_selected == i ) {
1238 } else if ( HC_gauge_hot == i ) {
1242 // If gauge is disabled, then draw disabled frame
1243 if ( !(hud_config_show_flag_is_set(i)) ) {
1248 if ( HC_gauge_regions[i].bitmap >= 0 ) {
1249 SDL_assert(offset < HC_gauge_regions[i].nframes);
1250 gr_set_bitmap(HC_gauge_regions[i].bitmap+offset);
1251 gr_bitmap(HC_gauge_regions[i].x, HC_gauge_regions[i].y);
1258 // hud_config_init() is called when the game enters the state GS_STATE_HUD_CONFIG
1259 void hud_config_init()
1261 hud_config_init_ui();
1262 hud_config_backup(); // save the HUD configuration in case the player decides to cancel changes
1263 HUD_config_inited = 1;
1266 // check for the mouse over gauge regions
1267 void hud_config_check_regions()
1272 for ( i=0; i<NUM_HUD_GAUGES; i++ ) {
1273 b = &HC_gauge_regions[gr_screen.res][i].button;
1275 // check for mouse over gauges
1276 if ( b->button_hilighted() ) {
1280 if ( b->pressed() ) {
1281 gamesnd_play_iface(SND_USER_SELECT);
1282 HC_gauge_selected = i;
1284 // turn off select all
1285 hud_config_select_all_toggle(0);
1287 // maybe setup rgb sliders
1289 if(HC_gauge_regions[gr_screen.res][i].use_iff){
1290 HC_color_sliders[HCS_RED].hide();
1291 HC_color_sliders[HCS_GREEN].hide();
1292 HC_color_sliders[HCS_BLUE].hide();
1293 HC_color_sliders[HCS_ALPHA].hide();
1295 HC_color_sliders[HCS_RED].disable();
1296 HC_color_sliders[HCS_GREEN].disable();
1297 HC_color_sliders[HCS_BLUE].disable();
1298 HC_color_sliders[HCS_ALPHA].disable();
1300 HC_color_sliders[HCS_RED].enable();
1301 HC_color_sliders[HCS_GREEN].enable();
1302 HC_color_sliders[HCS_BLUE].enable();
1303 HC_color_sliders[HCS_ALPHA].enable();
1305 HC_color_sliders[HCS_RED].unhide();
1306 HC_color_sliders[HCS_GREEN].unhide();
1307 HC_color_sliders[HCS_BLUE].unhide();
1308 HC_color_sliders[HCS_ALPHA].unhide();
1310 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HUD_config.clr[i].red) );
1311 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HUD_config.clr[i].green) );
1312 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HUD_config.clr[i].blue) );
1313 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(HUD_config.clr[i].alpha) );
1317 // recalc alpha slider
1318 hud_config_recalc_alpha_slider();
1323 // set the display flags for a HUD gauge
1324 void hud_config_set_gauge_flags(int gauge_index, int on_flag, int popup_flag)
1327 hud_config_show_flag_set(gauge_index);
1329 hud_config_show_flag_clear(gauge_index);
1333 hud_config_popup_flag_set(gauge_index);
1335 hud_config_popup_flag_clear(gauge_index);
1339 void hud_config_record_color(int color)
1341 HUD_config.main_color = color;
1342 HUD_color_red = HC_colors[color].r;
1343 HUD_color_green = HC_colors[color].g;
1344 HUD_color_blue = HC_colors[color].b;
1347 // Set the HUD color
1348 void hud_config_set_color(int color)
1352 hud_config_record_color(color);
1355 game_load_palette();
1358 HUD_init_hud_color_array();
1360 // apply the color to all gauges
1361 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1362 gr_init_alphacolor(&HUD_config.clr[idx], HC_colors[color].r, HC_colors[color].g, HC_colors[color].b, (HUD_color_alpha+1)*16, AC_TYPE_HUD);
1366 void hud_config_stuff_colors(int r, int g, int b)
1370 // apply the color to all gauges
1371 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1372 gr_init_alphacolor(&HUD_config.clr[idx], r, g, b, 255, AC_TYPE_HUD);
1376 // leave hud config without accepting changes
1377 void hud_config_cancel()
1379 hud_config_restore();
1380 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
1383 // leave hud config with accepting changes
1384 void hud_config_commit()
1386 gamesnd_play_iface(SND_COMMIT_PRESSED);
1387 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
1390 // move gauge state from on->off->popup
1391 void hud_cycle_gauge_status()
1393 if ( HC_gauge_selected < 0 ) {
1397 // gauge is off, move to popup
1398 if ( !(hud_config_show_flag_is_set(HC_gauge_selected)) ) {
1399 if ( HC_gauge_regions[gr_screen.res][HC_gauge_selected].can_popup ) {
1400 hud_config_set_gauge_flags(HC_gauge_selected, 1, 1);
1402 hud_config_set_gauge_flags(HC_gauge_selected, 1, 0);
1407 // if gauge is popup, move to on
1408 if ( hud_config_popup_flag_is_set(HC_gauge_selected) ) {
1409 hud_config_set_gauge_flags(HC_gauge_selected, 1, 0);
1413 // gauge must be on, move to off
1414 hud_config_set_gauge_flags(HC_gauge_selected, 0, 0);
1417 // handle keyboard input while in hud config
1418 void hud_config_handle_keypresses(int k)
1422 hud_config_cancel();
1424 case KEY_CTRLED+SDLK_RETURN:
1425 hud_config_commit();
1428 gamesnd_play_iface(SND_USER_SELECT);
1429 hud_cycle_gauge_status();
1434 // Handlers for when buttons get pressed
1435 void hud_config_button_do(int n)
1439 char name[256] = "";
1444 hud_config_set_color(HUD_COLOR_AMBER);
1445 gamesnd_play_iface(SND_USER_SELECT);
1448 hud_config_set_color(HUD_COLOR_BLUE);
1449 gamesnd_play_iface(SND_USER_SELECT);
1452 hud_config_set_color(HUD_COLOR_GREEN);
1453 gamesnd_play_iface(SND_USER_SELECT);
1456 if ( HC_gauge_selected < 0 ) {
1459 gamesnd_play_iface(SND_USER_SELECT);
1460 hud_config_set_gauge_flags(HC_gauge_selected,1,0);
1463 if ( HC_gauge_selected < 0 ) {
1466 gamesnd_play_iface(SND_USER_SELECT);
1467 hud_config_set_gauge_flags(HC_gauge_selected,0,0);
1470 if ( HC_gauge_selected < 0 ) {
1473 gamesnd_play_iface(SND_USER_SELECT);
1474 hud_config_set_gauge_flags(HC_gauge_selected,1,1);
1477 gamesnd_play_iface(SND_RESET_PRESSED);
1478 hud_config_select_all_toggle(0);
1479 hud_set_default_hud_config(Player);
1480 hud_config_synch_ui();
1483 hud_config_commit();
1489 if( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) >= 255){
1490 gamesnd_play_iface(SND_GENERAL_FAIL);
1492 gamesnd_play_iface(SND_USER_SELECT);
1493 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) + 1) );
1494 hud_config_red_slider();
1499 if( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) >= 255){
1500 gamesnd_play_iface(SND_GENERAL_FAIL);
1502 gamesnd_play_iface(SND_USER_SELECT);
1503 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) + 1) );
1504 hud_config_green_slider();
1509 if( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) >= 255){
1510 gamesnd_play_iface(SND_GENERAL_FAIL);
1512 gamesnd_play_iface(SND_USER_SELECT);
1513 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) + 1) );
1514 hud_config_blue_slider();
1519 if( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) >= 255){
1520 gamesnd_play_iface(SND_GENERAL_FAIL);
1522 gamesnd_play_iface(SND_USER_SELECT);
1523 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) + 1) );
1524 hud_config_alpha_slider_up();
1529 if( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) <= 0){
1530 gamesnd_play_iface(SND_GENERAL_FAIL);
1532 gamesnd_play_iface(SND_USER_SELECT);
1533 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) - 1) );
1534 hud_config_red_slider();
1538 case HCB_GREEN_DOWN:
1539 if( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) <= 0){
1540 gamesnd_play_iface(SND_GENERAL_FAIL);
1542 gamesnd_play_iface(SND_USER_SELECT);
1543 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) - 1) );
1544 hud_config_green_slider();
1549 if( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) <= 0){
1550 gamesnd_play_iface(SND_GENERAL_FAIL);
1552 gamesnd_play_iface(SND_USER_SELECT);
1553 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) - 1) );
1554 hud_config_blue_slider();
1559 if( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) <= 0){
1560 gamesnd_play_iface(SND_GENERAL_FAIL);
1562 gamesnd_play_iface(SND_USER_SELECT);
1563 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) - 1) );
1564 hud_config_alpha_slider_down();
1572 // get the text in the input control
1574 HC_fname_input.get_text(name);
1575 if(strlen(name) > 0){
1576 // if the filename in there already exists
1577 for(idx=0; idx<HC_num_files; idx++){
1578 if(!SDL_strcasecmp(HC_filenames[idx], name)){
1587 out = cf_add_ext(name, ".hcf");
1588 hud_config_color_save(out);
1592 // otherwise we have to create a new file
1593 if(HC_num_files >= MAX_HCF_FILES){
1594 popup(PF_USE_AFFIRMATIVE_ICON, 1, "OK", "Max number of hud config files reached!");
1598 // save the file, maybe generating a new filename
1599 if(strlen(name) <= 0){
1600 SDL_snprintf(name, sizeof(name), "hud_%d.hcf", HC_num_files + 1);
1603 out = cf_add_ext(name, ".hcf");
1605 HC_filenames[HC_num_files++] = strdup(out);
1606 hud_config_color_save(out);
1608 HC_fname_input.set_text(out);
1612 if(HC_num_files <= 0){
1616 if(HC_current_file <= 0){
1617 HC_current_file = HC_num_files - 1;
1622 hud_config_color_load(HC_filenames[HC_current_file]);
1623 hud_config_synch_ui();
1625 HC_fname_input.set_text(HC_filenames[HC_current_file]);
1629 if(HC_num_files <= 0){
1633 if(HC_current_file >= HC_num_files - 1){
1634 HC_current_file = 0;
1640 hud_config_color_load(HC_filenames[HC_current_file]);
1641 hud_config_synch_ui();
1643 HC_fname_input.set_text(HC_filenames[HC_current_file]);
1646 case HCB_SELECT_ALL:
1647 hud_config_select_all_toggle(!HC_select_all);
1657 // Check if any buttons have been pressed
1658 void hud_config_check_buttons()
1663 for ( i=0; i<NUM_HUD_BUTTONS; i++ ) {
1664 b = &HC_buttons[gr_screen.res][i].button;
1665 if ( b->pressed() ) {
1666 hud_config_button_do(i);
1671 // set the hud color button
1672 void hud_config_draw_color_status()
1674 if ( HC_buttons[gr_screen.res][HCB_AMBER].button.button_down() || HC_buttons[gr_screen.res][HCB_GREEN].button.button_down() || HC_buttons[gr_screen.res][HCB_BLUE].button.button_down() ) {
1678 switch(HUD_config.main_color) {
1679 case HUD_COLOR_AMBER:
1680 HC_buttons[gr_screen.res][HCB_AMBER].button.draw_forced(2);
1682 case HUD_COLOR_GREEN:
1683 HC_buttons[gr_screen.res][HCB_GREEN].button.draw_forced(2);
1685 case HUD_COLOR_BLUE:
1686 HC_buttons[gr_screen.res][HCB_BLUE].button.draw_forced(2);
1691 // set the status (on/off/popup) for the selected gauge
1692 void hud_config_draw_gauge_status()
1694 if ( HC_gauge_selected < 0 ) {
1698 if ( HC_buttons[gr_screen.res][HCB_OFF].button.button_down() || HC_buttons[gr_screen.res][HCB_POPUP].button.button_down() || HC_buttons[gr_screen.res][HCB_ON].button.button_down() ) {
1703 if ( !(hud_config_show_flag_is_set(HC_gauge_selected)) ) {
1704 HC_buttons[gr_screen.res][HCB_OFF].button.draw_forced(2);
1709 if ( hud_config_popup_flag_is_set(HC_gauge_selected) ) {
1710 HC_buttons[gr_screen.res][HCB_POPUP].button.draw_forced(2);
1715 if ( hud_config_show_flag_is_set(HC_gauge_selected) ) {
1716 HC_buttons[gr_screen.res][HCB_ON].button.draw_forced(2);
1720 Int3(); // should never get here
1723 // disable a HUD config button
1724 void hud_config_button_disable(int index)
1726 // HC_buttons[gr_screen.res][index].button.hide();
1727 HC_buttons[gr_screen.res][index].button.disable();
1730 // enable a HUD config button
1731 void hud_config_button_enable(int index)
1733 // HC_buttons[gr_screen.res][index].button.unhide();
1734 HC_buttons[gr_screen.res][index].button.enable();
1737 // determine if on/off/popup buttons should be shown
1738 void hud_config_set_button_state()
1740 if ( HC_gauge_selected < 0 ) {
1741 hud_config_button_disable(HCB_ON);
1742 hud_config_button_disable(HCB_OFF);
1743 hud_config_button_disable(HCB_POPUP);
1747 // on/off are always on
1748 hud_config_button_enable(HCB_ON);
1749 hud_config_button_enable(HCB_OFF);
1751 // popup is maybe available
1752 if ( HC_gauge_regions[gr_screen.res][HC_gauge_selected].can_popup ) {
1753 hud_config_button_enable(HCB_POPUP);
1755 hud_config_button_disable(HCB_POPUP);
1759 void hud_config_render_description()
1763 if ( HC_gauge_selected >= 0 ) {
1764 gr_set_color_fast(&Color_normal);
1766 gr_get_string_size(&w, &h, HC_gauge_descriptions(HC_gauge_selected));
1767 sx = fl2i(HC_gauge_description_coords[gr_screen.res][0] + (HC_gauge_description_coords[gr_screen.res][2] - w)/2.0f);
1768 sy = HC_gauge_description_coords[gr_screen.res][1];
1769 gr_string(sx, sy, HC_gauge_descriptions(HC_gauge_selected));
1773 void hud_config_render_special_bitmaps()
1777 for (i=1; i<NUM_HC_SPECIAL_BITMAPS; i++) {
1778 if (HC_special_bitmaps[i].bitmap >= 0) {
1779 gr_set_bitmap(HC_special_bitmaps[i].bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1780 gr_bitmap(HC_special_bitmaps[i].x, HC_special_bitmaps[i].y);
1786 // update HUD_color_alpha based on brightness slider
1787 void hud_config_update_brightness()
1790 HUD_color_alpha = HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos+3;
1791 SDL_assert(HUD_color_alpha >= HUD_COLOR_ALPHA_USER_MIN);
1792 SDL_assert(HUD_color_alpha <= HUD_COLOR_ALPHA_USER_MAX);
1796 // redraw any pressed buttons, needed since the glow on pressed buttons might get clipped off by
1797 // adjacent buttons otherwise
1798 void hud_config_redraw_pressed_buttons()
1803 for ( i = 0; i < NUM_HUD_BUTTONS; i++ ) {
1804 b = &HC_buttons[gr_screen.res][i].button;
1805 if ( b->button_down() ) {
1811 // hud_config_do_frame() is called from the main freespace loop while the game is in the state
1812 // GS_STATE_HUD_CONFIG.
1814 void hud_config_do_frame(float frametime)
1818 if (!HUD_config_inited) {
1824 hud_config_set_button_state();
1826 k = HC_ui_window.process();
1828 hud_config_handle_keypresses(k);
1829 hud_config_check_regions();
1830 hud_config_check_buttons();
1831 hud_config_update_brightness();
1833 // set the background
1834 GR_MAYBE_CLEAR_RES(HC_background_bitmap);
1835 if ( HC_background_bitmap > 0 ) {
1836 gr_set_bitmap(HC_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1840 // rgb slider/button stuff
1841 hud_config_process_colors();
1843 HC_ui_window.draw();
1844 hud_config_redraw_pressed_buttons();
1846 hud_config_draw_gauge_status();
1847 hud_config_draw_color_status();
1850 if (HC_special_bitmaps[HC_SPECIAL_RETICLE].bitmap >= 0) {
1851 hud_set_default_color();
1852 gr_set_bitmap(HC_special_bitmaps[HC_SPECIAL_RETICLE].bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
1853 gr_aabitmap(HC_special_bitmaps[HC_SPECIAL_RETICLE].x, HC_special_bitmaps[HC_SPECIAL_RETICLE].y);
1857 // maybe force draw the select all button
1860 HC_buttons[gr_screen.res][HCB_SELECT_ALL].button.draw_forced(2);
1864 hud_config_render_gauges();
1865 hud_config_render_special_bitmaps();
1866 hud_config_render_description();
1871 void hud_config_unload_gauges()
1874 HC_gauge_region *hg;
1876 for (i=0; i<NUM_HUD_GAUGES; i++) {
1877 hg = &HC_gauge_regions[gr_screen.res][i];
1879 if ( hg->bitmap >= 0 ) {
1880 for ( j=0; j<hg->nframes; j++ ) {
1881 bm_unload(hg->bitmap+j);
1890 // hud_config_close() is called when the player leaves the hud configuration screen
1892 void hud_config_close()
1895 common_free_interface_palette(); // restore game palette
1897 hud_config_unload_gauges();
1898 hud_init_popup_timers(); // ensure no popup gauges are active
1900 hud_config_color_close();
1902 HC_ui_window.destroy();
1905 // hud_set_default_hud_config() will set the hud configuration to default values
1906 void hud_set_default_hud_config(player *p)
1910 HUD_color_alpha = HUD_COLOR_ALPHA_DEFAULT;
1911 HUD_config.main_color = HUD_COLOR_GREEN;
1912 HUD_color_red = HC_colors[HUD_config.main_color].r;
1913 HUD_color_green = HC_colors[HUD_config.main_color].g;
1914 HUD_color_blue = HC_colors[HUD_config.main_color].b;
1916 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1917 gr_init_alphacolor(&HUD_config.clr[idx], HUD_color_red, HUD_color_green, HUD_color_blue, (HUD_color_alpha+1)*16, AC_TYPE_HUD);
1920 HUD_config.show_flags = HUD_config_default_flags;
1921 HUD_config.show_flags2 = HUD_config_default_flags2;
1922 HUD_config.popup_flags = HUD_default_popup_mask;
1923 HUD_config.popup_flags2 = HUD_default_popup_mask2;
1924 HUD_config.num_msg_window_lines = 4; // one more than is actually visible
1925 HUD_config.rp_flags = RP_DEFAULT;
1926 HUD_config.rp_dist = RR_INFINITY;
1927 HUD_config.is_observer = 0;
1930 // hud_config_restore() will restore the hud configuration the player started with when the
1931 // hud configuration screen was started
1933 void hud_config_restore()
1935 HUD_config = HUD_config_backup;
1938 // hud_config_backup() will save the players hud configuration when they enter the hud configuration
1939 // screen. This is done in case the player decides to cancel the changes that were made.
1941 void hud_config_backup()
1943 HUD_config_backup = HUD_config;
1946 void hud_config_as_observer(ship *shipp,ai_info *aif)
1948 // store the current hus
1949 hud_config_backup();
1951 // bash these values so the HUD is not offset incorrectly
1952 HUD_offset_x = 0.0f;
1953 HUD_offset_y = 0.0f;
1955 // initialize the observer HUD
1956 hud_observer_init(shipp,aif);
1959 void hud_config_as_player()
1963 // ---------------------------------------------------------------------------------------------------------------
1967 void hud_config_color_save(const char *name)
1970 CFILE *out = cfopen(name, "wt", CFILE_NORMAL, CF_TYPE_PLAYERS);
1971 char vals[255] = "";
1979 // write out all gauges
1980 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1981 cfputs("+Gauge: ", out);
1982 cfputs(HC_gauge_descriptions(idx), out);
1984 cfputs("+RGBA: ", out);
1985 SDL_snprintf(vals, sizeof(vals), "%d %d %d %d\n\n", HUD_config.clr[idx].red, HUD_config.clr[idx].green, HUD_config.clr[idx].blue, HUD_config.clr[idx].alpha);
1993 void hud_config_color_load(const char *name)
1996 char str[1024] = "";
1999 fname = cf_add_ext(name, ".hcf");
2002 read_file_text(fname);
2005 // write out all gauges
2006 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
2007 required_string("+Gauge:");
2008 stuff_string(str, F_NAME, NULL, 1023);
2010 required_string("+RGBA:");
2011 stuff_byte(&HUD_config.clr[idx].red);
2012 stuff_byte(&HUD_config.clr[idx].green);
2013 stuff_byte(&HUD_config.clr[idx].blue);
2014 stuff_byte(&HUD_config.clr[idx].alpha);
2016 } catch (parse_error_t) {
2017 mprintf(("Error opening hud config file!\n"));
2021 void hud_config_alpha_slider_up()
2024 int pos = HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem());
2025 int max = max(max( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) ), HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) );
2027 // if this would put the brightest element past its limit, skip
2029 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(pos - 1) );
2033 // otherwise bump everybody up by one
2034 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) + 1) );
2035 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) + 1) );
2036 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) + 1) );
2040 hud_config_stuff_colors( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) );
2042 gr_init_alphacolor(&HUD_config.clr[HC_gauge_selected], HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()), 255, AC_TYPE_HUD);
2047 void hud_config_alpha_slider_down()
2050 int pos = HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem());
2051 int min = min(min( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) ), HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) );
2053 // if this would put the brightest element past its limit, skip
2055 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(pos + 1) );
2059 // otherwise bump everybody up by one
2060 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) - 1) );
2061 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) - 1) );
2062 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) - 1) );
2066 hud_config_stuff_colors( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) );
2068 gr_init_alphacolor(&HUD_config.clr[HC_gauge_selected], HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()), HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()), 255, AC_TYPE_HUD);
2073 void hud_config_recalc_alpha_slider()
2076 int avg =HC_color_sliders[HCS_RED].get_currentItem() + HC_color_sliders[HCS_GREEN].get_currentItem() + HC_color_sliders[HCS_BLUE].get_currentItem();
2078 HC_color_sliders[HCS_ALPHA].force_currentItem( avg );
2082 void hud_config_red_slider()
2086 int pos = HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) ;
2090 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
2091 gr_init_alphacolor(&HUD_config.clr[idx], pos, HUD_config.clr[idx].green, HUD_config.clr[idx].blue, HUD_config.clr[idx].alpha, AC_TYPE_HUD);
2096 if(HC_gauge_selected < 0){
2100 // get slider position
2101 gr_init_alphacolor(&HUD_config.clr[HC_gauge_selected], pos, HUD_config.clr[HC_gauge_selected].green, HUD_config.clr[HC_gauge_selected].blue, HUD_config.clr[HC_gauge_selected].alpha, AC_TYPE_HUD);
2104 hud_config_recalc_alpha_slider();
2108 void hud_config_green_slider()
2112 int pos = HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) ;
2116 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
2117 gr_init_alphacolor(&HUD_config.clr[idx], HUD_config.clr[idx].red, pos, HUD_config.clr[idx].blue, HUD_config.clr[idx].alpha, AC_TYPE_HUD);
2122 if(HC_gauge_selected < 0){
2126 // get slider position
2127 gr_init_alphacolor(&HUD_config.clr[HC_gauge_selected], HUD_config.clr[HC_gauge_selected].red, pos, HUD_config.clr[HC_gauge_selected].blue, HUD_config.clr[HC_gauge_selected].alpha, AC_TYPE_HUD);
2130 hud_config_recalc_alpha_slider();
2134 void hud_config_blue_slider()
2138 int pos = HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem());
2142 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
2143 gr_init_alphacolor(&HUD_config.clr[idx], HUD_config.clr[idx].red, HUD_config.clr[idx].green, pos, HUD_config.clr[idx].alpha, AC_TYPE_HUD);
2148 if(HC_gauge_selected < 0){
2152 // get slider position
2153 gr_init_alphacolor(&HUD_config.clr[HC_gauge_selected], HUD_config.clr[HC_gauge_selected].red, HUD_config.clr[HC_gauge_selected].green, pos, HUD_config.clr[HC_gauge_selected].alpha, AC_TYPE_HUD);
2156 hud_config_recalc_alpha_slider();
2160 void hud_config_process_colors()
2164 void hud_config_color_init()
2166 HC_current_file = -1;
2168 // get a list of all hcf files
2169 memset(HC_filenames, 0, sizeof(char*) * MAX_HCF_FILES);
2170 HC_num_files = cf_get_file_list(MAX_HCF_FILES, HC_filenames, CF_TYPE_PLAYERS, "*.hcf", CF_SORT_NAME);
2173 void hud_config_color_close()
2178 for(idx=0; idx<HC_num_files; idx++){
2179 if(HC_filenames[idx] != NULL){
2180 free(HC_filenames[idx]);
2181 HC_filenames[idx] = NULL;
2186 void hud_config_select_all_toggle(int toggle)
2191 // if we're turning off
2193 // determine if on/off/popup buttons should be shown
2194 hud_config_set_button_state();
2199 hud_config_synch_ui();
2201 // if we had a gauge previously selected, use its color everywhere
2202 if(HC_gauge_selected < 0){
2203 r = HUD_config.clr[HUD_RADAR].red;
2204 g = HUD_config.clr[HUD_RADAR].green;
2205 b = HUD_config.clr[HUD_RADAR].blue;
2206 a = HUD_config.clr[HUD_RADAR].alpha;
2208 r = HUD_config.clr[HC_gauge_selected].red;
2209 g = HUD_config.clr[HC_gauge_selected].green;
2210 b = HUD_config.clr[HC_gauge_selected].blue;
2211 a = HUD_config.clr[HC_gauge_selected].alpha;
2213 hud_config_stuff_colors(r, g, b);
2215 // no gauge selected
2216 HC_gauge_selected = -1;
2218 // enable all sliders
2219 HC_color_sliders[HCS_RED].enable();
2220 HC_color_sliders[HCS_GREEN].enable();
2221 HC_color_sliders[HCS_BLUE].enable();
2222 HC_color_sliders[HCS_ALPHA].enable();
2223 HC_color_sliders[HCS_RED].unhide();
2224 HC_color_sliders[HCS_GREEN].unhide();
2225 HC_color_sliders[HCS_BLUE].unhide();
2226 HC_color_sliders[HCS_ALPHA].unhide();
2227 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(r) );
2228 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(g) );
2229 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(b) );
2230 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(a) );
2233 hud_config_recalc_alpha_slider();
2235 // disable all three buttons
2236 hud_config_button_disable(HCB_ON);
2237 hud_config_button_disable(HCB_OFF);
2238 hud_config_button_disable(HCB_POPUP);