Debian Codegraph @

prboom2/src/dsda/hud_components/attempts.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 Attempts HUD Component
16 //
17
18 #include "dsda/split_tracker.h"
19
20 #include "base.h"
21
22 #include "attempts.h"
23
24 typedef struct {
25 dsda_text_t component;
26 } local_component_t;
27
28 static local_component_t* local;
29
30 static void dsda_UpdateComponentText(char* str, size_t max_size) {
31 if (!demorecording)
32 return;
33
34 snprintf(
35 str,
36 max_size,
37 "%s%d/%d",
38 dsda_TextColor(dsda_tc_exhud_attempts),
39 dsda_SessionAttempts(),
40 dsda_DemoAttempts()
41 );
42 }
43
44 void dsda_InitAttemptsHC(int x_offset, int y_offset, int vpt, int* args, int arg_count, void** data) {
45 *data = Z_Calloc(1, sizeof(local_component_t));
46 local = *data;
47
48 dsda_InitTextHC(&local->component, x_offset, y_offset, vpt);
49 }
50
51 void dsda_UpdateAttemptsHC(void* data) {
52 local = data;
53
54 dsda_UpdateComponentText(local->component.msg, sizeof(local->component.msg));
55 dsda_RefreshHudText(&local->component);
56 }
57
58 void dsda_DrawAttemptsHC(void* data) {
59 local = data;
60
61 dsda_DrawBasicText(&local->component);
62 }