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.

177 lines
6.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CHARINFO_LOADOUT_SUBPANEL_H
  8. #define CHARINFO_LOADOUT_SUBPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <game/client/iviewport.h>
  13. #include "vgui_controls/PropertyPage.h"
  14. #include <vgui_controls/Button.h>
  15. #include "tf_controls.h"
  16. #include "tf_shareddefs.h"
  17. #include "item_pickup_panel.h"
  18. #include "backpack_panel.h"
  19. #include "class_loadout_panel.h"
  20. #include "crafting_panel.h"
  21. #include "charinfo_armory_subpanel.h"
  22. #define NUM_CLASSES_IN_LOADOUT_PANEL (TF_LAST_NORMAL_CLASS-1) // We don't allow unlockables for the civilian
  23. class CImageButton : public vgui::Button
  24. {
  25. private:
  26. DECLARE_CLASS_SIMPLE( CImageButton, vgui::Button );
  27. public:
  28. CImageButton( vgui::Panel *parent, const char *panelName );
  29. virtual void ApplySettings( KeyValues *inResourceData );
  30. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  31. virtual void OnSizeChanged( int newWide, int newTall );
  32. void SetActiveImage( const char *imagename );
  33. void SetInactiveImage( const char *imagename );
  34. void SetActiveImage( vgui::IImage *image );
  35. void SetInactiveImage( vgui::IImage *image );
  36. public:
  37. virtual void Paint();
  38. private:
  39. vgui::IImage *m_pActiveImage;
  40. char *m_pszActiveImageName;
  41. vgui::IImage *m_pInactiveImage;
  42. char *m_pszInactiveImageName;
  43. bool m_bScaleImage;
  44. Color m_ActiveDrawColor;
  45. Color m_InactiveDrawColor;
  46. };
  47. enum charinfo_activepanels_t
  48. {
  49. CHAP_LOADOUT,
  50. CHAP_BACKPACK,
  51. CHAP_CRAFTING,
  52. CHAP_ARMORY,
  53. };
  54. enum charinfosubbuttons_t
  55. {
  56. CHSB_BACKPACK,
  57. CHSB_CRAFTING,
  58. CHSB_ARMORY,
  59. CHSB_TRADING,
  60. CHSB_NUM_BUTTONS
  61. };
  62. //-----------------------------------------------------------------------------
  63. // Purpose:
  64. //-----------------------------------------------------------------------------
  65. class CCharInfoLoadoutSubPanel : public vgui::PropertyPage
  66. {
  67. DECLARE_CLASS_SIMPLE( CCharInfoLoadoutSubPanel, vgui::PropertyPage );
  68. public:
  69. CCharInfoLoadoutSubPanel(Panel *parent);
  70. virtual ~CCharInfoLoadoutSubPanel();
  71. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  72. virtual void OnCommand( const char *command );
  73. virtual void PerformLayout( void );
  74. virtual void OnCursorMoved( int x, int y );
  75. void SetClassIndex( int iClassIndex, bool bOpenClassLoadout );
  76. void SetTeamIndex( int iTeamIndex );
  77. void OpenToBackpack( void ) { OpenSubPanel( CHAP_BACKPACK ); }
  78. void OpenToCrafting( void ) { OpenSubPanel( CHAP_CRAFTING ); }
  79. void OpenToArmory( int iItemDef = 0 ) { m_iArmoryItemDef = iItemDef; OpenSubPanel( CHAP_ARMORY ); }
  80. void OpenSubPanel( charinfo_activepanels_t iPanel );
  81. void UpdateModelPanels( bool bOpenClassLoadout = true );
  82. CClassLoadoutPanel *GetClassLoadoutPanel( void ) { return m_pClassLoadoutPanel; }
  83. CBackpackPanel *GetBackpackPanel( void ) { return m_pBackpackPanel; }
  84. CCraftingPanel *GetCraftingPanel( void ) { return m_pCraftingPanel; }
  85. CArmoryPanel *GetArmoryPanel( void ) { return m_pArmoryPanel; }
  86. void UpdateLabelFromClass( int nClass );
  87. void UpdateLabelFromSubButton( int nButton );
  88. virtual void OnTick( void );
  89. void RecalculateTargetClassLayout( void );
  90. void RecalculateTargetClassLayoutAtPos( int x, int y );
  91. void MoveCharacterSelection( int nDirection );
  92. void OnKeyCodeTyped( vgui::KeyCode code );
  93. void OnKeyCodePressed( vgui::KeyCode code );
  94. bool ShouldShowExplanations( void ) { return (m_iShowingPanel == CHAP_LOADOUT && m_iCurrentClassIndex == TF_CLASS_UNDEFINED); }
  95. charinfo_activepanels_t GetShowingPanel() const { return m_iShowingPanel; }
  96. int GetCurrentClassIndex() const { return m_iCurrentClassIndex; }
  97. MESSAGE_FUNC( OnPageShow, "PageShow" );
  98. MESSAGE_FUNC( OnSelectionStarted, "SelectionStarted" );
  99. MESSAGE_FUNC( OnSelectionEnded, "SelectionEnded" );
  100. MESSAGE_FUNC( OnCancelSelection, "CancelSelection" );
  101. MESSAGE_FUNC( OnOpenCrafting, "OpenCrafting" );
  102. MESSAGE_FUNC( OnCraftingClosed, "CraftingClosed" );
  103. MESSAGE_FUNC( OnArmoryClosed, "ArmoryClosed" );
  104. MESSAGE_FUNC( OnCharInfoClosing, "CharInfoClosing" );
  105. private:
  106. void RequestInventoryRefresh();
  107. CImageButton *m_pClassButtons[NUM_CLASSES_IN_LOADOUT_PANEL+1];
  108. CImageButton *m_pSubButtons[CHSB_NUM_BUTTONS];
  109. CExLabel *m_pButtonLabels[CHSB_NUM_BUTTONS];
  110. int m_iOverSubButton;
  111. int m_iClassLayout[NUM_CLASSES_IN_LOADOUT_PANEL+1][4];
  112. bool m_bClassLayoutDirty;
  113. bool m_bSnapClassLayout;
  114. bool m_bRequestingInventoryRefresh;
  115. int m_iCurrentClassIndex;
  116. int m_iCurrentTeamIndex;
  117. charinfo_activepanels_t m_iShowingPanel;
  118. charinfo_activepanels_t m_iPrevShowingPanel;
  119. CClassLoadoutPanel *m_pClassLoadoutPanel;
  120. CBackpackPanel *m_pBackpackPanel;
  121. CCraftingPanel *m_pCraftingPanel;
  122. CArmoryPanel *m_pArmoryPanel;
  123. vgui::Label *m_pSelectLabel;
  124. vgui::Label *m_pLoadoutChangesLabel;
  125. vgui::Label *m_pNoSteamLabel;
  126. vgui::Label *m_pNoGCLabel;
  127. vgui::Label *m_pClassLabel;
  128. CExLabel *m_pItemsLabel;
  129. int m_iMouseXPos;
  130. int m_iMouseYPos;
  131. int m_iLabelSetToClass;
  132. int m_iClassLabelYPos;
  133. int m_iItemLabelYPos;
  134. Color m_ItemColorNone;
  135. Color m_ItemColor;
  136. float m_flStartExplanationsAt;
  137. int m_iArmoryItemDef;
  138. CPanelAnimationVarAliasType( int, m_iSelectLabelY, "selectlabely_default", "0", "proportional_int" );
  139. CPanelAnimationVarAliasType( int, m_iSelectLabelOnChangesY, "selectlabely_onchanges", "0", "proportional_int" );
  140. CPanelAnimationVarAliasType( int, m_iClassYPos, "class_ypos", "0", "proportional_int" );
  141. CPanelAnimationVarAliasType( int, m_iClassXDelta, "class_xdelta", "0", "proportional_int" );
  142. CPanelAnimationVarAliasType( int, m_iClassWideMin, "class_wide_min", "0", "proportional_int" );
  143. CPanelAnimationVarAliasType( int, m_iClassWideMax, "class_wide_max", "0", "proportional_int" );
  144. CPanelAnimationVarAliasType( int, m_iClassTallMin, "class_tall_min", "0", "proportional_int" );
  145. CPanelAnimationVarAliasType( int, m_iClassTallMax, "class_tall_max", "0", "proportional_int" );
  146. CPanelAnimationVarAliasType( int, m_iClassDistanceMin, "class_distance_min", "0", "proportional_int" );
  147. CPanelAnimationVarAliasType( int, m_iClassDistanceMax, "class_distance_max", "0", "proportional_int" );
  148. };
  149. #endif // CHARINFO_LOADOUT_SUBPANEL_H