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.

218 lines
6.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CSACHIEVEMENTSPAGE_H
  8. #define CSACHIEVEMENTSPAGE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "vgui_controls/PanelListPanel.h"
  13. #include "vgui_controls/Label.h"
  14. #include "tier1/KeyValues.h"
  15. #include "vgui_controls/PropertyPage.h"
  16. #include "vgui_controls/Button.h"
  17. #include "c_cs_player.h"
  18. #include "vgui_avatarimage.h"
  19. #include "GameEventListener.h"
  20. class CCSBaseAchievement;
  21. class IScheme;
  22. class CAchievementsPageGroupPanel;
  23. class StatCard;
  24. #define ACHIEVED_ICON_PATH "hud/icon_check.vtf"
  25. #define LOCK_ICON_PATH "hud/icon_locked.vtf"
  26. // Loads an achievement's icon into a specified image panel, or turns the panel off if no achievement icon was found.
  27. bool CSLoadAchievementIconForPage( vgui::ImagePanel* pIconPanel, CCSBaseAchievement *pAchievement, const char *pszExt = NULL );
  28. // Loads an achievement's icon into a specified image panel, or turns the panel off if no achievement icon was found.
  29. bool CSLoadIconForPage( vgui::ImagePanel* pIconPanel, const char* pFilename, const char *pszExt = NULL );
  30. // Updates a listed achievement item's progress bar.
  31. void CSUpdateProgressBarForPage( vgui::EditablePanel* pPanel, CCSBaseAchievement *pAchievement, Color clrProgressBar );
  32. ////////////////////////////////////////////////////////////////////////////
  33. // PC version
  34. //////////////////////////////////////////////////////////////////////////
  35. class CAchievementsPage : public vgui::PropertyPage, public CGameEventListener
  36. {
  37. DECLARE_CLASS_SIMPLE ( CAchievementsPage, vgui::PropertyPage );
  38. public:
  39. CAchievementsPage( vgui::Panel *parent, const char *name );
  40. ~CAchievementsPage();
  41. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  42. void UpdateTotalProgressDisplay();
  43. virtual void UpdateAchievementDialogInfo( void );
  44. virtual void OnPageShow();
  45. virtual void OnThink();
  46. virtual void ApplySettings( KeyValues *pResourceData );
  47. virtual void OnSizeChanged( int newWide, int newTall );
  48. virtual void FireGameEvent( IGameEvent *event );
  49. void CreateNewAchievementGroup( int iMinRange, int iMaxRange );
  50. void CreateOrUpdateComboItems( bool bCreate );
  51. void UpdateAchievementList(CAchievementsPageGroupPanel* groupPanel);
  52. void UpdateAchievementList(int minID, int maxID);
  53. vgui::PanelListPanel *m_pAchievementsList;
  54. vgui::ImagePanel *m_pListBG;
  55. vgui::PanelListPanel *m_pGroupsList;
  56. vgui::ImagePanel *m_pGroupListBG;
  57. vgui::ImagePanel *m_pPercentageBarBackground;
  58. vgui::ImagePanel *m_pPercentageBar;
  59. StatCard* m_pStatCard;
  60. int m_iFixedWidth;
  61. bool m_bStatsDirty;
  62. bool m_bAchievementsDirty;
  63. typedef struct
  64. {
  65. int m_iMinRange;
  66. int m_iMaxRange;
  67. } achievement_group_t;
  68. int m_iNumAchievementGroups;
  69. achievement_group_t m_AchievementGroups[15];
  70. };
  71. class CHiddenHUDToggleButton : public vgui::Button
  72. {
  73. DECLARE_CLASS_SIMPLE( CHiddenHUDToggleButton, vgui::Button );
  74. public:
  75. CHiddenHUDToggleButton( vgui::Panel *pParent, const char *pName, const char *pText );
  76. virtual void DoClick( void );
  77. };
  78. //////////////////////////////////////////////////////////////////////////
  79. // Individual item panel, displaying stats for one achievement
  80. class CAchievementsPageItemPanel : public vgui::EditablePanel
  81. {
  82. DECLARE_CLASS_SIMPLE( CAchievementsPageItemPanel, vgui::EditablePanel );
  83. public:
  84. CAchievementsPageItemPanel( vgui::PanelListPanel *parent, const char* name);
  85. ~CAchievementsPageItemPanel();
  86. void SetAchievementInfo ( CCSBaseAchievement* pAchievement );
  87. CCSBaseAchievement* GetAchievementInfo( void ) { return m_pSourceAchievement; }
  88. void UpdateAchievementInfo( vgui::IScheme *pScheme );
  89. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  90. void ToggleShowOnHUDButton();
  91. MESSAGE_FUNC_PTR( OnCheckButtonChecked, "CheckButtonChecked", panel );
  92. private:
  93. static void PreloadResourceFile();
  94. CCSBaseAchievement* m_pSourceAchievement;
  95. int m_iSourceAchievementIndex;
  96. vgui::PanelListPanel *m_pParent;
  97. vgui::Label *m_pAchievementNameLabel;
  98. vgui::Label *m_pAchievementDescLabel;
  99. vgui::Label *m_pPercentageText;
  100. vgui::Label *m_pAwardDate;
  101. vgui::ImagePanel *m_pLockedIcon;
  102. vgui::ImagePanel *m_pAchievementIcon;
  103. vgui::ImagePanel *m_pPercentageBarBackground;
  104. vgui::ImagePanel *m_pPercentageBar;
  105. vgui::CheckButton *m_pShowOnHUDButton;
  106. vgui::IScheme *m_pSchemeSettings;
  107. CHiddenHUDToggleButton *m_pHiddenHUDToggleButton;
  108. CPanelAnimationVar( Color, m_clrProgressBar, "ProgressBarColor", "140 140 140 255" );
  109. };
  110. class CGroupButton : public vgui::Button
  111. {
  112. DECLARE_CLASS_SIMPLE( CGroupButton, vgui::Button );
  113. public:
  114. CGroupButton( vgui::Panel *pParent, const char *pName, const char *pText );
  115. virtual void DoClick( void );
  116. };
  117. //////////////////////////////////////////////////////////////////////////
  118. // Individual achievement group panel, displaying info for one achievement group
  119. class CAchievementsPageGroupPanel : public vgui::EditablePanel
  120. {
  121. DECLARE_CLASS_SIMPLE( CAchievementsPageGroupPanel, vgui::EditablePanel );
  122. public:
  123. CAchievementsPageGroupPanel( vgui::PanelListPanel *parent, CAchievementsPage *owner, const char* name, int iListItemID );
  124. ~CAchievementsPageGroupPanel();
  125. void SetGroupInfo ( const wchar_t* name, int firstAchievementID, int lastAchievementID );
  126. void UpdateAchievementInfo( vgui::IScheme *pScheme );
  127. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  128. int GetFirstAchievementID() { return m_iFirstAchievementID; }
  129. int GetLastAchievementID() { return m_iLastAchievementID; }
  130. vgui::PanelListPanel* GetParent() { return m_pParent; }
  131. CAchievementsPage* GetOwner() { return m_pOwner; }
  132. void SetGroupActive(bool active) { m_bActiveButton = active; }
  133. bool IsGroupActive() { return m_bActiveButton; }
  134. private:
  135. void PreloadResourceFile( void );
  136. vgui::PanelListPanel *m_pParent;
  137. CAchievementsPage *m_pOwner;
  138. vgui::Label *m_pAchievementGroupLabel;
  139. vgui::Label *m_pPercentageText;
  140. CGroupButton *m_pGroupButton;
  141. vgui::ImagePanel *m_pGroupIcon;
  142. vgui::ImagePanel *m_pPercentageBarBackground;
  143. vgui::ImagePanel *m_pPercentageBar;
  144. vgui::IScheme *m_pSchemeSettings;
  145. bool m_bActiveButton;
  146. CPanelAnimationVar( Color, m_clrProgressBar, "ProgressBarColor", "140 140 140 255" );
  147. int m_iFirstAchievementID;
  148. int m_iLastAchievementID;
  149. wchar_t *m_pGroupName;
  150. };
  151. #endif // CSACHIEVEMENTSPAGE_H