Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef IVGUI_H
  8. #define IVGUI_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier1/interface.h"
  13. #include <vgui/VGUI.h>
  14. #include "appframework/IAppSystem.h"
  15. class KeyValues;
  16. namespace vgui
  17. {
  18. // safe handle to a panel - can be converted to and from a VPANEL
  19. typedef unsigned long HPanel;
  20. typedef int HContext;
  21. enum
  22. {
  23. DEFAULT_VGUI_CONTEXT = ((vgui::HContext)~0)
  24. };
  25. // safe handle to a panel - can be converted to and from a VPANEL
  26. typedef unsigned long HPanel;
  27. //-----------------------------------------------------------------------------
  28. // Purpose: Interface to core vgui components
  29. //-----------------------------------------------------------------------------
  30. class IVGui : public IAppSystem
  31. {
  32. public:
  33. // activates vgui message pump
  34. virtual void Start() = 0;
  35. // signals vgui to Stop running
  36. virtual void Stop() = 0;
  37. // returns true if vgui is current active
  38. virtual bool IsRunning() = 0;
  39. // runs a single frame of vgui
  40. virtual void RunFrame() = 0;
  41. // broadcasts "ShutdownRequest" "id" message to all top-level panels in the app
  42. virtual void ShutdownMessage(unsigned int shutdownID) = 0;
  43. // panel allocation
  44. virtual VPANEL AllocPanel() = 0;
  45. virtual void FreePanel(VPANEL panel) = 0;
  46. // debugging prints
  47. virtual void DPrintf(PRINTF_FORMAT_STRING const char *format, ...) = 0;
  48. virtual void DPrintf2(PRINTF_FORMAT_STRING const char *format, ...) = 0;
  49. virtual void SpewAllActivePanelNames() = 0;
  50. // safe-pointer handle methods
  51. virtual HPanel PanelToHandle(VPANEL panel) = 0;
  52. virtual VPANEL HandleToPanel(HPanel index) = 0;
  53. virtual void MarkPanelForDeletion(VPANEL panel) = 0;
  54. // makes panel receive a 'Tick' message every frame (~50ms, depending on sleep times/framerate)
  55. // panel is automatically removed from tick signal list when it's deleted
  56. virtual void AddTickSignal(VPANEL panel, int intervalMilliseconds = 0 ) = 0;
  57. virtual void RemoveTickSignal(VPANEL panel) = 0;
  58. // message sending
  59. virtual void PostMessage(VPANEL target, KeyValues *params, VPANEL from, float delaySeconds = 0.0f) = 0;
  60. // Creates/ destroys vgui contexts, which contains information
  61. // about which controls have mouse + key focus, for example.
  62. virtual HContext CreateContext() = 0;
  63. virtual void DestroyContext( HContext context ) = 0;
  64. // Associates a particular panel with a vgui context
  65. // Associating NULL is valid; it disconnects the panel from the context
  66. virtual void AssociatePanelWithContext( HContext context, VPANEL pRoot ) = 0;
  67. // Activates a particular context, use DEFAULT_VGUI_CONTEXT
  68. // to get the one normally used by VGUI
  69. virtual void ActivateContext( HContext context ) = 0;
  70. // whether to sleep each frame or not, true = sleep
  71. virtual void SetSleep( bool state) = 0;
  72. // data accessor for above
  73. virtual bool GetShouldVGuiControlSleep() = 0;
  74. // enables VR mode
  75. virtual void SetVRMode( bool bVRMode ) = 0;
  76. virtual bool GetVRMode() = 0;
  77. // add a tick signal like above, but to the head of the list of tick signals
  78. virtual void AddTickSignalToHead( VPANEL panel, int intervalMilliseconds = 0 ) = 0;
  79. };
  80. #define VGUI_IVGUI_INTERFACE_VERSION "VGUI_ivgui008"
  81. };
  82. #endif // IVGUI_H