| 1 |
// |
| 2 |
// Copyright(C) 2022 by Ryan Krafnick |
| 3 |
// |
| 4 |
// This program is free software; you can redistribute it and/or |
| 5 |
// modify it under the terms of the GNU General Public License |
| 6 |
// as published by the Free Software Foundation; either version 2 |
| 7 |
// of the License, or (at your option) any later version. |
| 8 |
// |
| 9 |
// This program is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
// |
| 14 |
// DESCRIPTION: |
| 15 |
// DSDA Big Armor HUD Component |
| 16 |
// |
| 17 |
|
| 18 |
#include "base.h" |
| 19 |
|
| 20 |
#include "big_armor.h" |
| 21 |
|
| 22 |
typedef struct { |
| 23 |
dsda_patch_component_t component; |
| 24 |
} local_component_t; |
| 25 |
|
| 26 |
static local_component_t* local; |
| 27 |
|
| 28 |
static int armor_lump_green; |
| 29 |
static int armor_lump_blue; |
| 30 |
static int patch_delta_x; |
| 31 |
static int patch_vertical_spacing; |
| 32 |
static int patch_spacing; |
| 33 |
|
| 34 |
static void dsda_DrawComponent(void) { |
| 35 |
player_t* player; |
| 36 |
int x, y; |
| 37 |
int cm; |
| 38 |
int lump; |
| 39 |
int armor; |
| 40 |
|
| 41 |
player = &players[displayplayer]; |
| 42 |
x = local->component.x; |
| 43 |
y = local->component.y; |
| 44 |
|
| 45 |
if (hexen) { |
| 46 |
armor = dsda_HexenArmor(player); |
| 47 |
cm = dsda_TextCR(dsda_tc_stbar_armor_zero); |
| 48 |
lump = armor_lump_green; |
| 49 |
} |
| 50 |
else { |
| 51 |
armor = player->armorpoints[ARMOR_ARMOR]; |
| 52 |
if (armor <= 0) { |
| 53 |
cm = dsda_TextCR(dsda_tc_stbar_armor_zero); |
| 54 |
lump = armor_lump_green; |
| 55 |
} |
| 56 |
else if (player->armortype < 2) { |
| 57 |
cm = dsda_TextCR(dsda_tc_stbar_armor_one); |
| 58 |
lump = armor_lump_green; |
| 59 |
} |
| 60 |
else { |
| 61 |
cm = dsda_TextCR(dsda_tc_stbar_armor_two); |
| 62 |
lump = armor_lump_blue; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
V_DrawNumPatch(x, y, FG, lump, CR_DEFAULT, local->component.vpt); |
| 67 |
|
| 68 |
x += patch_spacing; |
| 69 |
y += patch_vertical_spacing; |
| 70 |
|
| 71 |
dsda_DrawBigNumber(x, y, patch_delta_x, 0, |
| 72 |
cm, local->component.vpt, 3, armor); |
| 73 |
} |
| 74 |
|
| 75 |
void dsda_InitBigArmorHC(int x_offset, int y_offset, int vpt, int* args, int arg_count, void** data) { |
| 76 |
*data = Z_Calloc(1, sizeof(local_component_t)); |
| 77 |
local = *data; |
| 78 |
|
| 79 |
if (heretic) { |
| 80 |
armor_lump_green = R_NumPatchForSpriteIndex(HERETIC_SPR_SHLD); |
| 81 |
armor_lump_blue = R_NumPatchForSpriteIndex(HERETIC_SPR_SHD2); |
| 82 |
patch_delta_x = 10; |
| 83 |
patch_vertical_spacing = 6; |
| 84 |
patch_spacing = 2; |
| 85 |
} |
| 86 |
else if (hexen) { |
| 87 |
armor_lump_green = R_NumPatchForSpriteIndex(HEXEN_SPR_ARM3); |
| 88 |
armor_lump_blue = R_NumPatchForSpriteIndex(HEXEN_SPR_ARM3); |
| 89 |
patch_delta_x = 10; |
| 90 |
patch_vertical_spacing = 4; |
| 91 |
patch_spacing = 2; |
| 92 |
} |
| 93 |
else { |
| 94 |
armor_lump_green = R_NumPatchForSpriteIndex(SPR_ARM1); |
| 95 |
armor_lump_blue = R_NumPatchForSpriteIndex(SPR_ARM2); |
| 96 |
patch_delta_x = 14; |
| 97 |
patch_vertical_spacing = 1; |
| 98 |
patch_spacing = 2; |
| 99 |
} |
| 100 |
patch_spacing += MAX(R_NumPatchWidth(armor_lump_green), R_NumPatchWidth(armor_lump_blue)); |
| 101 |
dsda_InitPatchHC(&local->component, x_offset, y_offset, vpt); |
| 102 |
} |
| 103 |
|
| 104 |
void dsda_UpdateBigArmorHC(void* data) { |
| 105 |
local = data; |
| 106 |
} |
| 107 |
|
| 108 |
void dsda_DrawBigArmorHC(void* data) { |
| 109 |
local = data; |
| 110 |
|
| 111 |
dsda_DrawComponent(); |
| 112 |
} |