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.

47 lines
1.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "CommandCheckButton.h"
  8. #include "EngineInterface.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include <tier0/memdbgon.h>
  11. using namespace vgui;
  12. CCommandCheckButton::CCommandCheckButton( Panel *parent, const char *panelName, const char *text, const char *downcmd, const char *upcmd )
  13. : CheckButton( parent, panelName, text )
  14. {
  15. m_pszDown = downcmd ? strdup( downcmd ) : NULL;
  16. m_pszUp = upcmd ? strdup( upcmd ) : NULL;
  17. }
  18. CCommandCheckButton::~CCommandCheckButton()
  19. {
  20. free( m_pszDown );
  21. free( m_pszUp );
  22. }
  23. //-----------------------------------------------------------------------------
  24. // Purpose:
  25. // Input : *panel -
  26. //-----------------------------------------------------------------------------
  27. void CCommandCheckButton::SetSelected( bool state )
  28. {
  29. BaseClass::SetSelected( state );
  30. if ( IsSelected() && m_pszDown )
  31. {
  32. engine->ClientCmd_Unrestricted( m_pszDown );
  33. engine->ClientCmd_Unrestricted( "\n" );
  34. }
  35. else if ( !IsSelected() && m_pszUp )
  36. {
  37. engine->ClientCmd_Unrestricted( m_pszUp );
  38. engine->ClientCmd_Unrestricted( "\n" );
  39. }
  40. }