Settings.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #ifndef CRYINCLUDE_EDITOR_SETTINGS_H
  10. #define CRYINCLUDE_EDITOR_SETTINGS_H
  11. #include "SettingsManager.h"
  12. #include <QColor>
  13. #include <QFont>
  14. #include <QRect>
  15. #include <QSettings>
  16. #include <AzToolsFramework/Editor/EditorSettingsAPIBus.h>
  17. #include <AzToolsFramework/Prefab/PrefabLoaderInterface.h>
  18. #include <AzCore/JSON/document.h>
  19. #include <AzCore/Console/IConsole.h>
  20. #include <AzQtComponents/Components/Widgets/ToolBar.h>
  21. //////////////////////////////////////////////////////////////////////////
  22. // Settings for snapping in the viewports.
  23. //////////////////////////////////////////////////////////////////////////
  24. struct SSnapSettings
  25. {
  26. SSnapSettings()
  27. {
  28. constructPlaneDisplay = false;
  29. constructPlaneSize = 5;
  30. markerDisplay = false;
  31. markerColor = QColor(0, 200, 200);
  32. markerSize = 1.0f;
  33. bGridUserDefined = false;
  34. bGridGetFromSelected = false;
  35. }
  36. // Display settings for construction plane.
  37. bool constructPlaneDisplay;
  38. float constructPlaneSize;
  39. // Display settings for snapping marker.
  40. bool markerDisplay;
  41. QColor markerColor;
  42. float markerSize;
  43. bool bGridUserDefined;
  44. bool bGridGetFromSelected;
  45. };
  46. //////////////////////////////////////////////////////////////////////////
  47. // Settings for View of Tools
  48. //////////////////////////////////////////////////////////////////////////
  49. struct SToolViewSettings
  50. {
  51. SToolViewSettings()
  52. {
  53. }
  54. int nFrameRate;
  55. QString codec;
  56. };
  57. //////////////////////////////////////////////////////////////////////////
  58. // Settings for deep selection.
  59. //////////////////////////////////////////////////////////////////////////
  60. struct SDeepSelectionSettings
  61. {
  62. SDeepSelectionSettings()
  63. : fRange(1.f)
  64. , bStickDuplicate(false) {}
  65. //! If there are other objects hit within this value, one of them needs
  66. //! to be selected by user.
  67. //! If this value is 0.f, then deep selection mode won't work.
  68. float fRange;
  69. bool bStickDuplicate;
  70. };
  71. //////////////////////////////////////////////////////////////////////////
  72. struct SObjectColors
  73. {
  74. SObjectColors()
  75. {
  76. groupHighlight = QColor(0, 255, 0);
  77. entityHighlight = QColor(112, 117, 102);
  78. fBBoxAlpha = 0.3f;
  79. geometryHighlightColor = QColor(192, 0, 192);
  80. solidBrushGeometryColor = QColor(192, 0, 192);
  81. fGeomAlpha = 0.2f;
  82. fChildGeomAlpha = 0.4f;
  83. }
  84. QColor groupHighlight;
  85. QColor entityHighlight;
  86. QColor geometryHighlightColor;
  87. QColor solidBrushGeometryColor;
  88. float fBBoxAlpha;
  89. float fGeomAlpha;
  90. float fChildGeomAlpha;
  91. };
  92. //////////////////////////////////////////////////////////////////////////
  93. struct SViewportsSettings
  94. {
  95. //! If enabled always show entity radiuse.
  96. bool bAlwaysShowRadiuses;
  97. //! True if 2D viewports will be synchronized with same view and origin.
  98. bool bSync2DViews;
  99. //! Camera Aspect Ratio for perspective View.
  100. float fDefaultAspectRatio;
  101. //! To highlight selected geometry.
  102. bool bHighlightSelectedGeometry;
  103. //! To highlight selected vegetation.
  104. bool bHighlightSelectedVegetation;
  105. //! To highlight selected geometry.
  106. int bHighlightMouseOverGeometry;
  107. //! Show triangle count on mouse over
  108. bool bShowMeshStatsOnMouseOver;
  109. //! If enabled will always display entity labels.
  110. bool bDrawEntityLabels;
  111. //! Show Trigger bounds.
  112. bool bShowTriggerBounds;
  113. //! Show Helpers in viewport for frozen objects.
  114. int nShowFrozenHelpers;
  115. //! Fill Selected Shapes.
  116. bool bFillSelectedShapes;
  117. // Swap X/Y in map viewport.
  118. bool bTopMapSwapXY;
  119. // Texture resolution in the Top map viewport.
  120. int nTopMapTextureResolution;
  121. // Whether the grid guide (for move/rotate tool) will be shown or not.
  122. bool bShowGridGuide;
  123. // Whether the mouse cursor will be hidden when capturing the mouse.
  124. bool bHideMouseCursorWhenCaptured;
  125. // Size of square which the mouse must leave before a drag operation begins.
  126. int nDragSquareSize;
  127. // Enable context menu in the viewport
  128. bool bEnableContextMenu;
  129. //! Warning icons draw distance
  130. float fWarningIconsDrawDistance;
  131. //! Warnings for scale != 1
  132. bool bShowScaleWarnings;
  133. //! Warnings for rotation != 0
  134. bool bShowRotationWarnings;
  135. };
  136. struct SSelectObjectDialogSettings
  137. {
  138. QString columns;
  139. int nLastColumnSortDirection;
  140. SSelectObjectDialogSettings()
  141. : nLastColumnSortDirection(0)
  142. {
  143. }
  144. };
  145. //////////////////////////////////////////////////////////////////////////
  146. struct SGUI_Settings
  147. {
  148. int nToolbarIconSize; // Override size of the toolbar icons
  149. };
  150. //////////////////////////////////////////////////////////////////////////
  151. struct STextureBrowserSettings
  152. {
  153. int nCellSize; // Stores the default texture maximum cell size for
  154. };
  155. //////////////////////////////////////////////////////////////////////////
  156. struct SExperimentalFeaturesSettings
  157. {
  158. bool bTotalIlluminationEnabled;
  159. };
  160. //////////////////////////////////////////////////////////////////////////
  161. struct SLevelSaveSettings
  162. {
  163. AzToolsFramework::Prefab::SaveAllPrefabsPreference saveAllPrefabsPreference;
  164. };
  165. //////////////////////////////////////////////////////////////////////////
  166. struct SAssetBrowserSettings
  167. {
  168. // stores the default thumb size
  169. int nThumbSize;
  170. // the current filename search filter in the search edit box
  171. QString sFilenameSearch,
  172. // the current filter preset name
  173. sPresetName;
  174. // current selected/checked/visible databases, db names separated by comma (,), Ex: "Textures,Models,Sounds"
  175. QString sVisibleDatabaseNames;
  176. // current visible columns in asset list
  177. QString sVisibleColumnNames;
  178. // current columns in asset list, in their actual order (including visible and hidden columns)
  179. QString sColumnNames;
  180. // check to show only the assets used in current level
  181. bool bShowUsedInLevel,
  182. // check to show only the assets loaded in the current level
  183. bShowLoadedInLevel,
  184. // check to filter only the favorite assets
  185. bShowFavorites,
  186. // hide LODs from thumbs view, for CGFs for example
  187. bHideLods,
  188. // true when the edited filter preset was changed, it will be saved automatically, without the user to push the "Save" button
  189. bAutoSaveFilterPreset,
  190. // true when we want sync between asset browser selection and viewport selection
  191. bAutoChangeViewportSelection,
  192. // true when we want sync between viewport selection and asset browser visible thumbs
  193. bAutoFilterFromViewportSelection;
  194. };
  195. struct SSmartOpenDialogSettings
  196. {
  197. QRect rect;
  198. QString lastSearchTerm;
  199. };
  200. //////////////////////////////////////////////////////////////////////////
  201. /** Various editor settings.
  202. */
  203. AZ_CVAR_EXTERNED(int64_t, ed_backgroundSystemTickCap);
  204. struct SANDBOX_API SEditorSettings
  205. : AzToolsFramework::EditorSettingsAPIBus::Handler
  206. {
  207. SEditorSettings();
  208. ~SEditorSettings() = default;
  209. void Save(bool isEditorClosing = false);
  210. void Load();
  211. void LoadCloudSettings();
  212. void Connect();
  213. void Disconnect();
  214. // EditorSettingsAPIBus...
  215. AZStd::vector<AZStd::string> BuildSettingsList() override;
  216. SettingOutcome GetValue(const AZStd::string_view path) override;
  217. SettingOutcome SetValue(const AZStd::string_view path, const AZStd::any& value) override;
  218. AzToolsFramework::ConsoleColorTheme GetConsoleColorTheme() const override;
  219. AZ::u64 GetMaxNumberOfItemsShownInSearchView() const override;
  220. void SaveSettingsRegistryFile() override;
  221. void ConvertPath(const AZStd::string_view sourcePath, AZStd::string& category, AZStd::string& attribute);
  222. // needs to be called after crysystem has been loaded
  223. void LoadDefaultGamePaths();
  224. // need to expose updating of the source control enable/disable flag
  225. // because its state is updateable through the main status bar
  226. void SaveEnableSourceControlFlag(bool triggerUpdate = false);
  227. void LoadEnableSourceControlFlag();
  228. void PostInitApply();
  229. //////////////////////////////////////////////////////////////////////////
  230. // Variables.
  231. //////////////////////////////////////////////////////////////////////////
  232. int undoLevels;
  233. bool bShowDashboardAtStartup;
  234. bool bAutoloadLastLevelAtStartup;
  235. bool bMuteAudio;
  236. //! Speed of camera movement.
  237. float cameraMoveSpeed;
  238. float cameraRotateSpeed;
  239. float cameraFastMoveSpeed;
  240. float wheelZoomSpeed;
  241. bool invertYRotation;
  242. bool invertPan;
  243. bool stylusMode; // if stylus mode is enabled, no setCursorPos will be performed (WACOM tablets, etc)
  244. bool restoreViewportCamera; // When true, restore the original editor viewport camera when exiting game mode
  245. //! Hide mask for objects.
  246. int objectHideMask;
  247. //! Selection mask for objects.
  248. int objectSelectMask;
  249. //////////////////////////////////////////////////////////////////////////
  250. // Viewport settings.
  251. //////////////////////////////////////////////////////////////////////////
  252. SViewportsSettings viewports;
  253. SToolViewSettings toolViewSettings;
  254. //////////////////////////////////////////////////////////////////////////
  255. // Files.
  256. //////////////////////////////////////////////////////////////////////////
  257. //! Before saving, make a backup into a subfolder
  258. bool bBackupOnSave;
  259. //! how many save backups to keep
  260. int backupOnSaveMaxCount;
  261. //////////////////////////////////////////////////////////////////////////
  262. // Autobackup.
  263. //////////////////////////////////////////////////////////////////////////
  264. //! Save auto backup file every autoSaveTime minutes.
  265. int autoBackupTime;
  266. //! Keep only several last autobackups.
  267. int autoBackupMaxCount;
  268. //! When this variable set to true automatic file backup is enabled.
  269. bool autoBackupEnabled;
  270. //! After this amount of minutes message box with reminder to save will pop on.
  271. int autoRemindTime;
  272. //////////////////////////////////////////////////////////////////////////
  273. //! If true preview windows is displayed when browsing geometries.
  274. bool bPreviewGeometryWindow;
  275. int showErrorDialogOnLoad;
  276. //! Keeps the editor active even if no focus is set
  277. int keepEditorActive;
  278. // Settings of the snapping.
  279. SSnapSettings snap;
  280. //! Source Control Enabling.
  281. bool enableSourceControl = false;
  282. bool clearConsoleOnGameModeStart;
  283. //! Text editor.
  284. QString textEditorForScript;
  285. QString textEditorForShaders;
  286. QString textEditorForBspaces;
  287. //! Asset editors
  288. QString textureEditor;
  289. QString animEditor;
  290. //////////////////////////////////////////////////////////////////////////
  291. //! Editor data search paths.
  292. QStringList searchPaths[10]; // EDITOR_PATH_LAST
  293. // This directory is related to the editor root.
  294. QString strStandardTempDirectory;
  295. SGUI_Settings gui;
  296. // For the texture browser configurations.
  297. STextureBrowserSettings sTextureBrowserSettings;
  298. // Experimental features configurations.
  299. SExperimentalFeaturesSettings sExperimentalFeaturesSettings;
  300. // For the asset browser configurations.
  301. SAssetBrowserSettings sAssetBrowserSettings;
  302. SSelectObjectDialogSettings selectObjectDialog;
  303. AzToolsFramework::ConsoleColorTheme consoleBackgroundColorTheme;
  304. bool bShowTimeInConsole;
  305. // Enable the option do get detailed information about the loaded scene data in the Scene Settings window.
  306. bool enableSceneInspector;
  307. // Deep Selection Mode Settings
  308. SDeepSelectionSettings deepSelectionSettings;
  309. // Object Highlight Settings
  310. SObjectColors objectColorSettings;
  311. SSmartOpenDialogSettings smartOpenSettings;
  312. bool bSettingsManagerMode;
  313. bool bNavigationContinuousUpdate;
  314. bool bNavigationShowAreas;
  315. bool bNavigationDebugDisplay;
  316. bool bVisualizeNavigationAccessibility;
  317. int navigationDebugAgentType;
  318. int backgroundUpdatePeriod;
  319. const char* g_TemporaryLevelName;
  320. SLevelSaveSettings levelSaveSettings;
  321. // Legacy - remove once all references have been removed.
  322. struct SSliceSettings
  323. {
  324. bool dynamicByDefault;
  325. };
  326. SSliceSettings sliceSettings;
  327. bool prefabSystem = true;
  328. private:
  329. void SaveValue(const char* sSection, const char* sKey, int value);
  330. void SaveValue(const char* sSection, const char* sKey, const QColor& value);
  331. void SaveValue(const char* sSection, const char* sKey, float value);
  332. void SaveValue(const char* sSection, const char* sKey, const QString& value);
  333. void LoadValue(const char* sSection, const char* sKey, int& value);
  334. void LoadValue(const char* sSection, const char* sKey, QColor& value);
  335. void LoadValue(const char* sSection, const char* sKey, float& value);
  336. void LoadValue(const char* sSection, const char* sKey, bool& value);
  337. void LoadValue(const char* sSection, const char* sKey, QString& value);
  338. void SaveCloudSettings();
  339. };
  340. //! Single instance of editor settings for fast access.
  341. SANDBOX_API extern SEditorSettings gSettings;
  342. #endif // CRYINCLUDE_EDITOR_SETTINGS_H