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.

72 lines
1.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "IconPanel.h"
  8. #include "keyvalues.h"
  9. // NOTE: This has to be the last file included!
  10. #include "tier0/memdbgon.h"
  11. DECLARE_BUILD_FACTORY( CIconPanel );
  12. CIconPanel::CIconPanel( vgui::Panel *parent, const char *name ) : vgui::Panel( parent, name )
  13. {
  14. m_szIcon[0] = '\0';
  15. m_icon = NULL;
  16. m_bScaleImage = false;
  17. }
  18. void CIconPanel::ApplySettings( KeyValues *inResourceData )
  19. {
  20. Q_strncpy( m_szIcon, inResourceData->GetString( "icon", "" ), sizeof( m_szIcon ) );
  21. m_icon = HudIcons().GetIcon( m_szIcon );
  22. m_bScaleImage = inResourceData->GetBool( "scaleImage", false );
  23. BaseClass::ApplySettings( inResourceData );
  24. }
  25. void CIconPanel::SetIcon( const char *szIcon )
  26. {
  27. Q_strncpy( m_szIcon, szIcon, sizeof(m_szIcon) );
  28. m_icon = HudIcons().GetIcon( m_szIcon );
  29. }
  30. void CIconPanel::Paint()
  31. {
  32. BaseClass::Paint();
  33. if ( m_icon )
  34. {
  35. int x, y, w, h;
  36. GetBounds( x, y, w, h );
  37. if ( m_bScaleImage )
  38. {
  39. m_icon->DrawSelf( 0, 0, w, h, m_IconColor );
  40. }
  41. else
  42. {
  43. m_icon->DrawSelf( 0, 0, m_IconColor );
  44. }
  45. }
  46. }
  47. void CIconPanel::ApplySchemeSettings( vgui::IScheme *pScheme )
  48. {
  49. BaseClass::ApplySchemeSettings( pScheme );
  50. if ( m_szIcon[0] != '\0' )
  51. {
  52. m_icon = HudIcons().GetIcon( m_szIcon );
  53. }
  54. SetFgColor( pScheme->GetColor( "FgColor", Color( 255, 255, 255, 255 ) ) );
  55. }