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.

255 lines
6.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef GAMECONFIG_H
  7. #define GAMECONFIG_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #pragma warning(push, 1)
  12. #pragma warning(disable:4701 4702 4530)
  13. #include <fstream>
  14. #pragma warning(pop)
  15. #include "fgdlib/HelperInfo.h"
  16. #include "tier2/TokenReader.h"
  17. #include "fgdlib/gamedata.h"
  18. #include "GamePalette.h"
  19. #include "IEditorTexture.h"
  20. #include "UtlVector.h"
  21. class MDkeyvalue;
  22. class KeyValues;
  23. #define MAX_DIRECTORY_SIZE 32
  24. enum MAPFORMAT
  25. {
  26. mfQuake = 0,
  27. mfHexen2,
  28. mfQuake2,
  29. mfHalfLife,
  30. mfHalfLife2,
  31. };
  32. struct MatExlcusions_s
  33. {
  34. char szDirectory[MAX_PATH]; // Where we store the material exclusion directories
  35. bool bUserGenerated; // If the user specified this ( default: false -- FGD defined )
  36. };
  37. class CGameConfig
  38. {
  39. public:
  40. CGameConfig();
  41. static CGameConfig *GetActiveGame(void);
  42. static void SetActiveGame(CGameConfig *pGame);
  43. inline TEXTUREFORMAT GetTextureFormat(void);
  44. inline void SetTextureFormat(TEXTUREFORMAT eFormat);
  45. inline float GetDefaultTextureScale(void);
  46. inline void SetDefaultTextureScale(float fScale);
  47. inline int GetDefaultLightmapScale(void);
  48. inline void SetDefaultLightmapScale(int nScale);
  49. inline const char *GetCordonTexture(void);
  50. inline void SetCordonTexture(const char *szCordonTexture);
  51. inline void GetSteamExe(CString &str);
  52. inline void GetSteamDir(CString &str);
  53. inline void GetSteamUserDir(CString &str);
  54. inline void GetSteamAppID(CString &str);
  55. inline MAPFORMAT GetMapFormat();
  56. CUtlVector< MatExlcusions_s > m_MaterialExclusions;
  57. DWORD dwID; // assigned on load
  58. char szName[128];
  59. int nGDFiles;
  60. MAPFORMAT mapformat;
  61. char szExecutable[128];
  62. char szDefaultPoint[128];
  63. char szDefaultSolid[128];
  64. char szBSP[128];
  65. char szLIGHT[128];
  66. char szVIS[128];
  67. char m_szGameExeDir[128];
  68. char szMapDir[128];
  69. char szBSPDir[128];
  70. char m_szModDir[128];
  71. char m_szPrefabDir[128];
  72. int m_MaterialExcludeCount;
  73. CStringArray GDFiles;
  74. GameData GD; // gamedata files loaded
  75. CGamePalette Palette;
  76. BOOL Import(std::fstream &, float fVersion);
  77. bool Load(KeyValues *pkv);
  78. bool Save(KeyValues *pkv);
  79. void Save(std::fstream &);
  80. bool Save(const char *pszFileName, const char *pszSection);
  81. void CopyFrom(CGameConfig *pConfig);
  82. void LoadGDFiles(void);
  83. void ParseGameInfo();
  84. // Accessor methods to get at the mod + the game (*not* full paths)
  85. const char *GetMod();
  86. const char *GetGame();
  87. protected:
  88. TEXTUREFORMAT textureformat;
  89. float m_fDefaultTextureScale;
  90. int m_nDefaultLightmapScale;
  91. char m_szCordonTexture[MAX_PATH];
  92. // These settings are loaded from GameInfo.txt:
  93. char m_szSteamDir[MAX_PATH]; // The full path to steam.exe
  94. char m_szSteamUserDir[MAX_PATH]; // The full path to the users's directory under SteamApps
  95. char m_szSteamAppID[32]; // The app id to add to the command line when launching the game via Steam.
  96. };
  97. //-----------------------------------------------------------------------------
  98. // Purpose:
  99. //-----------------------------------------------------------------------------
  100. MAPFORMAT CGameConfig::GetMapFormat()
  101. {
  102. return mapformat;
  103. }
  104. //-----------------------------------------------------------------------------
  105. // Purpose:
  106. //-----------------------------------------------------------------------------
  107. TEXTUREFORMAT CGameConfig::GetTextureFormat(void)
  108. {
  109. return(textureformat);
  110. }
  111. //-----------------------------------------------------------------------------
  112. // Purpose:
  113. //-----------------------------------------------------------------------------
  114. void CGameConfig::SetTextureFormat(TEXTUREFORMAT eFormat)
  115. {
  116. textureformat = eFormat;
  117. }
  118. //-----------------------------------------------------------------------------
  119. // Purpose:
  120. //-----------------------------------------------------------------------------
  121. const char *CGameConfig::GetCordonTexture(void)
  122. {
  123. return(m_szCordonTexture);
  124. }
  125. //-----------------------------------------------------------------------------
  126. // Purpose:
  127. //-----------------------------------------------------------------------------
  128. void CGameConfig::SetCordonTexture(const char *szCordonTexture)
  129. {
  130. Q_strncpy( m_szCordonTexture, szCordonTexture, sizeof( m_szCordonTexture ) );
  131. }
  132. //-----------------------------------------------------------------------------
  133. // Purpose:
  134. //-----------------------------------------------------------------------------
  135. int CGameConfig::GetDefaultLightmapScale(void)
  136. {
  137. return(m_nDefaultLightmapScale);
  138. }
  139. //-----------------------------------------------------------------------------
  140. // Purpose:
  141. //-----------------------------------------------------------------------------
  142. void CGameConfig::SetDefaultLightmapScale(int nScale)
  143. {
  144. m_nDefaultLightmapScale = nScale;
  145. }
  146. //-----------------------------------------------------------------------------
  147. // Purpose:
  148. //-----------------------------------------------------------------------------
  149. float CGameConfig::GetDefaultTextureScale(void)
  150. {
  151. return(m_fDefaultTextureScale);
  152. }
  153. //-----------------------------------------------------------------------------
  154. // Purpose:
  155. //-----------------------------------------------------------------------------
  156. void CGameConfig::SetDefaultTextureScale(float fScale)
  157. {
  158. m_fDefaultTextureScale = fScale;
  159. }
  160. //-----------------------------------------------------------------------------
  161. // Purpose: Returns the full path to steam.exe, found by searching up from
  162. // whatever directory hammer is in.
  163. //-----------------------------------------------------------------------------
  164. void CGameConfig::GetSteamDir(CString &str)
  165. {
  166. str = m_szSteamDir;
  167. }
  168. //-----------------------------------------------------------------------------
  169. // Purpose: Returns the full path to steam.exe, found by searching up from
  170. // whatever directory hammer is in.
  171. //-----------------------------------------------------------------------------
  172. void CGameConfig::GetSteamExe(CString &str)
  173. {
  174. GetSteamDir(str);
  175. str += "\\steam.exe";
  176. }
  177. //-----------------------------------------------------------------------------
  178. // Purpose: Returns the full path to steam.exe, found by searching up from
  179. // whatever directory hammer is in.
  180. //-----------------------------------------------------------------------------
  181. void CGameConfig::GetSteamUserDir(CString &str)
  182. {
  183. str = m_szSteamUserDir;
  184. }
  185. //-----------------------------------------------------------------------------
  186. // Purpose:
  187. //-----------------------------------------------------------------------------
  188. void CGameConfig::GetSteamAppID(CString &str)
  189. {
  190. str = m_szSteamAppID;
  191. }
  192. extern GameData *pGD;
  193. extern CGameConfig *g_pGameConfig;
  194. extern float g_MAX_MAP_COORD;
  195. extern float g_MIN_MAP_COORD;
  196. #endif // GAMECONFIG_H