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.

145 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef HUD_BASEDEATHNOTICE_H
  8. #define HUD_BASEDEATHNOTICE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. // Player entries in a death notice
  13. struct DeathNoticePlayer
  14. {
  15. DeathNoticePlayer()
  16. {
  17. szName[0] = 0;
  18. iTeam = TEAM_UNASSIGNED;
  19. }
  20. char szName[MAX_PLAYER_NAME_LENGTH*2]; // big enough for player name and additional information
  21. int iTeam; // team #
  22. };
  23. // Contents of each entry in our list of death notices
  24. struct DeathNoticeItem
  25. {
  26. DeathNoticeItem()
  27. {
  28. szIcon[0]=0;
  29. wzInfoText[0]=0;
  30. wzInfoTextEnd[0]=0;
  31. iconDeath = NULL;
  32. iconCritDeath = NULL;
  33. bSelfInflicted = false;
  34. bLocalPlayerInvolved = false;
  35. bCrit = false;
  36. flCreationTime = 0;
  37. iCount = 0;
  38. iWeaponID = -1;
  39. iKillerID = -1;
  40. iVictimID = -1;
  41. iconPreKillerName = NULL;
  42. iconPostKillerName = NULL;
  43. wzPreKillerText[0] = 0;
  44. iconPostVictimName = NULL;
  45. bSpecialScore = false;
  46. }
  47. float GetExpiryTime();
  48. DeathNoticePlayer Killer;
  49. DeathNoticePlayer Victim;
  50. char szIcon[32]; // name of icon to display
  51. wchar_t wzInfoText[32]; // any additional text to display next to icon
  52. wchar_t wzInfoTextEnd[32]; // any additional text to display next to victim name
  53. CHudTexture *iconDeath;
  54. CHudTexture *iconCritDeath; // crit background icon
  55. CHudTexture *iconPreKillerName;
  56. CHudTexture *iconPostKillerName;
  57. wchar_t wzPreKillerText[32];
  58. CHudTexture *iconPostVictimName;
  59. bool bSelfInflicted;
  60. bool bLocalPlayerInvolved;
  61. bool bCrit;
  62. float flCreationTime;
  63. int iWeaponID;
  64. int iKillerID;
  65. int iVictimID;
  66. int iCount;
  67. bool bSpecialScore;
  68. };
  69. #define NUM_CORNER_COORD 10
  70. #define NUM_BACKGROUND_COORD NUM_CORNER_COORD*4
  71. //-----------------------------------------------------------------------------
  72. // Purpose:
  73. //-----------------------------------------------------------------------------
  74. class CHudBaseDeathNotice : public CHudElement, public vgui::Panel
  75. {
  76. DECLARE_CLASS_SIMPLE( CHudBaseDeathNotice, vgui::Panel );
  77. public:
  78. CHudBaseDeathNotice( const char *pElementName );
  79. void VidInit( void );
  80. virtual void Init( void );
  81. virtual bool ShouldDraw( void );
  82. virtual void Paint( void );
  83. virtual void ApplySchemeSettings( vgui::IScheme *scheme );
  84. void RetireExpiredDeathNotices( void );
  85. virtual void FireGameEvent( IGameEvent *event );
  86. virtual bool ShouldShowDeathNotice( IGameEvent *event ){ return true; }
  87. protected:
  88. virtual Color GetTeamColor( int iTeamNumber, bool bLocalPlayerInvolved = false );
  89. virtual void OnGameEvent( IGameEvent *event, int iDeathNoticeMsg ) {};
  90. void DrawText( int x, int y, vgui::HFont hFont, Color clr, const wchar_t *szText );
  91. int AddDeathNoticeItem();
  92. void GetBackgroundPolygonVerts( int x0, int y0, int x1, int y1, int iVerts, vgui::Vertex_t vert[] );
  93. void CalcRoundedCorners();
  94. enum EDeathNoticeIconFormat
  95. {
  96. kDeathNoticeIcon_Standard,
  97. kDeathNoticeIcon_Inverted, // used for display on lighter background when kill involved the local player
  98. };
  99. CHudTexture *GetIcon( const char *szIcon, EDeathNoticeIconFormat eIconFormat );
  100. virtual bool EventIsPlayerDeath( const char *eventName );
  101. virtual int UseExistingNotice( IGameEvent *event );
  102. void GetLocalizedControlPointName( IGameEvent *event, char *namebuf, int namelen );
  103. virtual Color GetInfoTextColor( int iDeathNoticeMsg ){ return Color( 255, 255, 255, 255 ); }
  104. virtual Color GetBackgroundColor ( int iDeathNoticeMsg ) { return m_DeathNotices[iDeathNoticeMsg].bLocalPlayerInvolved ? m_clrLocalBGColor : m_clrBaseBGColor; }
  105. CPanelAnimationVarAliasType( float, m_flLineHeight, "LineHeight", "16", "proportional_float" );
  106. CPanelAnimationVarAliasType( float, m_flLineSpacing, "LineSpacing", "4", "proportional_float" );
  107. CPanelAnimationVarAliasType( float, m_flCornerRadius, "CornerRadius", "3", "proportional_float" );
  108. CPanelAnimationVar( float, m_flMaxDeathNotices, "MaxDeathNotices", "4" );
  109. CPanelAnimationVar( bool, m_bRightJustify, "RightJustify", "1" );
  110. CPanelAnimationVar( vgui::HFont, m_hTextFont, "TextFont", "Default" );
  111. CPanelAnimationVar( Color, m_clrIcon, "IconColor", "255 80 0 255" );
  112. CPanelAnimationVar( Color, m_clrBaseBGColor, "BaseBackgroundColor", "46 43 42 220" );
  113. CPanelAnimationVar( Color, m_clrLocalBGColor, "LocalBackgroundColor", "245 229 196 200" );
  114. CPanelAnimationVar( Color, m_clrKillStreakBg, "KillStreakBackgroundColor", "224 223 219 200" );
  115. CUtlVector<DeathNoticeItem> m_DeathNotices;
  116. Vector2D m_CornerCoord[NUM_CORNER_COORD];
  117. };
  118. #endif // HUD_BASEDEATHNOTICE_H