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.

157 lines
4.8 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =====//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #ifndef TOOLFRAMEWORK_CLIENT_H
  7. #define TOOLFRAMEWORK_CLIENT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "toolframework/itoolentity.h"
  12. #include "vstdlib/ikeyvaluessystem.h"
  13. //-----------------------------------------------------------------------------
  14. // Forward declarations
  15. //-----------------------------------------------------------------------------
  16. class KeyValues;
  17. struct AudioState_t;
  18. //-----------------------------------------------------------------------------
  19. // Posts a message to all tools
  20. //-----------------------------------------------------------------------------
  21. void ToolFramework_PostToolMessage( HTOOLHANDLE hEntity, KeyValues *msg );
  22. //-----------------------------------------------------------------------------
  23. // Should we render with a 3rd person camera?
  24. //-----------------------------------------------------------------------------
  25. bool ToolFramework_IsThirdPersonCamera( );
  26. //-----------------------------------------------------------------------------
  27. // Are tools enabled?
  28. //-----------------------------------------------------------------------------
  29. #ifndef NO_TOOLFRAMEWORK
  30. bool ToolsEnabled();
  31. #else
  32. #define ToolsEnabled() 0
  33. #endif
  34. //-----------------------------------------------------------------------------
  35. // Recorded temp entity structures
  36. //-----------------------------------------------------------------------------
  37. enum TERecordingType_t
  38. {
  39. TE_DYNAMIC_LIGHT = 0,
  40. TE_WORLD_DECAL,
  41. TE_DISPATCH_EFFECT,
  42. TE_MUZZLE_FLASH,
  43. TE_ARMOR_RICOCHET,
  44. TE_METAL_SPARKS,
  45. TE_SMOKE,
  46. TE_SPARKS,
  47. TE_BLOOD_SPRITE,
  48. TE_BREAK_MODEL,
  49. TE_GLOW_SPRITE,
  50. TE_PHYSICS_PROP,
  51. TE_SPRITE_SINGLE,
  52. TE_SPRITE_SPRAY,
  53. TE_CONCUSSIVE_EXPLOSION,
  54. TE_BLOOD_STREAM,
  55. TE_SHATTER_SURFACE,
  56. TE_DECAL,
  57. TE_PROJECT_DECAL,
  58. TE_EXPLOSION,
  59. TE_RECORDING_TYPE_COUNT,
  60. };
  61. //-----------------------------------------------------------------------------
  62. // View manipulation
  63. //-----------------------------------------------------------------------------
  64. void ToolFramework_AdjustEngineViewport( int& x, int& y, int& width, int& height );
  65. bool ToolFramework_SetupEngineView( Vector &origin, QAngle &angles, float &fov );
  66. bool ToolFramework_SetupAudioState( AudioState_t &audioState );
  67. //-----------------------------------------------------------------------------
  68. // Helper class to indicate ownership of effects
  69. //-----------------------------------------------------------------------------
  70. class CRecordEffectOwner
  71. {
  72. public:
  73. CRecordEffectOwner( C_BaseEntity *pEntity, bool bIsViewModel = false );
  74. ~CRecordEffectOwner();
  75. private:
  76. bool m_bToolsEnabled;
  77. };
  78. //only ever create global/static instances of this to auto-register your entity keyvalues data handler
  79. class CIFM_EntityKeyValuesHandler_AutoRegister
  80. {
  81. public:
  82. explicit CIFM_EntityKeyValuesHandler_AutoRegister( const char *szHandlerID );
  83. virtual void HandleData_PreUpdate( void ) {}; //called once before any received data is distributed to its handlers
  84. virtual void HandleData( KeyValues *pKeyValues ) = 0;
  85. virtual void HandleData_PostUpdate( void ) {}; //called once after all received data is distributed to its handlers
  86. static void AllHandlers_PreUpdate( void );
  87. static void FindAndCallHandler( const char *szHandlerID, KeyValues *pKeyValues );
  88. static void AllHandlers_PostUpdate( void );
  89. virtual void HandleData_RemoveAll( void ) {};
  90. static void AllHandlers_RemoveAll( void );
  91. static HKeySymbol GetGameKeyValuesKeySymbol( void );
  92. static const char *GetGameKeyValuesKeyString( void );
  93. static HKeySymbol GetHandlerIDKeySymbol( void );
  94. static const char *GetHandlerIDKeyString( void );
  95. static KeyValues *FindOrCreateNonConformantKeyValues( KeyValues *pParentKV );
  96. private:
  97. const char *m_szHandlerID;
  98. CIFM_EntityKeyValuesHandler_AutoRegister *m_pNext;
  99. static CIFM_EntityKeyValuesHandler_AutoRegister *s_pRegisteredHandlers;
  100. };
  101. //assuming you've stored "entIndex" into your recorded values, this will create/destroy a unique instance per unique index
  102. class CIFM_EntityKeyValuesHandler_RecreateEntities : CIFM_EntityKeyValuesHandler_AutoRegister
  103. {
  104. public:
  105. explicit CIFM_EntityKeyValuesHandler_RecreateEntities( const char *szHandlerID );
  106. virtual void HandleData_PreUpdate( void );
  107. virtual void HandleData( KeyValues *pKeyValues );
  108. virtual void HandleData_PostUpdate( void );
  109. virtual void HandleData_RemoveAll( void );
  110. virtual void *CreateInstance( void ) = 0; //make a new instance of your entity
  111. virtual void DestroyInstance( void *pEntity ) = 0;
  112. virtual void HandleInstance( void *pEntity, KeyValues *pKeyValues ) = 0; //update your entity.
  113. private:
  114. struct RecordedEntity_t
  115. {
  116. void *pEntity;
  117. int iEntIndex;
  118. bool bTouched;
  119. };
  120. CUtlVector<RecordedEntity_t> m_PlaybackEntities;
  121. };
  122. #endif // TOOLFRAMEWORK_CLIENT_H