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.

248 lines
9.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_MATCH_SUMMARY_H
  8. #define TF_MATCH_SUMMARY_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "hudelement.h"
  13. #include <vgui_controls/EditablePanel.h>
  14. #include <vgui_controls/SectionedListPanel.h>
  15. #include "tf_imagepanel.h"
  16. #include "econ_controls.h"
  17. #include "drawing_panel.h"
  18. #include "tf_particlepanel.h"
  19. #include "tf_matchmaking_shared.h"
  20. #include "tf_gamerules.h"
  21. #include "tf_match_join_handlers.h"
  22. using namespace vgui;
  23. class CAvatarImagePanel;
  24. class CTFBadgePanel;
  25. enum matchsummary_displaystate_t
  26. {
  27. MS_STATE_INITIAL = 0,
  28. MS_STATE_DRAWING,
  29. MS_STATE_STATS,
  30. MS_STATE_BRONZE_MEDALS,
  31. MS_STATE_SILVER_MEDALS,
  32. MS_STATE_GOLD_MEDALS,
  33. MS_STATE_FINAL,
  34. MS_NUM_STATES
  35. };
  36. enum matchsummary_columns_t
  37. {
  38. MS_COLUMN_INVALID = -1,
  39. MS_COLUMN_MEDAL = 0,
  40. MS_COLUMN_AVATAR,
  41. MS_COLUMN_SPACER,
  42. MS_COLUMN_NAME,
  43. MS_COLUMN_CLASS,
  44. MS_COLUMN_SCORE,
  45. MS_COLUMN_SCORE_MEDAL,
  46. MS_COLUMN_KILLS,
  47. MS_COLUMN_KILLS_MEDAL,
  48. MS_COLUMN_DAMAGE,
  49. MS_COLUMN_DAMAGE_MEDAL,
  50. MS_COLUMN_HEALING,
  51. MS_COLUMN_HEALING_MEDAL,
  52. MS_COLUMN_SUPPORT,
  53. MS_COLUMN_SUPPORT_MEDAL,
  54. MS_NUM_COLUMNS
  55. };
  56. class TFSectionedListPanel : public vgui::SectionedListPanel
  57. {
  58. private:
  59. DECLARE_CLASS_SIMPLE( TFSectionedListPanel, vgui::SectionedListPanel );
  60. public:
  61. TFSectionedListPanel( Panel *parent, const char *panelName ) : BaseClass( parent, panelName ){}
  62. virtual ~TFSectionedListPanel(){}
  63. CPanelAnimationVarAliasType( int, m_iMedalWidth, "medal_width", "s.05", "proportional_width" );
  64. CPanelAnimationVarAliasType( int, m_iAvatarWidth, "avatar_width", "s.1", "proportional_width" ); // Avatar width doesn't scale with resolution
  65. CPanelAnimationVarAliasType( int, m_iSpacerWidth, "spacer", "s.1", "proportional_width" );
  66. CPanelAnimationVarAliasType( int, m_iNameWidth, "name_width", "s.1", "proportional_width" );
  67. CPanelAnimationVarAliasType( int, m_iClassWidth, "class_width", "s.1", "proportional_width" );
  68. CPanelAnimationVarAliasType( int, m_iAwardWidth, "award_width", "s.1", "proportional_width" );
  69. CPanelAnimationVarAliasType( int, m_iStatsWidth, "stats_width", "s.1", "proportional_width" );
  70. CPanelAnimationVarAliasType( int, m_iHorizFillInset, "horiz_inset", "5", "proportional_int" );
  71. };
  72. class CTFMatchSummary : public CHudElement, public vgui::EditablePanel
  73. {
  74. private:
  75. DECLARE_CLASS_SIMPLE( CTFMatchSummary, vgui::EditablePanel );
  76. public:
  77. CTFMatchSummary( const char *pElementName );
  78. virtual ~CTFMatchSummary();
  79. virtual bool ShouldDraw( void ) OVERRIDE;
  80. virtual void ApplySchemeSettings( vgui::IScheme *pScheme ) OVERRIDE;
  81. virtual void PerformLayout() OVERRIDE;
  82. virtual void SetVisible( bool state ) OVERRIDE;
  83. virtual void OnTick() OVERRIDE;
  84. virtual void LevelInit( void ) OVERRIDE;
  85. virtual void LevelShutdown( void ) OVERRIDE;
  86. virtual GameActionSet_t GetPreferredActionSet() OVERRIDE { return GAME_ACTION_SET_IN_GAME_HUD; }
  87. virtual void FireGameEvent( IGameEvent *event ) OVERRIDE;
  88. bool ShowPerformanceMedals( void );
  89. private:
  90. void Update( void );
  91. void InitPlayerList( TFSectionedListPanel *pPlayerList, int nTeam );
  92. static bool TFPlayerSortFunc( vgui::SectionedListPanel *list, int itemID1, int itemID2 );
  93. void UpdateTeamInfo();
  94. void UpdatePlayerList();
  95. void UpdatePlayerAvatar( int playerIndex, KeyValues *kv );
  96. void RecalculateMedalCounts();
  97. void UpdateBadgePanels( CUtlVector<CTFBadgePanel*> &pBadgePanels, TFSectionedListPanel *pPlayerList );
  98. void InternalUpdateMedalCountForType( int iTeam, StatMedal_t eMedal );
  99. matchsummary_columns_t InternalAddMedalKeyValues( int iIndex, StatMedal_t eMedal, KeyValues *pKeyValues, int nTotalMedals = -1 );
  100. void FireMedalEffects( Panel *pPanel, int nPanelXPos, int nPanelYPos, int nPanelWide, int nPanelTall, StatMedal_t eParticleMedal );
  101. private:
  102. EditablePanel *m_pTeamScoresPanel;
  103. int m_iImageClass[SCOREBOARD_CLASS_ICONS];
  104. int m_iImageClassAlt[SCOREBOARD_CLASS_ICONS];
  105. int m_iImageMedals[StatMedal_Max];
  106. CDrawingPanel *m_pDrawingPanel;
  107. vgui::EditablePanel *m_pBlueTeamPanel;
  108. vgui::EditablePanel *m_pRedTeamPanel;
  109. vgui::EditablePanel *m_pMainStatsContainer;
  110. vgui::EditablePanel *m_pPlayerListBlueParent;
  111. TFSectionedListPanel *m_pPlayerListBlue;
  112. vgui::EditablePanel *m_pPlayerListRedParent;
  113. TFSectionedListPanel *m_pPlayerListRed;
  114. CExLabel *m_pBlueTeamScore;
  115. CExLabel *m_pBlueTeamScoreDropshadow;
  116. EditablePanel *m_pBlueTeamScoreBG;
  117. EditablePanel *m_pBluePlayerListBG;
  118. CExLabel *m_pRedTeamScore;
  119. CExLabel *m_pRedTeamScoreDropshadow;
  120. EditablePanel *m_pRedTeamScoreBG;
  121. EditablePanel *m_pRedPlayerListBG;
  122. EditablePanel *m_pBlueMedalsPanel;
  123. EditablePanel *m_pRedMedalsPanel;
  124. vgui::ImagePanel *m_pRedTeamImage;
  125. vgui::ImagePanel *m_pBlueTeamImage;
  126. CAvatarImagePanel *m_pRedLeaderAvatarImage;
  127. CAvatarImagePanel *m_pBlueLeaderAvatarImage;
  128. EditablePanel *m_pRedLeaderAvatarBG;
  129. EditablePanel *m_pBlueLeaderAvatarBG;
  130. EditablePanel *m_pStatsLabelPanel;
  131. CExLabel *m_pStatsAndMedals;
  132. CExLabel *m_pStatsAndMedalsShadow;
  133. CExLabel *m_pBlueTeamName;
  134. CExLabel *m_pRedTeamName;
  135. CExLabel *m_pRedTeamWinner;
  136. CExLabel *m_pRedTeamWinnerDropshadow;
  137. CExLabel *m_pBlueTeamWinner;
  138. CExLabel *m_pBlueTeamWinnerDropshadow;
  139. CTFParticlePanel *m_pParticlePanel;
  140. vgui::EditablePanel *m_pStatsBgPanel;
  141. vgui::ImageList *m_pImageList;
  142. CUtlMap<CSteamID,int> m_mapAvatarsToImageList;
  143. vgui::HFont m_hFont;
  144. bool m_bLargeMatchGroup;
  145. bool m_bXPShown;
  146. float m_flDrawingPanelTime;
  147. CPanelAnimationVar( Color, m_clrGoldMedal, "GoldMedalText", "214 186 24 255" );
  148. CPanelAnimationVar( Color, m_clrSilverMedal, "SilverMedalText", "222 218 222 255" );
  149. CPanelAnimationVar( Color, m_clrBronzeMedal, "BronzeMedalText", "214 125 57 255" );
  150. CPanelAnimationVarAliasType( int, m_iAnimBluePlayerListParent, "AnimBluePlayerListParent", "0", "proportional_width" );
  151. CPanelAnimationVarAliasType( int, m_iAnimBlueTeamScore, "AnimBlueTeamScore", "0", "proportional_width" );
  152. CPanelAnimationVarAliasType( int, m_iAnimBlueTeamScoreDropshadow, "AnimBlueTeamScoreDropshadow", "0", "proportional_width" );
  153. CPanelAnimationVarAliasType( int, m_iAnimBlueTeamScoreBG, "AnimBlueTeamScoreBG", "0", "proportional_width" );
  154. CPanelAnimationVarAliasType( int, m_iAnimBluePlayerListBG, "AnimBluePlayerListBG", "0", "proportional_width" );
  155. CPanelAnimationVarAliasType( int, m_iAnimRedTeamScoreBGWide, "AnimRedTeamScoreBGWide", "0", "proportional_width" );
  156. CPanelAnimationVarAliasType( int, m_iAnimRedTeamScoreBGXPos, "AnimRedTeamScoreBGXPos", "0", "proportional_xpos" );
  157. CPanelAnimationVarAliasType( int, m_iAnimRedTeamScoreWide, "AnimRedTeamScoreWide", "0", "proportional_width" );
  158. CPanelAnimationVarAliasType( int, m_iAnimRedTeamScoreXPos, "AnimRedTeamScoreXPos", "0", "proportional_xpos" );
  159. CPanelAnimationVarAliasType( int, m_iAnimRedTeamScoreDropshadowWide, "AnimRedTeamScoreDropshadowWide", "0", "proportional_width" );
  160. CPanelAnimationVarAliasType( int, m_iAnimRedTeamScoreDropshadowXPos, "AnimRedTeamScoreDropshadowXPos", "0", "proportional_xpos" );
  161. CPanelAnimationVarAliasType( int, m_iAnimRedPlayerListParentWide, "AnimRedPlayerListParentWide", "0", "proportional_width" );
  162. CPanelAnimationVarAliasType( int, m_iAnimRedPlayerListParentXPos, "AnimRedPlayerListParentXPos", "0", "proportional_xpos" );
  163. CPanelAnimationVarAliasType( int, m_iAnimRedPlayerListBGWide, "AnimRedPlayerListBGWide", "0", "proportional_width" );
  164. CPanelAnimationVarAliasType( int, m_iAnimRedPlayerListBGXPos, "AnimRedPlayerListBGXPos", "0", "proportional_xpos" );
  165. CPanelAnimationVarAliasType( int, m_iAnimBlueMedalsYPos, "AnimBlueMedalsYPos", "0", "proportional_ypos" );
  166. CPanelAnimationVarAliasType( int, m_iAnimRedMedalsYPos, "AnimRedMedalsYPos", "0", "proportional_ypos" );
  167. CPanelAnimationVarAliasType( int, m_iAnimStatsLabelPanel6v6YPos, "AnimStatsLabelPanel6v6YPos", "0", "proportional_ypos" );
  168. CPanelAnimationVarAliasType( int, m_iAnimBlueTeamLabel6v6YPos, "AnimBlueTeamLabel6v6YPos", "0", "proportional_ypos" );
  169. CPanelAnimationVarAliasType( int, m_iAnimRedTeamLabel6v6YPos, "AnimRedTeamLabel6v6YPos", "0", "proportional_ypos" );
  170. CPanelAnimationVarAliasType( int, m_iAnimStatsLabelPanel12v12YPos, "AnimStatsLabelPanel12v12YPos", "0", "proportional_ypos" );
  171. CPanelAnimationVarAliasType( int, m_iAnimBlueTeamLabel12v12YPos, "AnimBlueTeamLabel12v12YPos", "0", "proportional_ypos" );
  172. CPanelAnimationVarAliasType( int, m_iAnimRedTeamLabel12v12YPos, "AnimRedTeamLabel12v12YPos", "0", "proportional_ypos" );
  173. CPanelAnimationVarAliasType( int, m_iAnimStatsContainer12v12YPos, "AnimStatsContainer12v12YPos", "0", "proportional_ypos" );
  174. struct MatchDataUpdate_t
  175. {
  176. uint32 unRating;
  177. int nDelta;
  178. int nScoreRank;
  179. int nKillsRank;
  180. int nDamageRank;
  181. int nHealingRank;
  182. int nSupportRank;
  183. };
  184. MatchDataUpdate_t m_SkillRatings[MAX_PLAYERS + 1];
  185. int m_iCurrentState;
  186. float m_flNextActionTime;
  187. int m_nMedalsToAward_Bronze_Blue;
  188. int m_nMedalsToAward_Silver_Blue;
  189. int m_nMedalsToAward_Gold_Blue;
  190. int m_nMedalsToAward_Bronze_Red;
  191. int m_nMedalsToAward_Silver_Red;
  192. int m_nMedalsToAward_Gold_Red;
  193. int m_nMedalsRevealed;
  194. int m_nNumMedalsThisUpdate;
  195. bool m_bBlueGoldValueRevealed;
  196. bool m_bBlueSilverValueRevealed;
  197. bool m_bBlueBronzeValueRevealed;
  198. bool m_bRedGoldValueRevealed;
  199. bool m_bRedSilverValueRevealed;
  200. bool m_bRedBronzeValueRevealed;
  201. bool m_bPlayerAbandoned;
  202. float m_flMedalSoundTime;
  203. CUtlVector< CTFBadgePanel* > m_pBlueBadgePanels;
  204. CUtlVector< CTFBadgePanel* > m_pRedBadgePanels;
  205. };
  206. #endif //TF_MATCH_SUMMARY_H