Debian Codegraph @

prboom2/src/dsda/hud_components/minimap.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 Minimap HUD Component
16 //
17
18 #include "base.h"
19
20 #include "minimap.h"
21
22 typedef struct {
23 int x, y, width, height, scale;
24 } local_component_t;
25
26 static local_component_t* local;
27
28 void dsda_InitMinimapHC(int x_offset, int y_offset, int vpt, int* args, int arg_count, void** data) {
29 *data = Z_Calloc(1, sizeof(local_component_t));
30 local = *data;
31
32 local->x = x_offset;
33 local->y = dsda_HudComponentY(y_offset, vpt, 0);
34 local->width = args[0];
35 local->height = args[1];
36 local->scale = args[2];
37
38 if (local->x < 0)
39 local->x = 0;
40
41 if (local->width <= 0 || local->width > 320)
42 local->width = 48;
43
44 if (local->x + local->width > 320)
45 local->x = 320 - local->width;
46
47 if (local->y < 0)
48 local->y = 0;
49
50 if (local->height <= 0 || local->height > 200)
51 local->height = 48;
52
53 if (local->y + local->height > 200)
54 local->y = 200 - local->height;
55
56 if (local->scale < 64)
57 local->scale = 1024;
58
59 V_GetWideRect(&local->x, &local->y, &local->width, &local->height, vpt);
60 }
61
62 void dsda_UpdateMinimapHC(void* data) {
63 local = data;
64 }
65
66 void dsda_DrawMinimapHC(void* data) {
67 local = data;
68
69 AM_Drawer(true);
70 }
71
72 void dsda_CopyMinimapCoordinates(int* f_x, int* f_y, int* f_w, int* f_h) {
73 if (!local)
74 return;
75
76 *f_x = local->x;
77 *f_y = local->y;
78 *f_w = local->width;
79 *f_h = local->height;
80 }
81
82 int dsda_MinimapScale(void) {
83 if (!local)
84 return 1024;
85
86 return local->scale;
87 }