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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
/*
Displays information using hint text.
This is manually refreshed whenever player has taken off so that they see
their pre-speed as soon as possible, improving responsiveness.
*/
static bool infoPanelDuckPressedLast[MAXPLAYERS + 1];
static bool infoPanelOnGroundLast[MAXPLAYERS + 1];
static bool infoPanelShowDuckString[MAXPLAYERS + 1];
// =====[ PUBLIC ]=====
bool IsDrawingInfoPanel(int client)
{
KZPlayer player = KZPlayer(client);
return player.InfoPanel != InfoPanel_Disabled
&& !NothingEnabledInInfoPanel(player);
}
// =====[ EVENTS ]=====
void OnPlayerRunCmdPost_InfoPanel(int client, int cmdnum, HUDInfo info)
{
int updateSpeed = gB_FastUpdateRate[client] ? 1 : 10;
if (cmdnum % updateSpeed == 0 || info.IsTakeoff)
{
UpdateInfoPanel(client, info);
}
infoPanelOnGroundLast[info.ID] = info.OnGround;
infoPanelDuckPressedLast[info.ID] = info.Ducking;
}
// =====[ PRIVATE ]=====
static void UpdateInfoPanel(int client, HUDInfo info)
{
KZPlayer player = KZPlayer(client);
if (player.Fake || !IsDrawingInfoPanel(player.ID))
{
return;
}
char infoPanelText[512];
FormatEx(infoPanelText, sizeof(infoPanelText), GetInfoPanel(player, info));
if (infoPanelText[0] != '\0')
{
PrintCSGOHUDText(player.ID, infoPanelText);
}
}
static bool NothingEnabledInInfoPanel(KZPlayer player)
{
bool noTimerText = player.TimerText != TimerText_InfoPanel;
bool noSpeedText = player.SpeedText != SpeedText_InfoPanel || player.Paused;
bool noKeys = player.ShowKeys == ShowKeys_Disabled
|| player.ShowKeys == ShowKeys_Spectating && player.Alive;
return noTimerText && noSpeedText && noKeys;
}
static char[] GetInfoPanel(KZPlayer player, HUDInfo info)
{
char infoPanelText[512];
FormatEx(infoPanelText, sizeof(infoPanelText),
"%s%s%s%s",
GetSpectatorString(player, info),
GetTimeString(player, info),
GetSpeedString(player, info),
GetKeysString(player, info));
if (infoPanelText[0] == '\0')
{
return infoPanelText;
}
else
{
Format(infoPanelText, sizeof(infoPanelText), "<font color='#ffffff08'>%s", infoPanelText);
}
TrimString(infoPanelText);
return infoPanelText;
}
static char[] GetSpectatorString(KZPlayer player, HUDInfo info)
{
char spectatorString[255];
if (player.SpecListPosition != SpecListPosition_InfoPanel || player.ShowSpectators == ShowSpecs_Disabled)
{
return spectatorString;
}
// Only return something if the player is alive or observing someone else
if (player.Alive || player.ObserverTarget != -1)
{
FormatEx(spectatorString, sizeof(spectatorString), "%s", FormatSpectatorTextForInfoPanel(player, KZPlayer(info.ID)));
}
return spectatorString;
}
static char[] GetTimeString(KZPlayer player, HUDInfo info)
{
char timeString[128];
if (player.TimerText != TimerText_InfoPanel)
{
timeString = "";
}
else if (info.TimerRunning)
{
if (player.GetHUDOption(HUDOption_TimerType) == TimerType_Enabled)
{
switch (info.TimeType)
{
case TimeType_Nub:
{
FormatEx(timeString, sizeof(timeString),
"%T: <font color='#ead18a'>%s</font> %s\n",
"Info Panel Text - Time", player.ID,
GOKZ_HUD_FormatTime(player.ID, info.Time),
GetPausedString(player, info));
}
case TimeType_Pro:
{
FormatEx(timeString, sizeof(timeString),
"%T: <font color='#b5d4ee'>%s</font> %s\n",
"Info Panel Text - Time", player.ID,
GOKZ_HUD_FormatTime(player.ID, info.Time),
GetPausedString(player, info));
}
}
}
else
{
FormatEx(timeString, sizeof(timeString),
"%T: <font color='#ffffff'>%s</font> %s\n",
"Info Panel Text - Time", player.ID,
GOKZ_HUD_FormatTime(player.ID, info.Time),
GetPausedString(player, info));
}
}
else
{
FormatEx(timeString, sizeof(timeString),
"%T: <font color='#ea4141'>%T</font> %s\n",
"Info Panel Text - Time", player.ID,
"Info Panel Text - Stopped", player.ID,
GetPausedString(player, info));
}
return timeString;
}
static char[] GetPausedString(KZPlayer player, HUDInfo info)
{
char pausedString[64];
if (info.Paused)
{
FormatEx(pausedString, sizeof(pausedString),
"(<font color='#ffffff'>%T</font>)",
"Info Panel Text - PAUSED", player.ID);
}
else
{
pausedString = "";
}
return pausedString;
}
static char[] GetSpeedString(KZPlayer player, HUDInfo info)
{
char speedString[128];
if (player.SpeedText != SpeedText_InfoPanel || info.Paused)
{
speedString = "";
}
else
{
if (info.OnGround || info.OnLadder || info.Noclipping)
{
FormatEx(speedString, sizeof(speedString),
"%T: <font color='#ffffff'>%.0f</font> u/s\n",
"Info Panel Text - Speed", player.ID,
RoundToPowerOfTen(info.Speed, -2));
infoPanelShowDuckString[info.ID] = false;
}
else
{
if (GOKZ_HUD_GetOption(player.ID, HUDOption_DeadstrafeColor) == DeadstrafeColor_Enabled
&& Movement_GetVerticalVelocity(info.ID) > 0.0 && Movement_GetVerticalVelocity(info.ID) < 140.0)
{
FormatEx(speedString, sizeof(speedString),
"%T: <font color='#ff2020'>%.0f</font> %s\n",
"Info Panel Text - Speed", player.ID,
RoundToPowerOfTen(info.Speed, -2),
GetTakeoffString(info));
}
else
{
FormatEx(speedString, sizeof(speedString),
"%T: <font color='#ffffff'>%.0f</font> %s\n",
"Info Panel Text - Speed", player.ID,
RoundToPowerOfTen(info.Speed, -2),
GetTakeoffString(info));
}
}
}
return speedString;
}
static char[] GetTakeoffString(HUDInfo info)
{
char takeoffString[96], duckString[32];
if (infoPanelShowDuckString[info.ID]
|| (infoPanelOnGroundLast[info.ID]
&& !info.HitBhop
&& info.IsTakeoff
&& info.Jumped
&& info.Ducking
&& (infoPanelDuckPressedLast[info.ID] || GOKZ_GetCoreOption(info.ID, Option_Mode) == Mode_Vanilla)))
{
duckString = " <font color='#71eeb8'>C</font>";
infoPanelShowDuckString[info.ID] = true;
}
else
{
duckString = "";
infoPanelShowDuckString[info.ID] = false;
}
if (info.HitJB)
{
FormatEx(takeoffString, sizeof(takeoffString),
"(<font color='#ffff20'>%.0f</font>)%s",
RoundToPowerOfTen(info.TakeoffSpeed, -2),
duckString);
}
else if (info.HitPerf)
{
FormatEx(takeoffString, sizeof(takeoffString),
"(<font color='#40ff40'>%.0f</font>)%s",
RoundToPowerOfTen(info.TakeoffSpeed, -2),
duckString);
}
else
{
FormatEx(takeoffString, sizeof(takeoffString),
"(<font color='#ffffff'>%.0f</font>)%s",
RoundToPowerOfTen(info.TakeoffSpeed, -2),
duckString);
}
return takeoffString;
}
static char[] GetKeysString(KZPlayer player, HUDInfo info)
{
char keysString[64];
if (player.ShowKeys == ShowKeys_Disabled)
{
keysString = "";
}
else if (player.ShowKeys == ShowKeys_Spectating && player.Alive)
{
keysString = "";
}
else
{
int buttons = info.Buttons;
FormatEx(keysString, sizeof(keysString),
"%T: <font color='#ffffff'>%c %c %c %c %c %c</font>\n",
"Info Panel Text - Keys", player.ID,
buttons & IN_MOVELEFT ? 'A' : '_',
buttons & IN_FORWARD ? 'W' : '_',
buttons & IN_BACK ? 'S' : '_',
buttons & IN_MOVERIGHT ? 'D' : '_',
buttons & IN_DUCK ? 'C' : '_',
buttons & IN_JUMP ? 'J' : '_');
}
return keysString;
}
// Credits to Franc1sco (https://github.com/Franc1sco/FixHintColorMessages)
void PrintCSGOHUDText(int client, const char[] format)
{
char buff[HUD_MAX_HINT_SIZE];
Format(buff, sizeof(buff), "</font>%s", format);
for (int i = strlen(buff); i < sizeof(buff) - 1; i++)
{
buff[i] = ' ';
}
buff[sizeof(buff) - 1] = '\0';
Protobuf pb = view_as<Protobuf>(StartMessageOne("TextMsg", client, USERMSG_BLOCKHOOKS));
pb.SetInt("msg_dst", 4);
pb.AddString("params", "#SFUI_ContractKillStart");
pb.AddString("params", buff);
pb.AddString("params", NULL_STRING);
pb.AddString("params", NULL_STRING);
pb.AddString("params", NULL_STRING);
pb.AddString("params", NULL_STRING);
EndMessage();
}
|