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.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "baseentity.h"
  8. #include "tf_gamerules.h"
  9. #include "tf_team.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. class CTFHudNotify : public CPointEntity
  13. {
  14. public:
  15. DECLARE_CLASS( CTFHudNotify, CPointEntity );
  16. DECLARE_DATADESC();
  17. void InputDisplay( inputdata_t &inputdata );
  18. void Display( CBaseEntity *pActivator );
  19. private:
  20. string_t m_iszMessage;
  21. string_t m_iszIcon;
  22. int m_iRecipientTeam;
  23. int m_iBackgroundTeam;
  24. };
  25. LINK_ENTITY_TO_CLASS( game_text_tf, CTFHudNotify );
  26. BEGIN_DATADESC( CTFHudNotify )
  27. DEFINE_KEYFIELD( m_iszMessage, FIELD_STRING, "message" ),
  28. DEFINE_KEYFIELD( m_iszIcon, FIELD_STRING, "icon" ),
  29. DEFINE_KEYFIELD( m_iRecipientTeam, FIELD_INTEGER, "display_to_team" ),
  30. DEFINE_KEYFIELD( m_iBackgroundTeam, FIELD_INTEGER, "background" ),
  31. // Inputs
  32. DEFINE_INPUTFUNC( FIELD_VOID, "Display", InputDisplay ),
  33. END_DATADESC()
  34. void CTFHudNotify::InputDisplay( inputdata_t &inputdata )
  35. {
  36. Display( inputdata.pActivator );
  37. }
  38. void CTFHudNotify::Display( CBaseEntity *pActivator )
  39. {
  40. CBroadcastRecipientFilter filter;
  41. switch( m_iRecipientTeam )
  42. {
  43. case TF_TEAM_RED:
  44. filter.RemoveRecipientsByTeam( GetGlobalTeam(TF_TEAM_BLUE) );
  45. break;
  46. case TF_TEAM_BLUE:
  47. filter.RemoveRecipientsByTeam( GetGlobalTeam(TF_TEAM_RED) );
  48. break;
  49. }
  50. TFGameRules()->SendHudNotification( filter, STRING(m_iszMessage), STRING(m_iszIcon), m_iBackgroundTeam );
  51. }