| 1 |
/* |
| 2 |
* Portions of this file are copyright Rebirth contributors and licensed as |
| 3 |
* described in COPYING.txt. |
| 4 |
* Portions of this file are copyright Parallax Software and licensed |
| 5 |
* according to the Parallax license below. |
| 6 |
* See COPYING.txt for license details. |
| 7 |
|
| 8 |
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
| 9 |
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
| 10 |
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
| 11 |
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
| 12 |
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
| 13 |
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
| 14 |
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
| 15 |
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
| 16 |
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
| 17 |
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* |
| 22 |
* Inferno gauge drivers |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
#include <algorithm> |
| 27 |
#include <cmath> |
| 28 |
#include <stdio.h> |
| 29 |
#include <string.h> |
| 30 |
#include <stdlib.h> |
| 31 |
#include <stdarg.h> |
| 32 |
#include <ranges> |
| 33 |
|
| 34 |
#include "hudmsg.h" |
| 35 |
#include "inferno.h" |
| 36 |
#include "game.h" |
| 37 |
#include "gauges.h" |
| 38 |
#include "physics.h" |
| 39 |
#include "dxxerror.h" |
| 40 |
#include "object.h" |
| 41 |
#include "newdemo.h" |
| 42 |
#include "player.h" |
| 43 |
#include "gamefont.h" |
| 44 |
#include "bm.h" |
| 45 |
#include "text.h" |
| 46 |
#include "powerup.h" |
| 47 |
#include "sounds.h" |
| 48 |
#include "multi.h" |
| 49 |
#include "endlevel.h" |
| 50 |
#include "controls.h" |
| 51 |
#include "text.h" |
| 52 |
#include "render.h" |
| 53 |
#include "piggy.h" |
| 54 |
#include "laser.h" |
| 55 |
#include "weapon.h" |
| 56 |
#include "common/3d/globvars.h" |
| 57 |
#include "playsave.h" |
| 58 |
#include "rle.h" |
| 59 |
#if DXX_USE_OGL |
| 60 |
#include "ogl_init.h" |
| 61 |
#endif |
| 62 |
#include "args.h" |
| 63 |
#include "vclip.h" |
| 64 |
#include "compiler-range_for.h" |
| 65 |
#include "d_levelstate.h" |
| 66 |
#include "partial_range.h" |
| 67 |
#include <utility> |
| 68 |
|
| 69 |
using std::min; |
| 70 |
|
| 71 |
namespace { |
| 72 |
|
| 73 |
enum class gauge_screen_resolution : uint8_t |
| 74 |
{ |
| 75 |
low, |
| 76 |
high, |
| 77 |
}; |
| 78 |
|
| 79 |
class local_multires_gauge_graphic |
| 80 |
{ |
| 81 |
public: |
| 82 |
const gauge_screen_resolution hiresmode = gauge_screen_resolution{HIRESMODE}; |
| 83 |
bool is_hires() const |
| 84 |
{ |
| 85 |
return hiresmode != gauge_screen_resolution::low; |
| 86 |
} |
| 87 |
template <typename T> |
| 88 |
T get(T h, T l) const |
| 89 |
{ |
| 90 |
return is_hires() ? h : l; |
| 91 |
} |
| 92 |
template <typename T> |
| 93 |
const T &rget(const T &h, const T &l) const |
| 94 |
{ |
| 95 |
return is_hires() ? h : l; |
| 96 |
} |
| 97 |
}; |
| 98 |
|
| 99 |
static bool show_cloak_invul_timer() |
| 100 |
{ |
| 101 |
return PlayerCfg.CloakInvulTimer && Newdemo_state != ND_STATE_PLAYBACK; |
| 102 |
} |
| 103 |
|
| 104 |
static void draw_ammo_info(grs_canvas &, unsigned x, unsigned y, unsigned ammo_count); |
| 105 |
|
| 106 |
union weapon_index |
| 107 |
{ |
| 108 |
primary_weapon_index_t primary; |
| 109 |
secondary_weapon_index_t secondary; |
| 110 |
constexpr weapon_index() : |
| 111 |
primary(static_cast<primary_weapon_index_t>(~0u)) |
| 112 |
{ |
| 113 |
} |
| 114 |
constexpr weapon_index(const primary_weapon_index_t p) : |
| 115 |
primary(p) |
| 116 |
{ |
| 117 |
} |
| 118 |
constexpr weapon_index(const secondary_weapon_index_t s) : |
| 119 |
secondary(s) |
| 120 |
{ |
| 121 |
} |
| 122 |
constexpr bool operator==(const weapon_index w) const |
| 123 |
{ |
| 124 |
return primary == w.primary; |
| 125 |
} |
| 126 |
}; |
| 127 |
|
| 128 |
static constexpr const char *PRIMARY_WEAPON_NAMES_SHORT(const primary_weapon_index_t weapon_index) |
| 129 |
{ |
| 130 |
switch (weapon_index) |
| 131 |
{ |
| 132 |
default: // unreachable |
| 133 |
case primary_weapon_index_t::LASER_INDEX: // reachable |
| 134 |
return TXT_W_LASER_S; |
| 135 |
case primary_weapon_index_t::VULCAN_INDEX: |
| 136 |
return TXT_W_VULCAN_S; |
| 137 |
case primary_weapon_index_t::SPREADFIRE_INDEX: |
| 138 |
return TXT_W_SPREADFIRE_S; |
| 139 |
case primary_weapon_index_t::PLASMA_INDEX: |
| 140 |
return TXT_W_PLASMA_S; |
| 141 |
case primary_weapon_index_t::FUSION_INDEX: |
| 142 |
return TXT_W_FUSION_S; |
| 143 |
#if DXX_BUILD_DESCENT == 2 |
| 144 |
case primary_weapon_index_t::SUPER_LASER_INDEX: |
| 145 |
return TXT_W_SLASER_S; |
| 146 |
case primary_weapon_index_t::GAUSS_INDEX: |
| 147 |
return TXT_W_SVULCAN_S; |
| 148 |
case primary_weapon_index_t::HELIX_INDEX: |
| 149 |
return TXT_W_SSPREADFIRE_S; |
| 150 |
case primary_weapon_index_t::PHOENIX_INDEX: |
| 151 |
return TXT_W_SPLASMA_S; |
| 152 |
case primary_weapon_index_t::OMEGA_INDEX: |
| 153 |
return TXT_W_SFUSION_S; |
| 154 |
#endif |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
} |
| 159 |
|
| 160 |
//bitmap numbers for gauges |
| 161 |
#define GAUGE_SHIELDS 0 //0..9, in decreasing order (100%,90%...0%) |
| 162 |
#define GAUGE_INVULNERABLE 10 //10..19 |
| 163 |
#define N_INVULNERABLE_FRAMES 10 |
| 164 |
#define GAUGE_ENERGY_LEFT 21 |
| 165 |
#define GAUGE_ENERGY_RIGHT 22 |
| 166 |
#define GAUGE_NUMERICAL 23 |
| 167 |
#define GAUGE_BLUE_KEY 24 |
| 168 |
#define GAUGE_GOLD_KEY 25 |
| 169 |
#define GAUGE_RED_KEY 26 |
| 170 |
#define GAUGE_BLUE_KEY_OFF 27 |
| 171 |
#define GAUGE_GOLD_KEY_OFF 28 |
| 172 |
#define GAUGE_RED_KEY_OFF 29 |
| 173 |
#define SB_GAUGE_BLUE_KEY 30 |
| 174 |
#define SB_GAUGE_GOLD_KEY 31 |
| 175 |
#define SB_GAUGE_RED_KEY 32 |
| 176 |
#define SB_GAUGE_BLUE_KEY_OFF 33 |
| 177 |
#define SB_GAUGE_GOLD_KEY_OFF 34 |
| 178 |
#define SB_GAUGE_RED_KEY_OFF 35 |
| 179 |
#define SB_GAUGE_ENERGY 36 |
| 180 |
#define GAUGE_LIVES 37 |
| 181 |
#define GAUGE_SHIPS 38 |
| 182 |
#define RETICLE_CROSS 46 |
| 183 |
#define RETICLE_PRIMARY 48 |
| 184 |
#define RETICLE_SECONDARY 51 |
| 185 |
#define GAUGE_HOMING_WARNING_ON 56 |
| 186 |
#define GAUGE_HOMING_WARNING_OFF 57 |
| 187 |
#define KEY_ICON_BLUE 68 |
| 188 |
#define KEY_ICON_YELLOW 69 |
| 189 |
#define KEY_ICON_RED 70 |
| 190 |
|
| 191 |
//Coordinats for gauges |
| 192 |
#if DXX_BUILD_DESCENT == 1 |
| 193 |
#define GAUGE_BLUE_KEY_X_L 45 |
| 194 |
#define GAUGE_BLUE_KEY_X_H 91 |
| 195 |
#define GAUGE_GOLD_KEY_X_L 44 |
| 196 |
#define GAUGE_GOLD_KEY_X_H 89 |
| 197 |
#define GAUGE_RED_KEY_X_L 43 |
| 198 |
#define GAUGE_RED_KEY_X_H 87 |
| 199 |
#define GAUGE_RED_KEY_Y_H 417 |
| 200 |
#define LEFT_ENERGY_GAUGE_X_H 137 |
| 201 |
#define RIGHT_ENERGY_GAUGE_X ((multires_gauge_graphic.get(380, 190))) |
| 202 |
#elif DXX_BUILD_DESCENT == 2 |
| 203 |
#define GAUGE_AFTERBURNER 20 |
| 204 |
#define SB_GAUGE_AFTERBURNER 71 |
| 205 |
#define FLAG_ICON_RED 72 |
| 206 |
#define FLAG_ICON_BLUE 73 |
| 207 |
#define GAUGE_BLUE_KEY_X_L 272 |
| 208 |
#define GAUGE_BLUE_KEY_X_H 535 |
| 209 |
#define GAUGE_GOLD_KEY_X_L 273 |
| 210 |
#define GAUGE_GOLD_KEY_X_H 537 |
| 211 |
#define GAUGE_RED_KEY_X_L 274 |
| 212 |
#define GAUGE_RED_KEY_X_H 539 |
| 213 |
#define GAUGE_RED_KEY_Y_H 416 |
| 214 |
#define LEFT_ENERGY_GAUGE_X_H 138 |
| 215 |
#define RIGHT_ENERGY_GAUGE_X ((multires_gauge_graphic.get(379, 190))) |
| 216 |
#endif |
| 217 |
|
| 218 |
#define GAUGE_BLUE_KEY_Y_L 152 |
| 219 |
#define GAUGE_BLUE_KEY_Y_H 374 |
| 220 |
#define GAUGE_BLUE_KEY_X ((multires_gauge_graphic.get(GAUGE_BLUE_KEY_X_H, GAUGE_BLUE_KEY_X_L))) |
| 221 |
#define GAUGE_BLUE_KEY_Y ((multires_gauge_graphic.get(GAUGE_BLUE_KEY_Y_H, GAUGE_BLUE_KEY_Y_L))) |
| 222 |
#define GAUGE_GOLD_KEY_Y_L 162 |
| 223 |
#define GAUGE_GOLD_KEY_Y_H 395 |
| 224 |
#define GAUGE_GOLD_KEY_X ((multires_gauge_graphic.get(GAUGE_GOLD_KEY_X_H, GAUGE_GOLD_KEY_X_L))) |
| 225 |
#define GAUGE_GOLD_KEY_Y ((multires_gauge_graphic.get(GAUGE_GOLD_KEY_Y_H, GAUGE_GOLD_KEY_Y_L))) |
| 226 |
#define GAUGE_RED_KEY_Y_L 172 |
| 227 |
#define GAUGE_RED_KEY_X ((multires_gauge_graphic.get(GAUGE_RED_KEY_X_H, GAUGE_RED_KEY_X_L))) |
| 228 |
#define GAUGE_RED_KEY_Y ((multires_gauge_graphic.get(GAUGE_RED_KEY_Y_H, GAUGE_RED_KEY_Y_L))) |
| 229 |
#define SB_GAUGE_KEYS_X_L 11 |
| 230 |
#define SB_GAUGE_KEYS_X_H 26 |
| 231 |
#define SB_GAUGE_KEYS_X ((multires_gauge_graphic.get(SB_GAUGE_KEYS_X_H, SB_GAUGE_KEYS_X_L))) |
| 232 |
#define SB_GAUGE_BLUE_KEY_Y_L 153 |
| 233 |
#define SB_GAUGE_GOLD_KEY_Y_L 169 |
| 234 |
#define SB_GAUGE_RED_KEY_Y_L 185 |
| 235 |
#define SB_GAUGE_BLUE_KEY_Y_H 390 |
| 236 |
#define SB_GAUGE_GOLD_KEY_Y_H 422 |
| 237 |
#define SB_GAUGE_RED_KEY_Y_H 454 |
| 238 |
#define SB_GAUGE_BLUE_KEY_Y ((multires_gauge_graphic.get(SB_GAUGE_BLUE_KEY_Y_H, SB_GAUGE_BLUE_KEY_Y_L))) |
| 239 |
#define SB_GAUGE_GOLD_KEY_Y ((multires_gauge_graphic.get(SB_GAUGE_GOLD_KEY_Y_H, SB_GAUGE_GOLD_KEY_Y_L))) |
| 240 |
#define SB_GAUGE_RED_KEY_Y ((multires_gauge_graphic.get(SB_GAUGE_RED_KEY_Y_H, SB_GAUGE_RED_KEY_Y_L))) |
| 241 |
#define LEFT_ENERGY_GAUGE_X_L 70 |
| 242 |
#define LEFT_ENERGY_GAUGE_Y_L 131 |
| 243 |
#define LEFT_ENERGY_GAUGE_W_L 64 |
| 244 |
#define LEFT_ENERGY_GAUGE_H_L 8 |
| 245 |
#define LEFT_ENERGY_GAUGE_Y_H 314 |
| 246 |
#define LEFT_ENERGY_GAUGE_W_H 133 |
| 247 |
#define LEFT_ENERGY_GAUGE_H_H 21 |
| 248 |
#define LEFT_ENERGY_GAUGE_X ((multires_gauge_graphic.get(LEFT_ENERGY_GAUGE_X_H, LEFT_ENERGY_GAUGE_X_L))) |
| 249 |
#define LEFT_ENERGY_GAUGE_Y ((multires_gauge_graphic.get(LEFT_ENERGY_GAUGE_Y_H, LEFT_ENERGY_GAUGE_Y_L))) |
| 250 |
#define LEFT_ENERGY_GAUGE_W ((multires_gauge_graphic.get(LEFT_ENERGY_GAUGE_W_H, LEFT_ENERGY_GAUGE_W_L))) |
| 251 |
#define LEFT_ENERGY_GAUGE_H ((multires_gauge_graphic.get(LEFT_ENERGY_GAUGE_H_H, LEFT_ENERGY_GAUGE_H_L))) |
| 252 |
#define RIGHT_ENERGY_GAUGE_Y ((multires_gauge_graphic.get(314, 131))) |
| 253 |
#define RIGHT_ENERGY_GAUGE_W ((multires_gauge_graphic.get(133, 64))) |
| 254 |
#define RIGHT_ENERGY_GAUGE_H ((multires_gauge_graphic.get(21, 8))) |
| 255 |
|
| 256 |
#if DXX_BUILD_DESCENT == 1 |
| 257 |
#define SB_ENERGY_GAUGE_Y ((multires_gauge_graphic.get(390, 155))) |
| 258 |
#define SB_ENERGY_GAUGE_H ((multires_gauge_graphic.get(82, 41))) |
| 259 |
#define SB_ENERGY_NUM_Y ((multires_gauge_graphic.get(457, 190))) |
| 260 |
#define SHIELD_GAUGE_Y ((multires_gauge_graphic.get(374, 155))) |
| 261 |
#define SB_SHIELD_NUM_Y (SB_SHIELD_GAUGE_Y-((multires_gauge_graphic.get(16, 7)))) //156 -- MWA used to be hard coded to 156 |
| 262 |
#define NUMERICAL_GAUGE_Y ((multires_gauge_graphic.get(316, 130))) |
| 263 |
#define PRIMARY_W_PIC_X ((multires_gauge_graphic.get(135, 64))) |
| 264 |
#define SECONDARY_W_PIC_X ((multires_gauge_graphic.get(405, 234))) |
| 265 |
#define SECONDARY_W_PIC_Y ((multires_gauge_graphic.get(370, 154))) |
| 266 |
#define SECONDARY_W_TEXT_X multires_gauge_graphic.get(462, 207) |
| 267 |
#define SECONDARY_W_TEXT_Y multires_gauge_graphic.get(400, 157) |
| 268 |
#define SECONDARY_AMMO_X multires_gauge_graphic.get(475, 213) |
| 269 |
#define SECONDARY_AMMO_Y multires_gauge_graphic.get(425, 171) |
| 270 |
#define SB_LIVES_X ((multires_gauge_graphic.get(550, 266))) |
| 271 |
#define SB_LIVES_Y ((multires_gauge_graphic.get(450, 185))) |
| 272 |
#define SB_SCORE_RIGHT_H 605 |
| 273 |
#define BOMB_COUNT_X ((multires_gauge_graphic.get(468, 210))) |
| 274 |
#define PRIMARY_W_BOX_RIGHT_H 241 |
| 275 |
#define SECONDARY_W_BOX_RIGHT_L 264 //(SECONDARY_W_BOX_LEFT+54) |
| 276 |
#define SECONDARY_W_BOX_LEFT_H 403 |
| 277 |
#define SECONDARY_W_BOX_TOP_H 364 |
| 278 |
#define SECONDARY_W_BOX_RIGHT_H 531 |
| 279 |
#define SB_PRIMARY_W_BOX_TOP_L 154 |
| 280 |
#define SB_PRIMARY_W_BOX_BOT_L (195) |
| 281 |
#define SB_SECONDARY_W_BOX_TOP_L 154 |
| 282 |
#define SB_SECONDARY_W_BOX_RIGHT_L (SB_SECONDARY_W_BOX_LEFT_L+54) |
| 283 |
#define SB_SECONDARY_W_BOX_BOT_L (153+42) |
| 284 |
#define SB_SECONDARY_AMMO_X (SB_SECONDARY_W_BOX_LEFT + (multires_gauge_graphic.get(14, 11))) //(212+9) |
| 285 |
#define GET_GAUGE_INDEX(x) (Gauges[x]) |
| 286 |
|
| 287 |
#elif DXX_BUILD_DESCENT == 2 |
| 288 |
#define AFTERBURNER_GAUGE_X_L 45-1 |
| 289 |
#define AFTERBURNER_GAUGE_Y_L 158 |
| 290 |
#define AFTERBURNER_GAUGE_H_L 32 |
| 291 |
#define AFTERBURNER_GAUGE_X_H 88 |
| 292 |
#define AFTERBURNER_GAUGE_Y_H 378 |
| 293 |
#define AFTERBURNER_GAUGE_H_H 65 |
| 294 |
#define AFTERBURNER_GAUGE_X ((multires_gauge_graphic.get(AFTERBURNER_GAUGE_X_H, AFTERBURNER_GAUGE_X_L))) |
| 295 |
#define AFTERBURNER_GAUGE_Y ((multires_gauge_graphic.get(AFTERBURNER_GAUGE_Y_H, AFTERBURNER_GAUGE_Y_L))) |
| 296 |
#define AFTERBURNER_GAUGE_H ((multires_gauge_graphic.get(AFTERBURNER_GAUGE_H_H, AFTERBURNER_GAUGE_H_L))) |
| 297 |
#define SB_AFTERBURNER_GAUGE_X ((multires_gauge_graphic.get(196, 98))) |
| 298 |
#define SB_AFTERBURNER_GAUGE_Y ((multires_gauge_graphic.get(445, 184))) |
| 299 |
#define SB_AFTERBURNER_GAUGE_W ((multires_gauge_graphic.get(33, 16))) |
| 300 |
#define SB_AFTERBURNER_GAUGE_H ((multires_gauge_graphic.get(29, 13))) |
| 301 |
#define SB_ENERGY_GAUGE_Y ((multires_gauge_graphic.get(381, 155-2))) |
| 302 |
#define SB_ENERGY_GAUGE_H ((multires_gauge_graphic.get(60, 29))) |
| 303 |
#define SB_ENERGY_NUM_Y ((multires_gauge_graphic.get(457, 175))) |
| 304 |
#define SHIELD_GAUGE_Y ((multires_gauge_graphic.get(375, 155))) |
| 305 |
#define SB_SHIELD_NUM_Y (SB_SHIELD_GAUGE_Y-((multires_gauge_graphic.get(16, 8)))) //156 -- MWA used to be hard coded to 156 |
| 306 |
#define NUMERICAL_GAUGE_Y ((multires_gauge_graphic.get(314, 130))) |
| 307 |
#define PRIMARY_W_PIC_X ((multires_gauge_graphic.get(135-10, 64))) |
| 308 |
#define SECONDARY_W_PIC_X ((multires_gauge_graphic.get(466, 234))) |
| 309 |
#define SECONDARY_W_PIC_Y ((multires_gauge_graphic.get(374, 154))) |
| 310 |
#define SECONDARY_W_TEXT_X multires_gauge_graphic.get(413, 207) |
| 311 |
#define SECONDARY_W_TEXT_Y multires_gauge_graphic.get(378, 157) |
| 312 |
#define SECONDARY_AMMO_X multires_gauge_graphic.get(428, 213) |
| 313 |
#define SECONDARY_AMMO_Y multires_gauge_graphic.get(407, 171) |
| 314 |
#define SB_LIVES_X ((multires_gauge_graphic.get(550-10-3, 266))) |
| 315 |
#define SB_LIVES_Y ((multires_gauge_graphic.get(450-3, 185))) |
| 316 |
#define SB_SCORE_RIGHT_H (605+8) |
| 317 |
#define BOMB_COUNT_X ((multires_gauge_graphic.get(546, 275))) |
| 318 |
#define PRIMARY_W_BOX_RIGHT_H 242 |
| 319 |
#define SECONDARY_W_BOX_RIGHT_L 263 //(SECONDARY_W_BOX_LEFT+54) |
| 320 |
#define SECONDARY_W_BOX_LEFT_H 404 |
| 321 |
#define SECONDARY_W_BOX_TOP_H 363 |
| 322 |
#define SECONDARY_W_BOX_RIGHT_H 529 |
| 323 |
#define SB_PRIMARY_W_BOX_TOP_L 153 |
| 324 |
#define SB_PRIMARY_W_BOX_BOT_L (195+1) |
| 325 |
#define SB_SECONDARY_W_BOX_TOP_L 153 |
| 326 |
#define SB_SECONDARY_W_BOX_RIGHT_L (SB_SECONDARY_W_BOX_LEFT_L+54+1) |
| 327 |
#define SB_SECONDARY_W_BOX_BOT_L (SB_SECONDARY_W_BOX_TOP_L+43) |
| 328 |
#define SB_SECONDARY_AMMO_X (SB_SECONDARY_W_BOX_LEFT + (multires_gauge_graphic.get(14 - 4, 11))) //(212+9) |
| 329 |
#define GET_GAUGE_INDEX(x) ((multires_gauge_graphic.rget(Gauges_hires, Gauges)[x])) |
| 330 |
|
| 331 |
#endif |
| 332 |
|
| 333 |
// MOVEME |
| 334 |
#define HOMING_WARNING_X ((multires_gauge_graphic.get(13, 7))) |
| 335 |
#define HOMING_WARNING_Y ((multires_gauge_graphic.get(416, 171))) |
| 336 |
|
| 337 |
#define SB_ENERGY_GAUGE_X ((multires_gauge_graphic.get(196, 98))) |
| 338 |
#define SB_ENERGY_GAUGE_W ((multires_gauge_graphic.get(32, 16))) |
| 339 |
#define SHIP_GAUGE_X (SHIELD_GAUGE_X+((multires_gauge_graphic.get(11, 5)))) |
| 340 |
#define SHIP_GAUGE_Y (SHIELD_GAUGE_Y+((multires_gauge_graphic.get(10, 5)))) |
| 341 |
#define SHIELD_GAUGE_X ((multires_gauge_graphic.get(292, 146))) |
| 342 |
#define SB_SHIELD_GAUGE_X ((multires_gauge_graphic.get(247, 123))) //139 |
| 343 |
#define SB_SHIELD_GAUGE_Y ((multires_gauge_graphic.get(395, 163))) |
| 344 |
#define SB_SHIP_GAUGE_X (SB_SHIELD_GAUGE_X+((multires_gauge_graphic.get(11, 5)))) |
| 345 |
#define SB_SHIP_GAUGE_Y (SB_SHIELD_GAUGE_Y+((multires_gauge_graphic.get(10, 5)))) |
| 346 |
#define SB_SHIELD_NUM_X (SB_SHIELD_GAUGE_X+((multires_gauge_graphic.get(21, 12)))) //151 |
| 347 |
#define NUMERICAL_GAUGE_X ((multires_gauge_graphic.get(308, 154))) |
| 348 |
#define PRIMARY_W_PIC_Y ((multires_gauge_graphic.get(370, 154))) |
| 349 |
#define PRIMARY_W_TEXT_X multires_gauge_graphic.get(182, 87) |
| 350 |
#define PRIMARY_W_TEXT_Y multires_gauge_graphic.get(378, 157) |
| 351 |
#define PRIMARY_AMMO_X multires_gauge_graphic.get(186, 93) |
| 352 |
#define PRIMARY_AMMO_Y multires_gauge_graphic.get(407, 171) |
| 353 |
#define SB_LIVES_LABEL_X ((multires_gauge_graphic.get(475, 237))) |
| 354 |
#define SB_SCORE_RIGHT_L 301 |
| 355 |
#define SB_SCORE_RIGHT ((multires_gauge_graphic.get(SB_SCORE_RIGHT_H, SB_SCORE_RIGHT_L))) |
| 356 |
#define SB_SCORE_Y ((multires_gauge_graphic.get(398, 158))) |
| 357 |
#define SB_SCORE_LABEL_X ((multires_gauge_graphic.get(475, 237))) |
| 358 |
#define SB_SCORE_ADDED_RIGHT ((multires_gauge_graphic.get(SB_SCORE_RIGHT_H, SB_SCORE_RIGHT_L))) |
| 359 |
#define SB_SCORE_ADDED_Y ((multires_gauge_graphic.get(413, 165))) |
| 360 |
#define BOMB_COUNT_Y ((multires_gauge_graphic.get(445, 186))) |
| 361 |
#define SB_BOMB_COUNT_X ((multires_gauge_graphic.get(342, 171))) |
| 362 |
#define SB_BOMB_COUNT_Y ((multires_gauge_graphic.get(458, 191))) |
| 363 |
|
| 364 |
// defining box boundries for weapon pictures |
| 365 |
#define PRIMARY_W_BOX_LEFT_L 63 |
| 366 |
#define PRIMARY_W_BOX_TOP_L 151 //154 |
| 367 |
#define PRIMARY_W_BOX_RIGHT_L (PRIMARY_W_BOX_LEFT_L+58) |
| 368 |
#define PRIMARY_W_BOX_BOT_L (PRIMARY_W_BOX_TOP_L+42) |
| 369 |
#define PRIMARY_W_BOX_LEFT_H 121 |
| 370 |
#define PRIMARY_W_BOX_TOP_H 364 |
| 371 |
#define PRIMARY_W_BOX_BOT_H (PRIMARY_W_BOX_TOP_H+106) //470 |
| 372 |
#define PRIMARY_W_BOX_LEFT ((multires_gauge_graphic.get(PRIMARY_W_BOX_LEFT_H, PRIMARY_W_BOX_LEFT_L))) |
| 373 |
#define PRIMARY_W_BOX_TOP ((multires_gauge_graphic.get(PRIMARY_W_BOX_TOP_H, PRIMARY_W_BOX_TOP_L))) |
| 374 |
#define PRIMARY_W_BOX_RIGHT ((multires_gauge_graphic.get(PRIMARY_W_BOX_RIGHT_H, PRIMARY_W_BOX_RIGHT_L))) |
| 375 |
#define PRIMARY_W_BOX_BOT ((multires_gauge_graphic.get(PRIMARY_W_BOX_BOT_H, PRIMARY_W_BOX_BOT_L))) |
| 376 |
#define SECONDARY_W_BOX_LEFT_L 202 //207 |
| 377 |
#define SECONDARY_W_BOX_TOP_L 151 |
| 378 |
#define SECONDARY_W_BOX_BOT_L (SECONDARY_W_BOX_TOP_L+42) |
| 379 |
#define SECONDARY_W_BOX_BOT_H (SECONDARY_W_BOX_TOP_H+106) //470 |
| 380 |
#define SECONDARY_W_BOX_LEFT ((multires_gauge_graphic.get(SECONDARY_W_BOX_LEFT_H, SECONDARY_W_BOX_LEFT_L))) |
| 381 |
#define SECONDARY_W_BOX_TOP ((multires_gauge_graphic.get(SECONDARY_W_BOX_TOP_H, SECONDARY_W_BOX_TOP_L))) |
| 382 |
#define SECONDARY_W_BOX_RIGHT ((multires_gauge_graphic.get(SECONDARY_W_BOX_RIGHT_H, SECONDARY_W_BOX_RIGHT_L))) |
| 383 |
#define SECONDARY_W_BOX_BOT ((multires_gauge_graphic.get(SECONDARY_W_BOX_BOT_H, SECONDARY_W_BOX_BOT_L))) |
| 384 |
#define SB_PRIMARY_W_BOX_LEFT_L 34 //50 |
| 385 |
#define SB_PRIMARY_W_BOX_RIGHT_L (SB_PRIMARY_W_BOX_LEFT_L+55) |
| 386 |
#define SB_PRIMARY_W_BOX_LEFT_H 68 |
| 387 |
#define SB_PRIMARY_W_BOX_TOP_H 381 |
| 388 |
#define SB_PRIMARY_W_BOX_RIGHT_H 179 |
| 389 |
#define SB_PRIMARY_W_BOX_BOT_H 473 |
| 390 |
#define SB_PRIMARY_W_BOX_LEFT ((multires_gauge_graphic.get(SB_PRIMARY_W_BOX_LEFT_H, SB_PRIMARY_W_BOX_LEFT_L))) |
| 391 |
#define SB_SECONDARY_W_BOX_LEFT_L 169 |
| 392 |
#define SB_SECONDARY_W_BOX_LEFT_H 338 |
| 393 |
#define SB_SECONDARY_W_BOX_TOP_H 381 |
| 394 |
#define SB_SECONDARY_W_BOX_RIGHT_H 449 |
| 395 |
#define SB_SECONDARY_W_BOX_BOT_H 473 |
| 396 |
#define SB_SECONDARY_W_BOX_LEFT ((multires_gauge_graphic.get(SB_SECONDARY_W_BOX_LEFT_H, SB_SECONDARY_W_BOX_LEFT_L))) //210 |
| 397 |
#define SB_PRIMARY_W_PIC_X (SB_PRIMARY_W_BOX_LEFT+1) //51 |
| 398 |
#define SB_PRIMARY_W_PIC_Y ((multires_gauge_graphic.get(382, 154))) |
| 399 |
#define SB_PRIMARY_W_TEXT_X (SB_PRIMARY_W_BOX_LEFT + multires_gauge_graphic.get(50, 24)) //(51+23) |
| 400 |
#define SB_PRIMARY_W_TEXT_Y (multires_gauge_graphic.get(390, 157)) |
| 401 |
#define SB_PRIMARY_AMMO_X (SB_PRIMARY_W_BOX_LEFT + multires_gauge_graphic.get(58, 30)) //((SB_PRIMARY_W_BOX_LEFT+33)-3) //(51+32) |
| 402 |
#define SB_PRIMARY_AMMO_Y multires_gauge_graphic.get(410, 171) |
| 403 |
#define SB_SECONDARY_W_PIC_X ((multires_gauge_graphic.get(385, (SB_SECONDARY_W_BOX_LEFT+27)))) //(212+27) |
| 404 |
#define SB_SECONDARY_W_PIC_Y ((multires_gauge_graphic.get(382, 154))) |
| 405 |
#define SB_SECONDARY_W_TEXT_X (SB_SECONDARY_W_BOX_LEFT + 2) //212 |
| 406 |
#define SB_SECONDARY_W_TEXT_Y multires_gauge_graphic.get(390, 157) |
| 407 |
#define SB_SECONDARY_AMMO_Y multires_gauge_graphic.get(414, 171) |
| 408 |
|
| 409 |
#define FADE_SCALE (2*i2f(GR_FADE_LEVELS)/REARM_TIME) // fade out and back in REARM_TIME, in fade levels per seconds (int) |
| 410 |
|
| 411 |
#define COCKPIT_PRIMARY_BOX ((multires_gauge_graphic.get(4, 0))) |
| 412 |
#define COCKPIT_SECONDARY_BOX ((multires_gauge_graphic.get(5, 1))) |
| 413 |
#define SB_PRIMARY_BOX ((multires_gauge_graphic.get(6, 2))) |
| 414 |
#define SB_SECONDARY_BOX ((multires_gauge_graphic.get(7, 3))) |
| 415 |
|
| 416 |
// scaling gauges |
| 417 |
#define BASE_WIDTH(G) ((G).get(640, 320)) |
| 418 |
#define BASE_HEIGHT(G) ((G).get(480, 200)) |
| 419 |
namespace { |
| 420 |
|
| 421 |
enum class weapon_box_state : uint8_t |
| 422 |
{ |
| 423 |
set, //in correct state |
| 424 |
fading_out, |
| 425 |
fading_in, |
| 426 |
}; |
| 427 |
static_assert(static_cast<unsigned>(weapon_box_state::set) == 0, "weapon_box_states must start at zero"); |
| 428 |
|
| 429 |
#if DXX_USE_OGL |
| 430 |
template <char tag> |
| 431 |
class hud_scale_float; |
| 432 |
#else |
| 433 |
struct hud_unscaled_int |
| 434 |
{ |
| 435 |
long operator()(const unsigned i) const |
| 436 |
{ |
| 437 |
return i; |
| 438 |
} |
| 439 |
}; |
| 440 |
|
| 441 |
template <char tag> |
| 442 |
using hud_scale_float = hud_unscaled_int; |
| 443 |
#endif |
| 444 |
|
| 445 |
using hud_ar_scale_float = hud_scale_float<'a'>; |
| 446 |
using hud_x_scale_float = hud_scale_float<'x'>; |
| 447 |
using hud_y_scale_float = hud_scale_float<'y'>; |
| 448 |
|
| 449 |
#if DXX_USE_OGL |
| 450 |
class base_hud_scaled_int |
| 451 |
{ |
| 452 |
const long v; |
| 453 |
public: |
| 454 |
explicit constexpr base_hud_scaled_int(const long l) : |
| 455 |
v(l) |
| 456 |
{ |
| 457 |
} |
| 458 |
operator long() const |
| 459 |
{ |
| 460 |
return v; |
| 461 |
} |
| 462 |
}; |
| 463 |
|
| 464 |
template <char> |
| 465 |
class hud_scaled_int : public base_hud_scaled_int |
| 466 |
{ |
| 467 |
public: |
| 468 |
using base_hud_scaled_int::base_hud_scaled_int; |
| 469 |
}; |
| 470 |
|
| 471 |
class base_hud_scale_float |
| 472 |
{ |
| 473 |
protected: |
| 474 |
const double scale; |
| 475 |
long operator()(const int i) const |
| 476 |
{ |
| 477 |
return (this->scale * static_cast<double>(i)) + 0.5; |
| 478 |
} |
| 479 |
double get() const |
| 480 |
{ |
| 481 |
return scale; |
| 482 |
} |
| 483 |
public: |
| 484 |
constexpr base_hud_scale_float(const double s) : |
| 485 |
scale(s) |
| 486 |
{ |
| 487 |
} |
| 488 |
}; |
| 489 |
|
| 490 |
template <char tag> |
| 491 |
class hud_scale_float : base_hud_scale_float |
| 492 |
{ |
| 493 |
public: |
| 494 |
using scaled = hud_scaled_int<tag>; |
| 495 |
using base_hud_scale_float::get; |
| 496 |
using base_hud_scale_float::base_hud_scale_float; |
| 497 |
scaled operator()(const int i) const |
| 498 |
{ |
| 499 |
return scaled(this->base_hud_scale_float::operator()(i)); |
| 500 |
} |
| 501 |
}; |
| 502 |
|
| 503 |
static hud_x_scale_float HUD_SCALE_X(const unsigned screen_width, const local_multires_gauge_graphic multires_gauge_graphic) |
| 504 |
{ |
| 505 |
return static_cast<double>(screen_width) / BASE_WIDTH(multires_gauge_graphic); |
| 506 |
} |
| 507 |
|
| 508 |
static hud_y_scale_float HUD_SCALE_Y(const unsigned screen_height, const local_multires_gauge_graphic multires_gauge_graphic) |
| 509 |
{ |
| 510 |
return static_cast<double>(screen_height) / BASE_HEIGHT(multires_gauge_graphic); |
| 511 |
} |
| 512 |
|
| 513 |
static hud_ar_scale_float HUD_SCALE_AR(const hud_x_scale_float x, const hud_y_scale_float y) |
| 514 |
{ |
| 515 |
return std::min(x.get(), y.get()); |
| 516 |
} |
| 517 |
|
| 518 |
static hud_ar_scale_float HUD_SCALE_AR(const unsigned screen_width, const unsigned screen_height, const local_multires_gauge_graphic multires_gauge_graphic) |
| 519 |
{ |
| 520 |
return HUD_SCALE_AR(HUD_SCALE_X(screen_width, multires_gauge_graphic), HUD_SCALE_Y(screen_height, multires_gauge_graphic)); |
| 521 |
} |
| 522 |
|
| 523 |
#define draw_numerical_display_draw_context hud_draw_context_hs |
| 524 |
#else |
| 525 |
#define hud_bitblt_free(canvas,x,y,w,h,bm) hud_bitblt_free(canvas,x,y,bm) |
| 526 |
#define draw_numerical_display_draw_context hud_draw_context_hs_mr |
| 527 |
|
| 528 |
static hud_ar_scale_float HUD_SCALE_AR(hud_x_scale_float, hud_y_scale_float) |
| 529 |
{ |
| 530 |
return {}; |
| 531 |
} |
| 532 |
|
| 533 |
static hud_ar_scale_float HUD_SCALE_AR(unsigned, unsigned, local_multires_gauge_graphic) |
| 534 |
{ |
| 535 |
return {}; |
| 536 |
} |
| 537 |
#endif |
| 538 |
|
| 539 |
struct CockpitWeaponBoxFrameBitmaps : std::array<grs_subbitmap_ptr, 2> // Overlay subbitmaps for both weapon boxes |
| 540 |
{ |
| 541 |
/* `decoded_full_cockpit_image` is a member instead of a local in |
| 542 |
* the initializer function because it must remain allocated. It |
| 543 |
* must remain allocated because the subbitmaps refer to the data |
| 544 |
* managed by `decoded_full_cockpit_image`, so destroying it would |
| 545 |
* leave the subbitmaps dangling. For OpenGL, the texture would be |
| 546 |
* dangling. For SDL-only, the bm_data pointers would be dangling. |
| 547 |
*/ |
| 548 |
#if DXX_USE_OGL |
| 549 |
/* Use bare grs_bitmap because the caller has special rules for |
| 550 |
* managing the memory pointed at by `bm_data`. |
| 551 |
*/ |
| 552 |
grs_bitmap decoded_full_cockpit_image; |
| 553 |
#else |
| 554 |
/* Use grs_main_bitmap because the bitmap follows the standard |
| 555 |
* rules. |
| 556 |
*/ |
| 557 |
grs_main_bitmap decoded_full_cockpit_image; |
| 558 |
#endif |
| 559 |
}; |
| 560 |
|
| 561 |
static CockpitWeaponBoxFrameBitmaps WinBoxOverlay; |
| 562 |
|
| 563 |
} |
| 564 |
|
| 565 |
#if DXX_BUILD_DESCENT == 1 |
| 566 |
#define PAGE_IN_GAUGE(x,g) PAGE_IN_GAUGE(x) |
| 567 |
std::array<bitmap_index, MAX_GAUGE_BMS_MAC> Gauges; // Array of all gauge bitmaps. |
| 568 |
#elif DXX_BUILD_DESCENT == 2 |
| 569 |
#define PAGE_IN_GAUGE PAGE_IN_GAUGE |
| 570 |
std::array<bitmap_index, MAX_GAUGE_BMS> Gauges, // Array of all gauge bitmaps. |
| 571 |
Gauges_hires; // hires gauges |
| 572 |
#endif |
| 573 |
|
| 574 |
namespace dsx { |
| 575 |
namespace { |
| 576 |
static inline void PAGE_IN_GAUGE(int x, const local_multires_gauge_graphic multires_gauge_graphic) |
| 577 |
{ |
| 578 |
const auto &g = |
| 579 |
#if DXX_BUILD_DESCENT == 2 |
| 580 |
multires_gauge_graphic.is_hires() ? Gauges_hires : |
| 581 |
#endif |
| 582 |
Gauges; |
| 583 |
PIGGY_PAGE_IN(g[x]); |
| 584 |
} |
| 585 |
} |
| 586 |
} |
| 587 |
|
| 588 |
namespace { |
| 589 |
static int score_display; |
| 590 |
static fix score_time; |
| 591 |
static laser_level old_laser_level; |
| 592 |
static int invulnerable_frame; |
| 593 |
} |
| 594 |
int Color_0_31_0 = -1; |
| 595 |
|
| 596 |
namespace dcx { |
| 597 |
|
| 598 |
namespace { |
| 599 |
|
| 600 |
struct hud_draw_context_canvas |
| 601 |
{ |
| 602 |
grs_canvas &canvas; |
| 603 |
hud_draw_context_canvas(grs_canvas &c) : |
| 604 |
canvas(c) |
| 605 |
{ |
| 606 |
} |
| 607 |
}; |
| 608 |
|
| 609 |
struct hud_draw_context_multires |
| 610 |
{ |
| 611 |
const local_multires_gauge_graphic multires_gauge_graphic; |
| 612 |
hud_draw_context_multires(const local_multires_gauge_graphic mr) : |
| 613 |
multires_gauge_graphic(mr) |
| 614 |
{ |
| 615 |
} |
| 616 |
}; |
| 617 |
|
| 618 |
struct hud_draw_context_mr : hud_draw_context_canvas, hud_draw_context_multires |
| 619 |
{ |
| 620 |
hud_draw_context_mr(grs_canvas &c, const local_multires_gauge_graphic mr) : |
| 621 |
hud_draw_context_canvas(c), hud_draw_context_multires(mr) |
| 622 |
{ |
| 623 |
} |
| 624 |
}; |
| 625 |
|
| 626 |
struct hud_draw_context_xyscale |
| 627 |
{ |
| 628 |
const hud_x_scale_float xscale; |
| 629 |
const hud_y_scale_float yscale; |
| 630 |
#if DXX_USE_OGL |
| 631 |
constexpr hud_draw_context_xyscale(const hud_x_scale_float x, const hud_y_scale_float y) : |
| 632 |
xscale(x), yscale(y) |
| 633 |
{ |
| 634 |
} |
| 635 |
#else |
| 636 |
constexpr hud_draw_context_xyscale() : |
| 637 |
xscale{}, yscale{} |
| 638 |
{ |
| 639 |
} |
| 640 |
#endif |
| 641 |
}; |
| 642 |
|
| 643 |
struct hud_draw_context_hs_mr : hud_draw_context_mr, hud_draw_context_xyscale |
| 644 |
{ |
| 645 |
#if DXX_USE_OGL |
| 646 |
hud_draw_context_hs_mr(grs_canvas &c, const unsigned screen_width, const unsigned screen_height, const local_multires_gauge_graphic multires_gauge_graphic) : |
| 647 |
hud_draw_context_mr(c, multires_gauge_graphic), |
| 648 |
hud_draw_context_xyscale(HUD_SCALE_X(screen_width, multires_gauge_graphic), HUD_SCALE_Y(screen_height, multires_gauge_graphic)) |
| 649 |
{ |
| 650 |
} |
| 651 |
#else |
| 652 |
hud_draw_context_hs_mr(grs_canvas &c, unsigned, unsigned, const local_multires_gauge_graphic multires_gauge_graphic) : |
| 653 |
hud_draw_context_mr(c, multires_gauge_graphic) |
| 654 |
{ |
| 655 |
} |
| 656 |
#endif |
| 657 |
}; |
| 658 |
|
| 659 |
struct hud_draw_context_hs : hud_draw_context_canvas, hud_draw_context_xyscale |
| 660 |
{ |
| 661 |
hud_draw_context_hs(const hud_draw_context_hs_mr &hudctx) : |
| 662 |
hud_draw_context_canvas(hudctx.canvas), hud_draw_context_xyscale(hudctx) |
| 663 |
{ |
| 664 |
} |
| 665 |
}; |
| 666 |
|
| 667 |
struct gauge_box |
| 668 |
{ |
| 669 |
int left,top; |
| 670 |
int right,bot; //maximal box |
| 671 |
}; |
| 672 |
|
| 673 |
enum class gauge_hud_type : uint_fast32_t |
| 674 |
{ |
| 675 |
cockpit, |
| 676 |
statusbar, |
| 677 |
// fullscreen mode handled separately |
| 678 |
}; |
| 679 |
|
| 680 |
constexpr enumerated_array< |
| 681 |
enumerated_array< |
| 682 |
enumerated_array<gauge_box, 2, gauge_hud_type>, |
| 683 |
2, gauge_inset_window_view>, |
| 684 |
2, gauge_screen_resolution> gauge_boxes = {{{ |
| 685 |
{{{ |
| 686 |
{{{ |
| 687 |
{PRIMARY_W_BOX_LEFT_L,PRIMARY_W_BOX_TOP_L,PRIMARY_W_BOX_RIGHT_L,PRIMARY_W_BOX_BOT_L}, |
| 688 |
{SB_PRIMARY_W_BOX_LEFT_L,SB_PRIMARY_W_BOX_TOP_L,SB_PRIMARY_W_BOX_RIGHT_L,SB_PRIMARY_W_BOX_BOT_L}, |
| 689 |
}}}, |
| 690 |
|
| 691 |
{{{ |
| 692 |
{SECONDARY_W_BOX_LEFT_L,SECONDARY_W_BOX_TOP_L,SECONDARY_W_BOX_RIGHT_L,SECONDARY_W_BOX_BOT_L}, |
| 693 |
{SB_SECONDARY_W_BOX_LEFT_L,SB_SECONDARY_W_BOX_TOP_L,SB_SECONDARY_W_BOX_RIGHT_L,SB_SECONDARY_W_BOX_BOT_L}, |
| 694 |
}}}, |
| 695 |
}}}, |
| 696 |
|
| 697 |
{{{ |
| 698 |
{{{ |
| 699 |
{PRIMARY_W_BOX_LEFT_H,PRIMARY_W_BOX_TOP_H,PRIMARY_W_BOX_RIGHT_H,PRIMARY_W_BOX_BOT_H}, |
| 700 |
{SB_PRIMARY_W_BOX_LEFT_H,SB_PRIMARY_W_BOX_TOP_H,SB_PRIMARY_W_BOX_RIGHT_H,SB_PRIMARY_W_BOX_BOT_H}, |
| 701 |
}}}, |
| 702 |
|
| 703 |
{{{ |
| 704 |
{SECONDARY_W_BOX_LEFT_H,SECONDARY_W_BOX_TOP_H,SECONDARY_W_BOX_RIGHT_H,SECONDARY_W_BOX_BOT_H}, |
| 705 |
{SB_SECONDARY_W_BOX_LEFT_H,SB_SECONDARY_W_BOX_TOP_H,SB_SECONDARY_W_BOX_RIGHT_H,SB_SECONDARY_W_BOX_BOT_H}, |
| 706 |
}}} |
| 707 |
}}} |
| 708 |
}}}; |
| 709 |
|
| 710 |
struct d_gauge_span |
| 711 |
{ |
| 712 |
uint16_t l, r; |
| 713 |
}; |
| 714 |
|
| 715 |
struct dspan |
| 716 |
{ |
| 717 |
d_gauge_span l, r; |
| 718 |
}; |
| 719 |
|
| 720 |
//store delta x values from left of box |
| 721 |
constexpr std::array<dspan, 43> weapon_windows_lowres = {{ |
| 722 |
{{71,114}, {208,255}}, |
| 723 |
{{69,116}, {206,257}}, |
| 724 |
{{68,117}, {205,258}}, |
| 725 |
{{66,118}, {204,259}}, |
| 726 |
{{66,119}, {203,260}}, |
| 727 |
{{66,119}, {203,260}}, |
| 728 |
{{65,119}, {203,260}}, |
| 729 |
{{65,119}, {203,260}}, |
| 730 |
{{65,119}, {203,260}}, |
| 731 |
{{65,119}, {203,261}}, |
| 732 |
{{65,119}, {203,261}}, |
| 733 |
{{65,119}, {203,261}}, |
| 734 |
{{65,119}, {203,261}}, |
| 735 |
{{65,119}, {203,261}}, |
| 736 |
{{65,119}, {203,261}}, |
| 737 |
{{64,119}, {203,261}}, |
| 738 |
{{64,119}, {203,261}}, |
| 739 |
{{64,119}, {203,261}}, |
| 740 |
{{64,119}, {203,262}}, |
| 741 |
{{64,119}, {203,262}}, |
| 742 |
{{64,119}, {203,262}}, |
| 743 |
{{64,119}, {203,262}}, |
| 744 |
{{64,119}, {203,262}}, |
| 745 |
{{64,119}, {203,262}}, |
| 746 |
{{63,119}, {203,262}}, |
| 747 |
{{63,118}, {203,262}}, |
| 748 |
{{63,118}, {204,263}}, |
| 749 |
{{63,118}, {204,263}}, |
| 750 |
{{63,118}, {204,263}}, |
| 751 |
{{63,118}, {204,263}}, |
| 752 |
{{63,118}, {204,263}}, |
| 753 |
{{63,118}, {204,263}}, |
| 754 |
{{63,118}, {204,263}}, |
| 755 |
{{63,118}, {204,263}}, |
| 756 |
{{63,118}, {204,263}}, |
| 757 |
{{63,118}, {204,263}}, |
| 758 |
{{63,118}, {204,263}}, |
| 759 |
{{63,117}, {204,263}}, |
| 760 |
{{63,117}, {205,263}}, |
| 761 |
{{64,116}, {206,262}}, |
| 762 |
{{65,115}, {207,261}}, |
| 763 |
{{66,113}, {208,260}}, |
| 764 |
{{68,111}, {211,255}}, |
| 765 |
}}; |
| 766 |
|
| 767 |
//store delta x values from left of box |
| 768 |
constexpr std::array<dspan, 107> weapon_windows_hires = {{ |
| 769 |
{{141,231}, {416,509}}, |
| 770 |
{{139,234}, {413,511}}, |
| 771 |
{{137,235}, {412,513}}, |
| 772 |
{{136,237}, {410,514}}, |
| 773 |
{{135,238}, {409,515}}, |
| 774 |
{{134,239}, {408,516}}, |
| 775 |
{{133,240}, {407,517}}, |
| 776 |
{{132,240}, {407,518}}, |
| 777 |
{{131,241}, {406,519}}, |
| 778 |
{{131,241}, {406,519}}, |
| 779 |
{{130,242}, {405,520}}, |
| 780 |
{{129,242}, {405,521}}, |
| 781 |
{{129,242}, {405,521}}, |
| 782 |
{{129,243}, {404,521}}, |
| 783 |
{{128,243}, {404,522}}, |
| 784 |
{{128,243}, {404,522}}, |
| 785 |
{{128,243}, {404,522}}, |
| 786 |
{{128,243}, {404,522}}, |
| 787 |
{{128,243}, {404,522}}, |
| 788 |
{{127,243}, {404,523}}, |
| 789 |
{{127,243}, {404,523}}, |
| 790 |
{{127,243}, {404,523}}, |
| 791 |
{{127,243}, {404,523}}, |
| 792 |
{{127,243}, {404,523}}, |
| 793 |
{{127,243}, {404,523}}, |
| 794 |
{{127,243}, {404,523}}, |
| 795 |
{{127,243}, {404,523}}, |
| 796 |
{{127,243}, {404,523}}, |
| 797 |
{{127,243}, {404,523}}, |
| 798 |
{{126,243}, {404,524}}, |
| 799 |
{{126,243}, {404,524}}, |
| 800 |
{{126,243}, {404,524}}, |
| 801 |
{{126,243}, {404,524}}, |
| 802 |
{{126,242}, {405,524}}, |
| 803 |
{{126,242}, {405,524}}, |
| 804 |
{{126,242}, {405,524}}, |
| 805 |
{{126,242}, {405,524}}, |
| 806 |
{{126,242}, {405,524}}, |
| 807 |
{{126,242}, {405,524}}, |
| 808 |
{{125,242}, {405,525}}, |
| 809 |
{{125,242}, {405,525}}, |
| 810 |
{{125,242}, {405,525}}, |
| 811 |
{{125,242}, {405,525}}, |
| 812 |
{{125,242}, {405,525}}, |
| 813 |
{{125,242}, {405,525}}, |
| 814 |
{{125,242}, {405,525}}, |
| 815 |
{{125,242}, {405,525}}, |
| 816 |
{{125,242}, {405,525}}, |
| 817 |
{{125,242}, {405,525}}, |
| 818 |
{{124,242}, {405,526}}, |
| 819 |
{{124,242}, {405,526}}, |
| 820 |
{{124,241}, {406,526}}, |
| 821 |
{{124,241}, {406,526}}, |
| 822 |
{{124,241}, {406,526}}, |
| 823 |
{{124,241}, {406,526}}, |
| 824 |
{{124,241}, {406,526}}, |
| 825 |
{{124,241}, {406,526}}, |
| 826 |
{{124,241}, {406,526}}, |
| 827 |
{{124,241}, {406,526}}, |
| 828 |
{{124,241}, {406,527}}, |
| 829 |
{{123,241}, {406,527}}, |
| 830 |
{{123,241}, {406,527}}, |
| 831 |
{{123,241}, {406,527}}, |
| 832 |
{{123,241}, {406,527}}, |
| 833 |
{{123,241}, {406,527}}, |
| 834 |
{{123,241}, {406,527}}, |
| 835 |
{{123,241}, {406,527}}, |
| 836 |
{{123,241}, {406,527}}, |
| 837 |
{{123,241}, {406,527}}, |
| 838 |
{{123,241}, {406,527}}, |
| 839 |
{{123,241}, {406,527}}, |
| 840 |
{{123,241}, {406,527}}, |
| 841 |
{{122,241}, {406,528}}, |
| 842 |
{{122,241}, {406,528}}, |
| 843 |
{{122,240}, {407,528}}, |
| 844 |
{{122,240}, {407,528}}, |
| 845 |
{{122,240}, {407,528}}, |
| 846 |
{{122,240}, {407,528}}, |
| 847 |
{{122,240}, {407,528}}, |
| 848 |
{{122,240}, {407,528}}, |
| 849 |
{{122,240}, {407,528}}, |
| 850 |
{{122,240}, {407,529}}, |
| 851 |
{{121,240}, {407,529}}, |
| 852 |
{{121,240}, {407,529}}, |
| 853 |
{{121,240}, {407,529}}, |
| 854 |
{{121,240}, {407,529}}, |
| 855 |
{{121,240}, {407,529}}, |
| 856 |
{{121,240}, {407,529}}, |
| 857 |
{{121,240}, {407,529}}, |
| 858 |
{{121,239}, {408,529}}, |
| 859 |
{{121,239}, {408,529}}, |
| 860 |
{{121,239}, {408,529}}, |
| 861 |
{{121,238}, {409,529}}, |
| 862 |
{{121,238}, {409,529}}, |
| 863 |
{{121,238}, {409,529}}, |
| 864 |
{{122,237}, {410,529}}, |
| 865 |
{{122,237}, {410,528}}, |
| 866 |
{{123,236}, {411,527}}, |
| 867 |
{{123,235}, {412,527}}, |
| 868 |
{{124,234}, {413,526}}, |
| 869 |
{{125,233}, {414,525}}, |
| 870 |
{{126,232}, {415,524}}, |
| 871 |
{{126,231}, {416,524}}, |
| 872 |
{{128,230}, {417,522}}, |
| 873 |
{{130,228}, {419,521}}, |
| 874 |
{{131,226}, {422,519}}, |
| 875 |
{{133,223}, {424,518}}, |
| 876 |
}}; |
| 877 |
|
| 878 |
struct gauge_inset_window |
| 879 |
{ |
| 880 |
fix fade_value{}; |
| 881 |
weapon_index old_weapon{}; |
| 882 |
weapon_box_state box_state{weapon_box_state::set}; |
| 883 |
#if DXX_BUILD_DESCENT == 2 |
| 884 |
weapon_box_user user{weapon_box_user::weapon}; |
| 885 |
uint8_t overlap_dirty{}; |
| 886 |
fix time_static_played{}; |
| 887 |
#endif |
| 888 |
}; |
| 889 |
|
| 890 |
enumerated_array<gauge_inset_window, 2, gauge_inset_window_view> inset_window; |
| 891 |
|
| 892 |
static inline void hud_bitblt_free(grs_canvas &canvas, const unsigned x, const unsigned y, const unsigned w, const unsigned h, grs_bitmap &bm) |
| 893 |
{ |
| 894 |
#if DXX_USE_OGL |
| 895 |
ogl_ubitmapm_cs(canvas, x, y, w, h, bm, ogl_colors::white); |
| 896 |
#else |
| 897 |
gr_ubitmapm(canvas, x, y, bm); |
| 898 |
#endif |
| 899 |
} |
| 900 |
|
| 901 |
static void hud_bitblt_scaled_xy(const hud_draw_context_hs hudctx, const unsigned x, const unsigned y, grs_bitmap &bm) |
| 902 |
{ |
| 903 |
hud_bitblt_free(hudctx.canvas, x, y, hudctx.xscale(bm.bm_w), hudctx.yscale(bm.bm_h), bm); |
| 904 |
} |
| 905 |
|
| 906 |
static void hud_bitblt(const hud_draw_context_hs hudctx, const unsigned x, const unsigned y, grs_bitmap &bm) |
| 907 |
{ |
| 908 |
hud_bitblt_scaled_xy(hudctx, hudctx.xscale(x), hudctx.yscale(y), bm); |
| 909 |
} |
| 910 |
|
| 911 |
} |
| 912 |
|
| 913 |
} |
| 914 |
|
| 915 |
namespace dsx { |
| 916 |
|
| 917 |
namespace { |
| 918 |
|
| 919 |
#if DXX_BUILD_DESCENT == 1 |
| 920 |
#define hud_gauge_bitblt_draw_context hud_draw_context_hs |
| 921 |
#elif DXX_BUILD_DESCENT == 2 |
| 922 |
#define hud_gauge_bitblt_draw_context hud_draw_context_hs_mr |
| 923 |
#endif |
| 924 |
static void hud_gauge_bitblt(const hud_gauge_bitblt_draw_context hudctx, const unsigned x, const unsigned y, const unsigned gauge) |
| 925 |
{ |
| 926 |
#if DXX_BUILD_DESCENT == 2 |
| 927 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 928 |
#endif |
| 929 |
PAGE_IN_GAUGE(gauge, multires_gauge_graphic); |
| 930 |
hud_bitblt(hudctx, x, y, GameBitmaps[GET_GAUGE_INDEX(gauge)]); |
| 931 |
} |
| 932 |
|
| 933 |
class draw_keys_state |
| 934 |
{ |
| 935 |
const hud_draw_context_hs_mr hudctx; |
| 936 |
const player_flags player_key_flags; |
| 937 |
public: |
| 938 |
draw_keys_state(const hud_draw_context_hs_mr hc, const player_flags f) : |
| 939 |
hudctx(hc), player_key_flags(f) |
| 940 |
{ |
| 941 |
} |
| 942 |
void draw_all_cockpit_keys(); |
| 943 |
void draw_all_statusbar_keys(); |
| 944 |
protected: |
| 945 |
void draw_one_key(const unsigned x, const unsigned y, const unsigned gauge, const PLAYER_FLAG flag) const |
| 946 |
{ |
| 947 |
hud_gauge_bitblt(hudctx, x, y, (player_key_flags & flag) ? gauge : (gauge + 3)); |
| 948 |
} |
| 949 |
}; |
| 950 |
|
| 951 |
} |
| 952 |
|
| 953 |
} |
| 954 |
|
| 955 |
namespace { |
| 956 |
|
| 957 |
static void hud_show_score(grs_canvas &canvas, const player_info &player_info, const game_mode_flags Game_mode) |
| 958 |
{ |
| 959 |
char score_str[20]; |
| 960 |
|
| 961 |
if (HUD_toolong) |
| 962 |
return; |
| 963 |
|
| 964 |
const char *label; |
| 965 |
int value; |
| 966 |
if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) |
| 967 |
{ |
| 968 |
label = TXT_KILLS; |
| 969 |
value = player_info.net_kills_total; |
| 970 |
} else { |
| 971 |
label = TXT_SCORE; |
| 972 |
value = player_info.mission.score; |
| 973 |
} |
| 974 |
snprintf(score_str, sizeof(score_str), "%s: %5d", label, value); |
| 975 |
|
| 976 |
if (Color_0_31_0 == -1) |
| 977 |
Color_0_31_0 = BM_XRGB(0,31,0); |
| 978 |
gr_set_fontcolor(canvas, Color_0_31_0, -1); |
| 979 |
|
| 980 |
auto &game_font = *GAME_FONT; |
| 981 |
const auto &&[w, h] = gr_get_string_size(game_font, score_str); |
| 982 |
gr_string(canvas, game_font, canvas.cv_bitmap.bm_w - w - FSPACX(1), FSPACY(1), score_str, w, h); |
| 983 |
} |
| 984 |
|
| 985 |
static void hud_show_timer_count(grs_canvas &canvas, const game_mode_flags Game_mode) |
| 986 |
{ |
| 987 |
auto &LevelUniqueControlCenterState = LevelUniqueObjectState.ControlCenterState; |
| 988 |
|
| 989 |
if (HUD_toolong) |
| 990 |
return; |
| 991 |
|
| 992 |
if (!(Game_mode & GM_NETWORK)) |
| 993 |
return; |
| 994 |
|
| 995 |
if (!Netgame.PlayTimeAllowed.count()) |
| 996 |
return; |
| 997 |
|
| 998 |
if (LevelUniqueControlCenterState.Control_center_destroyed) |
| 999 |
return; |
| 1000 |
|
| 1001 |
if (Netgame.PlayTimeAllowed < ThisLevelTime) |
| 1002 |
return; |
| 1003 |
|
| 1004 |
const auto TicksUntilPlayTimeAllowedElapses = Netgame.PlayTimeAllowed - ThisLevelTime; |
| 1005 |
const auto SecondsUntilPlayTimeAllowedElapses = f2i(TicksUntilPlayTimeAllowedElapses.count()); |
| 1006 |
if (SecondsUntilPlayTimeAllowedElapses >= 0) |
| 1007 |
{ |
| 1008 |
if (Color_0_31_0 == -1) |
| 1009 |
Color_0_31_0 = BM_XRGB(0,31,0); |
| 1010 |
|
| 1011 |
gr_set_fontcolor(canvas, Color_0_31_0, -1); |
| 1012 |
|
| 1013 |
char score_str[20]; |
| 1014 |
snprintf(score_str, sizeof(score_str), "T - %5d", SecondsUntilPlayTimeAllowedElapses + 1); |
| 1015 |
const auto &&[w, h] = gr_get_string_size(*canvas.cv_font, score_str); |
| 1016 |
gr_string(canvas, *canvas.cv_font, canvas.cv_bitmap.bm_w - w - FSPACX(12), LINE_SPACING(*canvas.cv_font, *GAME_FONT) + FSPACY(1), score_str, w, h); |
| 1017 |
} |
| 1018 |
} |
| 1019 |
|
| 1020 |
static void hud_show_score_added(grs_canvas &canvas, const game_mode_flags Game_mode) |
| 1021 |
{ |
| 1022 |
int color; |
| 1023 |
|
| 1024 |
if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) |
| 1025 |
return; |
| 1026 |
|
| 1027 |
if (score_display == 0) |
| 1028 |
return; |
| 1029 |
|
| 1030 |
score_time -= FrameTime; |
| 1031 |
if (score_time > 0) { |
| 1032 |
color = f2i(score_time * 20) + 12; |
| 1033 |
|
| 1034 |
if (color < 10) color = 12; |
| 1035 |
if (color > 31) color = 30; |
| 1036 |
|
| 1037 |
color = color - (color % 4); |
| 1038 |
|
| 1039 |
char score_buf[32]; |
| 1040 |
const auto score_str = cheats.enabled |
| 1041 |
? TXT_CHEATER |
| 1042 |
: (snprintf(score_buf, sizeof(score_buf), "%5d", score_display), score_buf); |
| 1043 |
|
| 1044 |
gr_set_fontcolor(canvas, BM_XRGB(0, color, 0), -1); |
| 1045 |
auto &game_font = *GAME_FONT; |
| 1046 |
const auto &&[w, h] = gr_get_string_size(game_font, score_str); |
| 1047 |
gr_string(canvas, game_font, canvas.cv_bitmap.bm_w - w - FSPACX(PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen ? 1 : 12), LINE_SPACING(game_font, game_font) + FSPACY(1), score_str, w, h); |
| 1048 |
} else { |
| 1049 |
score_time = 0; |
| 1050 |
score_display = 0; |
| 1051 |
} |
| 1052 |
} |
| 1053 |
|
| 1054 |
static void sb_show_score(const hud_draw_context_hs_mr hudctx, const player_info &player_info, const bool is_multiplayer_non_cooperative) |
| 1055 |
{ |
| 1056 |
char score_str[20]; |
| 1057 |
|
| 1058 |
auto &canvas = hudctx.canvas; |
| 1059 |
gr_set_fontcolor(canvas, BM_XRGB(0, 20, 0), -1); |
| 1060 |
|
| 1061 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 1062 |
const auto y = hudctx.yscale(SB_SCORE_Y); |
| 1063 |
auto &game_font = *GAME_FONT; |
| 1064 |
gr_printf(canvas, game_font, hudctx.xscale(SB_SCORE_LABEL_X), y, "%s:", is_multiplayer_non_cooperative ? TXT_KILLS : TXT_SCORE); |
| 1065 |
|
| 1066 |
snprintf(score_str, sizeof(score_str), "%5d", |
| 1067 |
is_multiplayer_non_cooperative |
| 1068 |
? player_info.net_kills_total |
| 1069 |
: (gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1), player_info.mission.score)); |
| 1070 |
const auto &&[w, h] = gr_get_string_size(game_font, score_str); |
| 1071 |
|
| 1072 |
const auto scaled_score_right = hudctx.xscale(SB_SCORE_RIGHT); |
| 1073 |
const auto x = scaled_score_right - w - FSPACX(1); |
| 1074 |
|
| 1075 |
//erase old score |
| 1076 |
const uint8_t color = BM_XRGB(0, 0, 0); |
| 1077 |
gr_rect(canvas, x, y, scaled_score_right, y + LINE_SPACING(game_font, game_font), color); |
| 1078 |
|
| 1079 |
gr_string(canvas, game_font, x, y, score_str, w, h); |
| 1080 |
} |
| 1081 |
|
| 1082 |
static void sb_show_score_added(const hud_draw_context_hs_mr hudctx) |
| 1083 |
{ |
| 1084 |
static int x; |
| 1085 |
static int last_score_display = -1; |
| 1086 |
|
| 1087 |
if (score_display == 0) |
| 1088 |
return; |
| 1089 |
|
| 1090 |
auto &canvas = hudctx.canvas; |
| 1091 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 1092 |
|
| 1093 |
score_time -= FrameTime; |
| 1094 |
if (score_time > 0) { |
| 1095 |
if (score_display != last_score_display) |
| 1096 |
last_score_display = score_display; |
| 1097 |
|
| 1098 |
int color; |
| 1099 |
color = f2i(score_time * 20) + 10; |
| 1100 |
|
| 1101 |
if (color < 10) color = 10; |
| 1102 |
if (color > 31) color = 31; |
| 1103 |
|
| 1104 |
char score_buf[32]; |
| 1105 |
const auto score_str = cheats.enabled |
| 1106 |
? TXT_CHEATER |
| 1107 |
: (snprintf(score_buf, sizeof(score_buf), "%5d", score_display), score_buf); |
| 1108 |
|
| 1109 |
auto &game_font = *GAME_FONT; |
| 1110 |
const auto &&[w, h] = gr_get_string_size(game_font, score_str); |
| 1111 |
x = hudctx.xscale(SB_SCORE_ADDED_RIGHT) - w - FSPACX(1); |
| 1112 |
gr_set_fontcolor(canvas, BM_XRGB(0, color, 0), -1); |
| 1113 |
gr_string(canvas, game_font, x, hudctx.yscale(SB_SCORE_ADDED_Y), score_str, w, h); |
| 1114 |
} else { |
| 1115 |
//erase old score |
| 1116 |
const uint8_t color = BM_XRGB(0, 0, 0); |
| 1117 |
const auto scaled_score_y = hudctx.yscale(SB_SCORE_ADDED_Y); |
| 1118 |
gr_rect(canvas, x, scaled_score_y, hudctx.xscale(SB_SCORE_ADDED_RIGHT), scaled_score_y + LINE_SPACING(*canvas.cv_font, *GAME_FONT), color); |
| 1119 |
score_time = 0; |
| 1120 |
score_display = 0; |
| 1121 |
} |
| 1122 |
} |
| 1123 |
|
| 1124 |
} |
| 1125 |
|
| 1126 |
namespace dsx { |
| 1127 |
|
| 1128 |
// ----------------------------------------------------------------------------- |
| 1129 |
void play_homing_warning(const player_info &player_info) |
| 1130 |
{ |
| 1131 |
fix beep_delay; |
| 1132 |
static fix64 Last_warning_beep_time = 0; // Time we last played homing missile warning beep. |
| 1133 |
|
| 1134 |
if (Endlevel_sequence || Player_dead_state != player_dead_state::no) |
| 1135 |
return; |
| 1136 |
|
| 1137 |
const auto homing_object_dist = player_info.homing_object_dist; |
| 1138 |
if (homing_object_dist >= 0) { |
| 1139 |
beep_delay = homing_object_dist / 128; |
| 1140 |
if (beep_delay > F1_0) |
| 1141 |
beep_delay = F1_0; |
| 1142 |
else if (beep_delay < F1_0/8) |
| 1143 |
beep_delay = F1_0/8; |
| 1144 |
|
| 1145 |
if (GameTime64 - Last_warning_beep_time > beep_delay/2 || Last_warning_beep_time > GameTime64) { |
| 1146 |
Last_warning_beep_time = {GameTime64}; |
| 1147 |
digi_play_sample( sound_effect::SOUND_HOMING_WARNING, F1_0 ); |
| 1148 |
} |
| 1149 |
} |
| 1150 |
} |
| 1151 |
|
| 1152 |
} |
| 1153 |
|
| 1154 |
namespace { |
| 1155 |
|
| 1156 |
// ----------------------------------------------------------------------------- |
| 1157 |
static void show_homing_warning(const hud_draw_context_hs_mr hudctx, const int homing_object_dist) |
| 1158 |
{ |
| 1159 |
unsigned gauge; |
| 1160 |
if (Endlevel_sequence) |
| 1161 |
{ |
| 1162 |
gauge = GAUGE_HOMING_WARNING_OFF; |
| 1163 |
} |
| 1164 |
else |
| 1165 |
{ |
| 1166 |
gauge = ((GameTime64 & 0x4000) && homing_object_dist >= 0) |
| 1167 |
? GAUGE_HOMING_WARNING_ON |
| 1168 |
: GAUGE_HOMING_WARNING_OFF; |
| 1169 |
} |
| 1170 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 1171 |
hud_gauge_bitblt(hudctx, HOMING_WARNING_X, HOMING_WARNING_Y, gauge); |
| 1172 |
} |
| 1173 |
|
| 1174 |
static void hud_show_homing_warning(grs_canvas &canvas, const int homing_object_dist) |
| 1175 |
{ |
| 1176 |
if (homing_object_dist >= 0) |
| 1177 |
{ |
| 1178 |
if (GameTime64 & 0x4000) { |
| 1179 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 1180 |
auto &game_font = *GAME_FONT; |
| 1181 |
gr_string(canvas, game_font, 0x8000, canvas.cv_bitmap.bm_h - LINE_SPACING(*canvas.cv_font, *GAME_FONT), TXT_LOCK); |
| 1182 |
} |
| 1183 |
} |
| 1184 |
} |
| 1185 |
|
| 1186 |
static void hud_show_keys(const hud_draw_context_mr hudctx, const hud_ar_scale_float hud_scale_ar, const player_info &player_info) |
| 1187 |
{ |
| 1188 |
const auto player_key_flags = player_info.powerup_flags; |
| 1189 |
if (!(player_key_flags & (PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_GOLD_KEY | PLAYER_FLAGS_RED_KEY))) |
| 1190 |
return; |
| 1191 |
class gauge_key |
| 1192 |
{ |
| 1193 |
grs_bitmap *const bm; |
| 1194 |
public: |
| 1195 |
gauge_key(const unsigned key_icon, const local_multires_gauge_graphic multires_gauge_graphic) : |
| 1196 |
bm(&GameBitmaps[(static_cast<void>(multires_gauge_graphic), PAGE_IN_GAUGE(key_icon, multires_gauge_graphic), GET_GAUGE_INDEX(key_icon))]) |
| 1197 |
{ |
| 1198 |
} |
| 1199 |
grs_bitmap *operator->() const |
| 1200 |
{ |
| 1201 |
return bm; |
| 1202 |
} |
| 1203 |
operator grs_bitmap &() const |
| 1204 |
{ |
| 1205 |
return *bm; |
| 1206 |
} |
| 1207 |
}; |
| 1208 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 1209 |
const gauge_key blue(KEY_ICON_BLUE, multires_gauge_graphic); |
| 1210 |
const unsigned y = hud_scale_ar(GameBitmaps[ GET_GAUGE_INDEX(GAUGE_LIVES) ].bm_h + 2) + FSPACY(1); |
| 1211 |
|
| 1212 |
const unsigned blue_bitmap_width = blue->bm_w; |
| 1213 |
const auto &&fspacx2 = FSPACX(2); |
| 1214 |
auto &canvas = hudctx.canvas; |
| 1215 |
if (player_key_flags & PLAYER_FLAGS_BLUE_KEY) |
| 1216 |
hud_bitblt_free(canvas, fspacx2, y, hud_scale_ar(blue_bitmap_width), hud_scale_ar(blue->bm_h), blue); |
| 1217 |
|
| 1218 |
if (!(player_key_flags & (PLAYER_FLAGS_GOLD_KEY | PLAYER_FLAGS_RED_KEY))) |
| 1219 |
return; |
| 1220 |
const gauge_key yellow(KEY_ICON_YELLOW, multires_gauge_graphic); |
| 1221 |
const unsigned yellow_bitmap_width = yellow->bm_w; |
| 1222 |
if (player_key_flags & PLAYER_FLAGS_GOLD_KEY) |
| 1223 |
hud_bitblt_free(canvas, fspacx2 + hud_scale_ar(blue_bitmap_width + 3), y, hud_scale_ar(yellow_bitmap_width), hud_scale_ar(yellow->bm_h), yellow); |
| 1224 |
|
| 1225 |
if (player_key_flags & PLAYER_FLAGS_RED_KEY) |
| 1226 |
{ |
| 1227 |
const gauge_key red(KEY_ICON_RED, multires_gauge_graphic); |
| 1228 |
hud_bitblt_free(canvas, fspacx2 + hud_scale_ar(blue_bitmap_width + yellow_bitmap_width + 6), y, hud_scale_ar(red->bm_w), hud_scale_ar(red->bm_h), red); |
| 1229 |
} |
| 1230 |
} |
| 1231 |
|
| 1232 |
#if DXX_BUILD_DESCENT == 2 |
| 1233 |
static void hud_show_orbs(grs_canvas &canvas, const player_info &player_info, const local_multires_gauge_graphic multires_gauge_graphic) |
| 1234 |
{ |
| 1235 |
if (game_mode_hoard(Game_mode)) |
| 1236 |
{ |
| 1237 |
const auto &&fspacy1 = FSPACY(1); |
| 1238 |
int x, y = LINE_SPACING(*canvas.cv_font, *GAME_FONT) + fspacy1; |
| 1239 |
const auto &&hud_scale_ar = HUD_SCALE_AR(grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height(), multires_gauge_graphic); |
| 1240 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_cockpit) |
| 1241 |
{ |
| 1242 |
x = (SWIDTH/18); |
| 1243 |
} |
| 1244 |
else |
| 1245 |
{ |
| 1246 |
x = FSPACX(2); |
| 1247 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) |
| 1248 |
{ |
| 1249 |
} |
| 1250 |
else if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen) |
| 1251 |
{ |
| 1252 |
y = hud_scale_ar(GameBitmaps[ GET_GAUGE_INDEX(GAUGE_LIVES) ].bm_h + GameBitmaps[ GET_GAUGE_INDEX(KEY_ICON_RED) ].bm_h + 4) + fspacy1; |
| 1253 |
} |
| 1254 |
else |
| 1255 |
{ |
| 1256 |
Int3(); //what sort of cockpit? |
| 1257 |
return; |
| 1258 |
} |
| 1259 |
} |
| 1260 |
|
| 1261 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 1262 |
auto &bm = Orb_icons[multires_gauge_graphic.is_hires()]; |
| 1263 |
const auto &&scaled_width = hud_scale_ar(bm.bm_w); |
| 1264 |
hud_bitblt_free(canvas, x, y, scaled_width, hud_scale_ar(bm.bm_h), bm); |
| 1265 |
gr_printf(canvas, *canvas.cv_font, x + scaled_width, y, " x %d", player_info.hoard.orbs); |
| 1266 |
} |
| 1267 |
} |
| 1268 |
|
| 1269 |
static void hud_show_flag(grs_canvas &canvas, const player_info &player_info, const local_multires_gauge_graphic multires_gauge_graphic) |
| 1270 |
{ |
| 1271 |
if (game_mode_capture_flag(Game_mode) && (player_info.powerup_flags & PLAYER_FLAGS_FLAG)) |
| 1272 |
{ |
| 1273 |
int x, y = GameBitmaps[ GET_GAUGE_INDEX(GAUGE_LIVES) ].bm_h + 2, icon; |
| 1274 |
const auto &&fspacy1 = FSPACY(1); |
| 1275 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_cockpit) |
| 1276 |
{ |
| 1277 |
x = (SWIDTH/10); |
| 1278 |
} |
| 1279 |
else |
| 1280 |
{ |
| 1281 |
x = FSPACX(2); |
| 1282 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) |
| 1283 |
{ |
| 1284 |
} |
| 1285 |
else if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen) |
| 1286 |
{ |
| 1287 |
y += GameBitmaps[GET_GAUGE_INDEX(KEY_ICON_RED)].bm_h + 2; |
| 1288 |
} |
| 1289 |
else |
| 1290 |
{ |
| 1291 |
Int3(); //what sort of cockpit? |
| 1292 |
return; |
| 1293 |
} |
| 1294 |
} |
| 1295 |
|
| 1296 |
icon = (multi_get_team_from_player(Netgame, Player_num) == team_number::blue) ? FLAG_ICON_RED : FLAG_ICON_BLUE; |
| 1297 |
auto &bm = GameBitmaps[GET_GAUGE_INDEX(icon)]; |
| 1298 |
PAGE_IN_GAUGE(icon, multires_gauge_graphic); |
| 1299 |
const auto &&hud_scale_ar = HUD_SCALE_AR(grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height(), multires_gauge_graphic); |
| 1300 |
hud_bitblt_free(canvas, x, hud_scale_ar(y) + fspacy1, hud_scale_ar(bm.bm_w), hud_scale_ar(bm.bm_h), bm); |
| 1301 |
} |
| 1302 |
} |
| 1303 |
#endif |
| 1304 |
|
| 1305 |
static void hud_show_energy(grs_canvas &canvas, const player_info &player_info, const grs_font &game_font, const unsigned current_y) |
| 1306 |
{ |
| 1307 |
auto &energy = player_info.energy; |
| 1308 |
if (PlayerCfg.HudMode == HudType::Standard || PlayerCfg.HudMode == HudType::Alternate1) |
| 1309 |
{ |
| 1310 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 1311 |
gr_printf(canvas, game_font, FSPACX(1), current_y, "%s: %i", TXT_ENERGY, f2ir(energy)); |
| 1312 |
} |
| 1313 |
|
| 1314 |
if (Newdemo_state == ND_STATE_RECORDING) |
| 1315 |
newdemo_record_player_energy(f2ir(energy)); |
| 1316 |
} |
| 1317 |
|
| 1318 |
#if DXX_BUILD_DESCENT == 1 |
| 1319 |
#define convert_1s(s) |
| 1320 |
#elif DXX_BUILD_DESCENT == 2 |
| 1321 |
static void hud_show_afterburner(grs_canvas &canvas, const player_info &player_info, const grs_font &game_font, const unsigned current_y) |
| 1322 |
{ |
| 1323 |
if (! (player_info.powerup_flags & PLAYER_FLAGS_AFTERBURNER)) |
| 1324 |
return; //don't draw if don't have |
| 1325 |
|
| 1326 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 1327 |
gr_printf(canvas, game_font, FSPACX(1), current_y, "burn: %d%%" , fixmul(Afterburner_charge, 100)); |
| 1328 |
|
| 1329 |
if (Newdemo_state==ND_STATE_RECORDING ) |
| 1330 |
newdemo_record_player_afterburner(Afterburner_charge); |
| 1331 |
} |
| 1332 |
|
| 1333 |
//convert '1' characters to special wide ones |
| 1334 |
#define convert_1s(s) do {char *p=s; while ((p=strchr(p,'1')) != NULL) *p=132;} while(0) |
| 1335 |
#endif |
| 1336 |
|
| 1337 |
[[nodiscard]] |
| 1338 |
static constexpr const char *SECONDARY_WEAPON_NAMES_VERY_SHORT(const secondary_weapon_index_t u) |
| 1339 |
{ |
| 1340 |
switch(u) |
| 1341 |
{ |
| 1342 |
default: |
| 1343 |
Int3(); |
| 1344 |
[[fallthrough]]; |
| 1345 |
case secondary_weapon_index_t::CONCUSSION_INDEX: return TXT_CONCUSSION; |
| 1346 |
case secondary_weapon_index_t::HOMING_INDEX: return TXT_HOMING; |
| 1347 |
case secondary_weapon_index_t::PROXIMITY_INDEX: return TXT_PROXBOMB; |
| 1348 |
case secondary_weapon_index_t::SMART_INDEX: return TXT_SMART; |
| 1349 |
case secondary_weapon_index_t::MEGA_INDEX: return TXT_MEGA; |
| 1350 |
#if DXX_BUILD_DESCENT == 2 |
| 1351 |
case secondary_weapon_index_t::SMISSILE1_INDEX: return "Flash"; |
| 1352 |
case secondary_weapon_index_t::GUIDED_INDEX: return "Guided"; |
| 1353 |
case secondary_weapon_index_t::SMART_MINE_INDEX: return "SmrtMine"; |
| 1354 |
case secondary_weapon_index_t::SMISSILE4_INDEX: return "Mercury"; |
| 1355 |
case secondary_weapon_index_t::SMISSILE5_INDEX: return "Shaker"; |
| 1356 |
#endif |
| 1357 |
} |
| 1358 |
} |
| 1359 |
|
| 1360 |
} |
| 1361 |
|
| 1362 |
namespace dsx { |
| 1363 |
|
| 1364 |
namespace { |
| 1365 |
|
| 1366 |
static void show_bomb_count(grs_canvas &canvas, const player_info &player_info, const int x, const int y, const int bg_color, const int always_show, const int right_align) |
| 1367 |
{ |
| 1368 |
#if DXX_BUILD_DESCENT == 1 |
| 1369 |
if (!PlayerCfg.BombGauge) |
| 1370 |
return; |
| 1371 |
#endif |
| 1372 |
|
| 1373 |
const auto bomb = which_bomb(player_info); |
| 1374 |
int count = player_info.secondary_ammo[bomb]; |
| 1375 |
|
| 1376 |
count = min(count,99); //only have room for 2 digits - cheating give 200 |
| 1377 |
|
| 1378 |
if (always_show && count == 0) //no bombs, draw nothing on HUD |
| 1379 |
return; |
| 1380 |
|
| 1381 |
gr_set_fontcolor(canvas, count |
| 1382 |
? (bomb == secondary_weapon_index_t::PROXIMITY_INDEX |
| 1383 |
? gr_find_closest_color(55, 0, 0) |
| 1384 |
: BM_XRGB(59, 50, 21) |
| 1385 |
) |
| 1386 |
: bg_color, //erase by drawing in background color |
| 1387 |
bg_color); |
| 1388 |
|
| 1389 |
char txt[5]; |
| 1390 |
snprintf(txt, sizeof(txt), "B:%02d", count); |
| 1391 |
//convert to wide '1' |
| 1392 |
std::replace(&txt[2], &txt[4], '1', '\x84'); |
| 1393 |
|
| 1394 |
const auto &&[w, h] = gr_get_string_size(*canvas.cv_font, txt); |
| 1395 |
gr_string(canvas, *canvas.cv_font, right_align ? x - w : x, y, txt, w, h); |
| 1396 |
} |
| 1397 |
} |
| 1398 |
} |
| 1399 |
|
| 1400 |
namespace { |
| 1401 |
static void draw_primary_ammo_info(const hud_draw_context_hs_mr hudctx, const unsigned ammo_count) |
| 1402 |
{ |
| 1403 |
int x, y; |
| 1404 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 1405 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) |
| 1406 |
x = SB_PRIMARY_AMMO_X, y = SB_PRIMARY_AMMO_Y; |
| 1407 |
else |
| 1408 |
x = PRIMARY_AMMO_X, y = PRIMARY_AMMO_Y; |
| 1409 |
draw_ammo_info(hudctx.canvas, hudctx.xscale(x), hudctx.yscale(y), ammo_count); |
| 1410 |
} |
| 1411 |
} |
| 1412 |
|
| 1413 |
namespace dcx { |
| 1414 |
namespace { |
| 1415 |
|
| 1416 |
constexpr rgb_t hud_rgb_red = {40, 0, 0}; |
| 1417 |
constexpr rgb_t hud_rgb_green = {0, 30, 0}; |
| 1418 |
constexpr rgb_t hud_rgb_dimgreen = {0, 12, 0}; |
| 1419 |
constexpr rgb_t hud_rgb_gray = {6, 6, 6}; |
| 1420 |
} |
| 1421 |
} |
| 1422 |
|
| 1423 |
namespace dsx { |
| 1424 |
namespace { |
| 1425 |
|
| 1426 |
#if DXX_BUILD_DESCENT == 2 |
| 1427 |
constexpr rgb_t hud_rgb_yellow = {30, 30, 0}; |
| 1428 |
#endif |
| 1429 |
|
| 1430 |
[[nodiscard]] |
| 1431 |
static rgb_t hud_get_primary_weapon_fontcolor(const player_info &player_info, const primary_weapon_index_t consider_weapon) |
| 1432 |
{ |
| 1433 |
if (player_info.Primary_weapon == consider_weapon) |
| 1434 |
/* The currently active weapon is `consider_weapon` */ |
| 1435 |
return hud_rgb_red; |
| 1436 |
else{ |
| 1437 |
if (has_weapon(player_has_primary_weapon(player_info, consider_weapon))) |
| 1438 |
{ |
| 1439 |
/* The player has not armed this weapon, but could do so. */ |
| 1440 |
#if DXX_BUILD_DESCENT == 2 |
| 1441 |
const auto is_super = is_super_weapon(consider_weapon); |
| 1442 |
const auto base_weapon = is_super ? primary_weapon_index_t{static_cast<uint8_t>(static_cast<uint8_t>(consider_weapon) - SUPER_WEAPON)} : consider_weapon; |
| 1443 |
if (player_info.Primary_last_was_super & HAS_PRIMARY_FLAG(base_weapon)) |
| 1444 |
{ |
| 1445 |
/* The player would select the super-weapon version on next press. */ |
| 1446 |
if (is_super) |
| 1447 |
/* The weapon is a super-weapon, so it would be selected on |
| 1448 |
* next press. |
| 1449 |
*/ |
| 1450 |
return hud_rgb_green; |
| 1451 |
else |
| 1452 |
/* The weapon is not a super-weapon, so the player will |
| 1453 |
* need to press twice to select it (once to make the |
| 1454 |
* non-super active, then again to toggle to super). |
| 1455 |
*/ |
| 1456 |
return hud_rgb_yellow; |
| 1457 |
} |
| 1458 |
/* Else the player will select the non-super weapon on next press */ |
| 1459 |
else if (is_super) |
| 1460 |
/* The candidate weapon is a super-weapon, so the player will |
| 1461 |
* need to press twice to select it. |
| 1462 |
*/ |
| 1463 |
return hud_rgb_yellow; |
| 1464 |
else |
| 1465 |
#endif |
| 1466 |
return hud_rgb_green; |
| 1467 |
} |
| 1468 |
else |
| 1469 |
return hud_rgb_gray; |
| 1470 |
} |
| 1471 |
} |
| 1472 |
|
| 1473 |
static void hud_set_primary_weapon_fontcolor(const player_info &player_info, const primary_weapon_index_t consider_weapon, grs_canvas &canvas) |
| 1474 |
{ |
| 1475 |
auto rgb = hud_get_primary_weapon_fontcolor(player_info, consider_weapon); |
| 1476 |
gr_set_fontcolor(canvas, gr_find_closest_color(rgb.r, rgb.g, rgb.b), -1); |
| 1477 |
} |
| 1478 |
|
| 1479 |
[[nodiscard]] |
| 1480 |
static rgb_t hud_get_secondary_weapon_fontcolor(const player_info &player_info, const secondary_weapon_index_t consider_weapon) |
| 1481 |
{ |
| 1482 |
if (player_info.Secondary_weapon == consider_weapon) |
| 1483 |
/* The currently active weapon is `consider_weapon` */ |
| 1484 |
return hud_rgb_red; |
| 1485 |
else{ |
| 1486 |
if (player_info.secondary_ammo[consider_weapon]) |
| 1487 |
{ |
| 1488 |
/* The player has not armed this weapon, but has ammo for it. */ |
| 1489 |
#if DXX_BUILD_DESCENT == 2 |
| 1490 |
const auto is_super = is_super_weapon(consider_weapon); |
| 1491 |
const auto base_weapon = is_super ? secondary_weapon_index_t{static_cast<uint8_t>(static_cast<uint8_t>(consider_weapon) - SUPER_WEAPON)} : consider_weapon; |
| 1492 |
if (player_info.Secondary_last_was_super & HAS_SECONDARY_FLAG(base_weapon)) |
| 1493 |
{ |
| 1494 |
/* The player would select the super-weapon version on next press. */ |
| 1495 |
if (is_super) |
| 1496 |
/* The weapon is a super-weapon, so it would be selected on |
| 1497 |
* next press. |
| 1498 |
*/ |
| 1499 |
return hud_rgb_green; |
| 1500 |
else |
| 1501 |
/* The weapon is not a super-weapon, so the player will |
| 1502 |
* need to press twice to select it (once to make the |
| 1503 |
* non-super active, then again to toggle to super). |
| 1504 |
*/ |
| 1505 |
return hud_rgb_yellow; |
| 1506 |
} |
| 1507 |
/* Else the player will select the non-super weapon on next press */ |
| 1508 |
else if (is_super) |
| 1509 |
/* The candidate weapon is a super-weapon, so the player will |
| 1510 |
* need to press twice to select it. |
| 1511 |
*/ |
| 1512 |
return hud_rgb_yellow; |
| 1513 |
else |
| 1514 |
#endif |
| 1515 |
return hud_rgb_green; |
| 1516 |
} |
| 1517 |
else |
| 1518 |
/* The weapon has no ammo, so dim it out. */ |
| 1519 |
return hud_rgb_dimgreen; |
| 1520 |
} |
| 1521 |
} |
| 1522 |
|
| 1523 |
static void hud_set_secondary_weapon_fontcolor(const player_info &player_info, const secondary_weapon_index_t consider_weapon, grs_canvas &canvas) |
| 1524 |
{ |
| 1525 |
auto rgb = hud_get_secondary_weapon_fontcolor(player_info, consider_weapon); |
| 1526 |
gr_set_fontcolor(canvas, gr_find_closest_color(rgb.r, rgb.g, rgb.b), -1); |
| 1527 |
} |
| 1528 |
|
| 1529 |
[[nodiscard]] |
| 1530 |
static rgb_t hud_get_vulcan_ammo_fontcolor(const player_info &player_info, const unsigned has_weapon_uses_vulcan_ammo) |
| 1531 |
{ |
| 1532 |
if (weapon_index_uses_vulcan_ammo(player_info.Primary_weapon)) |
| 1533 |
return hud_rgb_red; |
| 1534 |
else if (has_weapon_uses_vulcan_ammo) |
| 1535 |
return hud_rgb_green; |
| 1536 |
else |
| 1537 |
return hud_rgb_gray; |
| 1538 |
} |
| 1539 |
|
| 1540 |
static void hud_set_vulcan_ammo_fontcolor(const player_info &player_info, const unsigned has_weapon_uses_vulcan_ammo, grs_canvas &canvas) |
| 1541 |
{ |
| 1542 |
auto rgb = hud_get_vulcan_ammo_fontcolor(player_info, has_weapon_uses_vulcan_ammo); |
| 1543 |
gr_set_fontcolor(canvas, gr_find_closest_color(rgb.r, rgb.g, rgb.b), -1); |
| 1544 |
} |
| 1545 |
|
| 1546 |
static void hud_printf_vulcan_ammo(grs_canvas &canvas, const player_info &player_info, const int x, const int y) |
| 1547 |
{ |
| 1548 |
const unsigned primary_weapon_flags = player_info.primary_weapon_flags; |
| 1549 |
const auto vulcan_mask{HAS_VULCAN_FLAG}; |
| 1550 |
#if DXX_BUILD_DESCENT == 1 |
| 1551 |
const auto gauss_mask{vulcan_mask}; |
| 1552 |
#elif DXX_BUILD_DESCENT == 2 |
| 1553 |
const auto gauss_mask{HAS_GAUSS_FLAG}; |
| 1554 |
#endif |
| 1555 |
const auto fmt_vulcan_ammo = vulcan_ammo_scale(player_info.vulcan_ammo); |
| 1556 |
const unsigned has_weapon_uses_vulcan_ammo = (primary_weapon_flags & (gauss_mask | vulcan_mask)); |
| 1557 |
if (!has_weapon_uses_vulcan_ammo && !fmt_vulcan_ammo) |
| 1558 |
return; |
| 1559 |
hud_set_vulcan_ammo_fontcolor(player_info, has_weapon_uses_vulcan_ammo, canvas); |
| 1560 |
const char c = |
| 1561 |
#if DXX_BUILD_DESCENT == 2 |
| 1562 |
((primary_weapon_flags & gauss_mask) && ((player_info.Primary_last_was_super & HAS_VULCAN_FLAG) || !(primary_weapon_flags & vulcan_mask))) |
| 1563 |
? 'G' |
| 1564 |
: |
| 1565 |
#endif |
| 1566 |
(primary_weapon_flags & vulcan_mask) |
| 1567 |
? 'V' |
| 1568 |
: 'A' |
| 1569 |
; |
| 1570 |
gr_printf(canvas, *canvas.cv_font, x, y, "%c:%u", c, fmt_vulcan_ammo); |
| 1571 |
} |
| 1572 |
|
| 1573 |
static void hud_show_primary_weapons_mode(grs_canvas &canvas, const player_info &player_info, const int vertical, const int orig_x, const int orig_y) |
| 1574 |
{ |
| 1575 |
int x=orig_x,y=orig_y; |
| 1576 |
|
| 1577 |
const auto &&line_spacing = LINE_SPACING(*canvas.cv_font, *GAME_FONT); |
| 1578 |
if (vertical){ |
| 1579 |
y += line_spacing * 4; |
| 1580 |
} |
| 1581 |
|
| 1582 |
const auto &&fspacx = FSPACX(); |
| 1583 |
const auto &&fspacx3 = fspacx(3); |
| 1584 |
const auto &&fspacy2 = FSPACY(2); |
| 1585 |
{ |
| 1586 |
for (uint_fast32_t ui = 5; ui --;) |
| 1587 |
{ |
| 1588 |
const auto i = static_cast<primary_weapon_index_t>(ui); |
| 1589 |
const char *txtweapon; |
| 1590 |
char weapon_str[10]; |
| 1591 |
hud_set_primary_weapon_fontcolor(player_info, i, canvas); |
| 1592 |
switch(i) |
| 1593 |
{ |
| 1594 |
case primary_weapon_index_t::LASER_INDEX: |
| 1595 |
{ |
| 1596 |
snprintf(weapon_str, sizeof(weapon_str), "%c%u", (player_info.powerup_flags & PLAYER_FLAGS_QUAD_LASERS) ? 'Q' : 'L', static_cast<unsigned>(player_info.laser_level) + 1); |
| 1597 |
txtweapon = weapon_str; |
| 1598 |
} |
| 1599 |
break; |
| 1600 |
case primary_weapon_index_t::VULCAN_INDEX: |
| 1601 |
txtweapon = "V"; |
| 1602 |
break; |
| 1603 |
case primary_weapon_index_t::SPREADFIRE_INDEX: |
| 1604 |
txtweapon = "S"; |
| 1605 |
break; |
| 1606 |
case primary_weapon_index_t::PLASMA_INDEX: |
| 1607 |
txtweapon = "P"; |
| 1608 |
break; |
| 1609 |
case primary_weapon_index_t::FUSION_INDEX: |
| 1610 |
txtweapon = "F"; |
| 1611 |
break; |
| 1612 |
default: |
| 1613 |
continue; |
| 1614 |
} |
| 1615 |
const auto &&[w, h] = gr_get_string_size(*canvas.cv_font, txtweapon); |
| 1616 |
if (vertical){ |
| 1617 |
y -= h + fspacy2; |
| 1618 |
}else |
| 1619 |
x -= w + fspacx3; |
| 1620 |
gr_string(canvas, *canvas.cv_font, x, y, txtweapon, w, h); |
| 1621 |
if (i == primary_weapon_index_t::VULCAN_INDEX) |
| 1622 |
{ |
| 1623 |
/* |
| 1624 |
* In Descent 1, this will always draw the ammo, but the |
| 1625 |
* position depends on fullscreen and, if in fullscreen, |
| 1626 |
* whether in vertical mode. |
| 1627 |
* |
| 1628 |
* In Descent 2, this will draw in non-fullscreen and in |
| 1629 |
* fullscreen non-vertical, but not in fullscreen |
| 1630 |
* vertical. The fullscreen vertical case is handled |
| 1631 |
* specially in a large Descent2 block below. |
| 1632 |
*/ |
| 1633 |
int vx, vy; |
| 1634 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen ? ( |
| 1635 |
vertical ? ( |
| 1636 |
#if DXX_BUILD_DESCENT == 1 |
| 1637 |
vx = x, vy = y, true |
| 1638 |
#else |
| 1639 |
false |
| 1640 |
#endif |
| 1641 |
) : ( |
| 1642 |
vx = x, vy = y - line_spacing, true |
| 1643 |
) |
| 1644 |
) : ( |
| 1645 |
vx = x - (w + fspacx3), vy = y - ((h + fspacy2) * 2), true |
| 1646 |
) |
| 1647 |
) |
| 1648 |
hud_printf_vulcan_ammo(canvas, player_info, vx, vy); |
| 1649 |
} |
| 1650 |
} |
| 1651 |
} |
| 1652 |
#if DXX_BUILD_DESCENT == 2 |
| 1653 |
x = orig_x; |
| 1654 |
y = orig_y; |
| 1655 |
if (vertical) |
| 1656 |
{ |
| 1657 |
x += fspacx(15); |
| 1658 |
y += line_spacing * 4; |
| 1659 |
} |
| 1660 |
else |
| 1661 |
{ |
| 1662 |
y += line_spacing; |
| 1663 |
} |
| 1664 |
|
| 1665 |
{ |
| 1666 |
for (uint_fast32_t ui = 10; ui -- != 5;) |
| 1667 |
{ |
| 1668 |
const auto i = static_cast<primary_weapon_index_t>(ui); |
| 1669 |
const char *txtweapon; |
| 1670 |
char weapon_str[10]; |
| 1671 |
hud_set_primary_weapon_fontcolor(player_info, i, canvas); |
| 1672 |
switch(i) |
| 1673 |
{ |
| 1674 |
case primary_weapon_index_t::SUPER_LASER_INDEX: |
| 1675 |
txtweapon = " "; |
| 1676 |
break; |
| 1677 |
case primary_weapon_index_t::GAUSS_INDEX: |
| 1678 |
txtweapon = "G"; |
| 1679 |
break; |
| 1680 |
case primary_weapon_index_t::HELIX_INDEX: |
| 1681 |
txtweapon = "H"; |
| 1682 |
break; |
| 1683 |
case primary_weapon_index_t::PHOENIX_INDEX: |
| 1684 |
txtweapon = "P"; |
| 1685 |
break; |
| 1686 |
case primary_weapon_index_t::OMEGA_INDEX: |
| 1687 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen && (player_info.primary_weapon_flags & HAS_OMEGA_FLAG)) |
| 1688 |
{ |
| 1689 |
snprintf(weapon_str, sizeof(weapon_str), "O%3i", player_info.Omega_charge * 100 / MAX_OMEGA_CHARGE); |
| 1690 |
txtweapon = weapon_str; |
| 1691 |
} |
| 1692 |
else |
| 1693 |
txtweapon = "O"; |
| 1694 |
break; |
| 1695 |
default: |
| 1696 |
continue; |
| 1697 |
} |
| 1698 |
const auto &&[w, h] = gr_get_string_size(*canvas.cv_font, txtweapon); |
| 1699 |
if (vertical){ |
| 1700 |
y -= h + fspacy2; |
| 1701 |
}else |
| 1702 |
x -= w + fspacx3; |
| 1703 |
if (i == primary_weapon_index_t::SUPER_LASER_INDEX) |
| 1704 |
{ |
| 1705 |
if (vertical && (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen)) |
| 1706 |
hud_printf_vulcan_ammo(canvas, player_info, x, y); |
| 1707 |
continue; |
| 1708 |
} |
| 1709 |
gr_string(canvas, *canvas.cv_font, x, y, txtweapon, w, h); |
| 1710 |
} |
| 1711 |
} |
| 1712 |
#endif |
| 1713 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 1714 |
} |
| 1715 |
|
| 1716 |
static void hud_show_secondary_weapons_mode(grs_canvas &canvas, const player_info &player_info, const unsigned vertical, const int orig_x, const int orig_y) |
| 1717 |
{ |
| 1718 |
int x=orig_x,y=orig_y; |
| 1719 |
|
| 1720 |
const auto &&line_spacing = LINE_SPACING(*canvas.cv_font, *GAME_FONT); |
| 1721 |
if (vertical){ |
| 1722 |
y += line_spacing * 4; |
| 1723 |
} |
| 1724 |
|
| 1725 |
const auto &&fspacx = FSPACX(); |
| 1726 |
const auto &&fspacx3 = fspacx(3); |
| 1727 |
const auto &&fspacy2 = FSPACY(2); |
| 1728 |
auto &secondary_ammo = player_info.secondary_ammo; |
| 1729 |
{ |
| 1730 |
for (uint_fast32_t ui = 5; ui --;) |
| 1731 |
{ |
| 1732 |
const auto i = static_cast<secondary_weapon_index_t>(ui); |
| 1733 |
char weapon_str[10]; |
| 1734 |
hud_set_secondary_weapon_fontcolor(player_info, i, canvas); |
| 1735 |
snprintf(weapon_str, sizeof(weapon_str), "%i", secondary_ammo[i]); |
| 1736 |
const auto &&[w, h] = gr_get_string_size(*canvas.cv_font, weapon_str); |
| 1737 |
if (vertical){ |
| 1738 |
y -= h + fspacy2; |
| 1739 |
}else |
| 1740 |
x -= w + fspacx3; |
| 1741 |
gr_string(canvas, *canvas.cv_font, x, y, weapon_str, w, h); |
| 1742 |
} |
| 1743 |
} |
| 1744 |
|
| 1745 |
#if DXX_BUILD_DESCENT == 2 |
| 1746 |
x = orig_x; |
| 1747 |
y = orig_y; |
| 1748 |
if (vertical) |
| 1749 |
{ |
| 1750 |
x += fspacx(15); |
| 1751 |
y += line_spacing * 4; |
| 1752 |
} |
| 1753 |
else |
| 1754 |
{ |
| 1755 |
y += line_spacing; |
| 1756 |
} |
| 1757 |
|
| 1758 |
{ |
| 1759 |
for (uint_fast32_t ui = 10; ui -- != 5;) |
| 1760 |
{ |
| 1761 |
const auto i = static_cast<secondary_weapon_index_t>(ui); |
| 1762 |
char weapon_str[10]; |
| 1763 |
hud_set_secondary_weapon_fontcolor(player_info, i, canvas); |
| 1764 |
snprintf(weapon_str, sizeof(weapon_str), "%u", secondary_ammo[i]); |
| 1765 |
const auto &&[w, h] = gr_get_string_size(*canvas.cv_font, weapon_str); |
| 1766 |
if (vertical){ |
| 1767 |
y -= h + fspacy2; |
| 1768 |
}else |
| 1769 |
x -= w + fspacx3; |
| 1770 |
gr_string(canvas, *canvas.cv_font, x, y, weapon_str, w, h); |
| 1771 |
} |
| 1772 |
} |
| 1773 |
#endif |
| 1774 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 1775 |
} |
| 1776 |
|
| 1777 |
static void hud_show_weapons(grs_canvas &canvas, const object &plrobj, const grs_font &game_font, const bool is_multiplayer) |
| 1778 |
{ |
| 1779 |
auto &player_info = plrobj.ctype.player_info; |
| 1780 |
int y; |
| 1781 |
const char *weapon_name; |
| 1782 |
char weapon_str[32]; |
| 1783 |
|
| 1784 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 1785 |
|
| 1786 |
y = canvas.cv_bitmap.bm_h; |
| 1787 |
|
| 1788 |
const auto &&line_spacing = LINE_SPACING(game_font, game_font); |
| 1789 |
if (is_multiplayer) |
| 1790 |
y -= line_spacing * 4; |
| 1791 |
|
| 1792 |
if (PlayerCfg.HudMode == HudType::Alternate1) |
| 1793 |
{ |
| 1794 |
#if DXX_BUILD_DESCENT == 1 |
| 1795 |
constexpr unsigned multiplier = 1; |
| 1796 |
#elif DXX_BUILD_DESCENT == 2 |
| 1797 |
constexpr unsigned multiplier = 2; |
| 1798 |
#endif |
| 1799 |
hud_show_primary_weapons_mode(canvas, player_info, 0, canvas.cv_bitmap.bm_w, y - (line_spacing * 2 * multiplier)); |
| 1800 |
hud_show_secondary_weapons_mode(canvas, player_info, 0, canvas.cv_bitmap.bm_w, y - (line_spacing * multiplier)); |
| 1801 |
return; |
| 1802 |
} |
| 1803 |
const auto &&fspacx = FSPACX(); |
| 1804 |
if (PlayerCfg.HudMode == HudType::Alternate2) |
| 1805 |
{ |
| 1806 |
int x1; |
| 1807 |
const auto w = gr_get_string_size(game_font, "V1000").width; |
| 1808 |
const auto w0 = gr_get_string_size(game_font, "0 ").width; |
| 1809 |
y = canvas.cv_bitmap.bm_h / 1.75; |
| 1810 |
x1 = canvas.cv_bitmap.bm_w / 2.1 - (fspacx(40) + w); |
| 1811 |
const auto x2 = canvas.cv_bitmap.bm_w / 1.9 + (fspacx(42) + w0); |
| 1812 |
hud_show_primary_weapons_mode(canvas, player_info, 1, x1, y); |
| 1813 |
hud_show_secondary_weapons_mode(canvas, player_info, 1, x2, y); |
| 1814 |
gr_set_fontcolor(canvas, BM_XRGB(14, 14, 23), -1); |
| 1815 |
gr_printf(canvas, game_font, x2, y - (line_spacing * 4), "%i", f2ir(plrobj.shields)); |
| 1816 |
gr_set_fontcolor(canvas, BM_XRGB(25, 18, 6), -1); |
| 1817 |
gr_printf(canvas, game_font, x1, y - (line_spacing * 4), "%i", f2ir(player_info.energy)); |
| 1818 |
} |
| 1819 |
else |
| 1820 |
{ |
| 1821 |
const char *disp_primary_weapon_name; |
| 1822 |
const auto Primary_weapon = player_info.Primary_weapon; |
| 1823 |
|
| 1824 |
weapon_name = PRIMARY_WEAPON_NAMES_SHORT(Primary_weapon); |
| 1825 |
switch (Primary_weapon) { |
| 1826 |
case primary_weapon_index_t::LASER_INDEX: |
| 1827 |
{ |
| 1828 |
const auto level = static_cast<unsigned>(player_info.laser_level) + 1; |
| 1829 |
if (player_info.powerup_flags & PLAYER_FLAGS_QUAD_LASERS) |
| 1830 |
snprintf(weapon_str, sizeof(weapon_str), "%s %s %u", TXT_QUAD, weapon_name, level); |
| 1831 |
else |
| 1832 |
snprintf(weapon_str, sizeof(weapon_str), "%s %u", weapon_name, level); |
| 1833 |
} |
| 1834 |
disp_primary_weapon_name = weapon_str; |
| 1835 |
break; |
| 1836 |
|
| 1837 |
case primary_weapon_index_t::VULCAN_INDEX: |
| 1838 |
#if DXX_BUILD_DESCENT == 2 |
| 1839 |
case primary_weapon_index_t::GAUSS_INDEX: |
| 1840 |
#endif |
| 1841 |
snprintf(weapon_str, sizeof(weapon_str), "%s: %u", weapon_name, vulcan_ammo_scale(player_info.vulcan_ammo)); |
| 1842 |
convert_1s(weapon_str); |
| 1843 |
disp_primary_weapon_name = weapon_str; |
| 1844 |
break; |
| 1845 |
|
| 1846 |
case primary_weapon_index_t::SPREADFIRE_INDEX: |
| 1847 |
case primary_weapon_index_t::PLASMA_INDEX: |
| 1848 |
case primary_weapon_index_t::FUSION_INDEX: |
| 1849 |
#if DXX_BUILD_DESCENT == 2 |
| 1850 |
case primary_weapon_index_t::HELIX_INDEX: |
| 1851 |
case primary_weapon_index_t::PHOENIX_INDEX: |
| 1852 |
#endif |
| 1853 |
disp_primary_weapon_name = weapon_name; |
| 1854 |
break; |
| 1855 |
#if DXX_BUILD_DESCENT == 2 |
| 1856 |
case primary_weapon_index_t::OMEGA_INDEX: |
| 1857 |
snprintf(weapon_str, sizeof(weapon_str), "%s: %03i", weapon_name, player_info.Omega_charge * 100 / MAX_OMEGA_CHARGE); |
| 1858 |
convert_1s(weapon_str); |
| 1859 |
disp_primary_weapon_name = weapon_str; |
| 1860 |
break; |
| 1861 |
|
| 1862 |
case primary_weapon_index_t::SUPER_LASER_INDEX: //no such thing as super laser |
| 1863 |
#endif |
| 1864 |
default: |
| 1865 |
Int3(); |
| 1866 |
disp_primary_weapon_name = ""; |
| 1867 |
break; |
| 1868 |
} |
| 1869 |
|
| 1870 |
const auto &&bmwx = canvas.cv_bitmap.bm_w - fspacx(1); |
| 1871 |
{ |
| 1872 |
const auto &&[w, h] = gr_get_string_size(game_font, disp_primary_weapon_name); |
| 1873 |
gr_string(canvas, game_font, bmwx - w, y - (line_spacing * 2), disp_primary_weapon_name, w, h); |
| 1874 |
} |
| 1875 |
const char *disp_secondary_weapon_name; |
| 1876 |
|
| 1877 |
auto &Secondary_weapon = player_info.Secondary_weapon; |
| 1878 |
disp_secondary_weapon_name = SECONDARY_WEAPON_NAMES_VERY_SHORT(Secondary_weapon); |
| 1879 |
|
| 1880 |
snprintf(weapon_str, sizeof(weapon_str), "%s %u", disp_secondary_weapon_name, player_info.secondary_ammo[Secondary_weapon]); |
| 1881 |
{ |
| 1882 |
const auto &&[w, h] = gr_get_string_size(game_font, weapon_str); |
| 1883 |
gr_string(canvas, game_font, bmwx - w, y - line_spacing, weapon_str, w, h); |
| 1884 |
} |
| 1885 |
|
| 1886 |
show_bomb_count(canvas, player_info, bmwx, y - (line_spacing * 3), -1, 1, 1); |
| 1887 |
} |
| 1888 |
} |
| 1889 |
} |
| 1890 |
} |
| 1891 |
|
| 1892 |
namespace { |
| 1893 |
|
| 1894 |
static void hud_show_cloak_invuln(grs_canvas &canvas, const player_flags player_flags, const fix64 cloak_time, const fix64 invulnerable_time, const unsigned base_y) |
| 1895 |
{ |
| 1896 |
if (!(player_flags & (PLAYER_FLAGS_CLOAKED | PLAYER_FLAGS_INVULNERABLE))) |
| 1897 |
return; |
| 1898 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 1899 |
const auto &&line_spacing = LINE_SPACING(*canvas.cv_font, *GAME_FONT); |
| 1900 |
const auto gametime64{GameTime64}; |
| 1901 |
const auto &&fspacx1 = FSPACX(1); |
| 1902 |
|
| 1903 |
const auto cloak_invul_timer = show_cloak_invul_timer(); |
| 1904 |
const auto a = [&](const fix64 effect_end, int y, const char *txt) { |
| 1905 |
if (cloak_invul_timer) |
| 1906 |
gr_printf(canvas, *canvas.cv_font, fspacx1, y, "%s: %lu", txt, static_cast<unsigned long>(effect_end / F1_0)); |
| 1907 |
else |
| 1908 |
gr_string(canvas, *canvas.cv_font, fspacx1, y, txt); |
| 1909 |
}; |
| 1910 |
|
| 1911 |
if (player_flags & PLAYER_FLAGS_CLOAKED) |
| 1912 |
{ |
| 1913 |
const fix64 effect_end = cloak_time + CLOAK_TIME_MAX - gametime64; |
| 1914 |
if (effect_end > F1_0*3 || gametime64 & 0x8000) |
| 1915 |
{ |
| 1916 |
a(effect_end, base_y, TXT_CLOAKED); |
| 1917 |
} |
| 1918 |
} |
| 1919 |
|
| 1920 |
if (player_flags & PLAYER_FLAGS_INVULNERABLE) |
| 1921 |
{ |
| 1922 |
const fix64 effect_end = invulnerable_time + INVULNERABLE_TIME_MAX - gametime64; |
| 1923 |
if (effect_end > F1_0*4 || gametime64 & 0x8000) |
| 1924 |
{ |
| 1925 |
a(effect_end, base_y - line_spacing, TXT_INVULNERABLE); |
| 1926 |
} |
| 1927 |
} |
| 1928 |
} |
| 1929 |
|
| 1930 |
static void hud_show_shield(grs_canvas &canvas, const object &plrobj, const grs_font &game_font, const unsigned current_y) |
| 1931 |
{ |
| 1932 |
if (PlayerCfg.HudMode == HudType::Standard || PlayerCfg.HudMode == HudType::Alternate1) |
| 1933 |
{ |
| 1934 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 1935 |
|
| 1936 |
const auto shields{plrobj.shields}; |
| 1937 |
gr_printf(canvas, game_font, FSPACX(1), current_y, "%s: %i", TXT_SHIELD, shields >= 0 ? f2ir(shields) : 0); |
| 1938 |
} |
| 1939 |
|
| 1940 |
if (Newdemo_state==ND_STATE_RECORDING ) |
| 1941 |
newdemo_record_player_shields(f2ir(plrobj.shields)); |
| 1942 |
} |
| 1943 |
|
| 1944 |
//draw the icons for number of lives |
| 1945 |
static void hud_show_lives(const hud_draw_context_hs_mr hudctx, const hud_ar_scale_float hud_scale_ar, const player_info &player_info, const bool is_multiplayer) |
| 1946 |
{ |
| 1947 |
if (HUD_toolong) |
| 1948 |
return; |
| 1949 |
if (Newdemo_state == ND_STATE_PLAYBACK) |
| 1950 |
return; |
| 1951 |
|
| 1952 |
const int x = (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_cockpit) |
| 1953 |
? static_cast<int>(hudctx.xscale(7)) |
| 1954 |
: static_cast<int>(FSPACX(2)); |
| 1955 |
|
| 1956 |
auto &canvas = hudctx.canvas; |
| 1957 |
auto &game_font = *GAME_FONT; |
| 1958 |
if (is_multiplayer) |
| 1959 |
{ |
| 1960 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 1961 |
gr_printf(canvas, game_font, x, FSPACY(1), "%s: %d", TXT_DEATHS, player_info.net_killed_total); |
| 1962 |
} |
| 1963 |
else if (const uint16_t lives = get_local_player().lives - 1) |
| 1964 |
{ |
| 1965 |
gr_set_curfont(canvas, game_font); |
| 1966 |
gr_set_fontcolor(canvas, BM_XRGB(0, 20, 0), -1); |
| 1967 |
#if DXX_BUILD_DESCENT == 2 |
| 1968 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 1969 |
#endif |
| 1970 |
PAGE_IN_GAUGE(GAUGE_LIVES, multires_gauge_graphic); |
| 1971 |
auto &bm = GameBitmaps[GET_GAUGE_INDEX(GAUGE_LIVES)]; |
| 1972 |
const auto &&fspacy1 = FSPACY(1); |
| 1973 |
hud_bitblt_free(canvas, x, fspacy1, hud_scale_ar(bm.bm_w), hud_scale_ar(bm.bm_h), bm); |
| 1974 |
auto &game_font = *GAME_FONT; |
| 1975 |
gr_printf(canvas, game_font, hud_scale_ar(bm.bm_w) + x, fspacy1, " x %hu", lives); |
| 1976 |
} |
| 1977 |
} |
| 1978 |
|
| 1979 |
static void sb_show_lives(const hud_draw_context_hs_mr hudctx, const hud_ar_scale_float hud_scale_ar, const player_info &player_info, const bool is_multiplayer) |
| 1980 |
{ |
| 1981 |
if (Newdemo_state == ND_STATE_PLAYBACK) |
| 1982 |
return; |
| 1983 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 1984 |
const auto y{SB_LIVES_Y}; |
| 1985 |
|
| 1986 |
auto &canvas = hudctx.canvas; |
| 1987 |
gr_set_fontcolor(canvas, BM_XRGB(0, 20, 0), -1); |
| 1988 |
const auto scaled_y = hudctx.yscale(y); |
| 1989 |
auto &game_font = *GAME_FONT; |
| 1990 |
gr_printf(canvas, game_font, hudctx.xscale(SB_LIVES_LABEL_X), scaled_y, "%s:", is_multiplayer ? TXT_DEATHS : TXT_LIVES); |
| 1991 |
|
| 1992 |
const uint8_t color = BM_XRGB(0,0,0); |
| 1993 |
const auto scaled_score_right = hudctx.xscale(SB_SCORE_RIGHT); |
| 1994 |
if (is_multiplayer) |
| 1995 |
{ |
| 1996 |
char killed_str[20]; |
| 1997 |
static std::array<int, 4> last_x{{SB_SCORE_RIGHT_L, SB_SCORE_RIGHT_L, SB_SCORE_RIGHT_H, SB_SCORE_RIGHT_H}}; |
| 1998 |
|
| 1999 |
snprintf(killed_str, sizeof(killed_str), "%5d", player_info.net_killed_total); |
| 2000 |
const auto &&[w, h] = gr_get_string_size(game_font, killed_str); |
| 2001 |
const auto x = scaled_score_right - w - FSPACX(1); |
| 2002 |
gr_rect(canvas, std::exchange(last_x[multires_gauge_graphic.is_hires()], x), scaled_y, scaled_score_right, scaled_y + LINE_SPACING(game_font, game_font), color); |
| 2003 |
gr_string(canvas, game_font, x, scaled_y, killed_str, w, h); |
| 2004 |
return; |
| 2005 |
} |
| 2006 |
|
| 2007 |
const int x = SB_LIVES_X; |
| 2008 |
//erase old icons |
| 2009 |
auto &bm = GameBitmaps[GET_GAUGE_INDEX(GAUGE_LIVES)]; |
| 2010 |
const auto scaled_x = hudctx.xscale(x); |
| 2011 |
gr_rect(canvas, scaled_x, scaled_y, scaled_score_right, hudctx.yscale(y + bm.bm_h), color); |
| 2012 |
|
| 2013 |
if (const uint16_t lives = get_local_player().lives - 1) |
| 2014 |
{ |
| 2015 |
PAGE_IN_GAUGE(GAUGE_LIVES, multires_gauge_graphic); |
| 2016 |
const auto scaled_width = hud_scale_ar(bm.bm_w); |
| 2017 |
hud_bitblt_free(canvas, scaled_x, scaled_y, scaled_width, hud_scale_ar(bm.bm_h), bm); |
| 2018 |
gr_printf(canvas, game_font, scaled_x + scaled_width, scaled_y, " x %hu", lives); |
| 2019 |
} |
| 2020 |
} |
| 2021 |
|
| 2022 |
#ifndef RELEASE |
| 2023 |
static void show_time(grs_canvas &canvas, const grs_font &cv_font) |
| 2024 |
{ |
| 2025 |
auto &plr = get_local_player(); |
| 2026 |
const unsigned secs = f2i(plr.time_level) % 60; |
| 2027 |
const unsigned mins = f2i(plr.time_level) / 60; |
| 2028 |
|
| 2029 |
if (Color_0_31_0 == -1) |
| 2030 |
Color_0_31_0 = BM_XRGB(0,31,0); |
| 2031 |
gr_set_fontcolor(canvas, Color_0_31_0, -1); |
| 2032 |
auto &game_font = *GAME_FONT; |
| 2033 |
gr_printf(canvas, game_font, FSPACX(2), (LINE_SPACING(cv_font, game_font) * 15), "%d:%02d", mins, secs); |
| 2034 |
} |
| 2035 |
#endif |
| 2036 |
|
| 2037 |
#define EXTRA_SHIP_SCORE 50000 //get new ship every this many points |
| 2038 |
|
| 2039 |
static void common_add_points_to_score(const int points, int &score, const game_mode_flags Game_mode) |
| 2040 |
{ |
| 2041 |
if (points == 0 || cheats.enabled) |
| 2042 |
return; |
| 2043 |
|
| 2044 |
if (Newdemo_state == ND_STATE_RECORDING) |
| 2045 |
newdemo_record_player_score(points); |
| 2046 |
|
| 2047 |
const auto prev_score{score}; |
| 2048 |
score += points; |
| 2049 |
|
| 2050 |
if (Game_mode & GM_MULTI) |
| 2051 |
/* In single player, fall through and check whether an extra |
| 2052 |
* life has been earned. In multiplayer, extra lives cannot be |
| 2053 |
* earned, so return. |
| 2054 |
*/ |
| 2055 |
return; |
| 2056 |
|
| 2057 |
const auto current_ship_score = score / EXTRA_SHIP_SCORE; |
| 2058 |
const auto previous_ship_score = prev_score / EXTRA_SHIP_SCORE; |
| 2059 |
if (current_ship_score != previous_ship_score) |
| 2060 |
{ |
| 2061 |
get_local_player().lives += current_ship_score - previous_ship_score; |
| 2062 |
const auto &&m = TXT_EXTRA_LIFE; |
| 2063 |
powerup_basic_str(20, 20, 20, 0, {m, strlen(m)}); |
| 2064 |
if (const auto snd{Powerup_info[powerup_type_t::POW_EXTRA_LIFE].hit_sound}; snd != sound_effect::None) |
| 2065 |
digi_play_sample( snd, F1_0 ); |
| 2066 |
} |
| 2067 |
} |
| 2068 |
|
| 2069 |
} |
| 2070 |
|
| 2071 |
namespace dsx { |
| 2072 |
|
| 2073 |
void add_points_to_score(player_info &player_info, const unsigned points, const game_mode_flags Game_mode) |
| 2074 |
{ |
| 2075 |
if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP)) |
| 2076 |
return; |
| 2077 |
score_time += f1_0*2; |
| 2078 |
score_display += points; |
| 2079 |
if (score_time > f1_0*4) score_time = f1_0*4; |
| 2080 |
|
| 2081 |
common_add_points_to_score(points, player_info.mission.score, Game_mode); |
| 2082 |
if (Game_mode & GM_MULTI_COOP) |
| 2083 |
multi_send_score(); |
| 2084 |
} |
| 2085 |
|
| 2086 |
/* This is only called in single player when the player is between |
| 2087 |
* levels. |
| 2088 |
*/ |
| 2089 |
void add_bonus_points_to_score(player_info &player_info, unsigned points, const game_mode_flags Game_mode) |
| 2090 |
{ |
| 2091 |
assert(!(Game_mode & GM_MULTI)); |
| 2092 |
common_add_points_to_score(points, player_info.mission.score, Game_mode); |
| 2093 |
} |
| 2094 |
|
| 2095 |
} |
| 2096 |
|
| 2097 |
namespace { |
| 2098 |
|
| 2099 |
// Decode cockpit bitmap to deccpt and add alpha fields to weapon boxes (as it should have always been) so we later can render sub bitmaps over the window canvases |
| 2100 |
static void cockpit_decode_alpha(const hud_draw_context_mr hudctx, grs_bitmap *const bm) |
| 2101 |
{ |
| 2102 |
static const uint8_t *cur; |
| 2103 |
static uint16_t cur_w, cur_h; |
| 2104 |
#ifndef DXX_MAX_COCKPIT_BITMAP_SIZE |
| 2105 |
/* 640 wide by 480 high should be enough for all bitmaps shipped |
| 2106 |
* with shareware or commercial data. |
| 2107 |
* Use a #define so that the value can be easily overridden at build |
| 2108 |
* time. |
| 2109 |
*/ |
| 2110 |
#define DXX_MAX_COCKPIT_BITMAP_SIZE (640 * 480) |
| 2111 |
#endif |
| 2112 |
|
| 2113 |
const unsigned bm_h = bm->bm_h; |
| 2114 |
if (unlikely(!bm_h)) |
| 2115 |
/* Invalid, but later code has undefined results if bm_h==0 */ |
| 2116 |
return; |
| 2117 |
const unsigned bm_w = bm->bm_w; |
| 2118 |
// check if we processed this bitmap already |
| 2119 |
if (cur == bm->bm_data && cur_w == bm_w && cur_h == bm_h) |
| 2120 |
{ |
| 2121 |
#if DXX_USE_OGL |
| 2122 |
// check if textures are still valid |
| 2123 |
const ogl_texture *gltexture; |
| 2124 |
if ((gltexture = WinBoxOverlay[0].get()->gltexture) && |
| 2125 |
gltexture->handle && |
| 2126 |
(gltexture = WinBoxOverlay[1].get()->gltexture) && |
| 2127 |
gltexture->handle) |
| 2128 |
return; |
| 2129 |
#else |
| 2130 |
return; |
| 2131 |
#endif |
| 2132 |
} |
| 2133 |
|
| 2134 |
auto cockpitbuf = std::make_unique<uint8_t[]>(DXX_MAX_COCKPIT_BITMAP_SIZE); |
| 2135 |
|
| 2136 |
// decode the bitmap |
| 2137 |
if (bm->get_flag_mask(BM_FLAG_RLE)) |
| 2138 |
{ |
| 2139 |
if (!bm_rle_expand(*bm).loop(bm_w, bm_rle_expand_range(cockpitbuf.get(), cockpitbuf.get() + DXX_MAX_COCKPIT_BITMAP_SIZE))) |
| 2140 |
{ |
| 2141 |
/* Out of space. Return without adjusting the bitmap. |
| 2142 |
* The result will look ugly, but run correctly. |
| 2143 |
*/ |
| 2144 |
con_printf(CON_URGENT, __FILE__ ":%u: BUG: RLE-encoded bitmap with size %hux%hu exceeds decode buffer size %u", __LINE__, static_cast<uint16_t>(bm_w), static_cast<uint16_t>(bm_h), DXX_MAX_COCKPIT_BITMAP_SIZE); |
| 2145 |
return; |
| 2146 |
} |
| 2147 |
} |
| 2148 |
else |
| 2149 |
{ |
| 2150 |
const std::size_t len = bm_w * bm_h; |
| 2151 |
if (len > DXX_MAX_COCKPIT_BITMAP_SIZE) |
| 2152 |
{ |
| 2153 |
con_printf(CON_URGENT, __FILE__ ":%u: BUG: RLE-encoded bitmap with size %hux%hu exceeds decode buffer size %u", __LINE__, static_cast<uint16_t>(bm_w), static_cast<uint16_t>(bm_h), DXX_MAX_COCKPIT_BITMAP_SIZE); |
| 2154 |
return; |
| 2155 |
} |
| 2156 |
memcpy(cockpitbuf.get(), bm->bm_data, len); |
| 2157 |
} |
| 2158 |
|
| 2159 |
// add alpha color to the pixels which are inside the window box spans |
| 2160 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2161 |
const unsigned lower_y = ((multires_gauge_graphic.get(364, 151))); |
| 2162 |
unsigned i = bm_w * lower_y; |
| 2163 |
const auto fill_alpha_one_line = [&cockpitbuf](unsigned o, const d_gauge_span &s) { |
| 2164 |
std::fill_n(&cockpitbuf[o + s.l], s.r - s.l + 1, TRANSPARENCY_COLOR); |
| 2165 |
}; |
| 2166 |
range_for (auto &s, |
| 2167 |
multires_gauge_graphic.is_hires() |
| 2168 |
? std::ranges::subrange(weapon_windows_hires) |
| 2169 |
: std::ranges::subrange(weapon_windows_lowres) |
| 2170 |
) |
| 2171 |
{ |
| 2172 |
fill_alpha_one_line(i, s.l); |
| 2173 |
fill_alpha_one_line(i, s.r); |
| 2174 |
i += bm_w; |
| 2175 |
} |
| 2176 |
constexpr auto lowres_primary_height = PRIMARY_W_BOX_BOT_L - PRIMARY_W_BOX_TOP_L; |
| 2177 |
constexpr auto highres_primary_height = PRIMARY_W_BOX_BOT_H - PRIMARY_W_BOX_TOP_H; |
| 2178 |
static_assert(lowres_primary_height == SECONDARY_W_BOX_BOT_L - SECONDARY_W_BOX_TOP_L); |
| 2179 |
static_assert(highres_primary_height == SECONDARY_W_BOX_BOT_H - SECONDARY_W_BOX_TOP_H); |
| 2180 |
const auto primary_left = (PRIMARY_W_BOX_LEFT) - 2; |
| 2181 |
const auto primary_top = (PRIMARY_W_BOX_TOP) - 2; |
| 2182 |
const auto primary_width = PRIMARY_W_BOX_RIGHT - PRIMARY_W_BOX_LEFT + 4; |
| 2183 |
const auto primary_height = PRIMARY_W_BOX_BOT - PRIMARY_W_BOX_TOP + 4; |
| 2184 |
const auto secondary_left = (SECONDARY_W_BOX_LEFT) - 2; |
| 2185 |
const auto secondary_top = (SECONDARY_W_BOX_TOP) - 2; |
| 2186 |
const auto secondary_width = (SECONDARY_W_BOX_RIGHT - SECONDARY_W_BOX_LEFT) + 4; |
| 2187 |
const auto sum_box_width = primary_width + secondary_width; |
| 2188 |
RAIIdmem<uint8_t[]> inset_window_buffer; |
| 2189 |
MALLOC(inset_window_buffer, uint8_t[], primary_height * sum_box_width); |
| 2190 |
{ |
| 2191 |
const uint8_t *primary_src_iter = &cockpitbuf[primary_left + (primary_top * bm_w)]; |
| 2192 |
const uint8_t *secondary_src_iter = &cockpitbuf[secondary_left + (secondary_top * bm_w)]; |
| 2193 |
uint8_t *primary_dst_iter = &inset_window_buffer[0]; |
| 2194 |
for (const auto iter_y : xrange(primary_height, std::integral_constant<unsigned, 0>(), xrange_descending())) |
| 2195 |
{ |
| 2196 |
(void)iter_y; |
| 2197 |
std::move(primary_src_iter, std::next(primary_src_iter, primary_width), primary_dst_iter); |
| 2198 |
std::move(secondary_src_iter, std::next(secondary_src_iter, secondary_width), std::next(primary_dst_iter, primary_width)); |
| 2199 |
primary_src_iter += bm_w; |
| 2200 |
primary_dst_iter += sum_box_width; |
| 2201 |
secondary_src_iter += bm_w; |
| 2202 |
} |
| 2203 |
cockpitbuf.reset(); |
| 2204 |
} |
| 2205 |
#if DXX_USE_OGL |
| 2206 |
ogl_freebmtexture(*bm); |
| 2207 |
/* In the OpenGL build, copy the data pointer into the bitmap for |
| 2208 |
* use until the OpenGL texture is created. |
| 2209 |
*/ |
| 2210 |
gr_init_bitmap(WinBoxOverlay.decoded_full_cockpit_image, bm_mode::linear, 0, 0, sum_box_width, primary_height, sum_box_width, inset_window_buffer.get()); |
| 2211 |
#else |
| 2212 |
/* In the SDL-only build, move the data pointer into the bitmap so |
| 2213 |
* that the underlying data buffer remains allocated. |
| 2214 |
*/ |
| 2215 |
gr_init_main_bitmap(WinBoxOverlay.decoded_full_cockpit_image, bm_mode::linear, 0, 0, sum_box_width, primary_height, sum_box_width, std::move(inset_window_buffer)); |
| 2216 |
#endif |
| 2217 |
gr_set_transparent(WinBoxOverlay.decoded_full_cockpit_image, 1); |
| 2218 |
#if DXX_USE_OGL |
| 2219 |
ogl_ubitmapm_cs(hudctx.canvas, 0, 0, opengl_bitmap_use_dst_canvas, opengl_bitmap_use_dst_canvas, WinBoxOverlay.decoded_full_cockpit_image, 255); // render one time to init the texture |
| 2220 |
#endif |
| 2221 |
WinBoxOverlay[0] = gr_create_sub_bitmap(WinBoxOverlay.decoded_full_cockpit_image, 0, 0, primary_width, primary_height); |
| 2222 |
WinBoxOverlay[1] = gr_create_sub_bitmap(WinBoxOverlay.decoded_full_cockpit_image, primary_width, 0, secondary_width, primary_height); |
| 2223 |
#if DXX_USE_OGL |
| 2224 |
/* The image has been copied to OpenGL as a texture. The underlying |
| 2225 |
* main application memory will be freed when `inset_window_buffer` |
| 2226 |
* goes out of scope. |
| 2227 |
* Clear bm_data to avoid leaving a dangling pointer. |
| 2228 |
*/ |
| 2229 |
WinBoxOverlay.decoded_full_cockpit_image.bm_data = nullptr; |
| 2230 |
WinBoxOverlay[0]->bm_data = nullptr; |
| 2231 |
WinBoxOverlay[1]->bm_data = nullptr; |
| 2232 |
#endif |
| 2233 |
|
| 2234 |
cur = bm->get_bitmap_data(); |
| 2235 |
cur_w = bm_w; |
| 2236 |
cur_h = bm_h; |
| 2237 |
} |
| 2238 |
} |
| 2239 |
|
| 2240 |
namespace dsx { |
| 2241 |
namespace { |
| 2242 |
static void draw_wbu_overlay(const hud_draw_context_hs_mr hudctx) |
| 2243 |
{ |
| 2244 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2245 |
const auto cockpit_idx{ |
| 2246 |
#if DXX_BUILD_DESCENT == 2 |
| 2247 |
multires_gauge_graphic.is_hires() |
| 2248 |
? cockpit_bitmap_index::hires_full_cockpit |
| 2249 |
: |
| 2250 |
#endif |
| 2251 |
cockpit_bitmap_index::full_cockpit |
| 2252 |
}; |
| 2253 |
const auto cb{cockpit_bitmap[cockpit_idx]}; |
| 2254 |
PIGGY_PAGE_IN(cb); |
| 2255 |
grs_bitmap *const bm = &GameBitmaps[cb]; |
| 2256 |
|
| 2257 |
cockpit_decode_alpha(hudctx, bm); |
| 2258 |
|
| 2259 |
/* The code that rendered the inset windows drew simple square |
| 2260 |
* boxes, which partially overwrote the frame surrounding the inset |
| 2261 |
* windows in the cockpit graphic. These calls reapply the |
| 2262 |
* overwritten frame, while leaving untouched the portion that was |
| 2263 |
* supposed to be overwritten. |
| 2264 |
*/ |
| 2265 |
if (WinBoxOverlay[0]) |
| 2266 |
hud_bitblt(hudctx, PRIMARY_W_BOX_LEFT - 2, PRIMARY_W_BOX_TOP - 2, *WinBoxOverlay[0].get()); |
| 2267 |
if (WinBoxOverlay[1]) |
| 2268 |
hud_bitblt(hudctx, SECONDARY_W_BOX_LEFT - 2, SECONDARY_W_BOX_TOP - 2, *WinBoxOverlay[1].get()); |
| 2269 |
} |
| 2270 |
} |
| 2271 |
} |
| 2272 |
|
| 2273 |
void close_gauges() |
| 2274 |
{ |
| 2275 |
WinBoxOverlay = {}; |
| 2276 |
} |
| 2277 |
|
| 2278 |
namespace dsx { |
| 2279 |
void init_gauges() |
| 2280 |
{ |
| 2281 |
inset_window = {}; |
| 2282 |
old_laser_level = {}; |
| 2283 |
} |
| 2284 |
} |
| 2285 |
|
| 2286 |
namespace { |
| 2287 |
|
| 2288 |
static void draw_energy_bar(grs_canvas &canvas, const hud_draw_context_hs_mr hudctx, const int energy) |
| 2289 |
{ |
| 2290 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2291 |
const int not_energy = hudctx.xscale(multires_gauge_graphic.is_hires() ? (125 - (energy * 125) / 100) : (63 - (energy * 63) / 100)); |
| 2292 |
const double aplitscale = static_cast<double>(hudctx.xscale(65) / hudctx.yscale(8)) / (65 / 8); //scale amplitude of energy bar to current resolution aspect |
| 2293 |
|
| 2294 |
// Draw left energy bar |
| 2295 |
hud_gauge_bitblt(hudctx, LEFT_ENERGY_GAUGE_X, LEFT_ENERGY_GAUGE_Y, GAUGE_ENERGY_LEFT); |
| 2296 |
|
| 2297 |
const auto color = BM_XRGB(0, 0, 0); |
| 2298 |
|
| 2299 |
if (energy < 100) |
| 2300 |
{ |
| 2301 |
const auto xscale_energy_gauge_x = hudctx.xscale(LEFT_ENERGY_GAUGE_X); |
| 2302 |
const auto xscale_energy_gauge_w = hudctx.xscale(LEFT_ENERGY_GAUGE_W); |
| 2303 |
const auto xscale_energy_gauge_h2 = hudctx.xscale(LEFT_ENERGY_GAUGE_H - 2); |
| 2304 |
const auto yscale_energy_gauge_y = hudctx.yscale(LEFT_ENERGY_GAUGE_Y); |
| 2305 |
const auto yscale_energy_gauge_h = hudctx.yscale(LEFT_ENERGY_GAUGE_H); |
| 2306 |
for (unsigned y = 0; y < yscale_energy_gauge_h; ++y) |
| 2307 |
{ |
| 2308 |
const auto bound = xscale_energy_gauge_w - (y * aplitscale) / 3; |
| 2309 |
const auto x1 = xscale_energy_gauge_h2 - y * aplitscale; |
| 2310 |
const auto x2 = std::min(x1 + not_energy, bound); |
| 2311 |
|
| 2312 |
if (x2 > x1) |
| 2313 |
{ |
| 2314 |
const auto ly = i2f(y + yscale_energy_gauge_y); |
| 2315 |
gr_uline(canvas, i2f(x1 + xscale_energy_gauge_x), ly, i2f(x2 + xscale_energy_gauge_x), ly, color); |
| 2316 |
} |
| 2317 |
} |
| 2318 |
} |
| 2319 |
|
| 2320 |
// Draw right energy bar |
| 2321 |
hud_gauge_bitblt(hudctx, RIGHT_ENERGY_GAUGE_X, RIGHT_ENERGY_GAUGE_Y, GAUGE_ENERGY_RIGHT); |
| 2322 |
|
| 2323 |
if (energy < 100) |
| 2324 |
{ |
| 2325 |
const auto xscale_energy_gauge_x = hudctx.xscale(RIGHT_ENERGY_GAUGE_X); |
| 2326 |
const auto yscale_energy_gauge_y = hudctx.yscale(RIGHT_ENERGY_GAUGE_Y); |
| 2327 |
const auto yscale_energy_gauge_h = hudctx.yscale(RIGHT_ENERGY_GAUGE_H); |
| 2328 |
const auto xscale_right_energy = hudctx.xscale(RIGHT_ENERGY_GAUGE_W - RIGHT_ENERGY_GAUGE_H + 2); |
| 2329 |
for (unsigned y = 0; y < yscale_energy_gauge_h; ++y) |
| 2330 |
{ |
| 2331 |
const auto bound = (y * aplitscale) / 3; |
| 2332 |
const auto x2 = xscale_right_energy + y * aplitscale; |
| 2333 |
auto x1 = x2 - not_energy; |
| 2334 |
|
| 2335 |
if (x1 < bound) |
| 2336 |
x1 = bound; |
| 2337 |
|
| 2338 |
if (x2 > x1) |
| 2339 |
{ |
| 2340 |
const auto ly = i2f(y + yscale_energy_gauge_y); |
| 2341 |
gr_uline(canvas, i2f(x1 + xscale_energy_gauge_x), ly, i2f(x2 + xscale_energy_gauge_x), ly, color); |
| 2342 |
} |
| 2343 |
} |
| 2344 |
} |
| 2345 |
} |
| 2346 |
|
| 2347 |
} |
| 2348 |
|
| 2349 |
#if DXX_BUILD_DESCENT == 2 |
| 2350 |
namespace dsx { |
| 2351 |
namespace { |
| 2352 |
static void draw_afterburner_bar(const hud_draw_context_hs_mr hudctx, const int afterburner) |
| 2353 |
{ |
| 2354 |
struct lr |
| 2355 |
{ |
| 2356 |
uint8_t l, r; |
| 2357 |
}; |
| 2358 |
static const std::array<lr, AFTERBURNER_GAUGE_H_L> afterburner_bar_table = {{ |
| 2359 |
{3, 11}, |
| 2360 |
{3, 11}, |
| 2361 |
{3, 11}, |
| 2362 |
{3, 11}, |
| 2363 |
{3, 11}, |
| 2364 |
{3, 11}, |
| 2365 |
{2, 11}, |
| 2366 |
{2, 10}, |
| 2367 |
{2, 10}, |
| 2368 |
{2, 10}, |
| 2369 |
{2, 10}, |
| 2370 |
{2, 10}, |
| 2371 |
{2, 10}, |
| 2372 |
{1, 10}, |
| 2373 |
{1, 10}, |
| 2374 |
{1, 10}, |
| 2375 |
{1, 9}, |
| 2376 |
{1, 9}, |
| 2377 |
{1, 9}, |
| 2378 |
{1, 9}, |
| 2379 |
{0, 9}, |
| 2380 |
{0, 9}, |
| 2381 |
{0, 8}, |
| 2382 |
{0, 8}, |
| 2383 |
{0, 8}, |
| 2384 |
{0, 8}, |
| 2385 |
{1, 8}, |
| 2386 |
{2, 8}, |
| 2387 |
{3, 8}, |
| 2388 |
{4, 8}, |
| 2389 |
{5, 8}, |
| 2390 |
{6, 7} |
| 2391 |
}}; |
| 2392 |
static const std::array<lr, AFTERBURNER_GAUGE_H_H> afterburner_bar_table_hires = {{ |
| 2393 |
{5, 20}, |
| 2394 |
{5, 20}, |
| 2395 |
{5, 19}, |
| 2396 |
{5, 19}, |
| 2397 |
{5, 19}, |
| 2398 |
{5, 19}, |
| 2399 |
{4, 19}, |
| 2400 |
{4, 19}, |
| 2401 |
{4, 19}, |
| 2402 |
{4, 19}, |
| 2403 |
{4, 19}, |
| 2404 |
{4, 18}, |
| 2405 |
{4, 18}, |
| 2406 |
{4, 18}, |
| 2407 |
{4, 18}, |
| 2408 |
{3, 18}, |
| 2409 |
{3, 18}, |
| 2410 |
{3, 18}, |
| 2411 |
{3, 18}, |
| 2412 |
{3, 18}, |
| 2413 |
{3, 18}, |
| 2414 |
{3, 17}, |
| 2415 |
{3, 17}, |
| 2416 |
{2, 17}, |
| 2417 |
{2, 17}, |
| 2418 |
{2, 17}, |
| 2419 |
{2, 17}, |
| 2420 |
{2, 17}, |
| 2421 |
{2, 17}, |
| 2422 |
{2, 17}, |
| 2423 |
{2, 17}, |
| 2424 |
{2, 16}, |
| 2425 |
{2, 16}, |
| 2426 |
{1, 16}, |
| 2427 |
{1, 16}, |
| 2428 |
{1, 16}, |
| 2429 |
{1, 16}, |
| 2430 |
{1, 16}, |
| 2431 |
{1, 16}, |
| 2432 |
{1, 16}, |
| 2433 |
{1, 16}, |
| 2434 |
{1, 15}, |
| 2435 |
{1, 15}, |
| 2436 |
{1, 15}, |
| 2437 |
{0, 15}, |
| 2438 |
{0, 15}, |
| 2439 |
{0, 15}, |
| 2440 |
{0, 15}, |
| 2441 |
{0, 15}, |
| 2442 |
{0, 15}, |
| 2443 |
{0, 14}, |
| 2444 |
{0, 14}, |
| 2445 |
{0, 14}, |
| 2446 |
{1, 14}, |
| 2447 |
{2, 14}, |
| 2448 |
{3, 14}, |
| 2449 |
{4, 14}, |
| 2450 |
{5, 14}, |
| 2451 |
{6, 13}, |
| 2452 |
{7, 13}, |
| 2453 |
{8, 13}, |
| 2454 |
{9, 13}, |
| 2455 |
{10, 13}, |
| 2456 |
{11, 13}, |
| 2457 |
{12, 13} |
| 2458 |
}}; |
| 2459 |
|
| 2460 |
// Draw afterburner bar |
| 2461 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2462 |
const auto afterburner_gauge_x{AFTERBURNER_GAUGE_X}; |
| 2463 |
const auto afterburner_gauge_y{AFTERBURNER_GAUGE_Y}; |
| 2464 |
const auto [table_data, table_size] = multires_gauge_graphic.is_hires() |
| 2465 |
? std::make_pair(afterburner_bar_table_hires.data(), afterburner_bar_table_hires.size()) |
| 2466 |
: std::make_pair(afterburner_bar_table.data(), afterburner_bar_table.size()); |
| 2467 |
hud_gauge_bitblt(hudctx, afterburner_gauge_x, afterburner_gauge_y, GAUGE_AFTERBURNER); |
| 2468 |
const unsigned not_afterburner = fixmul(f1_0 - afterburner, table_size); |
| 2469 |
if (not_afterburner > table_size) |
| 2470 |
return; |
| 2471 |
const uint8_t color = BM_XRGB(0, 0, 0); |
| 2472 |
const int base_top = hudctx.yscale(afterburner_gauge_y - 1); |
| 2473 |
const int base_bottom = hudctx.yscale(afterburner_gauge_y); |
| 2474 |
int y{0}; |
| 2475 |
for (auto &ab : unchecked_partial_range(table_data, not_afterburner)) |
| 2476 |
{ |
| 2477 |
const int left = hudctx.xscale(afterburner_gauge_x + ab.l); |
| 2478 |
const int right = hudctx.xscale(afterburner_gauge_x + ab.r + 1); |
| 2479 |
for (int i = hudctx.yscale(y), j = hudctx.yscale(++y); i < j; ++i) |
| 2480 |
{ |
| 2481 |
gr_rect(hudctx.canvas, left, base_top + i, right, base_bottom + i, color); |
| 2482 |
} |
| 2483 |
} |
| 2484 |
} |
| 2485 |
|
| 2486 |
} |
| 2487 |
} |
| 2488 |
#endif |
| 2489 |
|
| 2490 |
namespace { |
| 2491 |
|
| 2492 |
static void draw_shield_bar(const hud_draw_context_hs_mr hudctx, const int shield) |
| 2493 |
{ |
| 2494 |
int bm_num = shield>=100?9:(shield / 10); |
| 2495 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2496 |
hud_gauge_bitblt(hudctx, SHIELD_GAUGE_X, SHIELD_GAUGE_Y, GAUGE_SHIELDS + 9 - bm_num); |
| 2497 |
} |
| 2498 |
|
| 2499 |
static void show_cockpit_cloak_invul_timer(grs_canvas &canvas, const fix64 effect_end, const int y) |
| 2500 |
{ |
| 2501 |
char countdown[8]; |
| 2502 |
snprintf(countdown, sizeof(countdown), "%lu", static_cast<unsigned long>(effect_end / F1_0)); |
| 2503 |
gr_set_fontcolor(canvas, BM_XRGB(31, 31, 31), -1); |
| 2504 |
const auto &&[ow, oh] = gr_get_string_size(*canvas.cv_font, countdown); |
| 2505 |
const int x = grd_curscreen->get_screen_width() / (PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar |
| 2506 |
? 2.266 |
| 2507 |
: 1.951 |
| 2508 |
); |
| 2509 |
gr_string(canvas, *canvas.cv_font, x - (ow / 2), y, countdown, ow, oh); |
| 2510 |
} |
| 2511 |
|
| 2512 |
} |
| 2513 |
|
| 2514 |
#define CLOAK_FADE_WAIT_TIME 0x400 |
| 2515 |
|
| 2516 |
namespace dsx { |
| 2517 |
|
| 2518 |
namespace { |
| 2519 |
|
| 2520 |
static void draw_player_ship(const hud_draw_context_hs_mr hudctx, const player_info &player_info, const int cloak_state, const int x, const int y) |
| 2521 |
{ |
| 2522 |
static fix cloak_fade_timer=0; |
| 2523 |
static int8_t cloak_fade_value = GR_FADE_LEVELS - 1; |
| 2524 |
|
| 2525 |
if (cloak_state) |
| 2526 |
{ |
| 2527 |
static int step = 0; |
| 2528 |
const auto cloak_time = player_info.cloak_time; |
| 2529 |
|
| 2530 |
if (GameTime64 - cloak_time < F1_0) |
| 2531 |
{ |
| 2532 |
step = -2; |
| 2533 |
} |
| 2534 |
else if (cloak_time + CLOAK_TIME_MAX - GameTime64 <= F1_0*3) |
| 2535 |
{ |
| 2536 |
if (cloak_fade_value >= static_cast<signed>(GR_FADE_LEVELS-1)) |
| 2537 |
{ |
| 2538 |
step = -2; |
| 2539 |
} |
| 2540 |
else if (cloak_fade_value <= 0) |
| 2541 |
{ |
| 2542 |
step = 2; |
| 2543 |
} |
| 2544 |
} |
| 2545 |
else |
| 2546 |
{ |
| 2547 |
step = 0; |
| 2548 |
cloak_fade_value = 0; |
| 2549 |
} |
| 2550 |
|
| 2551 |
cloak_fade_timer -= FrameTime; |
| 2552 |
|
| 2553 |
while (cloak_fade_timer < 0) |
| 2554 |
{ |
| 2555 |
cloak_fade_timer += CLOAK_FADE_WAIT_TIME; |
| 2556 |
cloak_fade_value += step; |
| 2557 |
} |
| 2558 |
|
| 2559 |
if (cloak_fade_value > static_cast<signed>(GR_FADE_LEVELS-1)) |
| 2560 |
cloak_fade_value = (GR_FADE_LEVELS-1); |
| 2561 |
if (cloak_fade_value <= 0) |
| 2562 |
cloak_fade_value = 0; |
| 2563 |
} |
| 2564 |
else |
| 2565 |
{ |
| 2566 |
cloak_fade_timer = 0; |
| 2567 |
cloak_fade_value = GR_FADE_LEVELS-1; |
| 2568 |
} |
| 2569 |
|
| 2570 |
const auto color{get_player_or_team_color(Netgame, Game_mode, Player_num)}; |
| 2571 |
#if DXX_BUILD_DESCENT == 2 |
| 2572 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2573 |
#endif |
| 2574 |
const auto gauge_index{GAUGE_SHIPS + underlying_value(color)}; |
| 2575 |
PAGE_IN_GAUGE(gauge_index, multires_gauge_graphic); |
| 2576 |
auto &bm = GameBitmaps[GET_GAUGE_INDEX(gauge_index)]; |
| 2577 |
hud_bitblt(hudctx, x, y, bm); |
| 2578 |
auto &canvas = hudctx.canvas; |
| 2579 |
gr_settransblend(canvas, gr_fade_level{static_cast<uint8_t>(cloak_fade_value)}, gr_blend::normal); |
| 2580 |
gr_rect(canvas, hudctx.xscale(x - 3), hudctx.yscale(y - 3), hudctx.xscale(x + bm.bm_w + 3), hudctx.yscale(y + bm.bm_h + 3), 0); |
| 2581 |
gr_settransblend(canvas, GR_FADE_OFF, gr_blend::normal); |
| 2582 |
// Show Cloak Timer if enabled |
| 2583 |
if (cloak_fade_value < GR_FADE_LEVELS/2 && show_cloak_invul_timer()) |
| 2584 |
show_cockpit_cloak_invul_timer(canvas, player_info.cloak_time + CLOAK_TIME_MAX - GameTime64, hudctx.yscale(y + (bm.bm_h / 2))); |
| 2585 |
} |
| 2586 |
|
| 2587 |
} |
| 2588 |
|
| 2589 |
} |
| 2590 |
|
| 2591 |
#define INV_FRAME_TIME (f1_0/10) //how long for each frame |
| 2592 |
|
| 2593 |
namespace dcx { |
| 2594 |
|
| 2595 |
namespace { |
| 2596 |
|
| 2597 |
static const char *get_gauge_width_string(const unsigned v) |
| 2598 |
{ |
| 2599 |
if (v > 199) |
| 2600 |
return "200"; |
| 2601 |
return &"100"[(v > 99) |
| 2602 |
? 0 |
| 2603 |
: (v > 9) ? 1 : 2 |
| 2604 |
]; |
| 2605 |
} |
| 2606 |
|
| 2607 |
} |
| 2608 |
|
| 2609 |
} |
| 2610 |
|
| 2611 |
namespace { |
| 2612 |
|
| 2613 |
static void draw_numerical_display(const draw_numerical_display_draw_context hudctx, const int shield, const int energy) |
| 2614 |
{ |
| 2615 |
auto &canvas = hudctx.canvas; |
| 2616 |
#if !DXX_USE_OGL |
| 2617 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2618 |
hud_gauge_bitblt(hudctx, NUMERICAL_GAUGE_X, NUMERICAL_GAUGE_Y, GAUGE_NUMERICAL); |
| 2619 |
#endif |
| 2620 |
// cockpit is not 100% geometric so we need to divide shield and energy X position by 1.951 which should be most accurate |
| 2621 |
// gr_get_string_size is used so we can get the numbers finally in the correct position with sw and ew |
| 2622 |
const int xb = grd_curscreen->get_screen_width() / 1.951; |
| 2623 |
auto &game_font = *GAME_FONT; |
| 2624 |
const auto a = [&canvas, &game_font, xb](int v, int y) { |
| 2625 |
const auto w = gr_get_string_size(game_font, get_gauge_width_string(v)).width; |
| 2626 |
gr_printf(canvas, game_font, xb - (w / 2), y, "%d", v); |
| 2627 |
}; |
| 2628 |
gr_set_fontcolor(canvas, BM_XRGB(14, 14, 23), -1); |
| 2629 |
const auto screen_height = grd_curscreen->get_screen_height(); |
| 2630 |
a(shield, screen_height / 1.365); |
| 2631 |
|
| 2632 |
gr_set_fontcolor(canvas, BM_XRGB(25, 18, 6), -1); |
| 2633 |
a(energy, screen_height / 1.5); |
| 2634 |
} |
| 2635 |
|
| 2636 |
} |
| 2637 |
|
| 2638 |
namespace dsx { |
| 2639 |
namespace { |
| 2640 |
|
| 2641 |
void draw_keys_state::draw_all_cockpit_keys() |
| 2642 |
{ |
| 2643 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2644 |
draw_one_key(GAUGE_BLUE_KEY_X, GAUGE_BLUE_KEY_Y, GAUGE_BLUE_KEY, PLAYER_FLAGS_BLUE_KEY); |
| 2645 |
draw_one_key(GAUGE_GOLD_KEY_X, GAUGE_GOLD_KEY_Y, GAUGE_GOLD_KEY, PLAYER_FLAGS_GOLD_KEY); |
| 2646 |
draw_one_key(GAUGE_RED_KEY_X, GAUGE_RED_KEY_Y, GAUGE_RED_KEY, PLAYER_FLAGS_RED_KEY); |
| 2647 |
} |
| 2648 |
|
| 2649 |
static void draw_weapon_info_sub(const hud_draw_context_hs_mr hudctx, const player_info &player_info, const weapon_id_type info_index, const gauge_box *const box, const int pic_x, const int pic_y, const char *const name, const int text_x, const int text_y) |
| 2650 |
{ |
| 2651 |
//clear the window |
| 2652 |
const uint8_t color = BM_XRGB(0, 0, 0); |
| 2653 |
{ |
| 2654 |
#if DXX_BUILD_DESCENT == 1 |
| 2655 |
constexpr unsigned bottom_bias = 1; |
| 2656 |
#elif DXX_BUILD_DESCENT == 2 |
| 2657 |
constexpr unsigned bottom_bias = 0; |
| 2658 |
#endif |
| 2659 |
gr_rect(hudctx.canvas, hudctx.xscale(box->left), hudctx.yscale(box->top), hudctx.xscale(box->right), hudctx.yscale(box->bot + bottom_bias), color); |
| 2660 |
} |
| 2661 |
const auto picture = |
| 2662 |
#if DXX_BUILD_DESCENT == 2 |
| 2663 |
// !SHAREWARE |
| 2664 |
(Piggy_hamfile_version >= pig_hamfile_version::_3 && hudctx.multires_gauge_graphic.is_hires()) ? |
| 2665 |
Weapon_info[info_index].hires_picture : |
| 2666 |
#endif |
| 2667 |
Weapon_info[info_index].picture; |
| 2668 |
PIGGY_PAGE_IN(picture); |
| 2669 |
auto &bm = GameBitmaps[picture]; |
| 2670 |
hud_bitblt(hudctx, pic_x, pic_y, bm); |
| 2671 |
|
| 2672 |
if (PlayerCfg.HudMode == HudType::Standard) |
| 2673 |
{ |
| 2674 |
auto &canvas = hudctx.canvas; |
| 2675 |
gr_set_fontcolor(canvas, BM_XRGB(0, 20, 0), -1); |
| 2676 |
|
| 2677 |
gr_string(canvas, *canvas.cv_font, text_x, text_y, name); |
| 2678 |
|
| 2679 |
// For laser, show level and quadness |
| 2680 |
#if DXX_BUILD_DESCENT == 1 |
| 2681 |
if (info_index == weapon_id_type::LASER_ID) |
| 2682 |
#elif DXX_BUILD_DESCENT == 2 |
| 2683 |
if (info_index == weapon_id_type::LASER_ID || info_index == weapon_id_type::SUPER_LASER_ID) |
| 2684 |
#endif |
| 2685 |
{ |
| 2686 |
const auto &&line_spacing = LINE_SPACING(*canvas.cv_font, *GAME_FONT); |
| 2687 |
gr_printf(canvas, *canvas.cv_font, text_x, text_y + line_spacing, "%s: %u", TXT_LVL, static_cast<unsigned>(player_info.laser_level) + 1); |
| 2688 |
if (player_info.powerup_flags & PLAYER_FLAGS_QUAD_LASERS) |
| 2689 |
gr_string(canvas, *canvas.cv_font, text_x, text_y + (line_spacing * 2), TXT_QUAD); |
| 2690 |
} |
| 2691 |
} |
| 2692 |
} |
| 2693 |
|
| 2694 |
static void draw_primary_weapon_info(const hud_draw_context_hs_mr hudctx, const player_info &player_info, const primary_weapon_index_t weapon_num, const laser_level level) |
| 2695 |
{ |
| 2696 |
#if DXX_BUILD_DESCENT == 1 |
| 2697 |
(void)level; |
| 2698 |
#endif |
| 2699 |
int x,y; |
| 2700 |
|
| 2701 |
{ |
| 2702 |
const auto weapon_id = Primary_weapon_to_weapon_info[weapon_num]; |
| 2703 |
const auto info_index = |
| 2704 |
#if DXX_BUILD_DESCENT == 2 |
| 2705 |
(weapon_id == weapon_id_type::LASER_ID && level > MAX_LASER_LEVEL) |
| 2706 |
? weapon_id_type::SUPER_LASER_ID |
| 2707 |
: |
| 2708 |
#endif |
| 2709 |
weapon_id; |
| 2710 |
|
| 2711 |
const gauge_box *box; |
| 2712 |
int pic_x, pic_y, text_x, text_y; |
| 2713 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2714 |
auto &resbox = gauge_boxes[multires_gauge_graphic.hiresmode]; |
| 2715 |
auto &weaponbox = resbox[gauge_inset_window_view::primary]; |
| 2716 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) |
| 2717 |
{ |
| 2718 |
box = &weaponbox[gauge_hud_type::statusbar]; |
| 2719 |
pic_x = SB_PRIMARY_W_PIC_X; |
| 2720 |
pic_y = SB_PRIMARY_W_PIC_Y; |
| 2721 |
text_x = SB_PRIMARY_W_TEXT_X; |
| 2722 |
text_y = SB_PRIMARY_W_TEXT_Y; |
| 2723 |
x=SB_PRIMARY_AMMO_X; |
| 2724 |
y=SB_PRIMARY_AMMO_Y; |
| 2725 |
} |
| 2726 |
else |
| 2727 |
{ |
| 2728 |
box = &weaponbox[gauge_hud_type::cockpit]; |
| 2729 |
pic_x = PRIMARY_W_PIC_X; |
| 2730 |
pic_y = PRIMARY_W_PIC_Y; |
| 2731 |
text_x = PRIMARY_W_TEXT_X; |
| 2732 |
text_y = PRIMARY_W_TEXT_Y; |
| 2733 |
x=PRIMARY_AMMO_X; |
| 2734 |
y=PRIMARY_AMMO_Y; |
| 2735 |
} |
| 2736 |
draw_weapon_info_sub(hudctx, player_info, info_index, box, pic_x, pic_y, PRIMARY_WEAPON_NAMES_SHORT(weapon_num), hudctx.xscale(text_x), hudctx.yscale(text_y)); |
| 2737 |
if (PlayerCfg.HudMode != HudType::Standard) |
| 2738 |
{ |
| 2739 |
#if DXX_BUILD_DESCENT == 2 |
| 2740 |
if (inset_window[gauge_inset_window_view::primary].user == weapon_box_user::weapon) |
| 2741 |
#endif |
| 2742 |
hud_show_primary_weapons_mode(hudctx.canvas, player_info, 1, hudctx.xscale(x), hudctx.yscale(y)); |
| 2743 |
} |
| 2744 |
} |
| 2745 |
} |
| 2746 |
|
| 2747 |
static void draw_secondary_weapon_info(const hud_draw_context_hs_mr hudctx, const player_info &player_info, const secondary_weapon_index_t weapon_num) |
| 2748 |
{ |
| 2749 |
int x,y; |
| 2750 |
|
| 2751 |
{ |
| 2752 |
const auto info_index = Secondary_weapon_to_weapon_info[weapon_num]; |
| 2753 |
const gauge_box *box; |
| 2754 |
int pic_x, pic_y, text_x, text_y; |
| 2755 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2756 |
auto &resbox = gauge_boxes[multires_gauge_graphic.hiresmode]; |
| 2757 |
auto &weaponbox = resbox[gauge_inset_window_view::secondary]; |
| 2758 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) |
| 2759 |
{ |
| 2760 |
box = &weaponbox[gauge_hud_type::statusbar]; |
| 2761 |
pic_x = SB_SECONDARY_W_PIC_X; |
| 2762 |
pic_y = SB_SECONDARY_W_PIC_Y; |
| 2763 |
text_x = SB_SECONDARY_W_TEXT_X; |
| 2764 |
text_y = SB_SECONDARY_W_TEXT_Y; |
| 2765 |
x=SB_SECONDARY_AMMO_X; |
| 2766 |
y=SB_SECONDARY_AMMO_Y; |
| 2767 |
} |
| 2768 |
else |
| 2769 |
{ |
| 2770 |
box = &weaponbox[gauge_hud_type::cockpit]; |
| 2771 |
pic_x = SECONDARY_W_PIC_X; |
| 2772 |
pic_y = SECONDARY_W_PIC_Y; |
| 2773 |
text_x = SECONDARY_W_TEXT_X; |
| 2774 |
text_y = SECONDARY_W_TEXT_Y; |
| 2775 |
x=SECONDARY_AMMO_X; |
| 2776 |
y=SECONDARY_AMMO_Y; |
| 2777 |
} |
| 2778 |
const char *weapon_name; |
| 2779 |
switch (weapon_num) |
| 2780 |
{ |
| 2781 |
default: // unreachable |
| 2782 |
case secondary_weapon_index_t::CONCUSSION_INDEX: // reachable |
| 2783 |
weapon_name = TXT_W_C_MISSILE_S; |
| 2784 |
break; |
| 2785 |
case secondary_weapon_index_t::HOMING_INDEX: |
| 2786 |
weapon_name = TXT_W_H_MISSILE_S; |
| 2787 |
break; |
| 2788 |
case secondary_weapon_index_t::PROXIMITY_INDEX: |
| 2789 |
weapon_name = TXT_W_P_BOMB_S; |
| 2790 |
break; |
| 2791 |
case secondary_weapon_index_t::SMART_INDEX: |
| 2792 |
weapon_name = TXT_W_S_MISSILE_S; |
| 2793 |
break; |
| 2794 |
case secondary_weapon_index_t::MEGA_INDEX: |
| 2795 |
weapon_name = TXT_W_M_MISSILE_S; |
| 2796 |
break; |
| 2797 |
#if DXX_BUILD_DESCENT == 2 |
| 2798 |
case secondary_weapon_index_t::SMISSILE1_INDEX: |
| 2799 |
weapon_name = TXT_W_SMISSILE1_S; |
| 2800 |
break; |
| 2801 |
case secondary_weapon_index_t::GUIDED_INDEX: |
| 2802 |
weapon_name = TXT_W_SMISSILE2_S; |
| 2803 |
break; |
| 2804 |
case secondary_weapon_index_t::SMART_MINE_INDEX: |
| 2805 |
weapon_name = TXT_W_SMISSILE3_S; |
| 2806 |
break; |
| 2807 |
case secondary_weapon_index_t::SMISSILE4_INDEX: |
| 2808 |
weapon_name = TXT_W_SMISSILE4_S; |
| 2809 |
break; |
| 2810 |
case secondary_weapon_index_t::SMISSILE5_INDEX: |
| 2811 |
weapon_name = TXT_W_SMISSILE5_S; |
| 2812 |
break; |
| 2813 |
#endif |
| 2814 |
} |
| 2815 |
draw_weapon_info_sub(hudctx, player_info, info_index, box, pic_x, pic_y, weapon_name, hudctx.xscale(text_x), hudctx.yscale(text_y)); |
| 2816 |
if (PlayerCfg.HudMode != HudType::Standard) |
| 2817 |
{ |
| 2818 |
#if DXX_BUILD_DESCENT == 2 |
| 2819 |
if (inset_window[gauge_inset_window_view::secondary].user == weapon_box_user::weapon) |
| 2820 |
#endif |
| 2821 |
hud_show_secondary_weapons_mode(hudctx.canvas, player_info, 1, hudctx.xscale(x), hudctx.yscale(y)); |
| 2822 |
} |
| 2823 |
} |
| 2824 |
} |
| 2825 |
|
| 2826 |
static void draw_weapon_info(const hud_draw_context_hs_mr hudctx, const player_info &player_info, const weapon_index weapon_num, const laser_level laser_level, const gauge_inset_window_view wt) |
| 2827 |
{ |
| 2828 |
if (wt == gauge_inset_window_view::primary) |
| 2829 |
draw_primary_weapon_info(hudctx, player_info, weapon_num.primary, laser_level); |
| 2830 |
else |
| 2831 |
draw_secondary_weapon_info(hudctx, player_info, weapon_num.secondary); |
| 2832 |
} |
| 2833 |
|
| 2834 |
} |
| 2835 |
} |
| 2836 |
|
| 2837 |
namespace { |
| 2838 |
|
| 2839 |
static void draw_ammo_info(grs_canvas &canvas, const unsigned x, const unsigned y, const unsigned ammo_count) |
| 2840 |
{ |
| 2841 |
if (PlayerCfg.HudMode == HudType::Standard) |
| 2842 |
{ |
| 2843 |
gr_set_fontcolor(canvas, BM_XRGB(20, 0, 0), -1); |
| 2844 |
gr_printf(canvas, *canvas.cv_font, x, y, "%03u", ammo_count); |
| 2845 |
} |
| 2846 |
} |
| 2847 |
|
| 2848 |
static void draw_secondary_ammo_info(const hud_draw_context_hs_mr hudctx, const unsigned ammo_count) |
| 2849 |
{ |
| 2850 |
int x, y; |
| 2851 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2852 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) |
| 2853 |
x = SB_SECONDARY_AMMO_X, y = SB_SECONDARY_AMMO_Y; |
| 2854 |
else |
| 2855 |
x = SECONDARY_AMMO_X, y = SECONDARY_AMMO_Y; |
| 2856 |
draw_ammo_info(hudctx.canvas, hudctx.xscale(x), hudctx.yscale(y), ammo_count); |
| 2857 |
} |
| 2858 |
|
| 2859 |
static void draw_weapon_box(const hud_draw_context_hs_mr hudctx, const player_info &player_info, const weapon_index weapon_num, const gauge_inset_window_view wt) |
| 2860 |
{ |
| 2861 |
auto &canvas = hudctx.canvas; |
| 2862 |
gr_set_curfont(canvas, *GAME_FONT); |
| 2863 |
|
| 2864 |
const auto laser_level_changed = (wt == gauge_inset_window_view::primary && weapon_num.primary == primary_weapon_index_t::LASER_INDEX && (player_info.laser_level != old_laser_level)); |
| 2865 |
|
| 2866 |
auto &inset = inset_window[wt]; |
| 2867 |
if ((weapon_num != inset.old_weapon || laser_level_changed) && inset.box_state == weapon_box_state::set && inset.old_weapon != weapon_index{} && PlayerCfg.HudMode == HudType::Standard) |
| 2868 |
{ |
| 2869 |
inset.box_state = weapon_box_state::fading_out; |
| 2870 |
inset.fade_value = i2f(GR_FADE_LEVELS - 1); |
| 2871 |
} |
| 2872 |
|
| 2873 |
const local_multires_gauge_graphic multires_gauge_graphic{}; |
| 2874 |
if (inset.old_weapon == weapon_index{}) |
| 2875 |
{ |
| 2876 |
draw_weapon_info(hudctx, player_info, weapon_num, player_info.laser_level, wt); |
| 2877 |
inset.old_weapon = weapon_num; |
| 2878 |
inset.box_state = weapon_box_state::set; |
| 2879 |
} |
| 2880 |
|
| 2881 |
if (inset.box_state == weapon_box_state::fading_out) |
| 2882 |
{ |
| 2883 |
draw_weapon_info(hudctx, player_info, inset.old_weapon, old_laser_level, wt); |
| 2884 |
inset.fade_value -= FrameTime * FADE_SCALE; |
| 2885 |
if (inset.fade_value <= 0) |
| 2886 |
{ |
| 2887 |
inset.fade_value = 0; |
| 2888 |
inset.box_state = weapon_box_state::fading_in; |
| 2889 |
inset.old_weapon = weapon_num; |
| 2890 |
old_laser_level = player_info.laser_level; |
| 2891 |
} |
| 2892 |
} |
| 2893 |
else if (inset.box_state == weapon_box_state::fading_in) |
| 2894 |
{ |
| 2895 |
if (weapon_num != inset.old_weapon) { |
| 2896 |
inset.box_state = weapon_box_state::fading_out; |
| 2897 |
} |
| 2898 |
else { |
| 2899 |
draw_weapon_info(hudctx, player_info, weapon_num, player_info.laser_level, wt); |
| 2900 |
inset.fade_value += FrameTime * FADE_SCALE; |
| 2901 |
if (inset.fade_value >= i2f(GR_FADE_LEVELS - 1)) |
| 2902 |
{ |
| 2903 |
inset.old_weapon = {}; |
| 2904 |
inset.box_state = weapon_box_state::set; |
| 2905 |
} |
| 2906 |
} |
| 2907 |
} else |
| 2908 |
{ |
| 2909 |
draw_weapon_info(hudctx, player_info, weapon_num, player_info.laser_level, wt); |
| 2910 |
inset.old_weapon = weapon_num; |
| 2911 |
old_laser_level = player_info.laser_level; |
| 2912 |
} |
| 2913 |
|
| 2914 |
if (inset.box_state != weapon_box_state::set) //fade gauge |
| 2915 |
{ |
| 2916 |
int fade_value = f2i(inset_window[wt].fade_value); |
| 2917 |
|
| 2918 |
gr_settransblend(canvas, static_cast<gr_fade_level>(fade_value), gr_blend::normal); |
| 2919 |
auto &resbox = gauge_boxes[multires_gauge_graphic.hiresmode]; |
| 2920 |
auto &weaponbox = resbox[wt]; |
| 2921 |
auto &g = weaponbox[(PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) ? gauge_hud_type::statusbar : gauge_hud_type::cockpit]; |
| 2922 |
auto &canvas = hudctx.canvas; |
| 2923 |
gr_rect(canvas, hudctx.xscale(g.left), hudctx.yscale(g.top), hudctx.xscale(g.right), hudctx.yscale(g.bot), 0); |
| 2924 |
|
| 2925 |
gr_settransblend(canvas, GR_FADE_OFF, gr_blend::normal); |
| 2926 |
} |
| 2927 |
} |
| 2928 |
|
| 2929 |
} |
| 2930 |
|
| 2931 |
namespace dsx { |
| 2932 |
namespace { |
| 2933 |
#if DXX_BUILD_DESCENT == 2 |
| 2934 |
static void draw_static(const d_vclip_array &Vclip, const hud_draw_context_hs_mr hudctx, const gauge_inset_window_view win) |
| 2935 |
{ |
| 2936 |
const vclip *const vc = &Vclip[vclip_index::monitor_static]; |
| 2937 |
int framenum; |
| 2938 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 2939 |
#if !DXX_USE_OGL |
| 2940 |
int x,y; |
| 2941 |
#endif |
| 2942 |
|
| 2943 |
auto &time_static_played = inset_window[win].time_static_played; |
| 2944 |
time_static_played += FrameTime; |
| 2945 |
if (time_static_played >= vc->play_time) { |
| 2946 |
inset_window[win].user = weapon_box_user::weapon; |
| 2947 |
return; |
| 2948 |
} |
| 2949 |
|
| 2950 |
framenum = time_static_played * vc->num_frames / vc->play_time; |
| 2951 |
|
| 2952 |
PIGGY_PAGE_IN(vc->frames[framenum]); |
| 2953 |
|
| 2954 |
auto &bmp = GameBitmaps[vc->frames[framenum]]; |
| 2955 |
auto &resbox = gauge_boxes[multires_gauge_graphic.hiresmode]; |
| 2956 |
auto &weaponbox = resbox[win]; |
| 2957 |
auto &box = weaponbox[(PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) ? gauge_hud_type::statusbar : gauge_hud_type::cockpit]; |
| 2958 |
#if !DXX_USE_OGL |
| 2959 |
for (x = box.left; x < box.right; x += bmp.bm_w) |
| 2960 |
for (y = box.top; y < box.bot; y += bmp.bm_h) |
| 2961 |
gr_bitmap(hudctx.canvas, x, y, bmp); |
| 2962 |
#else |
| 2963 |
if (multires_gauge_graphic.is_hires()) |
| 2964 |
{ |
| 2965 |
const auto scaled_left = hudctx.xscale(box.left); |
| 2966 |
const auto scaled_top = hudctx.yscale(box.top); |
| 2967 |
const auto scaled_bottom = hudctx.yscale(box.bot - bmp.bm_h); |
| 2968 |
hud_bitblt_scaled_xy(hudctx, scaled_left, scaled_top, bmp); |
| 2969 |
hud_bitblt_scaled_xy(hudctx, scaled_left, scaled_bottom, bmp); |
| 2970 |
const auto scaled_right = hudctx.xscale(box.right - bmp.bm_w); |
| 2971 |
hud_bitblt_scaled_xy(hudctx, scaled_right, scaled_top, bmp); |
| 2972 |
hud_bitblt_scaled_xy(hudctx, scaled_right, scaled_bottom, bmp); |
| 2973 |
} |
| 2974 |
#endif |
| 2975 |
} |
| 2976 |
#endif |
| 2977 |
|
| 2978 |
static void draw_weapon_box0(const hud_draw_context_hs_mr hudctx, const player_info &player_info) |
| 2979 |
{ |
| 2980 |
#if DXX_BUILD_DESCENT == 2 |
| 2981 |
const auto user = inset_window[gauge_inset_window_view::primary].user; |
| 2982 |
if (user == weapon_box_user::weapon) |
| 2983 |
#endif |
| 2984 |
{ |
| 2985 |
const auto Primary_weapon = player_info.Primary_weapon; |
| 2986 |
draw_weapon_box(hudctx, player_info, Primary_weapon.get_active(), gauge_inset_window_view::primary); |
| 2987 |
|
| 2988 |
if (inset_window[gauge_inset_window_view::primary].box_state == weapon_box_state::set) |
| 2989 |
{ |
| 2990 |
unsigned nd_ammo; |
| 2991 |
unsigned ammo_count; |
| 2992 |
if (weapon_index_uses_vulcan_ammo(Primary_weapon)) |
| 2993 |
{ |
| 2994 |
nd_ammo = player_info.vulcan_ammo; |
| 2995 |
ammo_count = vulcan_ammo_scale(nd_ammo); |
| 2996 |
} |
| 2997 |
#if DXX_BUILD_DESCENT == 2 |
| 2998 |
else if (Primary_weapon == primary_weapon_index_t::OMEGA_INDEX) |
| 2999 |
{ |
| 3000 |
auto &Omega_charge = player_info.Omega_charge; |
| 3001 |
nd_ammo = Omega_charge; |
| 3002 |
ammo_count = Omega_charge * 100/MAX_OMEGA_CHARGE; |
| 3003 |
} |
| 3004 |
#endif |
| 3005 |
else |
| 3006 |
return; |
| 3007 |
if (Newdemo_state == ND_STATE_RECORDING) |
| 3008 |
newdemo_record_primary_ammo(nd_ammo); |
| 3009 |
draw_primary_ammo_info(hudctx, ammo_count); |
| 3010 |
} |
| 3011 |
} |
| 3012 |
#if DXX_BUILD_DESCENT == 2 |
| 3013 |
else if (user == weapon_box_user::post_missile_static) |
| 3014 |
draw_static(Vclip, hudctx, gauge_inset_window_view::primary); |
| 3015 |
#endif |
| 3016 |
} |
| 3017 |
|
| 3018 |
static void draw_weapon_box1(const hud_draw_context_hs_mr hudctx, const player_info &player_info) |
| 3019 |
{ |
| 3020 |
#if DXX_BUILD_DESCENT == 2 |
| 3021 |
if (inset_window[gauge_inset_window_view::secondary].user == weapon_box_user::weapon) |
| 3022 |
#endif |
| 3023 |
{ |
| 3024 |
auto &Secondary_weapon = player_info.Secondary_weapon; |
| 3025 |
draw_weapon_box(hudctx, player_info, Secondary_weapon.get_active(), gauge_inset_window_view::secondary); |
| 3026 |
if (inset_window[gauge_inset_window_view::secondary].box_state == weapon_box_state::set) |
| 3027 |
{ |
| 3028 |
const auto ammo = player_info.secondary_ammo[Secondary_weapon]; |
| 3029 |
if (Newdemo_state == ND_STATE_RECORDING) |
| 3030 |
newdemo_record_secondary_ammo(ammo); |
| 3031 |
draw_secondary_ammo_info(hudctx, ammo); |
| 3032 |
} |
| 3033 |
} |
| 3034 |
#if DXX_BUILD_DESCENT == 2 |
| 3035 |
else if (inset_window[gauge_inset_window_view::secondary].user == weapon_box_user::post_missile_static) |
| 3036 |
draw_static(Vclip, hudctx, gauge_inset_window_view::secondary); |
| 3037 |
#endif |
| 3038 |
} |
| 3039 |
|
| 3040 |
static void draw_weapon_boxes(const hud_draw_context_hs_mr hudctx, const player_info &player_info) |
| 3041 |
{ |
| 3042 |
draw_weapon_box0(hudctx, player_info); |
| 3043 |
draw_weapon_box1(hudctx, player_info); |
| 3044 |
} |
| 3045 |
|
| 3046 |
static void sb_draw_energy_bar(const hud_draw_context_hs_mr hudctx, const unsigned energy) |
| 3047 |
{ |
| 3048 |
|
| 3049 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 3050 |
hud_gauge_bitblt(hudctx, SB_ENERGY_GAUGE_X, SB_ENERGY_GAUGE_Y, SB_GAUGE_ENERGY); |
| 3051 |
|
| 3052 |
auto &canvas = hudctx.canvas; |
| 3053 |
if (energy <= 100) |
| 3054 |
{ |
| 3055 |
const auto color{0}; |
| 3056 |
const int erase_x0 = i2f(hudctx.xscale(SB_ENERGY_GAUGE_X)); |
| 3057 |
const int erase_x1 = i2f(hudctx.xscale(SB_ENERGY_GAUGE_X + SB_ENERGY_GAUGE_W)); |
| 3058 |
const int erase_y_base = hudctx.yscale(SB_ENERGY_GAUGE_Y); |
| 3059 |
for (int i = hudctx.yscale((100 - energy) * SB_ENERGY_GAUGE_H / 100); i-- > 0;) |
| 3060 |
{ |
| 3061 |
const int erase_y = i2f(erase_y_base + i); |
| 3062 |
gr_uline(canvas, erase_x0, erase_y, erase_x1, erase_y, color); |
| 3063 |
} |
| 3064 |
} |
| 3065 |
|
| 3066 |
//draw numbers |
| 3067 |
gr_set_fontcolor(canvas, BM_XRGB(25, 18, 6), -1); |
| 3068 |
const auto ew = gr_get_string_size(*canvas.cv_font, get_gauge_width_string(energy)).width; |
| 3069 |
#if DXX_BUILD_DESCENT == 1 |
| 3070 |
unsigned y = SB_ENERGY_NUM_Y; |
| 3071 |
#elif DXX_BUILD_DESCENT == 2 |
| 3072 |
unsigned y = SB_ENERGY_GAUGE_Y + SB_ENERGY_GAUGE_H - GAME_FONT->ft_h - (GAME_FONT->ft_h / 4); |
| 3073 |
#endif |
| 3074 |
gr_printf(canvas, *canvas.cv_font, (grd_curscreen->get_screen_width() / 3) - (ew / 2), hudctx.yscale(y), "%d", energy); |
| 3075 |
} |
| 3076 |
|
| 3077 |
#if DXX_BUILD_DESCENT == 2 |
| 3078 |
static void sb_draw_afterburner(const hud_draw_context_hs_mr hudctx, const player_info &player_info) |
| 3079 |
{ |
| 3080 |
auto &ab_str = "AB"; |
| 3081 |
|
| 3082 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 3083 |
hud_gauge_bitblt(hudctx, SB_AFTERBURNER_GAUGE_X, SB_AFTERBURNER_GAUGE_Y, SB_GAUGE_AFTERBURNER); |
| 3084 |
|
| 3085 |
const auto color{0}; |
| 3086 |
const int erase_x0 = i2f(hudctx.xscale(SB_AFTERBURNER_GAUGE_X)); |
| 3087 |
const int erase_x1 = i2f(hudctx.xscale(SB_AFTERBURNER_GAUGE_X + (SB_AFTERBURNER_GAUGE_W))); |
| 3088 |
const int erase_y_base = hudctx.yscale(SB_AFTERBURNER_GAUGE_Y); |
| 3089 |
for (int i = hudctx.yscale(fixmul((f1_0 - Afterburner_charge), SB_AFTERBURNER_GAUGE_H)); i-- > 0;) |
| 3090 |
{ |
| 3091 |
const int erase_y = i2f(erase_y_base + i); |
| 3092 |
gr_uline(hudctx.canvas, erase_x0, erase_y, erase_x1, erase_y, color); |
| 3093 |
} |
| 3094 |
|
| 3095 |
//draw legend |
| 3096 |
unsigned r, g, b; |
| 3097 |
if (player_info.powerup_flags & PLAYER_FLAGS_AFTERBURNER) |
| 3098 |
r = 90, g = b = 0; |
| 3099 |
else |
| 3100 |
r = g = b = 24; |
| 3101 |
auto &canvas = hudctx.canvas; |
| 3102 |
gr_set_fontcolor(canvas, gr_find_closest_color(r, g, b), -1); |
| 3103 |
|
| 3104 |
const auto &&[w, h] = gr_get_string_size(*canvas.cv_font, ab_str); |
| 3105 |
gr_string(canvas, *canvas.cv_font, hudctx.xscale(SB_AFTERBURNER_GAUGE_X + (SB_AFTERBURNER_GAUGE_W + 1) / 2) - (w / 2), hudctx.yscale(SB_AFTERBURNER_GAUGE_Y + (SB_AFTERBURNER_GAUGE_H - GAME_FONT->ft_h - (GAME_FONT->ft_h / 4))), ab_str, w, h); |
| 3106 |
} |
| 3107 |
#endif |
| 3108 |
|
| 3109 |
} |
| 3110 |
} |
| 3111 |
|
| 3112 |
namespace { |
| 3113 |
|
| 3114 |
static void sb_draw_shield_num(const hud_draw_context_hs_mr hudctx, const unsigned shield) |
| 3115 |
{ |
| 3116 |
//draw numbers |
| 3117 |
auto &canvas = hudctx.canvas; |
| 3118 |
gr_set_fontcolor(canvas, BM_XRGB(14, 14, 23), -1); |
| 3119 |
|
| 3120 |
auto &game_font = *GAME_FONT; |
| 3121 |
const auto sw = gr_get_string_size(game_font, get_gauge_width_string(shield)).width; |
| 3122 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 3123 |
gr_printf(canvas, game_font, (grd_curscreen->get_screen_width() / 2.266) - (sw / 2), hudctx.yscale(SB_SHIELD_NUM_Y), "%d", shield); |
| 3124 |
} |
| 3125 |
|
| 3126 |
static void sb_draw_shield_bar(const hud_draw_context_hs_mr hudctx, const int shield) |
| 3127 |
{ |
| 3128 |
int bm_num = shield>=100?9:(shield / 10); |
| 3129 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 3130 |
hud_gauge_bitblt(hudctx, SB_SHIELD_GAUGE_X, SB_SHIELD_GAUGE_Y, GAUGE_SHIELDS+9-bm_num); |
| 3131 |
} |
| 3132 |
|
| 3133 |
} |
| 3134 |
|
| 3135 |
namespace dsx { |
| 3136 |
namespace { |
| 3137 |
|
| 3138 |
void draw_keys_state::draw_all_statusbar_keys() |
| 3139 |
{ |
| 3140 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 3141 |
draw_one_key(SB_GAUGE_KEYS_X, SB_GAUGE_BLUE_KEY_Y, SB_GAUGE_BLUE_KEY, PLAYER_FLAGS_BLUE_KEY); |
| 3142 |
draw_one_key(SB_GAUGE_KEYS_X, SB_GAUGE_GOLD_KEY_Y, SB_GAUGE_GOLD_KEY, PLAYER_FLAGS_GOLD_KEY); |
| 3143 |
draw_one_key(SB_GAUGE_KEYS_X, SB_GAUGE_RED_KEY_Y, SB_GAUGE_RED_KEY, PLAYER_FLAGS_RED_KEY); |
| 3144 |
} |
| 3145 |
|
| 3146 |
// Draws invulnerable ship, or maybe the flashing ship, depending on invulnerability time left. |
| 3147 |
static void draw_invulnerable_ship(const hud_draw_context_hs_mr hudctx, const object &plrobj) |
| 3148 |
{ |
| 3149 |
auto &player_info = plrobj.ctype.player_info; |
| 3150 |
const auto cmmode = PlayerCfg.CockpitMode[1]; |
| 3151 |
const auto t = player_info.invulnerable_time; |
| 3152 |
if (t + INVULNERABLE_TIME_MAX - GameTime64 > F1_0*4 || GameTime64 & 0x8000) |
| 3153 |
{ |
| 3154 |
static fix time; |
| 3155 |
auto ltime = time + FrameTime; |
| 3156 |
const auto old_invulnerable_frame{invulnerable_frame}; |
| 3157 |
while (ltime > INV_FRAME_TIME) |
| 3158 |
{ |
| 3159 |
ltime -= INV_FRAME_TIME; |
| 3160 |
if (++invulnerable_frame == N_INVULNERABLE_FRAMES) |
| 3161 |
invulnerable_frame=0; |
| 3162 |
} |
| 3163 |
time = ltime; |
| 3164 |
unsigned x, y; |
| 3165 |
auto &multires_gauge_graphic = hudctx.multires_gauge_graphic; |
| 3166 |
if (cmmode == cockpit_mode_t::status_bar) |
| 3167 |
{ |
| 3168 |
x = SB_SHIELD_GAUGE_X; |
| 3169 |
y = SB_SHIELD_GAUGE_Y; |
| 3170 |
} |
| 3171 |
else |
| 3172 |
{ |
| 3173 |
x = SHIELD_GAUGE_X; |
| 3174 |
y = SHIELD_GAUGE_Y; |
| 3175 |
} |
| 3176 |
hud_gauge_bitblt(hudctx, x, y, GAUGE_INVULNERABLE + old_invulnerable_frame); |
| 3177 |
|
| 3178 |
// Show Invulnerability Timer if enabled |
| 3179 |
if (show_cloak_invul_timer()) |
| 3180 |
show_cockpit_cloak_invul_timer(hudctx.canvas, t + INVULNERABLE_TIME_MAX - GameTime64, hudctx.yscale(y)); |
| 3181 |
} |
| 3182 |
else |
| 3183 |
{ |
| 3184 |
const auto shields_ir = f2ir(plrobj.shields); |
| 3185 |
if (cmmode == cockpit_mode_t::status_bar) |
| 3186 |
sb_draw_shield_bar(hudctx, shields_ir); |
| 3187 |
else |
| 3188 |
draw_shield_bar(hudctx, shields_ir); |
| 3189 |
} |
| 3190 |
} |
| 3191 |
|
| 3192 |
} |
| 3193 |
} |
| 3194 |
|
| 3195 |
constexpr rgb_array_t player_rgb_normal{{ |
| 3196 |
/* These colors are mentioned by approximate name as members of |
| 3197 |
* `player_ship_color`. |
| 3198 |
*/ |
| 3199 |
{15,15,23}, |
| 3200 |
{27,0,0}, |
| 3201 |
{0,23,0}, |
| 3202 |
{30,11,31}, |
| 3203 |
{31,16,0}, |
| 3204 |
{24,17,6}, |
| 3205 |
{14,21,12}, |
| 3206 |
{29,29,0}, |
| 3207 |
}}; |
| 3208 |
|
| 3209 |
namespace { |
| 3210 |
|
| 3211 |
struct xy { |
| 3212 |
sbyte x, y; |
| 3213 |
}; |
| 3214 |
|
| 3215 |
//offsets for reticle parts: high-big high-sml low-big low-sml |
| 3216 |
const std::array<xy, 4> cross_offsets{{ |
| 3217 |
{-8,-5}, |
| 3218 |
{-4,-2}, |
| 3219 |
{-4,-2}, |
| 3220 |
{-2,-1} |
| 3221 |
}}, |
| 3222 |
primary_offsets{{ |
| 3223 |
{-30,14}, |
| 3224 |
{-16,6}, |
| 3225 |
{-15,6}, |
| 3226 |
{-8, 2} |
| 3227 |
}}, |
| 3228 |
secondary_offsets{{ |
| 3229 |
{-24,2}, |
| 3230 |
{-12,0}, |
| 3231 |
{-12,1}, |
| 3232 |
{-6,-2} |
| 3233 |
}}; |
| 3234 |
|
| 3235 |
} |
| 3236 |
|
| 3237 |
//draw the reticle |
| 3238 |
namespace dsx { |
| 3239 |
void show_reticle(grs_canvas &canvas, const player_info &player_info, enum reticle_type reticle_type, int secondary_display) |
| 3240 |
{ |
| 3241 |
int x,y,size; |
| 3242 |
int laser_ready,missile_ready; |
| 3243 |
int cross_bm_num,primary_bm_num,secondary_bm_num; |
| 3244 |
int gauge_index; |
| 3245 |
|
| 3246 |
#if DXX_BUILD_DESCENT == 2 |
| 3247 |
if (Newdemo_state==ND_STATE_PLAYBACK && Viewer->type != OBJ_PLAYER) |
| 3248 |
return; |
| 3249 |
#endif |
| 3250 |
|
| 3251 |
x = canvas.cv_bitmap.bm_w/2; |
| 3252 |
y = canvas.cv_bitmap.bm_h/2; |
| 3253 |
size = (canvas.cv_bitmap.bm_h / (32-(PlayerCfg.ReticleSize*4))); |
| 3254 |
|
| 3255 |
laser_ready = allowed_to_fire_laser(player_info); |
| 3256 |
|
| 3257 |
missile_ready = allowed_to_fire_missile(player_info); |
| 3258 |
auto &Primary_weapon = player_info.Primary_weapon; |
| 3259 |
primary_bm_num = (laser_ready && has_all(player_has_primary_weapon(player_info, Primary_weapon))); |
| 3260 |
auto &Secondary_weapon = player_info.Secondary_weapon; |
| 3261 |
secondary_bm_num = (missile_ready && has_all(player_has_secondary_weapon(player_info, Secondary_weapon))); |
| 3262 |
|
| 3263 |
if (primary_bm_num && Primary_weapon == primary_weapon_index_t::LASER_INDEX && (player_info.powerup_flags & PLAYER_FLAGS_QUAD_LASERS)) |
| 3264 |
primary_bm_num++; |
| 3265 |
|
| 3266 |
if (Secondary_weapon_to_gun_num[Secondary_weapon] == player_gun_number::_7) |
| 3267 |
secondary_bm_num += 3; //now value is 0,1 or 3,4 |
| 3268 |
else if (secondary_bm_num && !(player_info.missile_gun & 1)) |
| 3269 |
secondary_bm_num++; |
| 3270 |
|
| 3271 |
cross_bm_num = ((primary_bm_num > 0) || (secondary_bm_num > 0)); |
| 3272 |
|
| 3273 |
Assert(primary_bm_num <= 2); |
| 3274 |
Assert(secondary_bm_num <= 4); |
| 3275 |
Assert(cross_bm_num <= 1); |
| 3276 |
|
| 3277 |
const auto color = BM_XRGB(PlayerCfg.ReticleRGBA[0],PlayerCfg.ReticleRGBA[1],PlayerCfg.ReticleRGBA[2]); |
| 3278 |
gr_settransblend(canvas, static_cast<gr_fade_level>(PlayerCfg.ReticleRGBA[3]), gr_blend::normal); |
| 3279 |
|
| 3280 |
[&]{ |
| 3281 |
int x0, x1, y0, y1; |
| 3282 |
switch (reticle_type) |
| 3283 |
{ |
| 3284 |
case reticle_type::classic: |
| 3285 |
{ |
| 3286 |
const local_multires_gauge_graphic multires_gauge_graphic{}; |
| 3287 |
const hud_draw_context_hs_mr hudctx(canvas, grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height(), multires_gauge_graphic); |
| 3288 |
const auto use_hires_reticle = multires_gauge_graphic.is_hires(); |
| 3289 |
const unsigned ofs = (use_hires_reticle ? 0 : 2); |
| 3290 |
gauge_index = RETICLE_CROSS + cross_bm_num; |
| 3291 |
PAGE_IN_GAUGE(gauge_index, multires_gauge_graphic); |
| 3292 |
auto &cross = GameBitmaps[GET_GAUGE_INDEX(gauge_index)]; |
| 3293 |
const auto &&hud_scale_ar = HUD_SCALE_AR(hudctx.xscale, hudctx.yscale); |
| 3294 |
hud_bitblt_free(canvas, x + hud_scale_ar(cross_offsets[ofs].x), y + hud_scale_ar(cross_offsets[ofs].y), hud_scale_ar(cross.bm_w), hud_scale_ar(cross.bm_h), cross); |
| 3295 |
|
| 3296 |
gauge_index = RETICLE_PRIMARY + primary_bm_num; |
| 3297 |
PAGE_IN_GAUGE(gauge_index, multires_gauge_graphic); |
| 3298 |
auto &primary = GameBitmaps[GET_GAUGE_INDEX(gauge_index)]; |
| 3299 |
hud_bitblt_free(canvas, x + hud_scale_ar(primary_offsets[ofs].x), y + hud_scale_ar(primary_offsets[ofs].y), hud_scale_ar(primary.bm_w), hud_scale_ar(primary.bm_h), primary); |
| 3300 |
|
| 3301 |
gauge_index = RETICLE_SECONDARY + secondary_bm_num; |
| 3302 |
PAGE_IN_GAUGE(gauge_index, multires_gauge_graphic); |
| 3303 |
auto &secondary = GameBitmaps[GET_GAUGE_INDEX(gauge_index)]; |
| 3304 |
hud_bitblt_free(canvas, x + hud_scale_ar(secondary_offsets[ofs].x), y + hud_scale_ar(secondary_offsets[ofs].y), hud_scale_ar(secondary.bm_w), hud_scale_ar(secondary.bm_h), secondary); |
| 3305 |
return; |
| 3306 |
} |
| 3307 |
case reticle_type::classic_reboot: |
| 3308 |
#if DXX_USE_OGL |
| 3309 |
ogl_draw_vertex_reticle(canvas, cross_bm_num,primary_bm_num,secondary_bm_num,BM_XRGB(PlayerCfg.ReticleRGBA[0],PlayerCfg.ReticleRGBA[1],PlayerCfg.ReticleRGBA[2]),PlayerCfg.ReticleRGBA[3],PlayerCfg.ReticleSize); |
| 3310 |
#endif |
| 3311 |
return; |
| 3312 |
case reticle_type::x: |
| 3313 |
{ |
| 3314 |
gr_uline(canvas, i2f(x-(size/2)), i2f(y-(size/2)), i2f(x-(size/5)), i2f(y-(size/5)), color); // top-left |
| 3315 |
gr_uline(canvas, i2f(x+(size/2)), i2f(y-(size/2)), i2f(x+(size/5)), i2f(y-(size/5)), color); // top-right |
| 3316 |
gr_uline(canvas, i2f(x-(size/2)), i2f(y+(size/2)), i2f(x-(size/5)), i2f(y+(size/5)), color); // bottom-left |
| 3317 |
gr_uline(canvas, i2f(x+(size/2)), i2f(y+(size/2)), i2f(x+(size/5)), i2f(y+(size/5)), color); // bottom-right |
| 3318 |
if (secondary_display && secondary_bm_num == 1) |
| 3319 |
x0 = i2f(x-(size/2)-(size/5)), y0 = i2f(y-(size/2)), x1 = i2f(x-(size/5)-(size/5)), y1 = i2f(y-(size/5)); |
| 3320 |
else if (secondary_display && secondary_bm_num == 2) |
| 3321 |
x0 = i2f(x+(size/2)+(size/5)), y0 = i2f(y-(size/2)), x1 = i2f(x+(size/5)+(size/5)), y1 = i2f(y-(size/5)); |
| 3322 |
else if (secondary_display && secondary_bm_num == 4) |
| 3323 |
x0 = i2f(x+(size/2)), y0 = i2f(y+(size/2)+(size/5)), x1 = i2f(x+(size/5)), y1 = i2f(y+(size/5)+(size/5)); |
| 3324 |
else |
| 3325 |
return; |
| 3326 |
} |
| 3327 |
break; |
| 3328 |
case reticle_type::dot: |
| 3329 |
{ |
| 3330 |
gr_disk(canvas, i2f(x), i2f(y), i2f(size/5), color); |
| 3331 |
if (secondary_display && secondary_bm_num == 1) |
| 3332 |
x0 = i2f(x-(size/2)-(size/5)), y0 = i2f(y-(size/2)), x1 = i2f(x-(size/5)-(size/5)), y1 = i2f(y-(size/5)); |
| 3333 |
else if (secondary_display && secondary_bm_num == 2) |
| 3334 |
x0 = i2f(x+(size/2)+(size/5)), y0 = i2f(y-(size/2)), x1 = i2f(x+(size/5)+(size/5)), y1 = i2f(y-(size/5)); |
| 3335 |
else if (secondary_display && secondary_bm_num == 4) |
| 3336 |
x0 = i2f(x), y0 = i2f(y+(size/2)+(size/5)), x1 = i2f(x), y1 = i2f(y+(size/5)+(size/5)); |
| 3337 |
else |
| 3338 |
return; |
| 3339 |
} |
| 3340 |
break; |
| 3341 |
case reticle_type::circle: |
| 3342 |
{ |
| 3343 |
gr_ucircle(canvas, i2f(x), i2f(y), i2f(size/4), color); |
| 3344 |
if (secondary_display && secondary_bm_num == 1) |
| 3345 |
x0 = i2f(x-(size/2)-(size/5)), y0 = i2f(y-(size/2)), x1 = i2f(x-(size/5)-(size/5)), y1 = i2f(y-(size/5)); |
| 3346 |
else if (secondary_display && secondary_bm_num == 2) |
| 3347 |
x0 = i2f(x+(size/2)+(size/5)), y0 = i2f(y-(size/2)), x1 = i2f(x+(size/5)+(size/5)), y1 = i2f(y-(size/5)); |
| 3348 |
else if (secondary_display && secondary_bm_num == 4) |
| 3349 |
x0 = i2f(x), y0 = i2f(y+(size/2)+(size/5)), x1 = i2f(x), y1 = i2f(y+(size/5)+(size/5)); |
| 3350 |
else |
| 3351 |
return; |
| 3352 |
} |
| 3353 |
break; |
| 3354 |
case reticle_type::cross_v1: |
| 3355 |
{ |
| 3356 |
gr_uline(canvas, i2f(x),i2f(y-(size/2)),i2f(x),i2f(y+(size/2)+1), color); // horiz |
| 3357 |
gr_uline(canvas, i2f(x-(size/2)),i2f(y),i2f(x+(size/2)+1),i2f(y), color); // vert |
| 3358 |
if (secondary_display && secondary_bm_num == 1) |
| 3359 |
x0 = i2f(x-(size/2)), y0 = i2f(y-(size/2)), x1 = i2f(x-(size/5)), y1 = i2f(y-(size/5)); |
| 3360 |
else if (secondary_display && secondary_bm_num == 2) |
| 3361 |
x0 = i2f(x+(size/2)), y0 = i2f(y-(size/2)), x1 = i2f(x+(size/5)), y1 = i2f(y-(size/5)); |
| 3362 |
else if (secondary_display && secondary_bm_num == 4) |
| 3363 |
x0 = i2f(x-(size/2)), y0 = i2f(y+(size/2)), x1 = i2f(x-(size/5)), y1 = i2f(y+(size/5)); |
| 3364 |
else |
| 3365 |
return; |
| 3366 |
} |
| 3367 |
break; |
| 3368 |
case reticle_type::cross_v2: |
| 3369 |
{ |
| 3370 |
gr_uline(canvas, i2f(x), i2f(y-(size/2)), i2f(x), i2f(y-(size/6)), color); // vert-top |
| 3371 |
gr_uline(canvas, i2f(x), i2f(y+(size/2)), i2f(x), i2f(y+(size/6)), color); // vert-bottom |
| 3372 |
gr_uline(canvas, i2f(x-(size/2)), i2f(y), i2f(x-(size/6)), i2f(y), color); // horiz-left |
| 3373 |
gr_uline(canvas, i2f(x+(size/2)), i2f(y), i2f(x+(size/6)), i2f(y), color); // horiz-right |
| 3374 |
if (secondary_display && secondary_bm_num == 1) |
| 3375 |
x0 = i2f(x-(size/2)), y0 = i2f(y-(size/2)), x1 = i2f(x-(size/5)), y1 = i2f(y-(size/5)); |
| 3376 |
else if (secondary_display && secondary_bm_num == 2) |
| 3377 |
x0 = i2f(x+(size/2)), y0 = i2f(y-(size/2)), x1 = i2f(x+(size/5)), y1 = i2f(y-(size/5)); |
| 3378 |
else if (secondary_display && secondary_bm_num == 4) |
| 3379 |
x0 = i2f(x-(size/2)), y0 = i2f(y+(size/2)), x1 = i2f(x-(size/5)), y1 = i2f(y+(size/5)); |
| 3380 |
else |
| 3381 |
return; |
| 3382 |
} |
| 3383 |
break; |
| 3384 |
case reticle_type::angle: |
| 3385 |
{ |
| 3386 |
gr_uline(canvas, i2f(x),i2f(y),i2f(x),i2f(y+(size/2)), color); // vert |
| 3387 |
gr_uline(canvas, i2f(x),i2f(y),i2f(x+(size/2)),i2f(y), color); // horiz |
| 3388 |
if (secondary_display && secondary_bm_num == 1) |
| 3389 |
x0 = i2f(x-(size/2)), y0 = i2f(y-(size/2)), x1 = i2f(x-(size/5)), y1 = i2f(y-(size/5)); |
| 3390 |
else if (secondary_display && secondary_bm_num == 2) |
| 3391 |
x0 = i2f(x+(size/2)), y0 = i2f(y-(size/2)), x1 = i2f(x+(size/5)), y1 = i2f(y-(size/5)); |
| 3392 |
else if (secondary_display && secondary_bm_num == 4) |
| 3393 |
x0 = i2f(x-(size/2)), y0 = i2f(y+(size/2)), x1 = i2f(x-(size/5)), y1 = i2f(y+(size/5)); |
| 3394 |
else |
| 3395 |
return; |
| 3396 |
} |
| 3397 |
break; |
| 3398 |
case reticle_type::none: |
| 3399 |
default: |
| 3400 |
return; |
| 3401 |
} |
| 3402 |
gr_uline(canvas, x0, y0, x1, y1, color); |
| 3403 |
}(); |
| 3404 |
gr_settransblend(canvas, GR_FADE_OFF, gr_blend::normal); |
| 3405 |
} |
| 3406 |
} |
| 3407 |
|
| 3408 |
namespace dcx { |
| 3409 |
|
| 3410 |
void show_mousefs_indicator(grs_canvas &canvas, int mx, int my, int mz, int x, int y, int size) |
| 3411 |
{ |
| 3412 |
int axscale = (MOUSEFS_DELTA_RANGE*2)/size, xaxpos = x+(mx/axscale), yaxpos = y+(my/axscale), zaxpos = y+(mz/axscale); |
| 3413 |
|
| 3414 |
gr_settransblend(canvas, static_cast<gr_fade_level>(PlayerCfg.ReticleRGBA[3]), gr_blend::normal); |
| 3415 |
auto &rgba = PlayerCfg.ReticleRGBA; |
| 3416 |
const auto color = BM_XRGB(rgba[0], rgba[1], rgba[2]); |
| 3417 |
gr_uline(canvas, i2f(xaxpos), i2f(y-(size/2)), i2f(xaxpos), i2f(y-(size/4)), color); |
| 3418 |
gr_uline(canvas, i2f(xaxpos), i2f(y+(size/2)), i2f(xaxpos), i2f(y+(size/4)), color); |
| 3419 |
gr_uline(canvas, i2f(x-(size/2)), i2f(yaxpos), i2f(x-(size/4)), i2f(yaxpos), color); |
| 3420 |
gr_uline(canvas, i2f(x+(size/2)), i2f(yaxpos), i2f(x+(size/4)), i2f(yaxpos), color); |
| 3421 |
const local_multires_gauge_graphic multires_gauge_graphic{}; |
| 3422 |
auto &&hud_scale_ar = HUD_SCALE_AR(grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height(), multires_gauge_graphic); |
| 3423 |
auto &&hud_scale_ar2 = hud_scale_ar(2); |
| 3424 |
gr_uline(canvas, i2f(x + (size / 2) + hud_scale_ar2), i2f(y), i2f(x + (size / 2) + hud_scale_ar2), i2f(zaxpos), color); |
| 3425 |
gr_settransblend(canvas, GR_FADE_OFF, gr_blend::normal); |
| 3426 |
} |
| 3427 |
|
| 3428 |
} |
| 3429 |
|
| 3430 |
namespace dsx { |
| 3431 |
namespace { |
| 3432 |
|
| 3433 |
static void hud_show_kill_list(fvcobjptr &vcobjptr, grs_canvas &canvas, const game_mode_flags Game_mode) |
| 3434 |
{ |
| 3435 |
playernum_array_t player_list; |
| 3436 |
int n_left,x0,x1,x2,y,save_y; |
| 3437 |
|
| 3438 |
if (Show_kill_list_timer > 0) |
| 3439 |
{ |
| 3440 |
Show_kill_list_timer -= FrameTime; |
| 3441 |
if (Show_kill_list_timer < 0) |
| 3442 |
Show_kill_list = show_kill_list_mode::None; |
| 3443 |
} |
| 3444 |
|
| 3445 |
const playernum_t n_players = (Show_kill_list == show_kill_list_mode::team_kills) |
| 3446 |
? 2 |
| 3447 |
: multi_get_kill_list(player_list); |
| 3448 |
|
| 3449 |
if (n_players <= 4) |
| 3450 |
n_left = n_players; |
| 3451 |
else |
| 3452 |
n_left = (n_players+1)/2; |
| 3453 |
|
| 3454 |
const auto &&fspacx = FSPACX(); |
| 3455 |
const auto &&fspacx43 = fspacx(43); |
| 3456 |
|
| 3457 |
x1 = fspacx43; |
| 3458 |
|
| 3459 |
const auto is_multiplayer_cooperative = Game_mode & GM_MULTI_COOP; |
| 3460 |
if (is_multiplayer_cooperative) |
| 3461 |
x1 = fspacx(31); |
| 3462 |
|
| 3463 |
auto &game_font = *GAME_FONT; |
| 3464 |
const auto &&line_spacing = LINE_SPACING(game_font, game_font); |
| 3465 |
save_y = y = canvas.cv_bitmap.bm_h - n_left * line_spacing; |
| 3466 |
|
| 3467 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_cockpit) |
| 3468 |
{ |
| 3469 |
save_y = y -= fspacx(6); |
| 3470 |
if (is_multiplayer_cooperative) |
| 3471 |
x1 = fspacx(33); |
| 3472 |
} |
| 3473 |
|
| 3474 |
const auto bm_w = canvas.cv_bitmap.bm_w; |
| 3475 |
const auto &&bmw_x0_cockpit = bm_w - fspacx(PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_cockpit ? 53 : 60); |
| 3476 |
// Right edge of name, change this for width problems |
| 3477 |
const auto &&bmw_x1_multi = bm_w - fspacx(is_multiplayer_cooperative ? 27 : 15); |
| 3478 |
const auto &&fspacx1 = fspacx(1); |
| 3479 |
const auto &&fspacx2 = fspacx(2); |
| 3480 |
const auto &&fspacx18 = fspacx(18); |
| 3481 |
const auto &&fspacx35 = fspacx(35); |
| 3482 |
const auto &&fspacx64 = fspacx(64); |
| 3483 |
x0 = fspacx1; |
| 3484 |
for (const uint8_t i : xrange(n_players)) |
| 3485 |
{ |
| 3486 |
playernum_t player_num; |
| 3487 |
callsign_t name; |
| 3488 |
|
| 3489 |
if (i>=n_left) { |
| 3490 |
x0 = bmw_x0_cockpit; |
| 3491 |
x1 = bmw_x1_multi; |
| 3492 |
if (PlayerCfg.MultiPingHud) |
| 3493 |
{ |
| 3494 |
x0 -= fspacx35; |
| 3495 |
x1 -= fspacx35; |
| 3496 |
} |
| 3497 |
if (i==n_left) |
| 3498 |
y = save_y; |
| 3499 |
|
| 3500 |
if (Netgame.KillGoal || Netgame.PlayTimeAllowed.count()) |
| 3501 |
x1 -= fspacx18; |
| 3502 |
} |
| 3503 |
else if (Netgame.KillGoal || Netgame.PlayTimeAllowed.count()) |
| 3504 |
{ |
| 3505 |
x1 = fspacx43; |
| 3506 |
x1 -= fspacx18; |
| 3507 |
} |
| 3508 |
|
| 3509 |
if (Show_kill_list == show_kill_list_mode::team_kills) |
| 3510 |
player_num = i; |
| 3511 |
else |
| 3512 |
player_num = player_list[i]; |
| 3513 |
auto &p = *vcplayerptr(player_num); |
| 3514 |
|
| 3515 |
color_t fontcolor; |
| 3516 |
rgb color; |
| 3517 |
if (Show_kill_list == show_kill_list_mode::_1 || Show_kill_list == show_kill_list_mode::efficiency) |
| 3518 |
{ |
| 3519 |
if (vcplayerptr(player_num)->connected != player_connection_status::playing) |
| 3520 |
color.r = color.g = color.b = 12; |
| 3521 |
else { |
| 3522 |
color = player_rgb[get_player_or_team_color(Netgame, Game_mode, player_num)]; |
| 3523 |
} |
| 3524 |
} |
| 3525 |
else |
| 3526 |
{ |
| 3527 |
color = player_rgb[static_cast<player_ship_color>(player_num)]; |
| 3528 |
} |
| 3529 |
fontcolor = BM_XRGB(color.r, color.g, color.b); |
| 3530 |
gr_set_fontcolor(canvas, fontcolor, -1); |
| 3531 |
|
| 3532 |
if (Show_kill_list == show_kill_list_mode::team_kills) |
| 3533 |
name = Netgame.team_name[(team_number{i})]; |
| 3534 |
else if ((Game_mode & GM_BOUNTY) && player_num == Bounty_target && (GameTime64 & 0x10000)) |
| 3535 |
{ |
| 3536 |
name = "[TARGET]"; |
| 3537 |
} |
| 3538 |
else |
| 3539 |
name = vcplayerptr(player_num)->callsign; // Note link to above if!! |
| 3540 |
auto [sw, sh] = gr_get_string_size(game_font, static_cast<const char *>(name)); |
| 3541 |
{ |
| 3542 |
const auto b = x1 - x0 - fspacx2; |
| 3543 |
if (sw > b) |
| 3544 |
for (char *e = &name.buffer()[strlen(name)];;) |
| 3545 |
{ |
| 3546 |
*--e = 0; |
| 3547 |
sw = gr_get_string_size(game_font, name).width; |
| 3548 |
if (!(sw > b)) |
| 3549 |
break; |
| 3550 |
} |
| 3551 |
} |
| 3552 |
gr_string(canvas, game_font, x0, y, name, sw, sh); |
| 3553 |
|
| 3554 |
auto &player_info = vcobjptr(p.objnum)->ctype.player_info; |
| 3555 |
if (Show_kill_list == show_kill_list_mode::efficiency) |
| 3556 |
{ |
| 3557 |
const int eff = (player_info.net_killed_total + player_info.net_kills_total <= 0) |
| 3558 |
? 0 |
| 3559 |
: static_cast<int>( |
| 3560 |
static_cast<float>(player_info.net_kills_total) / ( |
| 3561 |
static_cast<float>(player_info.net_killed_total) + static_cast<float>(player_info.net_kills_total) |
| 3562 |
) * 100.0 |
| 3563 |
); |
| 3564 |
gr_printf(canvas, game_font, x1, y, "%i%%", eff <= 0 ? 0 : eff); |
| 3565 |
} |
| 3566 |
else if (Show_kill_list == show_kill_list_mode::team_kills) |
| 3567 |
gr_printf(canvas, game_font, x1, y, "%3d", team_kills[(team_number{i})]); |
| 3568 |
else if (is_multiplayer_cooperative) |
| 3569 |
gr_printf(canvas, game_font, x1, y, "%-6d", player_info.mission.score); |
| 3570 |
else if (Netgame.KillGoal || Netgame.PlayTimeAllowed.count()) |
| 3571 |
gr_printf(canvas, game_font, x1, y, "%3d(%d)", player_info.net_kills_total, player_info.KillGoalCount); |
| 3572 |
else |
| 3573 |
gr_printf(canvas, game_font, x1, y, "%3d", player_info.net_kills_total); |
| 3574 |
|
| 3575 |
if (PlayerCfg.MultiPingHud && Show_kill_list != show_kill_list_mode::team_kills) |
| 3576 |
{ |
| 3577 |
if (is_multiplayer_cooperative) |
| 3578 |
x2 = SWIDTH - (fspacx64/2); |
| 3579 |
else |
| 3580 |
x2 = x0 + fspacx64; |
| 3581 |
gr_printf(canvas, game_font, x2, y, "%4dms", Netgame.players[player_num].ping); |
| 3582 |
} |
| 3583 |
|
| 3584 |
y += line_spacing; |
| 3585 |
} |
| 3586 |
} |
| 3587 |
|
| 3588 |
//returns true if viewer can see object |
| 3589 |
static int see_object(const d_robot_info_array &Robot_info, fvcobjptridx &vcobjptridx, const vcobjptridx_t objnum) |
| 3590 |
{ |
| 3591 |
fvi_info hit_data; |
| 3592 |
|
| 3593 |
//see if we can see this player |
| 3594 |
const auto hit_type = find_vector_intersection(fvi_query{ |
| 3595 |
Viewer->pos, |
| 3596 |
objnum->pos, |
| 3597 |
fvi_query::unused_ignore_obj_list, |
| 3598 |
&LevelUniqueObjectState, |
| 3599 |
/* This is only necessary if `Viewer` can be a robot. In developer |
| 3600 |
* builds, the user can view from any object, not just a player. |
| 3601 |
*/ |
| 3602 |
&Robot_info, |
| 3603 |
FQ_TRANSWALL, |
| 3604 |
vcobjptridx(Viewer), |
| 3605 |
}, Viewer->segnum, 0, hit_data); |
| 3606 |
return hit_type == fvi_hit_type::Object && hit_data.hit_object == objnum; |
| 3607 |
} |
| 3608 |
|
| 3609 |
} |
| 3610 |
|
| 3611 |
//show names of teammates & players carrying flags |
| 3612 |
|
| 3613 |
void show_HUD_names(const d_robot_info_array &Robot_info, grs_canvas &canvas, const game_mode_flags Game_mode) |
| 3614 |
{ |
| 3615 |
auto &Objects = LevelUniqueObjectState.Objects; |
| 3616 |
auto &vcobjptr = Objects.vcptr; |
| 3617 |
auto &vcobjptridx = Objects.vcptridx; |
| 3618 |
for (playernum_t pnum = 0;pnum < N_players; ++pnum) |
| 3619 |
{ |
| 3620 |
if (pnum == Player_num) |
| 3621 |
continue; |
| 3622 |
auto &plr = *vcplayerptr(pnum); |
| 3623 |
if (plr.connected != player_connection_status::playing) |
| 3624 |
continue; |
| 3625 |
// ridiculusly complex to check if we want to show something... but this is readable at least. |
| 3626 |
|
| 3627 |
objnum_t objnum; |
| 3628 |
if (Newdemo_state == ND_STATE_PLAYBACK) { |
| 3629 |
//if this is a demo, the objnum in the player struct is wrong, so we search the object list for the objnum |
| 3630 |
for (objnum=0;objnum<=Highest_object_index;objnum++) |
| 3631 |
{ |
| 3632 |
auto &objp = *vcobjptr(objnum); |
| 3633 |
if (objp.type == OBJ_PLAYER && get_player_id(objp) == pnum) |
| 3634 |
break; |
| 3635 |
} |
| 3636 |
if (objnum > Highest_object_index) //not in list, thus not visible |
| 3637 |
continue; //..so don't show name |
| 3638 |
} |
| 3639 |
else |
| 3640 |
objnum = plr.objnum; |
| 3641 |
|
| 3642 |
const auto &&objp = vcobjptridx(objnum); |
| 3643 |
const auto &pl_flags = objp->ctype.player_info.powerup_flags; |
| 3644 |
const auto is_friend = (Game_mode & GM_MULTI_COOP || (Game_mode & GM_TEAM && multi_get_team_from_player(Netgame, pnum) == multi_get_team_from_player(Netgame, Player_num))); |
| 3645 |
const auto show_friend_name{Show_reticle_name}; |
| 3646 |
const auto is_cloaked = pl_flags & PLAYER_FLAGS_CLOAKED; |
| 3647 |
const auto show_enemy_name = Show_reticle_name && Netgame.ShowEnemyNames && !is_cloaked; |
| 3648 |
const auto show_name = is_friend ? show_friend_name : show_enemy_name; |
| 3649 |
const auto show_typing = is_friend || !is_cloaked; |
| 3650 |
const auto is_bounty_target = (Game_mode & GM_BOUNTY) && pnum == Bounty_target; |
| 3651 |
const auto show_indi = (is_friend || !is_cloaked) && |
| 3652 |
#if DXX_BUILD_DESCENT == 1 |
| 3653 |
is_bounty_target; |
| 3654 |
#elif DXX_BUILD_DESCENT == 2 |
| 3655 |
(is_bounty_target || ((game_mode_capture_flag(Game_mode) || game_mode_hoard(Game_mode)) && (pl_flags & PLAYER_FLAGS_FLAG))); |
| 3656 |
#endif |
| 3657 |
|
| 3658 |
if ((show_name || show_typing || show_indi) && see_object(Robot_info, vcobjptridx, objp)) |
| 3659 |
{ |
| 3660 |
auto player_point = g3_rotate_point(objp->pos); |
| 3661 |
if (player_point.p3_codes == clipping_code::None) //on screen |
| 3662 |
{ |
| 3663 |
g3_project_point(player_point); |
| 3664 |
if (!(player_point.p3_flags & projection_flag::overflow)) |
| 3665 |
{ |
| 3666 |
const fix x = player_point.p3_sx; |
| 3667 |
const fix y = player_point.p3_sy; |
| 3668 |
const fix dy = -fixmuldiv(fixmul(objp->size, Matrix_scale.y), i2f(canvas.cv_bitmap.bm_h) / 2, player_point.p3_vec.z); |
| 3669 |
const fix dx = fixmul(dy, grd_curscreen->sc_aspect); |
| 3670 |
/* Set the text to show */ |
| 3671 |
const auto name = is_bounty_target |
| 3672 |
? "Target" |
| 3673 |
: (show_name |
| 3674 |
? plr.callsign.operator const char *() |
| 3675 |
: nullptr); |
| 3676 |
const auto trailer = show_typing |
| 3677 |
? ({ |
| 3678 |
const auto m = multi_sending_message[pnum]; |
| 3679 |
m == msgsend_state::typing |
| 3680 |
? ", Typing" |
| 3681 |
: m == msgsend_state::automap |
| 3682 |
? ", Map" |
| 3683 |
: nullptr; |
| 3684 |
}) |
| 3685 |
: nullptr; |
| 3686 |
/* If both `name` and `trailer` are present, then |
| 3687 |
* concatenate them into label_storage. If successful, set |
| 3688 |
* `s` to `label_storage`. Otherwise, set `s` to |
| 3689 |
* `nullptr`. |
| 3690 |
* |
| 3691 |
* If exactly one of `name` or `trailer` is present, set |
| 3692 |
* `s` to the one that is present. In the case that |
| 3693 |
* `trailer` is present, skip the leading literal `", "` |
| 3694 |
* that is necessary for the name-present case, but not |
| 3695 |
* necessary for the name-absent case. |
| 3696 |
* |
| 3697 |
* If neither is present, set `s` to `trailer`, which by |
| 3698 |
* definition is `nullptr` in this branch. |
| 3699 |
* |
| 3700 |
* Finally, if `s` is not `nullptr`, then something can be |
| 3701 |
* shown. Show whatever `s` points at, which will be one |
| 3702 |
* of: |
| 3703 |
* - `label_storage` |
| 3704 |
* - `name` |
| 3705 |
* - `&trailer[2]` |
| 3706 |
*/ |
| 3707 |
std::array<char, CALLSIGN_LEN + 10> label_storage; |
| 3708 |
if (const auto s = name |
| 3709 |
? ( |
| 3710 |
trailer |
| 3711 |
? (std::snprintf(label_storage.data(), label_storage.size(), "%s%s", name, trailer) > 0 ? label_storage.data() : nullptr) |
| 3712 |
: name |
| 3713 |
) |
| 3714 |
: ( |
| 3715 |
trailer ? &trailer[2] : trailer |
| 3716 |
) |
| 3717 |
) |
| 3718 |
{ |
| 3719 |
const auto &&[w, h] = gr_get_string_size(*canvas.cv_font, s); |
| 3720 |
const auto color{get_player_or_team_color(Netgame, Game_mode, pnum)}; |
| 3721 |
auto &c = player_rgb[color]; |
| 3722 |
gr_set_fontcolor(canvas, BM_XRGB(c.r, c.g, c.b), -1); |
| 3723 |
const int x1 = f2i(x) - w / 2; |
| 3724 |
const int y1 = f2i(y - dy) + FSPACY(1); |
| 3725 |
gr_string(canvas, *canvas.cv_font, x1, y1, s, w, h); |
| 3726 |
} |
| 3727 |
|
| 3728 |
/* Draw box on HUD */ |
| 3729 |
if (show_indi) |
| 3730 |
{ |
| 3731 |
const fix w = dx / 4; |
| 3732 |
const fix h = dy / 4; |
| 3733 |
|
| 3734 |
struct { |
| 3735 |
int r, g, b; |
| 3736 |
} c{}; |
| 3737 |
#if DXX_BUILD_DESCENT == 2 |
| 3738 |
if (game_mode_capture_flag(Game_mode)) |
| 3739 |
((multi_get_team_from_player(Netgame, pnum) == team_number::blue) ? c.r : c.b) = 31; |
| 3740 |
else if (game_mode_hoard(Game_mode)) |
| 3741 |
{ |
| 3742 |
((Game_mode & GM_TEAM) |
| 3743 |
? ((multi_get_team_from_player(Netgame, pnum) == team_number::blue) ? c.b : c.r) |
| 3744 |
: c.g |
| 3745 |
) = 31; |
| 3746 |
} |
| 3747 |
else |
| 3748 |
#endif |
| 3749 |
{ |
| 3750 |
auto &color = player_rgb[get_player_color(pnum)]; |
| 3751 |
c = {color.r, color.g, color.b}; |
| 3752 |
} |
| 3753 |
const uint8_t color = BM_XRGB(c.r, c.g, c.b); |
| 3754 |
|
| 3755 |
gr_line(canvas, x + dx - w, y - dy, x + dx, y - dy, color); |
| 3756 |
gr_line(canvas, x + dx, y - dy, x + dx, y - dy + h, color); |
| 3757 |
gr_line(canvas, x - dx, y - dy, x - dx + w, y - dy, color); |
| 3758 |
gr_line(canvas, x - dx, y - dy, x - dx, y - dy + h, color); |
| 3759 |
gr_line(canvas, x + dx - w, y + dy, x + dx, y + dy, color); |
| 3760 |
gr_line(canvas, x + dx, y + dy, x + dx, y + dy - h, color); |
| 3761 |
gr_line(canvas, x - dx, y + dy, x - dx + w, y + dy, color); |
| 3762 |
gr_line(canvas, x - dx, y + dy, x - dx, y + dy - h, color); |
| 3763 |
} |
| 3764 |
} |
| 3765 |
} |
| 3766 |
} |
| 3767 |
} |
| 3768 |
} |
| 3769 |
|
| 3770 |
//draw all the things on the HUD |
| 3771 |
void draw_hud(const d_robot_info_array &Robot_info, grs_canvas &canvas, const object &plrobj, const control_info &Controls, const game_mode_flags Game_mode) |
| 3772 |
{ |
| 3773 |
auto &Objects = LevelUniqueObjectState.Objects; |
| 3774 |
auto &vcobjptr = Objects.vcptr; |
| 3775 |
auto &player_info = plrobj.ctype.player_info; |
| 3776 |
if (Newdemo_state == ND_STATE_RECORDING) |
| 3777 |
{ |
| 3778 |
int ammo; |
| 3779 |
auto &Primary_weapon = player_info.Primary_weapon; |
| 3780 |
if ((Primary_weapon == primary_weapon_index_t::VULCAN_INDEX && (ammo = player_info.vulcan_ammo, true)) |
| 3781 |
#if DXX_BUILD_DESCENT == 2 |
| 3782 |
|| |
| 3783 |
(Primary_weapon == primary_weapon_index_t::OMEGA_INDEX && (ammo = player_info.Omega_charge, true)) |
| 3784 |
#endif |
| 3785 |
) |
| 3786 |
newdemo_record_primary_ammo(ammo); |
| 3787 |
newdemo_record_secondary_ammo(player_info.secondary_ammo[player_info.Secondary_weapon]); |
| 3788 |
} |
| 3789 |
if (PlayerCfg.HudMode == HudType::Hidden) // no hud, "immersion mode" |
| 3790 |
return; |
| 3791 |
|
| 3792 |
// Cruise speed |
| 3793 |
if (auto &viewer = *Viewer; viewer.type == OBJ_PLAYER && get_player_id(viewer) == Player_num && PlayerCfg.CockpitMode[1] != cockpit_mode_t::rear_view) |
| 3794 |
{ |
| 3795 |
int x = FSPACX(1); |
| 3796 |
int y = canvas.cv_bitmap.bm_h; |
| 3797 |
|
| 3798 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 3799 |
if (Cruise_speed > 0) { |
| 3800 |
auto &game_font = *GAME_FONT; |
| 3801 |
const auto &&line_spacing = LINE_SPACING(game_font, game_font); |
| 3802 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen) |
| 3803 |
{ |
| 3804 |
y -= (Game_mode & GM_MULTI) |
| 3805 |
? line_spacing * 10 |
| 3806 |
: line_spacing * 6; |
| 3807 |
} |
| 3808 |
else if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) |
| 3809 |
{ |
| 3810 |
y -= (Game_mode & GM_MULTI) |
| 3811 |
? line_spacing * 6 |
| 3812 |
: line_spacing * 1; |
| 3813 |
} else { |
| 3814 |
y -= (Game_mode & GM_MULTI) |
| 3815 |
? line_spacing * 7 |
| 3816 |
: line_spacing * 2; |
| 3817 |
} |
| 3818 |
|
| 3819 |
gr_printf(canvas, game_font, x, y, "%s %2d%%", TXT_CRUISE, f2i(Cruise_speed) ); |
| 3820 |
} |
| 3821 |
} |
| 3822 |
|
| 3823 |
// Show score so long as not in rearview |
| 3824 |
if (!Rear_view && PlayerCfg.CockpitMode[1] != cockpit_mode_t::rear_view && PlayerCfg.CockpitMode[1] != cockpit_mode_t::status_bar) |
| 3825 |
{ |
| 3826 |
hud_show_score(canvas, player_info, Game_mode); |
| 3827 |
if (score_time) |
| 3828 |
hud_show_score_added(canvas, Game_mode); |
| 3829 |
} |
| 3830 |
|
| 3831 |
if (!Rear_view && PlayerCfg.CockpitMode[1] != cockpit_mode_t::rear_view) |
| 3832 |
hud_show_timer_count(canvas, Game_mode); |
| 3833 |
|
| 3834 |
// Show other stuff if not in rearview or letterbox. |
| 3835 |
if (!Rear_view && PlayerCfg.CockpitMode[1] != cockpit_mode_t::rear_view) |
| 3836 |
{ |
| 3837 |
show_HUD_names(Robot_info, canvas, Game_mode); |
| 3838 |
|
| 3839 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar || PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen) |
| 3840 |
hud_show_homing_warning(canvas, player_info.homing_object_dist); |
| 3841 |
|
| 3842 |
const local_multires_gauge_graphic multires_gauge_graphic{}; |
| 3843 |
const hud_draw_context_hs_mr hudctx(canvas, grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height(), multires_gauge_graphic); |
| 3844 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen) |
| 3845 |
{ |
| 3846 |
|
| 3847 |
auto &game_font = *GAME_FONT; |
| 3848 |
const auto &&line_spacing = LINE_SPACING(game_font, game_font); |
| 3849 |
const unsigned base_y = canvas.cv_bitmap.bm_h - ((Game_mode & GM_MULTI) ? (line_spacing * (5 + (N_players > 3))) : line_spacing); |
| 3850 |
unsigned current_y = base_y; |
| 3851 |
hud_show_energy(canvas, player_info, game_font, current_y); |
| 3852 |
current_y -= line_spacing; |
| 3853 |
hud_show_shield(canvas, plrobj, game_font, current_y); |
| 3854 |
current_y -= line_spacing; |
| 3855 |
#if DXX_BUILD_DESCENT == 2 |
| 3856 |
hud_show_afterburner(canvas, player_info, game_font, current_y); |
| 3857 |
current_y -= line_spacing; |
| 3858 |
#endif |
| 3859 |
hud_show_weapons(canvas, plrobj, game_font, Game_mode & GM_MULTI); |
| 3860 |
#if DXX_BUILD_DESCENT == 1 |
| 3861 |
if (!PCSharePig) |
| 3862 |
#endif |
| 3863 |
{ |
| 3864 |
if (!((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))) |
| 3865 |
/* In non-cooperative multiplayer games, everyone always has all |
| 3866 |
* keys. Hide them to reduce visual clutter. |
| 3867 |
*/ |
| 3868 |
hud_show_keys(hudctx, HUD_SCALE_AR(hudctx.xscale, hudctx.yscale), player_info); |
| 3869 |
} |
| 3870 |
hud_show_cloak_invuln(canvas, player_info.powerup_flags, player_info.cloak_time, player_info.invulnerable_time, current_y); |
| 3871 |
|
| 3872 |
if (Newdemo_state==ND_STATE_RECORDING) |
| 3873 |
newdemo_record_player_flags(player_info.powerup_flags.get_player_flags()); |
| 3874 |
} |
| 3875 |
|
| 3876 |
#ifndef RELEASE |
| 3877 |
if (!(Game_mode&GM_MULTI && Show_kill_list != show_kill_list_mode::None)) |
| 3878 |
show_time(canvas, *canvas.cv_font); |
| 3879 |
#endif |
| 3880 |
|
| 3881 |
#if DXX_BUILD_DESCENT == 2 |
| 3882 |
if (PlayerCfg.CockpitMode[1] != cockpit_mode_t::letterbox && PlayerCfg.CockpitMode[1] != cockpit_mode_t::rear_view) |
| 3883 |
{ |
| 3884 |
hud_show_flag(canvas, player_info, multires_gauge_graphic); |
| 3885 |
hud_show_orbs(canvas, player_info, multires_gauge_graphic); |
| 3886 |
} |
| 3887 |
#endif |
| 3888 |
HUD_render_message_frame(canvas); |
| 3889 |
|
| 3890 |
if (PlayerCfg.CockpitMode[1] != cockpit_mode_t::status_bar) |
| 3891 |
hud_show_lives(hudctx, HUD_SCALE_AR(grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height(), multires_gauge_graphic), player_info, Game_mode & GM_MULTI); |
| 3892 |
if (Game_mode&GM_MULTI && Show_kill_list != show_kill_list_mode::None) |
| 3893 |
hud_show_kill_list(vcobjptr, canvas, Game_mode); |
| 3894 |
if (PlayerCfg.CockpitMode[1] != cockpit_mode_t::letterbox) |
| 3895 |
show_reticle(canvas, player_info, PlayerCfg.ReticleType, 1); |
| 3896 |
if (PlayerCfg.CockpitMode[1] != cockpit_mode_t::letterbox && Newdemo_state != ND_STATE_PLAYBACK && PlayerCfg.MouseFlightSim && PlayerCfg.MouseFSIndicator) |
| 3897 |
{ |
| 3898 |
const auto gwidth = canvas.cv_bitmap.bm_w; |
| 3899 |
const auto gheight = canvas.cv_bitmap.bm_h; |
| 3900 |
auto &raw_mouse_axis = Controls.raw_mouse_axis; |
| 3901 |
show_mousefs_indicator(canvas, raw_mouse_axis[0], raw_mouse_axis[1], raw_mouse_axis[2], gwidth / 2, gheight / 2, gheight / 4); |
| 3902 |
} |
| 3903 |
} |
| 3904 |
|
| 3905 |
if (Rear_view && PlayerCfg.CockpitMode[1] != cockpit_mode_t::rear_view) |
| 3906 |
{ |
| 3907 |
HUD_render_message_frame(canvas); |
| 3908 |
gr_set_fontcolor(canvas, BM_XRGB(0, 31, 0), -1); |
| 3909 |
auto &game_font = *GAME_FONT; |
| 3910 |
gr_string(canvas, game_font, 0x8000, canvas.cv_bitmap.bm_h - LINE_SPACING(game_font, game_font), TXT_REAR_VIEW); |
| 3911 |
} |
| 3912 |
} |
| 3913 |
|
| 3914 |
//print out some player statistics |
| 3915 |
void render_gauges(grs_canvas &canvas, const game_mode_flags Game_mode) |
| 3916 |
{ |
| 3917 |
auto &Objects = LevelUniqueObjectState.Objects; |
| 3918 |
auto &vmobjptr = Objects.vmptr; |
| 3919 |
auto &plrobj = get_local_plrobj(); |
| 3920 |
auto &player_info = plrobj.ctype.player_info; |
| 3921 |
const auto energy = f2ir(player_info.energy); |
| 3922 |
auto &pl_flags = player_info.powerup_flags; |
| 3923 |
const auto cloak = (pl_flags & PLAYER_FLAGS_CLOAKED); |
| 3924 |
|
| 3925 |
assert(PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_cockpit || PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar); |
| 3926 |
|
| 3927 |
auto shields = f2ir(plrobj.shields); |
| 3928 |
if (shields < 0 ) shields = 0; |
| 3929 |
|
| 3930 |
gr_set_curfont(canvas, *GAME_FONT); |
| 3931 |
|
| 3932 |
if (Newdemo_state == ND_STATE_RECORDING) |
| 3933 |
{ |
| 3934 |
const auto homing_object_dist = player_info.homing_object_dist; |
| 3935 |
if (homing_object_dist >= 0) |
| 3936 |
newdemo_record_homing_distance(homing_object_dist); |
| 3937 |
} |
| 3938 |
|
| 3939 |
const local_multires_gauge_graphic multires_gauge_graphic{}; |
| 3940 |
const hud_draw_context_hs_mr hudctx(canvas, grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height(), multires_gauge_graphic); |
| 3941 |
draw_weapon_boxes(hudctx, player_info); |
| 3942 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_cockpit) |
| 3943 |
{ |
| 3944 |
if (Newdemo_state == ND_STATE_RECORDING) |
| 3945 |
newdemo_record_player_energy(energy); |
| 3946 |
draw_energy_bar(*grd_curcanv, hudctx, energy); |
| 3947 |
gr_set_default_canvas(); |
| 3948 |
#if DXX_BUILD_DESCENT == 1 |
| 3949 |
if (PlayerCfg.HudMode == HudType::Standard) |
| 3950 |
#elif DXX_BUILD_DESCENT == 2 |
| 3951 |
if (Newdemo_state==ND_STATE_RECORDING ) |
| 3952 |
newdemo_record_player_afterburner(Afterburner_charge); |
| 3953 |
draw_afterburner_bar(hudctx, Afterburner_charge); |
| 3954 |
#endif |
| 3955 |
show_bomb_count(hudctx.canvas, player_info, hudctx.xscale(BOMB_COUNT_X), hudctx.yscale(BOMB_COUNT_Y), gr_find_closest_color(0, 0, 0), 0, 0); |
| 3956 |
draw_player_ship(hudctx, player_info, cloak, SHIP_GAUGE_X, SHIP_GAUGE_Y); |
| 3957 |
|
| 3958 |
if (player_info.powerup_flags & PLAYER_FLAGS_INVULNERABLE) |
| 3959 |
draw_invulnerable_ship(hudctx, plrobj); |
| 3960 |
else |
| 3961 |
draw_shield_bar(hudctx, shields); |
| 3962 |
draw_numerical_display(hudctx, shields, energy); |
| 3963 |
|
| 3964 |
if (Newdemo_state==ND_STATE_RECORDING) |
| 3965 |
{ |
| 3966 |
newdemo_record_player_shields(shields); |
| 3967 |
newdemo_record_player_flags(player_info.powerup_flags.get_player_flags()); |
| 3968 |
} |
| 3969 |
draw_keys_state(hudctx, player_info.powerup_flags).draw_all_cockpit_keys(); |
| 3970 |
|
| 3971 |
show_homing_warning(hudctx, player_info.homing_object_dist); |
| 3972 |
draw_wbu_overlay(hudctx); |
| 3973 |
|
| 3974 |
} |
| 3975 |
else if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) |
| 3976 |
{ |
| 3977 |
|
| 3978 |
if (Newdemo_state == ND_STATE_RECORDING) |
| 3979 |
newdemo_record_player_energy(energy); |
| 3980 |
sb_draw_energy_bar(hudctx, energy); |
| 3981 |
#if DXX_BUILD_DESCENT == 1 |
| 3982 |
if (PlayerCfg.HudMode == HudType::Standard) |
| 3983 |
#elif DXX_BUILD_DESCENT == 2 |
| 3984 |
if (Newdemo_state==ND_STATE_RECORDING ) |
| 3985 |
newdemo_record_player_afterburner(Afterburner_charge); |
| 3986 |
sb_draw_afterburner(hudctx, player_info); |
| 3987 |
if (PlayerCfg.HudMode == HudType::Standard && inset_window[gauge_inset_window_view::secondary].user == weapon_box_user::weapon) |
| 3988 |
#endif |
| 3989 |
show_bomb_count(hudctx.canvas, player_info, hudctx.xscale(SB_BOMB_COUNT_X), hudctx.yscale(SB_BOMB_COUNT_Y), gr_find_closest_color(0, 0, 0), 0, 0); |
| 3990 |
|
| 3991 |
draw_player_ship(hudctx, player_info, cloak, SB_SHIP_GAUGE_X, SB_SHIP_GAUGE_Y); |
| 3992 |
|
| 3993 |
if (player_info.powerup_flags & PLAYER_FLAGS_INVULNERABLE) |
| 3994 |
draw_invulnerable_ship(hudctx, plrobj); |
| 3995 |
else |
| 3996 |
sb_draw_shield_bar(hudctx, shields); |
| 3997 |
sb_draw_shield_num(hudctx, shields); |
| 3998 |
|
| 3999 |
if (Newdemo_state==ND_STATE_RECORDING) |
| 4000 |
{ |
| 4001 |
newdemo_record_player_shields(shields); |
| 4002 |
newdemo_record_player_flags(player_info.powerup_flags.get_player_flags()); |
| 4003 |
} |
| 4004 |
draw_keys_state(hudctx, player_info.powerup_flags).draw_all_statusbar_keys(); |
| 4005 |
|
| 4006 |
sb_show_lives(hudctx, HUD_SCALE_AR(grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height(), hudctx.multires_gauge_graphic), player_info, Game_mode & GM_MULTI); |
| 4007 |
const auto is_multiplayer_non_cooperative = (Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP); |
| 4008 |
sb_show_score(hudctx, player_info, is_multiplayer_non_cooperative); |
| 4009 |
|
| 4010 |
if (!is_multiplayer_non_cooperative) |
| 4011 |
{ |
| 4012 |
sb_show_score_added(hudctx); |
| 4013 |
} |
| 4014 |
} |
| 4015 |
#if DXX_BUILD_DESCENT == 1 |
| 4016 |
else |
| 4017 |
draw_player_ship(hudctx, player_info, cloak, SB_SHIP_GAUGE_X, SB_SHIP_GAUGE_Y); |
| 4018 |
#endif |
| 4019 |
} |
| 4020 |
|
| 4021 |
// --------------------------------------------------------------------------------------------------------- |
| 4022 |
// Call when picked up a quad laser powerup. |
| 4023 |
// If laser is active, set old_weapon[0] to -1 to force redraw. |
| 4024 |
void update_laser_weapon_info(void) |
| 4025 |
{ |
| 4026 |
auto &old_weapon = inset_window[gauge_inset_window_view::primary].old_weapon; |
| 4027 |
if (old_weapon.primary == primary_weapon_index_t::LASER_INDEX) |
| 4028 |
old_weapon = {}; |
| 4029 |
} |
| 4030 |
|
| 4031 |
#if DXX_BUILD_DESCENT == 2 |
| 4032 |
|
| 4033 |
//draws a 3d view into one of the cockpit windows. win is 0 for left, |
| 4034 |
//1 for right. viewer is object. NULL object means give up window |
| 4035 |
//user is one of the WBU_ constants. If rear_view_flag is set, show a |
| 4036 |
//rear view. If label is non-NULL, print the label at the top of the |
| 4037 |
//window. |
| 4038 |
void do_cockpit_window_view(const gauge_inset_window_view win, const weapon_box_user user) |
| 4039 |
{ |
| 4040 |
assert(user == weapon_box_user::weapon || user == weapon_box_user::post_missile_static); |
| 4041 |
auto &inset = inset_window[win]; |
| 4042 |
auto &inset_user = inset.user; |
| 4043 |
if (user == weapon_box_user::post_missile_static && inset_user != weapon_box_user::post_missile_static) |
| 4044 |
inset_window[win].time_static_played = 0; |
| 4045 |
if (inset_user == weapon_box_user::weapon || inset_user == weapon_box_user::post_missile_static) |
| 4046 |
return; //already set |
| 4047 |
inset_user = user; |
| 4048 |
if (inset.overlap_dirty) { |
| 4049 |
inset.overlap_dirty = 0; |
| 4050 |
gr_set_default_canvas(); |
| 4051 |
} |
| 4052 |
} |
| 4053 |
|
| 4054 |
void do_cockpit_window_view(grs_canvas &canvas, const gauge_inset_window_view win, const object &viewer, const int rear_view_flag, const weapon_box_user user, const char *const label, const player_info *const player_info) |
| 4055 |
{ |
| 4056 |
grs_subcanvas window_canv; |
| 4057 |
const auto viewer_save{Viewer}; |
| 4058 |
static int window_x,window_y; |
| 4059 |
int rear_view_save = Rear_view; |
| 4060 |
|
| 4061 |
window_rendered_data window; |
| 4062 |
|
| 4063 |
inset_window[win].user = user; //say who's using window |
| 4064 |
|
| 4065 |
Viewer = &viewer; |
| 4066 |
Rear_view = rear_view_flag; |
| 4067 |
|
| 4068 |
const local_multires_gauge_graphic multires_gauge_graphic{}; |
| 4069 |
const hud_draw_context_hs_mr hudctx(window_canv, grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height(), multires_gauge_graphic); |
| 4070 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen) |
| 4071 |
{ |
| 4072 |
const unsigned w = HUD_SCALE_AR(hudctx.xscale, hudctx.yscale)(multires_gauge_graphic.get(106, 44)); |
| 4073 |
const unsigned h = w; |
| 4074 |
|
| 4075 |
const int dx = (win == gauge_inset_window_view::primary) ? -(w + (w / 10)) : (w / 10); |
| 4076 |
|
| 4077 |
window_x = grd_curscreen->get_screen_width() / 2 + dx; |
| 4078 |
window_y = grd_curscreen->get_screen_height() - h - (SHEIGHT / 15); |
| 4079 |
|
| 4080 |
gr_init_sub_canvas(window_canv, canvas, window_x, window_y, w, h); |
| 4081 |
} |
| 4082 |
else { |
| 4083 |
if (PlayerCfg.CockpitMode[1] != cockpit_mode_t::full_cockpit && PlayerCfg.CockpitMode[1] != cockpit_mode_t::status_bar) |
| 4084 |
goto abort; |
| 4085 |
|
| 4086 |
auto &resbox = gauge_boxes[multires_gauge_graphic.hiresmode]; |
| 4087 |
auto &weaponbox = resbox[win]; |
| 4088 |
const auto box = &weaponbox[(PlayerCfg.CockpitMode[1] == cockpit_mode_t::status_bar) ? gauge_hud_type::statusbar : gauge_hud_type::cockpit]; |
| 4089 |
gr_init_sub_canvas(window_canv, canvas, hudctx.xscale(box->left), hudctx.yscale(box->top), hudctx.xscale(box->right - box->left + 1), hudctx.yscale(box->bot - box->top + 1)); |
| 4090 |
} |
| 4091 |
|
| 4092 |
gr_set_current_canvas(window_canv); |
| 4093 |
|
| 4094 |
render_frame(window_canv, 0, window); |
| 4095 |
|
| 4096 |
// HACK! If guided missile, wake up robots as necessary. |
| 4097 |
if (viewer.type == OBJ_WEAPON) { |
| 4098 |
// -- Used to require to be GUIDED -- if (viewer->id == GUIDEDMISS_ID) |
| 4099 |
wake_up_rendered_objects(viewer, window); |
| 4100 |
} |
| 4101 |
|
| 4102 |
if (label) { |
| 4103 |
if (Color_0_31_0 == -1) |
| 4104 |
Color_0_31_0 = BM_XRGB(0,31,0); |
| 4105 |
gr_set_fontcolor(window_canv, Color_0_31_0, -1); |
| 4106 |
auto &game_font = *GAME_FONT; |
| 4107 |
gr_string(window_canv, game_font, 0x8000, FSPACY(1), label); |
| 4108 |
} |
| 4109 |
|
| 4110 |
if (player_info) // only non-nullptr for weapon_box_user::guided |
| 4111 |
show_reticle(window_canv, *player_info, reticle_type::cross_v1, 0); |
| 4112 |
|
| 4113 |
if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_screen) |
| 4114 |
{ |
| 4115 |
int small_window_bottom,big_window_bottom,extra_part_h; |
| 4116 |
|
| 4117 |
gr_ubox(window_canv, 0, 0, window_canv.cv_bitmap.bm_w, window_canv.cv_bitmap.bm_h, BM_XRGB(0,0,32)); |
| 4118 |
|
| 4119 |
//if the window only partially overlaps the big 3d window, copy |
| 4120 |
//the extra part to the visible screen |
| 4121 |
|
| 4122 |
big_window_bottom = SHEIGHT - 1; |
| 4123 |
|
| 4124 |
if (window_y > big_window_bottom) { |
| 4125 |
|
| 4126 |
//the small window is completely outside the big 3d window, so |
| 4127 |
//copy it to the visible screen |
| 4128 |
gr_bitmap(canvas, window_x, window_y, window_canv.cv_bitmap); |
| 4129 |
inset_window[win].overlap_dirty = 1; |
| 4130 |
} |
| 4131 |
else { |
| 4132 |
|
| 4133 |
small_window_bottom = window_y + window_canv.cv_bitmap.bm_h - 1; |
| 4134 |
|
| 4135 |
extra_part_h = small_window_bottom - big_window_bottom; |
| 4136 |
|
| 4137 |
if (extra_part_h > 0) { |
| 4138 |
grs_subcanvas overlap_canv; |
| 4139 |
gr_init_sub_canvas(overlap_canv, window_canv, 0, window_canv.cv_bitmap.bm_h-extra_part_h, window_canv.cv_bitmap.bm_w, extra_part_h); |
| 4140 |
gr_bitmap(canvas, window_x, big_window_bottom + 1, overlap_canv.cv_bitmap); |
| 4141 |
inset_window[win].overlap_dirty = 1; |
| 4142 |
} |
| 4143 |
} |
| 4144 |
} |
| 4145 |
else if (PlayerCfg.CockpitMode[1] == cockpit_mode_t::full_cockpit) |
| 4146 |
/* `draw_wbu_overlay` has hard-coded x/y coordinates with their |
| 4147 |
* origin at the root of the screen canvas, not the window |
| 4148 |
* canvas. Pass the screen canvas so that the coordinates are |
| 4149 |
* interpreted properly. |
| 4150 |
*/ |
| 4151 |
draw_wbu_overlay(hud_draw_context_hs_mr(canvas, grd_curscreen->get_screen_width(), grd_curscreen->get_screen_height(), multires_gauge_graphic)); |
| 4152 |
|
| 4153 |
//force redraw when done |
| 4154 |
inset_window[win].old_weapon = {}; |
| 4155 |
|
| 4156 |
abort:; |
| 4157 |
|
| 4158 |
Viewer = viewer_save; |
| 4159 |
|
| 4160 |
Rear_view = rear_view_save; |
| 4161 |
/* grd_curcanv may point to `window_canv`; if so, grd_curcanv |
| 4162 |
* would become a dangling pointer when `window_canv` goes out of |
| 4163 |
* scope at the end of the block. Redirect it to the default screen |
| 4164 |
* to avoid pointing to freed memory. Setting grd_curcanv to |
| 4165 |
* nullptr would be better, but some code assumes that grd_curcanv |
| 4166 |
* is never nullptr, so instead set it to the default canvas. |
| 4167 |
* Eventually, grd_curcanv will be removed entirely. |
| 4168 |
*/ |
| 4169 |
gr_set_current_canvas(canvas); |
| 4170 |
} |
| 4171 |
#endif |
| 4172 |
} |