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.

81 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #ifndef IACHIEVEMENTMGR_H
  7. #define IACHIEVEMENTMGR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "utlmap.h"
  12. #include "vgui_controls/Panel.h"
  13. class CBaseAchievement;
  14. abstract_class IAchievement
  15. {
  16. public:
  17. virtual int GetAchievementID() = 0;
  18. virtual const char *GetName() = 0;
  19. virtual int GetFlags() = 0;
  20. virtual int GetGoal() = 0;
  21. virtual int GetCount() = 0;
  22. virtual bool IsAchieved() = 0;
  23. virtual int GetPointValue() = 0;
  24. virtual bool ShouldSaveWithGame() = 0;
  25. virtual bool ShouldHideUntilAchieved() = 0;
  26. virtual bool ShouldShowOnHUD() = 0;
  27. virtual void SetShowOnHUD( bool bShow ) = 0;
  28. };
  29. abstract_class IAchievementMgr
  30. {
  31. public:
  32. virtual IAchievement* GetAchievementByIndex( int index ) = 0;
  33. virtual CBaseAchievement* GetAchievementByID ( int id ) = 0;
  34. virtual int GetAchievementCount() = 0;
  35. virtual void InitializeAchievements() = 0;
  36. virtual void AwardAchievement( int iAchievementID ) = 0;
  37. virtual void OnMapEvent( const char *pchEventName ) = 0;
  38. virtual void DownloadUserData() = 0;
  39. virtual void EnsureGlobalStateLoaded() = 0;
  40. virtual void SaveGlobalStateIfDirty( bool bAsync ) = 0;
  41. virtual bool HasAchieved( const char *pchName ) = 0;
  42. virtual bool WereCheatsEverOn() = 0;
  43. };
  44. // flags for IAchievement::GetFlags
  45. #define ACH_LISTEN_KILL_EVENTS 0x0001
  46. #define ACH_LISTEN_MAP_EVENTS 0x0002
  47. #define ACH_LISTEN_COMPONENT_EVENTS 0x0004
  48. #define ACH_HAS_COMPONENTS 0x0020
  49. #define ACH_SAVE_WITH_GAME 0x0040
  50. #define ACH_SAVE_GLOBAL 0x0080
  51. #define ACH_FILTER_ATTACKER_IS_PLAYER 0x0100
  52. #define ACH_FILTER_VICTIM_IS_PLAYER_ENEMY 0x0200
  53. #define ACH_FILTER_FULL_ROUND_ONLY 0x0400
  54. #define ACH_LISTEN_PLAYER_KILL_ENEMY_EVENTS ACH_LISTEN_KILL_EVENTS | ACH_FILTER_ATTACKER_IS_PLAYER | ACH_FILTER_VICTIM_IS_PLAYER_ENEMY
  55. #define ACH_LISTEN_KILL_ENEMY_EVENTS ACH_LISTEN_KILL_EVENTS | ACH_FILTER_VICTIM_IS_PLAYER_ENEMY
  56. // Update this for changes in either abstract class in this file
  57. #define ACHIEVEMENTMGR_INTERFACE_VERSION "ACHIEVEMENTMGR_INTERFACE_VERSION001"
  58. #define ACHIEVEMENT_LOCALIZED_NAME_FROM_STR( name ) \
  59. ( g_pVGuiLocalize->Find( CFmtStr( "#%s_NAME", name ) ) )
  60. #define ACHIEVEMENT_LOCALIZED_NAME( pAchievement ) \
  61. ( ACHIEVEMENT_LOCALIZED_NAME_FROM_STR( pAchievement->GetName() ) )
  62. #define ACHIEVEMENT_LOCALIZED_DESC_FROM_STR( name ) \
  63. ( g_pVGuiLocalize->Find( CFmtStr( "#%s_DESC", name ) ) )
  64. #define ACHIEVEMENT_LOCALIZED_DESC( pAchievement ) \
  65. ( ACHIEVEMENT_LOCALIZED_DESC_FROM_STR( pAchievement->GetName() ) )
  66. #endif // IACHIEVEMENTMGR_H