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.

128 lines
4.5 KiB

  1. //========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Weapon selection handling
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #if !defined( WEAPON_SELECTION_H )
  8. #define WEAPON_SELECTION_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "hudelement.h"
  13. class C_BaseCombatWeapon;
  14. class C_BasePlayer;
  15. extern ConVar hud_fastswitch;
  16. // weapon switch types for Convar hud_fastswitch
  17. #define HUDTYPE_BUCKETS 0 // PC buckets
  18. #define HUDTYPE_FASTSWITCH 1 // PC fastswitch
  19. #define HUDTYPE_PLUS 2 // console buckets
  20. #define HUDTYPE_CAROUSEL 3 // console carousel scroll
  21. //-----------------------------------------------------------------------------
  22. // Purpose: Base class for tf2 & hl2 weapon selection hud elements
  23. //-----------------------------------------------------------------------------
  24. abstract_class CBaseHudWeaponSelection : public CHudElement
  25. {
  26. DECLARE_CLASS( CBaseHudWeaponSelection, CHudElement );
  27. public:
  28. CBaseHudWeaponSelection( const char *pElementName );
  29. virtual void Init( void );
  30. virtual void VidInit( void );
  31. virtual void ProcessInput();
  32. virtual void Reset(void);
  33. virtual void OnThink(void);
  34. virtual void OpenSelection( void );
  35. virtual void HideSelection( void );
  36. virtual void CancelWeaponSelection( void );
  37. // Game specific overrides
  38. virtual void CycleToNextWeapon( void ) = 0;
  39. virtual void CycleToPrevWeapon( void ) = 0;
  40. virtual void SwitchToLastWeapon( void );
  41. virtual void CycleToNextGrenadeOrBomb( void ) = 0;
  42. virtual void CycleToNextGrenadeBombOrMelee( void ) = 0;
  43. virtual void CycleToNextNonGrenadeOrBomb( void ) = 0;
  44. virtual C_BaseCombatWeapon *GetWeaponInSlot( int iSlot, int iSlotPos ) = 0;
  45. virtual void SelectWeaponSlot( int iSlot ) = 0;
  46. virtual C_BaseCombatWeapon *GetFirstPos( int iSlot );
  47. virtual C_BaseCombatWeapon *GetNextActivePos( int iSlot, int iSlotPos );
  48. virtual void SetWeaponSelected( void );
  49. virtual void SelectWeapon( void );
  50. virtual C_BaseCombatWeapon *GetSelectedWeapon( void ) = 0;
  51. virtual void OnWeaponPickup( C_BaseCombatWeapon *pWeapon );
  52. virtual void OnWeaponDrop( C_BaseCombatWeapon *pWeapon ) {}
  53. virtual void OnWeaponSwitch( C_BaseCombatWeapon *pWeapon ) {}
  54. virtual bool IsInSelectionMode();
  55. void UserCmd_Slot1( void );
  56. void UserCmd_Slot2( void );
  57. virtual void UserCmd_Slot3( void );
  58. virtual void UserCmd_Slot4( void );
  59. virtual void UserCmd_Slot5( void );
  60. virtual void UserCmd_Slot6( void );
  61. virtual void UserCmd_Slot7( void );
  62. virtual void UserCmd_Slot8( void );
  63. virtual void UserCmd_Slot9( void );
  64. void UserCmd_Slot0( void );
  65. virtual void UserCmd_Slot10( void );
  66. virtual void UserCmd_Slot11( void );
  67. void UserCmd_Close( void );
  68. void UserCmd_NextWeapon( void );
  69. void UserCmd_PrevWeapon( void );
  70. void UserCmd_LastWeapon( void );
  71. void UserCmd_DropPrimary( void );
  72. void UserCmd_NextGrenadeWeapon( void );
  73. void UserCmd_NextItemWeapon( void );
  74. void UserCmd_NextNonGrenadeWeapon( void );
  75. virtual void UserCmd_GamePadSlot1( void )=0;
  76. virtual void UserCmd_GamePadSlot2( void )=0;
  77. virtual void UserCmd_GamePadSlot3( void )=0;
  78. virtual void UserCmd_GamePadSlot4( void )=0;
  79. virtual void UserCmd_GamePadSlot5( void )=0;
  80. virtual void UserCmd_GamePadSlot6( void )=0;
  81. virtual void SelectSlot( int iSlot );
  82. virtual bool IsHudMenuTakingInput();
  83. virtual bool IsHudMenuPreventingWeaponSelection();
  84. bool HandleHudMenuInput( int iSlot );
  85. static CBaseHudWeaponSelection *GetInstance();
  86. // these functions are exposed as virtual so that the tf_hints system can redraw the weapon selection
  87. virtual void DrawWList( C_BasePlayer *pPlayer, C_BaseCombatWeapon *pSelectedWeapon, bool drawOutline = false, int ora = 0, int og = 0, int ob = 0, int oa = 0 ) {}
  88. virtual bool ComputeRect( C_BasePlayer *pPlayer, C_BaseCombatWeapon *pSelectedWeapon, wrect_t *outrect ) { return false; }
  89. virtual int KeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding );
  90. protected:
  91. // returns true if there is a weapon currently visible to select
  92. virtual bool IsWeaponSelectable() { return IsInSelectionMode(); }
  93. bool CanBeSelectedInHUD( C_BaseCombatWeapon *pWeapon );
  94. void UpdateSelectionTime( void );
  95. float m_flSelectionTime; // most recent time at which weapon selection had input
  96. static CBaseHudWeaponSelection *s_pInstance[MAX_SPLITSCREEN_PLAYERS];
  97. bool m_bSelectionVisible;
  98. CHandle< C_BaseCombatWeapon > m_hSelectedWeapon;
  99. };
  100. // accessor
  101. CBaseHudWeaponSelection *GetHudWeaponSelection();
  102. #endif // WEAPON_SELECTION_H