-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins.cpp
More file actions
104 lines (86 loc) · 2.2 KB
/
Copy pathplugins.cpp
File metadata and controls
104 lines (86 loc) · 2.2 KB
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
#include "plugins.h"
#include "VGUI2ExtensionImport.h"
#include "CommandBuilder.h"
#include <interface.h>
#include <vgui/isurface.h>
cl_enginefunc_t gEngfuncs = { 0 };
cl_exportfuncs_t gExportfuncs = { 0 };
metahook_api_t* g_pMetaHookAPI = nullptr;
mh_interface_t* g_pInterface = nullptr;
mh_enginesave_t* g_pMetaSave = nullptr;
IFileSystem* g_pFileSystem = nullptr;
extern IFileSystem* g_pFullFileSystem;
static void (*g_pfnHUD_Init)(void) = nullptr;
void CommandBuilder_Toggle(void)
{
if (g_hCommandBuilderVGUI)
{
bool visible = g_hCommandBuilderVGUI->IsVisible();
g_hCommandBuilderVGUI->SetVisible(!visible);
if (!visible)
{
g_hCommandBuilderVGUI->Activate();
}
}
else
{
g_hCommandBuilderVGUI = new CCommandBuilderVGUI(nullptr);
if (vgui::surface())
{
g_hCommandBuilderVGUI->SetParent(vgui::surface()->GetEmbeddedPanel());
}
g_hCommandBuilderVGUI->Activate();
}
}
static void HUD_Init(void)
{
if (g_pfnHUD_Init)
g_pfnHUD_Init();
gEngfuncs.pfnAddCommand("commandbuilder", CommandBuilder_Toggle);
}
void IPluginsV4::Init(metahook_api_t* pAPI, mh_interface_t* pIface, mh_enginesave_t* pSave)
{
g_pMetaHookAPI = pAPI;
g_pInterface = pIface;
g_pMetaSave = pSave;
}
void IPluginsV4::Shutdown(void)
{
if (VGUI2Extension())
{
VGUI2Extension()->UnregisterClientVGUICallbacks(&g_ClientVGUICallbacks);
}
VGUI2Extension_Shutdown();
}
void IPluginsV4::LoadEngine(cl_enginefunc_t* pEngfuncs)
{
g_pFileSystem = g_pInterface->FileSystem;
g_pFullFileSystem = g_pFileSystem;
memcpy(&gEngfuncs, pEngfuncs, sizeof(gEngfuncs));
VGUI2Extension_Init();
if (VGUI2Extension())
{
VGUI2Extension()->RegisterClientVGUICallbacks(&g_ClientVGUICallbacks);
}
}
void IPluginsV4::LoadClient(cl_exportfuncs_t* pExportFunc)
{
if (!pExportFunc)
return;
memcpy(&gExportfuncs, pExportFunc, sizeof(gExportfuncs));
g_pfnHUD_Init = pExportFunc->HUD_Init;
pExportFunc->HUD_Init = HUD_Init;
}
void IPluginsV4::ExitGame(int iResult)
{
if (VGUI2Extension())
{
VGUI2Extension()->UnregisterClientVGUICallbacks(&g_ClientVGUICallbacks);
}
VGUI2Extension_Shutdown();
}
const char* IPluginsV4::GetVersion(void)
{
return "0.0.1-dev";
}
EXPOSE_SINGLE_INTERFACE(IPluginsV4, IPluginsV4, METAHOOK_PLUGIN_API_VERSION_V4);