Debian Codegraph @

prboom2/src/dsda/hud_components/big_health_text.c

raw
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 Health Text HUD Component
16 //
17
18 #include "base.h"
19
20 #include "big_health_text.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 patch_delta_x;
29
30 static void dsda_DrawComponent(void) {
31 player_t* player;
32 int cm;
33
34 player = &players[displayplayer];
35
36 cm = player->health <= hud_health_red ? dsda_TextCR(dsda_tc_stbar_health_bad) :
37 player->health <= hud_health_yellow ? dsda_TextCR(dsda_tc_stbar_health_warning) :
38 player->health <= hud_health_green ? dsda_TextCR(dsda_tc_stbar_health_ok) :
39 dsda_TextCR(dsda_tc_stbar_health_super);
40
41 dsda_DrawBigNumber(local->component.x, local->component.y, patch_delta_x, 0,
42 cm, local->component.vpt, 3, player->health);
43 }
44
45 void dsda_InitBigHealthTextHC(int x_offset, int y_offset, int vpt, int* args, int arg_count, void** data) {
46 *data = Z_Calloc(1, sizeof(local_component_t));
47 local = *data;
48
49 if (heretic)
50 patch_delta_x = 10;
51 else if (hexen)
52 patch_delta_x = 10;
53 else
54 patch_delta_x = 14;
55
56 dsda_InitPatchHC(&local->component, x_offset, y_offset, vpt);
57 }
58
59 void dsda_UpdateBigHealthTextHC(void* data) {
60 local = data;
61 }
62
63 void dsda_DrawBigHealthTextHC(void* data) {
64 local = data;
65
66 dsda_DrawComponent();
67 }