Settings.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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. AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
  205. struct SANDBOX_API SEditorSettings
  206. : AzToolsFramework::EditorSettingsAPIBus::Handler
  207. {
  208. AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING
  209. SEditorSettings();
  210. ~SEditorSettings() = default;
  211. void Save(bool isEditorClosing = false);
  212. void Load();
  213. void LoadCloudSettings();
  214. void Connect();
  215. void Disconnect();
  216. // EditorSettingsAPIBus...
  217. AZStd::vector<AZStd::string> BuildSettingsList() override;
  218. SettingOutcome GetValue(const AZStd::string_view path) override;
  219. SettingOutcome SetValue(const AZStd::string_view path, const AZStd::any& value) override;
  220. AzToolsFramework::ConsoleColorTheme GetConsoleColorTheme() const override;
  221. AZ::u64 GetMaxNumberOfItemsShownInSearchView() const override;
  222. void SaveSettingsRegistryFile() override;
  223. void ConvertPath(const AZStd::string_view sourcePath, AZStd::string& category, AZStd::string& attribute);
  224. // needs to be called after crysystem has been loaded
  225. void LoadDefaultGamePaths();
  226. // need to expose updating of the source control enable/disable flag
  227. // because its state is updateable through the main status bar
  228. void SaveEnableSourceControlFlag(bool triggerUpdate = false);
  229. void LoadEnableSourceControlFlag();
  230. void PostInitApply();
  231. //////////////////////////////////////////////////////////////////////////
  232. // Variables.
  233. //////////////////////////////////////////////////////////////////////////
  234. int undoLevels;
  235. bool bShowDashboardAtStartup;
  236. bool bAutoloadLastLevelAtStartup;
  237. bool bMuteAudio;
  238. //! Speed of camera movement.
  239. float cameraMoveSpeed;
  240. float cameraRotateSpeed;
  241. float cameraFastMoveSpeed;
  242. float wheelZoomSpeed;
  243. bool invertYRotation;
  244. bool invertPan;
  245. bool stylusMode; // if stylus mode is enabled, no setCursorPos will be performed (WACOM tablets, etc)
  246. bool restoreViewportCamera; // When true, restore the original editor viewport camera when exiting game mode
  247. //! Hide mask for objects.
  248. int objectHideMask;
  249. //! Selection mask for objects.
  250. int objectSelectMask;
  251. //////////////////////////////////////////////////////////////////////////
  252. // Viewport settings.
  253. //////////////////////////////////////////////////////////////////////////
  254. SViewportsSettings viewports;
  255. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  256. SToolViewSettings toolViewSettings;
  257. //////////////////////////////////////////////////////////////////////////
  258. // Files.
  259. //////////////////////////////////////////////////////////////////////////
  260. //! Before saving, make a backup into a subfolder
  261. bool bBackupOnSave;
  262. //! how many save backups to keep
  263. int backupOnSaveMaxCount;
  264. //////////////////////////////////////////////////////////////////////////
  265. // Autobackup.
  266. //////////////////////////////////////////////////////////////////////////
  267. //! Save auto backup file every autoSaveTime minutes.
  268. int autoBackupTime;
  269. //! Keep only several last autobackups.
  270. int autoBackupMaxCount;
  271. //! When this variable set to true automatic file backup is enabled.
  272. bool autoBackupEnabled;
  273. //! After this amount of minutes message box with reminder to save will pop on.
  274. int autoRemindTime;
  275. //////////////////////////////////////////////////////////////////////////
  276. //! If true preview windows is displayed when browsing geometries.
  277. bool bPreviewGeometryWindow;
  278. int showErrorDialogOnLoad;
  279. //! Keeps the editor active even if no focus is set
  280. int keepEditorActive;
  281. // Settings of the snapping.
  282. SSnapSettings snap;
  283. //! Source Control Enabling.
  284. bool enableSourceControl = false;
  285. bool clearConsoleOnGameModeStart;
  286. //! Text editor.
  287. QString textEditorForScript;
  288. QString textEditorForShaders;
  289. QString textEditorForBspaces;
  290. //! Asset editors
  291. QString textureEditor;
  292. QString animEditor;
  293. //////////////////////////////////////////////////////////////////////////
  294. //! Editor data search paths.
  295. QStringList searchPaths[10]; // EDITOR_PATH_LAST
  296. // This directory is related to the editor root.
  297. QString strStandardTempDirectory;
  298. SGUI_Settings gui;
  299. // For the texture browser configurations.
  300. STextureBrowserSettings sTextureBrowserSettings;
  301. // Experimental features configurations.
  302. SExperimentalFeaturesSettings sExperimentalFeaturesSettings;
  303. // For the asset browser configurations.
  304. SAssetBrowserSettings sAssetBrowserSettings;
  305. SSelectObjectDialogSettings selectObjectDialog;
  306. AzToolsFramework::ConsoleColorTheme consoleBackgroundColorTheme;
  307. bool bShowTimeInConsole;
  308. // Enable the option do get detailed information about the loaded scene data in the Scene Settings window.
  309. bool enableSceneInspector;
  310. // Deep Selection Mode Settings
  311. SDeepSelectionSettings deepSelectionSettings;
  312. // Object Highlight Settings
  313. SObjectColors objectColorSettings;
  314. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  315. SSmartOpenDialogSettings smartOpenSettings;
  316. bool bSettingsManagerMode;
  317. bool bNavigationContinuousUpdate;
  318. bool bNavigationShowAreas;
  319. bool bNavigationDebugDisplay;
  320. bool bVisualizeNavigationAccessibility;
  321. int navigationDebugAgentType;
  322. int backgroundUpdatePeriod;
  323. const char* g_TemporaryLevelName;
  324. SLevelSaveSettings levelSaveSettings;
  325. // Legacy - remove once all references have been removed.
  326. struct SSliceSettings
  327. {
  328. bool dynamicByDefault;
  329. };
  330. SSliceSettings sliceSettings;
  331. bool prefabSystem = true;
  332. private:
  333. void SaveValue(const char* sSection, const char* sKey, int value);
  334. void SaveValue(const char* sSection, const char* sKey, const QColor& value);
  335. void SaveValue(const char* sSection, const char* sKey, float value);
  336. void SaveValue(const char* sSection, const char* sKey, const QString& value);
  337. void LoadValue(const char* sSection, const char* sKey, int& value);
  338. void LoadValue(const char* sSection, const char* sKey, QColor& value);
  339. void LoadValue(const char* sSection, const char* sKey, float& value);
  340. void LoadValue(const char* sSection, const char* sKey, bool& value);
  341. void LoadValue(const char* sSection, const char* sKey, QString& value);
  342. void SaveCloudSettings();
  343. };
  344. //! Single instance of editor settings for fast access.
  345. SANDBOX_API extern SEditorSettings gSettings;
  346. #endif // CRYINCLUDE_EDITOR_SETTINGS_H