Guest
Public paste!

Untitled

By: a guest | Mar 22nd, 2010 | Syntax: C++ | Size: 1.26 KB | Hits: 71 | Expires: Never
Copy text to clipboard
  1. #include "cbase.h"
  2. #include "HudHealthHearts.h"
  3.  
  4. #include "iclientmode.h"
  5. #include "hud_macros.h"
  6. #include "vgui_controls/controls.h"
  7. #include "vgui/ISurface.h"
  8.  
  9. #include "tier0/memdbgon.h"
  10.  
  11. using namespace vgui;
  12.  
  13. CHudHeart::CHudHeart( Panel *pElement )
  14. {
  15.         SetParent( pElement );
  16.  
  17.         SetVisible( false );
  18.         SetAlpha( 255 );
  19.         SetSize(64, 64);
  20.  
  21.         m_nImport = surface()->CreateNewTextureID();
  22. }
  23.  
  24. void CHudHeart::Paint()
  25. {
  26.         surface()->DrawSetTextureFile( m_nImport, "hud/hearts/f_HeartContainertV2_empty" , true, true);
  27.         surface()->DrawSetTexture( m_nImport );
  28.         //surface()->DrawTexturedRect( x0, y0, x1, y1);
  29. }
  30.  
  31.  
  32. // Logic
  33. CHudHearts::CHudHearts( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "CHudHearts" )
  34. {
  35.         Panel *pParent = g_pClientMode->GetViewport();
  36.         SetParent( pParent );
  37.  
  38.         int o_x0 = 0, o_y0 = 0;
  39.         for(int i = 0; i < 20; i++)
  40.         {
  41.                 m_pHeart[i] = new CHudHeart( this );
  42.                 m_pHeart[i]->SetPos(o_x0, o_y0);
  43.                 o_x0 += 64;
  44.                 if(i >= 10)
  45.                         o_y0 = 64;
  46.         }
  47.  
  48.         SetHiddenBits( HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT );
  49. }
  50.  
  51. void CHudHearts::ApplySchemeSettings()
  52. {
  53.  
  54. }
  55.  
  56. void CHudHearts::OnThink()
  57. {
  58.         for(int i = 0; i < pItemList->m_nMaxHearts; i++)
  59.                 m_pHeart[i]->SetVisible( true );
  60.  
  61.         BaseClass::OnThink();
  62. }