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
|
/*
Uses HUD text to show current run time somewhere on the screen.
This is manually refreshed whenever the players' timer is started, ended or
stopped to improve responsiveness.
*/
static Handle timerHudSynchronizer;
// =====[ PUBLIC ]=====
char[] FormatTimerTextForMenu(KZPlayer player, HUDInfo info)
{
char timerTextString[32];
if (info.TimerRunning)
{
if (player.GetHUDOption(HUDOption_TimerType) == TimerType_Enabled)
{
FormatEx(timerTextString, sizeof(timerTextString),
"%s %s",
gC_TimeTypeNames[info.TimeType],
GOKZ_HUD_FormatTime(player.ID, info.Time));
}
else
{
FormatEx(timerTextString, sizeof(timerTextString),
"%s",
GOKZ_HUD_FormatTime(player.ID, info.Time));
}
if (info.Paused)
{
Format(timerTextString, sizeof(timerTextString), "%s (%T)", timerTextString, "Info Panel Text - PAUSED", player.ID);
}
}
return timerTextString;
}
// =====[ EVENTS ]=====
void OnPluginStart_TimerText()
{
timerHudSynchronizer = CreateHudSynchronizer();
}
void OnPlayerRunCmdPost_TimerText(int client, int cmdnum, HUDInfo info)
{
int updateSpeed = gB_FastUpdateRate[client] ? 3 : 6;
if (cmdnum % updateSpeed == 1)
{
UpdateTimerText(client, info);
}
}
void OnOptionChanged_TimerText(int client, HUDOption option)
{
if (option == HUDOption_TimerText)
{
ClearTimerText(client);
}
}
void OnTimerEnd_TimerText(int client)
{
ClearTimerText(client);
}
void OnTimerStopped_TimerText(int client)
{
ClearTimerText(client);
}
// =====[ PRIVATE ]=====
static void UpdateTimerText(int client, HUDInfo info)
{
KZPlayer player = KZPlayer(client);
if (player.Fake)
{
return;
}
ShowTimerText(player, info);
}
static void ClearTimerText(int client)
{
ClearSyncHud(client, timerHudSynchronizer);
}
static void ShowTimerText(KZPlayer player, HUDInfo info)
{
if (!info.TimerRunning)
{
if (player.ID != info.ID)
{
CancelGOKZHUDMenu(player.ID);
}
return;
}
if (player.TimerText == TimerText_Top || player.TimerText == TimerText_Bottom)
{
int colour[4]; // RGBA
if (player.GetHUDOption(HUDOption_TimerType) == TimerType_Enabled)
{
switch (info.TimeType)
{
case TimeType_Nub:colour = { 234, 209, 138, 0 };
case TimeType_Pro:colour = { 181, 212, 238, 0 };
}
}
else colour = { 255, 255, 255, 0};
switch (player.TimerText)
{
case TimerText_Top:
{
SetHudTextParams(-1.0, 0.07, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
}
case TimerText_Bottom:
{
SetHudTextParams(-1.0, 0.9, GetTextHoldTime(gB_FastUpdateRate[player.ID] ? 3 : 6), colour[0], colour[1], colour[2], colour[3], 0, 1.0, 0.0, 0.0);
}
}
ShowSyncHudText(player.ID, timerHudSynchronizer, GOKZ_HUD_FormatTime(player.ID, info.Time));
}
}
|