2 * $Logfile: /Freespace2/code/Hud/HUDconfig.cpp $
7 * C module to handle HUD configuration
10 * Revision 1.3 2002/06/01 07:12:33 relnev
11 * a few NDEBUG updates.
13 * removed a few warnings.
15 * Revision 1.2 2002/05/07 03:16:45 theoddone33
16 * The Great Newline Fix
18 * Revision 1.1.1.1 2002/05/03 03:28:09 root
22 * 19 10/25/99 5:43p Jefff
23 * reassigned some xstr ids
25 * 18 10/14/99 2:50p Jefff
28 * 17 9/02/99 5:09p Jefff
29 * disabled options now draw as a dark gray color
31 * 16 9/01/99 11:16a Dave
32 * Reverse direction of HUD config RGB sliders.
34 * 15 8/19/99 3:17p Dave
35 * Fixed talking head disappearing.
37 * 14 8/19/99 2:33p Dave
38 * Make sure support gauge and net lag gauge are configurable.
40 * 13 8/16/99 5:25p Dave
41 * New hud config. Whee!
43 * 12 8/16/99 4:04p Dave
44 * Big honking checkin.
46 * 11 7/30/99 10:31p Dave
47 * Added comm menu to the configurable hud files.
49 * 10 7/30/99 11:05a Jasenw
50 * Fixed hud config for new text warning gauge,
52 * 9 7/24/99 1:54p Dave
53 * Hud text flash gauge. Reworked dead popup to use 4 buttons in red-alert
56 * 8 7/15/99 9:20a Andsager
57 * FS2_DEMO initial checkin
59 * 7 6/08/99 2:33p Dave
60 * Fixed release build warning. Put in hud config stuff.
62 * 6 6/08/99 1:14a Dave
63 * Multi colored hud test.
65 * 5 1/30/99 5:08p Dave
66 * More new hi-res stuff.Support for nice D3D textures.
68 * 4 10/13/98 9:28a Dave
69 * Started neatening up freespace.h. Many variables renamed and
70 * reorganized. Added AlphaColors.[h,cpp]
72 * 3 10/07/98 11:28a Dave
73 * Removed wacky pragma.
75 * 2 10/07/98 10:53a Dave
78 * 1 10/07/98 10:49a Dave
80 * 72 8/25/98 1:48p Dave
81 * First rev of EMP effect. Player side stuff basically done. Next comes
84 * 71 6/09/98 10:31a Hoffoss
85 * Created index numbers for all xstr() references. Any new xstr() stuff
86 * added from here on out should be added to the end if the list. The
87 * current list count can be found in FreeSpace.cpp (search for
90 * 70 6/01/98 11:43a John
91 * JAS & MK: Classified all strings for localization.
93 * 69 5/24/98 9:01p Lawrance
94 * Add commit sounds when accept is pressed
96 * 68 5/23/98 3:31p Dave
97 * Tweaked pxo code. Fixed observer HUD stuff.
99 * 67 5/08/98 10:12a Lawrance
100 * play sound for auto-target toggle, don't display HUD message
102 * 66 4/29/98 6:00p Dave
103 * Fixed chatbox font colors. Made observer offscreen indicators work.
104 * Numerous small UI fixes. Fix rank limitations for mp games.
106 * 65 4/20/98 12:04a Lawrance
107 * tweak how button light up
109 * 64 4/16/98 4:07p Hoffoss
110 * Fixed bug with palette reseting when loading a new pilot. Also made
111 * barracks default to palette merging mode.
113 * 63 4/16/98 10:48a Lawrance
114 * reposition a couple of gauges
116 * 62 4/14/98 6:16p Lawrance
117 * Fix bug that was preventing non-green HUD color from getting set.
119 * 61 4/12/98 5:32p Lawrance
120 * don't show talking head in demo version of hud config
122 * 60 4/10/98 12:07a Lawrance
123 * Fix up talking head gauge.
125 * 59 4/08/98 10:15a Lawrance
126 * allow kills gauge to be popup
128 * 58 4/08/98 1:18a Lawrance
129 * Add in kills gauge art to HUD config.
131 * 57 4/05/98 7:42p Lawrance
134 * 56 4/03/98 3:13p Dave
135 * More work on udp reliable transport. Fixed observer hud offset problem.
136 * Made observer join and ingame join work again. Put subnet broadcasting
139 * 55 4/01/98 6:46p Lawrance
140 * default damage popup to on
142 * 54 3/31/98 11:47p Lawrance
143 * Add popup functionality for the countermeasure gauge.
145 * 53 3/30/98 4:48p Lawrance
146 * Turn on offscreen indicator range by default
148 * 52 3/26/98 5:45p Lawrance
149 * Added new gauges to HUD config
151 * 51 3/15/98 4:17p Dave
152 * Fixed oberver hud problems. Put in handy netplayer macros. Reduced size
153 * of network orientation matrices.
155 * 50 3/12/98 5:45p Dave
156 * Put in new observer HUD. Made it possible for observers to join at the
157 * beginning of a game and follow it around as an observer full-time.
159 * 49 3/11/98 12:13a Lawrance
160 * redraw pressed buttons
162 * 48 3/05/98 12:39a Lawrance
163 * show comma in 10000
165 * 47 2/22/98 4:30p John
166 * More string externalization classification
168 * 46 2/22/98 4:17p John
169 * More string externalization classification... 190 left to go!
171 * 45 2/22/98 12:19p John
172 * Externalized some strings
174 * 44 1/23/98 6:24p Lawrance
175 * Implement wingman status gauge
177 * 43 1/22/98 10:45p Lawrance
178 * Add coutermeasures and objective display to hud config.
180 * 42 1/19/98 11:37p Lawrance
181 * Fixing Optimization build warnings
183 * 41 1/17/98 10:02p Lawrance
184 * Fix bug with damage popup that would sometimes display with <none>.
186 * 40 1/17/98 1:30a Lawrance
187 * Add countermeasure gauge
189 * 39 1/15/98 5:10p Allender
190 * ton of interface changes. chatbox in multiplayer now behaves
191 * differently than before. It's always active in any screen that uses
192 * it. Only non-printatble characters will get passed back out from
195 * 38 1/14/98 11:07p Lawrance
196 * Hook in brightness slider to HUD config.
198 * 37 1/14/98 6:42p Hoffoss
199 * Massive changes to UI code. A lot cleaner and better now. Did all
200 * this to get the new UI_DOT_SLIDER to work properly, which the old code
201 * wasn't flexible enough to handle.
203 * 36 1/14/98 12:25p Lawrance
204 * center gauge text, use correct game palette.
206 * 35 1/13/98 5:33p Lawrance
207 * Tweaking HUD config.
209 * 34 1/13/98 2:20p John
210 * Added code to load palette based on hud color. Added code to turn off
211 * nebulas using detail. Added code in WinMain to time out after waiting
212 * too long for window creation.
214 * 33 1/13/98 10:22a Lawrance
215 * Integrate new art changes.
217 * 32 1/12/98 11:16p Lawrance
218 * Wonderful HUD config.
220 * 31 1/10/98 12:41a Lawrance
221 * start work on new HUD config
223 * 30 1/05/98 9:38p Lawrance
224 * Implement flashing HUD gauges.
226 * 29 1/02/98 9:10p Lawrance
227 * Big changes to how colors get set on the HUD.
229 * 28 12/16/97 9:13p Lawrance
230 * Integrate new gauges into HUD config.
232 * 27 12/01/97 12:27a Lawrance
233 * redo default alpha color for HUD, make it easy to modify in the future
241 #include "hudconfig.h"
242 #include "freespace.h"
243 #include "gamesequence.h"
254 #include "hudobserver.h"
256 #include "missionshipchoice.h"
258 #include "alphacolors.h"
262 //////////////////////////////////////////////////////////////////////////////
264 //////////////////////////////////////////////////////////////////////////////
266 #define MAX_HCF_FILES 30
267 int HC_num_files = -1; // num known hcf files
268 int HC_current_file = -1; // current hcf file
269 char *HC_filenames[MAX_HCF_FILES];
271 char HC_fname[MAX_FILENAME_LEN+1] = "";
272 UI_INPUTBOX HC_fname_input;
273 int HC_fname_coords[GR_NUM_RESOLUTIONS][4] = {
282 HUD_CONFIG_TYPE HUD_config; // Player HUD configuration
284 // specify the max distance that the radar should detect objects
285 // See RR_ #defines in HUDconfig.h.
286 float Radar_ranges[RR_MAX_RANGES] = {
289 10000000.0f, // infinity
292 char *Radar_range_text(int n)
294 #if RR_MAX_RANGES != 3
295 #error Number of ranges is wrong!
300 return XSTR( "2000 M", 246);
302 return XSTR( "10,000 M", 247);
304 return XSTR( "infinity", 248);
309 // default flags for observer HUD
310 int HUD_observer_default_flags =
312 (1<<HUD_CENTER_RETICLE) |
313 (1<<HUD_OFFSCREEN_INDICATOR) |
314 (1<<HUD_MESSAGE_LINES) |
315 (1<<HUD_HOSTILE_TRIANGLE) |
316 (1<<HUD_TARGET_TRIANGLE) |
317 (1<<HUD_TARGET_MINI_ICON) |
318 (1<<HUD_TARGET_MONITOR)
321 int HUD_observer_default_flags2 = {
322 (1<<(HUD_OFFSCREEN_RANGE - 32))
325 // default flags for regular HUD
326 int HUD_config_default_flags =
328 (1<<HUD_LEAD_INDICATOR) |
329 (1<<HUD_ORIENTATION_TEE) |
330 (1<<HUD_HOSTILE_TRIANGLE) |
331 (1<<HUD_TARGET_TRIANGLE) |
332 (1<<HUD_MISSION_TIME) |
333 (1<<HUD_RETICLE_CIRCLE) |
334 (1<<HUD_THROTTLE_GAUGE) |
336 (1<<HUD_TARGET_MONITOR) |
337 (1<<HUD_CENTER_RETICLE) |
338 (1<<HUD_TARGET_MONITOR_EXTRA_DATA) |
339 (1<<HUD_TARGET_SHIELD_ICON) |
340 (1<<HUD_PLAYER_SHIELD_ICON) |
342 (1<<HUD_AUTO_TARGET) |
343 (1<<HUD_AUTO_SPEED) |
344 (1<<HUD_WEAPONS_GAUGE) |
345 (1<<HUD_ESCORT_VIEW) |
346 (1<<HUD_DIRECTIVES_VIEW) |
347 (1<<HUD_THREAT_GAUGE) |
348 (1<<HUD_AFTERBURNER_ENERGY) |
349 (1<<HUD_WEAPONS_ENERGY) |
350 (1<<HUD_WEAPON_LINKING_GAUGE) |
351 (1<<HUD_TARGET_MINI_ICON) |
352 (1<<HUD_OFFSCREEN_INDICATOR) |
353 (1<<HUD_TALKING_HEAD) |
354 (1<<HUD_DAMAGE_GAUGE) |
355 (1<<HUD_MESSAGE_LINES) |
356 (1<<HUD_MISSILE_WARNING_ARROW) |
357 (1<<HUD_CMEASURE_GAUGE) |
358 (1<<HUD_OBJECTIVES_NOTIFY_GAUGE) |
359 (1<<HUD_WINGMEN_STATUS)
362 int HUD_config_default_flags2 =
364 (1<<(HUD_OFFSCREEN_RANGE-32)) |
365 (1<<(HUD_KILLS_GAUGE-32)) |
366 (1<<(HUD_ATTACKING_TARGET_COUNT-32)) |
367 (1<<(HUD_SUPPORT_GAUGE-32)) |
368 (1<<(HUD_LAG_GAUGE-32))
371 // bits to tell whether a given gauge should be treated as pop-up or not
372 int HUD_default_popup_mask =
374 0 | // (1<<HUD_LEAD_INDICATOR) |
375 0 | // (1<<HUD_ORIENTATION_TEE) |
376 0 | // (1<<HUD_HOSTILE_TRIANGLE) |
377 0 | // (1<<HUD_TARGET_TRIANGLE) |
378 0 | // (1<<HUD_MISSION_TIME) |
379 0 | // (1<<HUD_RETICLE_CIRCLE) |
380 0 | // (1<<HUD_THROTTLE_GAUGE) |
381 0 | // (1<<HUD_RADAR) |
382 0 | // (1<<HUD_TARGET_MONITOR) |
383 0 | // (1<<HUD_CENTER_RETICLE) |
384 0 | // (1<<HUD_TARGET_MONITOR_EXTRA_DATA) |
385 0 | // (1<<HUD_TARGET_SHIELD_ICON) |
386 0 | // (1<<HUD_PLAYER_SHIELD_ICON) |
387 0 | // (1<<HUD_ETS_GAUGE) |
388 0 | // (1<<HUD_AUTO_TARGET) |
389 0 | // (1<<HUD_AUTO_SPEED) |
390 0 | // (1<<HUD_WEAPONS_GAUGE) |
391 0 | // (1<<HUD_ESCORT_VIEW) |
392 0 | // (1<<HUD_DIRECTIVES_VIEW) |
393 0 | // (1<<HUD_THREAT_GAUGE) |
394 0 | // (1<<HUD_AFTERBURNER_ENERGY) |
395 0 | // (1<<HUD_WEAPONS_ENERGY) |
396 0 | // (1<<HUD_WEAPON_LINKING_GAUGE) |
397 0 | // (1<<HUD_TARGET_MINI_ICON) |
398 0 | //(1<<HUD_OFFSCREEN_INDICATOR)
402 0 | // missile warning arrow
403 0 | // countermeasures
407 int HUD_default_popup_mask2 =
409 0 | // offscreen indicator range
414 void hud_config_color_save(char *name);
415 void hud_config_select_all_toggle(int toggle);
417 int HC_select_all = 0;
419 //////////////////////////////////////////////////////////////////////////////
421 //////////////////////////////////////////////////////////////////////////////
424 #pragma warning(disable:4710)
427 char *Hud_config_fname[GR_NUM_RESOLUTIONS] = {
432 char *Hud_config_mask_fname[GR_NUM_RESOLUTIONS] = {
437 struct HC_gauge_region
449 HC_gauge_region(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){}
453 struct HC_gauge_region HC_gauge_regions[GR_NUM_RESOLUTIONS][NUM_HUD_GAUGES] =
457 HC_gauge_region("HCB_35", 407, 69, 35, 1, 0, -1, 0, 2), // lead indicator
458 HC_gauge_region("HCB_36", 305, 119, 36, 1, 0, -1, 0, 2), // orientation tee
459 HC_gauge_region("none", 1, 1, -1, 1, 0, -1, 0, 0), // hostile triangle
460 HC_gauge_region("HCB_37", 391, 107, 37, 1, 0, -1, 0, 2), // target triangle
461 HC_gauge_region("HCB_63", 575, 352, 63, 0, 0, -1, 0, 0), // mission time
462 HC_gauge_region("none", 1, 1, 1, 0, 0, -1, 0, 0), // reticle circle?
463 HC_gauge_region("HCB_40", 285, 146, 40, 0, 0, -1, 0, 0), // throttle gauge
464 HC_gauge_region("HCB_50", 317, 291, 50, 0, 0, -1, 0, 0), // radar
465 HC_gauge_region("HCB_31", 123, 249, 31, 0, 0, -1, 0, 0), // target monitor
466 HC_gauge_region("HCB_41", 361, 188, 41, 0, 0, -1, 0, 0), // center of reticle
467 HC_gauge_region("HCB_30", 123, 221, 30, 0, 0, -1, 0, 0), // extra target data
468 HC_gauge_region("HCB_49", 237, 303, 49, 0, 0, -1, 0, 0), // target shield icon
469 HC_gauge_region("HCB_51", 435, 304, 51, 0, 0, -1, 0, 0), // player shield icon
470 HC_gauge_region("HCB_58", 524, 299, 58, 0, 1, -1, 0, 0), // ets gauge
471 HC_gauge_region("HCB_61", 566, 299, 61, 0, 1, -1, 0, 0), // auto target
472 HC_gauge_region("HCB_62", 566, 317, 62, 0, 1, -1, 0, 0), // auto speed
473 HC_gauge_region("HCB_55", 504, 216, 55, 0, 1, -1, 0, 0), // weapons gauge
474 HC_gauge_region("HCB_54", 496, 166, 54, 0, 1, -1, 0, 0), // escort view
475 HC_gauge_region("HCB_29", 123, 142, 29, 0, 0, -1, 0, 0), // directives view
476 HC_gauge_region("HCB_43", 398, 147, 43, 0, 0, -1, 0, 0), // threat gauge
477 HC_gauge_region("HCB_39", 250, 212, 39, 0, 0, -1, 0, 0), // afterburner energy
478 HC_gauge_region("HCB_44", 449, 212, 44, 0, 0, -1, 0, 0), // weapons energy
479 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // weapon linking
480 HC_gauge_region("HCB_42", 356, 232, 42, 0, 1, -1, 0, 0), // target mini icon (shield)
481 HC_gauge_region("HCB_34", 438, 5, 34, 1, 0, -1, 0, 2), // offscreen indicator
482 HC_gauge_region("HCB_28", 123, 31, 28, 0, 0, -1, 0, 0), // talking head
483 HC_gauge_region("HCB_32", 309, 33, 32, 0, 1, -1, 0, 0), // damage gauge
484 HC_gauge_region("HCB_27", 124, 19, 27, 0, 0, -1, 0, 0), // message lines
485 HC_gauge_region("HCB_45", 307, 249, 45, 1, 0, -1, 0, 1), // missile warnings
486 HC_gauge_region("HCB_56", 505, 271, 56, 0, 1, -1, 0, 0), // cmeasure gauge
487 HC_gauge_region("HCB_33", 309, 87, 33, 0, 0, -1, 0, 0), // objectives notify gauge
488 HC_gauge_region("HCB_53", 546, 117, 53, 0, 0, -1, 0, 0), // wingman status gauge
489 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // offscreen indicator range
490 HC_gauge_region("HCB_57", 505, 285, 57, 0, 1, -1, 0, 0), // kills gauge
491 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // attacking target count
492 HC_gauge_region("HCB_38", 342, 138, 38, 0, 0, -1, 0, 0), // text flash gauge
493 HC_gauge_region("HCB_52", 465, 8, 52, 0, 0, -1, 0, 0), // comm menu
494 HC_gauge_region("HCB_46", 324, 264, 46, 0, 0, -1, 0, 0), // support view gauge
495 HC_gauge_region("HCB_47", 418, 262, 47, 0, 0, -1, 0, 0), // netlag icon gauge
500 HC_gauge_region("2_HCB_35", 652, 112, 35, 1, 0, -1, 0, 2), // lead indicator
501 HC_gauge_region("2_HCB_36", 489, 191, 36, 1, 0, -1, 0, 2), // orientation tee
502 HC_gauge_region("none", 1, 1, -1, 1, 0, -1, 0, 0), // hostile triangle
503 HC_gauge_region("2_HCB_37", 626, 173, 37, 1, 0, -1, 0, 2), // target triangle
504 HC_gauge_region("2_HCB_63", 920, 564, 63, 0, 0, -1, 0, 0), // mission time
505 HC_gauge_region("none", 1, 1, 1, 0, 0, -1, 0, 0), // reticle circle?
506 HC_gauge_region("2_HCB_40", 456, 235, 40, 0, 0, -1, 0, 0), // throttle gauge
507 HC_gauge_region("2_HCB_50", 508, 466, 50, 0, 0, -1, 0, 0), // radar
508 HC_gauge_region("2_HCB_31", 198, 399, 31, 0, 0, -1, 0, 0), // target monitor
509 HC_gauge_region("2_HCB_41", 578, 302, 41, 0, 0, -1, 0, 0), // center of reticle
510 HC_gauge_region("2_HCB_30", 198, 354, 30, 0, 0, -1, 0, 0), // extra target data
511 HC_gauge_region("2_HCB_49", 380, 485, 49, 0, 0, -1, 0, 0), // target shield icon
512 HC_gauge_region("2_HCB_51", 696, 486, 51, 0, 0, -1, 0, 0), // player shield icon
513 HC_gauge_region("2_HCB_58", 839, 479, 58, 0, 1, -1, 0, 0), // ets gauge
514 HC_gauge_region("2_HCB_61", 906, 479, 61, 0, 1, -1, 0, 0), // auto target
515 HC_gauge_region("2_HCB_62", 906, 508, 62, 0, 1, -1, 0, 0), // auto speed
516 HC_gauge_region("2_HCB_55", 807, 346, 55, 0, 1, -1, 0, 0), // weapons gauge
517 HC_gauge_region("2_HCB_54", 794, 265, 54, 0, 1, -1, 0, 0), // escort view
518 HC_gauge_region("2_HCB_29", 198, 228, 29, 0, 0, -1, 0, 0), // directives view
519 HC_gauge_region("2_HCB_43", 637, 237, 43, 0, 0, -1, 0, 0), // threat gauge
520 HC_gauge_region("2_HCB_39", 403, 339, 39, 0, 0, -1, 0, 0), // afterburner energy
521 HC_gauge_region("2_HCB_44", 719, 339, 44, 0, 0, -1, 0, 0), // weapons energy
522 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // weapon linking
523 HC_gauge_region("2_HCB_42", 569, 371, 42, 0, 1, -1, 0, 0), // target mini icon (shield)
524 HC_gauge_region("2_HCB_34", 701, 9, 34, 1, 0, -1, 0, 2), // offscreen indicator
525 HC_gauge_region("2_HCB_28", 198, 50, 28, 0, 0, -1, 0, 0), // talking head
526 HC_gauge_region("2_HCB_32", 495, 55, 32, 0, 1, -1, 0, 0), // damage gauge
527 HC_gauge_region("2_HCB_27", 199, 30, 27, 0, 0, -1, 0, 0), // message lines
528 HC_gauge_region("2_HCB_45", 491, 399, 45, 1, 0, -1, 0, 1), // missile warnings
529 HC_gauge_region("2_HCB_56", 808, 433, 56, 0, 1, -1, 0, 0), // cmeasure gauge
530 HC_gauge_region("2_HCB_33", 495, 141, 33, 0, 0, -1, 0, 0), // objectives notify gauge
531 HC_gauge_region("2_HCB_53", 873, 188, 53, 0, 0, -1, 0, 0), // wingman status gauge
532 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // offscreen indicator range
533 HC_gauge_region("2_HCB_57", 808, 456, 57, 0, 1, -1, 0, 0), // kills gauge
534 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // attacking target count
535 HC_gauge_region("2_HCB_38", 548, 222, 38, 0, 0, -1, 0, 0), // text flash gauge
536 HC_gauge_region("2_HCB_52", 744, 14, 52, 0, 0, -1, 0, 0), // comm menu
537 HC_gauge_region("2_HCB_46", 520, 422, 46, 0, 0, -1, 0, 0), // support view gauge
538 HC_gauge_region("2_HCB_47", 670, 419, 47, 0, 0, -1, 0, 0), // netlag icon gauge
544 #pragma warning(default:4710)
547 int HC_gauge_description_coords[GR_NUM_RESOLUTIONS][3] = {
556 char *HC_gauge_descriptions(int n)
560 return XSTR( "lead indicator", 249);
562 return XSTR( "target orientation", 250);
564 return XSTR( "closest attacking hostile", 251);
566 return XSTR( "current target direction", 252);
568 return XSTR( "mission time", 253);
570 return XSTR( "reticle", 254);
572 return XSTR( "throttle", 255);
574 return XSTR( "radar", 256);
576 return XSTR( "target monitor", 257);
578 return XSTR( "center of reticle", 258);
580 return XSTR( "extra target info", 259);
582 return XSTR( "target shield", 260);
584 return XSTR( "player shield", 261);
586 return XSTR( "power management", 262);
588 return XSTR( "auto-target icon", 263);
590 return XSTR( "auto-speed-match icon", 264);
592 return XSTR( "weapons display", 265);
594 return XSTR( "monitoring view", 266);
596 return XSTR( "directives view", 267);
598 return XSTR( "threat gauge", 268);
600 return XSTR( "afterburner energy", 269);
602 return XSTR( "weapons energy", 270);
604 return XSTR( "weapon linking", 271);
606 return XSTR( "target hull/shield icon", 272);
608 return XSTR( "offscreen indicator", 273);
610 return XSTR( "comm video", 274);
612 return XSTR( "damage display", 275);
614 return XSTR( "message output", 276);
616 return XSTR( "locked missile direction", 277);
618 return XSTR( "countermeasures", 278);
620 return XSTR( "objective notify", 279);
622 return XSTR( "wingmen status", 280);
624 return XSTR( "offscreen range", 281);
626 return XSTR( "kills gauge", 282);
628 return XSTR( "attacking target count", 283);
630 return XSTR("warning flash", 1459);
632 return XSTR("comm menu", 1460);
634 return XSTR("support gauge", 1461);
636 return XSTR("lag gauge", 1462);
641 #define NUM_HUD_BUTTONS 20
644 #define HCB_GREEN_UP 1
645 #define HCB_BLUE_UP 2
647 #define HCB_RED_DOWN 4
648 #define HCB_GREEN_DOWN 5
649 #define HCB_BLUE_DOWN 6
654 #define HCB_SAVE_HCF 11
655 #define HCB_PREV_HCF 12
656 #define HCB_NEXT_HCF 13
660 #define HCB_SELECT_ALL 17
662 #define HCB_ACCEPT 19
665 #pragma warning(disable : 4710)
668 ui_button_info HC_buttons[GR_NUM_RESOLUTIONS][NUM_HUD_BUTTONS] = {
670 ui_button_info("HCB_00", 6, 27, -1, -1, 0),
671 ui_button_info("HCB_01", 30, 27, -1, -1, 1),
672 ui_button_info("HCB_02", 55, 27, -1, -1, 2),
673 ui_button_info("HCB_03", 80, 27, -1, -1, 3),
674 ui_button_info("HCB_08", 6, 291, -1, -1, 8),
675 ui_button_info("HCB_09", 30, 291, -1, -1, 9),
676 ui_button_info("HCB_10", 55, 291, -1, -1, 10),
677 ui_button_info("HCB_11", 80, 291, -1, -1, 11),
678 ui_button_info("HCB_12", 4, 329, -1, -1, 12),
679 ui_button_info("HCB_13", 4, 348, -1, -1, 13),
680 ui_button_info("HCB_14", 4, 367, -1, -1, 14),
681 ui_button_info("HCB_15", 2, 439, -1, -1, 15),
682 ui_button_info("HCB_16", 266, 456, -1, -1, 16),
683 ui_button_info("HCB_17", 292, 456, -1, -1, 17),
684 ui_button_info("HCB_18", 327, 421, -1, -1, 18),
685 ui_button_info("HCB_19", 327, 440, -1, -1, 19),
686 ui_button_info("HCB_20", 327, 459, -1, -1, 20),
687 ui_button_info("HCB_24", 472, 436, -1, -1, 24),
688 ui_button_info("HCB_25", 523, 433, -1, -1, 25),
689 ui_button_info("HCB_26", 576, 434, -1, -1, 26),
692 ui_button_info("2_HCB_00", 9, 44, -1, -1, 0),
693 ui_button_info("2_HCB_01", 48, 44, -1, -1, 1),
694 ui_button_info("2_HCB_02", 88, 44, -1, -1, 2),
695 ui_button_info("2_HCB_03", 127, 44, -1, -1, 3),
696 ui_button_info("2_HCB_08", 9, 466, -1, -1, 8),
697 ui_button_info("2_HCB_09", 48, 466, -1, -1, 9),
698 ui_button_info("2_HCB_10", 88, 466, -1, -1, 10),
699 ui_button_info("2_HCB_11", 127, 466, -1, -1, 11),
700 ui_button_info("2_HCB_12", 6, 526, -1, -1, 12),
701 ui_button_info("2_HCB_13", 6, 556, -1, -1, 13),
702 ui_button_info("2_HCB_14", 6, 586, -1, -1, 14),
703 ui_button_info("2_HCB_15", 3, 703, -1, -1, 15),
704 ui_button_info("2_HCB_16", 426, 730, -1, -1, 16),
705 ui_button_info("2_HCB_17", 467, 730, -1, -1, 17),
706 ui_button_info("2_HCB_18", 524, 674, -1, -1, 18),
707 ui_button_info("2_HCB_19", 524, 704, -1, -1, 19),
708 ui_button_info("2_HCB_20", 524, 734, -1, -1, 20),
709 ui_button_info("2_HCB_24", 755, 698, -1, -1, 24),
710 ui_button_info("2_HCB_25", 837, 693, -1, -1, 25),
711 ui_button_info("2_HCB_26", 922, 695, -1, -1, 26),
716 #define NUM_HUD_TEXT 15
717 UI_XSTR HC_text[GR_NUM_RESOLUTIONS][NUM_HUD_TEXT] = {
719 { "R", 1512, 14, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
720 { "G", 1513, 37, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
721 { "B", 1514, 62, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
722 { "I", 1515, 90, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
723 { "On", 1285, 36, 334, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_ON].button },
724 { "Off", 1286, 36, 353, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_OFF].button },
725 { "Popup", 1453, 36, 372, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_POPUP].button },
726 { "Save", 1454, 51, 428, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SAVE_HCF].button },
727 { "Amber", 1455, 364, 426, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_AMBER].button },
728 { "Blue", 1456, 364, 445, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_BLUE].button },
729 { "Green", 1457, 364, 464, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_GREEN].button },
730 { "Select", 1550, 442, 413, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SELECT_ALL].button },
731 { "All", 1551, 442, 424, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SELECT_ALL].button },
732 { "Reset", 1337, 515, 413, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_RESET].button },
733 { "Accept", 1035, 573, 413, UI_XSTR_COLOR_PINK, -1, &HC_buttons[0][HCB_ACCEPT].button },
736 { "R", 1512, 23, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
737 { "G", 1513, 60, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
738 { "B", 1514, 100, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
739 { "I", 1515, 144, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
740 { "On", 1285, 58, 536, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_ON].button },
741 { "Off", 1286, 58, 566, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_OFF].button },
742 { "Popup", 1453, 58, 596, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_POPUP].button },
743 { "Save", 1454, 82, 688, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SAVE_HCF].button },
744 { "Amber", 1455, 582, 685, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_AMBER].button },
745 { "Blue", 1456, 582, 715, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_BLUE].button },
746 { "Green", 1457, 582, 745, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_GREEN].button },
747 { "Select", 1550, 760, 671, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SELECT_ALL].button },
748 { "All", 1551, 760, 682, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SELECT_ALL].button },
749 { "Reset", 1337, 850, 669, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_RESET].button },
750 { "Accept", 1035, 930, 670, UI_XSTR_COLOR_PINK, -1, &HC_buttons[1][HCB_ACCEPT].button },
754 void hud_config_set_rgb(int gauge, int r, int g, int b);
755 void hud_config_set_alpha(int gauge, int a);
758 #define NUM_HC_SPECIAL_BITMAPS 2
759 #define HC_SPECIAL_RETICLE 0
760 #define HC_SPECIAL_TEXT 1
761 typedef struct HC_special_bitmap
768 HC_special_bitmap HC_special_bitmaps[NUM_HC_SPECIAL_BITMAPS] =
771 {"HG_00a", 272, 146, -1},
772 {"HG_04a", 132, 271, -1},
777 static int HC_background_bitmap;
778 static UI_WINDOW HC_ui_window;
780 static int HC_gauge_hot; // mouse is over this gauge
781 static int HC_gauge_selected; // gauge is selected
785 #define HC_NUM_SLIDERS 1
786 #define HC_BRIGHTNESS_SLIDER 0
795 // left and right buttons
797 int left_mask, left_x, left_y;
798 char *right_filename;
799 int right_mask, right_x, right_y;
802 UI_DOT_SLIDER_NEW slider; // because we have a class inside this struct, we need the constructor below..
804 hc_sliders(char *name, int x1, int y1, int xt1, int yt1, int h, int _dot_w, int _dots, char *_left_filename, int _left_mask, int _left_x, int _left_y, char *_right_filename, int _right_mask, int _right_x, int _right_y) :
805 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) {}
808 hc_sliders HC_sliders[GR_NUM_RESOLUTIONS][HC_NUM_SLIDERS] = {
810 hc_sliders( "HCB_22", 419, 379, -1, -1, 22, 20, 10,
811 "HCB_23", 23, 611, 379,
812 "HCB_21", 21, 391, 379)
815 hc_sliders( "2_HCB_22", 670, 606, -1, -1, 22, 32, 10,
816 "2_HCB_23", 23, 698, 606,
817 "2_HCB_21", 21, 625, 606),
824 typedef struct hc_col {
828 hc_col HC_colors[3] =
830 {0, 255, 0}, // Green - get RGB from Adam so it matches palette?-??.pcx
831 {67, 123, 203}, // Blue - get RGB from Adam so it matches palette?-??.pcx
832 {255, 197, 0}, // Amber - get RGB from Adam so it matches palette?-??.pcx
835 static HUD_CONFIG_TYPE HUD_config_backup; // backup HUD config, used to restore old config if changes not applied
836 static int HUD_config_inited = 0;
839 void hud_config_red_slider();
840 void hud_config_green_slider();
841 void hud_config_blue_slider();
842 void hud_config_alpha_slider_up();
843 void hud_config_alpha_slider_down();
844 void hud_config_recalc_alpha_slider();
845 void hud_config_process_colors();
846 void hud_config_color_init();
847 void hud_config_color_close();
848 #define NUM_HC_SLIDERS 4
853 UI_SLIDER2 HC_color_sliders[NUM_HC_SLIDERS];
854 int HC_slider_coords[GR_NUM_RESOLUTIONS][NUM_HC_SLIDERS][4] = {
865 { 133, 85, 32, 350 },
868 #define HCS_CONV(__v) ( 255 - (__v) )
870 char *HC_slider_fname[GR_NUM_RESOLUTIONS] = {
876 void hud_config_synch_sliders(int i)
879 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HUD_config.clr[i].red) );
880 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HUD_config.clr[i].green) );
881 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HUD_config.clr[i].blue) );
882 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(HUD_config.clr[i].alpha) );
886 // reset some ui components based on HUD config data
887 void hud_config_synch_ui()
889 // game_load_palette();
890 HUD_init_hud_color_array();
891 // HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos = HUD_color_alpha-3; // convert to value from 0-10
893 // sync sliders to currently selected gauge
894 hud_config_synch_sliders(HC_gauge_selected);
897 // Init the UI components
898 void hud_config_init_ui()
901 struct HC_gauge_region *hg;
902 struct ui_button_info *hb;
904 // common_set_interface_palette("HUDConfigPalette"); // set the interface palette
905 hud_config_synch_ui();
906 HC_background_bitmap = bm_load(Hud_config_fname[gr_screen.res]);
908 HC_ui_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
909 HC_ui_window.set_mask_bmap(Hud_config_mask_fname[gr_screen.res]);
911 for (i=0; i<NUM_HUD_GAUGES; i++) {
912 hg = &HC_gauge_regions[gr_screen.res][i];
913 if ( !stricmp(hg->filename, NOX("none")) ) {
916 hg->button.create(&HC_ui_window, "", hg->x, hg->y, 60, 30, 0, 1);
917 // set up callback for when a mouse first goes over a button
918 // hg->button.set_highlight_action(common_play_highlight_sound);
920 hg->button.link_hotspot(hg->hotspot);
922 // if ( hg->use_iff ) {
923 // hg->bitmap = bm_load_animation(hg->filename, &hg->nframes);
925 hg->bitmap = bm_load(hg->filename);
931 for(i=0; i<NUM_HUD_TEXT; i++){
932 HC_ui_window.add_XSTR(&HC_text[gr_screen.res][i]);
935 // initialize sliders
936 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],
937 255, HC_slider_fname[gr_screen.res], hud_config_red_slider, hud_config_red_slider, hud_config_red_slider);
939 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],
940 255, HC_slider_fname[gr_screen.res], hud_config_green_slider, hud_config_green_slider, hud_config_green_slider);
942 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],
943 255, HC_slider_fname[gr_screen.res], hud_config_blue_slider, hud_config_blue_slider, hud_config_blue_slider);
945 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],
946 255, HC_slider_fname[gr_screen.res], hud_config_alpha_slider_up, hud_config_alpha_slider_down, NULL);
948 hud_config_color_init();
950 for (i=0; i<NUM_HUD_BUTTONS; i++) {
951 hb = &HC_buttons[gr_screen.res][i];
952 hb->button.create(&HC_ui_window, "", hb->x, hb->y, 60, 30, 0, 1);
953 // set up callback for when a mouse first goes over a button
954 hb->button.set_bmaps(hb->filename);
955 hb->button.set_highlight_action(common_play_highlight_sound);
956 hb->button.link_hotspot(hb->hotspot);
959 // config file input name
960 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);
961 HC_fname_input.set_text("");
964 for (i=0; i<NUM_HC_SPECIAL_BITMAPS; i++) {
965 HC_special_bitmaps[i].bitmap = bm_load(HC_special_bitmaps[i].filename);
971 for(i=0; i<HC_NUM_SLIDERS; i++){
972 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,
973 HC_sliders[gr_screen.res][i].dots, HC_sliders[gr_screen.res][i].filename,
974 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,
975 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,
976 HC_sliders[gr_screen.res][i].dot_w);
978 HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos = HUD_color_alpha - 3;
983 HC_gauge_selected = -1;
987 strcpy(HC_fname, "");
990 int hud_config_show_flag_is_set(int i)
995 show_flag_set = HUD_config.show_flags & (1<<i);
997 show_flag_set = HUD_config.show_flags2 & (1<<(i-32));
1000 return show_flag_set;
1003 void hud_config_show_flag_set(int i)
1006 HUD_config.show_flags |= (1<<i);
1008 HUD_config.show_flags2 |= (1<<(i-32));
1012 void hud_config_show_flag_clear(int i)
1015 HUD_config.show_flags &= ~(1<<i);
1017 HUD_config.show_flags2 &= ~(1<<(i-32));
1021 int hud_config_popup_flag_is_set(int i)
1026 popup_flag_set = HUD_config.popup_flags & (1<<i);
1028 popup_flag_set = HUD_config.popup_flags2 & (1<<(i-32));
1031 return popup_flag_set;
1034 void hud_config_popup_flag_set(int i)
1037 HUD_config.popup_flags |= (1<<i);
1039 HUD_config.popup_flags2 |= (1<<(i-32));
1043 void hud_config_popup_flag_clear(int i)
1046 HUD_config.popup_flags &= ~(1<<i);
1048 HUD_config.popup_flags2 &= ~(1<<(i-32));
1052 // render all the hud config gauges
1053 void hud_config_render_gauges()
1059 for ( i=0; i<NUM_HUD_GAUGES; i++ ) {
1060 if ( (hud_config_show_flag_is_set(i)) ) {
1061 // set the correct color
1062 if(!HC_gauge_regions[gr_screen.res][i].use_iff){
1063 use_color = HUD_config.clr[i];
1065 if(HC_gauge_regions[gr_screen.res][i].color == 1){
1066 use_color = IFF_colors[IFF_COLOR_TAGGED][0];
1068 use_color = IFF_colors[IFF_COLOR_HOSTILE][0];
1072 if ( (HC_gauge_selected == i) || HC_select_all ) {
1074 } else if ( HC_gauge_hot == i ) {
1079 gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
1080 gr_set_color_fast(&use_color);
1082 // if its off, make it dark gray
1083 gr_init_alphacolor(&use_color, 127, 127, 127, 64);
1084 gr_set_color_fast(&use_color);
1088 if ( HC_gauge_regions[gr_screen.res][i].bitmap >= 0 ) {
1089 gr_set_bitmap(HC_gauge_regions[gr_screen.res][i].bitmap);
1090 gr_aabitmap(HC_gauge_regions[gr_screen.res][i].x, HC_gauge_regions[gr_screen.res][i].y);
1097 // set correct frame if using iff
1098 if ( HC_gauge_regions[i].use_iff ) {
1099 if ( HC_gauge_selected == i ) {
1101 } else if ( HC_gauge_hot == i ) {
1105 // If gauge is disabled, then draw disabled frame
1106 if ( !(hud_config_show_flag_is_set(i)) ) {
1111 if ( HC_gauge_regions[i].bitmap >= 0 ) {
1112 Assert(offset < HC_gauge_regions[i].nframes);
1113 gr_set_bitmap(HC_gauge_regions[i].bitmap+offset);
1114 gr_bitmap(HC_gauge_regions[i].x, HC_gauge_regions[i].y);
1121 // hud_config_init() is called when the game enters the state GS_STATE_HUD_CONFIG
1122 void hud_config_init()
1124 hud_config_init_ui();
1125 hud_config_backup(); // save the HUD configuration in case the player decides to cancel changes
1126 HUD_config_inited = 1;
1129 // check for the mouse over gauge regions
1130 void hud_config_check_regions()
1135 for ( i=0; i<NUM_HUD_GAUGES; i++ ) {
1136 b = &HC_gauge_regions[gr_screen.res][i].button;
1138 // check for mouse over gauges
1139 if ( b->button_hilighted() ) {
1143 if ( b->pressed() ) {
1144 gamesnd_play_iface(SND_USER_SELECT);
1145 HC_gauge_selected = i;
1147 // turn off select all
1148 hud_config_select_all_toggle(0);
1150 // maybe setup rgb sliders
1151 if(HC_gauge_regions[gr_screen.res][i].use_iff){
1152 HC_color_sliders[HCS_RED].hide();
1153 HC_color_sliders[HCS_GREEN].hide();
1154 HC_color_sliders[HCS_BLUE].hide();
1155 HC_color_sliders[HCS_ALPHA].hide();
1157 HC_color_sliders[HCS_RED].disable();
1158 HC_color_sliders[HCS_GREEN].disable();
1159 HC_color_sliders[HCS_BLUE].disable();
1160 HC_color_sliders[HCS_ALPHA].disable();
1162 HC_color_sliders[HCS_RED].enable();
1163 HC_color_sliders[HCS_GREEN].enable();
1164 HC_color_sliders[HCS_BLUE].enable();
1165 HC_color_sliders[HCS_ALPHA].enable();
1167 HC_color_sliders[HCS_RED].unhide();
1168 HC_color_sliders[HCS_GREEN].unhide();
1169 HC_color_sliders[HCS_BLUE].unhide();
1170 HC_color_sliders[HCS_ALPHA].unhide();
1172 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HUD_config.clr[i].red) );
1173 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HUD_config.clr[i].green) );
1174 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HUD_config.clr[i].blue) );
1175 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(HUD_config.clr[i].alpha) );
1178 // recalc alpha slider
1179 hud_config_recalc_alpha_slider();
1184 // set the display flags for a HUD gauge
1185 void hud_config_set_gauge_flags(int gauge_index, int on_flag, int popup_flag)
1188 hud_config_show_flag_set(gauge_index);
1190 hud_config_show_flag_clear(gauge_index);
1194 hud_config_popup_flag_set(gauge_index);
1196 hud_config_popup_flag_clear(gauge_index);
1200 void hud_config_record_color(int color)
1202 HUD_config.main_color = color;
1203 HUD_color_red = HC_colors[color].r;
1204 HUD_color_green = HC_colors[color].g;
1205 HUD_color_blue = HC_colors[color].b;
1208 // Set the HUD color
1209 void hud_config_set_color(int color)
1213 hud_config_record_color(color);
1215 // game_load_palette();
1217 HUD_init_hud_color_array();
1219 // apply the color to all gauges
1220 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1221 gr_init_alphacolor(&HUD_config.clr[idx], HC_colors[color].r, HC_colors[color].g, HC_colors[color].b, (HUD_color_alpha+1)*16);
1225 void hud_config_stuff_colors(int r, int g, int b)
1229 // apply the color to all gauges
1230 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1231 gr_init_alphacolor(&HUD_config.clr[idx], r, g, b, 255);
1235 // leave hud config without accepting changes
1236 void hud_config_cancel()
1238 hud_config_restore();
1239 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
1242 // leave hud config with accepting changes
1243 void hud_config_commit()
1245 gamesnd_play_iface(SND_COMMIT_PRESSED);
1246 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
1249 // move gauge state from on->off->popup
1250 void hud_cycle_gauge_status()
1252 if ( HC_gauge_selected < 0 ) {
1256 // gauge is off, move to popup
1257 if ( !(hud_config_show_flag_is_set(HC_gauge_selected)) ) {
1258 if ( HC_gauge_regions[gr_screen.res][HC_gauge_selected].can_popup ) {
1259 hud_config_set_gauge_flags(HC_gauge_selected, 1, 1);
1261 hud_config_set_gauge_flags(HC_gauge_selected, 1, 0);
1266 // if gauge is popup, move to on
1267 if ( hud_config_popup_flag_is_set(HC_gauge_selected) ) {
1268 hud_config_set_gauge_flags(HC_gauge_selected, 1, 0);
1272 // gauge must be on, move to off
1273 hud_config_set_gauge_flags(HC_gauge_selected, 0, 0);
1276 // handle keyboard input while in hud config
1277 void hud_config_handle_keypresses(int k)
1281 hud_config_cancel();
1283 case KEY_CTRLED+KEY_ENTER:
1284 hud_config_commit();
1287 gamesnd_play_iface(SND_USER_SELECT);
1288 hud_cycle_gauge_status();
1293 // Handlers for when buttons get pressed
1294 void hud_config_button_do(int n)
1297 char name[256] = "";
1301 hud_config_set_color(HUD_COLOR_AMBER);
1302 gamesnd_play_iface(SND_USER_SELECT);
1305 hud_config_set_color(HUD_COLOR_BLUE);
1306 gamesnd_play_iface(SND_USER_SELECT);
1309 hud_config_set_color(HUD_COLOR_GREEN);
1310 gamesnd_play_iface(SND_USER_SELECT);
1313 if ( HC_gauge_selected < 0 ) {
1316 gamesnd_play_iface(SND_USER_SELECT);
1317 hud_config_set_gauge_flags(HC_gauge_selected,1,0);
1320 if ( HC_gauge_selected < 0 ) {
1323 gamesnd_play_iface(SND_USER_SELECT);
1324 hud_config_set_gauge_flags(HC_gauge_selected,0,0);
1327 if ( HC_gauge_selected < 0 ) {
1330 gamesnd_play_iface(SND_USER_SELECT);
1331 hud_config_set_gauge_flags(HC_gauge_selected,1,1);
1334 gamesnd_play_iface(SND_RESET_PRESSED);
1335 hud_config_select_all_toggle(0);
1336 hud_set_default_hud_config(Player);
1337 hud_config_synch_ui();
1340 hud_config_commit();
1345 if( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) >= 255){
1346 gamesnd_play_iface(SND_GENERAL_FAIL);
1348 gamesnd_play_iface(SND_USER_SELECT);
1349 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) + 1) );
1350 hud_config_red_slider();
1355 if( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) >= 255){
1356 gamesnd_play_iface(SND_GENERAL_FAIL);
1358 gamesnd_play_iface(SND_USER_SELECT);
1359 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) + 1) );
1360 hud_config_green_slider();
1365 if( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) >= 255){
1366 gamesnd_play_iface(SND_GENERAL_FAIL);
1368 gamesnd_play_iface(SND_USER_SELECT);
1369 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) + 1) );
1370 hud_config_blue_slider();
1375 if( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) >= 255){
1376 gamesnd_play_iface(SND_GENERAL_FAIL);
1378 gamesnd_play_iface(SND_USER_SELECT);
1379 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) + 1) );
1380 hud_config_alpha_slider_up();
1385 if( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) <= 0){
1386 gamesnd_play_iface(SND_GENERAL_FAIL);
1388 gamesnd_play_iface(SND_USER_SELECT);
1389 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) - 1) );
1390 hud_config_red_slider();
1394 case HCB_GREEN_DOWN:
1395 if( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) <= 0){
1396 gamesnd_play_iface(SND_GENERAL_FAIL);
1398 gamesnd_play_iface(SND_USER_SELECT);
1399 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) - 1) );
1400 hud_config_green_slider();
1405 if( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) <= 0){
1406 gamesnd_play_iface(SND_GENERAL_FAIL);
1408 gamesnd_play_iface(SND_USER_SELECT);
1409 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) - 1) );
1410 hud_config_blue_slider();
1415 if( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) <= 0){
1416 gamesnd_play_iface(SND_GENERAL_FAIL);
1418 gamesnd_play_iface(SND_USER_SELECT);
1419 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) - 1) );
1420 hud_config_alpha_slider_down();
1428 // get the text in the input control
1430 HC_fname_input.get_text(name);
1431 if(strlen(name) > 0){
1432 // if the filename in there already exists
1433 for(idx=0; idx<HC_num_files; idx++){
1434 if(!stricmp(HC_filenames[idx], name)){
1443 out = cf_add_ext(name, ".hcf");
1444 hud_config_color_save(out);
1448 // otherwise we have to create a new file
1449 if(HC_num_files >= MAX_HCF_FILES){
1450 popup(PF_USE_AFFIRMATIVE_ICON, 1, "OK", "Max number of hud config files reached!");
1454 // save the file, maybe generating a new filename
1455 if(strlen(name) <= 0){
1456 sprintf(name, "hud_%d.hcf", HC_num_files + 1);
1459 out = cf_add_ext(name, ".hcf");
1461 HC_filenames[HC_num_files++] = strdup(out);
1462 hud_config_color_save(out);
1464 HC_fname_input.set_text(out);
1468 if(HC_num_files <= 0){
1472 if(HC_current_file <= 0){
1473 HC_current_file = HC_num_files - 1;
1478 hud_config_color_load(HC_filenames[HC_current_file]);
1479 hud_config_synch_ui();
1481 HC_fname_input.set_text(HC_filenames[HC_current_file]);
1485 if(HC_num_files <= 0){
1489 if(HC_current_file >= HC_num_files - 1){
1490 HC_current_file = 0;
1496 hud_config_color_load(HC_filenames[HC_current_file]);
1497 hud_config_synch_ui();
1499 HC_fname_input.set_text(HC_filenames[HC_current_file]);
1502 case HCB_SELECT_ALL:
1503 hud_config_select_all_toggle(!HC_select_all);
1512 // Check if any buttons have been pressed
1513 void hud_config_check_buttons()
1518 for ( i=0; i<NUM_HUD_BUTTONS; i++ ) {
1519 b = &HC_buttons[gr_screen.res][i].button;
1520 if ( b->pressed() ) {
1521 hud_config_button_do(i);
1526 // set the hud color button
1527 void hud_config_draw_color_status()
1529 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() ) {
1533 switch(HUD_config.main_color) {
1534 case HUD_COLOR_AMBER:
1535 HC_buttons[gr_screen.res][HCB_AMBER].button.draw_forced(2);
1537 case HUD_COLOR_GREEN:
1538 HC_buttons[gr_screen.res][HCB_GREEN].button.draw_forced(2);
1540 case HUD_COLOR_BLUE:
1541 HC_buttons[gr_screen.res][HCB_BLUE].button.draw_forced(2);
1546 // set the status (on/off/popup) for the selected gauge
1547 void hud_config_draw_gauge_status()
1549 if ( HC_gauge_selected < 0 ) {
1553 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() ) {
1558 if ( !(hud_config_show_flag_is_set(HC_gauge_selected)) ) {
1559 HC_buttons[gr_screen.res][HCB_OFF].button.draw_forced(2);
1564 if ( hud_config_popup_flag_is_set(HC_gauge_selected) ) {
1565 HC_buttons[gr_screen.res][HCB_POPUP].button.draw_forced(2);
1570 if ( hud_config_show_flag_is_set(HC_gauge_selected) ) {
1571 HC_buttons[gr_screen.res][HCB_ON].button.draw_forced(2);
1575 Int3(); // should never get here
1578 // disable a HUD config button
1579 void hud_config_button_disable(int index)
1581 // HC_buttons[gr_screen.res][index].button.hide();
1582 HC_buttons[gr_screen.res][index].button.disable();
1585 // enable a HUD config button
1586 void hud_config_button_enable(int index)
1588 // HC_buttons[gr_screen.res][index].button.unhide();
1589 HC_buttons[gr_screen.res][index].button.enable();
1592 // determine if on/off/popup buttons should be shown
1593 void hud_config_set_button_state()
1595 if ( HC_gauge_selected < 0 ) {
1596 hud_config_button_disable(HCB_ON);
1597 hud_config_button_disable(HCB_OFF);
1598 hud_config_button_disable(HCB_POPUP);
1602 // on/off are always on
1603 hud_config_button_enable(HCB_ON);
1604 hud_config_button_enable(HCB_OFF);
1606 // popup is maybe available
1607 if ( HC_gauge_regions[gr_screen.res][HC_gauge_selected].can_popup ) {
1608 hud_config_button_enable(HCB_POPUP);
1610 hud_config_button_disable(HCB_POPUP);
1614 void hud_config_render_description()
1618 if ( HC_gauge_selected >= 0 ) {
1619 gr_set_color_fast(&Color_normal);
1621 gr_get_string_size(&w, &h, HC_gauge_descriptions(HC_gauge_selected));
1622 sx = fl2i(HC_gauge_description_coords[gr_screen.res][0] + (HC_gauge_description_coords[gr_screen.res][2] - w)/2.0f);
1623 sy = HC_gauge_description_coords[gr_screen.res][1];
1624 gr_string(sx, sy, HC_gauge_descriptions(HC_gauge_selected));
1628 void hud_config_render_special_bitmaps()
1632 for (i=1; i<NUM_HC_SPECIAL_BITMAPS; i++) {
1633 if (HC_special_bitmaps[i].bitmap >= 0) {
1634 gr_set_bitmap(HC_special_bitmaps[i].bitmap);
1635 gr_bitmap(HC_special_bitmaps[i].x, HC_special_bitmaps[i].y);
1641 // update HUD_color_alpha based on brightness slider
1642 void hud_config_update_brightness()
1644 // HUD_color_alpha = HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos+3;
1645 // Assert(HUD_color_alpha >= HUD_COLOR_ALPHA_USER_MIN);
1646 // Assert(HUD_color_alpha <= HUD_COLOR_ALPHA_USER_MAX);
1649 // redraw any pressed buttons, needed since the glow on pressed buttons might get clipped off by
1650 // adjacent buttons otherwise
1651 void hud_config_redraw_pressed_buttons()
1656 for ( i = 0; i < NUM_HUD_BUTTONS; i++ ) {
1657 b = &HC_buttons[gr_screen.res][i].button;
1658 if ( b->button_down() ) {
1664 // hud_config_do_frame() is called from the main freespace loop while the game is in the state
1665 // GS_STATE_HUD_CONFIG.
1667 void hud_config_do_frame(float frametime)
1671 if (!HUD_config_inited) {
1677 hud_config_set_button_state();
1679 k = HC_ui_window.process();
1681 hud_config_handle_keypresses(k);
1682 hud_config_check_regions();
1683 hud_config_check_buttons();
1684 hud_config_update_brightness();
1686 // set the background
1687 GR_MAYBE_CLEAR_RES(HC_background_bitmap);
1688 if ( HC_background_bitmap > 0 ) {
1689 gr_set_bitmap(HC_background_bitmap);
1693 // rgb slider/button stuff
1694 hud_config_process_colors();
1696 HC_ui_window.draw();
1697 hud_config_redraw_pressed_buttons();
1699 hud_config_draw_gauge_status();
1700 hud_config_draw_color_status();
1703 if (HC_special_bitmaps[HC_SPECIAL_RETICLE].bitmap >= 0) {
1704 hud_set_default_color();
1705 gr_set_bitmap(HC_special_bitmaps[HC_SPECIAL_RETICLE].bitmap);
1706 gr_aabitmap(HC_special_bitmaps[HC_SPECIAL_RETICLE].x, HC_special_bitmaps[HC_SPECIAL_RETICLE].y);
1710 // maybe force draw the select all button
1712 HC_buttons[gr_screen.res][HCB_SELECT_ALL].button.draw_forced(2);
1715 hud_config_render_gauges();
1716 hud_config_render_special_bitmaps();
1717 hud_config_render_description();
1722 void hud_config_unload_gauges()
1725 HC_gauge_region *hg;
1727 for (i=0; i<NUM_HUD_GAUGES; i++) {
1728 hg = &HC_gauge_regions[gr_screen.res][i];
1730 if ( hg->bitmap >= 0 ) {
1731 for ( j=0; j<hg->nframes; j++ ) {
1732 bm_unload(hg->bitmap+j);
1741 // hud_config_close() is called when the player leaves the hud configuration screen
1743 void hud_config_close()
1745 // common_free_interface_palette(); // restore game palette
1746 hud_config_unload_gauges();
1747 hud_init_popup_timers(); // ensure no popup gauges are active
1749 hud_config_color_close();
1751 HC_ui_window.destroy();
1754 // hud_set_default_hud_config() will set the hud configuration to default values
1755 void hud_set_default_hud_config(player *p)
1759 HUD_color_alpha = HUD_COLOR_ALPHA_DEFAULT;
1760 HUD_config.main_color = HUD_COLOR_GREEN;
1761 HUD_color_red = HC_colors[HUD_config.main_color].r;
1762 HUD_color_green = HC_colors[HUD_config.main_color].g;
1763 HUD_color_blue = HC_colors[HUD_config.main_color].b;
1765 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1766 gr_init_alphacolor(&HUD_config.clr[idx], HUD_color_red, HUD_color_green, HUD_color_blue, (HUD_color_alpha+1)*16);
1769 HUD_config.show_flags = HUD_config_default_flags;
1770 HUD_config.show_flags2 = HUD_config_default_flags2;
1771 HUD_config.popup_flags = HUD_default_popup_mask;
1772 HUD_config.popup_flags2 = HUD_default_popup_mask2;
1773 HUD_config.num_msg_window_lines = 4; // one more than is actually visible
1774 HUD_config.rp_flags = RP_DEFAULT;
1775 HUD_config.rp_dist = RR_INFINITY;
1776 HUD_config.is_observer = 0;
1779 // hud_config_restore() will restore the hud configuration the player started with when the
1780 // hud configuration screen was started
1782 void hud_config_restore()
1784 HUD_config = HUD_config_backup;
1787 // hud_config_backup() will save the players hud configuration when they enter the hud configuration
1788 // screen. This is done in case the player decides to cancel the changes that were made.
1790 void hud_config_backup()
1792 HUD_config_backup = HUD_config;
1795 void hud_config_as_observer(ship *shipp,ai_info *aif)
1797 // store the current hus
1798 hud_config_backup();
1800 // bash these values so the HUD is not offset incorrectly
1801 HUD_offset_x = 0.0f;
1802 HUD_offset_y = 0.0f;
1804 // initialize the observer HUD
1805 hud_observer_init(shipp,aif);
1808 void hud_config_as_player()
1812 // ---------------------------------------------------------------------------------------------------------------
1816 void hud_config_color_save(char *name)
1819 CFILE *out = cfopen(name, "wt", CFILE_NORMAL, CF_TYPE_PLAYERS);
1820 char vals[255] = "";
1828 // write out all gauges
1829 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1830 cfputs("+Gauge: ", out);
1831 cfputs(HC_gauge_descriptions(idx), out);
1833 cfputs("+RGBA: ", out);
1834 sprintf(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);
1842 void hud_config_color_load(char *name)
1845 char str[1024] = "";
1848 fname = cf_add_ext(name, ".hcf");
1850 if ((rval = setjmp(parse_abort)) != 0) {
1851 mprintf(("Error opening hud config file!\n"));
1854 read_file_text(fname);
1858 // write out all gauges
1859 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1860 required_string("+Gauge:");
1861 stuff_string(str, F_NAME, NULL, 1023);
1863 required_string("+RGBA:");
1864 stuff_byte(&HUD_config.clr[idx].red);
1865 stuff_byte(&HUD_config.clr[idx].green);
1866 stuff_byte(&HUD_config.clr[idx].blue);
1867 stuff_byte(&HUD_config.clr[idx].alpha);
1871 void hud_config_alpha_slider_up()
1873 int pos = HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem());
1874 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()) );
1876 // if this would put the brightest element past its limit, skip
1878 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(pos - 1) );
1882 // otherwise bump everybody up by one
1883 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) + 1) );
1884 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) + 1) );
1885 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) + 1) );
1889 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()) );
1891 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);
1895 void hud_config_alpha_slider_down()
1897 int pos = HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem());
1898 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()) );
1900 // if this would put the brightest element past its limit, skip
1902 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(pos + 1) );
1906 // otherwise bump everybody up by one
1907 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) - 1) );
1908 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) - 1) );
1909 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) - 1) );
1913 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()) );
1915 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);
1919 void hud_config_recalc_alpha_slider()
1921 int avg =HC_color_sliders[HCS_RED].get_currentItem() + HC_color_sliders[HCS_GREEN].get_currentItem() + HC_color_sliders[HCS_BLUE].get_currentItem();
1923 HC_color_sliders[HCS_ALPHA].force_currentItem( avg );
1926 void hud_config_red_slider()
1929 int pos = HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) ;
1933 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1934 gr_init_alphacolor(&HUD_config.clr[idx], pos, HUD_config.clr[idx].green, HUD_config.clr[idx].blue, HUD_config.clr[idx].alpha);
1939 if(HC_gauge_selected < 0){
1943 // get slider position
1944 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);
1947 hud_config_recalc_alpha_slider();
1950 void hud_config_green_slider()
1953 int pos = HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) ;
1957 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1958 gr_init_alphacolor(&HUD_config.clr[idx], HUD_config.clr[idx].red, pos, HUD_config.clr[idx].blue, HUD_config.clr[idx].alpha);
1963 if(HC_gauge_selected < 0){
1967 // get slider position
1968 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);
1971 hud_config_recalc_alpha_slider();
1974 void hud_config_blue_slider()
1977 int pos = HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem());
1981 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1982 gr_init_alphacolor(&HUD_config.clr[idx], HUD_config.clr[idx].red, HUD_config.clr[idx].green, pos, HUD_config.clr[idx].alpha);
1987 if(HC_gauge_selected < 0){
1991 // get slider position
1992 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);
1995 hud_config_recalc_alpha_slider();
1998 void hud_config_process_colors()
2002 void hud_config_color_init()
2004 HC_current_file = -1;
2006 // get a list of all hcf files
2007 memset(HC_filenames, 0, sizeof(char*) * MAX_HCF_FILES);
2008 HC_num_files = cf_get_file_list(MAX_HCF_FILES, HC_filenames, CF_TYPE_PLAYERS, "*.hcf", CF_SORT_NAME);
2011 void hud_config_color_close()
2016 for(idx=0; idx<HC_num_files; idx++){
2017 if(HC_filenames[idx] != NULL){
2018 free(HC_filenames[idx]);
2019 HC_filenames[idx] = NULL;
2024 void hud_config_select_all_toggle(int toggle)
2028 // if we're turning off
2030 // determine if on/off/popup buttons should be shown
2031 hud_config_set_button_state();
2036 hud_config_synch_ui();
2038 // if we had a gauge previously selected, use its color everywhere
2039 if(HC_gauge_selected < 0){
2040 r = HUD_config.clr[HUD_RADAR].red;
2041 g = HUD_config.clr[HUD_RADAR].green;
2042 b = HUD_config.clr[HUD_RADAR].blue;
2043 a = HUD_config.clr[HUD_RADAR].alpha;
2045 r = HUD_config.clr[HC_gauge_selected].red;
2046 g = HUD_config.clr[HC_gauge_selected].green;
2047 b = HUD_config.clr[HC_gauge_selected].blue;
2048 a = HUD_config.clr[HC_gauge_selected].alpha;
2050 hud_config_stuff_colors(r, g, b);
2052 // no gauge selected
2053 HC_gauge_selected = -1;
2055 // enable all sliders
2056 HC_color_sliders[HCS_RED].enable();
2057 HC_color_sliders[HCS_GREEN].enable();
2058 HC_color_sliders[HCS_BLUE].enable();
2059 HC_color_sliders[HCS_ALPHA].enable();
2060 HC_color_sliders[HCS_RED].unhide();
2061 HC_color_sliders[HCS_GREEN].unhide();
2062 HC_color_sliders[HCS_BLUE].unhide();
2063 HC_color_sliders[HCS_ALPHA].unhide();
2064 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(r) );
2065 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(g) );
2066 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(b) );
2067 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(a) );
2070 hud_config_recalc_alpha_slider();
2072 // disable all three buttons
2073 hud_config_button_disable(HCB_ON);
2074 hud_config_button_disable(HCB_OFF);
2075 hud_config_button_disable(HCB_POPUP);