Counter Strike : Global Offensive Source Code
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.

117 lines
4.0 KiB

  1. #ifndef HUD_ACHIEVEMENT_TRACKER_H
  2. #define HUD_ACHIEVEMENT_TRACKER_H
  3. #ifdef _WIN32
  4. #pragma once
  5. #endif
  6. #include "hudelement.h"
  7. #include <vgui_controls/EditablePanel.h>
  8. class IAchievement;
  9. namespace vgui
  10. {
  11. class ImagePanel;
  12. };
  13. //-----------------------------------------------------------------------------
  14. // Purpose: Draws information about one achievement (name, description, progress)
  15. //-----------------------------------------------------------------------------
  16. class CAchievementTrackerItem : public vgui::EditablePanel
  17. {
  18. DECLARE_CLASS_SIMPLE( CAchievementTrackerItem, vgui::EditablePanel );
  19. public:
  20. CAchievementTrackerItem( vgui::Panel* pParent, const char *pElementName );
  21. virtual ~CAchievementTrackerItem();
  22. virtual void ApplySchemeSettings( vgui::IScheme *scheme );
  23. virtual void SetAchievement( IAchievement* pAchievement );
  24. virtual void OnThink();
  25. virtual void SetSlot( int i ) { m_iSlot = i; }
  26. virtual void PerformLayout();
  27. virtual void AchievementIncremented( int iCount );
  28. virtual int GetAchievementID() { return m_iAchievementID; }
  29. virtual float GetGlow() { return m_flGlow; }
  30. virtual void ShowAccumulatedIncrements();
  31. virtual int GetLastCount() { return m_iLastCount; }
  32. virtual void UpdateAchievementDisplay();
  33. protected:
  34. vgui::Label *m_pAchievementName;
  35. vgui::Label *m_pAchievementNameGlow;
  36. vgui::Label *m_pAchievementDesc;
  37. vgui::ImagePanel *m_pProgressBarBackground;
  38. vgui::ImagePanel *m_pProgressBar;
  39. int m_iAchievementID;
  40. int m_iLastPaintedAchievementID;
  41. int m_iLastProgressBarGoal, m_iLastProgressBarCount, m_iLastCount;
  42. int m_iSlot;
  43. float m_flGlowTime;
  44. float m_flGlow;
  45. float m_flShowIncrementsTime;
  46. int m_iAccumulatedIncrement;
  47. CPanelAnimationVarAliasType( int, m_iPadding, "Padding", "1", "proportional_int" ); // space between description and bar
  48. };
  49. //---------------------------------------------------------------------------------------------
  50. // Purpose: Scrolls a floating number up the screen to indicate achievement progression
  51. //---------------------------------------------------------------------------------------------
  52. enum floating_number_directions
  53. {
  54. FN_DIR_UP,
  55. FN_DIR_DOWN,
  56. FN_DIR_LEFT,
  57. FN_DIR_RIGHT,
  58. };
  59. class CFloatingAchievementNumber : public vgui::EditablePanel
  60. {
  61. DECLARE_CLASS_SIMPLE( CFloatingAchievementNumber, vgui::EditablePanel );
  62. public:
  63. CFloatingAchievementNumber( int iProgress, int x, int y, floating_number_directions iDir, vgui::Panel* pParent );
  64. virtual ~CFloatingAchievementNumber();
  65. virtual void ApplySchemeSettings( vgui::IScheme *scheme );
  66. virtual void OnThink();
  67. protected:
  68. vgui::Label *m_pNumberLabel;
  69. int m_iStartX;
  70. int m_iStartY;
  71. int m_iProgress;
  72. float m_fStartTime;
  73. floating_number_directions m_iDirection;
  74. CPanelAnimationVarAliasType( int, m_iScrollDistance, "ScrollDistance", "40", "proportional_int" ); // how far the floating number will scroll up before disappearing completely
  75. };
  76. //-----------------------------------------------------------------------------
  77. // Purpose: Creates panels to show achievements on the HUD
  78. //-----------------------------------------------------------------------------
  79. class CHudBaseAchievementTracker : public CHudElement, public vgui::EditablePanel
  80. {
  81. DECLARE_CLASS_SIMPLE( CHudBaseAchievementTracker, vgui::EditablePanel );
  82. public:
  83. explicit CHudBaseAchievementTracker( const char *pElementName );
  84. virtual void Reset();
  85. virtual void LevelInit();
  86. virtual void ApplySchemeSettings( vgui::IScheme *scheme );
  87. virtual void OnThink();
  88. virtual bool ShouldDraw();
  89. virtual void PerformLayout();
  90. virtual bool ShouldShowAchievement( IAchievement *pAchievement );
  91. virtual void UpdateAchievementItems();
  92. virtual int GetMaxAchievementsShown();
  93. virtual CAchievementTrackerItem* GetAchievementPanel( int i );
  94. virtual CAchievementTrackerItem* CreateAchievementPanel();
  95. protected:
  96. float m_flNextThink;
  97. CUtlVector<CAchievementTrackerItem*> m_AchievementItem;
  98. CPanelAnimationVarAliasType( int, m_iItemPadding, "ItemPadding", "8", "proportional_int" ); // space between each achievement item
  99. };
  100. #endif // HUD_ACHIEVEMENT_TRACKER_H