|
|
learning VGUI recently, this one could get the panel api, but the functions of panel dont work... i give up..
- #include <exportfuncs.h>
- #include <triangleapi.h>
- #include "surface.h"
- #include "IGameUI.h"
- cl_enginefunc_t gEngfuncs;
- vgui::IPanel *pPanel;
- int Initialize(struct cl_enginefuncs_s *pEnginefuncs, int iVersion)
- {
- memcpy(&gEngfuncs, pEnginefuncs, sizeof(gEngfuncs));
- return gExportfuncs.Initialize(pEnginefuncs, iVersion);
- }
- int HUD_VidInit(void)
- {
- CreateInterfaceFn fnEngineCreateInterface = g_pMetaHookAPI->GetEngineFactory();
- vgui::ISurface *pSurface = (vgui::ISurface *)fnEngineCreateInterface(VGUI_SURFACE_INTERFACE_VERSION, NULL);
- Surface_Init(pSurface);
-
- HINTERFACEMODULE g_hVGUI2 = (HINTERFACEMODULE)GetModuleHandle("vgui2.dll");
- if (g_hVGUI2)
- {
- CreateInterfaceFn fnVGUI2CreateInterface = Sys_GetFactory(g_hVGUI2);
- CreateInterfaceFn fnEngineCreateInterface = g_pMetaHookAPI->GetEngineFactory();
- pPanel = (vgui::IPanel *)fnVGUI2CreateInterface(VGUI_PANEL_INTERFACE_VERSION, NULL);
-
- static char msg[512];
- wsprintf(msg, "%d %dw.", g_hVGUI2, pPanel);
- MessageBox(NULL, msg, "Fatal Error", MB_ICONERROR);
- }
- return gExportfuncs.HUD_VidInit();
- }
- void HUD_Init(void)
- {
- GameUI_InstallHook();
- return gExportfuncs.HUD_Init();
- }
- vgui::IEngineVGui *enginevguifuncs;
- int HUD_Redraw(float time, int intermission)
- {
- /*CreateInterfaceFn factories[2];
- factories[0] = g_pMetaHookAPI->GetEngineFactory();
- enginevguifuncs = (IEngineVGui *)factories[0](VENGINE_VGUI_VERSION, NULL);
- vgui::IPanel *g_pVGuiPanel;
- g_pVGuiPanel = (IPanel *)factoryList[1](VGUI_PANEL_INTERFACE_VERSION, NULL);
- vgui::VPANEL rootpanel = enginevguifuncs->GetPanel(1);
- int count = vgui::ipanel()->GetChildCount(rootpanel);
- for (int i = 0; i < count; i++)
- {
- vgui::VPANEL p = vgui::ipanel()->GetChild(rootpanel, i);
- if (!p)
- continue;
- vgui::ipanel()->SetParent(p, NULL);
- }*/
- CreateInterfaceFn factories;
- factories = g_pMetaHookAPI->GetEngineFactory();
- enginevguifuncs = (vgui::IEngineVGui *)factories(VENGINE_VGUI_VERSION, NULL);
- vgui::VPANEL rootpanel = enginevguifuncs->GetPanel((vgui::VGUIPANEL)1);
- int count = pPanel->GetChildCount(rootpanel);
- for (int i = 0; i < count; i++)
- {
- vgui::VPANEL p = pPanel->GetChild(rootpanel, i);
- if (!p)
- continue;
- pPanel->SetParent(p, NULL);
- }
-
- gEngfuncs.Con_Printf("asd %d", count);
- return gExportfuncs.HUD_Redraw(time, intermission);
- }
复制代码 |
|