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.5 2003/05/25 02:30:42 taylor
21 * Revision 1.4 2002/06/09 04:41:21 relnev
22 * added copyright header
24 * Revision 1.3 2002/06/01 07:12:33 relnev
25 * a few NDEBUG updates.
27 * removed a few warnings.
29 * Revision 1.2 2002/05/07 03:16:45 theoddone33
30 * The Great Newline Fix
32 * Revision 1.1.1.1 2002/05/03 03:28:09 root
36 * 19 10/25/99 5:43p Jefff
37 * reassigned some xstr ids
39 * 18 10/14/99 2:50p Jefff
42 * 17 9/02/99 5:09p Jefff
43 * disabled options now draw as a dark gray color
45 * 16 9/01/99 11:16a Dave
46 * Reverse direction of HUD config RGB sliders.
48 * 15 8/19/99 3:17p Dave
49 * Fixed talking head disappearing.
51 * 14 8/19/99 2:33p Dave
52 * Make sure support gauge and net lag gauge are configurable.
54 * 13 8/16/99 5:25p Dave
55 * New hud config. Whee!
57 * 12 8/16/99 4:04p Dave
58 * Big honking checkin.
60 * 11 7/30/99 10:31p Dave
61 * Added comm menu to the configurable hud files.
63 * 10 7/30/99 11:05a Jasenw
64 * Fixed hud config for new text warning gauge,
66 * 9 7/24/99 1:54p Dave
67 * Hud text flash gauge. Reworked dead popup to use 4 buttons in red-alert
70 * 8 7/15/99 9:20a Andsager
71 * FS2_DEMO initial checkin
73 * 7 6/08/99 2:33p Dave
74 * Fixed release build warning. Put in hud config stuff.
76 * 6 6/08/99 1:14a Dave
77 * Multi colored hud test.
79 * 5 1/30/99 5:08p Dave
80 * More new hi-res stuff.Support for nice D3D textures.
82 * 4 10/13/98 9:28a Dave
83 * Started neatening up freespace.h. Many variables renamed and
84 * reorganized. Added AlphaColors.[h,cpp]
86 * 3 10/07/98 11:28a Dave
87 * Removed wacky pragma.
89 * 2 10/07/98 10:53a Dave
92 * 1 10/07/98 10:49a Dave
94 * 72 8/25/98 1:48p Dave
95 * First rev of EMP effect. Player side stuff basically done. Next comes
98 * 71 6/09/98 10:31a Hoffoss
99 * Created index numbers for all xstr() references. Any new xstr() stuff
100 * added from here on out should be added to the end if the list. The
101 * current list count can be found in FreeSpace.cpp (search for
104 * 70 6/01/98 11:43a John
105 * JAS & MK: Classified all strings for localization.
107 * 69 5/24/98 9:01p Lawrance
108 * Add commit sounds when accept is pressed
110 * 68 5/23/98 3:31p Dave
111 * Tweaked pxo code. Fixed observer HUD stuff.
113 * 67 5/08/98 10:12a Lawrance
114 * play sound for auto-target toggle, don't display HUD message
116 * 66 4/29/98 6:00p Dave
117 * Fixed chatbox font colors. Made observer offscreen indicators work.
118 * Numerous small UI fixes. Fix rank limitations for mp games.
120 * 65 4/20/98 12:04a Lawrance
121 * tweak how button light up
123 * 64 4/16/98 4:07p Hoffoss
124 * Fixed bug with palette reseting when loading a new pilot. Also made
125 * barracks default to palette merging mode.
127 * 63 4/16/98 10:48a Lawrance
128 * reposition a couple of gauges
130 * 62 4/14/98 6:16p Lawrance
131 * Fix bug that was preventing non-green HUD color from getting set.
133 * 61 4/12/98 5:32p Lawrance
134 * don't show talking head in demo version of hud config
136 * 60 4/10/98 12:07a Lawrance
137 * Fix up talking head gauge.
139 * 59 4/08/98 10:15a Lawrance
140 * allow kills gauge to be popup
142 * 58 4/08/98 1:18a Lawrance
143 * Add in kills gauge art to HUD config.
145 * 57 4/05/98 7:42p Lawrance
148 * 56 4/03/98 3:13p Dave
149 * More work on udp reliable transport. Fixed observer hud offset problem.
150 * Made observer join and ingame join work again. Put subnet broadcasting
153 * 55 4/01/98 6:46p Lawrance
154 * default damage popup to on
156 * 54 3/31/98 11:47p Lawrance
157 * Add popup functionality for the countermeasure gauge.
159 * 53 3/30/98 4:48p Lawrance
160 * Turn on offscreen indicator range by default
162 * 52 3/26/98 5:45p Lawrance
163 * Added new gauges to HUD config
165 * 51 3/15/98 4:17p Dave
166 * Fixed oberver hud problems. Put in handy netplayer macros. Reduced size
167 * of network orientation matrices.
169 * 50 3/12/98 5:45p Dave
170 * Put in new observer HUD. Made it possible for observers to join at the
171 * beginning of a game and follow it around as an observer full-time.
173 * 49 3/11/98 12:13a Lawrance
174 * redraw pressed buttons
176 * 48 3/05/98 12:39a Lawrance
177 * show comma in 10000
179 * 47 2/22/98 4:30p John
180 * More string externalization classification
182 * 46 2/22/98 4:17p John
183 * More string externalization classification... 190 left to go!
185 * 45 2/22/98 12:19p John
186 * Externalized some strings
188 * 44 1/23/98 6:24p Lawrance
189 * Implement wingman status gauge
191 * 43 1/22/98 10:45p Lawrance
192 * Add coutermeasures and objective display to hud config.
194 * 42 1/19/98 11:37p Lawrance
195 * Fixing Optimization build warnings
197 * 41 1/17/98 10:02p Lawrance
198 * Fix bug with damage popup that would sometimes display with <none>.
200 * 40 1/17/98 1:30a Lawrance
201 * Add countermeasure gauge
203 * 39 1/15/98 5:10p Allender
204 * ton of interface changes. chatbox in multiplayer now behaves
205 * differently than before. It's always active in any screen that uses
206 * it. Only non-printatble characters will get passed back out from
209 * 38 1/14/98 11:07p Lawrance
210 * Hook in brightness slider to HUD config.
212 * 37 1/14/98 6:42p Hoffoss
213 * Massive changes to UI code. A lot cleaner and better now. Did all
214 * this to get the new UI_DOT_SLIDER to work properly, which the old code
215 * wasn't flexible enough to handle.
217 * 36 1/14/98 12:25p Lawrance
218 * center gauge text, use correct game palette.
220 * 35 1/13/98 5:33p Lawrance
221 * Tweaking HUD config.
223 * 34 1/13/98 2:20p John
224 * Added code to load palette based on hud color. Added code to turn off
225 * nebulas using detail. Added code in WinMain to time out after waiting
226 * too long for window creation.
228 * 33 1/13/98 10:22a Lawrance
229 * Integrate new art changes.
231 * 32 1/12/98 11:16p Lawrance
232 * Wonderful HUD config.
234 * 31 1/10/98 12:41a Lawrance
235 * start work on new HUD config
237 * 30 1/05/98 9:38p Lawrance
238 * Implement flashing HUD gauges.
240 * 29 1/02/98 9:10p Lawrance
241 * Big changes to how colors get set on the HUD.
243 * 28 12/16/97 9:13p Lawrance
244 * Integrate new gauges into HUD config.
246 * 27 12/01/97 12:27a Lawrance
247 * redo default alpha color for HUD, make it easy to modify in the future
255 #include "hudconfig.h"
256 #include "freespace.h"
257 #include "gamesequence.h"
268 #include "hudobserver.h"
270 #include "missionshipchoice.h"
272 #include "alphacolors.h"
276 //////////////////////////////////////////////////////////////////////////////
278 //////////////////////////////////////////////////////////////////////////////
280 #define MAX_HCF_FILES 30
281 int HC_num_files = -1; // num known hcf files
282 int HC_current_file = -1; // current hcf file
283 char *HC_filenames[MAX_HCF_FILES];
285 char HC_fname[MAX_FILENAME_LEN+1] = "";
286 UI_INPUTBOX HC_fname_input;
287 int HC_fname_coords[GR_NUM_RESOLUTIONS][4] = {
296 HUD_CONFIG_TYPE HUD_config; // Player HUD configuration
298 // specify the max distance that the radar should detect objects
299 // See RR_ #defines in HUDconfig.h.
300 float Radar_ranges[RR_MAX_RANGES] = {
303 10000000.0f, // infinity
306 char *Radar_range_text(int n)
308 #if RR_MAX_RANGES != 3
309 #error Number of ranges is wrong!
314 return XSTR( "2000 M", 246);
316 return XSTR( "10,000 M", 247);
318 return XSTR( "infinity", 248);
323 // default flags for observer HUD
324 int HUD_observer_default_flags =
326 (1<<HUD_CENTER_RETICLE) |
327 (1<<HUD_OFFSCREEN_INDICATOR) |
328 (1<<HUD_MESSAGE_LINES) |
329 (1<<HUD_HOSTILE_TRIANGLE) |
330 (1<<HUD_TARGET_TRIANGLE) |
331 (1<<HUD_TARGET_MINI_ICON) |
332 (1<<HUD_TARGET_MONITOR)
335 int HUD_observer_default_flags2 = {
336 (1<<(HUD_OFFSCREEN_RANGE - 32))
339 // default flags for regular HUD
340 int HUD_config_default_flags =
342 (1<<HUD_LEAD_INDICATOR) |
343 (1<<HUD_ORIENTATION_TEE) |
344 (1<<HUD_HOSTILE_TRIANGLE) |
345 (1<<HUD_TARGET_TRIANGLE) |
346 (1<<HUD_MISSION_TIME) |
347 (1<<HUD_RETICLE_CIRCLE) |
348 (1<<HUD_THROTTLE_GAUGE) |
350 (1<<HUD_TARGET_MONITOR) |
351 (1<<HUD_CENTER_RETICLE) |
352 (1<<HUD_TARGET_MONITOR_EXTRA_DATA) |
353 (1<<HUD_TARGET_SHIELD_ICON) |
354 (1<<HUD_PLAYER_SHIELD_ICON) |
356 (1<<HUD_AUTO_TARGET) |
357 (1<<HUD_AUTO_SPEED) |
358 (1<<HUD_WEAPONS_GAUGE) |
359 (1<<HUD_ESCORT_VIEW) |
360 (1<<HUD_DIRECTIVES_VIEW) |
361 (1<<HUD_THREAT_GAUGE) |
362 (1<<HUD_AFTERBURNER_ENERGY) |
363 (1<<HUD_WEAPONS_ENERGY) |
364 (1<<HUD_WEAPON_LINKING_GAUGE) |
365 (1<<HUD_TARGET_MINI_ICON) |
366 (1<<HUD_OFFSCREEN_INDICATOR) |
367 (1<<HUD_TALKING_HEAD) |
368 (1<<HUD_DAMAGE_GAUGE) |
369 (1<<HUD_MESSAGE_LINES) |
370 (1<<HUD_MISSILE_WARNING_ARROW) |
371 (1<<HUD_CMEASURE_GAUGE) |
372 (1<<HUD_OBJECTIVES_NOTIFY_GAUGE) |
373 (1<<HUD_WINGMEN_STATUS)
376 int HUD_config_default_flags2 =
378 (1<<(HUD_OFFSCREEN_RANGE-32)) |
379 (1<<(HUD_KILLS_GAUGE-32)) |
380 (1<<(HUD_ATTACKING_TARGET_COUNT-32)) |
381 (1<<(HUD_SUPPORT_GAUGE-32)) |
382 (1<<(HUD_LAG_GAUGE-32))
385 // bits to tell whether a given gauge should be treated as pop-up or not
386 int HUD_default_popup_mask =
388 0 | // (1<<HUD_LEAD_INDICATOR) |
389 0 | // (1<<HUD_ORIENTATION_TEE) |
390 0 | // (1<<HUD_HOSTILE_TRIANGLE) |
391 0 | // (1<<HUD_TARGET_TRIANGLE) |
392 0 | // (1<<HUD_MISSION_TIME) |
393 0 | // (1<<HUD_RETICLE_CIRCLE) |
394 0 | // (1<<HUD_THROTTLE_GAUGE) |
395 0 | // (1<<HUD_RADAR) |
396 0 | // (1<<HUD_TARGET_MONITOR) |
397 0 | // (1<<HUD_CENTER_RETICLE) |
398 0 | // (1<<HUD_TARGET_MONITOR_EXTRA_DATA) |
399 0 | // (1<<HUD_TARGET_SHIELD_ICON) |
400 0 | // (1<<HUD_PLAYER_SHIELD_ICON) |
401 0 | // (1<<HUD_ETS_GAUGE) |
402 0 | // (1<<HUD_AUTO_TARGET) |
403 0 | // (1<<HUD_AUTO_SPEED) |
404 0 | // (1<<HUD_WEAPONS_GAUGE) |
405 0 | // (1<<HUD_ESCORT_VIEW) |
406 0 | // (1<<HUD_DIRECTIVES_VIEW) |
407 0 | // (1<<HUD_THREAT_GAUGE) |
408 0 | // (1<<HUD_AFTERBURNER_ENERGY) |
409 0 | // (1<<HUD_WEAPONS_ENERGY) |
410 0 | // (1<<HUD_WEAPON_LINKING_GAUGE) |
411 0 | // (1<<HUD_TARGET_MINI_ICON) |
412 0 | //(1<<HUD_OFFSCREEN_INDICATOR)
416 0 | // missile warning arrow
417 0 | // countermeasures
421 int HUD_default_popup_mask2 =
423 0 | // offscreen indicator range
428 void hud_config_color_save(char *name);
429 void hud_config_select_all_toggle(int toggle);
431 int HC_select_all = 0;
433 //////////////////////////////////////////////////////////////////////////////
435 //////////////////////////////////////////////////////////////////////////////
438 #pragma warning(disable:4710)
441 char *Hud_config_fname[GR_NUM_RESOLUTIONS] = {
446 char *Hud_config_mask_fname[GR_NUM_RESOLUTIONS] = {
451 struct HC_gauge_region
463 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){}
467 struct HC_gauge_region HC_gauge_regions[GR_NUM_RESOLUTIONS][NUM_HUD_GAUGES] =
472 HC_gauge_region("HG_07", 377, 106, 7, 1, 0, -1, 4, 2), // lead indicator
473 HC_gauge_region("HG_08", 288, 153, 8, 1, 0, -1, 4, 2), // orientation tee
474 HC_gauge_region("HG_09", 312, 141, 9, 1, 0, -1, 4, 1), // hostile triangle
475 HC_gauge_region("HG_11", 362, 141, 11, 1, 0, -1, 4, 2), // target triangle
476 HC_gauge_region("HG_41", 530, 364, 41, 0, 0, -1, 0, 0), // mission time
477 HC_gauge_region("none", -1, -1, 0, 0, 0, -1, 0, 0), // reticle circle?
478 HC_gauge_region("HG_14", 272, 218, 14, 0, 0, -1, 0, 0), // throttle gauge
479 HC_gauge_region("HG_20", 301, 307, 20, 0, 0, -1, 0, 0), // radar
480 HC_gauge_region("HG_04", 126, 271, 4, 0, 0, -1, 0, 0), // target monitor
481 HC_gauge_region("HG_12", 335, 212, 12, 0, 0, -1, 0, 0), // center of reticle
482 HC_gauge_region("HG_03", 126, 246, 3, 0, 0, -1, 0, 0), // extra target data
483 HC_gauge_region("HG_19", 224, 322, 19, 0, 0, -1, 0, 0), // target shield icon
484 HC_gauge_region("HG_21", 403, 322, 21, 0, 0, -1, 0, 0), // player shield icon
485 HC_gauge_region("HG_24", 485, 315, 24, 0, 1, -1, 0, 0), // ets gauge
486 HC_gauge_region("HG_25", 523, 315, 25, 0, 1, -1, 0, 0), // auto target
487 HC_gauge_region("HG_26", 523, 332, 26, 0, 1, -1, 0, 0), // auto speed
488 HC_gauge_region("HG_23", 467, 241, 23, 0, 1, -1, 0, 0), // weapons gauge
489 HC_gauge_region("HG_22", 460, 196, 22, 0, 1, -1, 0, 0), // escort view
490 HC_gauge_region("HG_02", 126, 175, 2, 0, 0, -1, 0, 0), // directives view
491 HC_gauge_region("HG_10", 331, 149, 10, 0, 0, -1, 0, 0), // threat gauge
492 HC_gauge_region("HG_13", 241, 235, 13, 0, 0, -1, 0, 0), // afterburner energy
493 HC_gauge_region("HG_17", 412, 235, 17, 0, 0, -1, 0, 0), // weapons energy
494 HC_gauge_region("HG_16", 396, 226, 16, 0, 0, -1, 0, 0), // weapon linking
495 HC_gauge_region("HG_15", 333, 253, 15, 0, 1, -1, 0, 0), // target mini icon (shield)
496 HC_gauge_region("HG_05", 405, 52, 5, 1, 0, -1, 4, 2), // offscreen indicator
497 HC_gauge_region("HG_01", 126, 76, 1, 0, 0, -1, 0, 0), // talking head
498 HC_gauge_region("HG_06", 292, 78, 6, 0, 1, -1, 0, 0), // damage gauge
499 HC_gauge_region("HG_00", 126, 63, 0, 0, 0, -1, 0, 0), // message lines
500 HC_gauge_region("HG_18", 313, 283, 18, 1, 0, -1, 4, 3), // locked missile direction
501 HC_gauge_region("HG_40", 467, 291, 40, 0, 1, -1, 0, 0), // cmeasure gauge
502 HC_gauge_region("none", -1, -1, -1, 0, 0, -1, 0, 0), // objectives notify gauge
503 HC_gauge_region("HG_39", 504, 153, 39, 0, 0, -1, 0, 0), // wingman status gauge
504 HC_gauge_region("HG_38", 405, 59, 38, 1, 0, -1, 4, 2), // offscreen indicator range
505 HC_gauge_region("HG_42", 467, 303, 42, 0, 1, -1, 0, 0), // kills gauge
506 HC_gauge_region("HG_45", 317, 106, 45, 1, 0, -1, 4, 1), // attacking target count
507 HC_gauge_region("none", -1, -1, -1, 0, 0, -1, 0, 0), // text flash gauge
508 HC_gauge_region("none", -1, -1, -1, 0, 0, -1, 0, 0), // comm menu
509 HC_gauge_region("none", -1, -1, -1, 0, 0, -1, 0, 0), // support view gauge
510 HC_gauge_region("none", -1, -1, -1, 0, 0, -1, 0, 0), // netlag icon gauge
512 HC_gauge_region("HCB_35", 407, 69, 35, 1, 0, -1, 0, 2), // lead indicator
513 HC_gauge_region("HCB_36", 305, 119, 36, 1, 0, -1, 0, 2), // orientation tee
514 HC_gauge_region("none", 1, 1, -1, 1, 0, -1, 0, 0), // hostile triangle
515 HC_gauge_region("HCB_37", 391, 107, 37, 1, 0, -1, 0, 2), // target triangle
516 HC_gauge_region("HCB_63", 575, 352, 63, 0, 0, -1, 0, 0), // mission time
517 HC_gauge_region("none", 1, 1, 1, 0, 0, -1, 0, 0), // reticle circle?
518 HC_gauge_region("HCB_40", 285, 146, 40, 0, 0, -1, 0, 0), // throttle gauge
519 HC_gauge_region("HCB_50", 317, 291, 50, 0, 0, -1, 0, 0), // radar
520 HC_gauge_region("HCB_31", 123, 249, 31, 0, 0, -1, 0, 0), // target monitor
521 HC_gauge_region("HCB_41", 361, 188, 41, 0, 0, -1, 0, 0), // center of reticle
522 HC_gauge_region("HCB_30", 123, 221, 30, 0, 0, -1, 0, 0), // extra target data
523 HC_gauge_region("HCB_49", 237, 303, 49, 0, 0, -1, 0, 0), // target shield icon
524 HC_gauge_region("HCB_51", 435, 304, 51, 0, 0, -1, 0, 0), // player shield icon
525 HC_gauge_region("HCB_58", 524, 299, 58, 0, 1, -1, 0, 0), // ets gauge
526 HC_gauge_region("HCB_61", 566, 299, 61, 0, 1, -1, 0, 0), // auto target
527 HC_gauge_region("HCB_62", 566, 317, 62, 0, 1, -1, 0, 0), // auto speed
528 HC_gauge_region("HCB_55", 504, 216, 55, 0, 1, -1, 0, 0), // weapons gauge
529 HC_gauge_region("HCB_54", 496, 166, 54, 0, 1, -1, 0, 0), // escort view
530 HC_gauge_region("HCB_29", 123, 142, 29, 0, 0, -1, 0, 0), // directives view
531 HC_gauge_region("HCB_43", 398, 147, 43, 0, 0, -1, 0, 0), // threat gauge
532 HC_gauge_region("HCB_39", 250, 212, 39, 0, 0, -1, 0, 0), // afterburner energy
533 HC_gauge_region("HCB_44", 449, 212, 44, 0, 0, -1, 0, 0), // weapons energy
534 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // weapon linking
535 HC_gauge_region("HCB_42", 356, 232, 42, 0, 1, -1, 0, 0), // target mini icon (shield)
536 HC_gauge_region("HCB_34", 438, 5, 34, 1, 0, -1, 0, 2), // offscreen indicator
537 HC_gauge_region("HCB_28", 123, 31, 28, 0, 0, -1, 0, 0), // talking head
538 HC_gauge_region("HCB_32", 309, 33, 32, 0, 1, -1, 0, 0), // damage gauge
539 HC_gauge_region("HCB_27", 124, 19, 27, 0, 0, -1, 0, 0), // message lines
540 HC_gauge_region("HCB_45", 307, 249, 45, 1, 0, -1, 0, 1), // missile warnings
541 HC_gauge_region("HCB_56", 505, 271, 56, 0, 1, -1, 0, 0), // cmeasure gauge
542 HC_gauge_region("HCB_33", 309, 87, 33, 0, 0, -1, 0, 0), // objectives notify gauge
543 HC_gauge_region("HCB_53", 546, 117, 53, 0, 0, -1, 0, 0), // wingman status gauge
544 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // offscreen indicator range
545 HC_gauge_region("HCB_57", 505, 285, 57, 0, 1, -1, 0, 0), // kills gauge
546 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // attacking target count
547 HC_gauge_region("HCB_38", 342, 138, 38, 0, 0, -1, 0, 0), // text flash gauge
548 HC_gauge_region("HCB_52", 465, 8, 52, 0, 0, -1, 0, 0), // comm menu
549 HC_gauge_region("HCB_46", 324, 264, 46, 0, 0, -1, 0, 0), // support view gauge
550 HC_gauge_region("HCB_47", 418, 262, 47, 0, 0, -1, 0, 0), // netlag icon gauge
556 HC_gauge_region("2_HCB_35", 652, 112, 35, 1, 0, -1, 0, 2), // lead indicator
557 HC_gauge_region("2_HCB_36", 489, 191, 36, 1, 0, -1, 0, 2), // orientation tee
558 HC_gauge_region("none", 1, 1, -1, 1, 0, -1, 0, 0), // hostile triangle
559 HC_gauge_region("2_HCB_37", 626, 173, 37, 1, 0, -1, 0, 2), // target triangle
560 HC_gauge_region("2_HCB_63", 920, 564, 63, 0, 0, -1, 0, 0), // mission time
561 HC_gauge_region("none", 1, 1, 1, 0, 0, -1, 0, 0), // reticle circle?
562 HC_gauge_region("2_HCB_40", 456, 235, 40, 0, 0, -1, 0, 0), // throttle gauge
563 HC_gauge_region("2_HCB_50", 508, 466, 50, 0, 0, -1, 0, 0), // radar
564 HC_gauge_region("2_HCB_31", 198, 399, 31, 0, 0, -1, 0, 0), // target monitor
565 HC_gauge_region("2_HCB_41", 578, 302, 41, 0, 0, -1, 0, 0), // center of reticle
566 HC_gauge_region("2_HCB_30", 198, 354, 30, 0, 0, -1, 0, 0), // extra target data
567 HC_gauge_region("2_HCB_49", 380, 485, 49, 0, 0, -1, 0, 0), // target shield icon
568 HC_gauge_region("2_HCB_51", 696, 486, 51, 0, 0, -1, 0, 0), // player shield icon
569 HC_gauge_region("2_HCB_58", 839, 479, 58, 0, 1, -1, 0, 0), // ets gauge
570 HC_gauge_region("2_HCB_61", 906, 479, 61, 0, 1, -1, 0, 0), // auto target
571 HC_gauge_region("2_HCB_62", 906, 508, 62, 0, 1, -1, 0, 0), // auto speed
572 HC_gauge_region("2_HCB_55", 807, 346, 55, 0, 1, -1, 0, 0), // weapons gauge
573 HC_gauge_region("2_HCB_54", 794, 265, 54, 0, 1, -1, 0, 0), // escort view
574 HC_gauge_region("2_HCB_29", 198, 228, 29, 0, 0, -1, 0, 0), // directives view
575 HC_gauge_region("2_HCB_43", 637, 237, 43, 0, 0, -1, 0, 0), // threat gauge
576 HC_gauge_region("2_HCB_39", 403, 339, 39, 0, 0, -1, 0, 0), // afterburner energy
577 HC_gauge_region("2_HCB_44", 719, 339, 44, 0, 0, -1, 0, 0), // weapons energy
578 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // weapon linking
579 HC_gauge_region("2_HCB_42", 569, 371, 42, 0, 1, -1, 0, 0), // target mini icon (shield)
580 HC_gauge_region("2_HCB_34", 701, 9, 34, 1, 0, -1, 0, 2), // offscreen indicator
581 HC_gauge_region("2_HCB_28", 198, 50, 28, 0, 0, -1, 0, 0), // talking head
582 HC_gauge_region("2_HCB_32", 495, 55, 32, 0, 1, -1, 0, 0), // damage gauge
583 HC_gauge_region("2_HCB_27", 199, 30, 27, 0, 0, -1, 0, 0), // message lines
584 HC_gauge_region("2_HCB_45", 491, 399, 45, 1, 0, -1, 0, 1), // missile warnings
585 HC_gauge_region("2_HCB_56", 808, 433, 56, 0, 1, -1, 0, 0), // cmeasure gauge
586 HC_gauge_region("2_HCB_33", 495, 141, 33, 0, 0, -1, 0, 0), // objectives notify gauge
587 HC_gauge_region("2_HCB_53", 873, 188, 53, 0, 0, -1, 0, 0), // wingman status gauge
588 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // offscreen indicator range
589 HC_gauge_region("2_HCB_57", 808, 456, 57, 0, 1, -1, 0, 0), // kills gauge
590 HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // attacking target count
591 HC_gauge_region("2_HCB_38", 548, 222, 38, 0, 0, -1, 0, 0), // text flash gauge
592 HC_gauge_region("2_HCB_52", 744, 14, 52, 0, 0, -1, 0, 0), // comm menu
593 HC_gauge_region("2_HCB_46", 520, 422, 46, 0, 0, -1, 0, 0), // support view gauge
594 HC_gauge_region("2_HCB_47", 670, 419, 47, 0, 0, -1, 0, 0), // netlag icon gauge
600 #pragma warning(default:4710)
603 int HC_gauge_description_coords[GR_NUM_RESOLUTIONS][3] = {
616 char *HC_gauge_descriptions(int n)
620 return XSTR( "lead indicator", 249);
622 return XSTR( "target orientation", 250);
624 return XSTR( "closest attacking hostile", 251);
626 return XSTR( "current target direction", 252);
628 return XSTR( "mission time", 253);
630 return XSTR( "reticle", 254);
632 return XSTR( "throttle", 255);
634 return XSTR( "radar", 256);
636 return XSTR( "target monitor", 257);
638 return XSTR( "center of reticle", 258);
640 return XSTR( "extra target info", 259);
642 return XSTR( "target shield", 260);
644 return XSTR( "player shield", 261);
646 return XSTR( "power management", 262);
648 return XSTR( "auto-target icon", 263);
650 return XSTR( "auto-speed-match icon", 264);
652 return XSTR( "weapons display", 265);
654 return XSTR( "monitoring view", 266);
656 return XSTR( "directives view", 267);
658 return XSTR( "threat gauge", 268);
660 return XSTR( "afterburner energy", 269);
662 return XSTR( "weapons energy", 270);
664 return XSTR( "weapon linking", 271);
666 return XSTR( "target hull/shield icon", 272);
668 return XSTR( "offscreen indicator", 273);
670 return XSTR( "comm video", 274);
672 return XSTR( "damage display", 275);
674 return XSTR( "message output", 276);
676 return XSTR( "locked missile direction", 277);
678 return XSTR( "countermeasures", 278);
680 return XSTR( "objective notify", 279);
682 return XSTR( "wingmen status", 280);
684 return XSTR( "offscreen range", 281);
686 return XSTR( "kills gauge", 282);
688 return XSTR( "attacking target count", 283);
690 return XSTR("warning flash", 1459);
692 return XSTR("comm menu", 1460);
694 return XSTR("support gauge", 1461);
696 return XSTR("lag gauge", 1462);
702 #define NUM_HUD_BUTTONS 8
704 #define NUM_HUD_BUTTONS 20
709 #define HCB_GREEN_UP 1
710 #define HCB_BLUE_UP 2
712 #define HCB_RED_DOWN 4
713 #define HCB_GREEN_DOWN 5
714 #define HCB_BLUE_DOWN 6
719 #define HCB_SAVE_HCF 11
720 #define HCB_PREV_HCF 12
721 #define HCB_NEXT_HCF 13
725 #define HCB_SELECT_ALL 17
727 #define HCB_ACCEPT 19
740 #pragma warning(disable : 4710)
743 ui_button_info HC_buttons[GR_NUM_RESOLUTIONS][NUM_HUD_BUTTONS] = {
746 ui_button_info("HG_27", 31, 92, -1, -1, 27), // amber
747 ui_button_info("HG_28", 31, 113, -1, -1, 28), // blue
748 ui_button_info("HG_29", 31, 133, -1, -1, 29), // green
749 ui_button_info("HG_30", 31, 385, -1, -1, 30), // on
750 ui_button_info("HG_31", 31, 405, -1, -1, 31), // off
751 ui_button_info("HG_32", 31, 424, -1, -1, 32), // popup
752 ui_button_info("HG_36", 504, 411, -1, -1, 36), // reset
753 ui_button_info("HG_37", 561, 411, -1, -1, 37), // accept
755 ui_button_info("HCB_00", 6, 27, -1, -1, 0),
756 ui_button_info("HCB_01", 30, 27, -1, -1, 1),
757 ui_button_info("HCB_02", 55, 27, -1, -1, 2),
758 ui_button_info("HCB_03", 80, 27, -1, -1, 3),
759 ui_button_info("HCB_08", 6, 291, -1, -1, 8),
760 ui_button_info("HCB_09", 30, 291, -1, -1, 9),
761 ui_button_info("HCB_10", 55, 291, -1, -1, 10),
762 ui_button_info("HCB_11", 80, 291, -1, -1, 11),
763 ui_button_info("HCB_12", 4, 329, -1, -1, 12),
764 ui_button_info("HCB_13", 4, 348, -1, -1, 13),
765 ui_button_info("HCB_14", 4, 367, -1, -1, 14),
766 ui_button_info("HCB_15", 2, 439, -1, -1, 15),
767 ui_button_info("HCB_16", 266, 456, -1, -1, 16),
768 ui_button_info("HCB_17", 292, 456, -1, -1, 17),
769 ui_button_info("HCB_18", 327, 421, -1, -1, 18),
770 ui_button_info("HCB_19", 327, 440, -1, -1, 19),
771 ui_button_info("HCB_20", 327, 459, -1, -1, 20),
772 ui_button_info("HCB_24", 472, 436, -1, -1, 24),
773 ui_button_info("HCB_25", 523, 433, -1, -1, 25),
774 ui_button_info("HCB_26", 576, 434, -1, -1, 26),
778 ui_button_info("2_HCB_00", 9, 44, -1, -1, 0),
779 ui_button_info("2_HCB_01", 48, 44, -1, -1, 1),
780 ui_button_info("2_HCB_02", 88, 44, -1, -1, 2),
781 ui_button_info("2_HCB_03", 127, 44, -1, -1, 3),
782 ui_button_info("2_HCB_08", 9, 466, -1, -1, 8),
783 ui_button_info("2_HCB_09", 48, 466, -1, -1, 9),
784 ui_button_info("2_HCB_10", 88, 466, -1, -1, 10),
785 ui_button_info("2_HCB_11", 127, 466, -1, -1, 11),
787 ui_button_info("2_HCB_12", 6, 526, -1, -1, 12),
788 ui_button_info("2_HCB_13", 6, 556, -1, -1, 13),
789 ui_button_info("2_HCB_14", 6, 586, -1, -1, 14),
790 ui_button_info("2_HCB_15", 3, 703, -1, -1, 15),
791 ui_button_info("2_HCB_16", 426, 730, -1, -1, 16),
792 ui_button_info("2_HCB_17", 467, 730, -1, -1, 17),
793 ui_button_info("2_HCB_18", 524, 674, -1, -1, 18),
794 ui_button_info("2_HCB_19", 524, 704, -1, -1, 19),
795 ui_button_info("2_HCB_20", 524, 734, -1, -1, 20),
796 ui_button_info("2_HCB_24", 755, 698, -1, -1, 24),
797 ui_button_info("2_HCB_25", 837, 693, -1, -1, 25),
798 ui_button_info("2_HCB_26", 922, 695, -1, -1, 26),
805 #define NUM_HUD_TEXT 0
807 #define NUM_HUD_TEXT 15
809 UI_XSTR HC_text[GR_NUM_RESOLUTIONS][NUM_HUD_TEXT] = {
811 // nothing needed for FS1
813 { "R", 1512, 14, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
814 { "G", 1513, 37, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
815 { "B", 1514, 62, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
816 { "I", 1515, 90, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
817 { "On", 1285, 36, 334, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_ON].button },
818 { "Off", 1286, 36, 353, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_OFF].button },
819 { "Popup", 1453, 36, 372, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_POPUP].button },
820 { "Save", 1454, 51, 428, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SAVE_HCF].button },
821 { "Amber", 1455, 364, 426, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_AMBER].button },
822 { "Blue", 1456, 364, 445, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_BLUE].button },
823 { "Green", 1457, 364, 464, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_GREEN].button },
824 { "Select", 1550, 442, 413, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SELECT_ALL].button },
825 { "All", 1551, 442, 424, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SELECT_ALL].button },
826 { "Reset", 1337, 515, 413, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_RESET].button },
827 { "Accept", 1035, 573, 413, UI_XSTR_COLOR_PINK, -1, &HC_buttons[0][HCB_ACCEPT].button },
831 // nothing needed for FS1
833 { "R", 1512, 23, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
834 { "G", 1513, 60, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
835 { "B", 1514, 100, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
836 { "I", 1515, 144, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
837 { "On", 1285, 58, 536, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_ON].button },
838 { "Off", 1286, 58, 566, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_OFF].button },
839 { "Popup", 1453, 58, 596, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_POPUP].button },
840 { "Save", 1454, 82, 688, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SAVE_HCF].button },
841 { "Amber", 1455, 582, 685, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_AMBER].button },
842 { "Blue", 1456, 582, 715, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_BLUE].button },
843 { "Green", 1457, 582, 745, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_GREEN].button },
844 { "Select", 1550, 760, 671, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SELECT_ALL].button },
845 { "All", 1551, 760, 682, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SELECT_ALL].button },
846 { "Reset", 1337, 850, 669, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_RESET].button },
847 { "Accept", 1035, 930, 670, UI_XSTR_COLOR_PINK, -1, &HC_buttons[1][HCB_ACCEPT].button },
852 void hud_config_set_rgb(int gauge, int r, int g, int b);
853 void hud_config_set_alpha(int gauge, int a);
856 #define NUM_HC_SPECIAL_BITMAPS 2
857 #define HC_SPECIAL_RETICLE 0
858 #define HC_SPECIAL_TEXT 1
859 typedef struct HC_special_bitmap
866 HC_special_bitmap HC_special_bitmaps[NUM_HC_SPECIAL_BITMAPS] =
869 {"HG_00a", 272, 146, -1},
870 {"HG_04a", 132, 271, -1},
875 static int HC_background_bitmap;
876 static UI_WINDOW HC_ui_window;
878 static int HC_gauge_hot; // mouse is over this gauge
879 static int HC_gauge_selected; // gauge is selected
883 #define HC_NUM_SLIDERS 1
884 #define HC_BRIGHTNESS_SLIDER 0
893 // left and right buttons
895 int left_mask, left_x, left_y;
896 char *right_filename;
897 int right_mask, right_x, right_y;
900 UI_DOT_SLIDER_NEW slider; // because we have a class inside this struct, we need the constructor below..
902 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) :
903 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) {}
906 hc_sliders HC_sliders[GR_NUM_RESOLUTIONS][HC_NUM_SLIDERS] = {
909 hc_sliders( "HCB_22", 419, 379, -1, -1, 22, 20, 10,
910 "HCB_23", 23, 611, 379,
911 "HCB_21", 21, 391, 379)
913 // ten dots but 11 frames, use frame count
914 hc_sliders( "HG_34", 373, 21, -1, -1, 34, 20, 11,
915 "HG_35", 35, 565, 20,
916 "HG_33", 33, 349, 20)
919 hc_sliders( "2_HCB_22", 670, 606, -1, -1, 22, 32, 10,
920 "2_HCB_23", 23, 698, 606,
921 "2_HCB_21", 21, 625, 606),
928 typedef struct hc_col {
932 hc_col HC_colors[3] =
934 {0, 255, 0}, // Green - get RGB from Adam so it matches palette?-??.pcx
935 {67, 123, 203}, // Blue - get RGB from Adam so it matches palette?-??.pcx
936 {255, 197, 0}, // Amber - get RGB from Adam so it matches palette?-??.pcx
939 static HUD_CONFIG_TYPE HUD_config_backup; // backup HUD config, used to restore old config if changes not applied
940 static int HUD_config_inited = 0;
943 void hud_config_red_slider();
944 void hud_config_green_slider();
945 void hud_config_blue_slider();
946 void hud_config_alpha_slider_up();
947 void hud_config_alpha_slider_down();
948 void hud_config_recalc_alpha_slider();
949 void hud_config_process_colors();
950 void hud_config_color_init();
951 void hud_config_color_close();
952 #define NUM_HC_SLIDERS 4
957 UI_SLIDER2 HC_color_sliders[NUM_HC_SLIDERS];
958 int HC_slider_coords[GR_NUM_RESOLUTIONS][NUM_HC_SLIDERS][4] = {
969 { 133, 85, 32, 350 },
972 #define HCS_CONV(__v) ( 255 - (__v) )
974 char *HC_slider_fname[GR_NUM_RESOLUTIONS] = {
980 void hud_config_synch_sliders(int i)
984 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HUD_config.clr[i].red) );
985 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HUD_config.clr[i].green) );
986 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HUD_config.clr[i].blue) );
987 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(HUD_config.clr[i].alpha) );
992 // reset some ui components based on HUD config data
993 void hud_config_synch_ui()
998 HUD_init_hud_color_array();
1000 HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos = HUD_color_alpha -3; // convert to value from 0-10
1003 // sync sliders to currently selected gauge
1004 hud_config_synch_sliders(HC_gauge_selected);
1008 // Init the UI components
1009 void hud_config_init_ui()
1012 struct HC_gauge_region *hg;
1013 struct ui_button_info *hb;
1016 common_set_interface_palette("HUDConfigPalette"); // set the interface palette
1018 hud_config_synch_ui();
1019 HC_background_bitmap = bm_load(Hud_config_fname[gr_screen.res]);
1021 HC_ui_window.create( 0, 0, gr_screen.max_w, gr_screen.max_h, 0 );
1022 HC_ui_window.set_mask_bmap(Hud_config_mask_fname[gr_screen.res]);
1024 for (i=0; i<NUM_HUD_GAUGES; i++) {
1025 hg = &HC_gauge_regions[gr_screen.res][i];
1026 if ( !stricmp(hg->filename, NOX("none")) ) {
1029 hg->button.create(&HC_ui_window, "", hg->x, hg->y, 60, 30, 0, 1);
1030 // set up callback for when a mouse first goes over a button
1031 // hg->button.set_highlight_action(common_play_highlight_sound);
1033 hg->button.link_hotspot(hg->hotspot);
1036 if ( hg->use_iff ) {
1037 hg->bitmap = bm_load_animation(hg->filename, &hg->nframes);
1039 hg->bitmap = bm_load(hg->filename);
1043 hg->bitmap = bm_load(hg->filename);
1049 for(i=0; i<NUM_HUD_TEXT; i++){
1050 HC_ui_window.add_XSTR(&HC_text[gr_screen.res][i]);
1054 // initialize sliders
1055 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],
1056 255, HC_slider_fname[gr_screen.res], hud_config_red_slider, hud_config_red_slider, hud_config_red_slider);
1058 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],
1059 255, HC_slider_fname[gr_screen.res], hud_config_green_slider, hud_config_green_slider, hud_config_green_slider);
1061 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],
1062 255, HC_slider_fname[gr_screen.res], hud_config_blue_slider, hud_config_blue_slider, hud_config_blue_slider);
1064 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],
1065 255, HC_slider_fname[gr_screen.res], hud_config_alpha_slider_up, hud_config_alpha_slider_down, NULL);
1068 hud_config_color_init();
1070 for (i=0; i<NUM_HUD_BUTTONS; i++) {
1071 hb = &HC_buttons[gr_screen.res][i];
1072 hb->button.create(&HC_ui_window, "", hb->x, hb->y, 60, 30, 0, 1);
1073 // set up callback for when a mouse first goes over a button
1074 hb->button.set_bmaps(hb->filename);
1075 hb->button.set_highlight_action(common_play_highlight_sound);
1076 hb->button.link_hotspot(hb->hotspot);
1079 // config file input name
1080 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);
1081 HC_fname_input.set_text("");
1084 for (i=0; i<NUM_HC_SPECIAL_BITMAPS; i++) {
1085 HC_special_bitmaps[i].bitmap = bm_load(HC_special_bitmaps[i].filename);
1089 for(i=0; i<HC_NUM_SLIDERS; i++){
1090 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,
1091 HC_sliders[gr_screen.res][i].dots, HC_sliders[gr_screen.res][i].filename,
1092 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,
1093 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,
1094 HC_sliders[gr_screen.res][i].dot_w);
1096 HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos = HUD_color_alpha - 3;
1101 HC_gauge_selected = -1;
1105 strcpy(HC_fname, "");
1108 int hud_config_show_flag_is_set(int i)
1113 show_flag_set = HUD_config.show_flags & (1<<i);
1115 show_flag_set = HUD_config.show_flags2 & (1<<(i-32));
1118 return show_flag_set;
1121 void hud_config_show_flag_set(int i)
1124 HUD_config.show_flags |= (1<<i);
1126 HUD_config.show_flags2 |= (1<<(i-32));
1130 void hud_config_show_flag_clear(int i)
1133 HUD_config.show_flags &= ~(1<<i);
1135 HUD_config.show_flags2 &= ~(1<<(i-32));
1139 int hud_config_popup_flag_is_set(int i)
1144 popup_flag_set = HUD_config.popup_flags & (1<<i);
1146 popup_flag_set = HUD_config.popup_flags2 & (1<<(i-32));
1149 return popup_flag_set;
1152 void hud_config_popup_flag_set(int i)
1155 HUD_config.popup_flags |= (1<<i);
1157 HUD_config.popup_flags2 |= (1<<(i-32));
1161 void hud_config_popup_flag_clear(int i)
1164 HUD_config.popup_flags &= ~(1<<i);
1166 HUD_config.popup_flags2 &= ~(1<<(i-32));
1170 // render all the hud config gauges
1171 void hud_config_render_gauges()
1179 for ( i=0; i<NUM_HUD_GAUGES; i++ ) {
1180 if ( (hud_config_show_flag_is_set(i)) ) {
1181 // set the correct color
1182 if(!HC_gauge_regions[gr_screen.res][i].use_iff){
1183 use_color = HUD_config.clr[i];
1186 if(HC_gauge_regions[gr_screen.res][i].color == 1){
1187 use_color = IFF_colors[IFF_COLOR_TAGGED][0];
1189 use_color = IFF_colors[IFF_COLOR_HOSTILE][0];
1193 if ( (HC_gauge_selected == i) || HC_select_all ) {
1195 } else if ( HC_gauge_hot == i ) {
1200 gr_init_alphacolor(&use_color, use_color.red, use_color.green, use_color.blue, alpha);
1201 gr_set_color_fast(&use_color);
1203 // set correct frame if using iff
1204 if ( HC_gauge_regions[gr_screen.res][i].use_iff ) {
1207 if ( HC_gauge_selected == i ) {
1209 } else if ( HC_gauge_hot == i ) {
1213 // If gauge is disabled, then draw disabled frame
1214 if ( !(hud_config_show_flag_is_set(i)) ) {
1218 if ( HC_gauge_regions[gr_screen.res][i].bitmap >= 0 ) {
1219 Assert(offset < HC_gauge_regions[gr_screen.res][i].nframes);
1220 gr_set_bitmap(HC_gauge_regions[gr_screen.res][i].bitmap+offset);
1221 gr_bitmap(HC_gauge_regions[gr_screen.res][i].x, HC_gauge_regions[gr_screen.res][i].y);
1227 // if its off, make it dark gray
1228 gr_init_alphacolor(&use_color, 127, 127, 127, 64);
1229 gr_set_color_fast(&use_color);
1233 if ( HC_gauge_regions[gr_screen.res][i].bitmap >= 0 ) {
1234 gr_set_bitmap(HC_gauge_regions[gr_screen.res][i].bitmap);
1235 gr_aabitmap(HC_gauge_regions[gr_screen.res][i].x, HC_gauge_regions[gr_screen.res][i].y);
1242 // set correct frame if using iff
1243 if ( HC_gauge_regions[i].use_iff ) {
1244 if ( HC_gauge_selected == i ) {
1246 } else if ( HC_gauge_hot == i ) {
1250 // If gauge is disabled, then draw disabled frame
1251 if ( !(hud_config_show_flag_is_set(i)) ) {
1256 if ( HC_gauge_regions[i].bitmap >= 0 ) {
1257 Assert(offset < HC_gauge_regions[i].nframes);
1258 gr_set_bitmap(HC_gauge_regions[i].bitmap+offset);
1259 gr_bitmap(HC_gauge_regions[i].x, HC_gauge_regions[i].y);
1266 // hud_config_init() is called when the game enters the state GS_STATE_HUD_CONFIG
1267 void hud_config_init()
1269 hud_config_init_ui();
1270 hud_config_backup(); // save the HUD configuration in case the player decides to cancel changes
1271 HUD_config_inited = 1;
1274 // check for the mouse over gauge regions
1275 void hud_config_check_regions()
1280 for ( i=0; i<NUM_HUD_GAUGES; i++ ) {
1281 b = &HC_gauge_regions[gr_screen.res][i].button;
1283 // check for mouse over gauges
1284 if ( b->button_hilighted() ) {
1288 if ( b->pressed() ) {
1289 gamesnd_play_iface(SND_USER_SELECT);
1290 HC_gauge_selected = i;
1292 // turn off select all
1293 hud_config_select_all_toggle(0);
1295 // maybe setup rgb sliders
1297 if(HC_gauge_regions[gr_screen.res][i].use_iff){
1298 HC_color_sliders[HCS_RED].hide();
1299 HC_color_sliders[HCS_GREEN].hide();
1300 HC_color_sliders[HCS_BLUE].hide();
1301 HC_color_sliders[HCS_ALPHA].hide();
1303 HC_color_sliders[HCS_RED].disable();
1304 HC_color_sliders[HCS_GREEN].disable();
1305 HC_color_sliders[HCS_BLUE].disable();
1306 HC_color_sliders[HCS_ALPHA].disable();
1308 HC_color_sliders[HCS_RED].enable();
1309 HC_color_sliders[HCS_GREEN].enable();
1310 HC_color_sliders[HCS_BLUE].enable();
1311 HC_color_sliders[HCS_ALPHA].enable();
1313 HC_color_sliders[HCS_RED].unhide();
1314 HC_color_sliders[HCS_GREEN].unhide();
1315 HC_color_sliders[HCS_BLUE].unhide();
1316 HC_color_sliders[HCS_ALPHA].unhide();
1318 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HUD_config.clr[i].red) );
1319 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HUD_config.clr[i].green) );
1320 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HUD_config.clr[i].blue) );
1321 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(HUD_config.clr[i].alpha) );
1325 // recalc alpha slider
1326 hud_config_recalc_alpha_slider();
1331 // set the display flags for a HUD gauge
1332 void hud_config_set_gauge_flags(int gauge_index, int on_flag, int popup_flag)
1335 hud_config_show_flag_set(gauge_index);
1337 hud_config_show_flag_clear(gauge_index);
1341 hud_config_popup_flag_set(gauge_index);
1343 hud_config_popup_flag_clear(gauge_index);
1347 void hud_config_record_color(int color)
1349 HUD_config.main_color = color;
1350 HUD_color_red = HC_colors[color].r;
1351 HUD_color_green = HC_colors[color].g;
1352 HUD_color_blue = HC_colors[color].b;
1355 // Set the HUD color
1356 void hud_config_set_color(int color)
1360 hud_config_record_color(color);
1363 game_load_palette();
1366 HUD_init_hud_color_array();
1368 // apply the color to all gauges
1369 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1370 gr_init_alphacolor(&HUD_config.clr[idx], HC_colors[color].r, HC_colors[color].g, HC_colors[color].b, (HUD_color_alpha+1)*16);
1374 void hud_config_stuff_colors(int r, int g, int b)
1378 // apply the color to all gauges
1379 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1380 gr_init_alphacolor(&HUD_config.clr[idx], r, g, b, 255);
1384 // leave hud config without accepting changes
1385 void hud_config_cancel()
1387 hud_config_restore();
1388 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
1391 // leave hud config with accepting changes
1392 void hud_config_commit()
1394 gamesnd_play_iface(SND_COMMIT_PRESSED);
1395 gameseq_post_event(GS_EVENT_PREVIOUS_STATE);
1398 // move gauge state from on->off->popup
1399 void hud_cycle_gauge_status()
1401 if ( HC_gauge_selected < 0 ) {
1405 // gauge is off, move to popup
1406 if ( !(hud_config_show_flag_is_set(HC_gauge_selected)) ) {
1407 if ( HC_gauge_regions[gr_screen.res][HC_gauge_selected].can_popup ) {
1408 hud_config_set_gauge_flags(HC_gauge_selected, 1, 1);
1410 hud_config_set_gauge_flags(HC_gauge_selected, 1, 0);
1415 // if gauge is popup, move to on
1416 if ( hud_config_popup_flag_is_set(HC_gauge_selected) ) {
1417 hud_config_set_gauge_flags(HC_gauge_selected, 1, 0);
1421 // gauge must be on, move to off
1422 hud_config_set_gauge_flags(HC_gauge_selected, 0, 0);
1425 // handle keyboard input while in hud config
1426 void hud_config_handle_keypresses(int k)
1430 hud_config_cancel();
1432 case KEY_CTRLED+KEY_ENTER:
1433 hud_config_commit();
1436 gamesnd_play_iface(SND_USER_SELECT);
1437 hud_cycle_gauge_status();
1442 // Handlers for when buttons get pressed
1443 void hud_config_button_do(int n)
1447 char name[256] = "";
1452 hud_config_set_color(HUD_COLOR_AMBER);
1453 gamesnd_play_iface(SND_USER_SELECT);
1456 hud_config_set_color(HUD_COLOR_BLUE);
1457 gamesnd_play_iface(SND_USER_SELECT);
1460 hud_config_set_color(HUD_COLOR_GREEN);
1461 gamesnd_play_iface(SND_USER_SELECT);
1464 if ( HC_gauge_selected < 0 ) {
1467 gamesnd_play_iface(SND_USER_SELECT);
1468 hud_config_set_gauge_flags(HC_gauge_selected,1,0);
1471 if ( HC_gauge_selected < 0 ) {
1474 gamesnd_play_iface(SND_USER_SELECT);
1475 hud_config_set_gauge_flags(HC_gauge_selected,0,0);
1478 if ( HC_gauge_selected < 0 ) {
1481 gamesnd_play_iface(SND_USER_SELECT);
1482 hud_config_set_gauge_flags(HC_gauge_selected,1,1);
1485 gamesnd_play_iface(SND_RESET_PRESSED);
1486 hud_config_select_all_toggle(0);
1487 hud_set_default_hud_config(Player);
1488 hud_config_synch_ui();
1491 hud_config_commit();
1497 if( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) >= 255){
1498 gamesnd_play_iface(SND_GENERAL_FAIL);
1500 gamesnd_play_iface(SND_USER_SELECT);
1501 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) + 1) );
1502 hud_config_red_slider();
1507 if( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) >= 255){
1508 gamesnd_play_iface(SND_GENERAL_FAIL);
1510 gamesnd_play_iface(SND_USER_SELECT);
1511 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) + 1) );
1512 hud_config_green_slider();
1517 if( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) >= 255){
1518 gamesnd_play_iface(SND_GENERAL_FAIL);
1520 gamesnd_play_iface(SND_USER_SELECT);
1521 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) + 1) );
1522 hud_config_blue_slider();
1527 if( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) >= 255){
1528 gamesnd_play_iface(SND_GENERAL_FAIL);
1530 gamesnd_play_iface(SND_USER_SELECT);
1531 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) + 1) );
1532 hud_config_alpha_slider_up();
1537 if( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) <= 0){
1538 gamesnd_play_iface(SND_GENERAL_FAIL);
1540 gamesnd_play_iface(SND_USER_SELECT);
1541 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) - 1) );
1542 hud_config_red_slider();
1546 case HCB_GREEN_DOWN:
1547 if( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) <= 0){
1548 gamesnd_play_iface(SND_GENERAL_FAIL);
1550 gamesnd_play_iface(SND_USER_SELECT);
1551 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) - 1) );
1552 hud_config_green_slider();
1557 if( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) <= 0){
1558 gamesnd_play_iface(SND_GENERAL_FAIL);
1560 gamesnd_play_iface(SND_USER_SELECT);
1561 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) - 1) );
1562 hud_config_blue_slider();
1567 if( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) <= 0){
1568 gamesnd_play_iface(SND_GENERAL_FAIL);
1570 gamesnd_play_iface(SND_USER_SELECT);
1571 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) - 1) );
1572 hud_config_alpha_slider_down();
1580 // get the text in the input control
1582 HC_fname_input.get_text(name);
1583 if(strlen(name) > 0){
1584 // if the filename in there already exists
1585 for(idx=0; idx<HC_num_files; idx++){
1586 if(!stricmp(HC_filenames[idx], name)){
1595 out = cf_add_ext(name, ".hcf");
1596 hud_config_color_save(out);
1600 // otherwise we have to create a new file
1601 if(HC_num_files >= MAX_HCF_FILES){
1602 popup(PF_USE_AFFIRMATIVE_ICON, 1, "OK", "Max number of hud config files reached!");
1606 // save the file, maybe generating a new filename
1607 if(strlen(name) <= 0){
1608 sprintf(name, "hud_%d.hcf", HC_num_files + 1);
1611 out = cf_add_ext(name, ".hcf");
1613 HC_filenames[HC_num_files++] = strdup(out);
1614 hud_config_color_save(out);
1616 HC_fname_input.set_text(out);
1620 if(HC_num_files <= 0){
1624 if(HC_current_file <= 0){
1625 HC_current_file = HC_num_files - 1;
1630 hud_config_color_load(HC_filenames[HC_current_file]);
1631 hud_config_synch_ui();
1633 HC_fname_input.set_text(HC_filenames[HC_current_file]);
1637 if(HC_num_files <= 0){
1641 if(HC_current_file >= HC_num_files - 1){
1642 HC_current_file = 0;
1648 hud_config_color_load(HC_filenames[HC_current_file]);
1649 hud_config_synch_ui();
1651 HC_fname_input.set_text(HC_filenames[HC_current_file]);
1654 case HCB_SELECT_ALL:
1655 hud_config_select_all_toggle(!HC_select_all);
1665 // Check if any buttons have been pressed
1666 void hud_config_check_buttons()
1671 for ( i=0; i<NUM_HUD_BUTTONS; i++ ) {
1672 b = &HC_buttons[gr_screen.res][i].button;
1673 if ( b->pressed() ) {
1674 hud_config_button_do(i);
1679 // set the hud color button
1680 void hud_config_draw_color_status()
1682 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() ) {
1686 switch(HUD_config.main_color) {
1687 case HUD_COLOR_AMBER:
1688 HC_buttons[gr_screen.res][HCB_AMBER].button.draw_forced(2);
1690 case HUD_COLOR_GREEN:
1691 HC_buttons[gr_screen.res][HCB_GREEN].button.draw_forced(2);
1693 case HUD_COLOR_BLUE:
1694 HC_buttons[gr_screen.res][HCB_BLUE].button.draw_forced(2);
1699 // set the status (on/off/popup) for the selected gauge
1700 void hud_config_draw_gauge_status()
1702 if ( HC_gauge_selected < 0 ) {
1706 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() ) {
1711 if ( !(hud_config_show_flag_is_set(HC_gauge_selected)) ) {
1712 HC_buttons[gr_screen.res][HCB_OFF].button.draw_forced(2);
1717 if ( hud_config_popup_flag_is_set(HC_gauge_selected) ) {
1718 HC_buttons[gr_screen.res][HCB_POPUP].button.draw_forced(2);
1723 if ( hud_config_show_flag_is_set(HC_gauge_selected) ) {
1724 HC_buttons[gr_screen.res][HCB_ON].button.draw_forced(2);
1728 Int3(); // should never get here
1731 // disable a HUD config button
1732 void hud_config_button_disable(int index)
1734 // HC_buttons[gr_screen.res][index].button.hide();
1735 HC_buttons[gr_screen.res][index].button.disable();
1738 // enable a HUD config button
1739 void hud_config_button_enable(int index)
1741 // HC_buttons[gr_screen.res][index].button.unhide();
1742 HC_buttons[gr_screen.res][index].button.enable();
1745 // determine if on/off/popup buttons should be shown
1746 void hud_config_set_button_state()
1748 if ( HC_gauge_selected < 0 ) {
1749 hud_config_button_disable(HCB_ON);
1750 hud_config_button_disable(HCB_OFF);
1751 hud_config_button_disable(HCB_POPUP);
1755 // on/off are always on
1756 hud_config_button_enable(HCB_ON);
1757 hud_config_button_enable(HCB_OFF);
1759 // popup is maybe available
1760 if ( HC_gauge_regions[gr_screen.res][HC_gauge_selected].can_popup ) {
1761 hud_config_button_enable(HCB_POPUP);
1763 hud_config_button_disable(HCB_POPUP);
1767 void hud_config_render_description()
1771 if ( HC_gauge_selected >= 0 ) {
1772 gr_set_color_fast(&Color_normal);
1774 gr_get_string_size(&w, &h, HC_gauge_descriptions(HC_gauge_selected));
1775 sx = fl2i(HC_gauge_description_coords[gr_screen.res][0] + (HC_gauge_description_coords[gr_screen.res][2] - w)/2.0f);
1776 sy = HC_gauge_description_coords[gr_screen.res][1];
1777 gr_string(sx, sy, HC_gauge_descriptions(HC_gauge_selected));
1781 void hud_config_render_special_bitmaps()
1785 for (i=1; i<NUM_HC_SPECIAL_BITMAPS; i++) {
1786 if (HC_special_bitmaps[i].bitmap >= 0) {
1787 gr_set_bitmap(HC_special_bitmaps[i].bitmap);
1788 gr_bitmap(HC_special_bitmaps[i].x, HC_special_bitmaps[i].y);
1794 // update HUD_color_alpha based on brightness slider
1795 void hud_config_update_brightness()
1798 HUD_color_alpha = HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos+3;
1799 Assert(HUD_color_alpha >= HUD_COLOR_ALPHA_USER_MIN);
1800 Assert(HUD_color_alpha <= HUD_COLOR_ALPHA_USER_MAX);
1804 // redraw any pressed buttons, needed since the glow on pressed buttons might get clipped off by
1805 // adjacent buttons otherwise
1806 void hud_config_redraw_pressed_buttons()
1811 for ( i = 0; i < NUM_HUD_BUTTONS; i++ ) {
1812 b = &HC_buttons[gr_screen.res][i].button;
1813 if ( b->button_down() ) {
1819 // hud_config_do_frame() is called from the main freespace loop while the game is in the state
1820 // GS_STATE_HUD_CONFIG.
1822 void hud_config_do_frame(float frametime)
1826 if (!HUD_config_inited) {
1832 hud_config_set_button_state();
1834 k = HC_ui_window.process();
1836 hud_config_handle_keypresses(k);
1837 hud_config_check_regions();
1838 hud_config_check_buttons();
1839 hud_config_update_brightness();
1841 // set the background
1842 GR_MAYBE_CLEAR_RES(HC_background_bitmap);
1843 if ( HC_background_bitmap > 0 ) {
1844 gr_set_bitmap(HC_background_bitmap);
1848 // rgb slider/button stuff
1849 hud_config_process_colors();
1851 HC_ui_window.draw();
1852 hud_config_redraw_pressed_buttons();
1854 hud_config_draw_gauge_status();
1855 hud_config_draw_color_status();
1858 if (HC_special_bitmaps[HC_SPECIAL_RETICLE].bitmap >= 0) {
1859 hud_set_default_color();
1860 gr_set_bitmap(HC_special_bitmaps[HC_SPECIAL_RETICLE].bitmap);
1861 gr_aabitmap(HC_special_bitmaps[HC_SPECIAL_RETICLE].x, HC_special_bitmaps[HC_SPECIAL_RETICLE].y);
1865 // maybe force draw the select all button
1868 HC_buttons[gr_screen.res][HCB_SELECT_ALL].button.draw_forced(2);
1872 hud_config_render_gauges();
1873 hud_config_render_special_bitmaps();
1874 hud_config_render_description();
1879 void hud_config_unload_gauges()
1882 HC_gauge_region *hg;
1884 for (i=0; i<NUM_HUD_GAUGES; i++) {
1885 hg = &HC_gauge_regions[gr_screen.res][i];
1887 if ( hg->bitmap >= 0 ) {
1888 for ( j=0; j<hg->nframes; j++ ) {
1889 bm_unload(hg->bitmap+j);
1898 // hud_config_close() is called when the player leaves the hud configuration screen
1900 void hud_config_close()
1903 common_free_interface_palette(); // restore game palette
1905 hud_config_unload_gauges();
1906 hud_init_popup_timers(); // ensure no popup gauges are active
1908 hud_config_color_close();
1910 HC_ui_window.destroy();
1913 // hud_set_default_hud_config() will set the hud configuration to default values
1914 void hud_set_default_hud_config(player *p)
1918 HUD_color_alpha = HUD_COLOR_ALPHA_DEFAULT;
1919 HUD_config.main_color = HUD_COLOR_GREEN;
1920 HUD_color_red = HC_colors[HUD_config.main_color].r;
1921 HUD_color_green = HC_colors[HUD_config.main_color].g;
1922 HUD_color_blue = HC_colors[HUD_config.main_color].b;
1924 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1925 gr_init_alphacolor(&HUD_config.clr[idx], HUD_color_red, HUD_color_green, HUD_color_blue, (HUD_color_alpha+1)*16);
1928 HUD_config.show_flags = HUD_config_default_flags;
1929 HUD_config.show_flags2 = HUD_config_default_flags2;
1930 HUD_config.popup_flags = HUD_default_popup_mask;
1931 HUD_config.popup_flags2 = HUD_default_popup_mask2;
1932 HUD_config.num_msg_window_lines = 4; // one more than is actually visible
1933 HUD_config.rp_flags = RP_DEFAULT;
1934 HUD_config.rp_dist = RR_INFINITY;
1935 HUD_config.is_observer = 0;
1938 // hud_config_restore() will restore the hud configuration the player started with when the
1939 // hud configuration screen was started
1941 void hud_config_restore()
1943 HUD_config = HUD_config_backup;
1946 // hud_config_backup() will save the players hud configuration when they enter the hud configuration
1947 // screen. This is done in case the player decides to cancel the changes that were made.
1949 void hud_config_backup()
1951 HUD_config_backup = HUD_config;
1954 void hud_config_as_observer(ship *shipp,ai_info *aif)
1956 // store the current hus
1957 hud_config_backup();
1959 // bash these values so the HUD is not offset incorrectly
1960 HUD_offset_x = 0.0f;
1961 HUD_offset_y = 0.0f;
1963 // initialize the observer HUD
1964 hud_observer_init(shipp,aif);
1967 void hud_config_as_player()
1971 // ---------------------------------------------------------------------------------------------------------------
1975 void hud_config_color_save(char *name)
1978 CFILE *out = cfopen(name, "wt", CFILE_NORMAL, CF_TYPE_PLAYERS);
1979 char vals[255] = "";
1987 // write out all gauges
1988 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1989 cfputs("+Gauge: ", out);
1990 cfputs(HC_gauge_descriptions(idx), out);
1992 cfputs("+RGBA: ", out);
1993 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);
2001 void hud_config_color_load(char *name)
2004 char str[1024] = "";
2007 fname = cf_add_ext(name, ".hcf");
2009 if ((rval = setjmp(parse_abort)) != 0) {
2010 mprintf(("Error opening hud config file!\n"));
2013 read_file_text(fname);
2017 // write out all gauges
2018 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
2019 required_string("+Gauge:");
2020 stuff_string(str, F_NAME, NULL, 1023);
2022 required_string("+RGBA:");
2023 stuff_byte(&HUD_config.clr[idx].red);
2024 stuff_byte(&HUD_config.clr[idx].green);
2025 stuff_byte(&HUD_config.clr[idx].blue);
2026 stuff_byte(&HUD_config.clr[idx].alpha);
2030 void hud_config_alpha_slider_up()
2033 int pos = HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem());
2034 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()) );
2036 // if this would put the brightest element past its limit, skip
2038 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(pos - 1) );
2042 // otherwise bump everybody up by one
2043 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) + 1) );
2044 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) + 1) );
2045 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) + 1) );
2049 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()) );
2051 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);
2056 void hud_config_alpha_slider_down()
2059 int pos = HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem());
2060 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()) );
2062 // if this would put the brightest element past its limit, skip
2064 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(pos + 1) );
2068 // otherwise bump everybody up by one
2069 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) - 1) );
2070 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) - 1) );
2071 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) - 1) );
2075 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()) );
2077 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);
2082 void hud_config_recalc_alpha_slider()
2085 int avg =HC_color_sliders[HCS_RED].get_currentItem() + HC_color_sliders[HCS_GREEN].get_currentItem() + HC_color_sliders[HCS_BLUE].get_currentItem();
2087 HC_color_sliders[HCS_ALPHA].force_currentItem( avg );
2091 void hud_config_red_slider()
2095 int pos = HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) ;
2099 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
2100 gr_init_alphacolor(&HUD_config.clr[idx], pos, HUD_config.clr[idx].green, HUD_config.clr[idx].blue, HUD_config.clr[idx].alpha);
2105 if(HC_gauge_selected < 0){
2109 // get slider position
2110 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);
2113 hud_config_recalc_alpha_slider();
2117 void hud_config_green_slider()
2121 int pos = HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) ;
2125 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
2126 gr_init_alphacolor(&HUD_config.clr[idx], HUD_config.clr[idx].red, pos, HUD_config.clr[idx].blue, HUD_config.clr[idx].alpha);
2131 if(HC_gauge_selected < 0){
2135 // get slider position
2136 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);
2139 hud_config_recalc_alpha_slider();
2143 void hud_config_blue_slider()
2147 int pos = HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem());
2151 for(idx=0; idx<NUM_HUD_GAUGES; idx++){
2152 gr_init_alphacolor(&HUD_config.clr[idx], HUD_config.clr[idx].red, HUD_config.clr[idx].green, pos, HUD_config.clr[idx].alpha);
2157 if(HC_gauge_selected < 0){
2161 // get slider position
2162 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);
2165 hud_config_recalc_alpha_slider();
2169 void hud_config_process_colors()
2173 void hud_config_color_init()
2175 HC_current_file = -1;
2177 // get a list of all hcf files
2178 memset(HC_filenames, 0, sizeof(char*) * MAX_HCF_FILES);
2179 HC_num_files = cf_get_file_list(MAX_HCF_FILES, HC_filenames, CF_TYPE_PLAYERS, "*.hcf", CF_SORT_NAME);
2182 void hud_config_color_close()
2187 for(idx=0; idx<HC_num_files; idx++){
2188 if(HC_filenames[idx] != NULL){
2189 free(HC_filenames[idx]);
2190 HC_filenames[idx] = NULL;
2195 void hud_config_select_all_toggle(int toggle)
2200 // if we're turning off
2202 // determine if on/off/popup buttons should be shown
2203 hud_config_set_button_state();
2208 hud_config_synch_ui();
2210 // if we had a gauge previously selected, use its color everywhere
2211 if(HC_gauge_selected < 0){
2212 r = HUD_config.clr[HUD_RADAR].red;
2213 g = HUD_config.clr[HUD_RADAR].green;
2214 b = HUD_config.clr[HUD_RADAR].blue;
2215 a = HUD_config.clr[HUD_RADAR].alpha;
2217 r = HUD_config.clr[HC_gauge_selected].red;
2218 g = HUD_config.clr[HC_gauge_selected].green;
2219 b = HUD_config.clr[HC_gauge_selected].blue;
2220 a = HUD_config.clr[HC_gauge_selected].alpha;
2222 hud_config_stuff_colors(r, g, b);
2224 // no gauge selected
2225 HC_gauge_selected = -1;
2227 // enable all sliders
2228 HC_color_sliders[HCS_RED].enable();
2229 HC_color_sliders[HCS_GREEN].enable();
2230 HC_color_sliders[HCS_BLUE].enable();
2231 HC_color_sliders[HCS_ALPHA].enable();
2232 HC_color_sliders[HCS_RED].unhide();
2233 HC_color_sliders[HCS_GREEN].unhide();
2234 HC_color_sliders[HCS_BLUE].unhide();
2235 HC_color_sliders[HCS_ALPHA].unhide();
2236 HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(r) );
2237 HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(g) );
2238 HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(b) );
2239 HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(a) );
2242 hud_config_recalc_alpha_slider();
2244 // disable all three buttons
2245 hud_config_button_disable(HCB_ON);
2246 hud_config_button_disable(HCB_OFF);
2247 hud_config_button_disable(HCB_POPUP);