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.

152 lines
5.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef CS_HUD_WEAPONSELECTION_H
  7. #define CS_HUD_WEAPONSELECTION_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "weapon_selection.h"
  12. #include <vgui_controls/Panel.h>
  13. #include "cs_weapon_parse.h"
  14. enum
  15. {
  16. WEPSELECT_PICKUP = 0,
  17. WEPSELECT_DROP,
  18. WEPSELECT_SWITCH,
  19. };
  20. //-----------------------------------------------------------------------------
  21. // Purpose: cstrike weapon selection hud element
  22. //-----------------------------------------------------------------------------
  23. class CHudWeaponSelection : public CBaseHudWeaponSelection, public vgui::Panel
  24. {
  25. DECLARE_CLASS_SIMPLE( CHudWeaponSelection, vgui::Panel );
  26. public:
  27. explicit CHudWeaponSelection(const char *pElementName );
  28. virtual bool ShouldDraw();
  29. virtual void OnWeaponPickup( C_BaseCombatWeapon *pWeapon );
  30. virtual void OnWeaponDrop( C_BaseCombatWeapon *pWeapon );
  31. virtual void OnWeaponSwitch( C_BaseCombatWeapon *pWeapon );
  32. virtual void CycleToNextWeapon( void );
  33. virtual void CycleToPrevWeapon( void );
  34. virtual void SwitchToLastWeapon( void );
  35. typedef enum
  36. {
  37. WEAPON_SELECTION_NORMAL = 0,
  38. WEAPON_SELECTION_MELEE,
  39. WEAPON_SELECTION_GRENADE_AND_BOMB,
  40. WEAPON_SELECTION_GRENADE_AND_BOMB_AND_MELEE,
  41. WEAPON_SELECTION_NO_GRENADE_AND_BOMB,
  42. WEAPON_SELECTION_GRENADE,
  43. WEAPON_SELECTION_ITEMSLOT,
  44. } WEAPON_SELECTION_MODE;
  45. void CycleToNextWeapon(WEAPON_SELECTION_MODE selectionMode);
  46. virtual void CycleToNextGrenadeOrBomb( void );
  47. virtual void CycleToNextGrenadeBombOrMelee( void );
  48. virtual void CycleToNextNonGrenadeOrBomb( void );
  49. virtual void UserCmd_Slot3( void );
  50. virtual void UserCmd_Slot4( void );
  51. virtual void UserCmd_Slot5( void );
  52. virtual void UserCmd_Slot6( void );
  53. virtual void UserCmd_Slot7( void );
  54. virtual void UserCmd_Slot8( void );
  55. virtual void UserCmd_Slot9( void );
  56. virtual void UserCmd_Slot10( void );
  57. virtual void UserCmd_Slot11( void );
  58. virtual void UserCmd_GamePadSlot1( void );
  59. virtual void UserCmd_GamePadSlot2( void );
  60. virtual void UserCmd_GamePadSlot3( void );
  61. virtual void UserCmd_GamePadSlot4( void );
  62. virtual void UserCmd_GamePadSlot5( void );
  63. virtual void UserCmd_GamePadSlot6( void );
  64. virtual C_BaseCombatWeapon *GetWeaponInSlot( int iSlot, int iSlotPos );
  65. virtual C_BaseCombatWeapon *GetWeaponInSlotForTarget( C_BasePlayer *player, int iSlot, int iSlotPos );
  66. virtual void SelectWeaponSlot( int iSlot );
  67. virtual void SelectWeapon( void );
  68. virtual C_BaseCombatWeapon *GetSelectedWeapon( void )
  69. {
  70. return static_cast< C_BaseCombatWeapon* >( m_hSelectedWeapon.Get() );
  71. }
  72. virtual void OpenSelection( void );
  73. virtual void HideSelection( void );
  74. virtual void CancelWeaponSelection( void );
  75. virtual void LevelInit();
  76. C_BaseCombatWeapon *FindNextWeaponInWeaponSelection(int iCurrentSlot, int iCurrentPosition, WEAPON_SELECTION_MODE selectionMode=WEAPON_SELECTION_NORMAL);
  77. //C_BaseCombatWeapon *FindNextWeaponInWeaponSelection(int iCurrentSlot, int iCurrentPosition);
  78. C_BaseCombatWeapon *FindPrevWeaponInWeaponSelection(int iCurrentSlot, int iCurrentPosition);
  79. protected:
  80. virtual void OnThink();
  81. virtual void Paint();
  82. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  83. virtual bool IsWeaponSelectable()
  84. {
  85. if (IsInSelectionMode())
  86. return true;
  87. return false;
  88. }
  89. virtual bool IsHudMenuTakingInput();
  90. virtual bool IsHudMenuPreventingWeaponSelection();
  91. private:
  92. void SelectSpecificWeapon( CSWeaponID weaponID );
  93. virtual void SetSelectedWeapon( C_BaseCombatWeapon *pWeapon );
  94. void DrawBox(int x, int y, int wide, int tall, Color color, float normalizedAlpha, int number);
  95. CPanelAnimationVar( vgui::HFont, m_hNumberFont, "NumberFont", "HudSelectionNumbers" );
  96. CPanelAnimationVar( vgui::HFont, m_hTextFont, "TextFont", "HudSelectionText" );
  97. CPanelAnimationVarAliasType( float, m_flSmallBoxSize, "SmallBoxSize", "32", "proportional_float" );
  98. CPanelAnimationVarAliasType( float, m_flLargeBoxWide, "LargeBoxWide", "108", "proportional_float" );
  99. CPanelAnimationVarAliasType( float, m_flLargeBoxTall, "LargeBoxTall", "72", "proportional_float" );
  100. CPanelAnimationVarAliasType( float, m_flBoxGap, "BoxGap", "12", "proportional_float" );
  101. CPanelAnimationVarAliasType( float, m_flSelectionNumberXPos, "SelectionNumberXPos", "4", "proportional_float" );
  102. CPanelAnimationVarAliasType( float, m_flSelectionNumberYPos, "SelectionNumberYPos", "4", "proportional_float" );
  103. CPanelAnimationVarAliasType( float, m_flIconXPos, "IconXPos", "16", "proportional_float" );
  104. CPanelAnimationVarAliasType( float, m_flIconYPos, "IconYPos", "8", "proportional_float" );
  105. CPanelAnimationVarAliasType( float, m_flTextYPos, "TextYPos", "54", "proportional_float" );
  106. CPanelAnimationVar( float, m_flAlphaOverride, "Alpha", "255" );
  107. CPanelAnimationVar( float, m_flSelectionAlphaOverride, "SelectionAlpha", "255" );
  108. CPanelAnimationVar( Color, m_TextColor, "TextColor", "SelectionTextFg" );
  109. CPanelAnimationVar( Color, m_NumberColor, "NumberColor", "SelectionNumberFg" );
  110. CPanelAnimationVar( Color, m_EmptyBoxColor, "EmptyBoxColor", "SelectionEmptyBoxBg" );
  111. CPanelAnimationVar( Color, m_BoxColor, "BoxColor", "SelectionBoxBg" );
  112. CPanelAnimationVar( Color, m_SelectedBoxColor, "SelectedBoxClor", "SelectionSelectedBoxBg" );
  113. CPanelAnimationVar( float, m_flWeaponPickupGrowTime, "SelectionGrowTime", "0.1" );
  114. CPanelAnimationVar( float, m_flTextScan, "TextScan", "1.0" );
  115. CPanelAnimationVar( int, m_iMaxSlots, "MaxSlots", "6" );
  116. CPanelAnimationVar( bool, m_bPlaySelectionSounds, "PlaySelectSounds", "1" );
  117. };
  118. #endif //CS_HUD_CHAT_H