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.

157 lines
4.7 KiB

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