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/CommandCheckButton.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'gameui/CommandCheckButton.cpp')
| -rw-r--r-- | gameui/CommandCheckButton.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gameui/CommandCheckButton.cpp b/gameui/CommandCheckButton.cpp new file mode 100644 index 0000000..1ea98ce --- /dev/null +++ b/gameui/CommandCheckButton.cpp @@ -0,0 +1,47 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "CommandCheckButton.h" +#include "EngineInterface.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include <tier0/memdbgon.h> + +using namespace vgui; + +CCommandCheckButton::CCommandCheckButton( Panel *parent, const char *panelName, const char *text, const char *downcmd, const char *upcmd ) + : CheckButton( parent, panelName, text ) +{ + m_pszDown = downcmd ? strdup( downcmd ) : NULL; + m_pszUp = upcmd ? strdup( upcmd ) : NULL; +} + +CCommandCheckButton::~CCommandCheckButton() +{ + free( m_pszDown ); + free( m_pszUp ); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : *panel - +//----------------------------------------------------------------------------- +void CCommandCheckButton::SetSelected( bool state ) +{ + BaseClass::SetSelected( state ); + + if ( IsSelected() && m_pszDown ) + { + engine->ClientCmd_Unrestricted( m_pszDown ); + engine->ClientCmd_Unrestricted( "\n" ); + } + else if ( !IsSelected() && m_pszUp ) + { + engine->ClientCmd_Unrestricted( m_pszUp ); + engine->ClientCmd_Unrestricted( "\n" ); + } +} |