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.

279 lines
7.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CSSPECTATORGUI_H
  8. #define CSSPECTATORGUI_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "spectatorgui.h"
  13. #include "mapoverview.h"
  14. #include "cs_shareddefs.h"
  15. extern ConVar mp_playerid; // in cs_gamerules.h
  16. extern ConVar mp_forcecamera; // in gamevars_shared.h
  17. extern ConVar mp_fadetoblack;
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Cstrike Spectator UI
  20. //-----------------------------------------------------------------------------
  21. class CCSSpectatorGUI : public CSpectatorGUI
  22. {
  23. private:
  24. DECLARE_CLASS_SIMPLE( CCSSpectatorGUI, CSpectatorGUI );
  25. public:
  26. CCSSpectatorGUI( IViewPort *pViewPort );
  27. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  28. virtual void UpdateSpectatorPlayerList( void );
  29. virtual void Update( void );
  30. virtual bool NeedsUpdate( void );
  31. //=============================================================================
  32. // HPE_BEGIN:
  33. // [smessick]
  34. //=============================================================================
  35. virtual void ShowPanel( bool bShow );
  36. //=============================================================================
  37. // HPE_END
  38. //=============================================================================
  39. protected:
  40. void UpdateTimer();
  41. void UpdateAccount();
  42. int m_nLastAccount;
  43. int m_nLastTime;
  44. int m_nLastSpecMode;
  45. CBaseEntity *m_nLastSpecTarget;
  46. void StoreWidths( void );
  47. void ResizeControls( void );
  48. bool ControlsPresent( void ) const;
  49. vgui::Label *m_pCTLabel;
  50. vgui::Label *m_pCTScore;
  51. vgui::Label *m_pTerLabel;
  52. vgui::Label *m_pTerScore;
  53. vgui::Label *m_pTimer;
  54. vgui::Label *m_pTimerLabel;
  55. vgui::Panel *m_pDivider;
  56. vgui::Label *m_pExtraInfo;
  57. bool m_modifiedWidths;
  58. int m_scoreWidth;
  59. int m_extraInfoWidth;
  60. };
  61. //////////////////////////////////////////////////////////////////////////
  62. //////////////////////////////////////////////////////////////////////////
  63. #define DESIRED_RADAR_RESOLUTION 450
  64. class CCSMapOverview : public CMapOverview
  65. {
  66. DECLARE_CLASS_SIMPLE( CCSMapOverview, CMapOverview );
  67. public:
  68. enum
  69. {
  70. MAP_ICON_T = 0,
  71. MAP_ICON_CT,
  72. MAP_ICON_HOSTAGE,
  73. MAP_ICON_COUNT
  74. };
  75. CCSMapOverview( const char *pElementName );
  76. virtual ~CCSMapOverview();
  77. virtual bool ShouldDraw( void );
  78. vgui::Panel *GetAsPanel(){ return this; }
  79. virtual bool AllowConCommandsWhileAlive(){return false;}
  80. virtual void SetPlayerPreferredMode( int mode );
  81. virtual void SetPlayerPreferredViewSize( float viewSize );
  82. virtual void ApplySchemeSettings( vgui::IScheme *scheme );
  83. protected: // private structures & types
  84. // list of game events the hLTV takes care of
  85. typedef struct {
  86. int xpos;
  87. int ypos;
  88. } FootStep_t;
  89. // Extra stuff in a this-level parallel array
  90. typedef struct CSMapPlayer_s {
  91. int overrideIcon; // if not -1, the icon to use instead
  92. int overrideIconOffscreen; // to use with overrideIcon
  93. float overrideFadeTime; // Time to start fading the override icon
  94. float overrideExpirationTime; // Time to not use the override icon any more
  95. Vector overridePosition; // Where the overridden icon will draw
  96. QAngle overrideAngle; // And at what angle
  97. bool isDead; // Death latch, since client can be behind the times on health messages.
  98. float timeLastSeen; // curtime that we last saw this guy.
  99. float timeFirstSeen; // curtime that we started seeing this guy
  100. bool isHostage; // Not a full player, a hostage. Special icon, different death event
  101. float flashUntilTime;
  102. float nextFlashPeakTime;
  103. int currentFlashAlpha;
  104. } CSMapPlayer_t;
  105. typedef struct CSMapBomb_s
  106. {
  107. Vector position;
  108. enum BombState
  109. {
  110. BOMB_PLANTED, //planted and ticking down
  111. BOMB_DROPPED, //dropped and lying loose
  112. BOMB_CARRIED, //in the arms of a player
  113. BOMB_GONE, //defused or exploded, but was planted
  114. BOMB_INVALID //no bomb
  115. };
  116. BombState state;
  117. float timeLastSeen;
  118. float timeFirstSeen;
  119. float timeFade;
  120. float timeGone;
  121. float currentRingRadius;
  122. float currentRingAlpha;
  123. float maxRingRadius;
  124. float ringTravelTime;
  125. } CSMapBomb_t;
  126. typedef struct CSMapGoal_s
  127. {
  128. Vector position;
  129. int iconToUse;
  130. } CSMapGoal_t;
  131. public: // IViewPortPanel interface:
  132. virtual void Update();
  133. virtual void Init( void );
  134. // both vgui::Frame and IViewPortPanel define these, so explicitly define them here as passthroughs to vgui
  135. vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
  136. virtual bool IsVisible() { return BaseClass::IsVisible(); }
  137. virtual void SetParent(vgui::VPANEL parent) { BaseClass::SetParent(parent); }
  138. // IGameEventListener
  139. virtual void FireGameEvent( IGameEvent *event);
  140. // VGUI overrides
  141. // Player settings:
  142. void SetPlayerSeen( int index );
  143. void SetBombSeen( bool seen );
  144. // general settings:
  145. virtual void SetMap(const char * map);
  146. virtual void SetMode( int mode );
  147. // Object settings
  148. virtual void FlashEntity( int entityID );
  149. // rules that define if you can see a player on the overview or not
  150. virtual bool CanPlayerBeSeen(MapPlayer_t *player);
  151. virtual int GetIconNumberFromTeamNumber( int teamNumber );
  152. protected:
  153. virtual void DrawCamera();
  154. virtual void DrawMapTexture();
  155. virtual void DrawMapPlayers();
  156. void DrawHostages();
  157. void DrawBomb();
  158. void DrawGoalIcons();
  159. virtual void ResetRound();
  160. virtual void InitTeamColorsAndIcons();
  161. virtual void UpdateSizeAndPosition();
  162. void UpdateGoalIcons();
  163. void ClearGoalIcons();
  164. virtual bool IsRadarLocked();
  165. Vector2D PanelToMap( const Vector2D &panelPos );
  166. bool AdjustPointToPanel(Vector2D *pos);
  167. MapPlayer_t* GetPlayerByEntityID( int entityID );
  168. MapPlayer_t* GetHostageByEntityID( int entityID );
  169. virtual void UpdatePlayers();
  170. void UpdateHostages();///< Update hostages in the MapPlayer list
  171. void UpdateBomb();
  172. void UpdateFlashes();
  173. bool CreateRadarImage(const char *mapName, const char *radarFileName);
  174. virtual bool RunHudAnimations(){ return false; }
  175. private:
  176. bool DrawIconCS( int textureID,
  177. int offscreenTextureID,
  178. Vector pos,
  179. float scale,
  180. float angle,
  181. int alpha,
  182. bool allowRotation = true,
  183. const char *text = NULL,
  184. Color *textColor = NULL,
  185. float status = -1,
  186. Color *statusColor = NULL
  187. );
  188. int GetMasterAlpha( void );// The main alpha that the map part should be, determined by using the mode to look at the right convar
  189. int GetBorderSize( void );// How far in from the edge of the panel we draw, based on mode. Let's the background fancy corners show.
  190. CSMapPlayer_t* GetCSInfoForPlayerIndex( int index );
  191. CSMapPlayer_t* GetCSInfoForPlayer(MapPlayer_t *player);
  192. CSMapPlayer_t* GetCSInfoForHostage(MapPlayer_t *hostage);
  193. bool CanHostageBeSeen(MapPlayer_t *hostage);
  194. CSMapPlayer_t m_PlayersCSInfo[MAX_PLAYERS];
  195. CSMapBomb_t m_bomb;
  196. MapPlayer_t m_Hostages[MAX_HOSTAGES];
  197. CSMapPlayer_t m_HostagesCSInfo[MAX_HOSTAGES];
  198. CUtlVector< CSMapGoal_t > m_goalIcons;
  199. bool m_goalIconsLoaded;
  200. int m_TeamIconsSelf[MAP_ICON_COUNT];
  201. int m_TeamIconsDead[MAP_ICON_COUNT];
  202. int m_TeamIconsOffscreen[MAP_ICON_COUNT];
  203. int m_TeamIconsDeadOffscreen[MAP_ICON_COUNT];
  204. int m_bombIconPlanted;
  205. int m_bombIconDropped;
  206. int m_bombIconCarried;
  207. int m_bombRingPlanted;
  208. int m_bombRingDropped;
  209. int m_bombRingCarried;
  210. int m_bombRingCarriedOffscreen;
  211. int m_radioFlash;
  212. int m_radioFlashOffscreen;
  213. int m_radarTint;
  214. int m_hostageFollowing;
  215. int m_hostageFollowingOffscreen;
  216. int m_playerFacing;
  217. int m_cameraIconFirst;
  218. int m_cameraIconThird;
  219. int m_cameraIconFree;
  220. int m_hostageRescueIcon;
  221. int m_bombSiteIconA;
  222. int m_bombSiteIconB;
  223. int m_nRadarMapTextureID; // texture id for radar version of current overview image
  224. int m_playerPreferredMode; // The mode the player wants to be in for when we aren't being the radar
  225. };
  226. #endif // CSSPECTATORGUI_H