hlsdk

hlsdk

Jan 22nd, 2010
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.80 KB | None | 0 0
  1. #include <tier3/tier3.h>
  2.  
  3. #define _____assert_ptr( something, name ) if (!something) Msg("[MS] Failed to assert %s\n", name)
  4. void GetGlobalInterfacePointers( CreateInterfaceFn VGUIFactory, CreateInterfaceFn VGUI2Factory )
  5. {
  6.     g_pVGuiSurface = (vgui::ISurface*)VGUIFactory(VGUI_SURFACE_INTERFACE_VERSION, NULL);
  7.         _____assert_ptr(g_pVGuiSurface, "g_pVGuiSurface");
  8.  
  9.     g_pVGuiInput = (vgui::IInput*)VGUI2Factory(VGUI_INPUT_INTERFACE_VERSION, NULL);
  10.         _____assert_ptr(g_pVGuiInput, "g_pVGuiInput");
  11.  
  12.     g_pVGui = (vgui::IVGui*)VGUI2Factory(VGUI_IVGUI_INTERFACE_VERSION, NULL);
  13.         _____assert_ptr(g_pVGui, "g_pVGui");
  14.  
  15.     g_pVGuiPanel = (vgui::IPanel*)VGUI2Factory(VGUI_PANEL_INTERFACE_VERSION, NULL);
  16.         _____assert_ptr(g_pVGuiPanel, "g_pVGuiPanel");
  17.  
  18.     g_pVGuiSchemeManager = (vgui::ISchemeManager*)VGUI2Factory(VGUI_SCHEME_INTERFACE_VERSION, NULL);
  19.         _____assert_ptr(g_pVGuiSchemeManager, "g_pVGuiSchemeManager");
  20.  
  21.     g_pVGuiSystem = (vgui::ISystem*)VGUI2Factory(VGUI_SYSTEM_INTERFACE_VERSION, NULL);
  22.         _____assert_ptr(g_pVGuiSystem, "g_pVGuiSystem");
  23.        
  24.     g_pEngineVGui = (IEngineVGui*) g_AppSystemFactory( "VEngineVGui001", NULL );
  25.         _____assert_ptr(g_pEngineVGui, "g_pEngineVGui");
  26. }
  27.  
  28. //  \/ This goes in plugin load or CON_COMMAND hook or whatever. Declare a global instance: CVMTHook g_PAINTTRAVERSEHOOK;
  29. g_PaintTraverseHook.Hook( (DWORD) &Hooked_PaintTraverse, (PDWORD) g_pVGuiPanel, 40 );
  30.  
  31. Then:
  32.  
  33. void __stdcall Hooked_PaintTraverse(VPANEL vguiPanel, bool forceRepaint, bool allowForce = true)
  34. {
  35.     g_PaintTraverseHook.UnHook();
  36.     g_pVGuiPanel->PaintTraverse(vguiPanel, forceRepaint, allowForce);
  37.     g_PaintTraverseHook.ReHook();
  38.  
  39.     //This gets called multiple times / frame
  40.     //You probably want to if(FStrEq(g_pEngineVGui->GetPanel(vguiPanel)->GetName(), "MatSysTopPanel"))
  41.     //if you want to draw like a s3x0r.
  42. }
Advertisement
Add Comment
Please, Sign In to add comment