请选择 进入手机版 | 继续访问电脑版
设为首页收藏本站

ESFKAMI

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz

ESFX

ESF: Xenoverse

ESF123

ESF1.2.3

EVM2.1

EVM2.1

ECXSSJ

ECX: TeamSSJ

ECX2.2

ECX RC2

ECX2.3

ECX RC3

查看: 2468|回复: 0

[VGUI]Get Panel API

[复制链接]

212

主题

217

帖子

1269

积分

ESFKAMI

Rank: 8Rank: 8

积分
1269
发表于 2017-7-13 12:17:05 | 显示全部楼层 |阅读模式
learning VGUI recently, this one could get the panel api, but the functions of panel dont work... i give up..

  1. #include <exportfuncs.h>
  2. #include <triangleapi.h>

  3. #include "surface.h"
  4. #include "IGameUI.h"

  5. cl_enginefunc_t gEngfuncs;
  6. vgui::IPanel *pPanel;

  7. int Initialize(struct cl_enginefuncs_s *pEnginefuncs, int iVersion)
  8. {
  9.         memcpy(&gEngfuncs, pEnginefuncs, sizeof(gEngfuncs));
  10.         return gExportfuncs.Initialize(pEnginefuncs, iVersion);
  11. }

  12. int HUD_VidInit(void)
  13. {
  14.         CreateInterfaceFn fnEngineCreateInterface = g_pMetaHookAPI->GetEngineFactory();
  15.         vgui::ISurface *pSurface = (vgui::ISurface *)fnEngineCreateInterface(VGUI_SURFACE_INTERFACE_VERSION, NULL);
  16.         Surface_Init(pSurface);

  17.        
  18.         HINTERFACEMODULE g_hVGUI2 = (HINTERFACEMODULE)GetModuleHandle("vgui2.dll");

  19.         if (g_hVGUI2)
  20.         {
  21.                 CreateInterfaceFn fnVGUI2CreateInterface = Sys_GetFactory(g_hVGUI2);
  22.                 CreateInterfaceFn fnEngineCreateInterface = g_pMetaHookAPI->GetEngineFactory();

  23.                 pPanel = (vgui::IPanel *)fnVGUI2CreateInterface(VGUI_PANEL_INTERFACE_VERSION, NULL);
  24.                
  25.                 static char msg[512];
  26.                 wsprintf(msg, "%d %dw.", g_hVGUI2, pPanel);
  27.                 MessageBox(NULL, msg, "Fatal Error", MB_ICONERROR);
  28.         }
  29.         return gExportfuncs.HUD_VidInit();
  30. }

  31. void HUD_Init(void)
  32. {
  33.         GameUI_InstallHook();
  34.         return gExportfuncs.HUD_Init();
  35. }

  36. vgui::IEngineVGui *enginevguifuncs;
  37. int HUD_Redraw(float time, int intermission)
  38. {
  39.         /*CreateInterfaceFn factories[2];
  40.         factories[0] = g_pMetaHookAPI->GetEngineFactory();
  41.         enginevguifuncs = (IEngineVGui *)factories[0](VENGINE_VGUI_VERSION, NULL);

  42.         vgui::IPanel *g_pVGuiPanel;
  43.         g_pVGuiPanel = (IPanel *)factoryList[1](VGUI_PANEL_INTERFACE_VERSION, NULL);

  44.         vgui::VPANEL rootpanel = enginevguifuncs->GetPanel(1);
  45.         int count = vgui::ipanel()->GetChildCount(rootpanel);

  46.         for (int i = 0; i < count; i++)
  47.         {
  48.                 vgui::VPANEL p = vgui::ipanel()->GetChild(rootpanel, i);

  49.                 if (!p)
  50.                         continue;

  51.                 vgui::ipanel()->SetParent(p, NULL);
  52.         }*/

  53.         CreateInterfaceFn factories;
  54.         factories = g_pMetaHookAPI->GetEngineFactory();
  55.         enginevguifuncs = (vgui::IEngineVGui *)factories(VENGINE_VGUI_VERSION, NULL);
  56.         vgui::VPANEL rootpanel = enginevguifuncs->GetPanel((vgui::VGUIPANEL)1);

  57.         int count = pPanel->GetChildCount(rootpanel);

  58.         for (int i = 0; i < count; i++)
  59.         {
  60.                 vgui::VPANEL p = pPanel->GetChild(rootpanel, i);

  61.                 if (!p)
  62.                         continue;

  63.                 pPanel->SetParent(p, NULL);
  64.         }
  65.        
  66.         gEngfuncs.Con_Printf("asd %d", count);
  67.         return gExportfuncs.HUD_Redraw(time, intermission);
  68. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|ESFKAMI    

GMT+8, 2018-12-19 02:07 , Processed in 0.233510 second(s), 21 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表