forked from haithun/CoD4X17a_testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathg_hud.c
199 lines (154 loc) · 5.42 KB
/
g_hud.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
===========================================================================
Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team
This file is part of CoD4X17a-Server source code.
CoD4X17a-Server source code is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
CoD4X17a-Server source code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
===========================================================================
*/
#include "g_hud.h"
#include "qcommon_io.h"
#include "g_shared.h"
#include "g_sv_shared.h"
#include "scr_vm.h"
game_hudelem_t* g_hudelems = (game_hudelem_t*)(HUDELEM_ADDR);
game_hudelem_t* G_GetNewHudElem(unsigned int clientnum){
int i;
game_hudelem_t* element = g_hudelems;
for(i = 0; i < MAX_HUDELEMS; i++, element++)
{
if(element->inuse)
continue;
element->inuse = qtrue;
element->x = 0;
element->y = 0;
element->var_03 = 0;
element->var_04 = 1023;
element->fonttype = 0;
element->align = 0;
element->screenalign = 0;
element->color.red = 255;
element->color.green = 255;
element->color.blue = 255;
element->color.alpha = 255;
element->glowcolor.red = 0;
element->glowcolor.green = 0;
element->glowcolor.blue = 0;
element->glowcolor.alpha = 0;
element->fadecolor.red = 0;
element->fadecolor.green = 0;
element->fadecolor.blue = 0;
element->fadecolor.alpha = 0;
element->fadestarttime = 0;
element->fadetime = 0;
element->var_13 = 0;
element->sort = 0;
element->displayoption = 0;
element->var_34 = 0;
element->var_35 = 0;
element->var_36 = 0;
element->var_37 = 0;
element->var_38 = 0;
element->movestarttime = 0;
element->movingtime = 0;
element->fontscale = 1.4;
element->archived = 0;
element->var_14 = 0;
element->var_15 = 0;
element->movex = 0;
element->movey = 0;
element->movealign = 0;
element->movescralign = 0;
element->var_18 = 0;
element->var_19 = 0;
element->var_20 = 0;
element->var_21 = 0;
element->var_28 = 0;
element->var_29 = 0;
element->var_30 = 0;
element->hudTextConfigStringIndex = 0;
if(clientnum > 63)
element->entitynum = 1023;
else
element->entitynum = clientnum;
element->teamnum = 0;
return element;
}
Com_PrintWarning("G_CreateHudElem: Exceeded limit of Hudelems\n");
return NULL;
}
void G_HudSetColor(game_hudelem_t* element ,ucolor_t color,ucolor_t glowcolor){
element->color = color;
element->glowcolor = glowcolor;
}
void G_HudSetPosition(game_hudelem_t* element ,float x, float y, hudscrnalign_t scrnhalign, hudscrnalign_t scrnvalign, hudalign_t alignx, hudalign_t aligny){
element->x = x;
element->y = y;
element->align = alignx | aligny;
element->screenalign = scrnhalign + scrnvalign;
}
void G_HudSetFont(game_hudelem_t* element ,float fontscale, fonttype_t fonttype){
if(fontscale > 4.6 || fontscale < 1.399999)
{
Com_PrintWarning("Fontscale: %f is out of range. Range is 1.4 to 4.6\n", fontscale);
fontscale = 1.4;
}
element->fontscale = fontscale;
element->fonttype = fonttype;
}
void G_HudSetMovingOverTime(game_hudelem_t* element ,int time, float newx, float newy){
if(time > 60000 || time < 0)
{
Com_PrintWarning("G_HudSetMovingOverTime: time: %i is out of range. Range is 0 to 60000\n", time);
time = 0;
}
element->movestarttime = level.time;
element->movex = element->x;
element->movey = element->y;
element->x = newx;
element->y = newy;
element->movealign = element->align;
element->movescralign = element->screenalign;
element->movingtime = time;
}
void G_HudSetFadingOverTime(game_hudelem_t* element ,int time, ucolor_t newcolor){
if(time > 60000 || time < 0)
{
Com_PrintWarning("G_HudSetFadeingOverTime: time: %i is out of range. Range is 0 to 60000\n", time);
time = 0;
}
element->fadestarttime = level.time;
element->fadecolor = element->color;
element->fadetime = time;
element->color = newcolor;
}
void G_HudSetText(game_hudelem_t* element ,const char *text){
element->var_14 = 0;
element->var_15 = 0;
element->var_16 = 0;
element->movex = 0;
element->movey = 0;
element->movealign = 0;
element->movescralign = 0;
element->var_18 = 0;
element->var_19 = 0;
element->var_20 = 0;
element->var_21 = 0;
element->var_28 = 0;
element->var_29 = 0;
element->var_30 = 0;
element->hudTextConfigStringIndex = G_LocalizedStringIndex(text);
element->inuse = qtrue;
}
void G_HudDestroy(game_hudelem_t* element){
Scr_FreeHudElem(element);
element->inuse = qfalse;
}