Counter Strike : Global Offensive Source Code
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.

149 lines
4.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "OptionsDialog.h"
  8. #include "vgui_controls/Button.h"
  9. #include "vgui_controls/CheckButton.h"
  10. #include "vgui_controls/PropertySheet.h"
  11. #include "vgui_controls/Label.h"
  12. #include "vgui_controls/QueryBox.h"
  13. #include "vgui/ILocalize.h"
  14. #include "vgui/ISurface.h"
  15. #include "vgui/ISystem.h"
  16. #include "vgui/IVGui.h"
  17. #include "KeyValues.h"
  18. #include "OptionsSubKeyboard.h"
  19. #include "OptionsSubMouse.h"
  20. #include "OptionsSubAudio.h"
  21. #include "OptionsSubVideo.h"
  22. #include "OptionsSubVoice.h"
  23. #include "OptionsSubMultiplayer.h"
  24. #include "OptionsSubDifficulty.h"
  25. #include "OptionsSubPortal.h"
  26. #include "ModInfo.h"
  27. using namespace vgui;
  28. // memdbgon must be the last include file in a .cpp file!!!
  29. #include "tier0/memdbgon.h"
  30. //-----------------------------------------------------------------------------
  31. // Purpose: Basic help dialog
  32. //-----------------------------------------------------------------------------
  33. COptionsDialog::COptionsDialog(vgui::Panel *parent, OptionsDialogTabStyle iTabStyle) : PropertyDialog(parent, "OptionsDialog")
  34. {
  35. SetProportional( true );
  36. SetDeleteSelfOnClose( true );
  37. SetBounds(
  38. 0,
  39. 0,
  40. vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), 512 ),
  41. vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), 415 ) );
  42. SetSizeable( false );
  43. // debug timing code, this function takes too long
  44. // double s4 = system()->GetCurrentTime();
  45. if ( iTabStyle == OPTIONS_DIALOG_ALL_TABS )
  46. {
  47. SetTitle("#GameUI_Options", true);
  48. if ( ModInfo().IsSinglePlayerOnly() && !ModInfo().NoDifficulty() )
  49. {
  50. AddPage(new COptionsSubDifficulty(this), "#GameUI_Difficulty");
  51. }
  52. if ( ModInfo().HasPortals() )
  53. {
  54. AddPage(new COptionsSubPortal(this), "#GameUI_Portal");
  55. }
  56. AddPage(new COptionsSubKeyboard(this), "#GameUI_Keyboard");
  57. AddPage(new COptionsSubMouse(this), "#GameUI_Mouse");
  58. m_pOptionsSubAudio = new COptionsSubAudio(this);
  59. AddPage(m_pOptionsSubAudio, "#GameUI_Audio");
  60. m_pOptionsSubVideo = new COptionsSubVideo(this);
  61. AddPage(m_pOptionsSubVideo, "#GameUI_Video");
  62. if ( !ModInfo().IsSinglePlayerOnly() )
  63. {
  64. AddPage(new COptionsSubVoice(this), "#GameUI_Voice");
  65. }
  66. // add the multiplay page last, if we're combo single/multi or just multi
  67. if ( (ModInfo().IsMultiplayerOnly() && !ModInfo().IsSinglePlayerOnly()) ||
  68. (!ModInfo().IsMultiplayerOnly() && !ModInfo().IsSinglePlayerOnly()) )
  69. {
  70. AddPage(new COptionsSubMultiplayer(this), "#GameUI_Multiplayer");
  71. }
  72. }
  73. else if ( iTabStyle == OPTIONS_DIALOG_ONLY_BINDING_TABS )
  74. {
  75. SetTitle("#L4D360UI_Controller_Edit_Keys_Buttons", true);
  76. AddPage(new COptionsSubKeyboard(this), "#GameUI_Console_UserSettings");
  77. }
  78. // double s5 = system()->GetCurrentTime();
  79. // Msg("COptionsDialog::COptionsDialog(): %.3fms\n", (float)(s5 - s4) * 1000.0f);
  80. SetApplyButtonVisible(true);
  81. GetPropertySheet()->SetTabWidth(84);
  82. }
  83. //-----------------------------------------------------------------------------
  84. // Purpose: Destructor
  85. //-----------------------------------------------------------------------------
  86. COptionsDialog::~COptionsDialog()
  87. {
  88. }
  89. //-----------------------------------------------------------------------------
  90. // Purpose: Brings the dialog to the fore
  91. //-----------------------------------------------------------------------------
  92. void COptionsDialog::Activate()
  93. {
  94. BaseClass::Activate();
  95. EnableApplyButton(false);
  96. }
  97. //-----------------------------------------------------------------------------
  98. // Purpose: Opens the dialog
  99. //-----------------------------------------------------------------------------
  100. void COptionsDialog::Run()
  101. {
  102. SetTitle("#GameUI_Options", true);
  103. Activate();
  104. }
  105. //-----------------------------------------------------------------------------
  106. // Purpose: Opens the gamma dialog directly
  107. //-----------------------------------------------------------------------------
  108. void COptionsDialog::OpenGammaDialog()
  109. {
  110. m_pOptionsSubVideo->OpenGammaDialog();
  111. }
  112. //-----------------------------------------------------------------------------
  113. // Purpose: Called when the GameUI is hidden
  114. //-----------------------------------------------------------------------------
  115. void COptionsDialog::OnGameUIHidden()
  116. {
  117. // tell our children about it
  118. for ( int i = 0 ; i < GetChildCount() ; i++ )
  119. {
  120. Panel *pChild = GetChild( i );
  121. if ( pChild )
  122. {
  123. PostMessage( pChild, new KeyValues( "GameUIHidden" ) );
  124. }
  125. }
  126. }