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.

167 lines
4.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef BONUSMAPSDATABASE_H
  8. #define BONUSMAPSDATABASE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "utlvector.h"
  13. struct ChallengeDescription_t
  14. {
  15. char szName[32];
  16. char szComment[256];
  17. int iType;
  18. int iBronze;
  19. int iSilver;
  20. int iGold;
  21. int iBest;
  22. };
  23. struct BonusMapDescription_t
  24. {
  25. bool bIsFolder;
  26. char szShortName[64];
  27. char szFileName[128];
  28. char szMapFileName[128];
  29. char szChapterName[128];
  30. char szImageName[128];
  31. char szMapName[64];
  32. char szComment[256];
  33. bool bLocked;
  34. bool bComplete;
  35. CUtlVector<ChallengeDescription_t> *m_pChallenges;
  36. BonusMapDescription_t( void )
  37. {
  38. bIsFolder = false;
  39. szShortName[ 0 ] = '\0';
  40. szFileName[ 0 ] = '\0';
  41. szMapFileName[ 0 ] = '\0';
  42. szChapterName[ 0 ] = '\0';
  43. szImageName[ 0 ] = '\0';
  44. szMapName[ 0 ] = '\0';
  45. szComment[ 0 ] = '\0';
  46. bLocked = false;
  47. bComplete = false;
  48. m_pChallenges = NULL;
  49. }
  50. };
  51. struct BonusMapChallenge_t
  52. {
  53. char szFileName[128];
  54. char szMapName[32];
  55. char szChallengeName[32];
  56. int iBest;
  57. };
  58. class KeyValues;
  59. //-----------------------------------------------------------------------------
  60. // Purpose: Keeps track of bonus maps on disk
  61. //-----------------------------------------------------------------------------
  62. class CBonusMapsDatabase
  63. {
  64. public:
  65. CBonusMapsDatabase( void );
  66. ~CBonusMapsDatabase();
  67. bool ReadBonusMapSaveData( void );
  68. bool WriteSaveData( void );
  69. const char * GetPath( void ) { return m_szCurrentPath; }
  70. void RootPath( void );
  71. void AppendPath( const char *pchAppend );
  72. void BackPath( void );
  73. void SetPath( const char *pchPath, int iDirDepth );
  74. void ClearBonusMapsList( void );
  75. void ScanBonusMaps( void );
  76. void RefreshMapData( void );
  77. int BonusCount( void );
  78. BonusMapDescription_t * GetBonusData( int iIndex ) { return &(m_BonusMaps[ iIndex ]); }
  79. int InvalidIndex( void ) { return m_BonusMaps.InvalidIndex(); }
  80. bool IsValidIndex( int iIndex ) { return m_BonusMaps.IsValidIndex( iIndex ); }
  81. bool GetBlink( void );
  82. void SetBlink( bool bState );
  83. bool BonusesUnlocked( void );
  84. void SetCurrentChallengeNames( const char *pchFileName, const char *pchMapName, const char *pchChallengeName );
  85. void GetCurrentChallengeNames( char *pchFileName, char *pchMapName, char *pchChallengeName );
  86. void SetCurrentChallengeObjectives( int iBronze, int iSilver, int iGold );
  87. void GetCurrentChallengeObjectives( int &iBronze, int &iSilver, int &iGold );
  88. bool SetBooleanStatus( const char *pchName, const char *pchFileName, const char *pchMapName, bool bValue );
  89. bool SetBooleanStatus( const char *pchName, int iIndex, bool bValue );
  90. bool UpdateChallengeBest( const char *pchFileName, const char *pchMapName, const char *pchChallengeName, int iBest );
  91. float GetCompletionPercentage( void );
  92. int NumAdvancedComplete( void );
  93. void NumMedals( int piNumMedals[ 3 ] );
  94. private:
  95. void AddBonus( const char *pCurrentPath, const char *pDirFileName, bool bIsFolder );
  96. void BuildSubdirectoryList( const char *pCurrentPath, bool bOutOfRoot );
  97. void BuildBonusMapsList( const char *pCurrentPath, bool bOutOfRoot );
  98. void ParseBonusMapData( char const *pszFileName, char const *pszShortName, bool bIsFolder );
  99. private:
  100. KeyValues *m_pBonusMapsManifest;
  101. CUtlVector<BonusMapDescription_t> m_BonusMaps;
  102. KeyValues *m_pBonusMapSavedData;
  103. bool m_bSavedDataChanged;
  104. int m_iX360BonusesUnlocked; // Only used on 360
  105. bool m_bHasLoadedSaveData;
  106. int m_iDirDepth;
  107. char m_szCurrentPath[_MAX_PATH];
  108. float m_fCurrentCompletion;
  109. int m_iCompletableLevels;
  110. BonusMapChallenge_t m_CurrentChallengeNames;
  111. ChallengeDescription_t m_CurrentChallengeObjectives;
  112. };
  113. void GetChallengeMedals( ChallengeDescription_t *pChallengeDescription, int &iBest, int &iEarnedMedal, int &iNext, int &iNextMedal );
  114. CBonusMapsDatabase *BonusMapsDatabase( void );
  115. extern const char g_pszMedalNames[4][8];
  116. #endif // BONUSMAPSDATABASE_H