| 1 |
/* Emacs style mode select -*- C -*- |
| 2 |
*----------------------------------------------------------------------------- |
| 3 |
* |
| 4 |
* |
| 5 |
* PrBoom: a Doom port merged with LxDoom and LSDLDoom |
| 6 |
* based on BOOM, a modified and improved DOOM engine |
| 7 |
* Copyright (C) 1999 by |
| 8 |
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman |
| 9 |
* Copyright (C) 1999-2000 by |
| 10 |
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze |
| 11 |
* Copyright 2005, 2006 by |
| 12 |
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko |
| 13 |
* |
| 14 |
* This program is free software; you can redistribute it and/or |
| 15 |
* modify it under the terms of the GNU General Public License |
| 16 |
* as published by the Free Software Foundation; either version 2 |
| 17 |
* of the License, or (at your option) any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 27 |
* 02111-1307, USA. |
| 28 |
* |
| 29 |
* DESCRIPTION: |
| 30 |
* Status bar code. |
| 31 |
* Does the face/direction indicator animatin. |
| 32 |
* Does palette indicators as well (red pain/berserk, bright pickup) |
| 33 |
* |
| 34 |
*-----------------------------------------------------------------------------*/ |
| 35 |
|
| 36 |
#include "doomdef.h" |
| 37 |
#include "doomstat.h" |
| 38 |
#include "m_random.h" |
| 39 |
#include "i_video.h" |
| 40 |
#include "w_wad.h" |
| 41 |
#include "st_stuff.h" |
| 42 |
#include "hu_stuff.h" |
| 43 |
#include "st_lib.h" |
| 44 |
#include "r_main.h" |
| 45 |
#include "am_map.h" |
| 46 |
#include "m_cheat.h" |
| 47 |
#include "m_menu.h" |
| 48 |
#include "s_sound.h" |
| 49 |
#include "sounds.h" |
| 50 |
#include "dstrings.h" |
| 51 |
#include "p_pspr.h" |
| 52 |
#include "r_draw.h" |
| 53 |
#include "e6y.h"//e6y |
| 54 |
|
| 55 |
#include "dsda/settings.h" |
| 56 |
#include "dsda/stretch.h" |
| 57 |
#include "dsda/text_color.h" |
| 58 |
|
| 59 |
#include "heretic/sb_bar.h" |
| 60 |
|
| 61 |
// |
| 62 |
// STATUS BAR DATA |
| 63 |
// |
| 64 |
|
| 65 |
int ST_SCALED_HEIGHT; |
| 66 |
int ST_SCALED_WIDTH; |
| 67 |
int ST_SCALED_OFFSETX; |
| 68 |
|
| 69 |
// Palette indices. |
| 70 |
// For damage/bonus red-/gold-shifts |
| 71 |
#define STARTREDPALS 1 |
| 72 |
#define STARTBONUSPALS 9 |
| 73 |
#define NUMREDPALS 8 |
| 74 |
#define NUMBONUSPALS 4 |
| 75 |
// Radiation suit, green shift. |
| 76 |
#define RADIATIONPAL 13 |
| 77 |
|
| 78 |
// Location of status bar |
| 79 |
#define ST_X 0 |
| 80 |
#define ST_X2 104 |
| 81 |
|
| 82 |
// proff 08/18/98: Changed for high-res |
| 83 |
#define ST_FX (ST_X+143) |
| 84 |
#define ST_FY (ST_Y+1) |
| 85 |
//#define ST_FX 143 |
| 86 |
//#define ST_FY 169 |
| 87 |
|
| 88 |
// Should be set to patch width |
| 89 |
// for tall numbers later on |
| 90 |
#define ST_TALLNUMWIDTH (tallnum[0]->width) |
| 91 |
|
| 92 |
// Number of status faces. |
| 93 |
#define ST_NUMPAINFACES 5 |
| 94 |
#define ST_NUMSTRAIGHTFACES 3 |
| 95 |
#define ST_NUMTURNFACES 2 |
| 96 |
#define ST_NUMSPECIALFACES 3 |
| 97 |
|
| 98 |
#define ST_FACESTRIDE \ |
| 99 |
(ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES) |
| 100 |
|
| 101 |
#define ST_NUMEXTRAFACES 2 |
| 102 |
|
| 103 |
#define ST_NUMFACES \ |
| 104 |
(ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES) |
| 105 |
|
| 106 |
#define ST_TURNOFFSET (ST_NUMSTRAIGHTFACES) |
| 107 |
#define ST_OUCHOFFSET (ST_TURNOFFSET + ST_NUMTURNFACES) |
| 108 |
#define ST_EVILGRINOFFSET (ST_OUCHOFFSET + 1) |
| 109 |
#define ST_RAMPAGEOFFSET (ST_EVILGRINOFFSET + 1) |
| 110 |
#define ST_GODFACE (ST_NUMPAINFACES*ST_FACESTRIDE) |
| 111 |
#define ST_DEADFACE (ST_GODFACE+1) |
| 112 |
|
| 113 |
// proff 08/18/98: Changed for high-res |
| 114 |
#define ST_FACESX (ST_X+143) |
| 115 |
#define ST_FACESY (ST_Y) |
| 116 |
//#define ST_FACESX 143 |
| 117 |
//#define ST_FACESY 168 |
| 118 |
|
| 119 |
#define ST_EVILGRINCOUNT (2*TICRATE) |
| 120 |
#define ST_STRAIGHTFACECOUNT (TICRATE/2) |
| 121 |
#define ST_TURNCOUNT (1*TICRATE) |
| 122 |
#define ST_OUCHCOUNT (1*TICRATE) |
| 123 |
#define ST_RAMPAGEDELAY (2*TICRATE) |
| 124 |
|
| 125 |
#define ST_MUCHPAIN 20 |
| 126 |
|
| 127 |
// Location and size of statistics, |
| 128 |
// justified according to widget type. |
| 129 |
// Problem is, within which space? STbar? Screen? |
| 130 |
// Note: this could be read in by a lump. |
| 131 |
// Problem is, is the stuff rendered |
| 132 |
// into a buffer, |
| 133 |
// or into the frame buffer? |
| 134 |
// I dunno, why don't you go and find out!!! killough |
| 135 |
|
| 136 |
// AMMO number pos. |
| 137 |
#define ST_AMMOWIDTH 3 |
| 138 |
// proff 08/18/98: Changed for high-res |
| 139 |
#define ST_AMMOX (ST_X+44) |
| 140 |
#define ST_AMMOY (ST_Y+3) |
| 141 |
//#define ST_AMMOX 44 |
| 142 |
//#define ST_AMMOY 171 |
| 143 |
|
| 144 |
// HEALTH number pos. |
| 145 |
#define ST_HEALTHWIDTH 3 |
| 146 |
// proff 08/18/98: Changed for high-res |
| 147 |
#define ST_HEALTHX (ST_X+90) |
| 148 |
#define ST_HEALTHY (ST_Y+3) |
| 149 |
//#define ST_HEALTHX 90 |
| 150 |
//#define ST_HEALTHY 171 |
| 151 |
|
| 152 |
// Weapon pos. |
| 153 |
// proff 08/18/98: Changed for high-res |
| 154 |
#define ST_ARMSX (ST_X+111) |
| 155 |
#define ST_ARMSY (ST_Y+4) |
| 156 |
#define ST_ARMSBGX (ST_X+104) |
| 157 |
#define ST_ARMSBGY (ST_Y) |
| 158 |
//#define ST_ARMSX 111 |
| 159 |
//#define ST_ARMSY 172 |
| 160 |
//#define ST_ARMSBGX 104 |
| 161 |
//#define ST_ARMSBGY 168 |
| 162 |
#define ST_ARMSXSPACE 12 |
| 163 |
#define ST_ARMSYSPACE 10 |
| 164 |
|
| 165 |
// Frags pos. |
| 166 |
// proff 08/18/98: Changed for high-res |
| 167 |
#define ST_FRAGSX (ST_X+138) |
| 168 |
#define ST_FRAGSY (ST_Y+3) |
| 169 |
//#define ST_FRAGSX 138 |
| 170 |
//#define ST_FRAGSY 171 |
| 171 |
#define ST_FRAGSWIDTH 2 |
| 172 |
|
| 173 |
// ARMOR number pos. |
| 174 |
#define ST_ARMORWIDTH 3 |
| 175 |
// proff 08/18/98: Changed for high-res |
| 176 |
#define ST_ARMORX (ST_X+221) |
| 177 |
#define ST_ARMORY (ST_Y+3) |
| 178 |
//#define ST_ARMORX 221 |
| 179 |
//#define ST_ARMORY 171 |
| 180 |
|
| 181 |
// Key icon positions. |
| 182 |
#define ST_KEY0WIDTH 8 |
| 183 |
#define ST_KEY0HEIGHT 5 |
| 184 |
// proff 08/18/98: Changed for high-res |
| 185 |
#define ST_KEY0X (ST_X+239) |
| 186 |
#define ST_KEY0Y (ST_Y+3) |
| 187 |
//#define ST_KEY0X 239 |
| 188 |
//#define ST_KEY0Y 171 |
| 189 |
#define ST_KEY1WIDTH ST_KEY0WIDTH |
| 190 |
// proff 08/18/98: Changed for high-res |
| 191 |
#define ST_KEY1X (ST_X+239) |
| 192 |
#define ST_KEY1Y (ST_Y+13) |
| 193 |
//#define ST_KEY1X 239 |
| 194 |
//#define ST_KEY1Y 181 |
| 195 |
#define ST_KEY2WIDTH ST_KEY0WIDTH |
| 196 |
// proff 08/18/98: Changed for high-res |
| 197 |
#define ST_KEY2X (ST_X+239) |
| 198 |
#define ST_KEY2Y (ST_Y+23) |
| 199 |
//#define ST_KEY2X 239 |
| 200 |
//#define ST_KEY2Y 191 |
| 201 |
|
| 202 |
// Ammunition counter. |
| 203 |
#define ST_AMMO0WIDTH 3 |
| 204 |
#define ST_AMMO0HEIGHT 6 |
| 205 |
// proff 08/18/98: Changed for high-res |
| 206 |
#define ST_AMMO0X (ST_X+288) |
| 207 |
#define ST_AMMO0Y (ST_Y+5) |
| 208 |
//#define ST_AMMO0X 288 |
| 209 |
//#define ST_AMMO0Y 173 |
| 210 |
#define ST_AMMO1WIDTH ST_AMMO0WIDTH |
| 211 |
// proff 08/18/98: Changed for high-res |
| 212 |
#define ST_AMMO1X (ST_X+288) |
| 213 |
#define ST_AMMO1Y (ST_Y+11) |
| 214 |
//#define ST_AMMO1X 288 |
| 215 |
//#define ST_AMMO1Y 179 |
| 216 |
#define ST_AMMO2WIDTH ST_AMMO0WIDTH |
| 217 |
// proff 08/18/98: Changed for high-res |
| 218 |
#define ST_AMMO2X (ST_X+288) |
| 219 |
#define ST_AMMO2Y (ST_Y+23) |
| 220 |
//#define ST_AMMO2X 288 |
| 221 |
//#define ST_AMMO2Y 191 |
| 222 |
#define ST_AMMO3WIDTH ST_AMMO0WIDTH |
| 223 |
// proff 08/18/98: Changed for high-res |
| 224 |
#define ST_AMMO3X (ST_X+288) |
| 225 |
#define ST_AMMO3Y (ST_Y+17) |
| 226 |
//#define ST_AMMO3X 288 |
| 227 |
//#define ST_AMMO3Y 185 |
| 228 |
|
| 229 |
// Indicate maximum ammunition. |
| 230 |
// Only needed because backpack exists. |
| 231 |
#define ST_MAXAMMO0WIDTH 3 |
| 232 |
#define ST_MAXAMMO0HEIGHT 5 |
| 233 |
// proff 08/18/98: Changed for high-res |
| 234 |
#define ST_MAXAMMO0X (ST_X+314) |
| 235 |
#define ST_MAXAMMO0Y (ST_Y+5) |
| 236 |
//#define ST_MAXAMMO0X 314 |
| 237 |
//#define ST_MAXAMMO0Y 173 |
| 238 |
#define ST_MAXAMMO1WIDTH ST_MAXAMMO0WIDTH |
| 239 |
// proff 08/18/98: Changed for high-res |
| 240 |
#define ST_MAXAMMO1X (ST_X+314) |
| 241 |
#define ST_MAXAMMO1Y (ST_Y+11) |
| 242 |
//#define ST_MAXAMMO1X 314 |
| 243 |
//#define ST_MAXAMMO1Y 179 |
| 244 |
#define ST_MAXAMMO2WIDTH ST_MAXAMMO0WIDTH |
| 245 |
// proff 08/18/98: Changed for high-res |
| 246 |
#define ST_MAXAMMO2X (ST_X+314) |
| 247 |
#define ST_MAXAMMO2Y (ST_Y+23) |
| 248 |
//#define ST_MAXAMMO2X 314 |
| 249 |
//#define ST_MAXAMMO2Y 191 |
| 250 |
#define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH |
| 251 |
// proff 08/18/98: Changed for high-res |
| 252 |
#define ST_MAXAMMO3X (ST_X+314) |
| 253 |
#define ST_MAXAMMO3Y (ST_Y+17) |
| 254 |
//#define ST_MAXAMMO3X 314 |
| 255 |
//#define ST_MAXAMMO3Y 185 |
| 256 |
|
| 257 |
// killough 2/8/98: weapon info position macros UNUSED, removed here |
| 258 |
|
| 259 |
// main player in game |
| 260 |
static player_t *plyr; |
| 261 |
|
| 262 |
// ST_Start() has just been called |
| 263 |
static dboolean st_firsttime; |
| 264 |
|
| 265 |
// used to execute ST_Init() only once |
| 266 |
static int veryfirsttime = 1; |
| 267 |
|
| 268 |
// CPhipps - no longer do direct PLAYPAL handling here |
| 269 |
|
| 270 |
// used for timing |
| 271 |
static unsigned int st_clock; |
| 272 |
|
| 273 |
// whether left-side main status bar is active |
| 274 |
static dboolean st_statusbaron; |
| 275 |
|
| 276 |
// !deathmatch |
| 277 |
static dboolean st_notdeathmatch; |
| 278 |
|
| 279 |
// !deathmatch && st_statusbaron |
| 280 |
static dboolean st_armson; |
| 281 |
|
| 282 |
// !deathmatch |
| 283 |
static dboolean st_fragson; |
| 284 |
|
| 285 |
// 0-9, tall numbers |
| 286 |
static patchnum_t tallnum[10]; |
| 287 |
|
| 288 |
// tall % sign |
| 289 |
static patchnum_t tallpercent; |
| 290 |
|
| 291 |
// 0-9, short, yellow (,different!) numbers |
| 292 |
static patchnum_t shortnum[10]; |
| 293 |
|
| 294 |
// 3 key-cards, 3 skulls, 3 card/skull combos |
| 295 |
// jff 2/24/98 extend number of patches by three skull/card combos |
| 296 |
static patchnum_t keys[DOOM_NUMCARDS+3]; |
| 297 |
|
| 298 |
// face status patches |
| 299 |
static patchnum_t faces[ST_NUMFACES]; |
| 300 |
|
| 301 |
// face background |
| 302 |
static patchnum_t faceback; // CPhipps - single background, translated for different players |
| 303 |
|
| 304 |
//e6y: status bar background |
| 305 |
patchnum_t stbarbg; |
| 306 |
patchnum_t grnrock; |
| 307 |
patchnum_t brdr_b; |
| 308 |
|
| 309 |
// main bar right |
| 310 |
static patchnum_t armsbg; |
| 311 |
|
| 312 |
// weapon ownership patches |
| 313 |
static patchnum_t arms[6][2]; |
| 314 |
|
| 315 |
// ready-weapon widget |
| 316 |
static st_number_t w_ready; |
| 317 |
|
| 318 |
// in deathmatch only, summary of frags stats |
| 319 |
static st_number_t w_frags; |
| 320 |
|
| 321 |
// health widget |
| 322 |
static st_percent_t w_health; |
| 323 |
|
| 324 |
// weapon ownership widgets |
| 325 |
static st_multicon_t w_arms[6]; |
| 326 |
|
| 327 |
// face status widget |
| 328 |
static st_multicon_t w_faces; |
| 329 |
|
| 330 |
// keycard widgets |
| 331 |
static st_multicon_t w_keyboxes[3]; |
| 332 |
|
| 333 |
// armor widget |
| 334 |
static st_percent_t w_armor; |
| 335 |
|
| 336 |
// ammo widgets |
| 337 |
static st_number_t w_ammo[4]; |
| 338 |
|
| 339 |
// max ammo widgets |
| 340 |
static st_number_t w_maxammo[4]; |
| 341 |
|
| 342 |
// number of frags so far in deathmatch |
| 343 |
static int st_fragscount; |
| 344 |
|
| 345 |
// used to use appopriately pained face |
| 346 |
static int st_oldhealth = -1; |
| 347 |
|
| 348 |
// used for evil grin |
| 349 |
static dboolean oldweaponsowned[NUMWEAPONS]; |
| 350 |
|
| 351 |
// count until face changes |
| 352 |
static int st_facecount = 0; |
| 353 |
|
| 354 |
// current face index, used by w_faces |
| 355 |
static int st_faceindex = 0; |
| 356 |
|
| 357 |
// holds key-type for each key box on bar |
| 358 |
static int keyboxes[3]; |
| 359 |
|
| 360 |
// a random number per tick |
| 361 |
static int st_randomnumber; |
| 362 |
|
| 363 |
extern char *mapnames[]; |
| 364 |
|
| 365 |
static int cr_health_bad; |
| 366 |
static int cr_health_warning; |
| 367 |
static int cr_health_ok; |
| 368 |
static int cr_health_super; |
| 369 |
static int cr_armor_zero; |
| 370 |
static int cr_armor_one; |
| 371 |
static int cr_armor_two; |
| 372 |
static int cr_ammo_bad; |
| 373 |
static int cr_ammo_warning; |
| 374 |
static int cr_ammo_ok; |
| 375 |
static int cr_ammo_full; |
| 376 |
|
| 377 |
// |
| 378 |
// STATUS BAR CODE |
| 379 |
// |
| 380 |
|
| 381 |
static void ST_Stop(void); |
| 382 |
|
| 383 |
void ST_LoadTextColors(void) |
| 384 |
{ |
| 385 |
cr_health_bad = dsda_TextCR(dsda_tc_stbar_health_bad); |
| 386 |
cr_health_warning = dsda_TextCR(dsda_tc_stbar_health_warning); |
| 387 |
cr_health_ok = dsda_TextCR(dsda_tc_stbar_health_ok); |
| 388 |
cr_health_super = dsda_TextCR(dsda_tc_stbar_health_super); |
| 389 |
cr_armor_zero = dsda_TextCR(dsda_tc_stbar_armor_zero); |
| 390 |
cr_armor_one = dsda_TextCR(dsda_tc_stbar_armor_one); |
| 391 |
cr_armor_two = dsda_TextCR(dsda_tc_stbar_armor_two); |
| 392 |
cr_ammo_bad = dsda_TextCR(dsda_tc_stbar_ammo_bad); |
| 393 |
cr_ammo_warning = dsda_TextCR(dsda_tc_stbar_ammo_warning); |
| 394 |
cr_ammo_ok = dsda_TextCR(dsda_tc_stbar_ammo_ok); |
| 395 |
cr_ammo_full = dsda_TextCR(dsda_tc_stbar_ammo_full); |
| 396 |
} |
| 397 |
|
| 398 |
// [FG] support widescreen status bar backgrounds |
| 399 |
|
| 400 |
void ST_SetScaledWidth(void) |
| 401 |
{ |
| 402 |
int width = stbarbg.width; |
| 403 |
|
| 404 |
if (width == 0) |
| 405 |
width = ST_WIDTH; |
| 406 |
|
| 407 |
switch (stretch_hud(render_stretch_hud)) |
| 408 |
{ |
| 409 |
case patch_stretch_not_adjusted: |
| 410 |
ST_SCALED_WIDTH = width * patches_scalex; |
| 411 |
break; |
| 412 |
case patch_stretch_doom_format: |
| 413 |
ST_SCALED_WIDTH = width * WIDE_SCREENWIDTH / 320; |
| 414 |
break; |
| 415 |
case patch_stretch_fit_to_width: |
| 416 |
ST_SCALED_WIDTH = width * SCREENWIDTH / 320; |
| 417 |
break; |
| 418 |
} |
| 419 |
|
| 420 |
ST_SCALED_WIDTH = (ST_SCALED_WIDTH + 3) & (int)~3; |
| 421 |
|
| 422 |
if (ST_SCALED_WIDTH > SCREENWIDTH) |
| 423 |
ST_SCALED_WIDTH = SCREENWIDTH; |
| 424 |
|
| 425 |
ST_SCALED_OFFSETX = (SCREENWIDTH - ST_SCALED_WIDTH) / 2; |
| 426 |
} |
| 427 |
|
| 428 |
static void ST_refreshBackground(void) |
| 429 |
{ |
| 430 |
int y = ST_Y; |
| 431 |
enum patch_translation_e flags = VPT_ALIGN_LEFT_TOP; |
| 432 |
|
| 433 |
if (st_statusbaron) |
| 434 |
{ |
| 435 |
flags = VPT_ALIGN_BOTTOM; |
| 436 |
|
| 437 |
V_DrawNumPatchFS(ST_X, y, BG, stbarbg.lumpnum, CR_DEFAULT, flags); |
| 438 |
if (!deathmatch) |
| 439 |
{ |
| 440 |
V_DrawNumPatch(ST_ARMSBGX, y, BG, armsbg.lumpnum, CR_DEFAULT, flags); |
| 441 |
} |
| 442 |
|
| 443 |
// killough 3/7/98: make face background change with displayplayer |
| 444 |
if (netgame) |
| 445 |
{ |
| 446 |
V_DrawNumPatch(ST_FX, y, BG, faceback.lumpnum, |
| 447 |
displayplayer ? CR_LIMIT+displayplayer : CR_DEFAULT, |
| 448 |
displayplayer ? (VPT_TRANS | VPT_ALIGN_BOTTOM) : flags); |
| 449 |
} |
| 450 |
V_CopyRect(BG, FG, ST_X + ST_SCALED_OFFSETX, SCREENHEIGHT - ST_SCALED_HEIGHT, ST_SCALED_WIDTH, ST_SCALED_HEIGHT, VPT_NONE); |
| 451 |
} |
| 452 |
} |
| 453 |
|
| 454 |
|
| 455 |
// Respond to keyboard input events, |
| 456 |
// intercept cheats. |
| 457 |
dboolean ST_Responder(event_t *ev) |
| 458 |
{ |
| 459 |
return M_CheatResponder(ev); |
| 460 |
} |
| 461 |
|
| 462 |
static int ST_calcPainOffset(void) |
| 463 |
{ |
| 464 |
static int lastcalc; |
| 465 |
static int oldhealth = -1; |
| 466 |
int health = plyr->health > 100 ? 100 : plyr->health; |
| 467 |
|
| 468 |
if (health != oldhealth) |
| 469 |
{ |
| 470 |
lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101); |
| 471 |
oldhealth = health; |
| 472 |
} |
| 473 |
return lastcalc; |
| 474 |
} |
| 475 |
|
| 476 |
// |
| 477 |
// This is a not-very-pretty routine which handles |
| 478 |
// the face states and their timing. |
| 479 |
// the precedence of expressions is: |
| 480 |
// dead > evil grin > turned head > straight ahead |
| 481 |
// |
| 482 |
|
| 483 |
// [crispy] fix status bar face hysteresis |
| 484 |
static int faceindex; |
| 485 |
|
| 486 |
static void ST_updateFaceWidget(void) |
| 487 |
{ |
| 488 |
int i; |
| 489 |
angle_t badguyangle; |
| 490 |
angle_t diffang; |
| 491 |
static int lastattackdown = -1; |
| 492 |
static int priority = 0; |
| 493 |
dboolean doevilgrin; |
| 494 |
|
| 495 |
// [crispy] fix status bar face hysteresis |
| 496 |
int painoffset; |
| 497 |
|
| 498 |
painoffset = ST_calcPainOffset(); |
| 499 |
|
| 500 |
if (priority < 10) |
| 501 |
{ |
| 502 |
// dead |
| 503 |
if (!plyr->health) |
| 504 |
{ |
| 505 |
priority = 9; |
| 506 |
painoffset = 0; |
| 507 |
faceindex = ST_DEADFACE; |
| 508 |
st_facecount = 1; |
| 509 |
} |
| 510 |
} |
| 511 |
|
| 512 |
if (priority < 9) |
| 513 |
{ |
| 514 |
if (plyr->bonuscount) |
| 515 |
{ |
| 516 |
// picking up bonus |
| 517 |
doevilgrin = false; |
| 518 |
|
| 519 |
for (i=0;i<NUMWEAPONS;i++) |
| 520 |
{ |
| 521 |
if (oldweaponsowned[i] != plyr->weaponowned[i]) |
| 522 |
{ |
| 523 |
doevilgrin = true; |
| 524 |
oldweaponsowned[i] = plyr->weaponowned[i]; |
| 525 |
} |
| 526 |
} |
| 527 |
if (doevilgrin) |
| 528 |
{ |
| 529 |
// evil grin if just picked up weapon |
| 530 |
priority = 8; |
| 531 |
st_facecount = ST_EVILGRINCOUNT; |
| 532 |
faceindex = ST_EVILGRINOFFSET; |
| 533 |
} |
| 534 |
} |
| 535 |
|
| 536 |
} |
| 537 |
|
| 538 |
if (priority < 8) |
| 539 |
{ |
| 540 |
if (plyr->damagecount && plyr->attacker && plyr->attacker != plyr->mo) |
| 541 |
{ |
| 542 |
// being attacked |
| 543 |
priority = 7; |
| 544 |
|
| 545 |
// haleyjd 10/12/03: classic DOOM problem of missing OUCH face |
| 546 |
// was due to inversion of this test: |
| 547 |
// if(plyr->health - st_oldhealth > ST_MUCHPAIN) |
| 548 |
// e6y: compatibility optioned |
| 549 |
if((comp[comp_ouchface]? |
| 550 |
(plyr->health - st_oldhealth): |
| 551 |
(st_oldhealth - plyr->health)) > ST_MUCHPAIN) |
| 552 |
{ |
| 553 |
// e6y |
| 554 |
// There are TWO bugs in the ouch face code. |
| 555 |
// Not only was the condition reversed, but the priority system is |
| 556 |
// broken in a way that makes the face not work with monster damage. |
| 557 |
if(!comp[comp_ouchface]) |
| 558 |
priority = 8; |
| 559 |
|
| 560 |
st_facecount = ST_TURNCOUNT; |
| 561 |
faceindex = ST_OUCHOFFSET; |
| 562 |
} |
| 563 |
else |
| 564 |
{ |
| 565 |
badguyangle = R_PointToAngle2(plyr->mo->x, |
| 566 |
plyr->mo->y, |
| 567 |
plyr->attacker->x, |
| 568 |
plyr->attacker->y); |
| 569 |
|
| 570 |
if (badguyangle > plyr->mo->angle) |
| 571 |
{ |
| 572 |
// whether right or left |
| 573 |
diffang = badguyangle - plyr->mo->angle; |
| 574 |
i = diffang > ANG180; |
| 575 |
} |
| 576 |
else |
| 577 |
{ |
| 578 |
// whether left or right |
| 579 |
diffang = plyr->mo->angle - badguyangle; |
| 580 |
i = diffang <= ANG180; |
| 581 |
} // confusing, aint it? |
| 582 |
|
| 583 |
|
| 584 |
st_facecount = ST_TURNCOUNT; |
| 585 |
|
| 586 |
if (diffang < ANG45) |
| 587 |
{ |
| 588 |
// head-on |
| 589 |
faceindex = ST_RAMPAGEOFFSET; |
| 590 |
} |
| 591 |
else if (i) |
| 592 |
{ |
| 593 |
// turn face right |
| 594 |
faceindex = ST_TURNOFFSET; |
| 595 |
} |
| 596 |
else |
| 597 |
{ |
| 598 |
// turn face left |
| 599 |
faceindex = ST_TURNOFFSET+1; |
| 600 |
} |
| 601 |
} |
| 602 |
} |
| 603 |
} |
| 604 |
|
| 605 |
if (priority < 7) |
| 606 |
{ |
| 607 |
// getting hurt because of your own damn stupidity |
| 608 |
if (plyr->damagecount) |
| 609 |
{ |
| 610 |
// haleyjd 10/12/03: classic DOOM problem of missing OUCH face |
| 611 |
// was due to inversion of this test: |
| 612 |
// if(plyr->health - st_oldhealth > ST_MUCHPAIN) |
| 613 |
// e6y: compatibility optioned |
| 614 |
if((comp[comp_ouchface]? |
| 615 |
(plyr->health - st_oldhealth): |
| 616 |
(st_oldhealth - plyr->health)) > ST_MUCHPAIN) |
| 617 |
{ |
| 618 |
priority = 7; |
| 619 |
st_facecount = ST_TURNCOUNT; |
| 620 |
faceindex = ST_OUCHOFFSET; |
| 621 |
} |
| 622 |
else |
| 623 |
{ |
| 624 |
priority = 6; |
| 625 |
st_facecount = ST_TURNCOUNT; |
| 626 |
faceindex = ST_RAMPAGEOFFSET; |
| 627 |
} |
| 628 |
|
| 629 |
} |
| 630 |
|
| 631 |
} |
| 632 |
|
| 633 |
if (priority < 6) |
| 634 |
{ |
| 635 |
// rapid firing |
| 636 |
if (plyr->attackdown) |
| 637 |
{ |
| 638 |
if (lastattackdown==-1) |
| 639 |
lastattackdown = ST_RAMPAGEDELAY; |
| 640 |
else if (!--lastattackdown) |
| 641 |
{ |
| 642 |
priority = 5; |
| 643 |
faceindex = ST_RAMPAGEOFFSET; |
| 644 |
st_facecount = 1; |
| 645 |
lastattackdown = 1; |
| 646 |
} |
| 647 |
} |
| 648 |
else |
| 649 |
lastattackdown = -1; |
| 650 |
|
| 651 |
} |
| 652 |
|
| 653 |
if (priority < 5) |
| 654 |
{ |
| 655 |
// invulnerability |
| 656 |
if ((plyr->cheats & CF_GODMODE) |
| 657 |
|| plyr->powers[pw_invulnerability]) |
| 658 |
{ |
| 659 |
priority = 4; |
| 660 |
|
| 661 |
painoffset = 0; |
| 662 |
faceindex = ST_GODFACE; |
| 663 |
st_facecount = 1; |
| 664 |
|
| 665 |
} |
| 666 |
|
| 667 |
} |
| 668 |
|
| 669 |
// look left or look right if the facecount has timed out |
| 670 |
if (!st_facecount) |
| 671 |
{ |
| 672 |
faceindex = st_randomnumber % 3; |
| 673 |
st_facecount = ST_STRAIGHTFACECOUNT; |
| 674 |
priority = 0; |
| 675 |
} |
| 676 |
|
| 677 |
st_facecount--; |
| 678 |
|
| 679 |
// [crispy] fix status bar face hysteresis |
| 680 |
st_faceindex = painoffset + faceindex; |
| 681 |
} |
| 682 |
|
| 683 |
int sts_traditional_keys; // killough 2/28/98: traditional status bar keys |
| 684 |
|
| 685 |
static void ST_updateWidgets(void) |
| 686 |
{ |
| 687 |
static int largeammo = 1994; // means "n/a" |
| 688 |
int i; |
| 689 |
|
| 690 |
// must redirect the pointer if the ready weapon has changed. |
| 691 |
// if (w_ready.data != plyr->readyweapon) |
| 692 |
// { |
| 693 |
if (weaponinfo[plyr->readyweapon].ammo == am_noammo) |
| 694 |
w_ready.num = &largeammo; |
| 695 |
else |
| 696 |
w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo]; |
| 697 |
//{ |
| 698 |
// static int tic=0; |
| 699 |
// static int dir=-1; |
| 700 |
// if (!(tic&15)) |
| 701 |
// plyr->ammo[weaponinfo[plyr->readyweapon].ammo]+=dir; |
| 702 |
// if (plyr->ammo[weaponinfo[plyr->readyweapon].ammo] == -100) |
| 703 |
// dir = 1; |
| 704 |
// tic++; |
| 705 |
// } |
| 706 |
w_ready.data = plyr->readyweapon; |
| 707 |
|
| 708 |
// if (*w_ready.on) |
| 709 |
// STlib_updateNum(&w_ready, true); |
| 710 |
// refresh weapon change |
| 711 |
// } |
| 712 |
|
| 713 |
// update keycard multiple widgets |
| 714 |
for (i=0;i<3;i++) |
| 715 |
{ |
| 716 |
keyboxes[i] = plyr->cards[i] ? i : -1; |
| 717 |
|
| 718 |
//jff 2/24/98 select double key |
| 719 |
//killough 2/28/98: preserve traditional keys by config option |
| 720 |
|
| 721 |
if (plyr->cards[i+3]) |
| 722 |
keyboxes[i] = keyboxes[i]==-1 || sts_traditional_keys ? i+3 : i+6; |
| 723 |
} |
| 724 |
|
| 725 |
// refresh everything if this is him coming back to life |
| 726 |
ST_updateFaceWidget(); |
| 727 |
|
| 728 |
// used by the w_armsbg widget |
| 729 |
st_notdeathmatch = !deathmatch; |
| 730 |
|
| 731 |
// used by w_arms[] widgets |
| 732 |
st_armson = st_statusbaron && !deathmatch; |
| 733 |
|
| 734 |
// used by w_frags widget |
| 735 |
st_fragson = deathmatch && st_statusbaron; |
| 736 |
st_fragscount = 0; |
| 737 |
|
| 738 |
for (i = 0; i < g_maxplayers; i++) |
| 739 |
{ |
| 740 |
if (i != displayplayer) // killough 3/7/98 |
| 741 |
st_fragscount += plyr->frags[i]; |
| 742 |
else |
| 743 |
st_fragscount -= plyr->frags[i]; |
| 744 |
} |
| 745 |
} |
| 746 |
|
| 747 |
void ST_Ticker(void) |
| 748 |
{ |
| 749 |
if (raven) return SB_Ticker(); |
| 750 |
|
| 751 |
st_clock++; |
| 752 |
st_randomnumber = M_Random(); |
| 753 |
ST_updateWidgets(); |
| 754 |
st_oldhealth = plyr->health; |
| 755 |
} |
| 756 |
|
| 757 |
int st_palette = 0; |
| 758 |
|
| 759 |
static void ST_doPaletteStuff(void) |
| 760 |
{ |
| 761 |
int palette; |
| 762 |
int cnt = dsda_PainPalette() ? plyr->damagecount : 0; |
| 763 |
|
| 764 |
if (dsda_PowerPalette() && plyr->powers[pw_strength]) |
| 765 |
{ |
| 766 |
// slowly fade the berzerk out |
| 767 |
int bzc = 12 - (plyr->powers[pw_strength]>>6); |
| 768 |
if (bzc > cnt) |
| 769 |
cnt = bzc; |
| 770 |
} |
| 771 |
|
| 772 |
if (cnt) |
| 773 |
{ |
| 774 |
// In Chex Quest, the player never sees red. Instead, the |
| 775 |
// radiation suit palette is used to tint the screen green, |
| 776 |
// as though the player is being covered in goo by an |
| 777 |
// attacking flemoid. |
| 778 |
if (gamemission == tc_chex) |
| 779 |
{ |
| 780 |
palette = RADIATIONPAL; |
| 781 |
} |
| 782 |
else |
| 783 |
{ |
| 784 |
palette = (cnt+7)>>3; |
| 785 |
if (palette >= NUMREDPALS) |
| 786 |
palette = NUMREDPALS-1; |
| 787 |
|
| 788 |
/* cph 2006/08/06 - if in the menu, reduce the red tint - navigating to |
| 789 |
* load a game can be tricky if the screen is all red */ |
| 790 |
if (menuactive) palette >>=1; |
| 791 |
|
| 792 |
palette += STARTREDPALS; |
| 793 |
} |
| 794 |
} |
| 795 |
else |
| 796 |
if (dsda_BonusPalette() && plyr->bonuscount) |
| 797 |
{ |
| 798 |
palette = (plyr->bonuscount+7)>>3; |
| 799 |
if (palette >= NUMBONUSPALS) |
| 800 |
palette = NUMBONUSPALS-1; |
| 801 |
palette += STARTBONUSPALS; |
| 802 |
} |
| 803 |
else |
| 804 |
if (dsda_PowerPalette() && (plyr->powers[pw_ironfeet] > 4*32 || plyr->powers[pw_ironfeet] & 8)) |
| 805 |
palette = RADIATIONPAL; |
| 806 |
else |
| 807 |
palette = 0; |
| 808 |
|
| 809 |
if (palette != st_palette) { |
| 810 |
V_SetPalette(st_palette = palette); // CPhipps - use new palette function |
| 811 |
} |
| 812 |
} |
| 813 |
|
| 814 |
void M_ChangeApplyPalette(void) |
| 815 |
{ |
| 816 |
st_palette = -1; |
| 817 |
|
| 818 |
if (in_game && gamestate == GS_LEVEL) |
| 819 |
{ |
| 820 |
if (raven) |
| 821 |
SB_PaletteFlash(true); |
| 822 |
else |
| 823 |
ST_doPaletteStuff(); |
| 824 |
} |
| 825 |
else |
| 826 |
V_SetPalette(0); |
| 827 |
} |
| 828 |
|
| 829 |
int ST_HealthColor(int health) |
| 830 |
{ |
| 831 |
if (health < hud_health_red) |
| 832 |
return cr_health_bad; |
| 833 |
else if (health < hud_health_yellow) |
| 834 |
return cr_health_warning; |
| 835 |
else if (health <= hud_health_green) |
| 836 |
return cr_health_ok; |
| 837 |
else |
| 838 |
return cr_health_super; |
| 839 |
} |
| 840 |
|
| 841 |
static void ST_drawWidgets(dboolean refresh) |
| 842 |
{ |
| 843 |
int i; |
| 844 |
|
| 845 |
// used by w_arms[] widgets |
| 846 |
st_armson = st_statusbaron && !deathmatch; |
| 847 |
|
| 848 |
// used by w_frags widget |
| 849 |
st_fragson = deathmatch && st_statusbaron; |
| 850 |
|
| 851 |
//jff 2/16/98 make color of ammo depend on amount |
| 852 |
if (*w_ready.num == plyr->maxammo[weaponinfo[w_ready.data].ammo]) |
| 853 |
STlib_updateNum(&w_ready, cr_ammo_full, refresh); |
| 854 |
else { |
| 855 |
int ammopct = P_AmmoPercent(plyr, w_ready.data); |
| 856 |
|
| 857 |
if (ammopct < hud_ammo_red) |
| 858 |
STlib_updateNum(&w_ready, cr_ammo_bad, refresh); |
| 859 |
else if (ammopct < hud_ammo_yellow) |
| 860 |
STlib_updateNum(&w_ready, cr_ammo_warning, refresh); |
| 861 |
else |
| 862 |
STlib_updateNum(&w_ready, cr_ammo_ok, refresh); |
| 863 |
} |
| 864 |
|
| 865 |
for (i = 0; i < 4; i++) |
| 866 |
{ |
| 867 |
STlib_updateNum(&w_ammo[i], CR_DEFAULT, refresh); //jff 2/16/98 no xlation |
| 868 |
STlib_updateNum(&w_maxammo[i], CR_DEFAULT, refresh); |
| 869 |
} |
| 870 |
|
| 871 |
//jff 2/16/98 make color of health depend on amount |
| 872 |
STlib_updatePercent(&w_health, ST_HealthColor(*w_health.n.num), refresh); |
| 873 |
|
| 874 |
// armor color dictated by type (Status Bar) |
| 875 |
if (plyr->armortype >= 2) |
| 876 |
STlib_updatePercent(&w_armor, cr_armor_two, refresh); |
| 877 |
else if (plyr->armortype == 1) |
| 878 |
STlib_updatePercent(&w_armor, cr_armor_one, refresh); |
| 879 |
else if (plyr->armortype == 0) |
| 880 |
STlib_updatePercent(&w_armor, cr_armor_zero, refresh); |
| 881 |
|
| 882 |
for (i=0;i<6;i++) |
| 883 |
STlib_updateMultIcon(&w_arms[i], refresh); |
| 884 |
|
| 885 |
STlib_updateMultIcon(&w_faces, refresh); |
| 886 |
|
| 887 |
for (i=0;i<3;i++) |
| 888 |
STlib_updateMultIcon(&w_keyboxes[i], refresh); |
| 889 |
|
| 890 |
STlib_updateNum(&w_frags, CR_DEFAULT, refresh); |
| 891 |
|
| 892 |
} |
| 893 |
|
| 894 |
void ST_SetResolution(void) |
| 895 |
{ |
| 896 |
st_firsttime = true; |
| 897 |
R_FillBackScreen(); |
| 898 |
} |
| 899 |
|
| 900 |
void ST_Refresh(void) |
| 901 |
{ |
| 902 |
st_firsttime = true; |
| 903 |
} |
| 904 |
|
| 905 |
void ST_Drawer(dboolean refresh) |
| 906 |
{ |
| 907 |
dboolean statusbaron = R_StatusBarVisible(); |
| 908 |
|
| 909 |
V_BeginUIDraw(); |
| 910 |
|
| 911 |
if (raven) |
| 912 |
{ |
| 913 |
SB_Drawer(statusbaron, refresh); |
| 914 |
V_EndUIDraw(); |
| 915 |
return; |
| 916 |
} |
| 917 |
|
| 918 |
/* cph - let status bar on be controlled |
| 919 |
* completely by the call from D_Display |
| 920 |
* proff - really do it |
| 921 |
*/ |
| 922 |
st_firsttime = st_firsttime || refresh; |
| 923 |
|
| 924 |
ST_doPaletteStuff(); // Do red-/gold-shifts from damage/items |
| 925 |
|
| 926 |
if (statusbaron) { |
| 927 |
if (st_firsttime || (V_IsOpenGLMode() || fadeBG())) |
| 928 |
{ |
| 929 |
/* If just after ST_Start(), refresh all */ |
| 930 |
st_firsttime = false; |
| 931 |
ST_refreshBackground(); // draw status bar background to off-screen buff |
| 932 |
ST_drawWidgets(true); // and refresh all widgets |
| 933 |
} |
| 934 |
else |
| 935 |
{ |
| 936 |
/* Otherwise, update as little as possible */ |
| 937 |
ST_drawWidgets(false); // update all widgets |
| 938 |
} |
| 939 |
} |
| 940 |
|
| 941 |
V_EndUIDraw(); |
| 942 |
} |
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
// |
| 947 |
// ST_loadGraphics |
| 948 |
// |
| 949 |
// CPhipps - Loads graphics needed for status bar |
| 950 |
// |
| 951 |
static void ST_loadGraphics(void) |
| 952 |
{ |
| 953 |
int i, facenum; |
| 954 |
char namebuf[9]; |
| 955 |
// cph - macro that either acquires a pointer and lock for a lump, or |
| 956 |
// unlocks it. var is referenced exactly once in either case, so ++ in arg works |
| 957 |
|
| 958 |
// Load the numbers, tall and short |
| 959 |
for (i=0;i<10;i++) |
| 960 |
{ |
| 961 |
snprintf(namebuf, sizeof(namebuf), "STTNUM%d", i); |
| 962 |
R_SetPatchNum(&tallnum[i],namebuf); |
| 963 |
snprintf(namebuf, sizeof(namebuf), "STYSNUM%d", i); |
| 964 |
R_SetPatchNum(&shortnum[i],namebuf); |
| 965 |
} |
| 966 |
|
| 967 |
// Load percent key. |
| 968 |
R_SetPatchNum(&tallpercent,"STTPRCNT"); |
| 969 |
|
| 970 |
// key cards |
| 971 |
for (i=0;i<DOOM_NUMCARDS+3;i++) //jff 2/23/98 show both keys too |
| 972 |
{ |
| 973 |
snprintf(namebuf, sizeof(namebuf), "STKEYS%d", i); |
| 974 |
R_SetPatchNum(&keys[i], namebuf); |
| 975 |
} |
| 976 |
|
| 977 |
//e6y: status bar background |
| 978 |
R_SetPatchNum(&stbarbg, "STBAR"); |
| 979 |
R_SetPatchNum(&brdr_b, "brdr_b"); |
| 980 |
|
| 981 |
// arms background |
| 982 |
R_SetPatchNum(&armsbg, "STARMS"); |
| 983 |
|
| 984 |
// arms ownership widgets |
| 985 |
for (i=0;i<6;i++) |
| 986 |
{ |
| 987 |
snprintf(namebuf, sizeof(namebuf), "STGNUM%d", i+2); |
| 988 |
|
| 989 |
// gray # |
| 990 |
R_SetPatchNum(&arms[i][0], namebuf); |
| 991 |
|
| 992 |
// yellow # |
| 993 |
arms[i][1] = shortnum[i+2]; |
| 994 |
} |
| 995 |
|
| 996 |
// face backgrounds for different color players |
| 997 |
// killough 3/7/98: add better support for spy mode by loading all |
| 998 |
// player face backgrounds and using displayplayer to choose them: |
| 999 |
R_SetPatchNum(&faceback, "STFB0"); |
| 1000 |
|
| 1001 |
// face states |
| 1002 |
facenum = 0; |
| 1003 |
for (i=0;i<ST_NUMPAINFACES;i++) |
| 1004 |
{ |
| 1005 |
int j; |
| 1006 |
for (j=0;j<ST_NUMSTRAIGHTFACES;j++) |
| 1007 |
{ |
| 1008 |
snprintf(namebuf, sizeof(namebuf), "STFST%d%d", i, j); |
| 1009 |
R_SetPatchNum(&faces[facenum++], namebuf); |
| 1010 |
} |
| 1011 |
snprintf(namebuf, sizeof(namebuf), "STFTR%d0", i); // turn right |
| 1012 |
R_SetPatchNum(&faces[facenum++], namebuf); |
| 1013 |
snprintf(namebuf, sizeof(namebuf), "STFTL%d0", i); // turn left |
| 1014 |
R_SetPatchNum(&faces[facenum++], namebuf); |
| 1015 |
snprintf(namebuf, sizeof(namebuf), "STFOUCH%d", i); // ouch! |
| 1016 |
R_SetPatchNum(&faces[facenum++], namebuf); |
| 1017 |
snprintf(namebuf, sizeof(namebuf), "STFEVL%d", i); // evil grin ;) |
| 1018 |
R_SetPatchNum(&faces[facenum++], namebuf); |
| 1019 |
snprintf(namebuf, sizeof(namebuf), "STFKILL%d", i); // pissed off |
| 1020 |
R_SetPatchNum(&faces[facenum++], namebuf); |
| 1021 |
} |
| 1022 |
R_SetPatchNum(&faces[facenum++], "STFGOD0"); |
| 1023 |
R_SetPatchNum(&faces[facenum++], "STFDEAD0"); |
| 1024 |
|
| 1025 |
// [FG] support widescreen status bar backgrounds |
| 1026 |
ST_SetScaledWidth(); |
| 1027 |
|
| 1028 |
ST_LoadTextColors(); |
| 1029 |
} |
| 1030 |
|
| 1031 |
static void ST_initData(void) |
| 1032 |
{ |
| 1033 |
int i; |
| 1034 |
|
| 1035 |
st_firsttime = true; |
| 1036 |
plyr = &players[displayplayer]; // killough 3/7/98 |
| 1037 |
|
| 1038 |
st_clock = 0; |
| 1039 |
|
| 1040 |
st_statusbaron = true; |
| 1041 |
|
| 1042 |
faceindex = 0; // [crispy] fix status bar face hysteresis across level changes |
| 1043 |
st_faceindex = 0; |
| 1044 |
st_palette = -1; |
| 1045 |
|
| 1046 |
st_oldhealth = -1; |
| 1047 |
|
| 1048 |
for (i=0;i<NUMWEAPONS;i++) |
| 1049 |
oldweaponsowned[i] = plyr->weaponowned[i]; |
| 1050 |
|
| 1051 |
for (i=0;i<3;i++) |
| 1052 |
keyboxes[i] = -1; |
| 1053 |
|
| 1054 |
STlib_init(); |
| 1055 |
} |
| 1056 |
|
| 1057 |
static void ST_createWidgets(void) |
| 1058 |
{ |
| 1059 |
int i; |
| 1060 |
|
| 1061 |
// ready weapon ammo |
| 1062 |
STlib_initNum(&w_ready, |
| 1063 |
ST_AMMOX, |
| 1064 |
ST_AMMOY, |
| 1065 |
tallnum, |
| 1066 |
&plyr->ammo[weaponinfo[plyr->readyweapon].ammo], |
| 1067 |
&st_statusbaron, |
| 1068 |
ST_AMMOWIDTH ); |
| 1069 |
|
| 1070 |
// the last weapon type |
| 1071 |
w_ready.data = plyr->readyweapon; |
| 1072 |
|
| 1073 |
// health percentage |
| 1074 |
STlib_initPercent(&w_health, |
| 1075 |
ST_HEALTHX, |
| 1076 |
ST_HEALTHY, |
| 1077 |
tallnum, |
| 1078 |
&plyr->health, |
| 1079 |
&st_statusbaron, |
| 1080 |
&tallpercent); |
| 1081 |
|
| 1082 |
// weapons owned |
| 1083 |
for(i=0;i<6;i++) |
| 1084 |
{ |
| 1085 |
STlib_initMultIcon(&w_arms[i], |
| 1086 |
ST_ARMSX+(i%3)*ST_ARMSXSPACE, |
| 1087 |
ST_ARMSY+(i/3)*ST_ARMSYSPACE, |
| 1088 |
arms[i], (int *) &plyr->weaponowned[i+1], |
| 1089 |
&st_armson); |
| 1090 |
} |
| 1091 |
|
| 1092 |
// frags sum |
| 1093 |
STlib_initNum(&w_frags, |
| 1094 |
ST_FRAGSX, |
| 1095 |
ST_FRAGSY, |
| 1096 |
tallnum, |
| 1097 |
&st_fragscount, |
| 1098 |
&st_fragson, |
| 1099 |
ST_FRAGSWIDTH); |
| 1100 |
|
| 1101 |
// faces |
| 1102 |
STlib_initMultIcon(&w_faces, |
| 1103 |
ST_FACESX, |
| 1104 |
ST_FACESY, |
| 1105 |
faces, |
| 1106 |
&st_faceindex, |
| 1107 |
&st_statusbaron); |
| 1108 |
|
| 1109 |
// armor percentage - should be colored later |
| 1110 |
STlib_initPercent(&w_armor, |
| 1111 |
ST_ARMORX, |
| 1112 |
ST_ARMORY, |
| 1113 |
tallnum, |
| 1114 |
&plyr->armorpoints[ARMOR_ARMOR], |
| 1115 |
&st_statusbaron, &tallpercent); |
| 1116 |
|
| 1117 |
// keyboxes 0-2 |
| 1118 |
STlib_initMultIcon(&w_keyboxes[0], |
| 1119 |
ST_KEY0X, |
| 1120 |
ST_KEY0Y, |
| 1121 |
keys, |
| 1122 |
&keyboxes[0], |
| 1123 |
&st_statusbaron); |
| 1124 |
|
| 1125 |
STlib_initMultIcon(&w_keyboxes[1], |
| 1126 |
ST_KEY1X, |
| 1127 |
ST_KEY1Y, |
| 1128 |
keys, |
| 1129 |
&keyboxes[1], |
| 1130 |
&st_statusbaron); |
| 1131 |
|
| 1132 |
STlib_initMultIcon(&w_keyboxes[2], |
| 1133 |
ST_KEY2X, |
| 1134 |
ST_KEY2Y, |
| 1135 |
keys, |
| 1136 |
&keyboxes[2], |
| 1137 |
&st_statusbaron); |
| 1138 |
|
| 1139 |
// ammo count (all four kinds) |
| 1140 |
STlib_initNum(&w_ammo[0], |
| 1141 |
ST_AMMO0X, |
| 1142 |
ST_AMMO0Y, |
| 1143 |
shortnum, |
| 1144 |
&plyr->ammo[0], |
| 1145 |
&st_statusbaron, |
| 1146 |
ST_AMMO0WIDTH); |
| 1147 |
|
| 1148 |
STlib_initNum(&w_ammo[1], |
| 1149 |
ST_AMMO1X, |
| 1150 |
ST_AMMO1Y, |
| 1151 |
shortnum, |
| 1152 |
&plyr->ammo[1], |
| 1153 |
&st_statusbaron, |
| 1154 |
ST_AMMO1WIDTH); |
| 1155 |
|
| 1156 |
STlib_initNum(&w_ammo[2], |
| 1157 |
ST_AMMO2X, |
| 1158 |
ST_AMMO2Y, |
| 1159 |
shortnum, |
| 1160 |
&plyr->ammo[2], |
| 1161 |
&st_statusbaron, |
| 1162 |
ST_AMMO2WIDTH); |
| 1163 |
|
| 1164 |
STlib_initNum(&w_ammo[3], |
| 1165 |
ST_AMMO3X, |
| 1166 |
ST_AMMO3Y, |
| 1167 |
shortnum, |
| 1168 |
&plyr->ammo[3], |
| 1169 |
&st_statusbaron, |
| 1170 |
ST_AMMO3WIDTH); |
| 1171 |
|
| 1172 |
// max ammo count (all four kinds) |
| 1173 |
STlib_initNum(&w_maxammo[0], |
| 1174 |
ST_MAXAMMO0X, |
| 1175 |
ST_MAXAMMO0Y, |
| 1176 |
shortnum, |
| 1177 |
&plyr->maxammo[0], |
| 1178 |
&st_statusbaron, |
| 1179 |
ST_MAXAMMO0WIDTH); |
| 1180 |
|
| 1181 |
STlib_initNum(&w_maxammo[1], |
| 1182 |
ST_MAXAMMO1X, |
| 1183 |
ST_MAXAMMO1Y, |
| 1184 |
shortnum, |
| 1185 |
&plyr->maxammo[1], |
| 1186 |
&st_statusbaron, |
| 1187 |
ST_MAXAMMO1WIDTH); |
| 1188 |
|
| 1189 |
STlib_initNum(&w_maxammo[2], |
| 1190 |
ST_MAXAMMO2X, |
| 1191 |
ST_MAXAMMO2Y, |
| 1192 |
shortnum, |
| 1193 |
&plyr->maxammo[2], |
| 1194 |
&st_statusbaron, |
| 1195 |
ST_MAXAMMO2WIDTH); |
| 1196 |
|
| 1197 |
STlib_initNum(&w_maxammo[3], |
| 1198 |
ST_MAXAMMO3X, |
| 1199 |
ST_MAXAMMO3Y, |
| 1200 |
shortnum, |
| 1201 |
&plyr->maxammo[3], |
| 1202 |
&st_statusbaron, |
| 1203 |
ST_MAXAMMO3WIDTH); |
| 1204 |
} |
| 1205 |
|
| 1206 |
static dboolean st_stopped = true; |
| 1207 |
|
| 1208 |
void ST_Start(void) |
| 1209 |
{ |
| 1210 |
if (raven) return SB_Start(); |
| 1211 |
|
| 1212 |
if (!st_stopped) |
| 1213 |
ST_Stop(); |
| 1214 |
ST_initData(); |
| 1215 |
ST_createWidgets(); |
| 1216 |
st_stopped = false; |
| 1217 |
} |
| 1218 |
|
| 1219 |
static void ST_Stop(void) |
| 1220 |
{ |
| 1221 |
if (st_stopped) |
| 1222 |
return; |
| 1223 |
V_SetPalette(0); |
| 1224 |
st_stopped = true; |
| 1225 |
} |
| 1226 |
|
| 1227 |
void ST_Init(void) |
| 1228 |
{ |
| 1229 |
if (raven) return SB_Init(); |
| 1230 |
|
| 1231 |
veryfirsttime = 0; |
| 1232 |
ST_loadGraphics(); |
| 1233 |
} |