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.

110 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef CONFIGMANAGER_H
  7. #define CONFIGMANAGER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "KeyValues.h"
  12. #include "utlvector.h"
  13. #include "filesystem_init.h"
  14. // See filesystem_init for the vconfig registry values.
  15. #define TOKEN_GAMES "Games"
  16. #define TOKEN_GAME_DIRECTORY "GameDir"
  17. #define TOKEN_TOOLS "Tools"
  18. struct defaultConfigInfo_t
  19. {
  20. char gameName[MAX_PATH];
  21. char gameDir[MAX_PATH];
  22. char FGD[MAX_PATH];
  23. char defaultPointEntity[MAX_PATH];
  24. char exeName[MAX_PATH];
  25. int steamAppID;
  26. };
  27. enum eSDKEpochs
  28. {
  29. HL2 = 1,
  30. EP1 = 2,
  31. EP2 = 3,
  32. SP2009 = 4,
  33. MP2009 = 5,
  34. };
  35. extern defaultConfigInfo_t *gDefaultConfigs[];
  36. class CGameConfigManager
  37. {
  38. public:
  39. enum loadStatus_t
  40. {
  41. LOADSTATUS_NONE = 0, // Configs were loaded with no error
  42. LOADSTATUS_CONVERTED, // GameConfig.txt did not exist and was created by converting GameCfg.INI
  43. LOADSTATUS_CREATED, // GameCfg.INI was not found, the system created the default configuration based on found GameInfo.txt resources
  44. LOADSTATUS_ERROR, // File was not loaded and was unable to perform the above fail-safe procedures
  45. };
  46. CGameConfigManager( void );
  47. CGameConfigManager( const char *fileName );
  48. ~CGameConfigManager( void );
  49. bool LoadConfigs( const char *baseDir = NULL );
  50. bool SaveConfigs( const char *baseDir = NULL );
  51. bool ResetConfigs( const char *baseDir = NULL );
  52. int GetNumConfigs( void );
  53. KeyValues *GetGameBlock( void );
  54. KeyValues *GetGameSubBlock( const char *keyName );
  55. bool GetDefaultGameBlock( KeyValues *pIn );
  56. bool IsLoaded( void ) const { return m_pData != NULL; }
  57. bool WasConvertedOnLoad( void ) const { return m_LoadStatus == LOADSTATUS_CONVERTED; }
  58. bool WasCreatedOnLoad( void ) const { return m_LoadStatus == LOADSTATUS_CREATED; }
  59. bool AddDefaultConfig( const defaultConfigInfo_t &info, KeyValues *out, const char *rootDirectory, const char *gameExeDir );
  60. void SetBaseDirectory( const char *pDirectory );
  61. void GetRootGameDirectory( char *out, size_t outLen, const char *rootDir );
  62. const char *GetRootDirectory( void );
  63. void SetSDKEpoch( eSDKEpochs epoch ) { m_eSDKEpoch = epoch; };
  64. private:
  65. void GetRootContentDirectory( char *out, size_t outLen, const char *rootDir );
  66. const char *GetBaseDirectory( void );
  67. const char *GetIniFilePath( void );
  68. bool LoadConfigsInternal( const char *baseDir, bool bRecursiveCall );
  69. void UpdateConfigsInternal( void );
  70. void VersionConfig( void );
  71. bool IsConfigCurrent( void );
  72. bool ConvertGameConfigsINI( void );
  73. bool CreateAllDefaultConfigs( void );
  74. bool IsAppSubscribed( int nAppID );
  75. loadStatus_t m_LoadStatus; // Holds various state about what occured while loading
  76. KeyValues *m_pData; // Data as read from configuration file
  77. char m_szBaseDirectory[MAX_PATH]; // Default directory
  78. eSDKEpochs m_eSDKEpoch; // Holds the "working version" of the SDK for times when we need to create an older set of game configurations.
  79. // This is required now that the SDK is deploying the tools for both the latest and previous versions of the engine.
  80. };
  81. #endif // CONFIGMANAGER_H