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.

202 lines
5.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. // Author: Matthew D. Campbell ([email protected]), 2003
  7. #ifndef CAREER_BOX_H
  8. #define CAREER_BOX_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <KeyValues.h>
  13. #include <vgui_controls/Frame.h>
  14. #include <vgui_controls/Label.h>
  15. #include <vgui_controls/Button.h>
  16. #include <vgui_controls/TextEntry.h>
  17. #include "weapon_csbase.h"
  18. #include "buy_presets/buy_presets.h"
  19. #include "buypreset_listbox.h"
  20. #include "buypreset_weaponsetlabel.h"
  21. class ConVarToggleCheckButton;
  22. //--------------------------------------------------------------------------------------------------------------
  23. /**
  24. * Base class for career popup dialogs (handles custom backgrounds, etc)
  25. */
  26. class CCareerBaseBox : public vgui::Frame
  27. {
  28. public:
  29. CCareerBaseBox(vgui::Panel *parent, const char *panelName, bool loadResources = true, bool useCareerButtons = false );
  30. virtual void ShowWindow();
  31. void DoModal();
  32. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  33. virtual void PaintBackground();
  34. virtual void PaintBorder();
  35. virtual void PerformLayout();
  36. void SetLabelText( const char *text );
  37. void SetLabelText( const wchar_t *text );
  38. void SetCancelButtonAsDefault();
  39. vgui::Button * GetOkButton() { return m_pOkButton; }
  40. virtual vgui::Panel *CreateControlByName(const char *controlName);
  41. private:
  42. typedef vgui::Frame BaseClass;
  43. vgui::Button *m_pOkButton;
  44. vgui::Button *m_pCancelButton;
  45. vgui::Dar<vgui::Button *> m_buttons;
  46. vgui::Dar<ConVarToggleCheckButton *> m_conVarCheckButtons;
  47. Color m_bgColor;
  48. Color m_borderColor;
  49. vgui::Label *m_pTextLabel;
  50. bool m_cancelFocus;
  51. protected:
  52. void SetLabelVisible( bool visible ) { m_pTextLabel->SetVisible( visible ); }
  53. virtual void OnKeyCodeTyped( vgui::KeyCode code );
  54. virtual void OnCommand( const char *command ); ///< Handle button presses
  55. void AddButton( vgui::Button *pButton ); ///< Add a button to our list of buttons for rollover sounds
  56. };
  57. //--------------------------------------------------------------------------------------------------------------
  58. /**
  59. * Popup dialog with functionality similar to QueryBox, bot with different layout
  60. */
  61. class CCareerQueryBox : public CCareerBaseBox
  62. {
  63. public:
  64. CCareerQueryBox(vgui::Panel *parent, const char *panelName, const char *resourceName = NULL);
  65. CCareerQueryBox(const char *title, const char *labelText, const char *panelName, vgui::Panel *parent = NULL);
  66. CCareerQueryBox(const wchar_t *title, const wchar_t *labelText, const char *panelName, vgui::Panel *parent = NULL);
  67. virtual ~CCareerQueryBox();
  68. private:
  69. typedef CCareerBaseBox BaseClass;
  70. };
  71. //--------------------------------------------------------------------------------------------------------------
  72. /**
  73. * Popup dialog for selecting and editing a primary weapon (ammo to buy, side-availability)
  74. */
  75. class CWeaponSelectBox : public CCareerBaseBox
  76. {
  77. public:
  78. CWeaponSelectBox( vgui::Panel *parent, WeaponSet *pWeaponSet, bool isSecondary );
  79. virtual ~CWeaponSelectBox();
  80. virtual void ActivateBuildMode();
  81. void UpdateClips();
  82. protected:
  83. virtual void OnCommand( const char *command );
  84. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  85. private:
  86. void PopulateControls();
  87. void SetClipsVisible( bool visible );
  88. CSWeaponID GetSelectedWeaponID();
  89. typedef CCareerBaseBox BaseClass;
  90. vgui::ComboBox *m_pClips; ///< Number of clips to purchase
  91. vgui::Label *m_pBullets; ///< Label showing "M of N Bullets"
  92. WeaponSet *m_pWeaponSet; ///< WeaponSet being edited
  93. bool m_isSecondary; ///< is this weapon primary or secondary?
  94. BuyPresetListBox *m_pListBox; ///< List of weapons from which to choose
  95. int m_numWeapons;
  96. CSWeaponID *m_weaponIDs;
  97. };
  98. //--------------------------------------------------------------------------------------------------------------
  99. /**
  100. * Base class for editing grenades and equipment
  101. */
  102. class CBaseSelectBox : public CCareerBaseBox
  103. {
  104. typedef CCareerBaseBox BaseClass;
  105. public:
  106. CBaseSelectBox( vgui::Panel *parent, const char *panelName, bool loadResources = true ) : BaseClass( parent, panelName, loadResources ) {}
  107. virtual void OnControlChanged() = 0;
  108. };
  109. //--------------------------------------------------------------------------------------------------------------
  110. /**
  111. * Popup dialog for editing grenades in a buy preset fallback
  112. */
  113. class CGrenadeSelectBox : public CBaseSelectBox
  114. {
  115. typedef CBaseSelectBox BaseClass;
  116. public:
  117. CGrenadeSelectBox( vgui::Panel *parent, WeaponSet *pWeaponSet );
  118. void OnControlChanged(); ///< Updates item costs
  119. private:
  120. WeaponSet *m_pWeaponSet; ///< WeaponSet being edited
  121. // Equipment controls
  122. vgui::ComboBox *m_pHEGrenade;
  123. EquipmentLabel *m_pHEGrenadeImage;
  124. vgui::Label *m_pHELabel;
  125. vgui::ComboBox *m_pSmokeGrenade;
  126. EquipmentLabel *m_pSmokeGrenadeImage;
  127. vgui::Label *m_pSmokeLabel;
  128. vgui::ComboBox *m_pFlashbangs;
  129. EquipmentLabel *m_pFlashbangImage;
  130. vgui::Label *m_pFlashLabel;
  131. virtual void OnCommand( const char *command );
  132. };
  133. //--------------------------------------------------------------------------------------------------------------
  134. /**
  135. * Popup dialog for selecting an equipment set
  136. */
  137. class CEquipmentSelectBox : public CBaseSelectBox
  138. {
  139. typedef CBaseSelectBox BaseClass;
  140. public:
  141. CEquipmentSelectBox( vgui::Panel *parent, WeaponSet *pWeaponSet );
  142. void OnControlChanged();
  143. private:
  144. WeaponSet *m_pWeaponSet; ///< WeaponSet being edited
  145. // Equipment controls
  146. vgui::ComboBox *m_pKevlar;
  147. vgui::Label *m_pKevlarLabel;
  148. EquipmentLabel *m_pKevlarImage;
  149. vgui::ComboBox *m_pHelmet;
  150. vgui::Label *m_pHelmetLabel;
  151. EquipmentLabel *m_pHelmetImage;
  152. vgui::ComboBox *m_pDefuser;
  153. vgui::Label *m_pDefuserLabel;
  154. EquipmentLabel *m_pDefuserImage;
  155. vgui::ComboBox *m_pNightvision;
  156. vgui::Label *m_pNightvisionLabel;
  157. EquipmentLabel *m_pNightvisionImage;
  158. virtual void OnCommand( const char *command );
  159. };
  160. #endif // CAREER_BOX_H