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.

142 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #ifndef TF_STATSSUMMARY_H
  8. #define TF_STATSSUMMARY_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tf_hud_statpanel.h"
  13. #include "GameEventListener.h"
  14. struct ClassDetails_t
  15. {
  16. TFStatType_t statType; // type of stat
  17. uint iFlagsClass; // bit mask of classes to show this stat for
  18. const char * szResourceName; // name of label resource (format "Most damage:"
  19. const char * szAltResourceName; // name of alternative label resource "damage"
  20. };
  21. extern ClassDetails_t g_PerClassStatDetails[15];
  22. #define MAKESTATFLAG(x) ( 1 << x )
  23. #define ALL_CLASSES 0xFFFFFFFF
  24. class CTFStatsSummaryPanel : public vgui::EditablePanel, public CGameEventListener
  25. {
  26. private:
  27. DECLARE_CLASS_SIMPLE( CTFStatsSummaryPanel, vgui::EditablePanel );
  28. public:
  29. CTFStatsSummaryPanel();
  30. CTFStatsSummaryPanel( vgui::Panel *parent );
  31. ~CTFStatsSummaryPanel();
  32. void Init( void );
  33. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  34. virtual void OnCommand( const char *command );
  35. virtual void OnKeyCodePressed( KeyCode code );
  36. virtual void PerformLayout();
  37. virtual void OnThink();
  38. void SetStats( CUtlVector<ClassStats_t> &vecClassStats );
  39. void ShowModal();
  40. void SetupForEmbedded( void );
  41. void OnMapLoad( const char *pMapName );
  42. virtual void FireGameEvent( IGameEvent *event );
  43. private:
  44. MESSAGE_FUNC( OnActivate, "activate" );
  45. MESSAGE_FUNC( OnDeactivate, "deactivate" );
  46. enum StatDisplay_t
  47. {
  48. SHOW_MAX = 1,
  49. SHOW_TOTAL,
  50. SHOW_AVG
  51. };
  52. void Reset();
  53. void SetDefaultSelections();
  54. void UpdateDialog();
  55. void UpdateBarCharts();
  56. void UpdateClassDetails( bool bIsMVM = false );
  57. void UpdateTip();
  58. void UpdateControls();
  59. void ClearMapLabel();
  60. void ShowMapInfo( bool bShowMapInfo, bool bIsMVM = false, bool bBackgroundOverride = false );
  61. void UpdateLeaderboard();
  62. void InitBarChartComboBox( vgui::ComboBox *pComboBox );
  63. void SetValueAsClass( const char *pDialogVariable, int iValue, int iPlayerClass );
  64. void DisplayBarValue( int iChart, int iClass, ClassStats_t &stats, TFStatType_t statType, StatDisplay_t flags, float flMaxValue );
  65. static float GetDisplayValue( ClassStats_t &stats, TFStatType_t statType, StatDisplay_t statDisplay );
  66. const char *RenderValue( float flValue, TFStatType_t statType, StatDisplay_t statDisplay );
  67. static float SafeCalcFraction( float flNumerator, float flDemoninator );
  68. static int __cdecl CompareClassStats( const ClassStats_t *pStats0, const ClassStats_t *pStats1 );
  69. MESSAGE_FUNC( DoResetStats, "DoResetStats" );
  70. MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", data );
  71. vgui::EditablePanel *m_pPlayerData;
  72. vgui::EditablePanel *m_pInteractiveHeaders;
  73. vgui::EditablePanel *m_pNonInteractiveHeaders;
  74. vgui::ComboBox *m_pBarChartComboBoxA;
  75. vgui::ComboBox *m_pBarChartComboBoxB;
  76. vgui::ComboBox *m_pClassComboBox;
  77. CTFImagePanel *m_pTipImage;
  78. vgui::Label *m_pTipText;
  79. vgui::EditablePanel *m_pMapInfoPanel;
  80. vgui::Panel *m_pLeaderboardTitle;
  81. vgui::ImagePanel *m_pMainBackground;
  82. void UpdateMainBackground( void );
  83. vgui::EditablePanel *m_pContributedPanel;
  84. #ifdef _X360
  85. CTFFooter *m_pFooter;
  86. #else
  87. vgui::Button *m_pNextTipButton;
  88. vgui::Button *m_pCloseButton;
  89. vgui::Button *m_pResetStatsButton;
  90. #endif
  91. bool m_bInteractive; // are we in interactive mode
  92. bool m_bEmbedded; // are we embedded in a property sheet?
  93. bool m_bControlsLoaded; // have we loaded controls yet
  94. CUtlVector<ClassStats_t> m_aClassStats; // stats data
  95. int m_xStartLHBar; // x min of bars in left hand bar chart
  96. int m_xStartRHBar; // x min of bars in right hand bar chart
  97. int m_iBarMaxWidth; // width of bars in bar charts
  98. int m_iBarHeight; // height of bars in bar charts
  99. int m_iSelectedClass; // what class is selected, if any
  100. int m_iTotalSpawns; // how many spawns of all classes does this player have
  101. TFStatType_t m_statBarGraph[2]; // what stat is displayed in the left hand and right hand bar graphs
  102. StatDisplay_t m_displayBarGraph[2]; // the display type for the left hand and right hand bar graphs
  103. bool m_bShowingLeaderboard;
  104. bool m_bLoadingCommunityMap;
  105. int m_xStartLeaderboard;
  106. int m_yStartLeaderboard;
  107. CUtlVector< vgui::EditablePanel* > m_vecLeaderboardEntries;
  108. #ifdef _X360
  109. bool m_bShowBackButton;
  110. #endif
  111. };
  112. CTFStatsSummaryPanel *GStatsSummaryPanel();
  113. void DestroyStatsSummaryPanel();
  114. const char *FormatSeconds( int seconds );
  115. void UpdateStatSummaryPanels( CUtlVector<ClassStats_t> &vecClassStats );
  116. #endif // TF_STATSSUMMARY_H