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.

157 lines
5.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CLASS_LOADOUT_PANEL_H
  8. #define CLASS_LOADOUT_PANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "base_loadout_panel.h"
  13. #include "tf_playermodelpanel.h"
  14. #include "item_selection_panel.h"
  15. #include <../common/GameUI/cvarslider.h>
  16. #include <vgui/VGUI.h>
  17. #include "vgui_controls/CheckButton.h"
  18. #define NUM_ITEM_PANELS_IN_LOADOUT CLASS_LOADOUT_POSITION_COUNT
  19. class CLoadoutPresetPanel;
  20. class CLoadoutItemOptionsPanel : public vgui::EditablePanel
  21. {
  22. DECLARE_CLASS_SIMPLE( CLoadoutItemOptionsPanel, vgui::EditablePanel );
  23. public:
  24. CLoadoutItemOptionsPanel( Panel *parent, const char *pName );
  25. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  26. virtual void PerformLayout( void );
  27. virtual void OnCommand( const char *command );
  28. virtual void OnMessage( const KeyValues* pParams, vgui::VPANEL hFromPanel );
  29. void SetItemSlot( loadout_positions_t eItemSlot, int iClassIndex );
  30. loadout_positions_t GetItemSlot() const { return m_eItemSlot; }
  31. void UpdateItemOptionsUI();
  32. private:
  33. void AddControlsParticleEffect( void ) const;
  34. void AddControlsSetStyle( void ) const;
  35. CEconItemView* GetItem( void ) const;
  36. class vgui::PanelListPanel *m_pListPanel;
  37. CCvarSlider *m_pHatParticleSlider;
  38. CExButton *m_pSetStyleButton;
  39. vgui::CheckButton *m_pHatParticleUseHeadButton;
  40. int m_iCurrentClassIndex;
  41. loadout_positions_t m_eItemSlot;
  42. };
  43. //-----------------------------------------------------------------------------
  44. // A loadout screen that handles modifying the loadout of a specific class
  45. //-----------------------------------------------------------------------------
  46. class CClassLoadoutPanel : public CBaseLoadoutPanel
  47. {
  48. DECLARE_CLASS_SIMPLE( CClassLoadoutPanel, CBaseLoadoutPanel );
  49. public:
  50. CClassLoadoutPanel( vgui::Panel *parent );
  51. ~CClassLoadoutPanel();
  52. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  53. virtual void ApplySettings( KeyValues *inResourceData ) OVERRIDE;
  54. virtual void PerformLayout( void );
  55. virtual void FireGameEvent( IGameEvent *event );
  56. virtual void AddNewItemPanel( int iPanelIndex ) OVERRIDE;
  57. virtual void UpdateModelPanels( void );
  58. virtual int GetNumItemPanels( void ) { return NUM_ITEM_PANELS_IN_LOADOUT; };
  59. virtual void OnShowPanel( bool bVisible, bool bReturningFromArmory );
  60. virtual void PostShowPanel( bool bVisible );
  61. virtual void OnKeyCodePressed( vgui::KeyCode code ) OVERRIDE;
  62. virtual void OnNavigateTo( const char* panelName ) OVERRIDE;
  63. virtual void OnNavigateFrom( const char* panelName ) OVERRIDE;
  64. void SetClass( int iClass );
  65. void SetTeam( int iTeam );
  66. int GetNumRelevantSlots() const;
  67. CEconItemView *GetItemInSlot( int iSlot );
  68. MESSAGE_FUNC_PTR( OnItemPanelMouseReleased, "ItemPanelMouseReleased", panel );
  69. MESSAGE_FUNC_PARAMS( OnSelectionReturned, "SelectionReturned", data );
  70. MESSAGE_FUNC( OnCancelSelection, "CancelSelection" );
  71. MESSAGE_FUNC( OnClosing, "Closing" );
  72. virtual void OnCommand( const char *command );
  73. virtual void OnMessage( const KeyValues* pParams, vgui::VPANEL hFromPanel );
  74. void SetSelectionPanel( CEquipSlotItemSelectionPanel *pPanel ) { m_pSelectionPanel = pPanel; }
  75. void UpdatePassiveAttributes( void );
  76. bool IsInSelectionPanel() const { return m_pSelectionPanel != NULL; }
  77. CEquipSlotItemSelectionPanel *GetItemSelectionPanel() { return m_pSelectionPanel; }
  78. bool IsEditingTauntSlots() const { return m_bInTauntLoadoutMode; }
  79. enum classloadoutpage_t
  80. {
  81. CHARACTER_LOADOUT_PAGE,
  82. TAUNT_LOADOUT_PAGE
  83. };
  84. void SetLoadoutPage( classloadoutpage_t loadoutPage );
  85. protected:
  86. virtual void SetBorderForItem( CItemModelPanel *pItemPanel, bool bMouseOver );
  87. void AddAttribPassiveText( const class CEconAttributeDescription& AttrDesc, INOUT_Z_CAP(iNumPassiveChars) wchar_t *out_wszPassiveDesc, int iNumPassiveChars );
  88. void RespawnPlayer();
  89. virtual void ApplyKVsToItemPanels( void ) OVERRIDE;
  90. void ClearItemOptionsMenu( void );
  91. void SetOptionsButtonText( int nIndex, const char* pszText );
  92. static bool AnyOptionsAvailableForItem( const CEconItemView *pItem );
  93. int m_iCurrentClassIndex;
  94. int m_iCurrentTeamIndex;
  95. int m_iCurrentSlotIndex;
  96. bool m_bLoadoutHasChanged;
  97. bool m_bInTauntLoadoutMode;
  98. CTFPlayerModelPanel *m_pPlayerModelPanel;
  99. CEquipSlotItemSelectionPanel *m_pSelectionPanel;
  100. vgui::Label *m_pTauntHintLabel;
  101. CExLabel *m_pTauntLabel;
  102. CExLabel *m_pTauntCaratLabel;
  103. CExLabel *m_pPassiveAttribsLabel;
  104. Panel *m_pTopLinePanel;
  105. CExButton *m_pBuildablesButton;
  106. CExImageButton *m_pCharacterLoadoutButton;
  107. CExImageButton *m_pTauntLoadoutButton;
  108. CLoadoutPresetPanel *m_pLoadoutPresetPanel;
  109. CExplanationPopup *m_pPresetsExplanationPopup;
  110. CExplanationPopup *m_pTauntsExplanationPopup;
  111. KeyValues *m_pItemOptionPanelKVs;
  112. CUtlVector< CExButton * > m_vecItemOptionButtons;
  113. CLoadoutItemOptionsPanel *m_pItemOptionPanel;
  114. private:
  115. void UpdatePageButtonColor( CExImageButton *pPageButton, bool bIsActive );
  116. enum PageButtonColors_t
  117. {
  118. LOADED = 0, NOTLOADED,
  119. FG = 0, BG,
  120. DEFAULT = 0, ARMED, DEPRESSED
  121. };
  122. Color m_aDefaultColors[2][2][3]; // [LOADED|NOTLOADED][FG|BG][DEFAULT|ARMED|DEPRESSED]
  123. };
  124. extern CClassLoadoutPanel *g_pClassLoadoutPanel;
  125. #endif // CLASS_LOADOUT_PANEL_H