Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 22nd, 2010 | Syntax: C++ | Size: 1.32 KB | Hits: 66 | 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.  
  20.         m_nImport = surface()->CreateNewTextureID();
  21. }
  22.  
  23. void CHudHeart::Paint()
  24. {
  25.         surface()->DrawSetTextureFile( m_nImport, "hud/hearts/f_HeartContainertV2_empty" , true, true);
  26.         surface()->DrawSetTexture( m_nImport );
  27.         surface()->DrawTexturedRect( x0, y0, x1, y1);
  28. }
  29.  
  30.  
  31. // Logic
  32. CHudHearts::CHudHearts( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "CHudHearts" )
  33. {
  34.         Panel *pParent = g_pClientMode->GetViewport();
  35.         SetParent( pParent );
  36.  
  37.         int o_x0 = 0, o_y0 = 0, o_x1 = 64, o_y1 = 64;
  38.         for(int i = 0; i < 20; i++)
  39.         {
  40.                 m_pHeart[i] = new CHudHeart( this );
  41.                 m_pHeart[i]->x0 = o_x0+1;
  42.                 o_x0 += 64;
  43.                 m_pHeart[i]->y0 = o_y0;
  44.  
  45.                 m_pHeart[i]->x1 = o_x1+1;
  46.                 o_x1 += 64;
  47.                 m_pHeart[i]->y1 = o_y1;
  48.         }
  49.  
  50.         SetHiddenBits( HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT );
  51. }
  52.  
  53. void CHudHearts::ApplySchemeSettings()
  54. {
  55.  
  56. }
  57.  
  58. void CHudHearts::OnThink()
  59. {
  60.         for(int i = 0; i < pItemList->m_nMaxHearts; i++)
  61.                 m_pHeart[i]->SetVisible( true );
  62.  
  63.         BaseClass::OnThink();
  64. }