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.

67 lines
1.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include "cbase.h"
  3. #include "hud_baseachievement_tracker.h"
  4. #include "c_cs_player.h"
  5. #include "iachievementmgr.h"
  6. // memdbgon must be the last include file in a .cpp file!!!
  7. #include "tier0/memdbgon.h"
  8. // The number of counter-strike HUD achievements to display
  9. const int cMaxCSHUDAchievments = 4;
  10. using namespace vgui;
  11. class CHudAchievementTracker : public CHudBaseAchievementTracker
  12. {
  13. DECLARE_CLASS_SIMPLE( CHudAchievementTracker, CHudBaseAchievementTracker );
  14. public:
  15. CHudAchievementTracker( const char *pElementName );
  16. virtual void OnThink();
  17. virtual void PerformLayout();
  18. virtual int GetMaxAchievementsShown();
  19. virtual bool ShouldShowAchievement( IAchievement *pAchievement );
  20. private:
  21. CPanelAnimationVarAliasType( int, m_iNormalY, "NormalY", "5", "proportional_int" );
  22. };
  23. DECLARE_HUDELEMENT( CHudAchievementTracker );
  24. CHudAchievementTracker::CHudAchievementTracker( const char *pElementName ) : BaseClass( pElementName )
  25. {
  26. RegisterForRenderGroup( "hide_for_scoreboard" );
  27. }
  28. void CHudAchievementTracker::OnThink()
  29. {
  30. BaseClass::OnThink();
  31. }
  32. int CHudAchievementTracker::GetMaxAchievementsShown()
  33. {
  34. return MIN( BaseClass::GetMaxAchievementsShown(), cMaxCSHUDAchievments );
  35. }
  36. void CHudAchievementTracker::PerformLayout()
  37. {
  38. BaseClass::PerformLayout();
  39. int x, y;
  40. GetPos( x, y );
  41. SetPos( x, m_iNormalY );
  42. }
  43. bool CHudAchievementTracker::ShouldShowAchievement( IAchievement *pAchievement )
  44. {
  45. if ( !BaseClass::ShouldShowAchievement(pAchievement) )
  46. return false;
  47. C_CSPlayer *pPlayer = CCSPlayer::GetLocalCSPlayer();
  48. if ( !pPlayer )
  49. return false;
  50. return true;
  51. }