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.

174 lines
4.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef SFHUDRETICLE_H_
  7. #define SFHUDRETICLE_H_
  8. #include "hud.h"
  9. #include "hud_element_helper.h"
  10. #include "scaleformui/scaleformui.h"
  11. #include "sfhudflashinterface.h"
  12. #include "cs_gamerules.h"
  13. #include "c_cs_player.h"
  14. #include "weapon_csbase.h"
  15. #include "takedamageinfo.h"
  16. #include "weapon_csbase.h"
  17. #include "ammodef.h"
  18. #if defined(_PS3) || defined(POSIX)
  19. #define HUDRET_WEPICON_SELECTED_IMG_STRING L"<img src='icon-%ls.png' height='22'/>"
  20. #define HUDRET_WEPICON_IMG_STRING L"<img src='icon-%ls_grey.png' height='22'/>"
  21. #else
  22. #define HUDRET_WEPICON_SELECTED_IMG_STRING L"<img src='icon-%s.png' height='22'/>"
  23. #define HUDRET_WEPICON_IMG_STRING L"<img src='icon-%s_grey.png' height='22'/>"
  24. #endif
  25. #define VIEWPUNCH_COMPENSATE_MAGIC_SCALAR 0.65 // cl_flinch_scale.GetFloat()
  26. #define VIEWPUNCH_COMPENSATE_MAGIC_ANGLE 1
  27. struct PlayerIDPanel
  28. {
  29. EHANDLE hPlayer;
  30. SFVALUE panel;
  31. SFVALUE arrowA;
  32. SFVALUE arrowB;
  33. SFVALUE arrowF;
  34. SFVALUE voiceIcon;
  35. SFVALUE defuseIcon;
  36. int iconsFlag;
  37. bool bActive;
  38. bool bShowName;
  39. bool bFriend;
  40. int nTeam;
  41. int nHealth;
  42. float flUpdateAt;
  43. float bFlashedAmt;
  44. float flLastHighlightTime;
  45. float flNameAlpha;
  46. };
  47. class SFHudReticle : public SFHudFlashInterface
  48. {
  49. enum
  50. {
  51. TEXTFIELD_LENGTH = 256
  52. };
  53. public:
  54. enum RETICLE_MODE
  55. {
  56. RETICLE_MODE_NONE,
  57. RETICLE_MODE_WEAPON,
  58. RETICLE_MODE_OBSERVER
  59. };
  60. explicit SFHudReticle( const char *value );
  61. virtual ~SFHudReticle();
  62. void OnSwapReticle( SCALEFORM_CALLBACK_ARGS_DECL );
  63. // These overload the CHudElement class
  64. virtual void ProcessInput( void );
  65. virtual void LevelInit( void );
  66. virtual void LevelShutdown( void );
  67. virtual void SetActive( bool bActive );
  68. virtual bool ShouldDraw( void );
  69. // these overload the ScaleformFlashInterfaceMixin class
  70. virtual void FlashReady( void );
  71. virtual bool PreUnloadFlash( void );
  72. virtual void FireGameEvent( IGameEvent *event );
  73. void ToggleTeamEquipmentVisibility( bool bShow );
  74. protected:
  75. void ShowReticle( RETICLE_MODE mode, bool value );
  76. bool SetReticlePosition( int distance, int crosshairGap , int offsetX, int offsetY, int nDesiredFishtail );
  77. void LockSlot(bool wantItLocked, bool& currentlyLocked);
  78. void ResetDisplay( void );
  79. int TeamToTextIndex( int iTeamNumber );
  80. // Swaps the current reticle assets
  81. void PerformSwapReticle( const char * szReticleName );
  82. void AddNewPlayerID( CBaseEntity *player, bool bShowName, bool bFriend = false );
  83. void UpdatePlayerID( CBaseEntity *player, int slot, bool bHealthAndNameOnly = false );
  84. void RemoveID( int index );
  85. void RemoveAllIDs( void );
  86. void GetIconHTML( const wchar_t * szIcon, wchar_t * szBuffer, int nBufferSize, bool bSelected );
  87. bool ShouldShowAllFriendlyTargetIDs( void );
  88. bool ShouldShowAllFriendlyEquipment( void );
  89. protected:
  90. wchar_t m_wcIDString[ TEXTFIELD_LENGTH ];
  91. bool m_bCrosshairPositionsInitialized;
  92. double m_TopPipY;
  93. double m_BottomPipY;
  94. double m_LeftPipX;
  95. double m_RightPipX;
  96. float m_dotX;
  97. float m_dotY;
  98. float m_blackRingX;
  99. float m_blackRingY;
  100. float m_friendIndicatorX;
  101. float m_friendIndicatorY;
  102. float m_IDMovieX;
  103. float m_IDMovieY;
  104. SFVALUE m_WeaponCrosshairHandle;
  105. SFVALUE m_ObserverCrosshairHandle;
  106. SFVALUE m_TopPip;
  107. SFVALUE m_BottomPip;
  108. SFVALUE m_LeftPip;
  109. SFVALUE m_RightPip;
  110. SFVALUE m_topCrosshairArc;
  111. SFVALUE m_rightCrosshairArc;
  112. SFVALUE m_leftCrosshairArc;
  113. SFVALUE m_bottomCrosshairArc;
  114. SFVALUE m_FriendCrosshair;
  115. SFVALUE m_crosshairDot;
  116. SFVALUE m_blackRing;
  117. SFVALUE m_IDMovie;
  118. SFVALUE m_IDText;
  119. SFVALUE m_FlashedIcon;
  120. RETICLE_MODE m_iReticleMode;
  121. float m_fIDTimer;
  122. int m_iLastGap;
  123. int m_iLastSpread;
  124. bool m_bTextIDVisible;
  125. bool m_bFriendlyCrosshairVisible;
  126. bool m_bEnemyCrosshairVisible;
  127. bool m_bFlashedIconFadingOut;
  128. bool m_bForceShowAllTeammateTargetIDs;
  129. CUtlVector<PlayerIDPanel> m_playerIDs;
  130. };
  131. extern ConVar crosshair;
  132. //extern ConVar sfcrosshair;
  133. #endif /* SFHUDRETICLE_H_ */