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.

65 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "hud_base_account.h"
  8. #include "c_cs_player.h"
  9. #include "clientmode_csnormal.h"
  10. using namespace vgui;
  11. class CHudAccount : public CHudBaseAccount
  12. {
  13. public:
  14. DECLARE_CLASS_SIMPLE( CHudAccount, CHudBaseAccount );
  15. CHudAccount( const char *name );
  16. virtual bool ShouldDraw();
  17. virtual int GetPlayerAccount( void );
  18. virtual vgui::AnimationController *GetAnimationController( void );
  19. };
  20. DECLARE_HUDELEMENT( CHudAccount );
  21. CHudAccount::CHudAccount( const char *pName ) :
  22. CHudBaseAccount( "HudAccount" )
  23. {
  24. SetHiddenBits( HIDEHUD_PLAYERDEAD );
  25. SetIndent( false ); // don't indent small numbers in the drawing code - we're doing it manually
  26. }
  27. bool CHudAccount::ShouldDraw()
  28. {
  29. C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
  30. if ( pPlayer )
  31. {
  32. return !pPlayer->IsObserver();
  33. }
  34. else
  35. {
  36. return false;
  37. }
  38. }
  39. // How much money does the player have
  40. int CHudAccount::GetPlayerAccount( void )
  41. {
  42. C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
  43. if( !pPlayer )
  44. return 0;
  45. return (int)pPlayer->GetAccount();
  46. }
  47. vgui::AnimationController *CHudAccount::GetAnimationController( void )
  48. {
  49. vgui::AnimationController *pController = g_pClientMode->GetViewportAnimationController();
  50. Assert( pController );
  51. return pController;
  52. }