FS2_Open
Open source remastering of the Freespace 2 engine
hudconfig.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 
13 #include "cfile/cfile.h"
15 #include "gamesnd/gamesnd.h"
16 #include "globalincs/alphacolors.h"
17 #include "globalincs/pstypes.h"
18 #include "hud/hudconfig.h"
19 #include "hud/hudobserver.h"
20 #include "iff_defs/iff_defs.h"
21 #include "io/key.h"
22 #include "parse/parselo.h"
23 #include "playerman/player.h"
24 #include "popup/popup.h"
25 #include "ship/ship.h"
26 #include "ui/ui.h"
27 
28 
30 // Game-wide Globals
32 
33 #define MAX_HCF_FILES 30
34 int HC_num_files = -1; // num known hcf files
35 int HC_current_file = -1; // current hcf file
37 
41  { // GR_640
42  44, 449, 218, 17
43  },
44  { // GR_1024
45  101, 730, 319, 27
46  }
47 };
48 
49 HUD_CONFIG_TYPE HUD_config; // Player HUD configuration
50 
52  "lead indicator",
53  "target orientation",
54  "closest attacking hostile",
55  "current target direction",
56  "mission time",
57  "reticle",
58  "throttle",
59  "radar",
60  "target monitor",
61  "center of reticle",
62  "extra target info",
63  "target shield",
64  "player shield",
65  "power management",
66  "auto-target icon",
67  "auto-speed-match icon",
68  "weapons display",
69  "monitoring view",
70  "directives view",
71  "threat gauge",
72  "afterburner energy",
73  "weapons energy",
74  "weapon linking",
75  "target hull/shield icon",
76  "offscreen indicator",
77  "comm video",
78  "damage display",
79  "message output",
80  "locked missile direction",
81  "countermeasures",
82  "objective notify",
83  "wingmen status",
84  "offscreen range",
85  "kills gauge",
86  "attacking target count",
87  "warning flash",
88  "comm menu",
89  "support gauge",
90  "lag gauge"
91 };
92 
93 // specify the max distance that the radar should detect objects
94 // See RR_ #defines in HUDconfig.h.
95 
97  2000.0f, // short
98  10000.0f, // med
99  10000000.0f, // infinity
100 };
101 
102 const char *Radar_range_text(int n)
103 {
104  #if RR_MAX_RANGES != 3
105  #error Number of ranges is wrong!
106  #endif
107 
108  switch(n) {
109  case 0:
110  return XSTR( "2000 M", 246);
111  case 1:
112  return XSTR( "10,000 M", 247);
113  case 2:
114  return XSTR( "infinity", 248);
115  }
116  return NULL;
117 }
118 
119 // default flags for observer HUD
121 {
122  (1<<HUD_CENTER_RETICLE) |
124  (1<<HUD_MESSAGE_LINES) |
125  (1<<HUD_HOSTILE_TRIANGLE) |
126  (1<<HUD_TARGET_TRIANGLE) |
127  (1<<HUD_TARGET_MINI_ICON) |
128  (1<<HUD_TARGET_MONITOR)
129 };
130 
132  (1<<(HUD_OFFSCREEN_RANGE - 32))
133 };
134 
135 // default flags for regular HUD
137 {
138  (1<<HUD_LEAD_INDICATOR) |
139  (1<<HUD_ORIENTATION_TEE) |
140  (1<<HUD_HOSTILE_TRIANGLE) |
141  (1<<HUD_TARGET_TRIANGLE) |
142  (1<<HUD_MISSION_TIME) |
143  (1<<HUD_RETICLE_CIRCLE) |
144  (1<<HUD_THROTTLE_GAUGE) |
145  (1<<HUD_RADAR) |
146  (1<<HUD_TARGET_MONITOR) |
147  (1<<HUD_CENTER_RETICLE) |
151  (1<<HUD_ETS_GAUGE) |
152  (1<<HUD_AUTO_TARGET) |
153  (1<<HUD_AUTO_SPEED) |
154  (1<<HUD_WEAPONS_GAUGE) |
155  (1<<HUD_ESCORT_VIEW) |
156  (1<<HUD_DIRECTIVES_VIEW) |
157  (1<<HUD_THREAT_GAUGE) |
159  (1<<HUD_WEAPONS_ENERGY) |
161  (1<<HUD_TARGET_MINI_ICON) |
163  (1<<HUD_TALKING_HEAD) |
164  (1<<HUD_DAMAGE_GAUGE) |
165  (1<<HUD_MESSAGE_LINES) |
167  (1<<HUD_CMEASURE_GAUGE) |
169  (1<<HUD_WINGMEN_STATUS)
170 };
171 
173 {
174  (1<<(HUD_OFFSCREEN_RANGE-32)) |
175  (1<<(HUD_KILLS_GAUGE-32)) |
176  (1<<(HUD_ATTACKING_TARGET_COUNT-32)) |
177  (1<<(HUD_SUPPORT_GAUGE-32)) |
178  (1<<(HUD_LAG_GAUGE-32)) |
179  (1<<(HUD_TEXT_FLASH-32)) |
180  (1<<(HUD_MESSAGE_BOX-32))
181 };
182 
183 // bits to tell whether a given gauge should be treated as pop-up or not
185 {
186  0 | // (1<<HUD_LEAD_INDICATOR) | //-V578
187  0 | // (1<<HUD_ORIENTATION_TEE) |
188  0 | // (1<<HUD_HOSTILE_TRIANGLE) |
189  0 | // (1<<HUD_TARGET_TRIANGLE) |
190  0 | // (1<<HUD_MISSION_TIME) |
191  0 | // (1<<HUD_RETICLE_CIRCLE) |
192  0 | // (1<<HUD_THROTTLE_GAUGE) |
193  0 | // (1<<HUD_RADAR) |
194  0 | // (1<<HUD_TARGET_MONITOR) |
195  0 | // (1<<HUD_CENTER_RETICLE) |
196  0 | // (1<<HUD_TARGET_MONITOR_EXTRA_DATA) |
197  0 | // (1<<HUD_TARGET_SHIELD_ICON) |
198  0 | // (1<<HUD_PLAYER_SHIELD_ICON) |
199  0 | // (1<<HUD_ETS_GAUGE) |
200  0 | // (1<<HUD_AUTO_TARGET) |
201  0 | // (1<<HUD_AUTO_SPEED) |
202  0 | // (1<<HUD_WEAPONS_GAUGE) |
203  0 | // (1<<HUD_ESCORT_VIEW) |
204  0 | // (1<<HUD_DIRECTIVES_VIEW) |
205  0 | // (1<<HUD_THREAT_GAUGE) |
206  0 | // (1<<HUD_AFTERBURNER_ENERGY) |
207  0 | // (1<<HUD_WEAPONS_ENERGY) |
208  0 | // (1<<HUD_WEAPON_LINKING_GAUGE) |
209  0 | // (1<<HUD_TARGET_MINI_ICON) |
210  0 | //(1<<HUD_OFFSCREEN_INDICATOR)
211  0 | // talking head
212  0 | // damage gauge
213  0 | // message lines
214  0 | // missile warning arrow
215  0 | // countermeasures
216  0 // wingman status
217 };
218 
220 {
221  0 | // offscreen indicator range //-V578
222  0 |
223  0 // kills gauge
224 };
225 
226 void hud_config_color_save(char *name);
227 void hud_config_select_all_toggle(int toggle);
228 
230 
232 // Module Globals
234 
235 
237  "HUDConfig",
238  "2_HUDConfig"
239 };
240 
242  "HUDConfig-m",
243  "2_HUDConfig-m"
244 };
245 
247 {
248  char *filename;
249  int x,y;
250  int hotspot;
251  int use_iff;
253  int bitmap;
254  int nframes;
255  int color;
257 
258  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){}
259 };
260 
261 // hud config gauges
263 {
264  { // GR_640
265  //XSTR:OFF
266  HC_gauge_region("HCB_35", 407, 69, 35, 1, 0, -1, 0, 2), // lead indicator
267  HC_gauge_region("HCB_36", 305, 119, 36, 1, 0, -1, 0, 2), // orientation tee
268  HC_gauge_region("none", 1, 1, -1, 1, 0, -1, 0, 0), // hostile triangle
269  HC_gauge_region("HCB_37", 391, 107, 37, 1, 0, -1, 0, 2), // target triangle
270  HC_gauge_region("HCB_63", 575, 352, 63, 0, 0, -1, 0, 0), // mission time
271  HC_gauge_region("none", 1, 1, 1, 0, 0, -1, 0, 0), // reticle circle?
272  HC_gauge_region("HCB_40", 285, 146, 40, 0, 0, -1, 0, 0), // throttle gauge
273  HC_gauge_region("HCB_50", 317, 291, 50, 0, 0, -1, 0, 0), // radar
274  HC_gauge_region("HCB_31", 123, 249, 31, 0, 0, -1, 0, 0), // target monitor
275  HC_gauge_region("HCB_41", 361, 188, 41, 0, 0, -1, 0, 0), // center of reticle
276  HC_gauge_region("HCB_30", 123, 221, 30, 0, 0, -1, 0, 0), // extra target data
277  HC_gauge_region("HCB_49", 237, 303, 49, 0, 0, -1, 0, 0), // target shield icon
278  HC_gauge_region("HCB_51", 435, 304, 51, 0, 0, -1, 0, 0), // player shield icon
279  HC_gauge_region("HCB_58", 524, 299, 58, 0, 1, -1, 0, 0), // ets gauge
280  HC_gauge_region("HCB_61", 566, 299, 61, 0, 1, -1, 0, 0), // auto target
281  HC_gauge_region("HCB_62", 566, 317, 62, 0, 1, -1, 0, 0), // auto speed
282  HC_gauge_region("HCB_55", 504, 216, 55, 0, 1, -1, 0, 0), // weapons gauge
283  HC_gauge_region("HCB_54", 496, 166, 54, 0, 1, -1, 0, 0), // escort view
284  HC_gauge_region("HCB_29", 123, 142, 29, 0, 0, -1, 0, 0), // directives view
285  HC_gauge_region("HCB_43", 398, 147, 43, 0, 0, -1, 0, 0), // threat gauge
286  HC_gauge_region("HCB_39", 250, 212, 39, 0, 0, -1, 0, 0), // afterburner energy
287  HC_gauge_region("HCB_44", 449, 212, 44, 0, 0, -1, 0, 0), // weapons energy
288  HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // weapon linking
289  HC_gauge_region("HCB_42", 356, 232, 42, 0, 1, -1, 0, 0), // target mini icon (shield)
290  HC_gauge_region("HCB_34", 438, 5, 34, 1, 0, -1, 0, 2), // offscreen indicator
291  HC_gauge_region("HCB_28", 123, 31, 28, 0, 0, -1, 0, 0), // talking head
292  HC_gauge_region("HCB_32", 309, 33, 32, 0, 1, -1, 0, 0), // damage gauge
293  HC_gauge_region("HCB_27", 124, 19, 27, 0, 0, -1, 0, 0), // message lines
294  HC_gauge_region("HCB_45", 307, 249, 45, 1, 0, -1, 0, 1), // missile warnings
295  HC_gauge_region("HCB_56", 505, 271, 56, 0, 1, -1, 0, 0), // cmeasure gauge
296  HC_gauge_region("HCB_33", 309, 87, 33, 0, 0, -1, 0, 0), // objectives notify gauge
297  HC_gauge_region("HCB_53", 546, 117, 53, 0, 0, -1, 0, 0), // wingman status gauge
298  HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // offscreen indicator range
299  HC_gauge_region("HCB_57", 505, 285, 57, 0, 1, -1, 0, 0), // kills gauge
300  HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // attacking target count
301  HC_gauge_region("HCB_38", 342, 138, 38, 0, 0, -1, 0, 0), // text flash gauge
302  HC_gauge_region("HCB_52", 465, 8, 52, 0, 0, -1, 0, 0), // comm menu
303  HC_gauge_region("HCB_46", 324, 264, 46, 0, 0, -1, 0, 0), // support view gauge
304  HC_gauge_region("HCB_47", 418, 262, 47, 0, 0, -1, 0, 0), // netlag icon gauge
305  //XSTR:ON
306  },
307  { // GR_1024
308  //XSTR:OFF
309  HC_gauge_region("2_HCB_35", 652, 112, 35, 1, 0, -1, 0, 2), // lead indicator
310  HC_gauge_region("2_HCB_36", 489, 191, 36, 1, 0, -1, 0, 2), // orientation tee
311  HC_gauge_region("none", 1, 1, -1, 1, 0, -1, 0, 0), // hostile triangle
312  HC_gauge_region("2_HCB_37", 626, 173, 37, 1, 0, -1, 0, 2), // target triangle
313  HC_gauge_region("2_HCB_63", 920, 564, 63, 0, 0, -1, 0, 0), // mission time
314  HC_gauge_region("none", 1, 1, 1, 0, 0, -1, 0, 0), // reticle circle?
315  HC_gauge_region("2_HCB_40", 456, 235, 40, 0, 0, -1, 0, 0), // throttle gauge
316  HC_gauge_region("2_HCB_50", 508, 466, 50, 0, 0, -1, 0, 0), // radar
317  HC_gauge_region("2_HCB_31", 198, 399, 31, 0, 0, -1, 0, 0), // target monitor
318  HC_gauge_region("2_HCB_41", 578, 302, 41, 0, 0, -1, 0, 0), // center of reticle
319  HC_gauge_region("2_HCB_30", 198, 354, 30, 0, 0, -1, 0, 0), // extra target data
320  HC_gauge_region("2_HCB_49", 380, 485, 49, 0, 0, -1, 0, 0), // target shield icon
321  HC_gauge_region("2_HCB_51", 696, 486, 51, 0, 0, -1, 0, 0), // player shield icon
322  HC_gauge_region("2_HCB_58", 839, 479, 58, 0, 1, -1, 0, 0), // ets gauge
323  HC_gauge_region("2_HCB_61", 906, 479, 61, 0, 1, -1, 0, 0), // auto target
324  HC_gauge_region("2_HCB_62", 906, 508, 62, 0, 1, -1, 0, 0), // auto speed
325  HC_gauge_region("2_HCB_55", 807, 346, 55, 0, 1, -1, 0, 0), // weapons gauge
326  HC_gauge_region("2_HCB_54", 794, 265, 54, 0, 1, -1, 0, 0), // escort view
327  HC_gauge_region("2_HCB_29", 198, 228, 29, 0, 0, -1, 0, 0), // directives view
328  HC_gauge_region("2_HCB_43", 637, 237, 43, 0, 0, -1, 0, 0), // threat gauge
329  HC_gauge_region("2_HCB_39", 403, 339, 39, 0, 0, -1, 0, 0), // afterburner energy
330  HC_gauge_region("2_HCB_44", 719, 339, 44, 0, 0, -1, 0, 0), // weapons energy
331  HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // weapon linking
332  HC_gauge_region("2_HCB_42", 569, 371, 42, 0, 1, -1, 0, 0), // target mini icon (shield)
333  HC_gauge_region("2_HCB_34", 701, 9, 34, 1, 0, -1, 0, 2), // offscreen indicator
334  HC_gauge_region("2_HCB_28", 198, 50, 28, 0, 0, -1, 0, 0), // talking head
335  HC_gauge_region("2_HCB_32", 495, 55, 32, 0, 1, -1, 0, 0), // damage gauge
336  HC_gauge_region("2_HCB_27", 199, 30, 27, 0, 0, -1, 0, 0), // message lines
337  HC_gauge_region("2_HCB_45", 491, 399, 45, 1, 0, -1, 0, 1), // missile warnings
338  HC_gauge_region("2_HCB_56", 808, 433, 56, 0, 1, -1, 0, 0), // cmeasure gauge
339  HC_gauge_region("2_HCB_33", 495, 141, 33, 0, 0, -1, 0, 0), // objectives notify gauge
340  HC_gauge_region("2_HCB_53", 873, 188, 53, 0, 0, -1, 0, 0), // wingman status gauge
341  HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // offscreen indicator range
342  HC_gauge_region("2_HCB_57", 808, 456, 57, 0, 1, -1, 0, 0), // kills gauge
343  HC_gauge_region("none", 1, 1, -1, 0, 0, -1, 0, 0), // attacking target count
344  HC_gauge_region("2_HCB_38", 548, 222, 38, 0, 0, -1, 0, 0), // text flash gauge
345  HC_gauge_region("2_HCB_52", 744, 14, 52, 0, 0, -1, 0, 0), // comm menu
346  HC_gauge_region("2_HCB_46", 520, 422, 46, 0, 0, -1, 0, 0), // support view gauge
347  HC_gauge_region("2_HCB_47", 670, 419, 47, 0, 0, -1, 0, 0), // netlag icon gauge
348  //XSTR:ON
349  }
350 };
351 
352 
354  { // GR_640
355  35, 397, 197
356  },
357  { // GR_1024
358  56, 632, 307
359  }
360 };
361 
362 const char *HC_gauge_descriptions(int n)
363 {
364  switch(n) {
365  case 0:
366  return XSTR( "lead indicator", 249);
367  case 1:
368  return XSTR( "target orientation", 250);
369  case 2:
370  return XSTR( "closest attacking hostile", 251);
371  case 3:
372  return XSTR( "current target direction", 252);
373  case 4:
374  return XSTR( "mission time", 253);
375  case 5:
376  return XSTR( "reticle", 254);
377  case 6:
378  return XSTR( "throttle", 255);
379  case 7:
380  return XSTR( "radar", 256);
381  case 8:
382  return XSTR( "target monitor", 257);
383  case 9:
384  return XSTR( "center of reticle", 258);
385  case 10:
386  return XSTR( "extra target info", 259);
387  case 11:
388  return XSTR( "target shield", 260);
389  case 12:
390  return XSTR( "player shield", 261);
391  case 13:
392  return XSTR( "power management", 262);
393  case 14:
394  return XSTR( "auto-target icon", 263);
395  case 15:
396  return XSTR( "auto-speed-match icon", 264);
397  case 16:
398  return XSTR( "weapons display", 265);
399  case 17:
400  return XSTR( "monitoring view", 266);
401  case 18:
402  return XSTR( "directives view", 267);
403  case 19:
404  return XSTR( "threat gauge", 268);
405  case 20:
406  return XSTR( "afterburner energy", 269);
407  case 21:
408  return XSTR( "weapons energy", 270);
409  case 22:
410  return XSTR( "weapon linking", 271);
411  case 23:
412  return XSTR( "target hull/shield icon", 272);
413  case 24:
414  return XSTR( "offscreen indicator", 273);
415  case 25:
416  return XSTR( "comm video", 274);
417  case 26:
418  return XSTR( "damage display", 275);
419  case 27:
420  return XSTR( "message output", 276);
421  case 28:
422  return XSTR( "locked missile direction", 277);
423  case 29:
424  return XSTR( "countermeasures", 278);
425  case 30:
426  return XSTR( "objective notify", 279);
427  case 31:
428  return XSTR( "wingmen status", 280);
429  case 32:
430  return XSTR( "offscreen range", 281);
431  case 33:
432  return XSTR( "kills gauge", 282);
433  case 34:
434  return XSTR( "attacking target count", 283);
435  case 35:
436  return XSTR("warning flash", 1459);
437  case 36:
438  return XSTR("comm menu", 1460);
439  case 37:
440  return XSTR("support gauge", 1461);
441  case 38:
442  return XSTR("lag gauge", 1462);
443  }
444  return NULL;
445 }
446 
447 #define NUM_HUD_BUTTONS 20
448 
449 #define HCB_RED_UP 0
450 #define HCB_GREEN_UP 1
451 #define HCB_BLUE_UP 2
452 #define HCB_I_UP 3
453 #define HCB_RED_DOWN 4
454 #define HCB_GREEN_DOWN 5
455 #define HCB_BLUE_DOWN 6
456 #define HCB_I_DOWN 7
457 #define HCB_ON 8
458 #define HCB_OFF 9
459 #define HCB_POPUP 10
460 #define HCB_SAVE_HCF 11
461 #define HCB_PREV_HCF 12
462 #define HCB_NEXT_HCF 13
463 #define HCB_AMBER 14
464 #define HCB_BLUE 15
465 #define HCB_GREEN 16
466 #define HCB_SELECT_ALL 17
467 #define HCB_RESET 18
468 #define HCB_ACCEPT 19
469 
470 
472  { // GR_640
473  ui_button_info("HCB_00", 6, 27, -1, -1, 0),
474  ui_button_info("HCB_01", 30, 27, -1, -1, 1),
475  ui_button_info("HCB_02", 55, 27, -1, -1, 2),
476  ui_button_info("HCB_03", 80, 27, -1, -1, 3),
477  ui_button_info("HCB_08", 6, 291, -1, -1, 8),
478  ui_button_info("HCB_09", 30, 291, -1, -1, 9),
479  ui_button_info("HCB_10", 55, 291, -1, -1, 10),
480  ui_button_info("HCB_11", 80, 291, -1, -1, 11),
481  ui_button_info("HCB_12", 4, 329, -1, -1, 12),
482  ui_button_info("HCB_13", 4, 348, -1, -1, 13),
483  ui_button_info("HCB_14", 4, 367, -1, -1, 14),
484  ui_button_info("HCB_15", 2, 439, -1, -1, 15),
485  ui_button_info("HCB_16", 266, 456, -1, -1, 16),
486  ui_button_info("HCB_17", 292, 456, -1, -1, 17),
487  ui_button_info("HCB_18", 327, 421, -1, -1, 18),
488  ui_button_info("HCB_19", 327, 440, -1, -1, 19),
489  ui_button_info("HCB_20", 327, 459, -1, -1, 20),
490  ui_button_info("HCB_24", 472, 436, -1, -1, 24),
491  ui_button_info("HCB_25", 523, 433, -1, -1, 25),
492  ui_button_info("HCB_26", 576, 434, -1, -1, 26),
493  },
494  { // GR_1024
495  ui_button_info("2_HCB_00", 9, 44, -1, -1, 0),
496  ui_button_info("2_HCB_01", 48, 44, -1, -1, 1),
497  ui_button_info("2_HCB_02", 88, 44, -1, -1, 2),
498  ui_button_info("2_HCB_03", 127, 44, -1, -1, 3),
499  ui_button_info("2_HCB_08", 9, 466, -1, -1, 8),
500  ui_button_info("2_HCB_09", 48, 466, -1, -1, 9),
501  ui_button_info("2_HCB_10", 88, 466, -1, -1, 10),
502  ui_button_info("2_HCB_11", 127, 466, -1, -1, 11),
503  ui_button_info("2_HCB_12", 6, 526, -1, -1, 12),
504  ui_button_info("2_HCB_13", 6, 556, -1, -1, 13),
505  ui_button_info("2_HCB_14", 6, 586, -1, -1, 14),
506  ui_button_info("2_HCB_15", 3, 703, -1, -1, 15),
507  ui_button_info("2_HCB_16", 426, 730, -1, -1, 16),
508  ui_button_info("2_HCB_17", 467, 730, -1, -1, 17),
509  ui_button_info("2_HCB_18", 524, 674, -1, -1, 18),
510  ui_button_info("2_HCB_19", 524, 704, -1, -1, 19),
511  ui_button_info("2_HCB_20", 524, 734, -1, -1, 20),
512  ui_button_info("2_HCB_24", 755, 698, -1, -1, 24),
513  ui_button_info("2_HCB_25", 837, 693, -1, -1, 25),
514  ui_button_info("2_HCB_26", 922, 695, -1, -1, 26),
515  },
516 };
517 
518 // text
519 #define NUM_HUD_TEXT 15
521  { // GR_640
522  { "R", 1512, 14, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
523  { "G", 1513, 37, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
524  { "B", 1514, 62, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
525  { "I", 1515, 90, 8, UI_XSTR_COLOR_GREEN, -1, NULL },
526  { "On", 1285, 36, 334, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_ON].button },
527  { "Off", 1286, 36, 353, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_OFF].button },
528  { "Popup", 1453, 36, 372, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_POPUP].button },
529  { "Save", 1454, 51, 428, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SAVE_HCF].button },
530  { "Amber", 1455, 364, 426, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_AMBER].button },
531  { "Blue", 1456, 364, 445, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_BLUE].button },
532  { "Green", 1457, 364, 464, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_GREEN].button },
533  { "Select", 1550, 442, 413, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SELECT_ALL].button },
534  { "All", 1551, 442, 424, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_SELECT_ALL].button },
535  { "Reset", 1337, 515, 413, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[0][HCB_RESET].button },
536  { "Accept", 1035, 573, 413, UI_XSTR_COLOR_PINK, -1, &HC_buttons[0][HCB_ACCEPT].button },
537  },
538  { // GR_1024
539  { "R", 1512, 23, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
540  { "G", 1513, 60, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
541  { "B", 1514, 100, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
542  { "I", 1515, 144, 14, UI_XSTR_COLOR_GREEN, -1, NULL },
543  { "On", 1285, 58, 536, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_ON].button },
544  { "Off", 1286, 58, 566, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_OFF].button },
545  { "Popup", 1453, 58, 596, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_POPUP].button },
546  { "Save", 1454, 82, 688, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SAVE_HCF].button },
547  { "Amber", 1455, 582, 685, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_AMBER].button },
548  { "Blue", 1456, 582, 715, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_BLUE].button },
549  { "Green", 1457, 582, 745, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_GREEN].button },
550  { "Select", 1550, 760, 671, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SELECT_ALL].button },
551  { "All", 1551, 760, 682, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_SELECT_ALL].button },
552  { "Reset", 1337, 850, 669, UI_XSTR_COLOR_GREEN, -1, &HC_buttons[1][HCB_RESET].button },
553  { "Accept", 1035, 930, 670, UI_XSTR_COLOR_PINK, -1, &HC_buttons[1][HCB_ACCEPT].button },
554  }
555 };
556 
557 void hud_config_set_rgb(int gauge, int r, int g, int b);
558 void hud_config_set_alpha(int gauge, int a);
559 
560 /*
561 #define NUM_HC_SPECIAL_BITMAPS 2
562 #define HC_SPECIAL_RETICLE 0
563 #define HC_SPECIAL_TEXT 1
564 typedef struct HC_special_bitmap
565 {
566  char *filename;
567  int x,y;
568  int bitmap;
569 } HC_special_bitmap;
570 
571 HC_special_bitmap HC_special_bitmaps[NUM_HC_SPECIAL_BITMAPS] =
572 {
573 //XSTR:OFF
574  {"HG_00a", 272, 146, -1},
575  {"HG_04a", 132, 271, -1},
576 //XSTR:ON
577 };
578 */
579 
580 static int HC_background_bitmap;
581 static UI_WINDOW HC_ui_window;
582 
583 static int HC_gauge_hot; // mouse is over this gauge
584 static int HC_gauge_selected; // gauge is selected
585 
586 // slider controls
587 /*
588 #define HC_NUM_SLIDERS 1
589 #define HC_BRIGHTNESS_SLIDER 0
590 struct hc_sliders {
591  // base slider
592  char *filename;
593  int x, y, xt, yt;
594  int hotspot;
595  int dot_w;
596  int dots;
597 
598  // left and right buttons
599  char *left_filename;
600  int left_mask, left_x, left_y;
601  char *right_filename;
602  int right_mask, right_x, right_y;
603 
604  // slider control
605  UI_DOT_SLIDER_NEW slider; // because we have a class inside this struct, we need the constructor below..
606 
607  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) :
608  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) {}
609 };
610 
611 hc_sliders HC_sliders[GR_NUM_RESOLUTIONS][HC_NUM_SLIDERS] = {
612  { // GR_640
613  hc_sliders( "HCB_22", 419, 379, -1, -1, 22, 20, 10,
614  "HCB_23", 23, 611, 379,
615  "HCB_21", 21, 391, 379)
616  },
617  { // GR_1024
618  hc_sliders( "2_HCB_22", 670, 606, -1, -1, 22, 32, 10,
619  "2_HCB_23", 23, 698, 606,
620  "2_HCB_21", 21, 625, 606),
621  }
622 };
623 */
624 
625 
626 // HUD colors
627 typedef struct hc_col {
628  ubyte r, g, b;
629 } hc_col;
630 
632 {
633  {0, 255, 0}, // Green - get RGB from Adam so it matches palette?-??.pcx
634  {67, 123, 203}, // Blue - get RGB from Adam so it matches palette?-??.pcx
635  {255, 197, 0}, // Amber - get RGB from Adam so it matches palette?-??.pcx
636 };
637 
638 static HUD_CONFIG_TYPE HUD_config_backup; // backup HUD config, used to restore old config if changes not applied
639 static int HUD_config_inited = 0;
640 
641 // rgba slider stuff
642 void hud_config_red_slider();
649 void hud_config_color_init();
651 #define NUM_HC_SLIDERS 4
652 #define HCS_RED 0
653 #define HCS_GREEN 1
654 #define HCS_BLUE 2
655 #define HCS_ALPHA 3
658  { // GR_640
659  { 8, 53, 15, 225 },
660  { 33, 53, 15, 225 },
661  { 58, 53, 15, 225 },
662  { 83, 53, 15, 225 },
663  },
664  { // GR_1024
665  { 13, 85, 32, 350 },
666  { 53, 85, 32, 350 },
667  { 93, 85, 32, 350 },
668  { 133, 85, 32, 350 },
669  },
670 };
671 #define HCS_CONV(__v) ( 255 - (__v) )
672 
674  "slider",
675  "2_slider"
676 };
677 
678 // sync sliders
680 {
681  if(i >= 0){
682  HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HUD_config.clr[i].red) );
683  HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HUD_config.clr[i].green) );
684  HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HUD_config.clr[i].blue) );
685  HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(HUD_config.clr[i].alpha) );
686  }
687 }
688 
689 // reset some ui components based on HUD config data
691 {
693  // HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos = HUD_color_alpha-3; // convert to value from 0-10
694 
695  // sync sliders to currently selected gauge
696  hud_config_synch_sliders(HC_gauge_selected);
697 }
698 
699 // Init the UI components
701 {
702  int i;
703  struct HC_gauge_region *hg;
704  struct ui_button_info *hb;
705 
707  HC_background_bitmap = bm_load(Hud_config_fname[gr_screen.res]);
708 
709  HC_ui_window.create( 0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0 );
710  HC_ui_window.set_mask_bmap(Hud_config_mask_fname[gr_screen.res]);
711 
712  for (i=0; i<NUM_HUD_GAUGES; i++) {
713  hg = &HC_gauge_regions[gr_screen.res][i];
714  if ( !stricmp(hg->filename, NOX("none")) ) {
715  continue;
716  }
717  hg->button.create(&HC_ui_window, "", hg->x, hg->y, 60, 30, 0, 1);
718  // set up callback for when a mouse first goes over a button
719 // hg->button.set_highlight_action(common_play_highlight_sound);
720  hg->button.hide();
721  hg->button.link_hotspot(hg->hotspot);
722 
723  // if ( hg->use_iff ) {
724 // hg->bitmap = bm_load_animation(hg->filename, &hg->nframes);
725  // } else {
726  hg->bitmap = bm_load(hg->filename);
727  hg->nframes = 1;
728  // }
729  }
730 
731  // add text
732  for(i=0; i<NUM_HUD_TEXT; i++){
733  HC_ui_window.add_XSTR(&HC_text[gr_screen.res][i]);
734  }
735 
736  // initialize sliders
737  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],
739 
740  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],
742 
743  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],
745 
746  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],
748 
750 
751  for (i=0; i<NUM_HUD_BUTTONS; i++) {
752  hb = &HC_buttons[gr_screen.res][i];
753  hb->button.create(&HC_ui_window, "", hb->x, hb->y, 60, 30, 0, 1);
754  // set up callback for when a mouse first goes over a button
755  hb->button.set_bmaps(hb->filename);
757  hb->button.link_hotspot(hb->hotspot);
758  }
759 
760  // config file input name
762  HC_fname_input.set_text("");
763 
764  /*
765  for (i=0; i<NUM_HC_SPECIAL_BITMAPS; i++) {
766  HC_special_bitmaps[i].bitmap = bm_load(HC_special_bitmaps[i].filename);
767  }
768  */
769 
770  // create sliders
771  /*
772  for(i=0; i<HC_NUM_SLIDERS; i++){
773  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,
774  HC_sliders[gr_screen.res][i].dots, HC_sliders[gr_screen.res][i].filename,
775  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,
776  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,
777  HC_sliders[gr_screen.res][i].dot_w);
778  }
779  HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos = HUD_color_alpha - 3;
780  */
781 
782 
783  HC_gauge_hot = -1;
784  HC_gauge_selected = -1;
785 
786  HC_select_all = 0;
787 
788  strcpy_s(HC_fname, "");
789 }
790 
792 {
793  int show_flag_set;
794 
795  if ( i < 32 ) {
796  show_flag_set = HUD_config.show_flags & (1<<i);
797  } else {
798  show_flag_set = HUD_config.show_flags2 & (1<<(i-32));
799  }
800 
801  return show_flag_set;
802 }
803 
805 {
806  if ( i < 32 ) {
807  HUD_config.show_flags |= (1<<i);
808  } else {
809  HUD_config.show_flags2 |= (1<<(i-32));
810  }
811 }
812 
814 {
815  if ( i < 32 ) {
816  HUD_config.show_flags &= ~(1<<i);
817  } else {
818  HUD_config.show_flags2 &= ~(1<<(i-32));
819  }
820 }
821 
823 {
824  int popup_flag_set;
825 
826  if ( i < 32 ) {
827  popup_flag_set = HUD_config.popup_flags & (1<<i);
828  } else {
829  popup_flag_set = HUD_config.popup_flags2 & (1<<(i-32));
830  }
831 
832  return popup_flag_set;
833 }
834 
836 {
837  if ( i < 32 ) {
838  HUD_config.popup_flags |= (1<<i);
839  } else {
840  HUD_config.popup_flags2 |= (1<<(i-32));
841  }
842 }
843 
845 {
846  if ( i < 32 ) {
847  HUD_config.popup_flags &= ~(1<<i);
848  } else {
849  HUD_config.popup_flags2 &= ~(1<<(i-32));
850  }
851 }
852 
853 // render all the hud config gauges
855 {
856  int i;
857 
858  for ( i=0; i<NUM_HUD_GAUGES; i++ ) {
859  color *use_color;
860  int alpha;
861  if ( (hud_config_show_flag_is_set(i)) ) {
862  // set the correct color
863  if(!HC_gauge_regions[gr_screen.res][i].use_iff){
864  use_color = &HUD_config.clr[i];
865  } else {
866  if(HC_gauge_regions[gr_screen.res][i].color == 1){
867  use_color = iff_get_color(IFF_COLOR_TAGGED, 0);
868  } else {
869  use_color = &Color_bright_red;
870  }
871  }
872 
873  if ( (HC_gauge_selected == i) || HC_select_all ) {
874  alpha = 255;
875  } else if ( HC_gauge_hot == i ) {
876  alpha = 200;
877  } else {
878  alpha = 150;
879  }
880  gr_init_alphacolor(use_color, use_color->red, use_color->green, use_color->blue, alpha);
881  gr_set_color_fast(use_color);
882  } else {
883  // if its off, make it dark gray
884  use_color = &HUD_config.clr[i];
885  gr_init_alphacolor(use_color, 127, 127, 127, 64);
886  gr_set_color_fast(use_color);
887  }
888 
889  // draw
890  if ( HC_gauge_regions[gr_screen.res][i].bitmap >= 0 ) {
891  gr_set_bitmap(HC_gauge_regions[gr_screen.res][i].bitmap);
892  gr_aabitmap(HC_gauge_regions[gr_screen.res][i].x, HC_gauge_regions[gr_screen.res][i].y, GR_RESIZE_MENU);
893  }
894 
895  /*
896  else {
897 
898  int offset=0;
899  // set correct frame if using iff
900  if ( HC_gauge_regions[i].use_iff ) {
901  if ( HC_gauge_selected == i ) {
902  offset=2;
903  } else if ( HC_gauge_hot == i ) {
904  offset=1;
905  }
906 
907  // If gauge is disabled, then draw disabled frame
908  if ( !(hud_config_show_flag_is_set(i)) ) {
909  offset=3;
910  }
911  }
912 
913  if ( HC_gauge_regions[i].bitmap >= 0 ) {
914  Assert(offset < HC_gauge_regions[i].nframes);
915  gr_set_bitmap(HC_gauge_regions[i].bitmap+offset);
916  gr_bitmap(HC_gauge_regions[i].x, HC_gauge_regions[i].y, GR_RESIZE_MENU);
917  }
918  }
919  */
920  }
921 }
922 
923 // hud_config_init() is called when the game enters the state GS_STATE_HUD_CONFIG
925 {
927  hud_config_backup(); // save the HUD configuration in case the player decides to cancel changes
928  HUD_config_inited = 1;
929 }
930 
931 // check for the mouse over gauge regions
933 {
934  int i;
935  UI_BUTTON *b;
936 
937  for ( i=0; i<NUM_HUD_GAUGES; i++ ) {
938  b = &HC_gauge_regions[gr_screen.res][i].button;
939 
940  // check for mouse over gauges
941  if ( b->button_hilighted() ) {
942  HC_gauge_hot = i;
943  }
944 
945  if ( b->pressed() ) {
947  HC_gauge_selected = i;
948 
949  // turn off select all
951 
952  // maybe setup rgb sliders
953  if(HC_gauge_regions[gr_screen.res][i].use_iff){
954  HC_color_sliders[HCS_RED].hide();
955  HC_color_sliders[HCS_GREEN].hide();
956  HC_color_sliders[HCS_BLUE].hide();
957  HC_color_sliders[HCS_ALPHA].hide();
958 
959  HC_color_sliders[HCS_RED].disable();
960  HC_color_sliders[HCS_GREEN].disable();
961  HC_color_sliders[HCS_BLUE].disable();
962  HC_color_sliders[HCS_ALPHA].disable();
963  } else {
964  HC_color_sliders[HCS_RED].enable();
965  HC_color_sliders[HCS_GREEN].enable();
966  HC_color_sliders[HCS_BLUE].enable();
967  HC_color_sliders[HCS_ALPHA].enable();
968 
969  HC_color_sliders[HCS_RED].unhide();
970  HC_color_sliders[HCS_GREEN].unhide();
971  HC_color_sliders[HCS_BLUE].unhide();
972  HC_color_sliders[HCS_ALPHA].unhide();
973 
974  HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HUD_config.clr[i].red) );
975  HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HUD_config.clr[i].green) );
976  HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HUD_config.clr[i].blue) );
977  HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(HUD_config.clr[i].alpha) );
978  }
979 
980  // recalc alpha slider
982  }
983  }
984 }
985 
986 // set the display flags for a HUD gauge
987 void hud_config_set_gauge_flags(int gauge_index, int on_flag, int popup_flag)
988 {
989  if ( on_flag ) {
990  hud_config_show_flag_set(gauge_index);
991  } else {
992  hud_config_show_flag_clear(gauge_index);
993  }
994 
995  if ( popup_flag ) {
996  hud_config_popup_flag_set(gauge_index);
997  } else {
998  hud_config_popup_flag_clear(gauge_index);
999  }
1000 }
1001 
1002 void hud_config_record_color(int in_color)
1003 {
1004  HUD_config.main_color = in_color;
1005  HUD_color_red = HC_colors[in_color].r;
1006  HUD_color_green = HC_colors[in_color].g;
1007  HUD_color_blue = HC_colors[in_color].b;
1008 }
1009 
1010 // Set the HUD color
1011 void hud_config_set_color(int in_color)
1012 {
1013  int idx;
1014 
1015  hud_config_record_color(in_color);
1016 
1018 
1019  // apply the color to all gauges
1020  for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1021  gr_init_alphacolor(&HUD_config.clr[idx], HC_colors[in_color].r, HC_colors[in_color].g, HC_colors[in_color].b, (HUD_color_alpha+1)*16);
1022  }
1023 }
1024 
1025 void hud_config_stuff_colors(int r, int g, int b)
1026 {
1027  int idx;
1028 
1029  // apply the color to all gauges
1030  for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1031  gr_init_alphacolor(&HUD_config.clr[idx], r, g, b, 255);
1032  }
1033 }
1034 
1035 // leave hud config without accepting changes
1037 {
1040 }
1041 
1042 // leave hud config with accepting changes
1044 {
1047 }
1048 
1049 // move gauge state from on->off->popup
1051 {
1052  if ( HC_gauge_selected < 0 ) {
1053  return;
1054  }
1055 
1056  // gauge is off, move to popup
1057  if ( !(hud_config_show_flag_is_set(HC_gauge_selected)) ) {
1058  if ( HC_gauge_regions[gr_screen.res][HC_gauge_selected].can_popup ) {
1059  hud_config_set_gauge_flags(HC_gauge_selected, 1, 1);
1060  } else {
1061  hud_config_set_gauge_flags(HC_gauge_selected, 1, 0);
1062  }
1063  return;
1064  }
1065 
1066  // if gauge is popup, move to on
1067  if ( hud_config_popup_flag_is_set(HC_gauge_selected) ) {
1068  hud_config_set_gauge_flags(HC_gauge_selected, 1, 0);
1069  return;
1070  }
1071 
1072  // gauge must be on, move to off
1073  hud_config_set_gauge_flags(HC_gauge_selected, 0, 0);
1074 }
1075 
1076 // handle keyboard input while in hud config
1078 {
1079  switch(k) {
1080  case KEY_ESC:
1082  break;
1083  case KEY_CTRLED+KEY_ENTER:
1085  break;
1086  case KEY_TAB:
1089  break;
1090  }
1091 }
1092 
1093 // Handlers for when buttons get pressed
1095 {
1096  int idx;
1097  char name[256] = "";
1098 
1099  switch (n) {
1100  case HCB_AMBER:
1103  break;
1104  case HCB_BLUE:
1107  break;
1108  case HCB_GREEN:
1111  break;
1112  case HCB_ON:
1113  if ( HC_gauge_selected < 0 ) {
1114  break;
1115  }
1117  hud_config_set_gauge_flags(HC_gauge_selected,1,0);
1118  break;
1119  case HCB_OFF:
1120  if ( HC_gauge_selected < 0 ) {
1121  break;
1122  }
1124  hud_config_set_gauge_flags(HC_gauge_selected,0,0);
1125  break;
1126  case HCB_POPUP:
1127  if ( HC_gauge_selected < 0 ) {
1128  break;
1129  }
1131  hud_config_set_gauge_flags(HC_gauge_selected,1,1);
1132  break;
1133  case HCB_RESET:
1138  break;
1139  case HCB_ACCEPT:
1141  break;
1142 
1143  // new stuff
1144  case HCB_RED_UP:
1145  if( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) >= 255){
1147  } else {
1149  HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) + 1) );
1151  }
1152  break;
1153 
1154  case HCB_GREEN_UP:
1155  if( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) >= 255){
1157  } else {
1159  HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) + 1) );
1161  }
1162  break;
1163 
1164  case HCB_BLUE_UP:
1165  if( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) >= 255){
1167  } else {
1169  HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) + 1) );
1171  }
1172  break;
1173 
1174  case HCB_I_UP:
1175  if( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) >= 255){
1177  } else {
1179  HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) + 1) );
1181  }
1182  break;
1183 
1184  case HCB_RED_DOWN:
1185  if( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) <= 0){
1187  } else {
1189  HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) - 1) );
1191  }
1192  break;
1193 
1194  case HCB_GREEN_DOWN:
1195  if( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) <= 0){
1197  } else {
1199  HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) - 1) );
1201  }
1202  break;
1203 
1204  case HCB_BLUE_DOWN:
1205  if( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) <= 0){
1207  } else {
1209  HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) - 1) );
1211  }
1212  break;
1213 
1214  case HCB_I_DOWN:
1215  if( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) <= 0){
1217  } else {
1219  HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV( HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem()) - 1) );
1221  }
1222  break;
1223 
1224  case HCB_SAVE_HCF:
1225  int exists;
1226  char *out;
1227 
1228  // get the text in the input control
1229  exists = 0;
1230  HC_fname_input.get_text(name);
1231  if(name[0] != '\0'){
1232  // if the filename in there already exists
1233  for(idx=0; idx<HC_num_files; idx++){
1234  if(!stricmp(HC_filenames[idx], name)){
1235  exists = 1;
1236  }
1237  }
1238  }
1239 
1240  // already exists?
1241  if(exists){
1242  // save the file
1243  out = cf_add_ext(name, ".hcf");
1244  hud_config_color_save(out);
1245  break;
1246  }
1247 
1248  // otherwise we have to create a new file
1249  if(HC_num_files >= MAX_HCF_FILES){
1250  popup(PF_USE_AFFIRMATIVE_ICON, 1, "OK", "Max number of hud config files reached!");
1251  break;
1252  }
1253 
1254  // save the file, maybe generating a new filename
1255  if(strlen(name) <= 0){
1256  sprintf(name, "hud_%d.hcf", HC_num_files + 1);
1257  out = name;
1258  } else {
1259  out = cf_add_ext(name, ".hcf");
1260  }
1262  hud_config_color_save(out);
1263 
1264  HC_fname_input.set_text(out);
1265  break;
1266 
1267  case HCB_PREV_HCF:
1268  if(HC_num_files <= 0){
1269  break;
1270  }
1271 
1272  if(HC_current_file <= 0){
1274  } else {
1275  HC_current_file--;
1276  }
1277  // load em up
1280 
1281  HC_fname_input.set_text(HC_filenames[HC_current_file]);
1282  break;
1283 
1284  case HCB_NEXT_HCF:
1285  if(HC_num_files <= 0){
1286  break;
1287  }
1288 
1289  if(HC_current_file >= HC_num_files - 1){
1290  HC_current_file = 0;
1291  } else {
1292  HC_current_file++;
1293  }
1294 
1295  // load em up
1296  hud_config_color_load(HC_filenames[HC_current_file]);
1298 
1299  HC_fname_input.set_text(HC_filenames[HC_current_file]);
1300  break;
1301 
1302  case HCB_SELECT_ALL:
1303  hud_config_select_all_toggle(!HC_select_all);
1304  break;
1305 
1306  default:
1307  Int3();
1308  break;
1309  }
1310 }
1311 
1312 // Check if any buttons have been pressed
1314 {
1315  int i;
1316  UI_BUTTON *b;
1317 
1318  for ( i=0; i<NUM_HUD_BUTTONS; i++ ) {
1319  b = &HC_buttons[gr_screen.res][i].button;
1320  if ( b->pressed() ) {
1322  }
1323  }
1324 }
1325 
1326 // set the hud color button
1328 {
1329  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() ) {
1330  return;
1331  }
1332 
1333  switch(HUD_config.main_color) {
1334  case HUD_COLOR_AMBER:
1335  HC_buttons[gr_screen.res][HCB_AMBER].button.draw_forced(2);
1336  break;
1337  case HUD_COLOR_GREEN:
1338  HC_buttons[gr_screen.res][HCB_GREEN].button.draw_forced(2);
1339  break;
1340  case HUD_COLOR_BLUE:
1341  HC_buttons[gr_screen.res][HCB_BLUE].button.draw_forced(2);
1342  break;
1343  }
1344 }
1345 
1346 // set the status (on/off/popup) for the selected gauge
1348 {
1349  if ( HC_gauge_selected < 0 ) {
1350  return;
1351  }
1352 
1353  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() ) {
1354  return;
1355  }
1356 
1357  // check if off
1358  if ( !(hud_config_show_flag_is_set(HC_gauge_selected)) ) {
1359  HC_buttons[gr_screen.res][HCB_OFF].button.draw_forced(2);
1360  return;
1361  }
1362 
1363  // check if popup
1364  if ( hud_config_popup_flag_is_set(HC_gauge_selected) ) {
1365  HC_buttons[gr_screen.res][HCB_POPUP].button.draw_forced(2);
1366  return;
1367  }
1368 
1369  // check if on
1370  if ( hud_config_show_flag_is_set(HC_gauge_selected) ) {
1371  HC_buttons[gr_screen.res][HCB_ON].button.draw_forced(2);
1372  return;
1373  }
1374 
1375  Int3(); // should never get here
1376 }
1377 
1378 // disable a HUD config button
1380 {
1381  // HC_buttons[gr_screen.res][index].button.hide();
1382  HC_buttons[gr_screen.res][index].button.disable();
1383 }
1384 
1385 // enable a HUD config button
1387 {
1388  // HC_buttons[gr_screen.res][index].button.unhide();
1389  HC_buttons[gr_screen.res][index].button.enable();
1390 }
1391 
1392 // determine if on/off/popup buttons should be shown
1394 {
1395  if ( HC_gauge_selected < 0 ) {
1399  return;
1400  }
1401 
1402  // on/off are always on
1405 
1406  // popup is maybe available
1407  if ( HC_gauge_regions[gr_screen.res][HC_gauge_selected].can_popup ) {
1409  } else {
1411  }
1412 }
1413 
1415 {
1416  int w,h,sx,sy;
1417 
1418  if ( HC_gauge_selected >= 0 ) {
1420 
1421  gr_get_string_size(&w, &h, HC_gauge_descriptions(HC_gauge_selected));
1422  sx = fl2i(HC_gauge_description_coords[gr_screen.res][0] + (HC_gauge_description_coords[gr_screen.res][2] - w)/2.0f);
1423  sy = HC_gauge_description_coords[gr_screen.res][1];
1424  gr_string(sx, sy, HC_gauge_descriptions(HC_gauge_selected), GR_RESIZE_MENU);
1425  }
1426 }
1427 
1429 {
1430  /*
1431  int i;
1432  for (i=1; i<NUM_HC_SPECIAL_BITMAPS; i++) {
1433  if (HC_special_bitmaps[i].bitmap >= 0) {
1434  gr_set_bitmap(HC_special_bitmaps[i].bitmap);
1435  gr_bitmap(HC_special_bitmaps[i].x, HC_special_bitmaps[i].y, GR_RESIZE_MENU);
1436  }
1437  }
1438  */
1439 }
1440 
1441 // update HUD_color_alpha based on brightness slider
1443 {
1444  // HUD_color_alpha = HC_sliders[gr_screen.res][HC_BRIGHTNESS_SLIDER].slider.pos+3;
1445  // Assert(HUD_color_alpha >= HUD_COLOR_ALPHA_USER_MIN);
1446  // Assert(HUD_color_alpha <= HUD_COLOR_ALPHA_USER_MAX);
1447 }
1448 
1449 // redraw any pressed buttons, needed since the glow on pressed buttons might get clipped off by
1450 // adjacent buttons otherwise
1452 {
1453  int i;
1454  UI_BUTTON *b;
1455 
1456  for ( i = 0; i < NUM_HUD_BUTTONS; i++ ) {
1457  b = &HC_buttons[gr_screen.res][i].button;
1458  if ( b->button_down() ) {
1459  b->draw_forced(2);
1460  }
1461  }
1462 }
1463 
1464 // hud_config_do_frame() is called from the main freespace loop while the game is in the state
1465 // GS_STATE_HUD_CONFIG.
1466 //
1467 void hud_config_do_frame(float frametime)
1468 {
1469  int k;
1470 
1471  if (!HUD_config_inited) {
1472  hud_config_init();
1473  }
1474 
1475  HC_gauge_hot = -1;
1476 
1478 
1479  k = HC_ui_window.process();
1480 
1485 
1486  // set the background
1487  GR_MAYBE_CLEAR_RES(HC_background_bitmap);
1488  if ( HC_background_bitmap > 0 ) {
1489  gr_set_bitmap(HC_background_bitmap);
1491  }
1492 
1493  // rgb slider/button stuff
1495 
1496  HC_ui_window.draw();
1498 
1501 
1502  /*
1503  if (HC_special_bitmaps[HC_SPECIAL_RETICLE].bitmap >= 0) {
1504  hud_set_default_color();
1505  gr_set_bitmap(HC_special_bitmaps[HC_SPECIAL_RETICLE].bitmap);
1506  gr_aabitmap(HC_special_bitmaps[HC_SPECIAL_RETICLE].x, HC_special_bitmaps[HC_SPECIAL_RETICLE].y, GR_RESIZE_MENU);
1507  }
1508  */
1509 
1510  // maybe force draw the select all button
1511  if(HC_select_all){
1512  HC_buttons[gr_screen.res][HCB_SELECT_ALL].button.draw_forced(2);
1513  }
1514 
1518 
1519  gr_flip();
1520 }
1521 
1523 {
1524  int i;
1525  HC_gauge_region *hg;
1526 
1527  for (i=0; i<NUM_HUD_GAUGES; i++) {
1528  hg = &HC_gauge_regions[gr_screen.res][i];
1529 
1530  if ( hg->bitmap >= 0 ) {
1531  bm_release(hg->bitmap);
1532  }
1533 
1534  hg->bitmap=-1;
1535  hg->nframes=0;
1536  }
1537 }
1538 
1539 // hud_config_close() is called when the player leaves the hud configuration screen
1540 //
1542 {
1543 // common_free_interface_palette(); // restore game palette
1545 
1547 
1548  HC_ui_window.destroy();
1549 }
1550 
1551 // hud_set_default_hud_config() will set the hud configuration to default values
1553 {
1554  int idx;
1555 
1557  HUD_config.main_color = HUD_COLOR_GREEN;
1558  HUD_color_red = HC_colors[HUD_config.main_color].r;
1559  HUD_color_green = HC_colors[HUD_config.main_color].g;
1560  HUD_color_blue = HC_colors[HUD_config.main_color].b;
1561 
1562  for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1564  }
1565 
1566  HUD_config.show_flags = HUD_config_default_flags;
1568  HUD_config.popup_flags = HUD_default_popup_mask;
1570  HUD_config.num_msg_window_lines = 4; // one more than is actually visible
1571  HUD_config.rp_flags = RP_DEFAULT;
1572  HUD_config.rp_dist = RR_INFINITY;
1573  HUD_config.is_observer = 0;
1574 
1575  // load up the default colors
1576  hud_config_color_load("hud_3.hcf");
1577 }
1578 
1579 // hud_config_restore() will restore the hud configuration the player started with when the
1580 // hud configuration screen was started
1581 //
1583 {
1584  HUD_config = HUD_config_backup;
1585 }
1586 
1587 // hud_config_backup() will save the players hud configuration when they enter the hud configuration
1588 // screen. This is done in case the player decides to cancel the changes that were made.
1589 //
1591 {
1592  HUD_config_backup = HUD_config;
1593 }
1594 
1596 {
1597  // store the current hus
1599 
1600  // bash these values so the HUD is not offset incorrectly
1601  HUD_offset_x = 0.0f;
1602  HUD_offset_y = 0.0f;
1603 
1604  // initialize the observer HUD
1605  hud_observer_init(shipp,aif);
1606 }
1607 
1609 {
1610 }
1611 
1612 // ---------------------------------------------------------------------------------------------------------------
1613 // RGB color stuff
1614 //
1615 
1617 {
1618  int idx;
1619  CFILE *out = cfopen(name, "wt", CFILE_NORMAL, CF_TYPE_PLAYERS);
1620  char vals[255] = "";
1621 
1622  // bad
1623  if(out == NULL){
1624  Int3();
1625  return;
1626  }
1627 
1628  // write out all gauges
1629  for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1630  cfputs("+Gauge: ", out);
1631  cfputs(HC_gauge_descriptions(idx), out);
1632  cfputs("\n", out);
1633  cfputs("+RGBA: ", out);
1634  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);
1635  cfputs(vals, out);
1636  }
1637 
1638  // close the file
1639  cfclose(out);
1640 }
1641 
1643 {
1644  int idx;
1645  char str[1024];
1646  char *fname;
1647 
1648  fname = cf_add_ext(name, ".hcf");
1649 
1650  try
1651  {
1652  read_file_text(fname);
1653  reset_parse();
1654 
1655  // First, set all gauges to the current main color
1656  for (idx = 0; idx < NUM_HUD_GAUGES; idx++){
1658  }
1659 
1660  // Now read in the color values for the gauges
1661  while (optional_string("+Gauge:")) {
1662  stuff_string(str, F_NAME, sizeof(str));
1663 
1664  for (idx = 0; idx < NUM_HUD_GAUGES; idx++) {
1665  if (!stricmp(str, Hud_Gauge_Names[idx])) {
1666  required_string("+RGBA:");
1667  stuff_ubyte(&HUD_config.clr[idx].red);
1668  stuff_ubyte(&HUD_config.clr[idx].green);
1669  stuff_ubyte(&HUD_config.clr[idx].blue);
1670  stuff_ubyte(&HUD_config.clr[idx].alpha);
1671  break;
1672  }
1673  }
1674  }
1675  }
1676  catch (const parse::ParseException& e)
1677  {
1678  mprintf(("HUDCONFIG: Unable to parse '%s'! Error message = %s.\n", fname, e.what()));
1679  return;
1680  }
1681 }
1682 
1684 {
1685  int pos = HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem());
1686  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()) );
1687 
1688  // if this would put the brightest element past its limit, skip
1689  if(max >= 255){
1690  HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(pos - 1) );
1691  return;
1692  }
1693 
1694  // otherwise bump everybody up by one
1695  HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) + 1) );
1696  HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) + 1) );
1697  HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) + 1) );
1698 
1699  // apply
1700  if(HC_select_all){
1701  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()) );
1702  } else {
1703  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);
1704  }
1705 }
1706 
1708 {
1709  int pos = HCS_CONV(HC_color_sliders[HCS_ALPHA].get_currentItem());
1710  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()) );
1711 
1712  // if this would put the brightest element past its limit, skip
1713  if(min <= 0){
1714  HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(pos + 1) );
1715  return;
1716  }
1717 
1718  // otherwise bump everybody up by one
1719  HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) - 1) );
1720  HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) - 1) );
1721  HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem()) - 1) );
1722 
1723  // apply
1724  if(HC_select_all){
1725  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()) );
1726  } else {
1727  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);
1728  }
1729 }
1730 
1732 {
1733  int avg =HC_color_sliders[HCS_RED].get_currentItem() + HC_color_sliders[HCS_GREEN].get_currentItem() + HC_color_sliders[HCS_BLUE].get_currentItem();
1734  avg /= 3;
1735  HC_color_sliders[HCS_ALPHA].force_currentItem( avg );
1736 }
1737 
1739 {
1740  int idx;
1741  int pos = HCS_CONV(HC_color_sliders[HCS_RED].get_currentItem()) ;
1742 
1743  // select all ?
1744  if(HC_select_all){
1745  for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1746  gr_init_alphacolor(&HUD_config.clr[idx], pos, HUD_config.clr[idx].green, HUD_config.clr[idx].blue, HUD_config.clr[idx].alpha);
1747  }
1748  }
1749  // individual gauge
1750  else {
1751  if(HC_gauge_selected < 0){
1752  return;
1753  }
1754 
1755  // get slider position
1756  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);
1757  }
1758 
1760 }
1761 
1763 {
1764  int idx;
1765  int pos = HCS_CONV(HC_color_sliders[HCS_GREEN].get_currentItem()) ;
1766 
1767  // select all ?
1768  if(HC_select_all){
1769  for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1770  gr_init_alphacolor(&HUD_config.clr[idx], HUD_config.clr[idx].red, pos, HUD_config.clr[idx].blue, HUD_config.clr[idx].alpha);
1771  }
1772  }
1773  // individual gauge
1774  else {
1775  if(HC_gauge_selected < 0){
1776  return;
1777  }
1778 
1779  // get slider position
1780  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);
1781  }
1782 
1784 }
1785 
1787 {
1788  int idx;
1789  int pos = HCS_CONV(HC_color_sliders[HCS_BLUE].get_currentItem());
1790 
1791  // select all ?
1792  if(HC_select_all){
1793  for(idx=0; idx<NUM_HUD_GAUGES; idx++){
1794  gr_init_alphacolor(&HUD_config.clr[idx], HUD_config.clr[idx].red, HUD_config.clr[idx].green, pos, HUD_config.clr[idx].alpha);
1795  }
1796  }
1797  // individual gauge
1798  else {
1799  if(HC_gauge_selected < 0){
1800  return;
1801  }
1802 
1803  // get slider position
1804  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);
1805  }
1806 
1808 }
1809 
1811 {
1812 }
1813 
1815 {
1816  HC_current_file = -1;
1817 
1818  // get a list of all hcf files
1819  memset(HC_filenames, 0, sizeof(char*) * MAX_HCF_FILES);
1821 }
1822 
1824 {
1825  int idx;
1826 
1827  // free all
1828  for(idx=0; idx<HC_num_files; idx++){
1829  if(HC_filenames[idx] != NULL){
1830  vm_free(HC_filenames[idx]);
1831  HC_filenames[idx] = NULL;
1832  }
1833  }
1834 }
1835 
1837 {
1838  int r, g, b, a;
1839 
1840  // if we're turning off
1841  if(!toggle){
1842  // determine if on/off/popup buttons should be shown
1844 
1845  HC_select_all = 0;
1846  } else {
1847  // synch stuff up
1849 
1850  // if we had a gauge previously selected, use its color everywhere
1851  if(HC_gauge_selected < 0){
1852  r = HUD_config.clr[HUD_RADAR].red;
1853  g = HUD_config.clr[HUD_RADAR].green;
1854  b = HUD_config.clr[HUD_RADAR].blue;
1855  a = HUD_config.clr[HUD_RADAR].alpha;
1856  } else {
1857  r = HUD_config.clr[HC_gauge_selected].red;
1858  g = HUD_config.clr[HC_gauge_selected].green;
1859  b = HUD_config.clr[HC_gauge_selected].blue;
1860  a = HUD_config.clr[HC_gauge_selected].alpha;
1861  }
1862  hud_config_stuff_colors(r, g, b);
1863 
1864  // no gauge selected
1865  HC_gauge_selected = -1;
1866 
1867  // enable all sliders
1868  HC_color_sliders[HCS_RED].enable();
1869  HC_color_sliders[HCS_GREEN].enable();
1870  HC_color_sliders[HCS_BLUE].enable();
1871  HC_color_sliders[HCS_ALPHA].enable();
1872  HC_color_sliders[HCS_RED].unhide();
1873  HC_color_sliders[HCS_GREEN].unhide();
1874  HC_color_sliders[HCS_BLUE].unhide();
1875  HC_color_sliders[HCS_ALPHA].unhide();
1876  HC_color_sliders[HCS_RED].force_currentItem( HCS_CONV(r) );
1877  HC_color_sliders[HCS_GREEN].force_currentItem( HCS_CONV(g) );
1878  HC_color_sliders[HCS_BLUE].force_currentItem( HCS_CONV(b) );
1879  HC_color_sliders[HCS_ALPHA].force_currentItem( HCS_CONV(a) );
1880 
1881  // recalc alpha
1883 
1884  // disable all three buttons
1888 
1889  HC_select_all = 1;
1890  }
1891 }
void hud_config_popup_flag_clear(int i)
Definition: hudconfig.cpp:844
void set_text(const char *in)
Definition: inputbox.cpp:490
int HUD_config_default_flags2
Definition: hudconfig.cpp:172
#define MAX_FILENAME_LEN
Definition: pstypes.h:324
void set_highlight_action(void(*_user_function)(void))
Definition: button.cpp:375
void hud_config_blue_slider()
Definition: hudconfig.cpp:1786
#define HCS_RED
Definition: hudconfig.cpp:652
#define HCB_ON
Definition: hudconfig.cpp:457
#define CFILE_NORMAL
Definition: cfile.h:89
int i
Definition: multi_pxo.cpp:466
#define vm_free(ptr)
Definition: pstypes.h:548
UI_XSTR HC_text[GR_NUM_RESOLUTIONS][NUM_HUD_TEXT]
Definition: hudconfig.cpp:520
#define HUD_OFFSCREEN_INDICATOR
Definition: hudgauges.h:42
char * HC_slider_fname[GR_NUM_RESOLUTIONS]
Definition: hudconfig.cpp:673
void add_XSTR(char *string, int _xstr_id, int _x, int _y, UI_GADGET *_assoc, int _color_type, int _font_id=-1)
Definition: window.cpp:476
int button_hilighted()
Definition: button.cpp:387
int HUD_color_alpha
Definition: hud.cpp:76
#define HCB_RED_DOWN
Definition: hudconfig.cpp:453
#define HUD_TARGET_SHIELD_ICON
Definition: hudgauges.h:29
int hud_config_show_flag_is_set(int i)
Definition: hudconfig.cpp:791
#define MIN(a, b)
Definition: pstypes.h:296
#define HCB_GREEN_DOWN
Definition: hudconfig.cpp:454
reset (or similar button) pressed
Definition: gamesnd.h:306
int HUD_observer_default_flags2
Definition: hudconfig.cpp:131
int HC_fname_coords[GR_NUM_RESOLUTIONS][4]
Definition: hudconfig.cpp:40
#define HUD_COLOR_ALPHA_DEFAULT
Definition: hud.h:74
#define HUD_HOSTILE_TRIANGLE
Definition: hudgauges.h:20
#define HUD_OFFSCREEN_RANGE
Definition: hudgauges.h:50
#define HUD_TALKING_HEAD
Definition: hudgauges.h:43
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
#define HUD_TARGET_TRIANGLE
Definition: hudgauges.h:21
void gr_flip()
Definition: 2d.cpp:2113
commit pressed
Definition: gamesnd.h:294
#define HUD_THREAT_GAUGE
Definition: hudgauges.h:37
int x
Definition: ui.h:658
float Radar_ranges[RR_MAX_RANGES]
Definition: hudconfig.cpp:96
#define CF_TYPE_PLAYERS
Definition: cfile.h:67
#define GR_RESIZE_MENU
Definition: 2d.h:684
#define HCB_SAVE_HCF
Definition: hudconfig.cpp:460
int HUD_color_green
Definition: hud.cpp:74
void hud_config_color_close()
Definition: hudconfig.cpp:1823
int y
Definition: ui.h:658
#define HCB_RESET
Definition: hudconfig.cpp:467
GLuint index
Definition: Glext.h:5608
void hud_config_draw_gauge_status()
Definition: hudconfig.cpp:1347
char * Hud_config_mask_fname[GR_NUM_RESOLUTIONS]
Definition: hudconfig.cpp:241
void HUD_init_hud_color_array()
Definition: hud.cpp:208
struct hc_col hc_col
virtual void unhide()
Definition: gadget.cpp:217
#define GR_NUM_RESOLUTIONS
Definition: 2d.h:651
#define mprintf(args)
Definition: pstypes.h:238
void gr_init_alphacolor(color *clr, int r, int g, int b, int alpha, int type)
Definition: 2d.cpp:1173
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:769
void hud_config_set_button_state()
Definition: hudconfig.cpp:1393
#define HUD_OBJECTIVES_NOTIFY_GAUGE
Definition: hudgauges.h:48
general failure sound for any event
Definition: gamesnd.h:297
Definition: 2d.h:95
int HC_slider_coords[GR_NUM_RESOLUTIONS][NUM_HC_SLIDERS][4]
Definition: hudconfig.cpp:657
int res
Definition: 2d.h:370
int max_h_unscaled
Definition: 2d.h:361
void hud_config_check_regions()
Definition: hudconfig.cpp:932
void hud_config_unload_gauges()
Definition: hudconfig.cpp:1522
void hud_config_red_slider()
Definition: hudconfig.cpp:1738
Definition: cfile.h:28
color clr[NUM_HUD_GAUGES]
Definition: hudconfig.h:60
#define GR_MAYBE_CLEAR_RES(bmap)
Definition: 2d.h:639
#define RP_DEFAULT
Definition: hudconfig.h:39
#define HUD_LEAD_INDICATOR
Definition: hudgauges.h:18
#define HUD_ATTACKING_TARGET_COUNT
Definition: hudgauges.h:52
#define HCB_ACCEPT
Definition: hudconfig.cpp:468
Definition: ai.h:329
virtual void hide(int n)
Definition: gadget.cpp:207
void gr_set_color_fast(color *dst)
Definition: 2d.cpp:1197
void hud_config_show_flag_clear(int i)
Definition: hudconfig.cpp:813
#define UI_INPUTBOX_FLAG_ESC_FOC
Definition: ui.h:38
ubyte blue
Definition: 2d.h:102
#define IFF_COLOR_TAGGED
Definition: iff_defs.h:21
Definition: ui.h:195
#define HUD_COLOR_GREEN
Definition: hudconfig.h:21
void hud_config_color_load(char *name)
Definition: hudconfig.cpp:1642
ubyte g
Definition: hudconfig.cpp:628
struct HC_gauge_region HC_gauge_regions[GR_NUM_RESOLUTIONS][NUM_HUD_GAUGES]
Definition: hudconfig.cpp:262
int HUD_default_popup_mask2
Definition: hudconfig.cpp:219
void hud_config_record_color(int in_color)
Definition: hudconfig.cpp:1002
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
Definition: 2d.cpp:2105
#define HUD_DIRECTIVES_VIEW
Definition: hudgauges.h:36
int max_w_unscaled
Definition: 2d.h:361
#define Int3()
Definition: pstypes.h:292
void hud_config_popup_flag_set(int i)
Definition: hudconfig.cpp:835
#define HCB_PREV_HCF
Definition: hudconfig.cpp:461
ship * shipp
Definition: lua.cpp:9162
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
Definition: bmpman.cpp:2603
const char * Radar_range_text(int n)
Definition: hudconfig.cpp:102
void hud_config_do_frame(float frametime)
Definition: hudconfig.cpp:1467
char * HC_filenames[MAX_HCF_FILES]
Definition: hudconfig.cpp:36
#define HUD_DAMAGE_GAUGE
Definition: hudgauges.h:44
#define HCB_I_UP
Definition: hudconfig.cpp:452
void hud_config_render_description()
Definition: hudconfig.cpp:1414
#define HUD_LAG_GAUGE
Definition: hudgauges.h:56
ubyte green
Definition: 2d.h:101
#define HCB_BLUE
Definition: hudconfig.cpp:464
#define HCB_I_DOWN
Definition: hudconfig.cpp:456
#define HCB_BLUE_DOWN
Definition: hudconfig.cpp:455
void draw_forced(int frame_num)
Definition: button.cpp:104
#define HUD_TARGET_MONITOR
Definition: hudgauges.h:26
void destroy()
Definition: window.cpp:189
#define NUM_HUD_BUTTONS
Definition: hudconfig.cpp:447
ui_button_info HC_buttons[GR_NUM_RESOLUTIONS][NUM_HUD_BUTTONS]
Definition: hudconfig.cpp:471
void set_mask_bmap(char *fname)
Definition: window.cpp:75
int set_bmaps(char *ani_filename, int nframes=3, int start_frame=1)
Definition: gadget.cpp:71
int HC_select_all
Definition: hudconfig.cpp:229
Definition: player.h:85
GLdouble GLdouble GLdouble r
Definition: Glext.h:5337
void hud_config_set_gauge_flags(int gauge_index, int on_flag, int popup_flag)
Definition: hudconfig.cpp:987
#define HCS_GREEN
Definition: hudconfig.cpp:653
#define HUD_TARGET_MINI_ICON
Definition: hudgauges.h:41
#define HUD_KILLS_GAUGE
Definition: hudgauges.h:51
void hud_set_default_hud_config(player *p)
Definition: hudconfig.cpp:1552
#define HUD_MESSAGE_LINES
Definition: hudgauges.h:45
GLboolean GLboolean g
Definition: Glext.h:5781
#define cfopen(...)
Definition: cfile.h:134
int get_currentItem()
Definition: slider2.cpp:212
#define HUD_AFTERBURNER_ENERGY
Definition: hudgauges.h:38
#define HUD_TEXT_FLASH
Definition: hudgauges.h:53
GLboolean GLboolean GLboolean GLboolean a
Definition: Glext.h:5781
void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numberItems, char *_bitmapSliderControl, void(*_upCallback)(), void(*_downCallback)(), void(*_captureCallback)())
Definition: slider2.cpp:21
void hud_config_green_slider()
Definition: hudconfig.cpp:1762
const char * HC_gauge_descriptions(int n)
Definition: hudconfig.cpp:362
void hud_config_synch_ui()
Definition: hudconfig.cpp:690
int hotspot
Definition: ui.h:659
void hud_config_draw_color_status()
Definition: hudconfig.cpp:1327
void hud_config_render_special_bitmaps()
Definition: hudconfig.cpp:1428
int pressed()
Definition: button.cpp:325
void stuff_string(char *outstr, int type, int len, char *terminators)
Definition: parselo.cpp:1189
#define HUD_SUPPORT_GAUGE
Definition: hudgauges.h:55
#define w(p)
Definition: modelsinc.h:68
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
UI_SLIDER2 HC_color_sliders[NUM_HC_SLIDERS]
Definition: hudconfig.cpp:656
UI_BUTTON button
Definition: hudconfig.cpp:256
#define KEY_ENTER
Definition: key.h:125
#define HUD_RETICLE_CIRCLE
Definition: hudgauges.h:23
ubyte red
Definition: 2d.h:100
#define vm_strdup(ptr)
Definition: pstypes.h:549
#define HUD_MISSILE_WARNING_ARROW
Definition: hudgauges.h:46
#define NUM_HUD_GAUGES
Definition: hudgauges.h:16
int required_string(const char *pstr)
Definition: parselo.cpp:468
#define HUD_WEAPONS_ENERGY
Definition: hudgauges.h:39
int hud_config_popup_flag_is_set(int i)
Definition: hudconfig.cpp:822
Definition: ui.h:428
int optional_string(const char *pstr)
Definition: parselo.cpp:539
void hud_config_set_rgb(int gauge, int r, int g, int b)
#define RR_MAX_RANGES
Definition: hudconfig.h:28
UI_BUTTON button
Definition: ui.h:660
void hud_config_backup()
Definition: hudconfig.cpp:1590
void hud_config_init()
Definition: hudconfig.cpp:924
#define HUD_MESSAGE_BOX
Definition: hudgauges.h:54
void hud_config_init_ui()
Definition: hudconfig.cpp:700
Definition: ship.h:534
void hud_config_alpha_slider_down()
Definition: hudconfig.cpp:1707
void read_file_text(const char *filename, int mode, char *processed_text, char *raw_text)
Definition: parselo.cpp:1995
void hud_cycle_gauge_status()
Definition: hudconfig.cpp:1050
int idx
Definition: multiui.cpp:761
#define HCB_POPUP
Definition: hudconfig.cpp:459
void hud_config_commit()
Definition: hudconfig.cpp:1043
void hud_config_close()
Definition: hudconfig.cpp:1541
ubyte alpha
Definition: 2d.h:103
GLclampd n
Definition: Glext.h:7286
unsigned char ubyte
Definition: pstypes.h:62
const char * XSTR(const char *str, int index)
Definition: localize.cpp:851
void hud_config_as_observer(ship *shipp, ai_info *aif)
Definition: hudconfig.cpp:1595
void hud_config_button_do(int n)
Definition: hudconfig.cpp:1094
void hud_config_redraw_pressed_buttons()
Definition: hudconfig.cpp:1451
user_click (mouse selects a control)
Definition: gamesnd.h:305
void force_currentItem(int _currentItem)
Definition: slider2.cpp:279
color Color_bright_red
Definition: alphacolors.cpp:34
#define NOX(s)
Definition: pstypes.h:473
void hud_config_check_buttons()
Definition: hudconfig.cpp:1313
int HC_gauge_description_coords[GR_NUM_RESOLUTIONS][3]
Definition: hudconfig.cpp:353
void hud_config_handle_keypresses(int k)
Definition: hudconfig.cpp:1077
#define HUD_AUTO_TARGET
Definition: hudgauges.h:32
void reset_parse(char *text)
Definition: parselo.cpp:3305
GLuint const GLchar * name
Definition: Glext.h:5608
void hud_config_set_alpha(int gauge, int a)
#define HCB_GREEN
Definition: hudconfig.cpp:465
#define HUD_WINGMEN_STATUS
Definition: hudgauges.h:49
#define HUD_ORIENTATION_TEE
Definition: hudgauges.h:19
char * cf_add_ext(const char *filename, const char *ext)
Definition: cfile.cpp:458
color * iff_get_color(int color_index, int is_bright)
Definition: iff_defs.cpp:636
#define HUD_PLAYER_SHIELD_ICON
Definition: hudgauges.h:30
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
Definition: bmpman.cpp:1119
GLboolean GLboolean GLboolean b
Definition: Glext.h:5781
ubyte b
Definition: hudconfig.cpp:628
#define HCB_OFF
Definition: hudconfig.cpp:458
void hud_config_color_save(char *name)
Definition: hudconfig.cpp:1616
HC_gauge_region(char *name, int x1, int y1, int h, int iff, int cp, int b, int nf, int cl)
Definition: hudconfig.cpp:258
ubyte num_msg_window_lines
Definition: hudconfig.h:57
UI_INPUTBOX HC_fname_input
Definition: hudconfig.cpp:39
#define HCS_BLUE
Definition: hudconfig.cpp:654
void hud_observer_init(ship *shipp, ai_info *aip)
Definition: hudobserver.cpp:26
void link_hotspot(int num)
Definition: gadget.cpp:50
int cfputs(const char *str, CFILE *cfile)
Definition: cfile.cpp:1504
void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus=0)
Definition: button.cpp:26
#define KEY_ESC
Definition: key.h:124
#define NAME_LENGTH
Definition: globals.h:15
#define UI_XSTR_COLOR_PINK
Definition: ui.h:161
int button_down()
Definition: button.cpp:363
void hud_config_as_player()
Definition: hudconfig.cpp:1608
#define fl2i(fl)
Definition: floating.h:33
void hud_config_stuff_colors(int r, int g, int b)
Definition: hudconfig.cpp:1025
void hud_config_process_colors()
Definition: hudconfig.cpp:1810
void hud_config_synch_sliders(int i)
Definition: hudconfig.cpp:679
void create(int _x, int _y, int _w, int _h, int _flags, int _f_id=-1)
Definition: window.cpp:140
int HUD_color_red
Definition: hud.cpp:73
int HC_num_files
Definition: hudconfig.cpp:34
player * Player
Definition: ui.h:584
void hud_config_restore()
Definition: hudconfig.cpp:1582
#define HUD_WEAPONS_GAUGE
Definition: hudgauges.h:34
screen gr_screen
Definition: 2d.cpp:46
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
Definition: font.cpp:196
#define CF_SORT_NAME
Definition: cfile.h:93
Definition: ui.h:162
#define HCS_ALPHA
Definition: hudconfig.cpp:655
int HUD_default_popup_mask
Definition: hudconfig.cpp:184
void hud_config_color_init()
Definition: hudconfig.cpp:1814
void enable(int n=1)
Definition: gadget.cpp:440
#define HCB_GREEN_UP
Definition: hudconfig.cpp:450
GLfloat GLfloat p
Definition: Glext.h:8373
HUD_CONFIG_TYPE HUD_config
Definition: hudconfig.cpp:49
#define F_NAME
Definition: parselo.h:34
void common_play_highlight_sound()
Definition: gamesnd.cpp:1151
__inline void gr_aabitmap(int x, int y, int resize_mode=GR_RESIZE_FULL, bool mirror=false)
Definition: 2d.h:750
void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _textlen, char *_text, int _flags=0, int pixel_lim=-1, color *clr=NULL)
Definition: inputbox.cpp:101
#define NUM_HUD_TEXT
Definition: hudconfig.cpp:519
ubyte r
Definition: hudconfig.cpp:628
int HUD_observer_default_flags
Definition: hudconfig.cpp:120
#define NUM_HC_SLIDERS
Definition: hudconfig.cpp:651
hc_col HC_colors[3]
Definition: hudconfig.cpp:631
#define UI_INPUTBOX_FLAG_INVIS
Definition: ui.h:35
#define HUD_RADAR
Definition: hudgauges.h:25
#define HCB_RED_UP
Definition: hudconfig.cpp:449
hull_check pos
Definition: lua.cpp:5050
int HUD_config_default_flags
Definition: hudconfig.cpp:136
#define MAX_HCF_FILES
Definition: hudconfig.cpp:33
void hud_config_button_enable(int index)
Definition: hudconfig.cpp:1386
float HUD_offset_x
Definition: hud.cpp:90
#define KEY_CTRLED
Definition: key.h:64
color Color_normal
Definition: alphacolors.cpp:28
#define HCB_BLUE_UP
Definition: hudconfig.cpp:451
#define KEY_TAB
Definition: key.h:127
#define HCS_CONV(__v)
Definition: hudconfig.cpp:671
char * filename
Definition: ui.h:657
#define HCB_AMBER
Definition: hudconfig.cpp:463
#define HCB_SELECT_ALL
Definition: hudconfig.cpp:466
void hud_config_recalc_alpha_slider()
Definition: hudconfig.cpp:1731
void get_text(char *out)
Definition: inputbox.cpp:484
void hud_config_render_gauges()
Definition: hudconfig.cpp:854
#define HUD_TARGET_MONITOR_EXTRA_DATA
Definition: hudgauges.h:28
void gr_bitmap(int _x, int _y, int resize_mode)
Definition: 2d.cpp:1303
#define UI_XSTR_COLOR_GREEN
Definition: ui.h:160
void hud_config_set_color(int in_color)
Definition: hudconfig.cpp:1011
#define HUD_WEAPON_LINKING_GAUGE
Definition: hudgauges.h:40
void stuff_ubyte(ubyte *i)
Definition: parselo.cpp:2646
char HC_fname[MAX_FILENAME_LEN+1]
Definition: hudconfig.cpp:38
char Hud_Gauge_Names[NUM_HUD_GAUGES][NAME_LENGTH]
Definition: hudconfig.cpp:51
#define MAX(a, b)
Definition: pstypes.h:299
float HUD_offset_y
Definition: hud.cpp:91
#define HUD_COLOR_BLUE
Definition: hudconfig.h:22
#define HUD_CENTER_RETICLE
Definition: hudgauges.h:27
void gamesnd_play_iface(int n)
Definition: gamesnd.cpp:260
#define HUD_THROTTLE_GAUGE
Definition: hudgauges.h:24
int cfclose(CFILE *cfile)
Definition: cfile.cpp:895
void disable()
Definition: gadget.cpp:432
void draw()
Definition: window.cpp:220
struct ui_button_info ui_button_info
GLclampf GLclampf GLclampf alpha
Definition: Glext.h:5177
void hud_config_update_brightness()
Definition: hudconfig.cpp:1442
#define HUD_CMEASURE_GAUGE
Definition: hudgauges.h:47
#define HCB_NEXT_HCF
Definition: hudconfig.cpp:462
void hud_config_button_disable(int index)
Definition: hudconfig.cpp:1379
#define HUD_AUTO_SPEED
Definition: hudgauges.h:33
int cf_get_file_list(SCP_vector< SCP_string > &list, int pathtype, const char *filter, int sort=CF_SORT_NONE, SCP_vector< file_list_info > *info=NULL)
int process(int key_in=-1, int process_mouse=1)
Definition: window.cpp:401
void hud_config_show_flag_set(int i)
Definition: hudconfig.cpp:804
#define HUD_MISSION_TIME
Definition: hudgauges.h:22
#define RR_INFINITY
Definition: hudconfig.h:31
#define HUD_ESCORT_VIEW
Definition: hudgauges.h:35
void gameseq_post_event(int event)
#define stricmp(s1, s2)
Definition: config.h:271
char * Hud_config_fname[GR_NUM_RESOLUTIONS]
Definition: hudconfig.cpp:236
int HC_current_file
Definition: hudconfig.cpp:35
#define HUD_COLOR_AMBER
Definition: hudconfig.h:23
void hud_config_alpha_slider_up()
Definition: hudconfig.cpp:1683
#define HUD_ETS_GAUGE
Definition: hudgauges.h:31
void hud_config_cancel()
Definition: hudconfig.cpp:1036
#define strcpy_s(...)
Definition: safe_strings.h:67
void hud_config_select_all_toggle(int toggle)
Definition: hudconfig.cpp:1836
int HUD_color_blue
Definition: hud.cpp:75