Team Fortress 2 Source Code as on 22/4/2020
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.

79 lines
2.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "hudelement.h"
  8. #include <vgui_controls/Panel.h>
  9. #include <vgui/ISurface.h>
  10. #include "clientmode_csnormal.h"
  11. #include "c_cs_player.h"
  12. class CHudDefuser : public CHudElement, public vgui::Panel
  13. {
  14. public:
  15. DECLARE_CLASS_SIMPLE( CHudDefuser, vgui::Panel );
  16. CHudDefuser( const char *name );
  17. virtual bool ShouldDraw();
  18. virtual void Paint();
  19. private:
  20. CPanelAnimationVar( Color, m_clrIcon, "IconColor", "IconColor" );
  21. CHudTexture *m_pIcon;
  22. };
  23. DECLARE_HUDELEMENT( CHudDefuser );
  24. CHudDefuser::CHudDefuser( const char *pName ) :
  25. vgui::Panel( NULL, "HudDefuser" ), CHudElement( pName )
  26. {
  27. SetParent( g_pClientMode->GetViewport() );
  28. m_pIcon = NULL;
  29. SetHiddenBits( HIDEHUD_PLAYERDEAD );
  30. //=============================================================================
  31. // HPE_BEGIN:
  32. // [tj] Add this to the render group that disappears when the scoreboard is up
  33. //=============================================================================
  34. RegisterForRenderGroup( "hide_for_scoreboard" );
  35. //=============================================================================
  36. // HPE_END
  37. //=============================================================================
  38. }
  39. bool CHudDefuser::ShouldDraw()
  40. {
  41. C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
  42. //=============================================================================
  43. // HPE_BEGIN:
  44. // [tj] Added base class call
  45. //=============================================================================
  46. return pPlayer && pPlayer->HasDefuser() && CHudElement::ShouldDraw();
  47. //=============================================================================
  48. // HPE_END
  49. //=============================================================================
  50. }
  51. void CHudDefuser::Paint()
  52. {
  53. if ( !m_pIcon )
  54. {
  55. m_pIcon = gHUD.GetIcon( "defuser" );
  56. }
  57. if ( m_pIcon )
  58. {
  59. int x, y, w, h;
  60. GetBounds( x, y, w, h );
  61. m_pIcon->DrawSelf( 0, 0, w, h, m_clrIcon );
  62. }
  63. }