-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins.cpp
More file actions
79 lines (65 loc) · 1.91 KB
/
Copy pathplugins.cpp
File metadata and controls
79 lines (65 loc) · 1.91 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
#include <metahook.h>
#include <interface.h>
#include "plugins.h"
#include "exportfuncs.h"
cl_exportfuncs_t gExportfuncs = { 0 };
cl_enginefunc_t gEngfuncs = { 0 };
mh_interface_t* g_pInterface = nullptr;
metahook_api_t* g_pMetaHookAPI = nullptr;
mh_enginesave_t* g_pMetaSave = nullptr;
IFileSystem* g_pFileSystem = nullptr;
IFileSystem_HL25* g_pFileSystem_HL25 = nullptr;
IImGuiExtension* g_pImGuiExtension = nullptr;
int glwidth = 0, glheight = 0;
void IPluginsV4::Init(metahook_api_t* pAPI, mh_interface_t* pInterface, mh_enginesave_t* pSave)
{
g_pInterface = pInterface;
g_pMetaHookAPI = pAPI;
g_pMetaSave = pSave;
g_pFileSystem = pInterface->FileSystem;
if (!g_pFileSystem)
g_pFileSystem_HL25 = pInterface->FileSystem_HL25;
}
void IPluginsV4::Shutdown(void)
{
if (g_pImGuiExtension)
{
g_pImGuiExtension->UnregisterCallbacks(GetRadialMenuCallbacks());
}
}
void IPluginsV4::LoadEngine(cl_enginefunc_t* pEngfuncs)
{
g_pMetaHookAPI->GetVideoMode(&glwidth, &glheight, nullptr, nullptr);
memcpy(&gEngfuncs, pEngfuncs, sizeof(gEngfuncs));
}
void IPluginsV4::LoadClient(cl_exportfuncs_t* pExportFunc)
{
memcpy(&gExportfuncs, pExportFunc, sizeof(gExportfuncs));
pExportFunc->HUD_Init = HUD_Init;
// Resolve the shared ImGui Extension DLL and register callbacks
HINTERFACEMODULE hImGuiExt = g_pMetaHookAPI->GetPluginModuleHandleByBaseFileName("IMGUIExtension");
if (hImGuiExt)
{
auto factory = Sys_GetFactory(hImGuiExt);
if (factory)
{
g_pImGuiExtension = (IImGuiExtension*)factory(IMGUI_EXTENSION_INTERFACE_VERSION, nullptr);
}
}
if (g_pImGuiExtension)
{
g_pImGuiExtension->RegisterCallbacks(GetRadialMenuCallbacks());
}
}
void IPluginsV4::ExitGame(int iResult)
{
if (g_pImGuiExtension)
{
g_pImGuiExtension->UnregisterCallbacks(GetRadialMenuCallbacks());
}
}
const char* IPluginsV4::GetVersion(void)
{
return "0.3.2-dev";
}
EXPOSE_SINGLE_INTERFACE(IPluginsV4, IPluginsV4, METAHOOK_PLUGIN_API_VERSION_V4);