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.

136 lines
3.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef SFWEAPONSELECTION_H
  8. #define SFWEAPONSELECTION_H
  9. #pragma once
  10. #include "hudelement.h"
  11. #include "ehandle.h"
  12. #include "hud.h"
  13. #include "hud_element_helper.h"
  14. #include "scaleformui/scaleformui.h"
  15. #include "sfhudflashinterface.h"
  16. #include "cs_gamerules.h"
  17. #include "c_cs_player.h"
  18. #include "weapon_csbase.h"
  19. #include "takedamageinfo.h"
  20. #include "weapon_csbase.h"
  21. #include "ammodef.h"
  22. #include <vgui_controls/Panel.h>
  23. #include "cs_hud_weaponselection.h"
  24. #define MAX_WEP_SELECT_PANELS 5
  25. #define MAX_WEP_SELECT_POSITIONS 6 // if we limit the grenades to three, this will go down
  26. #define WEAPON_SELECTION_FADE_TIME_SEC 1.25
  27. #define WEAPON_SELECTION_FADE_SPEED 100.0 / WEAPON_SELECTION_FADE_TIME_SEC
  28. #define WEAPON_SELECTION_FADE_DELAY 1.5
  29. #define WEAPON_SELECT_PANEL_HEIGHT 65
  30. struct WeaponSelectPanel
  31. {
  32. SFVALUE handle;
  33. double alpha;
  34. EHANDLE hWeapon;
  35. bool bSelected;
  36. bool bJustPickedUp;
  37. float fEndBlinkTime;
  38. float fLastBlinkTime;
  39. };
  40. //-----------------------------------------------------------------------------
  41. // Purpose: Used to draw the history of weapon / item pickups and purchases by the player
  42. //-----------------------------------------------------------------------------
  43. class SFWeaponSelection : public SFHudFlashInterface
  44. {
  45. public:
  46. explicit SFWeaponSelection( const char *value );
  47. C_CSPlayer* GetLocalOrHudPlayer( void );
  48. void AddWeapon( C_BaseCombatWeapon *pWeapon, bool bSelected );
  49. void UpdateGGNextPanel( bool bForceShowForTRBomb = false, bool bKnifeReached = false );
  50. void HideWeapon( int nSlot, int nPos );
  51. void RemoveWeapon( int nSlot, int nPos );
  52. WeaponSelectPanel CreateNewPanel( C_BaseCombatWeapon *pWeapon = NULL, bool bSelected = false );
  53. void CreateGGNextPanel( void );
  54. void ShowAndUpdateSelection( int nType = WEPSELECT_SWITCH, C_BaseCombatWeapon *pWeapon = NULL, bool bGiveInitial = false );
  55. void UpdatePanelPositions( void );
  56. void DisplayLevelUpNextWeapon( void );
  57. void RemoveItem( int nSlot, int nPos );
  58. void RemoveAllItems( void );
  59. virtual void ProcessInput( void );
  60. virtual void LevelInit( void );
  61. virtual void LevelShutdown( void );
  62. virtual void SetActive( bool bActive );
  63. virtual bool ShouldDraw( void );
  64. void SetAlwaysShow( bool bAlwaysShow );
  65. bool IsC4Visible( void ) { return m_bC4IsVisible; }
  66. virtual void FlashReady( void );
  67. virtual bool PreUnloadFlash( void );
  68. // CGameEventListener methods
  69. virtual void FireGameEvent( IGameEvent *event );
  70. protected:
  71. // Calls either Show or Hide
  72. void ShowPanel( const bool bShow );
  73. // Show the item history
  74. void Show( void );
  75. // Hide the item history
  76. void Hide( void );
  77. virtual C_WeaponCSBase *GetSelectedWeapon( void )
  78. {
  79. return dynamic_cast<C_WeaponCSBase*>(m_hSelectedWeapon.Get());
  80. }
  81. private:
  82. SFVALUE m_anchorPanel;
  83. float m_lastUpdate;
  84. float m_flFadeStartTime;
  85. //CUtlVector<WeaponSelectPanel> m_weaponPanels;
  86. WeaponSelectPanel m_weaponPanels[MAX_WEP_SELECT_PANELS][MAX_WEP_SELECT_POSITIONS];
  87. bool m_bVisible; // Element visibility flag
  88. CHandle< C_BaseCombatWeapon > m_hSelectedWeapon;
  89. WeaponSelectPanel m_selectedPanel;
  90. bool m_bCreatedNextPanel;
  91. WeaponSelectPanel m_ggNextPanel;
  92. int m_nPrevWepAlignSlot;
  93. int m_nPrevOccupiedWepSlot;
  94. int m_nOrigXPos;
  95. int m_nOrigYPos;
  96. bool m_bInitPos;
  97. bool m_bInitialized;
  98. bool m_bAlwaysShow; // When true, will not fade out
  99. bool m_bC4IsVisible;
  100. int m_nLastTRKills;
  101. int m_nLastGGWepIndex;
  102. bool m_bUpdateGGNextPanel;
  103. float m_flUpdateInventoryAt;
  104. bool m_bUpdateInventoryReset;
  105. int m_bSpectatorTargetIndex;
  106. };
  107. #endif // SFWEAPONSELECTION_H