diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /gameui/OptionsSubDifficulty.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'gameui/OptionsSubDifficulty.cpp')
| -rw-r--r-- | gameui/OptionsSubDifficulty.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/gameui/OptionsSubDifficulty.cpp b/gameui/OptionsSubDifficulty.cpp new file mode 100644 index 0000000..2e2e47f --- /dev/null +++ b/gameui/OptionsSubDifficulty.cpp @@ -0,0 +1,79 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "OptionsSubDifficulty.h" +#include "tier1/convar.h" +#include "EngineInterface.h" +#include "tier1/KeyValues.h" + +#include "vgui_controls/RadioButton.h" + +using namespace vgui; + + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +COptionsSubDifficulty::COptionsSubDifficulty(vgui::Panel *parent) : BaseClass(parent, NULL) +{ + m_pEasyRadio = new RadioButton(this, "Skill1Radio", "#GameUI_SkillEasy"); + m_pNormalRadio = new RadioButton(this, "Skill2Radio", "#GameUI_SkillNormal"); + m_pHardRadio = new RadioButton(this, "Skill3Radio", "#GameUI_SkillHard"); + + LoadControlSettings("Resource/OptionsSubDifficulty.res"); +} + +//----------------------------------------------------------------------------- +// Purpose: resets controls +//----------------------------------------------------------------------------- +void COptionsSubDifficulty::OnResetData() +{ + ConVarRef var( "skill" ); + + if (var.GetInt() == 1) + { + m_pEasyRadio->SetSelected(true); + } + else if (var.GetInt() == 3) + { + m_pHardRadio->SetSelected(true); + } + else + { + m_pNormalRadio->SetSelected(true); + } +} + +//----------------------------------------------------------------------------- +// Purpose: sets data based on control settings +//----------------------------------------------------------------------------- +void COptionsSubDifficulty::OnApplyChanges() +{ + ConVarRef var( "skill" ); + + if ( m_pEasyRadio->IsSelected() ) + { + var.SetValue( 1 ); + } + else if ( m_pHardRadio->IsSelected() ) + { + var.SetValue( 3 ); + } + else + { + var.SetValue( 2 ); + } +} + + +//----------------------------------------------------------------------------- +// Purpose: enables apply button on radio buttons being pressed +//----------------------------------------------------------------------------- +void COptionsSubDifficulty::OnRadioButtonChecked() +{ + PostActionSignal(new KeyValues("ApplyButtonEnable")); +} |