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.

109 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TFSTATPANEL_H
  8. #define TFSTATPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/EditablePanel.h>
  13. #include <game/client/iviewport.h>
  14. #include <vgui/IScheme.h>
  15. #include "hud.h"
  16. #include "hudelement.h"
  17. #include "../game/shared/tf/tf_shareddefs.h"
  18. #include "../game/shared/tf/tf_gamestats_shared.h"
  19. #include "tf_hud_playerstatus.h"
  20. #include "tf_hud_arena_class_layout.h"
  21. using namespace vgui;
  22. enum PlayerStatsVersions_t
  23. {
  24. PLAYERSTATS_FILE_VERSION
  25. };
  26. enum RecordBreakType_t
  27. {
  28. RECORDBREAK_NONE,
  29. RECORDBREAK_CLOSE,
  30. RECORDBREAK_TIE,
  31. RECORDBREAK_BEST,
  32. RECORDBREAK_MAX
  33. };
  34. class CTFStatPanel : public EditablePanel, public CHudElement
  35. {
  36. private:
  37. DECLARE_CLASS_SIMPLE( CTFStatPanel, EditablePanel );
  38. public:
  39. CTFStatPanel( const char *pElementName );
  40. virtual ~CTFStatPanel();
  41. virtual void Reset();
  42. virtual void Init();
  43. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  44. virtual void ApplySettings( KeyValues *inResourceData );
  45. virtual void FireGameEvent( IGameEvent * event );
  46. virtual void OnTick();
  47. virtual void LevelShutdown();
  48. void Show();
  49. void Hide();
  50. virtual bool ShouldDraw( void );
  51. void ShowStatPanel( int iClass, int iTeam, int iCurStatValue, TFStatType_t statType, RecordBreakType_t recordBreakType,
  52. bool bAlive );
  53. void TestStatPanel( TFStatType_t statType, RecordBreakType_t recordType );
  54. void WriteStats( void );
  55. bool ReadStats( void );
  56. int CalcCRC( int iSteamID );
  57. void ClearStatsInMemory( void );
  58. void ResetStats( void );
  59. static ClassStats_t &GetClassStats( int iClass );
  60. static MapStats_t &GetMapStats( map_identifier_t iMapID );
  61. static bool IsValidMapID( map_identifier_t iMapID );
  62. static const char* GetMapNameFromID( map_identifier_t iMapID );
  63. static float GetTotalHoursPlayed( void ); // Return the total time this player has played the game, in hours
  64. void UpdateStatSummaryPanel();
  65. bool IsLocalFileTrusted() { return m_bLocalFileTrusted; }
  66. void SetStatsChanged( bool bChanged ) { m_bStatsChanged = bChanged; }
  67. void MsgFunc_PlayerStatsUpdate( bf_read &msg );
  68. void MsgFunc_MapStatsUpdate( bf_read &msg );
  69. virtual int GetRenderGroupPriority() { return 40; } // less than winpanel, build menu
  70. private:
  71. void GetStatValueAsString( int iValue, TFStatType_t statType, char *value, int valuelen );
  72. void UpdateStats( int iClass, const RoundStats_t &stats, bool bAlive );
  73. void UpdateMapStats( map_identifier_t iMapID, const RoundMapStats_t &stats );
  74. void ResetDisplayedStat();
  75. int m_iCurStatValue; // the value of the currently displayed stat
  76. int m_iCurStatClass; // the player class for current stat
  77. int m_iCurStatTeam; // the team of current stat
  78. TFStatType_t m_statType; // type of current stat
  79. RecordBreakType_t m_recordBreakType; // was record broken, tied, or just close
  80. bool m_bDisplayAfterSpawn; // should we display after player respawns
  81. float m_flTimeLastSpawn;
  82. float m_flTimeHide; // time at which to hide the panel
  83. CUtlVector<ClassStats_t> m_aClassStats;
  84. CUtlVector<MapStats_t> m_aMapStats;
  85. bool m_bStatsChanged;
  86. bool m_bLocalFileTrusted; // do we believe our local stats data file has not been tampered with
  87. CTFClassImage *m_pClassImage;
  88. bool m_bShouldBeVisible;
  89. };
  90. CTFStatPanel *GetStatPanel();
  91. #endif //TFSTATPANEL_H