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.

265 lines
6.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef ITOOLFRAMEWORK_H
  7. #define ITOOLFRAMEWORK_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "appframework/IAppSystem.h"
  12. #include "materialsystem/imaterialproxy.h"
  13. #include "toolframework/itoolentity.h"
  14. #include "mathlib/vector.h"
  15. #include "Color.h"
  16. #include "toolframework/itoolentity.h" // HTOOLHANDLE defn
  17. //-----------------------------------------------------------------------------
  18. // Forward declarations
  19. //-----------------------------------------------------------------------------
  20. class IToolSystem;
  21. struct SpatializationInfo_t;
  22. class KeyValues;
  23. class CBoneList;
  24. //-----------------------------------------------------------------------------
  25. // Standard messages
  26. //-----------------------------------------------------------------------------
  27. struct BaseEntityRecordingState_t
  28. {
  29. BaseEntityRecordingState_t() :
  30. m_flTime( 0.0f ),
  31. m_pModelName( 0 ),
  32. m_nOwner( -1 ),
  33. m_nEffects( 0 ),
  34. m_bVisible( false ),
  35. m_bRecordFinalVisibleSample( false )
  36. {
  37. m_vecRenderOrigin.Init();
  38. m_vecRenderAngles.Init();
  39. }
  40. float m_flTime;
  41. const char *m_pModelName;
  42. int m_nOwner;
  43. int m_nEffects;
  44. bool m_bVisible : 1;
  45. bool m_bRecordFinalVisibleSample : 1;
  46. Vector m_vecRenderOrigin;
  47. QAngle m_vecRenderAngles;
  48. };
  49. struct SpriteRecordingState_t
  50. {
  51. float m_flRenderScale;
  52. float m_flFrame;
  53. int m_nRenderMode;
  54. bool m_nRenderFX;
  55. Color m_Color;
  56. float m_flProxyRadius;
  57. };
  58. struct BaseAnimatingRecordingState_t
  59. {
  60. int m_nSkin;
  61. int m_nBody;
  62. int m_nSequence;
  63. CBoneList *m_pBoneList;
  64. };
  65. struct BaseFlexRecordingState_t
  66. {
  67. int m_nFlexCount;
  68. float *m_pDestWeight;
  69. Vector m_vecViewTarget;
  70. };
  71. struct CameraRecordingState_t
  72. {
  73. bool m_bThirdPerson;
  74. float m_flFOV;
  75. Vector m_vecEyePosition;
  76. QAngle m_vecEyeAngles;
  77. };
  78. struct MonitorRecordingState_t
  79. {
  80. bool m_bActive;
  81. float m_flFOV;
  82. bool m_bFogEnabled;
  83. float m_flFogStart;
  84. float m_flFogEnd;
  85. Color m_FogColor;
  86. };
  87. struct EntityTeleportedRecordingState_t
  88. {
  89. Vector m_vecTo;
  90. QAngle m_qaTo;
  91. bool m_bTeleported;
  92. bool m_bViewOverride;
  93. matrix3x4_t m_teleportMatrix;
  94. };
  95. struct PortalRecordingState_t
  96. {
  97. int m_nPortalId;
  98. int m_nLinkedPortalId;
  99. float m_fStaticAmount;
  100. float m_fSecondaryStaticAmount;
  101. float m_fOpenAmount;
  102. bool m_bIsPortal2; //for any set of portals, one must be portal 1, and the other portal 2. Uses different render targets
  103. };
  104. struct ParticleSystemCreatedState_t
  105. {
  106. int m_nParticleSystemId;
  107. const char * m_pName;
  108. float m_flTime;
  109. int m_nOwner;
  110. };
  111. struct ParticleSystemDestroyedState_t
  112. {
  113. int m_nParticleSystemId;
  114. float m_flTime;
  115. };
  116. struct ParticleSystemStopEmissionState_t
  117. {
  118. int m_nParticleSystemId;
  119. float m_flTime;
  120. bool m_bInfiniteOnly;
  121. };
  122. struct ParticleSystemSetControlPointObjectState_t
  123. {
  124. int m_nParticleSystemId;
  125. float m_flTime;
  126. int m_nControlPoint;
  127. int m_nObject;
  128. };
  129. struct ParticleSystemSetControlPointPositionState_t
  130. {
  131. int m_nParticleSystemId;
  132. float m_flTime;
  133. int m_nControlPoint;
  134. Vector m_vecPosition;
  135. };
  136. struct ParticleSystemSetControlPointOrientationState_t
  137. {
  138. int m_nParticleSystemId;
  139. float m_flTime;
  140. int m_nControlPoint;
  141. Quaternion m_qOrientation;
  142. };
  143. //-----------------------------------------------------------------------------
  144. // Purpose: This interface lives in the engine and handles loading up/unloading all
  145. // available tools
  146. //-----------------------------------------------------------------------------
  147. class IToolFrameworkInternal : public IAppSystem
  148. {
  149. public: // Client Hooks
  150. virtual bool ClientInit( CreateInterfaceFn clientFactory ) = 0;
  151. virtual void ClientShutdown() = 0;
  152. // Level init, shutdown
  153. virtual void ClientLevelInitPreEntityAllTools() = 0;
  154. // entities are created / spawned / precached here
  155. virtual void ClientLevelInitPostEntityAllTools() = 0;
  156. virtual void ClientLevelShutdownPreEntityAllTools() = 0;
  157. // Entities are deleted / released here...
  158. virtual void ClientLevelShutdownPostEntityAllTools() = 0;
  159. virtual void ClientPreRenderAllTools() = 0;
  160. virtual void ClientPostRenderAllTools() = 0;
  161. // Should we render with a thirdperson camera?
  162. virtual bool IsThirdPersonCamera() = 0;
  163. // is the current tool recording?
  164. virtual bool IsToolRecording() = 0;
  165. public: // Server Hooks
  166. // Level init, shutdown
  167. virtual bool ServerInit( CreateInterfaceFn serverFactory ) = 0;
  168. virtual void ServerShutdown() = 0;
  169. virtual void ServerLevelInitPreEntityAllTools() = 0;
  170. // entities are created / spawned / precached here
  171. virtual void ServerLevelInitPostEntityAllTools() = 0;
  172. virtual void ServerLevelShutdownPreEntityAllTools() = 0;
  173. // Entities are deleted / released here...
  174. virtual void ServerLevelShutdownPostEntityAllTools() = 0;
  175. // end of level shutdown
  176. // Called each frame before entities think
  177. virtual void ServerFrameUpdatePreEntityThinkAllTools() = 0;
  178. // called after entities think
  179. virtual void ServerFrameUpdatePostEntityThinkAllTools() = 0;
  180. virtual void ServerPreClientUpdateAllTools() = 0;
  181. virtual void ServerPreSetupVisibilityAllTools() = 0;
  182. public: // Other Hooks
  183. // If any tool returns false, the engine will not actually quit
  184. // FIXME: Not implemented yet
  185. virtual bool CanQuit() = 0;
  186. // Called at end of Host_Init
  187. virtual bool PostInit() = 0;
  188. virtual void Think( bool finalTick ) = 0;
  189. virtual void PostMessage( KeyValues *msg ) = 0;
  190. virtual bool GetSoundSpatialization( int iUserData, int guid, SpatializationInfo_t& info ) = 0;
  191. virtual void HostRunFrameBegin() = 0;
  192. virtual void HostRunFrameEnd() = 0;
  193. virtual void RenderFrameBegin() = 0;
  194. virtual void RenderFrameEnd() = 0;
  195. // Paintmode is an enum declared in enginevgui.h
  196. virtual void VGui_PreRenderAllTools( int paintMode ) = 0;
  197. virtual void VGui_PostRenderAllTools( int paintMode ) = 0;
  198. virtual void VGui_PreSimulateAllTools() = 0;
  199. virtual void VGui_PostSimulateAllTools() = 0;
  200. // Are we using tools?
  201. virtual bool InToolMode() = 0;
  202. // Should the game be allowed to render the world?
  203. virtual bool ShouldGameRenderView() = 0;
  204. virtual IMaterialProxy *LookupProxy( const char *proxyName ) = 0;
  205. public: // general framework hooks
  206. virtual int GetToolCount() = 0;
  207. virtual char const *GetToolName( int index ) = 0;
  208. virtual void SwitchToTool( int index ) = 0;
  209. virtual IToolSystem *SwitchToTool( const char *pToolName ) = 0;
  210. virtual bool IsTopmostTool( const IToolSystem *sys ) = 0;
  211. virtual const IToolSystem *GetToolSystem( int index ) const = 0;
  212. virtual IToolSystem *GetTopmostTool() = 0;
  213. };
  214. // Expose to rest of engine as a singleton
  215. extern IToolFrameworkInternal *toolframework;
  216. // Exposed to launcher to automatically add AppSystemGroup hooks
  217. #define VTOOLFRAMEWORK_INTERFACE_VERSION "VTOOLFRAMEWORKVERSION002"
  218. #endif // ITOOLFRAMEWORK_H