| 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 Armor Text HUD Component |
| 16 |
// |
| 17 |
|
| 18 |
#include "base.h" |
| 19 |
|
| 20 |
#include "armor_text.h" |
| 21 |
|
| 22 |
typedef struct { |
| 23 |
dsda_text_t component; |
| 24 |
} local_component_t; |
| 25 |
|
| 26 |
static local_component_t* local; |
| 27 |
|
| 28 |
static void dsda_UpdateComponentText(char* str, size_t max_size) { |
| 29 |
player_t* player; |
| 30 |
|
| 31 |
player = &players[displayplayer]; |
| 32 |
|
| 33 |
if (hexen) { |
| 34 |
fixed_t armor_percent; |
| 35 |
|
| 36 |
armor_percent = dsda_HexenArmor(player); |
| 37 |
|
| 38 |
snprintf( |
| 39 |
str, |
| 40 |
max_size, |
| 41 |
"%sA.C. %2d", |
| 42 |
armor_percent == 0 ? dsda_TextColor(dsda_tc_exhud_armor_zero) : |
| 43 |
armor_percent <= 50 ? dsda_TextColor(dsda_tc_exhud_armor_one) : |
| 44 |
dsda_TextColor(dsda_tc_exhud_armor_two), |
| 45 |
armor_percent |
| 46 |
); |
| 47 |
} |
| 48 |
else { |
| 49 |
snprintf( |
| 50 |
str, |
| 51 |
max_size, |
| 52 |
"%sARM %3d%%", |
| 53 |
player->armorpoints[ARMOR_ARMOR] <= 0 ? dsda_TextColor(dsda_tc_exhud_armor_zero) : |
| 54 |
player->armortype == 1 ? dsda_TextColor(dsda_tc_exhud_armor_one) : |
| 55 |
dsda_TextColor(dsda_tc_exhud_armor_two), |
| 56 |
player->armorpoints[ARMOR_ARMOR] |
| 57 |
); |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
void dsda_InitArmorTextHC(int x_offset, int y_offset, int vpt, int* args, int arg_count, void** data) { |
| 62 |
*data = Z_Calloc(1, sizeof(local_component_t)); |
| 63 |
local = *data; |
| 64 |
|
| 65 |
dsda_InitTextHC(&local->component, x_offset, y_offset, vpt); |
| 66 |
} |
| 67 |
|
| 68 |
void dsda_UpdateArmorTextHC(void* data) { |
| 69 |
local = data; |
| 70 |
|
| 71 |
dsda_UpdateComponentText(local->component.msg, sizeof(local->component.msg)); |
| 72 |
dsda_RefreshHudText(&local->component); |
| 73 |
} |
| 74 |
|
| 75 |
void dsda_DrawArmorTextHC(void* data) { |
| 76 |
local = data; |
| 77 |
|
| 78 |
dsda_DrawBasicText(&local->component); |
| 79 |
} |