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.

146 lines
4.9 KiB

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