-
Notifications
You must be signed in to change notification settings - Fork 3
/
plugin.cpp
191 lines (136 loc) · 3.72 KB
/
plugin.cpp
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
#include <IClientPlugin.h>
#include <interface.h>
#include <base_feature.h>
#include <convar.h>
#include <dbg.h>
#include "clientmenu.h"
#include "client_hooks.h"
//-----------------------------------------------------------------------------
// Client Menu plugin interface
//-----------------------------------------------------------------------------
class CClientMenuPlugin : public IClientPlugin
{
public:
virtual api_version_s GetAPIVersion();
virtual bool Load(CreateInterfaceFn pfnSvenModFactory, ISvenModAPI *pSvenModAPI, IPluginHelpers *pPluginHelpers);
virtual void PostLoad(bool bGlobalLoad);
virtual void Unload(void);
virtual bool Pause(void);
virtual void Unpause(void);
virtual void OnFirstClientdataReceived(client_data_t *pcldata, float flTime);
virtual void OnBeginLoading(void);
virtual void OnEndLoading(void);
virtual void OnDisconnect(void);
virtual void GameFrame(client_state_t state, double frametime, bool bPostRunCmd);
virtual void Draw(void);
virtual void DrawHUD(float time, int intermission);
virtual const char *GetName(void);
virtual const char *GetAuthor(void);
virtual const char *GetVersion(void);
virtual const char *GetDescription(void);
virtual const char *GetURL(void);
virtual const char *GetDate(void);
virtual const char *GetLogTag(void);
};
//-----------------------------------------------------------------------------
// Plugin's implementation
//-----------------------------------------------------------------------------
api_version_s CClientMenuPlugin::GetAPIVersion()
{
return SVENMOD_API_VER;
}
bool CClientMenuPlugin::Load(CreateInterfaceFn pfnSvenModFactory, ISvenModAPI *pSvenModAPI, IPluginHelpers *pPluginHelpers)
{
BindApiToGlobals(pSvenModAPI);
if ( !LoadFeatures() )
{
Warning("Failed to initialize ClientMenu feature\n");
return false;
}
ConVar_Register();
g_pEngineFuncs->ClientCmd("exec clientmenu.cfg\n");
ConColorMsg({ 40, 255, 40, 255 }, "[ClientMenu] Successfully loaded\n");
return true;
}
void CClientMenuPlugin::PostLoad(bool bGlobalLoad)
{
if (bGlobalLoad)
{
}
else
{
}
Hooks()->RegisterClientHooks( &g_ClientHooks );
PostLoadFeatures();
}
void CClientMenuPlugin::Unload(void)
{
Hooks()->UnregisterClientHooks(&g_ClientHooks);
UnloadFeatures();
ConVar_Unregister();
}
bool CClientMenuPlugin::Pause(void)
{
return true;
}
void CClientMenuPlugin::Unpause(void)
{
}
void CClientMenuPlugin::GameFrame(client_state_t state, double frametime, bool bPostRunCmd)
{
if ( !bPostRunCmd && state == CLS_ACTIVE )
{
g_ClientMenu.OnGameFrame();
}
}
void CClientMenuPlugin::OnFirstClientdataReceived(client_data_t *pcldata, float flTime)
{
}
void CClientMenuPlugin::OnBeginLoading(void)
{
}
void CClientMenuPlugin::OnEndLoading(void)
{
}
void CClientMenuPlugin::OnDisconnect(void)
{
}
void CClientMenuPlugin::Draw(void)
{
g_ClientMenu.Draw();
}
void CClientMenuPlugin::DrawHUD(float time, int intermission)
{
}
const char *CClientMenuPlugin::GetName(void)
{
return "Client Menu";
}
const char *CClientMenuPlugin::GetAuthor(void)
{
return "Sw1ft";
}
const char *CClientMenuPlugin::GetVersion(void)
{
return "1.1.0";
}
const char *CClientMenuPlugin::GetDescription(void)
{
return "Customizable client-side menu";
}
const char *CClientMenuPlugin::GetURL(void)
{
return "https://github.com/sw1ft747/clientmenu";
}
const char *CClientMenuPlugin::GetDate(void)
{
return SVENMOD_BUILD_TIMESTAMP;
}
const char *CClientMenuPlugin::GetLogTag(void)
{
return "CLMENU";
}
//-----------------------------------------------------------------------------
// Export the interface
//-----------------------------------------------------------------------------
EXPOSE_SINGLE_INTERFACE(CClientMenuPlugin, IClientPlugin, CLIENT_PLUGIN_INTERFACE_VERSION);