Debian Codegraph @

prboom2/src/dsda/hud_components/color_test.c

raw
1 //
2 // Copyright(C) 2023 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 Color Test HUD Component
16 //
17
18 #include "base.h"
19
20 #include "color_test.h"
21
22 typedef struct {
23 dsda_text_t component;
24 dsda_text_t component_blocky;
25 } local_component_t;
26
27 static local_component_t* local;
28
29 static void dsda_UpdateComponentText(char* str, size_t max_size) {
30 snprintf(
31 str,
32 max_size,
33 "\x1b%c %02d TEST\n"
34 "\x1b%c %02d TEST\n"
35 "\x1b%c %02d TEST\n"
36 "\x1b%c %02d TEST\n"
37 "\x1b%c %02d TEST\n"
38 "\x1b%c %02d TEST\n"
39 "\x1b%c %02d TEST\n"
40 "\x1b%c %02d TEST\n"
41 "\x1b%c %02d TEST\n"
42 "\x1b%c %02d TEST\n"
43 "\x1b%c %02d TEST\n"
44 "\x1b%c %02d TEST\n"
45 "\x1b%c %02d TEST\n"
46 "\x1b%c %02d TEST\n"
47 "\x1b%c %02d TEST\n",
48 HUlib_Color(0), 0,
49 HUlib_Color(1), 1,
50 HUlib_Color(2), 2,
51 HUlib_Color(3), 3,
52 HUlib_Color(4), 4,
53 HUlib_Color(5), 5,
54 HUlib_Color(6), 6,
55 HUlib_Color(7), 7,
56 HUlib_Color(8), 8,
57 HUlib_Color(9), 9,
58 HUlib_Color(10), 10,
59 HUlib_Color(11), 11,
60 HUlib_Color(12), 12,
61 HUlib_Color(13), 13,
62 HUlib_Color(14), 14
63 );
64 }
65
66 void dsda_InitColorTestHC(int x_offset, int y_offset, int vpt, int* args, int arg_count, void** data) {
67 *data = Z_Calloc(1, sizeof(local_component_t));
68 local = *data;
69
70 dsda_InitTextHC(&local->component, x_offset, y_offset, vpt);
71 dsda_InitBlockyHC(&local->component_blocky, x_offset + 64, y_offset, vpt);
72
73 dsda_UpdateComponentText(local->component.msg, sizeof(local->component.msg));
74 dsda_RefreshHudText(&local->component);
75
76 dsda_UpdateComponentText(local->component_blocky.msg, sizeof(local->component_blocky.msg));
77 dsda_RefreshHudText(&local->component_blocky);
78 }
79
80 void dsda_UpdateColorTestHC(void* data) {
81 // nothing to do
82 }
83
84 void dsda_DrawColorTestHC(void* data) {
85 local = data;
86
87 dsda_DrawBasicText(&local->component);
88 dsda_DrawBasicText(&local->component_blocky);
89 }