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.

252 lines
6.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Defines options that are written to the registry.
  4. //
  5. //=============================================================================//
  6. #ifndef OPTIONS_H
  7. #define OPTIONS_H
  8. #pragma once
  9. #pragma warning(push, 1)
  10. #pragma warning(disable:4701 4702 4530)
  11. #include <fstream>
  12. #pragma warning(pop)
  13. #include <afxtempl.h>
  14. class CGameConfig;
  15. class KeyValues;
  16. enum TextureAlignment_t;
  17. class COptionsGeneral
  18. {
  19. public:
  20. int nMaxCameras;
  21. int iUndoLevels;
  22. BOOL bLockingTextures;
  23. BOOL bScaleLockingTextures;
  24. TextureAlignment_t eTextureAlignment;
  25. BOOL bLoadwinpos;
  26. BOOL bIndependentwin;
  27. BOOL bGroupWhileIgnore;
  28. BOOL bStretchArches;
  29. BOOL bShowHelpers;
  30. BOOL bCheckVisibleMapErrors;
  31. int iTimeBetweenSaves;
  32. int iMaxAutosaveSpace;
  33. int iMaxAutosavesPerMap;
  34. BOOL bClosedCorrectly;
  35. char szAutosaveDir[MAX_PATH];
  36. BOOL bUseVGUIModelBrowser;
  37. BOOL bShowCollisionModels;
  38. BOOL bShowDetailObjects;
  39. BOOL bShowNoDrawBrushes;
  40. BOOL bEnableAutosave;
  41. BOOL bShowHiddenTargetsAsBroken;
  42. BOOL bRadiusCulling;
  43. };
  44. class COptionsTextures
  45. {
  46. public:
  47. CStringArray TextureFiles;
  48. int nTextureFiles;
  49. float fBrightness;
  50. };
  51. class COptionsColors
  52. {
  53. public:
  54. bool bUseCustom; // Whether to use the custom colors or not.
  55. bool bScaleAxisColor; // Whether to use the intensity slider to scale the axis color in the 2D view.
  56. bool bScaleGridColor; // Whether to use the intensity slider to scale the grid color in the 2D view.
  57. bool bScaleGridDotColor; // Whether to use the intensity slider to scale the dotted grid color in the 2D view.
  58. bool bScaleGrid10Color; // Whether to use the intensity slider to scale the 10 grid color in the 2D view.
  59. bool bScaleGrid1024Color; // Whether to use the intensity slider to scale the 1024 grid color in the 2D view.
  60. COLORREF clrAxis; // The 2D view axis color.
  61. COLORREF clrGrid; // The 2D view grid color.
  62. COLORREF clrGridDot; // The 2D view dotted grid color.
  63. COLORREF clrGrid10; // The 2D view grid color for every 10th line.
  64. COLORREF clrGrid1024; // The 2D view grid color for every 1024 units line.
  65. COLORREF clrBackground; // The 2D view background color.
  66. COLORREF clrBrush; // The color of brushes.
  67. COLORREF clrEntity; // The default color of point entities & brush entities, can be overridden by the FGD.
  68. COLORREF clrSelection; // The color of selected objects.
  69. COLORREF clrVertex; // The color of vertices.
  70. COLORREF clrToolHandle; // The color of tool handles.
  71. COLORREF clrToolBlock; // The color of the block tool.
  72. COLORREF clrToolSelection; // The color of the selection tool.
  73. COLORREF clrToolMorph; // The color of the morph tool.
  74. COLORREF clrToolPath; // The color of the path tool.
  75. COLORREF clrToolDrag; // The color of tool bounds while it is being dragged.
  76. COLORREF clrModelCollisionWireframe; // The color of a model's collision wireframe
  77. COLORREF clrModelCollisionWireframeDisabled; // The color of a model's collision wireframe when set to "Not Solid" via the entity properties
  78. };
  79. class COptionsView2D
  80. {
  81. public:
  82. BOOL bCrosshairs;
  83. BOOL bGroupCarve;
  84. BOOL bScrollbars;
  85. BOOL bRotateConstrain;
  86. BOOL bDrawVertices;
  87. BOOL bDrawModels;
  88. BOOL bWhiteOnBlack;
  89. BOOL bGridHigh1024;
  90. BOOL bGridHigh10;
  91. BOOL bHideSmallGrid;
  92. BOOL bNudge;
  93. BOOL bOrientPrimitives;
  94. BOOL bAutoSelect;
  95. BOOL bSelectbyhandles;
  96. BOOL bKeepclonegroup;
  97. BOOL bGridHigh64;
  98. BOOL bCenteroncamera;
  99. BOOL bUsegroupcolors;
  100. BOOL bGridDots;
  101. int iDefaultGrid;
  102. int iGridIntensity;
  103. int iGridHighSpec;
  104. };
  105. class COptionsView3D
  106. {
  107. public:
  108. BOOL bHardware; // Whether to use hardware acceleration (disabled for OpenGL).
  109. BOOL bReverseY; // Wether to reverse the mouse's Y axis when mouse looking.
  110. BOOL bUseMouseLook; // Whether to use the engine's default movement controls.
  111. int iBackPlane; // Distance to far clipping plane in world units.
  112. int nModelDistance; // Distance in world units within which studio models render.
  113. int nDetailDistance; // Distance in world units within which detail props render.
  114. BOOL bAnimateModels; // Whether to animate studio models.
  115. int nForwardSpeedMax; // Max forward speed in world units per second.
  116. int nTimeToMaxSpeed; // Time to max forward speed in milliseconds.
  117. BOOL bFilterTextures; // Whether to filter textures.
  118. BOOL bReverseSelection; // Whether to animate studio models.
  119. bool bPreviewModelFade; // Whether to preview model fade in the 3D view.
  120. float fFOV; // FOV of 3D Camera
  121. float fLightConeLength; // Multiplier for light_spot cone length
  122. };
  123. class COptionsConfigs
  124. {
  125. public:
  126. COptionsConfigs(void);
  127. virtual ~COptionsConfigs(void);
  128. CGameConfig *AddConfig(void);
  129. int LoadGameConfigs();
  130. void SaveGameConfigs();
  131. bool ResetGameConfigs( bool bOverwrite );
  132. inline int GetGameConfigCount();
  133. inline CGameConfig *GetGameConfig(int nIndex);
  134. // find a game config based on ID:
  135. CGameConfig *FindConfig(DWORD dwID, int *piIndex = NULL);
  136. CGameConfig *FindConfigForGame(const char *szGame);
  137. int nConfigs;
  138. CTypedPtrArray<CPtrArray, CGameConfig*> Configs;
  139. CString m_strConfigDir;
  140. private:
  141. int LoadGameConfigsBlock( KeyValues *pBlock );
  142. int ImportOldGameConfigs(const char *pszFileName);
  143. };
  144. //-----------------------------------------------------------------------------
  145. // Purpose: Functions for iterating the game configs.
  146. //-----------------------------------------------------------------------------
  147. int COptionsConfigs::GetGameConfigCount()
  148. {
  149. return nConfigs;
  150. }
  151. CGameConfig *COptionsConfigs::GetGameConfig(int nIndex)
  152. {
  153. return Configs.GetAt(nIndex);
  154. }
  155. class COptions
  156. {
  157. public:
  158. COptions();
  159. bool Init();
  160. bool Read();
  161. void SetDefaults();
  162. void Write( BOOL fOverwrite, BOOL fSaveConfigs );
  163. void SetClosedCorrectly(BOOL bClosed);
  164. // This happens if it can't initialize the file system, or if they're missing gameinfo.txt.
  165. // It forces them to choose or create a config that works.
  166. bool RunConfigurationDialog();
  167. void PerformChanges(DWORD = 0xffffffff);
  168. // Accessors:
  169. TextureAlignment_t GetTextureAlignment(void);
  170. TextureAlignment_t SetTextureAlignment(TextureAlignment_t eTextureAlignment);
  171. bool GetShowHelpers(void);
  172. void SetShowHelpers(bool bShow);
  173. BOOL SetLockingTextures(BOOL b);
  174. BOOL IsLockingTextures(void);
  175. BOOL SetScaleLockingTextures(BOOL b);
  176. BOOL IsScaleLockingTextures(void);
  177. bool IsVGUIModelBrowserEnabled();
  178. // Attributes:
  179. UINT uDaysSinceInstalled;
  180. // Flags for PerformChanges:
  181. enum
  182. {
  183. secTextures = 0x01,
  184. secGeneral = 0x02,
  185. secView2D = 0x04,
  186. secView3D = 0x08,
  187. secConfigs = 0x10
  188. };
  189. COptionsGeneral general;
  190. COptionsView2D view2d;
  191. COptionsView3D view3d;
  192. COptionsTextures textures;
  193. COptionsConfigs configs;
  194. COptionsColors colors;
  195. private:
  196. void ReadColorSettings(void);
  197. };
  198. extern COptions Options;
  199. #endif // OPTIONS_H