| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/hud.h $ |
| 21 | * $Revision: 67 $ |
| 22 | * $Date: 7/13/99 12:22a $ |
| 23 | * $Author: Jeff $ |
| 24 | * |
| 25 | * <hud.h> |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/hud.h $ |
| 28 | * |
| 29 | * 67 7/13/99 12:22a Jeff |
| 30 | * correctly externed HudInputMessage, increased size for new tokenized |
| 31 | * text macros |
| 32 | * |
| 33 | * 66 5/21/99 11:15p Samir |
| 34 | * savegames save hud timer and special text states. restore too. |
| 35 | * |
| 36 | * 65 5/21/99 4:06p Matt |
| 37 | * For customtext2 HUD items, store the buffer length in the HUD item. |
| 38 | * |
| 39 | * 64 5/21/99 2:58p Matt |
| 40 | * Fixed mis-defined flag that caused the multiplayer menus to not render. |
| 41 | * |
| 42 | * 63 5/20/99 5:48p Matt |
| 43 | * Added a HUD item flag, for use by Dallas-created items, that makes a |
| 44 | * HUD item persisitent for the duration of one level, but get cleared |
| 45 | * between levels. |
| 46 | * |
| 47 | * 62 5/19/99 11:25a Matt |
| 48 | * Added multisafe functions & Dallas actions for showing a timer on the |
| 49 | * screen and adding custom HUD messages. |
| 50 | * |
| 51 | * 61 5/17/99 6:22p Jeff |
| 52 | * added filtered HUD messages |
| 53 | * |
| 54 | * 60 5/08/99 1:04a Samir |
| 55 | * added timers for key presses in message list boxes. |
| 56 | * |
| 57 | * 59 5/07/99 10:48p Matt |
| 58 | * Made add-HUD functions return true if the message was added, and false |
| 59 | * if it wasn't (because the previous message was the same). |
| 60 | * |
| 61 | * 58 4/28/99 2:14a Samir |
| 62 | * save and load Game messages in savegame. |
| 63 | * |
| 64 | * 57 4/24/99 8:43p Samir |
| 65 | * when shrinking screen hud messages get rendered in black region. |
| 66 | * |
| 67 | * 56 4/06/99 11:39a Samir |
| 68 | * added more formatting options for hud items (added two other full |
| 69 | * screen hud infs for different ships) |
| 70 | * |
| 71 | * 55 3/30/99 2:39p Samir |
| 72 | * added custom config file for fullscreen hud and hacked mass driver |
| 73 | * reticle in special reticle code. |
| 74 | * |
| 75 | * 54 3/26/99 12:46p Samir |
| 76 | * configurable reticle. |
| 77 | * |
| 78 | * 53 3/04/99 7:39p Matt |
| 79 | * Added sound effects to FreeSpace-style persistent HUD messages. |
| 80 | * |
| 81 | * 52 3/03/99 5:34p Matt |
| 82 | * Added fade-out for goal complete messages |
| 83 | * |
| 84 | * 51 2/19/99 2:18p Samir |
| 85 | * AddGameMessage implicitly figures out time and level of message. |
| 86 | * |
| 87 | * 50 2/18/99 5:27p Matt |
| 88 | * Added color parm to AddPersistentHUDMessage() and fixed the timeout. |
| 89 | * |
| 90 | * 49 2/16/99 6:15p Jeff |
| 91 | * pause hud messages when in cinematics |
| 92 | * |
| 93 | * 48 2/06/99 6:59p Jeff |
| 94 | * created RenderHUDGetTextLineWidth and RenderHUDGetTextHeight |
| 95 | * |
| 96 | * 47 1/31/99 7:26p Matt |
| 97 | * Renamed a bunch of functions to have HUD capitalized |
| 98 | * |
| 99 | * 46 1/29/99 6:29p Samir |
| 100 | * implemented hud scrollback for hud messages. |
| 101 | * |
| 102 | * 45 1/27/99 6:05p Samir |
| 103 | * added scrollback for game messages on HUD. |
| 104 | * |
| 105 | * 44 1/23/99 2:33p Kevin |
| 106 | * Increased hud message length, because we clip to the real width of the |
| 107 | * hud. Also fixed up the multiline code a bit |
| 108 | * |
| 109 | * 43 1/22/99 4:06p Jeff |
| 110 | * added hud messages that can be sent to just teammates or individual |
| 111 | * people |
| 112 | * |
| 113 | * 42 1/11/99 4:08p Jason |
| 114 | * added multiplayer taunt macros |
| 115 | * |
| 116 | * 41 10/22/98 2:40p Samir |
| 117 | * redid HUD sequencing so multiplayer hud stuff works. |
| 118 | * |
| 119 | * 40 10/19/98 11:22p Samir |
| 120 | * added hud observer mode and fixed problems with hud switching and |
| 121 | * screen size. |
| 122 | * |
| 123 | * 39 10/14/98 4:26p Samir |
| 124 | * added persistent hud messages. |
| 125 | * |
| 126 | * 38 10/05/98 11:08a Jason |
| 127 | * implemented player message log |
| 128 | * |
| 129 | * 37 9/08/98 10:28a Samir |
| 130 | * added function to reset hud messages. |
| 131 | * |
| 132 | * 36 8/15/98 10:51p Matt |
| 133 | * Added function ToggleHUDMode(), and made StartHudInputMessage() public. |
| 134 | * |
| 135 | * 35 7/28/98 3:17p Jason |
| 136 | * fixed buffer overrun problem |
| 137 | * |
| 138 | * 34 7/06/98 7:34p Samir |
| 139 | * added countermeasures. |
| 140 | * |
| 141 | * 33 6/24/98 7:38p Samir |
| 142 | * redid graphical/text/cockpit hud item management. |
| 143 | * |
| 144 | * 32 6/17/98 6:31p Samir |
| 145 | * Added anti-grav warning when dying. |
| 146 | * |
| 147 | * 31 6/15/98 6:54p Samir |
| 148 | * added invulnerability and cloak effect. |
| 149 | * |
| 150 | * 30 6/15/98 2:14p Samir |
| 151 | * afterburner hud image scale modified. |
| 152 | * |
| 153 | * 29 5/26/98 5:05p Samir |
| 154 | * cockpit and hud config file now 'unified'. cockpit adds to hudconfig |
| 155 | * load's funtionality, so cockpit info files can contain same syntax as |
| 156 | * hud file. |
| 157 | * |
| 158 | * 28 5/25/98 8:30p Samir |
| 159 | * guided missile reticle and added a hud timer. |
| 160 | * |
| 161 | * 27 5/22/98 6:25p Samir |
| 162 | * implemented a lot of hud items. |
| 163 | * |
| 164 | * 26 5/07/98 6:01p Samir |
| 165 | * allow for certain hud items to not be resettable. |
| 166 | * |
| 167 | * 25 5/07/98 12:23p Samir |
| 168 | * RenderHudText functions added to hud.h |
| 169 | * |
| 170 | * 24 5/06/98 4:33p Samir |
| 171 | * added fixed screen width and height to grdefs.h (default res.) |
| 172 | * |
| 173 | * 23 5/05/98 6:27p Samir |
| 174 | * added hud aspect ratio values and reticle is scaled correctly. |
| 175 | * |
| 176 | * 22 4/28/98 4:26p Samir |
| 177 | * brightened hud., |
| 178 | * |
| 179 | * 21 4/24/98 5:32p Samir |
| 180 | * added reset reticle function. |
| 181 | * |
| 182 | * 20 4/24/98 8:01a Samir |
| 183 | * don't pass zoom argument to Render functions. |
| 184 | * |
| 185 | * 19 4/23/98 4:13a Samir |
| 186 | * new hud system. |
| 187 | * |
| 188 | * 18 4/14/98 9:19p Samir |
| 189 | * made hacked good looking reticle for mag demo. |
| 190 | * |
| 191 | * 17 4/13/98 7:02p Samir |
| 192 | * beginning reticle code. |
| 193 | * |
| 194 | * 16 3/25/98 11:59a Samir |
| 195 | * implemented energy analog fully. |
| 196 | * |
| 197 | * 15 3/23/98 5:36p Jason |
| 198 | * changed number of hud messages displayed at once |
| 199 | * |
| 200 | * 14 3/23/98 4:51p Jason |
| 201 | * incremental checkin for multiplay |
| 202 | * |
| 203 | * 13 3/20/98 8:23p Samir |
| 204 | * new hud and cockpit customization system. |
| 205 | * |
| 206 | * 12 3/19/98 9:19p Samir |
| 207 | * created a hud item type. |
| 208 | * |
| 209 | * 11 3/18/98 6:25p Samir |
| 210 | * Added new STAT_ constants/ |
| 211 | * |
| 212 | * 10 3/17/98 2:37p Samir |
| 213 | * reorg of hud/gauge/cockpit dependencies. |
| 214 | * |
| 215 | * 9 3/16/98 3:53p Jason |
| 216 | * added hud input message stuff |
| 217 | * |
| 218 | * 8 3/16/98 3:30p Samir |
| 219 | * incremental checkin. |
| 220 | * |
| 221 | * 7 3/13/98 12:09p Samir |
| 222 | * made changes to reflect new cockpit.cpp and cockpit.h |
| 223 | * |
| 224 | * 6 12/29/97 5:44p Samir |
| 225 | * Took out references to grViewport and old 2d library. |
| 226 | * |
| 227 | * 5 11/11/97 1:26p Samir |
| 228 | * Added function to modify a hud gauge and initialized some gauges for |
| 229 | * first cockpit. |
| 230 | * |
| 231 | * 4 11/04/97 6:23p Samir |
| 232 | * Lighting cockpit, initializes gauges. |
| 233 | * |
| 234 | * 3 10/28/97 6:37p Samir |
| 235 | * 3d Cockpit draws, bad lighting and no gauges. |
| 236 | * |
| 237 | * 5 5/14/97 11:29a Jason |
| 238 | * added energy and shield gauges to hud |
| 239 | * |
| 240 | * 4 3/05/97 3:03p Jason |
| 241 | * added blinking messages |
| 242 | * |
| 243 | * 3 3/04/97 12:58p Jason |
| 244 | * made hud messages scroll and fade |
| 245 | * |
| 246 | * 2 2/13/97 4:12p Jason |
| 247 | * added hud message test |
| 248 | * |
| 249 | * $NoKeywords: $ |
| 250 | */ |
| 251 | |
| 252 | #ifndef HUD_H |
| 253 | #define HUD_H |
| 254 | |
| 255 | #include "pstypes.h" |
| 256 | #include "grdefs.h" |
| 257 | |
| 258 | #define MAX_HUD_MESSAGES 3 |
| 259 | #define HUD_MESSAGE_LENGTH 200 |
| 260 | #define HUD_TEXT_LENGTH 32 |
| 261 | #define DEFAULT_HUD_WIDTH (float)FIXED_SCREEN_WIDTH |
| 262 | #define DEFAULT_HUD_HEIGHT (float)FIXED_SCREEN_HEIGHT |
| 263 | |
| 264 | struct object; |
| 265 | struct poly_model; |
| 266 | struct bsp_info; |
| 267 | struct g3Point; |
| 268 | |
| 269 | // type to pass to functions that draw stats |
| 270 | typedef uint16_t tStatMask; |
| 271 | |
| 272 | struct CFILE; |
| 273 | |
| 274 | // hud (or gauge) stat flag. |
| 275 | #define STAT_FPS 0x0001 |
| 276 | #define STAT_SHIELDS 0x0002 |
| 277 | #define STAT_ENERGY 0x0004 |
| 278 | #define STAT_PRIMARYLOAD 0x0008 |
| 279 | #define STAT_SECONDARYLOAD 0x0010 |
| 280 | #define STAT_MESSAGES 0x0020 |
| 281 | #define STAT_INVENTORY 0x0040 |
| 282 | #define STAT_SHIP 0x0080 |
| 283 | #define STAT_AFTERBURN 0x0100 |
| 284 | #define STAT_WARNING 0x0200 |
| 285 | #define STAT_GOALS 0x0400 |
| 286 | #define STAT_TIMER 0x0800 |
| 287 | #define STAT_CUSTOM 0x1000 |
| 288 | #define STAT_CNTRMEASURE 0x2000 |
| 289 | #define STAT_STANDARD 0x3ffe |
| 290 | #define STAT_ALL 0x3fff |
| 291 | |
| 292 | // is this the special version? (defined by huddisplay.cpp or user equiv.) |
| 293 | #define STAT_SPECIAL 0x4000 |
| 294 | // is this the graphical version? |
| 295 | #define STAT_GRAPHICAL 0x8000 |
| 296 | |
| 297 | // hud modes |
| 298 | enum tHUDMode { |
| 299 | |
| 300 | HUD_FULLSCREEN, |
| 301 | HUD_LETTERBOX, |
| 302 | HUD_COCKPIT, |
| 303 | HUD_OBSERVER |
| 304 | }; |
| 305 | |
| 306 | #define MAX_HUD_ITEMS 32 |
| 307 | #define HUD_COLOR GR_RGB(0, 255, 0) |
| 308 | #define HUD_ALPHA 192 |
| 309 | #define HUD_ZOOM 0.56f |
| 310 | |
| 311 | #define HUD_MSG_PERSISTENT_INFINITE 10000.0f |
| 312 | #define HUD_MSG_PERSISTENT_CENTER -1 |
| 313 | |
| 314 | ///////////////////////////////////////////////////////////////////////////////// |
| 315 | |
| 316 | // Max characters in a hud input message |
| 317 | #define MAX_HUD_INPUT_LEN 80 |
| 318 | |
| 319 | extern char HudInputMessage[MAX_HUD_INPUT_LEN]; |
| 320 | extern int HudInputMessageLen; |
| 321 | |
| 322 | extern char Hud_messages[MAX_HUD_MESSAGES][HUD_MESSAGE_LENGTH]; |
| 323 | extern int Num_hud_messages; |
| 324 | |
| 325 | // Whether or not we're in a input message frame |
| 326 | extern int Doing_input_message; |
| 327 | |
| 328 | // determines what's displayable on the hud |
| 329 | extern tStatMask Hud_stat_mask; |
| 330 | |
| 331 | // hud aspect ratio |
| 332 | extern float Hud_aspect_x; |
| 333 | extern float Hud_aspect_y; |
| 334 | |
| 335 | extern bool Hud_show_controls; |
| 336 | |
| 337 | // normalize hud coordinates |
| 338 | #define HUD_X(_x) ((float)(_x) * Hud_aspect_x) |
| 339 | #define HUD_Y(_y) ((float)(_y) * Hud_aspect_y) |
| 340 | |
| 341 | // number of shield frames in gauge |
| 342 | #define NUM_SHIELD_GAUGE_FRAMES 5 |
| 343 | #define SHIELD_GAUGE_FRAME_FULL 0 |
| 344 | #define SHIELD_GAUGE_FRAME_PARTIAL 1 |
| 345 | #define SHIELD_GAUGE_FRAME_HALF 2 |
| 346 | #define SHIELD_GAUGE_FRAME_SERIOUS 3 |
| 347 | #define SHIELD_GAUGE_FRAME_CRITICAL 4 |
| 348 | |
| 349 | ///////////////////////////////////////////////////////////////////////////////// |
| 350 | |
| 351 | // Adds a message to the HUD message list. If the list is already full, punt the |
| 352 | // top one and move the others up |
| 353 | // Returns true if message added, or false if message not (because the previous message was the same) |
| 354 | bool AddHUDMessage(const char *format, ...); |
| 355 | bool AddBlinkingHUDMessage(const char *format, ...); |
| 356 | |
| 357 | // Adds a HUD message (similar to AddHUDMessage), however can be filtered out by |
| 358 | // a "-playermessages" command line. |
| 359 | bool AddFilteredHUDMessage(const char *format, ...); |
| 360 | |
| 361 | // initializes other hud stuff |
| 362 | void SetHUDEnergyImage(const char *energy_img); |
| 363 | void SetHUDAfterburnImage(const char *afterburn_img); |
| 364 | |
| 365 | // Renders all the messages we have in the message list. If HUD_MESSAGE_TIME has |
| 366 | // elapsed, then punt the oldest message and move the others up one |
| 367 | void RenderHUDMessages(); |
| 368 | |
| 369 | // renders ship stats |
| 370 | void RenderHUDStats(tStatMask stat_mask); |
| 371 | |
| 372 | // Handles all incoming keys for an inputted hud message |
| 373 | void DoHUDInputMessageKey(int key); |
| 374 | |
| 375 | // Called when the player hit the Multiplayer message key. |
| 376 | // Puts the player in input mode, or if already inputting resets the hud input message. |
| 377 | void StartHUDInputMessage(); |
| 378 | |
| 379 | // Called when the player hits the Multiplayer team-message key. |
| 380 | // Puts the player in input mode, or if already inputting resets the hud input message. |
| 381 | void StartTeamHUDInputMessage(); |
| 382 | |
| 383 | // Adds a colored message to the hud |
| 384 | // Returns true if message added, or false if message not (because the previous message was the same) |
| 385 | bool AddColoredHUDMessage(ddgr_color color, const char *format, ...); |
| 386 | |
| 387 | // Adds a HUD message (similar to AddColoredHUDMessage), however can be filtered out by |
| 388 | // a "-playermessages" command line. |
| 389 | bool AddFilteredColoredHUDMessage(ddgr_color color, const char *format, ...); |
| 390 | |
| 391 | // Initializes Reticle on Hud. Usually called when weapon changes. |
| 392 | void InitReticle(int primary_slots, int secondary_slots); |
| 393 | |
| 394 | // resets reticle to current weapon. |
| 395 | void ResetReticle(); |
| 396 | |
| 397 | // frees up reticle bitmaps |
| 398 | void FreeReticle(); |
| 399 | |
| 400 | // Flags for persistent HUD messages |
| 401 | #define HPF_FADEOUT 1 // message fades out when done |
| 402 | #define HPF_FREESPACE_DRAW 2 // message draws with the FreeSpace briefing effect |
| 403 | |
| 404 | // adds a persistent hud message that is timed, or infinite until removed |
| 405 | // for infinite, time = HUD_MSG_PERSISTENT_INFINITE |
| 406 | // for centering on an axis,set either x or y to HUD_MSG_PERSISTENT_CENTER |
| 407 | void AddPersistentHUDMessage(ddgr_color color, int x, int y, float time, int flags, int sound_index, const char *fmt, |
| 408 | ...); |
| 409 | |
| 410 | // removes persistent hud message |
| 411 | void ResetPersistentHUDMessage(); |
| 412 | |
| 413 | // Given a hud message, it will determine who should get this message. |
| 414 | // "name: message" = the player with the callsign name should get the message |
| 415 | // "team: message" = the Player_num's team should get the message |
| 416 | // "0-32: message" = the player with player num of 0-32 should get the message |
| 417 | // all other messages are for everyone else |
| 418 | // |
| 419 | // returns the starting position of the real message (past the :) |
| 420 | // destination will receive one of the following values: |
| 421 | // MULTI_SEND_MESSAGE_ALL = everyone should get this message |
| 422 | // MULTI_SEND_MESSAGE_RED_TEAM = only red team (0) should get this message |
| 423 | // MULTI_SEND_MESSAGE_BLUE_TEAM = only blue team (1) should get this message |
| 424 | // MULTI_SEND_MESSAGE_GREEN_TEAM = only green team (2) should get this message |
| 425 | // MULTI_SEND_MESSAGE_YELLOW_TEAM = only yellow team (3) should get this message |
| 426 | // 0-32 = player num of the player to get the message |
| 427 | const char *GetMessageDestination(const char *message, int *destination); |
| 428 | |
| 429 | // HUD System |
| 430 | |
| 431 | // predefined types (tHUDItem::type) |
| 432 | #define HUD_ITEM_PRIMARY 1 |
| 433 | #define HUD_ITEM_SECONDARY 2 |
| 434 | #define HUD_ITEM_SHIELD 3 |
| 435 | #define HUD_ITEM_ENERGY 4 |
| 436 | #define HUD_ITEM_AFTERBURNER 5 |
| 437 | #define HUD_ITEM_INVENTORY 6 |
| 438 | #define HUD_ITEM_SHIPSTATUS 7 |
| 439 | #define HUD_ITEM_WARNINGS 8 |
| 440 | #define HUD_ITEM_GOALS 9 |
| 441 | #define HUD_ITEM_GOALSTATES 10 |
| 442 | #define HUD_ITEM_CNTRMEASURE 11 |
| 443 | #define HUD_ITEM_SCORE 12 |
| 444 | #define HUD_ITEM_CUSTOMTEXT 20 |
| 445 | #define HUD_ITEM_CUSTOMIMAGE 21 |
| 446 | #define HUD_ITEM_TIMER 22 |
| 447 | #define HUD_ITEM_CUSTOMTEXT2 23 // like custom text, keeps string pointer passed in |
| 448 | |
| 449 | #define HUD_FLAG_PERSISTANT 1 // this hud item will not be resetted. |
| 450 | #define HUD_FLAG_SMALL 2 // when small version of hud is rendered, this will render in the AUX frame |
| 451 | #define HUD_FLAG_LEVEL 4 // persistent for the current level, but cleared between levels |
| 452 | |
| 453 | #define HUD_INVALID_ID 255 // hud invalid id constant. |
| 454 | |
| 455 | struct t_dirty_rect { |
| 456 | struct { |
| 457 | int16_t l, t, r, b; |
| 458 | } r[3]; // three rectangles for each frame buffer (3 max) |
| 459 | |
| 460 | void set(int16_t l0, int16_t t0, int16_t r0, int16_t b0) { |
| 461 | r[0].l = l0; |
| 462 | r[0].t = t0; |
| 463 | r[0].r = r0; |
| 464 | r[0].b = b0; |
| 465 | }; |
| 466 | void reset(); |
| 467 | void fill(ddgr_color col); |
| 468 | }; // dirty rectangle for hud item (small hud version) |
| 469 | |
| 470 | struct tHUDItem { |
| 471 | int16_t x, y; |
| 472 | int16_t xa, ya; // auxillary points |
| 473 | int16_t xb, yb; |
| 474 | int16_t tx, ty; // text version x and y. |
| 475 | float grscalex, grscaley; // used to scale graphics. |
| 476 | |
| 477 | uint8_t id; // id number. |
| 478 | uint8_t type; // custom of predefined hud item type. |
| 479 | uint16_t stat; // stat mask (what class of hud items does this one belong to) |
| 480 | |
| 481 | uint16_t flags; // more flags. |
| 482 | uint8_t alpha; // alpha of hud item |
| 483 | uint8_t saturation_count; // how saturated is this hud item (how bright). |
| 484 | |
| 485 | ddgr_color color; // color of hud item. |
| 486 | ddgr_color tcolor; // text color of item. |
| 487 | |
| 488 | void (*render_fn)(struct tHUDItem *); // called by hud system to draw the hud item. |
| 489 | |
| 490 | int buffer_size; // for customtext2 item |
| 491 | |
| 492 | // data is initialized depending on 'type'. |
| 493 | // custom types must have either element of data already initialized. |
| 494 | // all predefined types can ignore this data field externally. |
| 495 | union { |
| 496 | int bm_handle; // custom images |
| 497 | int timer_handle; // timer |
| 498 | char *text; // custom text. |
| 499 | } data; |
| 500 | |
| 501 | t_dirty_rect dirty_rect; // used in small version of hud to clear only 'dirty' area |
| 502 | }; |
| 503 | |
| 504 | // hud resources |
| 505 | struct sHUDResources { |
| 506 | char hud_inf_name[PSFILENAME_LEN + 1]; |
| 507 | int arrow_bmp; |
| 508 | int goal_complete_bmp; |
| 509 | int goal_bmp; |
| 510 | int lock_bmp[2]; |
| 511 | int wpn_bmp; |
| 512 | int ship_bmp; |
| 513 | int energy_bmp; |
| 514 | int shield_bmp[NUM_SHIELD_GAUGE_FRAMES]; |
| 515 | int invpulse_bmp; |
| 516 | int dot_bmp; |
| 517 | int afterburn_bmp; |
| 518 | int antigrav_bmp[2]; |
| 519 | }; |
| 520 | |
| 521 | #define HUD_ARROW_SCALE 0.20f |
| 522 | #define HUD_WPN_SCALE 0.75f |
| 523 | #define HUD_SHIP_SCALE 0.33f |
| 524 | #define HUD_ENERGY_SCALE 0.50f |
| 525 | #define HUD_SHIELD_SCALE 0.625f |
| 526 | #define HUD_DOT_SCALE 0.20f |
| 527 | #define HUD_LOCK_SCALE 0.5f |
| 528 | #define HUD_BURN_SCALE 0.5f |
| 529 | |
| 530 | #define HUD_CLOAKEND_TIME 3.0f |
| 531 | |
| 532 | extern struct sHUDResources HUD_resources; |
| 533 | extern bool Small_hud_flag; |
| 534 | |
| 535 | // initializes hud system. |
| 536 | void InitHUD(); |
| 537 | |
| 538 | // initializes hud for ship. |
| 539 | void InitShipHUD(int ship); |
| 540 | |
| 541 | // closes hud. |
| 542 | void CloseHUD(); |
| 543 | |
| 544 | // closes hud for current ship |
| 545 | void CloseShipHUD(); |
| 546 | |
| 547 | // manually sets the cockpit display. |
| 548 | void SetHUDMode(tHUDMode mode); |
| 549 | |
| 550 | // toggle the hud between cockput & fullscreen modes |
| 551 | void ToggleHUDMode(); |
| 552 | |
| 553 | // sets the hud item state(what's visible, how it's drawn, etc) |
| 554 | void SetHUDState(uint16_t hud_mask, uint16_t hud_gr_mask); |
| 555 | |
| 556 | // the current cockpit mode; |
| 557 | tHUDMode GetHUDMode(); |
| 558 | |
| 559 | // places an item on the hud |
| 560 | void AddHUDItem(tHUDItem *item); |
| 561 | |
| 562 | // frees hud items based off their type class. |
| 563 | void FreeHUDItem(int item); |
| 564 | |
| 565 | // Updates the customtext2 item, if there is one |
| 566 | void UpdateCustomtext2HUDItem(char *text); |
| 567 | |
| 568 | // Returns the item number if there's a customtext2 item, else -1 |
| 569 | int FindCustomtext2HUDItem(); |
| 570 | |
| 571 | // resets hud |
| 572 | void ResetHUD(); |
| 573 | |
| 574 | // loads in hud configuration file, adds hud items. |
| 575 | void LoadHUDConfig(const char *filename, bool (*fn)(const char *, const char *, void *) = NULL, void *data = NULL); |
| 576 | |
| 577 | // render cockpit and gauges frame |
| 578 | void RenderHUDFrame(); |
| 579 | |
| 580 | // renders hud frame before any graphics are drawn |
| 581 | void RenderPreHUDFrame(); |
| 582 | |
| 583 | // render auxillary hud |
| 584 | void RenderAuxHUDFrame(); |
| 585 | |
| 586 | // savegame system hooks |
| 587 | void SGSHudState(CFILE *fp); |
| 588 | bool LGSHudState(CFILE *fp); |
| 589 | |
| 590 | // returns scaled line width |
| 591 | int RenderHUDGetTextLineWidth(const char *string); |
| 592 | |
| 593 | // returns scaled text height |
| 594 | int RenderHUDGetTextHeight(const char *string); |
| 595 | |
| 596 | // renders a bitmap onto the hud |
| 597 | void RenderHUDQuad(int x, int y, int w, int h, float u0, float v0, float u1, float v1, int bm, uint8_t alpha, |
| 598 | int sat_count = 0); |
| 599 | |
| 600 | // renders text, scaled, alphaed, saturated, |
| 601 | void RenderHUDText(ddgr_color col, uint8_t alpha, int sat_count, int x, int y, const char *fmt, ...); |
| 602 | |
| 603 | // flags for RenderHudText. |
| 604 | #define HUDTEXT_CENTERED 1 |
| 605 | |
| 606 | // renders text, scaled, alphaed, saturated, |
| 607 | void RenderHUDTextFlags(int flags, ddgr_color col, uint8_t alpha, int sat_count, int x, int y, const char *fmt, ...); |
| 608 | |
| 609 | // reset hud messages. |
| 610 | void ResetHUDMessages(); |
| 611 | |
| 612 | // Sends off the input message the player was typing |
| 613 | void SendOffHUDInputMessage(); |
| 614 | |
| 615 | // reset hud message list. |
| 616 | void ResetHUDMessages(); |
| 617 | |
| 618 | // opens a hud rollback console. |
| 619 | void OpenHUDMessageConsole(); |
| 620 | |
| 621 | // closes hud rollback console |
| 622 | void CloseHUDMessageConsole(); |
| 623 | |
| 624 | // toggles hud rollback console |
| 625 | void ToggleHUDMessageConsole(); |
| 626 | |
| 627 | // resets game message list to no messages |
| 628 | void ResetGameMessages(); |
| 629 | void AddGameMessage(const char *msg); |
| 630 | void SGSGameMessages(CFILE *fp); |
| 631 | void LGSGameMessages(CFILE *fp); |
| 632 | |
| 633 | // toggles game message console (you usually call this.) |
| 634 | void ToggleGameMessageConsole(); |
| 635 | |
| 636 | // game message console |
| 637 | void OpenGameMessageConsole(); |
| 638 | void CloseGameMessageConsole(); |
| 639 | |
| 640 | // pause/unpause hud message rendering |
| 641 | void HUDPauseMessages(void); |
| 642 | void HUDUnpauseMessages(void); |
| 643 | |
| 644 | ///////////////////////////////////////////////////////////////////////// |
| 645 | // Message Console System |
| 646 | ///////////////////////////////////////////////////////////////////////// |
| 647 | |
| 648 | struct tMsgList { |
| 649 | int m_nmsg, m_limit; |
| 650 | char **m_msg; |
| 651 | |
| 652 | tMsgList(); |
| 653 | void set_limit(int limit) { m_limit = limit; }; |
| 654 | bool add(const char *msg, uint8_t lvl = 0, uint8_t hr = 0, uint8_t min = 0, uint8_t sec = 0); |
| 655 | const char *get(int i); |
| 656 | void reset(); |
| 657 | }; |
| 658 | |
| 659 | ////////////////////////////////////////////////////////////////////////////// |
| 660 | |
| 661 | class MsgListConsole { |
| 662 | tMsgList *m_list; |
| 663 | int m_x, m_y, m_w, m_h; |
| 664 | int m_bufline, m_buflen, m_curmsgs, m_numlines; |
| 665 | bool m_opened; |
| 666 | char *m_buffer; |
| 667 | char m_title[32]; |
| 668 | char **m_conlines; |
| 669 | int n_conlines; |
| 670 | int m_keydownstate; // -1 for up key, 1 for down key, 0 for none. |
| 671 | float m_keydowntime; |
| 672 | |
| 673 | public: |
| 674 | MsgListConsole(); |
| 675 | ~MsgListConsole(); |
| 676 | bool Open(const char *title, int x, int y, int w, int h); // registers dimensions of box |
| 677 | void Close(); |
| 678 | void AttachMsgList(tMsgList *msglist); |
| 679 | void Draw(); |
| 680 | void DoInput(); // do scrolling ui on this console |
| 681 | }; |
| 682 | |
| 683 | #endif |