summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-hud/menu.sp
blob: 4b7259e705552fecccef450bf4480d64a4e97bf2 (plain)
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
/*
	Tracks whether a GOKZ HUD menu or panel element is being shown to the client.
*/



// Update the TP menu i.e. item text, item disabled/enabled
void CancelGOKZHUDMenu(int client)
{
	// Only cancel the menu if we know it's the TP menu
	if (gB_MenuShowing[client])
	{
		CancelClientMenu(client);
	}
}



// =====[ EVENTS ]=====

void OnPlayerSpawn_Menu(int client)
{
	CancelGOKZHUDMenu(client);
}

void OnOptionChanged_Menu(int client, HUDOption option)
{
	if (option == HUDOption_TPMenu || option == HUDOption_TimerText)
	{
		CancelGOKZHUDMenu(client);
	}
}

void OnTimerStart_Menu(int client)
{
	// Prevent the menu from getting cancelled every tick if player use start timer button zone.
	if (GOKZ_GetTime(client) > 0.0)
	{
		CancelGOKZHUDMenu(client);
	}
}

void OnTimerEnd_Menu(int client)
{
	CancelGOKZHUDMenu(client);
}

void OnTimerStopped_Menu(int client)
{
	CancelGOKZHUDMenu(client);
}

void OnPause_Menu(int client)
{
	CancelGOKZHUDMenu(client);
}

void OnResume_Menu(int client)
{
	CancelGOKZHUDMenu(client);
}

void OnMakeCheckpoint_Menu(int client)
{
	CancelGOKZHUDMenu(client);
}

void OnCountedTeleport_Menu(int client)
{
	CancelGOKZHUDMenu(client);
}

void OnJoinTeam_Menu(int client)
{
	CancelGOKZHUDMenu(client);
}

void OnStartPositionSet_Menu(int client)
{
	// Prevent the menu from getting cancelled every tick if player use start timer button zone.
	if (GOKZ_GetTime(client) > 0.0)
	{
		CancelGOKZHUDMenu(client);
	}
}

void OnPluginEnd_Menu()
{
	for (int client = 1; client <= MaxClients; client++)
	{
		if (IsValidClient(client))
		{
			CancelGOKZHUDMenu(client);
		}
	}
}