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.

113 lines
3.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef TF_PVP_RANK_PANEL_H
  7. #define TF_PVP_RANK_PANEL_H
  8. #include "cbase.h"
  9. #include "vgui_controls/EditablePanel.h"
  10. #include "tf_match_description.h"
  11. #include "GameEventListener.h"
  12. #include "local_steam_shared_object_listener.h"
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include <tier0/memdbgon.h>
  15. class CBaseModelPanel;
  16. namespace vgui
  17. {
  18. class ContinuousProgressBar;
  19. };
  20. namespace GCSDK
  21. {
  22. class CSharedObject;
  23. };
  24. using namespace GCSDK;
  25. class CPvPRankPanel : public vgui::EditablePanel, public CLocalSteamSharedObjectListener, public CGameEventListener
  26. {
  27. public:
  28. DECLARE_CLASS_SIMPLE( CPvPRankPanel, vgui::EditablePanel );
  29. CPvPRankPanel( Panel *parent, const char *panelName );
  30. virtual void ApplySchemeSettings( vgui::IScheme *pScheme ) OVERRIDE;
  31. virtual void ApplySettings( KeyValues *inResourceData ) OVERRIDE;
  32. virtual void PerformLayout() OVERRIDE;
  33. virtual void OnThink() OVERRIDE;
  34. virtual void OnCommand( const char *command ) OVERRIDE;
  35. virtual void FireGameEvent( IGameEvent *pEvent ) OVERRIDE;
  36. virtual void SetVisible( bool bVisible ) OVERRIDE;
  37. void SetMatchGroup( EMatchGroup eMatchGroup );
  38. void SetMatchStats( void );
  39. virtual void SOCreated( const CSteamID & steamIDOwner, const CSharedObject *pObject, ESOCacheEvent eEvent ) OVERRIDE;
  40. virtual void SOUpdated( const CSteamID & steamIDOwner, const CSharedObject *pObject, ESOCacheEvent eEvent ) OVERRIDE;
  41. MESSAGE_FUNC_PARAMS( OnAnimEvent, "AnimEvent", pParams );
  42. protected:
  43. virtual void PlayLevelUpEffects( const LevelInfo_t& level ) const;
  44. virtual void PlayLevelDownEffects( const LevelInfo_t& level ) const;
  45. private:
  46. struct XPState_t : public CGameEventListener, public CLocalSteamSharedObjectListener
  47. {
  48. XPState_t( EMatchGroup eMatchGroup );
  49. virtual void FireGameEvent( IGameEvent *pEvent ) OVERRIDE;
  50. // Get the current XP value
  51. uint32 GetCurrentXP() const;
  52. // Get the previous XP value before any changes occurred
  53. uint32 GetStartXP() const { return m_nStartXP; }
  54. // Get the target XP that the delta lerp is headed to
  55. uint32 GetTargetXP() const { return m_nTargetXP; }
  56. uint32 GetActualXP() const { return m_nActualXP; }
  57. // Start the timer that causes GetCurrentXP to lerp from m_nStartXP to m_nTargetXP
  58. bool BeginXPDeltaLerp();
  59. virtual void SOCreated( const CSteamID & steamIDOwner, const CSharedObject *pObject, ESOCacheEvent eEvent ) OVERRIDE;
  60. virtual void SOUpdated( const CSteamID & steamIDOwner, const CSharedObject *pObject, ESOCacheEvent eEvent ) OVERRIDE;
  61. private:
  62. void UpdateXP( bool bInitial );
  63. const EMatchGroup m_eMatchGroup;
  64. uint32 m_nStartXP; // The XP we show to the user that was the last state they saw
  65. uint32 m_nTargetXP; // The XP the user believes is their current value
  66. uint32 m_nActualXP; // The actual latest XP value
  67. RealTimeCountdownTimer m_progressTimer;
  68. bool m_bCurrentDeltaViewed;
  69. };
  70. XPState_t& GetXPState() const;
  71. void UpdateControls( uint32 nPreviousXP, uint32 nCurrentXP, const LevelInfo_t& levelCurrent );
  72. void UpdateBaseState();
  73. virtual const char* GetResFile() const;
  74. virtual KeyValues* GetConditions() const;
  75. void BeginXPLerp();
  76. EMatchGroup m_eMatchGroup;
  77. vgui::ContinuousProgressBar* m_pContinuousProgressBar;
  78. vgui::EditablePanel* m_pXPBar;
  79. CBaseModelPanel* m_pModelPanel;
  80. const IProgressionDesc* m_pProgressionDesc;
  81. EditablePanel* m_pBGPanel;
  82. bool m_bClicked;
  83. Panel* m_pModelButton;
  84. uint32 m_nLastLerpXP;
  85. uint32 m_nLastSeenLevel;
  86. CPanelAnimationVarAliasType( int, m_iXPSourceNotificationCenterX, "xp_source_notification_center_x", "19", "proportional_int" );
  87. };
  88. #endif //TF_PVP_RANK_PANEL_H