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.

246 lines
9.6 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef IENGINETOOL_H
  7. #define IENGINETOOL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "interface.h"
  12. #include "soundflags.h"
  13. #include "avi/iavi.h"
  14. #include "ispatialpartition.h"
  15. class CViewSetup;
  16. class IToolSystem;
  17. class KeyValues;
  18. class ITraceFilter;
  19. class CBaseTrace;
  20. struct dlight_t;
  21. struct Ray_t;
  22. struct AudioState_t;
  23. typedef bool (*FnQuitHandler)( void *pvUserData );
  24. #ifndef MAX_DLIGHTS
  25. #define MAX_DLIGHTS 32
  26. #endif
  27. // Exposed from engine to all tools, simplest interface
  28. class IEngineToolFramework : public IBaseInterface
  29. {
  30. public:
  31. // Input system overrides TBD
  32. // Something like this
  33. //virtual void AddMessageHandler( int wm_message, bool (*pfnCallback)( int wm_message, int wParam, int lParam ) ) = 0;
  34. //virtual void RemoveMessageHanlder( int wm_message, bool (*pfnCallbackToRemove)( int wm_message, int wParam, int lParam ) ) = 0;
  35. // Helpers for implementing a tool switching UI
  36. virtual int GetToolCount() const = 0;
  37. virtual char const *GetToolName( int index ) const = 0;
  38. virtual void SwitchToTool( int index ) = 0;
  39. virtual bool IsTopmostTool( const IToolSystem *sys ) const = 0;
  40. virtual const IToolSystem *GetToolSystem( int index ) const = 0;
  41. virtual IToolSystem *GetTopmostTool() = 0;
  42. // Take over input
  43. virtual void ShowCursor( bool show ) = 0;
  44. virtual bool IsCursorVisible() const = 0;
  45. // If module not already loaded, loads it and optionally switches to first tool in module. Returns false if load failed or tool already loaded
  46. virtual bool LoadToolModule( char const *pToolModule, bool bSwitchToFirst ) = 0;
  47. };
  48. #define VENGINETOOLFRAMEWORK_INTERFACE_VERSION "VENGINETOOLFRAMEWORK003"
  49. struct model_t;
  50. struct studiohdr_t;
  51. #include "toolframework/itoolentity.h"
  52. // Exposed from engine to tools via, more involved version of above
  53. class IEngineTool : public IEngineToolFramework
  54. {
  55. public:
  56. virtual void GetServerFactory( CreateInterfaceFn& factory ) = 0;
  57. virtual void GetClientFactory( CreateInterfaceFn& factory ) = 0;
  58. virtual float GetSoundDuration( const char *pszName ) = 0;
  59. virtual bool IsSoundStillPlaying( int guid ) = 0;
  60. // Returns the guid of the sound
  61. virtual int StartSound(
  62. int iUserData,
  63. bool staticsound,
  64. int iEntIndex,
  65. int iChannel,
  66. const char *pSample,
  67. float flVolume,
  68. soundlevel_t iSoundlevel,
  69. const Vector& origin,
  70. const Vector& direction,
  71. int iFlags = 0,
  72. int iPitch = PITCH_NORM,
  73. bool bUpdatePositions = true,
  74. float delay = 0.0f,
  75. int speakerentity = -1 ) = 0;
  76. virtual void StopSoundByGuid( int guid ) = 0;
  77. virtual void SetVolumeByGuid( int guid, float flVolume ) = 0;
  78. // Returns how long the sound is
  79. virtual float GetSoundDuration( int guid ) = 0;
  80. // Returns if the sound is looping
  81. virtual bool IsLoopingSound( int guid ) = 0;
  82. virtual void ReloadSound( const char *pSample ) = 0;
  83. virtual void StopAllSounds( ) = 0;
  84. virtual float GetMono16Samples( const char *pszName, CUtlVector< short >& sampleList ) = 0;
  85. virtual void SetAudioState( const AudioState_t &audioState ) = 0;
  86. // Issue a console command
  87. virtual void Command( char const *cmd ) = 0;
  88. // Flush console command buffer right away
  89. virtual void Execute() = 0;
  90. virtual char const *GetCurrentMap() = 0;
  91. virtual void ChangeToMap( char const *mapname ) = 0;
  92. virtual bool IsMapValid( char const *mapname ) = 0;
  93. // Method for causing engine to call client to render scene with no view model or overlays
  94. // See cdll_int.h for enum RenderViewInfo_t for specifying whatToRender
  95. virtual void RenderView( CViewSetup &view, int nFlags, int whatToRender ) = 0;
  96. // Returns true if the player is fully connected and active in game (i.e, not still loading)
  97. virtual bool IsInGame() = 0;
  98. // Returns true if the player is connected, but not necessarily active in game (could still be loading)
  99. virtual bool IsConnected() = 0;
  100. virtual int GetMaxClients() = 0; // Tools might want to ensure single player, e.g.
  101. virtual bool IsGamePaused() = 0;
  102. virtual void SetGamePaused( bool paused ) = 0;
  103. virtual float GetTimescale() = 0; // Could do this via ConVar system, too
  104. virtual void SetTimescale( float scale ) = 0;
  105. // Real time is unscaled, but is updated once per frame
  106. virtual float GetRealTime() = 0;
  107. virtual float GetRealFrameTime() = 0; // unscaled
  108. // Get high precision timer (for profiling?)
  109. virtual float Time() = 0;
  110. // Host time is scaled
  111. virtual float HostFrameTime() = 0; // host_frametime
  112. virtual float HostTime() = 0; // host_time
  113. virtual int HostTick() = 0; // host_tickcount
  114. virtual int HostFrameCount() = 0; // total famecount
  115. virtual float ServerTime() = 0; // gpGlobals->curtime on server
  116. virtual float ServerFrameTime() = 0; // gpGlobals->frametime on server
  117. virtual int ServerTick() = 0; // gpGlobals->tickcount on server
  118. virtual float ServerTickInterval() = 0; // tick interval on server
  119. virtual float ClientTime() = 0; // gpGlobals->curtime on client
  120. virtual float ClientFrameTime() = 0; // gpGlobals->frametime on client
  121. virtual int ClientTick() = 0; // gpGlobals->tickcount on client
  122. virtual void SetClientFrameTime( float frametime ) = 0; // gpGlobals->frametime on client
  123. // Currently the engine doesn't like to do networking when it's paused, but if a tool changes entity state, it can be useful to force
  124. // a network update to get that state over to the client
  125. virtual void ForceUpdateDuringPause() = 0;
  126. // Maybe through modelcache???
  127. virtual model_t *GetModel( HTOOLHANDLE hEntity ) = 0;
  128. // Get the .mdl file used by entity (if it's a cbaseanimating)
  129. virtual studiohdr_t *GetStudioModel( HTOOLHANDLE hEntity ) = 0;
  130. // SINGLE PLAYER/LISTEN SERVER ONLY (just matching the client .dll api for this)
  131. // Prints the formatted string to the notification area of the screen ( down the right hand edge
  132. // numbered lines starting at position 0
  133. virtual void Con_NPrintf( int pos, const char *fmt, ... ) = 0;
  134. // SINGLE PLAYER/LISTEN SERVER ONLY(just matching the client .dll api for this)
  135. // Similar to Con_NPrintf, but allows specifying custom text color and duration information
  136. virtual void Con_NXPrintf( const struct con_nprint_s *info, const char *fmt, ... ) = 0;
  137. // Get the current game directory (hl2, tf2, hl1, cstrike, etc.)
  138. virtual void GetGameDir( char *szGetGameDir, int maxlength ) = 0;
  139. // Do we need separate rects for the 3d "viewport" vs. the tools surface??? and can we control viewports from
  140. virtual void GetScreenSize( int& width, int &height ) = 0;
  141. // GetRootPanel(VPANEL)
  142. // Sets the location of the main view
  143. virtual void SetMainView( const Vector &vecOrigin, const QAngle &angles ) = 0;
  144. // Gets the player view
  145. virtual bool GetPlayerView( CViewSetup &playerView, int x, int y, int w, int h ) = 0;
  146. // From a location on the screen, figure out the vector into the world
  147. virtual void CreatePickingRay( const CViewSetup &viewSetup, int x, int y, Vector& org, Vector& forward ) = 0;
  148. // precache methods
  149. virtual bool PrecacheSound( const char *pName, bool bPreload = false ) = 0;
  150. virtual bool PrecacheModel( const char *pName, bool bPreload = false ) = 0;
  151. virtual void InstallQuitHandler( void *pvUserData, FnQuitHandler func ) = 0;
  152. virtual void TakeTGAScreenShot( char const *filename, int width, int height ) = 0;
  153. // Even if game is paused, force networking to update to get new server state down to client
  154. virtual void ForceSend() = 0;
  155. virtual bool IsRecordingMovie() = 0;
  156. // NOTE: Params can contain file name, frame rate, output avi, output raw, and duration
  157. virtual void StartMovieRecording( KeyValues *pMovieParams ) = 0;
  158. virtual void EndMovieRecording() = 0;
  159. virtual void CancelMovieRecording() = 0;
  160. virtual AVIHandle_t GetRecordingAVIHandle() = 0;
  161. virtual void StartRecordingVoiceToFile( char const *filename, char const *pPathID = 0 ) = 0;
  162. virtual void StopRecordingVoiceToFile() = 0;
  163. virtual bool IsVoiceRecording() = 0;
  164. // A version that simply accepts a ray (can work as a traceline or tracehull)
  165. virtual void TraceRay( const Ray_t &ray, unsigned int fMask, ITraceFilter *pTraceFilter, CBaseTrace *pTrace ) = 0; // client version
  166. virtual void TraceRayServer( const Ray_t &ray, unsigned int fMask, ITraceFilter *pTraceFilter, CBaseTrace *pTrace ) = 0;
  167. virtual bool IsConsoleVisible() = 0;
  168. virtual int GetPointContents( const Vector &vecPosition ) = 0;
  169. virtual int GetActiveDLights( dlight_t *pList[MAX_DLIGHTS] ) = 0;
  170. virtual int GetLightingConditions( const Vector &vecPosition, Vector *pColors, int nMaxLocalLights, LightDesc_t *pLocalLights ) = 0;
  171. virtual void GetWorldToScreenMatrixForView( const CViewSetup &view, VMatrix *pVMatrix ) = 0;
  172. // Collision support
  173. virtual SpatialPartitionHandle_t CreatePartitionHandle( IHandleEntity *pEntity,
  174. SpatialPartitionListMask_t listMask, const Vector& mins, const Vector& maxs ) = 0;
  175. virtual void DestroyPartitionHandle( SpatialPartitionHandle_t hPartition ) = 0;
  176. virtual void InstallPartitionQueryCallback( IPartitionQueryCallback *pQuery ) = 0;
  177. virtual void RemovePartitionQueryCallback( IPartitionQueryCallback *pQuery ) = 0;
  178. virtual void ElementMoved( SpatialPartitionHandle_t handle,
  179. const Vector& mins, const Vector& maxs ) = 0;
  180. virtual void OnModeChanged( bool bGameMode ) = 0;
  181. // Get the engine's window.
  182. virtual void* GetEngineHwnd() = 0;
  183. // Returns the actual elapsed time of the samples
  184. virtual float GetSoundElapsedTime( int guid ) = 0;
  185. virtual void ValidateSoundCache( char const *pchSoundName ) = 0;
  186. virtual void PrefetchSound( char const *pchSoundName ) = 0;
  187. };
  188. #define VENGINETOOL_INTERFACE_VERSION "VENGINETOOL003"
  189. #endif // IENGINETOOL_H