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.

115 lines
4.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef BASE_LOADOUT_PANEL_H
  8. #define BASE_LOADOUT_PANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "vgui_controls/EditablePanel.h"
  13. #include "econ_controls.h"
  14. #include "item_pickup_panel.h"
  15. #include "GameEventListener.h"
  16. #include "tf_item_card_panel.h"
  17. //-----------------------------------------------------------------------------
  18. // Purpose:
  19. //-----------------------------------------------------------------------------
  20. class CBaseLoadoutPanel : public vgui::EditablePanel, public CGameEventListener
  21. {
  22. DECLARE_CLASS_SIMPLE( CBaseLoadoutPanel, vgui::EditablePanel );
  23. public:
  24. CBaseLoadoutPanel( vgui::Panel *parent, const char *panelName );
  25. virtual ~CBaseLoadoutPanel();
  26. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  27. virtual void ApplySettings( KeyValues *inResourceData );
  28. virtual void PerformLayout( void );
  29. virtual void OnCommand( const char *command );
  30. void ShowPanel( int iClass, bool bBackpack, bool bReturningFromArmory = false );
  31. virtual void FireGameEvent( IGameEvent *event );
  32. virtual int GetNumSlotsPerPage( void ) { return 1; }
  33. virtual int GetNumColumns( void ) { return 99; }
  34. virtual int GetNumRows( void ) { return 99; }
  35. virtual int GetNumPages( void ) { return 1; }
  36. virtual int GetCurrentPage() const { return m_nCurrentPage; }
  37. virtual void SetCurrentPage( int nNewPage );
  38. virtual int GetNumItemPanels( void ) { Assert(0); return 0; };
  39. virtual void OnShowPanel( bool bVisible, bool bReturningFromArmory ) { return; }
  40. virtual void PostShowPanel( bool bVisible ) { return; }
  41. CItemModelPanel *FindBestPanelNavigationForDirection( const CItemModelPanel *pCurrentPanel, const Vector2D &vPos, const Vector2D &vDirection );
  42. void LinkModelPanelControllerNavigation( bool bForceRelink );
  43. virtual void AddNewItemPanel( int iPanelIndex );
  44. MESSAGE_FUNC_PTR( OnItemPanelEntered, "ItemPanelEntered", panel );
  45. MESSAGE_FUNC_PTR( OnItemPanelExited, "ItemPanelExited", panel );
  46. void HideMouseOverPanel( void );
  47. CItemModelPanel *GetMouseOverPanel( void ) { return m_pMouseOverItemPanel; }
  48. CItemModelPanelToolTip *GetMouseOverToolTipPanel( void ) { return m_pMouseOverTooltip; }
  49. protected:
  50. virtual void UpdateModelPanels( void ) { return; }
  51. virtual void SetBorderForItem( CItemModelPanel *pItemPanel, bool bMouseOver );
  52. virtual bool IsIgnoringItemPanelEnters( void ) { return false; }
  53. virtual void ApplyKVsToItemPanels( void );
  54. virtual void CreateItemPanels( void );
  55. virtual void OnItemSelectionChanged() {}
  56. bool HandleItemSelectionKeyPressed( vgui::KeyCode code ) ;
  57. bool HandleItemSelectionKeyReleased( vgui::KeyCode code ) ;
  58. // helpers to get selected items
  59. int GetFirstSelectedItemIndex( bool bIncludeEmptySlots );
  60. CItemModelPanel *GetFirstSelectedItemModelPanel( bool bIncludeEmptySlots );
  61. CEconItemView *GetFirstSelectedItem();
  62. bool GetAdjacentItemIndex( int nIndex, int nPage, int *pnNewIndex, int *pnNewPage, int dx, int dy );
  63. void SelectAdjacentItem( int dx, int dy );
  64. protected:
  65. CUtlVector<CItemModelPanel*> m_pItemModelPanels;
  66. vgui::Label *m_pTitleLabel;
  67. KeyValues *m_pItemModelPanelKVs;
  68. bool m_bReapplyItemKVs;
  69. bool m_bTooltipKeyPressed;
  70. int m_nCurrentPage;
  71. vgui::Label *m_pCaratLabel;
  72. vgui::Label *m_pClassLabel;
  73. CPanelAnimationVarAliasType( int, m_iItemXPosOffcenterA, "item_xpos_offcenter_a", "0", "proportional_int" );
  74. CPanelAnimationVarAliasType( int, m_iItemXPosOffcenterB, "item_xpos_offcenter_b", "0", "proportional_int" );
  75. CPanelAnimationVarAliasType( int, m_iItemYPos, "item_ypos", "0", "proportional_int" );
  76. CPanelAnimationVarAliasType( int, m_iItemYDelta, "item_ydelta", "0", "proportional_int" );
  77. CPanelAnimationVarAliasType( int, m_iButtonXPosOffcenter, "button_xpos_offcenter", "0", "proportional_int" );
  78. CPanelAnimationVarAliasType( int, m_iButtonYPos, "button_ypos", "0", "proportional_int" );
  79. CPanelAnimationVarAliasType( int, m_iButtonYDelta, "button_ydelta", "0", "proportional_int" );
  80. CPanelAnimationVarAliasType( int, m_iItemBackpackOffcenterX, "item_backpack_offcenter_x", "0", "proportional_int" );
  81. CPanelAnimationVarAliasType( int, m_iItemBackpackXDelta, "item_backpack_xdelta", "0", "proportional_int" );
  82. CPanelAnimationVarAliasType( int, m_iItemBackpackYDelta, "item_backpack_ydelta", "0", "proportional_int" );
  83. CPanelAnimationVar( bool, m_bItemsOnly, "items_only", "0" );
  84. CPanelAnimationVar( bool, m_bForceShowBackpackRarities, "force_show_backpack_rarities", "0" );
  85. CPanelAnimationVarAliasType( int, m_iDeleteButtonXPos, "button_override_delete_xpos", "0", "proportional_int" );
  86. protected:
  87. CItemModelPanel *m_pMouseOverItemPanel;
  88. CItemModelPanelToolTip *m_pMouseOverTooltip;
  89. CItemModelPanel *m_pItemPanelBeingMousedOver;
  90. #ifdef STAGING_ONLY
  91. CTFItemCardPanel *m_pMouseOverCardPanel;
  92. CItemCardPanelToolTip *m_pMouseOverCardTooltip;
  93. #endif
  94. };
  95. #endif // BASE_LOADOUT_PANEL_H