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.

141 lines
3.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef OPTIONSDIALOG_H
  8. #define OPTIONSDIALOG_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "vgui_controls/PropertyDialog.h"
  13. #include "vgui_controls/KeyRepeat.h"
  14. //-----------------------------------------------------------------------------
  15. // Purpose: Holds all the game option pages
  16. //-----------------------------------------------------------------------------
  17. class COptionsDialog : public vgui::PropertyDialog
  18. {
  19. DECLARE_CLASS_SIMPLE( COptionsDialog, vgui::PropertyDialog );
  20. public:
  21. COptionsDialog(vgui::Panel *parent);
  22. ~COptionsDialog();
  23. void Run();
  24. virtual void Activate();
  25. void OnKeyCodePressed( vgui::KeyCode code );
  26. vgui::PropertyPage* GetOptionsSubMultiplayer( void ) { return m_pOptionsSubMultiplayer; }
  27. MESSAGE_FUNC( OnGameUIHidden, "GameUIHidden" ); // called when the GameUI is hidden
  28. private:
  29. class COptionsSubAudio *m_pOptionsSubAudio;
  30. class COptionsSubVideo *m_pOptionsSubVideo;
  31. vgui::PropertyPage *m_pOptionsSubMultiplayer;
  32. };
  33. #define OPTIONS_MAX_NUM_ITEMS 15
  34. struct OptionData_t;
  35. //-----------------------------------------------------------------------------
  36. // Purpose: Holds all the game option pages
  37. //-----------------------------------------------------------------------------
  38. class COptionsDialogXbox : public vgui::Frame
  39. {
  40. DECLARE_CLASS_SIMPLE( COptionsDialogXbox, vgui::Frame );
  41. public:
  42. COptionsDialogXbox( vgui::Panel *parent, bool bControllerOptions = false );
  43. ~COptionsDialogXbox();
  44. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  45. virtual void ApplySettings( KeyValues *inResourceData );
  46. virtual void OnClose();
  47. virtual void OnKeyCodePressed( vgui::KeyCode code );
  48. virtual void OnCommand(const char *command);
  49. virtual void OnKeyCodeReleased( vgui::KeyCode code);
  50. virtual void OnThink();
  51. private:
  52. void HandleInactiveKeyCodePressed( vgui::KeyCode code );
  53. void HandleActiveKeyCodePressed( vgui::KeyCode code );
  54. void HandleBindKeyCodePressed( vgui::KeyCode code );
  55. int GetSelectionLabel( void ) { return m_iSelection - m_iScroll; }
  56. void ActivateSelection( void );
  57. void DeactivateSelection( void );
  58. void ChangeSelection( int iChange );
  59. void UpdateFooter( void );
  60. void UpdateSelection( void );
  61. void UpdateScroll( void );
  62. void UncacheChoices( void );
  63. void GetChoiceFromConvar( OptionData_t *pOption );
  64. void ChangeValue( float fChange );
  65. void UnbindOption( OptionData_t *pOption, int iLabel );
  66. void UpdateValue( OptionData_t *pOption, int iLabel );
  67. void UpdateBind( OptionData_t *pOption, int iLabel, ButtonCode_t codeIgnore = BUTTON_CODE_INVALID, ButtonCode_t codeAdd = BUTTON_CODE_INVALID );
  68. void UpdateAllBinds( ButtonCode_t code );
  69. void FillInDefaultBindings( void );
  70. bool ShouldSkipOption( KeyValues *pKey );
  71. void ReadOptionsFromFile( const char *pchFileName );
  72. void SortOptions( void );
  73. void InitializeSliderDefaults( void );
  74. private:
  75. bool m_bControllerOptions;
  76. bool m_bOptionsChanged;
  77. bool m_bOldForceEnglishAudio;
  78. CFooterPanel *m_pFooter;
  79. CUtlVector<OptionData_t*> *m_pOptions;
  80. bool m_bSelectionActive;
  81. OptionData_t *m_pSelectedOption;
  82. int m_iSelection;
  83. int m_iScroll;
  84. int m_iSelectorYStart;
  85. int m_iOptionSpacing;
  86. int m_iNumItems;
  87. int m_iXAxisState;
  88. int m_iYAxisState;
  89. float m_fNextChangeTime;
  90. vgui::Panel *m_pOptionsSelectionLeft;
  91. vgui::Panel *m_pOptionsSelectionLeft2;
  92. vgui::Label *m_pOptionsUpArrow;
  93. vgui::Label *m_pOptionsDownArrow;
  94. vgui::Label *(m_pOptionLabels[ OPTIONS_MAX_NUM_ITEMS ]);
  95. vgui::Label *(m_pValueLabels[ OPTIONS_MAX_NUM_ITEMS ]);
  96. vgui::AnalogBar *(m_pValueBars[ OPTIONS_MAX_NUM_ITEMS ]);
  97. vgui::HFont m_hLabelFont;
  98. vgui::HFont m_hButtonFont;
  99. Color m_SelectedColor;
  100. vgui::CKeyRepeatHandler m_KeyRepeat;
  101. int m_nButtonGap;
  102. };
  103. #endif // OPTIONSDIALOG_H