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.

79 lines
2.1 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "optionssubdifficulty.h"
  8. #include "tier1/convar.h"
  9. #include "engineinterface.h"
  10. #include "tier1/keyvalues.h"
  11. #include "vgui_controls/RadioButton.h"
  12. using namespace vgui;
  13. //-----------------------------------------------------------------------------
  14. // Purpose: Constructor
  15. //-----------------------------------------------------------------------------
  16. COptionsSubDifficulty::COptionsSubDifficulty(vgui::Panel *parent) : BaseClass(parent, NULL)
  17. {
  18. m_pEasyRadio = new RadioButton(this, "Skill1Radio", "#GameUI_SkillEasy");
  19. m_pNormalRadio = new RadioButton(this, "Skill2Radio", "#GameUI_SkillNormal");
  20. m_pHardRadio = new RadioButton(this, "Skill3Radio", "#GameUI_SkillHard");
  21. LoadControlSettings("Resource/OptionsSubDifficulty.res");
  22. }
  23. //-----------------------------------------------------------------------------
  24. // Purpose: resets controls
  25. //-----------------------------------------------------------------------------
  26. void COptionsSubDifficulty::OnResetData()
  27. {
  28. ConVarRef var( "skill" );
  29. if (var.GetInt() == 1)
  30. {
  31. m_pEasyRadio->SetSelected(true);
  32. }
  33. else if (var.GetInt() == 3)
  34. {
  35. m_pHardRadio->SetSelected(true);
  36. }
  37. else
  38. {
  39. m_pNormalRadio->SetSelected(true);
  40. }
  41. }
  42. //-----------------------------------------------------------------------------
  43. // Purpose: sets data based on control settings
  44. //-----------------------------------------------------------------------------
  45. void COptionsSubDifficulty::OnApplyChanges()
  46. {
  47. ConVarRef var( "skill" );
  48. if ( m_pEasyRadio->IsSelected() )
  49. {
  50. var.SetValue( 1 );
  51. }
  52. else if ( m_pHardRadio->IsSelected() )
  53. {
  54. var.SetValue( 3 );
  55. }
  56. else
  57. {
  58. var.SetValue( 2 );
  59. }
  60. }
  61. //-----------------------------------------------------------------------------
  62. // Purpose: enables apply button on radio buttons being pressed
  63. //-----------------------------------------------------------------------------
  64. void COptionsSubDifficulty::OnRadioButtonChecked()
  65. {
  66. PostActionSignal(new KeyValues("ApplyButtonEnable"));
  67. }