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.

325 lines
8.3 KiB

  1. //====== Copyright � 1996-2005, 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. //-----------------------------------------------------------------------------
  17. // Forward declarations
  18. //-----------------------------------------------------------------------------
  19. class IToolSystem;
  20. struct SpatializationInfo_t;
  21. class KeyValues;
  22. class CBoneList;
  23. //-----------------------------------------------------------------------------
  24. // Standard messages
  25. //-----------------------------------------------------------------------------
  26. struct EffectRecordingState_t
  27. {
  28. bool m_bVisible : 1;
  29. bool m_bThirdPerson : 1;
  30. Color m_Color;
  31. float m_Scale;
  32. const char *m_pMaterialName;
  33. int m_nAttachment;
  34. Vector m_vecAttachment; // only used if m_nAttachment is -1
  35. };
  36. struct BaseEntityRecordingState_t
  37. {
  38. BaseEntityRecordingState_t() :
  39. m_flTime( 0.0f ),
  40. m_pModelName( 0 ),
  41. m_nOwner( -1 ),
  42. m_fEffects( 0 ),
  43. m_bVisible( false ),
  44. m_bRecordFinalVisibleSample( false ),
  45. m_numEffects( 0 ),
  46. m_pEffects( NULL ),
  47. m_nFollowEntity( -1 )
  48. {
  49. m_vecRenderOrigin.Init();
  50. m_vecRenderAngles.Init();
  51. }
  52. float m_flTime;
  53. const char *m_pModelName;
  54. int m_nOwner;
  55. int m_fEffects;
  56. bool m_bVisible : 1;
  57. bool m_bRecordFinalVisibleSample : 1;
  58. Vector m_vecRenderOrigin;
  59. QAngle m_vecRenderAngles;
  60. int m_nFollowEntity;
  61. int m_numEffects;
  62. EffectRecordingState_t *m_pEffects;
  63. };
  64. struct SpriteRecordingState_t
  65. {
  66. float m_flRenderScale;
  67. float m_flFrame;
  68. int m_nRenderMode;
  69. bool m_nRenderFX;
  70. Color m_Color;
  71. float m_flProxyRadius;
  72. };
  73. struct BaseAnimatingHighLevelRecordingState_t
  74. {
  75. BaseAnimatingHighLevelRecordingState_t()
  76. : m_bClearIkTargets( false ),
  77. m_bIsRagdoll( false ),
  78. m_bShouldCreateIkContext( false ),
  79. m_nNumPoseParams( 0 ),
  80. m_flCycle( 0.0f ),
  81. m_flPlaybackRate( 1.0f ),
  82. m_flCycleRate( 0.0f ),
  83. m_nFrameCount( 0 ),
  84. m_bInterpEffectActive( false )
  85. {
  86. }
  87. bool m_bClearIkTargets;
  88. bool m_bIsRagdoll;
  89. bool m_bShouldCreateIkContext;
  90. int m_nNumPoseParams;
  91. float m_flCycle;
  92. float m_flPlaybackRate;
  93. float m_flCycleRate;
  94. int m_nFrameCount;
  95. float m_flPoseParameter[MAXSTUDIOPOSEPARAM];
  96. bool m_bInterpEffectActive;
  97. };
  98. struct BaseAnimatingRecordingState_t
  99. {
  100. BaseAnimatingHighLevelRecordingState_t m_highLevelState;
  101. int m_nSkin;
  102. int m_nBody;
  103. int m_nSequence;
  104. CBoneList *m_pBoneList;
  105. };
  106. struct BaseFlexRecordingState_t
  107. {
  108. int m_nFlexCount;
  109. float *m_pDestWeight;
  110. Vector m_vecViewTarget;
  111. };
  112. struct CameraRecordingState_t
  113. {
  114. bool m_bThirdPerson;
  115. float m_flFOV;
  116. Vector m_vecEyePosition;
  117. QAngle m_vecEyeAngles;
  118. bool m_bPlayerEyeIsPortalled; //for portal. Need to reverse some portal recursion draw logic when the player eye and body straddle a portal
  119. };
  120. struct MonitorRecordingState_t
  121. {
  122. bool m_bActive;
  123. float m_flFOV;
  124. bool m_bFogEnabled;
  125. float m_flFogStart;
  126. float m_flFogEnd;
  127. Color m_FogColor;
  128. };
  129. struct EntityTeleportedRecordingState_t
  130. {
  131. Vector m_vecTo;
  132. QAngle m_qaTo;
  133. bool m_bTeleported;
  134. bool m_bViewOverride;
  135. matrix3x4_t m_teleportMatrix;
  136. };
  137. struct PortalRecordingState_t
  138. {
  139. int m_nPortalId;
  140. int m_nLinkedPortalId;
  141. float m_fStaticAmount;
  142. float m_fSecondaryStaticAmount;
  143. float m_fOpenAmount;
  144. float m_fHalfWidth;
  145. float m_fHalfHeight;
  146. const char * m_portalType;
  147. bool m_bIsPortal2; //for any set of portals, one must be portal 1, and the other portal 2. Uses different render targets
  148. };
  149. struct ParticleSystemCreatedState_t
  150. {
  151. int m_nParticleSystemId;
  152. const char * m_pName;
  153. float m_flTime;
  154. int m_nOwner;
  155. };
  156. struct ParticleSystemDestroyedState_t
  157. {
  158. int m_nParticleSystemId;
  159. float m_flTime;
  160. };
  161. struct ParticleSystemStopEmissionState_t
  162. {
  163. int m_nParticleSystemId;
  164. float m_flTime;
  165. bool m_bInfiniteOnly;
  166. };
  167. struct ParticleSystemSetControlPointObjectState_t
  168. {
  169. int m_nParticleSystemId;
  170. float m_flTime;
  171. int m_nControlPoint;
  172. int m_nObject;
  173. };
  174. struct ParticleSystemSetControlPointPositionState_t
  175. {
  176. int m_nParticleSystemId;
  177. float m_flTime;
  178. int m_nControlPoint;
  179. Vector m_vecPosition;
  180. };
  181. struct ParticleSystemSetControlPointOrientationState_t
  182. {
  183. int m_nParticleSystemId;
  184. float m_flTime;
  185. int m_nControlPoint;
  186. Quaternion m_qOrientation;
  187. };
  188. //-----------------------------------------------------------------------------
  189. // Purpose: This interface lives in the engine and handles loading up/unloading all
  190. // available tools
  191. //-----------------------------------------------------------------------------
  192. class IToolFrameworkInternal : public IAppSystem
  193. {
  194. public: // Client Hooks
  195. virtual bool ClientInit( CreateInterfaceFn clientFactory ) = 0;
  196. virtual void ClientShutdown() = 0;
  197. // Level init, shutdown
  198. virtual void ClientLevelInitPreEntityAllTools() = 0;
  199. // entities are created / spawned / precached here
  200. virtual void ClientLevelInitPostEntityAllTools() = 0;
  201. virtual void ClientLevelShutdownPreEntityAllTools() = 0;
  202. // Entities are deleted / released here...
  203. virtual void ClientLevelShutdownPostEntityAllTools() = 0;
  204. virtual void ClientPreRenderAllTools() = 0;
  205. virtual void ClientPostRenderAllTools() = 0;
  206. // Should we render with a thirdperson camera?
  207. virtual bool IsThirdPersonCamera() = 0;
  208. // is the current tool recording?
  209. virtual bool IsToolRecording() = 0;
  210. public: // Server Hooks
  211. // Level init, shutdown
  212. virtual bool ServerInit( CreateInterfaceFn serverFactory ) = 0;
  213. virtual void ServerShutdown() = 0;
  214. virtual void ServerLevelInitPreEntityAllTools() = 0;
  215. // entities are created / spawned / precached here
  216. virtual void ServerLevelInitPostEntityAllTools() = 0;
  217. virtual void ServerLevelShutdownPreEntityAllTools() = 0;
  218. // Entities are deleted / released here...
  219. virtual void ServerLevelShutdownPostEntityAllTools() = 0;
  220. // end of level shutdown
  221. // Called each frame before entities think
  222. virtual void ServerFrameUpdatePreEntityThinkAllTools() = 0;
  223. // called after entities think
  224. virtual void ServerFrameUpdatePostEntityThinkAllTools() = 0;
  225. virtual void ServerPreClientUpdateAllTools() = 0;
  226. virtual void ServerPreSetupVisibilityAllTools() = 0;
  227. public: // Other Hooks
  228. // If any tool returns false, the engine will not actually quit
  229. // FIXME: Not implemented yet
  230. virtual bool CanQuit() = 0;
  231. // Called at end of Host_Init
  232. virtual bool PostInit() = 0;
  233. virtual void Think( bool finalTick ) = 0;
  234. virtual void PostMessage( KeyValues *msg ) = 0;
  235. virtual bool GetSoundSpatialization( int iUserData, int guid, SpatializationInfo_t& info ) = 0;
  236. virtual void HostRunFrameBegin() = 0;
  237. virtual void HostRunFrameEnd() = 0;
  238. virtual void RenderFrameBegin() = 0;
  239. virtual void RenderFrameEnd() = 0;
  240. // Paintmode is an enum declared in enginevgui.h
  241. virtual void VGui_PreRenderAllTools( int paintMode ) = 0;
  242. virtual void VGui_PostRenderAllTools( int paintMode ) = 0;
  243. virtual void VGui_PreSimulateAllTools() = 0;
  244. virtual void VGui_PostSimulateAllTools() = 0;
  245. // Are we using tools?
  246. virtual bool InToolMode() = 0;
  247. // Should the game be allowed to render the world?
  248. virtual bool ShouldGameRenderView() = 0;
  249. // Should sounds from the game be played?
  250. virtual bool ShouldGamePlaySounds() = 0;
  251. virtual IMaterialProxy *LookupProxy( const char *proxyName ) = 0;
  252. public: // general framework hooks
  253. virtual bool LoadFilmmaker() = 0;
  254. virtual void UnloadFilmmaker() = 0;
  255. virtual int GetToolCount() = 0;
  256. virtual char const *GetToolName( int index ) = 0;
  257. virtual void SwitchToTool( int index ) = 0;
  258. virtual IToolSystem *SwitchToTool( const char *pToolName ) = 0;
  259. virtual bool IsTopmostTool( const IToolSystem *sys ) = 0;
  260. virtual const IToolSystem *GetToolSystem( int index ) const = 0;
  261. virtual IToolSystem *GetTopmostTool() = 0;
  262. // If module not already loaded, loads it and optionally switches to first tool in module. Returns false if load failed or tool already loaded
  263. virtual bool LoadToolModule( char const *pToolModule, bool bSwitchToFirst ) = 0;
  264. };
  265. // Expose to rest of engine as a singleton
  266. extern IToolFrameworkInternal *toolframework;
  267. // Exposed to launcher to automatically add AppSystemGroup hooks
  268. #define VTOOLFRAMEWORK_INTERFACE_VERSION "VTOOLFRAMEWORKVERSION002"
  269. #endif // ITOOLFRAMEWORK_H