Counter Strike : Global Offensive Source Code
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.

159 lines
5.2 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef ITOOLSYSTEM_H
  7. #define ITOOLSYSTEM_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "itoolentity.h"
  12. #include "interface.h"
  13. #include "materialsystem/imaterialproxy.h"
  14. #include "inputsystem/iinputsystem.h"
  15. class KeyValues;
  16. struct SpatializationInfo_t;
  17. struct AudioState_t;
  18. namespace vgui
  19. {
  20. typedef uintp VPANEL;
  21. }
  22. class CServerDemo;
  23. //-----------------------------------------------------------------------------
  24. // Purpose: All tools expose this interface, which includes both client and server
  25. // related hooks
  26. //-----------------------------------------------------------------------------
  27. class IToolSystem
  28. {
  29. public:
  30. // Name describing the tool
  31. virtual char const *GetToolName() = 0;
  32. // Called at the end of engine startup (after client .dll and server .dll have been loaded)
  33. virtual bool Init() = 0;
  34. // Called during RemoveTool or when engine is shutting down
  35. virtual void Shutdown() = 0;
  36. // Called after server.dll is loaded
  37. virtual bool ServerInit( CreateInterfaceFn serverFactory ) = 0;
  38. // Called after client.dll is loaded
  39. virtual bool ClientInit( CreateInterfaceFn clientFactory ) = 0;
  40. virtual void ServerShutdown() = 0;
  41. virtual void ClientShutdown() = 0;
  42. // Allow tool to override quitting, called before Shutdown(), return no to abort quitting
  43. virtual bool CanQuit( const char *pExitMsg ) = 0;
  44. // Called when another system wiches to post a message to the tool and/or a specific entity
  45. // FIXME: Are KeyValues too inefficient here?
  46. virtual void PostToolMessage( HTOOLHANDLE hEntity, KeyValues *message ) = 0;
  47. // Called oncer per frame even when no level is loaded... (call ProcessMessages())
  48. virtual void Think( bool finalTick ) = 0;
  49. // Server calls:
  50. // Level init, shutdown
  51. virtual void ServerLevelInitPreEntity() = 0;
  52. // entities are created / spawned / precached here
  53. virtual void ServerLevelInitPostEntity() = 0;
  54. virtual void ServerLevelShutdownPreEntity() = 0;
  55. // Entities are deleted / released here...
  56. virtual void ServerLevelShutdownPostEntity() = 0;
  57. // end of level shutdown
  58. // Called each frame before entities think
  59. virtual void ServerFrameUpdatePreEntityThink() = 0;
  60. // called after entities think
  61. virtual void ServerFrameUpdatePostEntityThink() = 0;
  62. virtual void ServerPreClientUpdate() = 0;
  63. virtual void ServerPreSetupVisibility() = 0;
  64. // Used to allow the tool to spawn different entities when it's active
  65. virtual const char* GetEntityData( const char *pActualEntityData ) = 0;
  66. virtual void* QueryInterface( const char *pInterfaceName ) = 0;
  67. // Client calls:
  68. // Level init, shutdown
  69. virtual void ClientLevelInitPreEntity() = 0;
  70. // entities are created / spawned / precached here
  71. virtual void ClientLevelInitPostEntity() = 0;
  72. virtual void ClientLevelShutdownPreEntity() = 0;
  73. // Entities are deleted / released here...
  74. virtual void ClientLevelShutdownPostEntity() = 0;
  75. // end of level shutdown
  76. // Called before rendering
  77. virtual void ClientPreRender() = 0;
  78. virtual void ClientPostRender() = 0;
  79. // Let tool override viewport for engine
  80. virtual void AdjustEngineViewport( int& x, int& y, int& width, int& height ) = 0;
  81. // let tool override view/camera
  82. virtual bool SetupEngineView( Vector &origin, QAngle &angles, float &fov ) = 0;
  83. // let tool override microphone
  84. virtual bool SetupAudioState( AudioState_t &audioState ) = 0;
  85. // Should the client be allowed to render the view normally?
  86. virtual bool ShouldGameRenderView() = 0;
  87. virtual bool IsThirdPersonCamera() = 0;
  88. // Should sounds from the game be played?
  89. virtual bool ShouldGamePlaySounds() = 0;
  90. // is the current tool recording?
  91. virtual bool IsToolRecording() = 0;
  92. virtual IMaterialProxy *LookupProxy( const char *proxyName ) = 0;
  93. // Possible hooks for rendering
  94. // virtual void Think( float curtime, float frametime ) = 0;
  95. // virtual void Prerender() = 0;
  96. // virtual void Render3D() = 0;
  97. // virtual void Render2D() = 0;
  98. // Tool activation/deactivation
  99. // This tool is being activated
  100. virtual void OnToolActivate() = 0;
  101. // Another tool is being activated
  102. virtual void OnToolDeactivate() = 0;
  103. virtual bool TrapKey( ButtonCode_t key, bool down ) = 0;
  104. virtual bool GetSoundSpatialization( int iUserData, int guid, SpatializationInfo_t& info ) = 0;
  105. // Unlike the client .dll pre/post render stuff, these get called no matter whether a map is loaded and they only get called once per frame!!!
  106. virtual void RenderFrameBegin() = 0;
  107. virtual void RenderFrameEnd() = 0;
  108. // wraps the entire frame - surrounding all other begin/end and pre/post calls
  109. virtual void HostRunFrameBegin() = 0;
  110. virtual void HostRunFrameEnd() = 0;
  111. // See enginevgui.h for paintmode_t enum definitions
  112. virtual void VGui_PreRender( int paintMode ) = 0;
  113. virtual void VGui_PostRender( int paintMode ) = 0;
  114. virtual void VGui_PreSimulate() = 0;
  115. virtual void VGui_PostSimulate() = 0;
  116. virtual vgui::VPANEL GetClientWorkspaceArea() = 0;
  117. };
  118. // Pointer to a member method of IGameSystem
  119. typedef void (IToolSystem::*ToolSystemFunc_t)();
  120. typedef void (IToolSystem::*ToolSystemFunc_Int_t)( int arg );
  121. #endif // ITOOLSYSTEM_H