Settings.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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 SSliceSettings
  162. {
  163. bool dynamicByDefault;
  164. };
  165. struct SLevelSaveSettings
  166. {
  167. AzToolsFramework::Prefab::SaveAllPrefabsPreference saveAllPrefabsPreference;
  168. };
  169. //////////////////////////////////////////////////////////////////////////
  170. struct SAssetBrowserSettings
  171. {
  172. // stores the default thumb size
  173. int nThumbSize;
  174. // the current filename search filter in the search edit box
  175. QString sFilenameSearch,
  176. // the current filter preset name
  177. sPresetName;
  178. // current selected/checked/visible databases, db names separated by comma (,), Ex: "Textures,Models,Sounds"
  179. QString sVisibleDatabaseNames;
  180. // current visible columns in asset list
  181. QString sVisibleColumnNames;
  182. // current columns in asset list, in their actual order (including visible and hidden columns)
  183. QString sColumnNames;
  184. // check to show only the assets used in current level
  185. bool bShowUsedInLevel,
  186. // check to show only the assets loaded in the current level
  187. bShowLoadedInLevel,
  188. // check to filter only the favorite assets
  189. bShowFavorites,
  190. // hide LODs from thumbs view, for CGFs for example
  191. bHideLods,
  192. // true when the edited filter preset was changed, it will be saved automatically, without the user to push the "Save" button
  193. bAutoSaveFilterPreset,
  194. // true when we want sync between asset browser selection and viewport selection
  195. bAutoChangeViewportSelection,
  196. // true when we want sync between viewport selection and asset browser visible thumbs
  197. bAutoFilterFromViewportSelection;
  198. };
  199. struct SSmartOpenDialogSettings
  200. {
  201. QRect rect;
  202. QString lastSearchTerm;
  203. };
  204. //////////////////////////////////////////////////////////////////////////
  205. /** Various editor settings.
  206. */
  207. AZ_CVAR_EXTERNED(int64_t, ed_backgroundSystemTickCap);
  208. AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
  209. struct SANDBOX_API SEditorSettings
  210. : AzToolsFramework::EditorSettingsAPIBus::Handler
  211. {
  212. AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
  213. SEditorSettings();
  214. ~SEditorSettings() = default;
  215. void Save(bool isEditorClosing = false);
  216. void Load();
  217. void LoadCloudSettings();
  218. void Connect();
  219. void Disconnect();
  220. // EditorSettingsAPIBus...
  221. AZStd::vector<AZStd::string> BuildSettingsList() override;
  222. SettingOutcome GetValue(const AZStd::string_view path) override;
  223. SettingOutcome SetValue(const AZStd::string_view path, const AZStd::any& value) override;
  224. AzToolsFramework::ConsoleColorTheme GetConsoleColorTheme() const override;
  225. AZ::u64 GetMaxNumberOfItemsShownInSearchView() const override;
  226. void SaveSettingsRegistryFile() override;
  227. void ConvertPath(const AZStd::string_view sourcePath, AZStd::string& category, AZStd::string& attribute);
  228. // needs to be called after crysystem has been loaded
  229. void LoadDefaultGamePaths();
  230. // need to expose updating of the source control enable/disable flag
  231. // because its state is updateable through the main status bar
  232. void SaveEnableSourceControlFlag(bool triggerUpdate = false);
  233. void LoadEnableSourceControlFlag();
  234. void PostInitApply();
  235. //////////////////////////////////////////////////////////////////////////
  236. // Variables.
  237. //////////////////////////////////////////////////////////////////////////
  238. int undoLevels;
  239. bool m_undoSliceOverrideSaveValue;
  240. bool bShowDashboardAtStartup;
  241. bool m_showCircularDependencyError;
  242. bool bAutoloadLastLevelAtStartup;
  243. bool bMuteAudio;
  244. //! Speed of camera movement.
  245. float cameraMoveSpeed;
  246. float cameraRotateSpeed;
  247. float cameraFastMoveSpeed;
  248. float wheelZoomSpeed;
  249. bool invertYRotation;
  250. bool invertPan;
  251. bool stylusMode; // if stylus mode is enabled, no setCursorPos will be performed (WACOM tablets, etc)
  252. bool restoreViewportCamera; // When true, restore the original editor viewport camera when exiting game mode
  253. //! Hide mask for objects.
  254. int objectHideMask;
  255. //! Selection mask for objects.
  256. int objectSelectMask;
  257. //////////////////////////////////////////////////////////////////////////
  258. // Viewport settings.
  259. //////////////////////////////////////////////////////////////////////////
  260. SViewportsSettings viewports;
  261. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  262. SToolViewSettings toolViewSettings;
  263. //////////////////////////////////////////////////////////////////////////
  264. // Files.
  265. //////////////////////////////////////////////////////////////////////////
  266. //! Before saving, make a backup into a subfolder
  267. bool bBackupOnSave;
  268. //! how many save backups to keep
  269. int backupOnSaveMaxCount;
  270. //////////////////////////////////////////////////////////////////////////
  271. // Autobackup.
  272. //////////////////////////////////////////////////////////////////////////
  273. //! Save auto backup file every autoSaveTime minutes.
  274. int autoBackupTime;
  275. //! Keep only several last autobackups.
  276. int autoBackupMaxCount;
  277. //! When this variable set to true automatic file backup is enabled.
  278. bool autoBackupEnabled;
  279. //! After this amount of minutes message box with reminder to save will pop on.
  280. int autoRemindTime;
  281. //////////////////////////////////////////////////////////////////////////
  282. //! If true preview windows is displayed when browsing geometries.
  283. bool bPreviewGeometryWindow;
  284. int showErrorDialogOnLoad;
  285. //! Keeps the editor active even if no focus is set
  286. int keepEditorActive;
  287. // Settings of the snapping.
  288. SSnapSettings snap;
  289. //! Source Control Enabling.
  290. bool enableSourceControl = false;
  291. bool clearConsoleOnGameModeStart;
  292. //! Text editor.
  293. QString textEditorForScript;
  294. QString textEditorForShaders;
  295. QString textEditorForBspaces;
  296. //! Asset editors
  297. QString textureEditor;
  298. QString animEditor;
  299. //////////////////////////////////////////////////////////////////////////
  300. //! Editor data search paths.
  301. QStringList searchPaths[10]; // EDITOR_PATH_LAST
  302. // This directory is related to the editor root.
  303. QString strStandardTempDirectory;
  304. SGUI_Settings gui;
  305. // Read only parameter.
  306. // Refects the status of GetIEditor()->GetOperationMode
  307. // To change current operation mode use GetIEditor()->SetOperationMode
  308. // see EOperationMode
  309. int operationMode;
  310. // For the texture browser configurations.
  311. STextureBrowserSettings sTextureBrowserSettings;
  312. // Experimental features configurations.
  313. SExperimentalFeaturesSettings sExperimentalFeaturesSettings;
  314. // For the asset browser configurations.
  315. SAssetBrowserSettings sAssetBrowserSettings;
  316. SSelectObjectDialogSettings selectObjectDialog;
  317. AzToolsFramework::ConsoleColorTheme consoleBackgroundColorTheme;
  318. bool bShowTimeInConsole;
  319. // Enable the option do get detailed information about the loaded scene data in the Scene Settings window.
  320. bool enableSceneInspector;
  321. // Deep Selection Mode Settings
  322. SDeepSelectionSettings deepSelectionSettings;
  323. // Object Highlight Settings
  324. SObjectColors objectColorSettings;
  325. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  326. SSmartOpenDialogSettings smartOpenSettings;
  327. bool bSettingsManagerMode;
  328. bool bNavigationContinuousUpdate;
  329. bool bNavigationShowAreas;
  330. bool bNavigationDebugDisplay;
  331. bool bVisualizeNavigationAccessibility;
  332. int navigationDebugAgentType;
  333. int backgroundUpdatePeriod;
  334. const char* g_TemporaryLevelName;
  335. SSliceSettings sliceSettings;
  336. SLevelSaveSettings levelSaveSettings;
  337. bool prefabSystem = true; ///< Toggle to enable/disable the Prefab system for level entities.
  338. private:
  339. void SaveValue(const char* sSection, const char* sKey, int value);
  340. void SaveValue(const char* sSection, const char* sKey, const QColor& value);
  341. void SaveValue(const char* sSection, const char* sKey, float value);
  342. void SaveValue(const char* sSection, const char* sKey, const QString& value);
  343. void LoadValue(const char* sSection, const char* sKey, int& value);
  344. void LoadValue(const char* sSection, const char* sKey, QColor& value);
  345. void LoadValue(const char* sSection, const char* sKey, float& value);
  346. void LoadValue(const char* sSection, const char* sKey, bool& value);
  347. void LoadValue(const char* sSection, const char* sKey, QString& value);
  348. void SaveCloudSettings();
  349. };
  350. //! Single instance of editor settings for fast access.
  351. SANDBOX_API extern SEditorSettings gSettings;
  352. #endif // CRYINCLUDE_EDITOR_SETTINGS_H