Settings.cpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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. #include <AzCore/UserSettings/UserSettingsProvider.h>
  9. #include <GraphCanvas/Components/Nodes/Comment/CommentBus.h>
  10. #include "Settings.h"
  11. #include <ScriptCanvas/Data/Data.h>
  12. #include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
  13. #include <Editor/View/Widgets/VariablePanel/GraphVariablesTableView.h>
  14. namespace SettingsCpp
  15. {
  16. void UpdateProcessingSettings()
  17. {
  18. if (auto userSettings = AZ::UserSettings::CreateFind<ScriptCanvasEditor::EditorSettings::ScriptCanvasEditorSettings>(AZ_CRC_CE("ScriptCanvasPreviewSettings"), AZ::UserSettings::CT_LOCAL))
  19. {
  20. ScriptCanvas::Grammar::g_saveRawTranslationOuputToFile = userSettings->m_saveRawTranslationOuputToFile;
  21. ScriptCanvas::Grammar::g_printAbstractCodeModel = userSettings->m_printAbstractCodeModel;
  22. }
  23. }
  24. }
  25. namespace ScriptCanvasEditor
  26. {
  27. namespace EditorSettings
  28. {
  29. /////////////////////////////////
  30. // ScriptCanvasConstructPresets
  31. /////////////////////////////////
  32. ScriptCanvasConstructPresets::ScriptCanvasConstructPresets()
  33. {
  34. }
  35. void ScriptCanvasConstructPresets::InitializeConstructType(GraphCanvas::ConstructType constructType)
  36. {
  37. if (constructType == GraphCanvas::ConstructType::NodeGroup)
  38. {
  39. GraphCanvas::NodeGroupPresetBucket* nodeGroupPresetBucket = static_cast<GraphCanvas::NodeGroupPresetBucket*>(ModPresetBucket(GraphCanvas::ConstructType::NodeGroup));
  40. if (nodeGroupPresetBucket)
  41. {
  42. nodeGroupPresetBucket->ClearPresets();
  43. AZStd::vector< AZStd::pair< AZStd::string, AZ::Color > > defaultGroupPresets = {
  44. { "Initialization", AZ::Color(0.188f, 0.972f, 0.243f, 1.0f) },
  45. { "UI", AZ::Color(0.741f, 0.372f, 0.545f, 1.0f) },
  46. { "AI", AZ::Color(0.396f, 0.788f, 0.788f, 1.0f) },
  47. { "Physics", AZ::Color(0.866f, 0.498f, 0.427f, 1.0f) },
  48. { "Input", AZ::Color(0.396f, 0.788f, 0.549f, 1.0f) }
  49. };
  50. for (auto groupPairing : defaultGroupPresets)
  51. {
  52. AZStd::shared_ptr< GraphCanvas::ConstructPreset > initializaitonGroupPreset = nodeGroupPresetBucket->CreateNewPreset(groupPairing.first);
  53. if (initializaitonGroupPreset)
  54. {
  55. const auto& presetSaveData = initializaitonGroupPreset->GetPresetData();
  56. GraphCanvas::CommentNodeTextSaveData* saveData = presetSaveData.FindSaveDataAs<GraphCanvas::CommentNodeTextSaveData>();
  57. if (saveData)
  58. {
  59. saveData->m_backgroundColor = groupPairing.second;
  60. }
  61. }
  62. }
  63. }
  64. }
  65. else if (constructType == GraphCanvas::ConstructType::CommentNode)
  66. {
  67. GraphCanvas::CommentPresetBucket* commentPresetBucket = static_cast<GraphCanvas::CommentPresetBucket*>(ModPresetBucket(GraphCanvas::ConstructType::CommentNode));
  68. commentPresetBucket->ClearPresets();
  69. }
  70. }
  71. ////////////////////
  72. // EditorWorkspace
  73. ////////////////////
  74. // WorkspaceAssetSaveData
  75. EditorWorkspace::WorkspaceAssetSaveData::WorkspaceAssetSaveData()
  76. {
  77. }
  78. EditorWorkspace::WorkspaceAssetSaveData::WorkspaceAssetSaveData(SourceHandle assetId)
  79. : m_assetId(assetId)
  80. {
  81. }
  82. bool EditorWorkspace::VersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& rootDataElementNode)
  83. {
  84. if (rootDataElementNode.GetVersion() < 3)
  85. {
  86. AZStd::vector<WorkspaceAssetSaveData> assetSaveData;
  87. AZStd::vector<AZ::Data::AssetId> assetIds;
  88. auto subElement = rootDataElementNode.FindSubElement(AZ_CRC_CE("ActiveAssetIds"));
  89. if (subElement)
  90. {
  91. if (subElement->GetData(assetIds))
  92. {
  93. assetSaveData.reserve(assetIds.size());
  94. for (const AZ::Data::AssetId& assetId : assetIds)
  95. {
  96. assetSaveData.emplace_back(SourceHandle( nullptr, assetId.m_guid ));
  97. }
  98. }
  99. }
  100. rootDataElementNode.RemoveElementByName(AZ_CRC_CE("ActiveAssetIds"));
  101. rootDataElementNode.AddElementWithData(context, "ActiveAssetData", assetSaveData);
  102. }
  103. if (rootDataElementNode.GetVersion() < 4)
  104. {
  105. rootDataElementNode.RemoveElementByName(AZ_CRC_CE("ActiveAssetIds"));
  106. rootDataElementNode.RemoveElementByName(AZ_CRC_CE("FocusedAssetId"));
  107. }
  108. return true;
  109. }
  110. void EditorWorkspace::Reflect(AZ::ReflectContext* context)
  111. {
  112. AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
  113. if (serialize)
  114. {
  115. serialize->Class<WorkspaceAssetSaveData>()
  116. ->Version(2)
  117. ->Field("AssetId", &WorkspaceAssetSaveData::m_assetId)
  118. ;
  119. serialize->Class<EditorWorkspace>()
  120. ->Version(4, &EditorWorkspace::VersionConverter)
  121. ->Field("m_storedWindowState", &EditorWorkspace::m_storedWindowState)
  122. ->Field("m_windowGeometry", &EditorWorkspace::m_windowGeometry)
  123. ->Field("FocusedAssetId", &EditorWorkspace::m_focusedAssetId)
  124. ->Field("ActiveAssetData", &EditorWorkspace::m_activeAssetData)
  125. ;
  126. }
  127. }
  128. void EditorWorkspace::ConfigureActiveAssets(SourceHandle focussedAssetId, const AZStd::vector< WorkspaceAssetSaveData >& activeAssetData)
  129. {
  130. m_focusedAssetId = focussedAssetId;
  131. m_activeAssetData = activeAssetData;
  132. }
  133. SourceHandle EditorWorkspace::GetFocusedAssetId() const
  134. {
  135. return m_focusedAssetId;
  136. }
  137. AZStd::vector< EditorWorkspace::WorkspaceAssetSaveData > EditorWorkspace::GetActiveAssetData() const
  138. {
  139. return m_activeAssetData;
  140. }
  141. void EditorWorkspace::Init(const QByteArray& windowState, const QByteArray& windowGeometry)
  142. {
  143. m_storedWindowState.clear();
  144. m_windowState.assign((AZ::u8*)windowState.begin(), (AZ::u8*)windowState.end());
  145. m_windowGeometry.assign((AZ::u8*)windowGeometry.begin(), (AZ::u8*)windowGeometry.end());
  146. m_storedWindowState.assign((AZ::u8*)windowState.begin(), (AZ::u8*)windowState.end());
  147. }
  148. void EditorWorkspace::Restore(QMainWindow* window)
  149. {
  150. AZ_Assert(window, "A valid window must be provided to restore its state.");
  151. QByteArray windowStateData((const char*)GetWindowState().data(), (int)GetWindowState().size());
  152. window->restoreState(windowStateData);
  153. }
  154. const AZStd::vector<AZ::u8>& EditorWorkspace::GetWindowState()
  155. {
  156. m_windowState.clear();
  157. m_windowState.assign(m_storedWindowState.begin(), m_storedWindowState.end());
  158. return m_windowState;
  159. }
  160. ////////////////////
  161. // StylingSettings
  162. ////////////////////
  163. void StylingSettings::Reflect(AZ::ReflectContext* reflectContext)
  164. {
  165. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflectContext);
  166. if (serializeContext)
  167. {
  168. serializeContext->Class<StylingSettings>()
  169. ->Version(1)
  170. ->Field("ConnectionCurveType", &StylingSettings::m_connectionCurveType)
  171. ->Field("DataConnectionCurveType", &StylingSettings::m_dataConnectionCurveType)
  172. ;
  173. AZ::EditContext* editContext = serializeContext->GetEditContext();
  174. if (editContext)
  175. {
  176. editContext->Class<StylingSettings>("StylingSettings", "All of the styling configurations that can be customized per user.")
  177. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  178. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  179. ->DataElement(AZ::Edit::UIHandlers::ComboBox, &StylingSettings::m_connectionCurveType, "Connection Curve Type", "Controls the curve style of general connections.")
  180. ->EnumAttribute(GraphCanvas::Styling::ConnectionCurveType::Straight, "Straight")
  181. ->EnumAttribute(GraphCanvas::Styling::ConnectionCurveType::Curved, "Curved")
  182. ->DataElement(AZ::Edit::UIHandlers::ComboBox, &StylingSettings::m_dataConnectionCurveType, "Data Connection Curve Type", "Controls the curve style of data connections.")
  183. ->EnumAttribute(GraphCanvas::Styling::ConnectionCurveType::Straight, "Straight")
  184. ->EnumAttribute(GraphCanvas::Styling::ConnectionCurveType::Curved, "Curved")
  185. ;
  186. }
  187. }
  188. }
  189. ///////////////////////////////
  190. // ScriptCanvasEditorSettings
  191. ///////////////////////////////
  192. bool ScriptCanvasEditorSettings::VersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& classElement)
  193. {
  194. if (classElement.GetVersion() <= 5)
  195. {
  196. AZ::Crc32 dragCouplingEnabledId = AZ_CRC_CE("m_enableNodeDragCoupling");
  197. AZ::Crc32 dragCouplingTimeId = AZ_CRC_CE("m_dragNodeCouplingTime");
  198. AZ::Crc32 dragSplicingEnabledId = AZ_CRC_CE("m_enableNodeDragConnectionSplicing");
  199. AZ::Crc32 dragSplicingTimeId = AZ_CRC_CE("m_dragNodeConnectionSplicingTime");
  200. AZ::Crc32 dropSplicingEnabledId = AZ_CRC_CE("m_enableNodeDropConnectionSplicing");
  201. AZ::Crc32 dropSplicingTimeId = AZ_CRC_CE("m_dropNodeConnectionSplicingTime");
  202. ToggleableConfiguration dragCouplingConfiguration(false,1000);
  203. ToggleableConfiguration dragSplicingConfiguration(true, 1000);
  204. ToggleableConfiguration dropSplicingConfiguration(true, 1000);
  205. // Drag Coupling
  206. AZ::SerializeContext::DataElementNode* dataNode = classElement.FindSubElement(dragCouplingEnabledId);
  207. if (dataNode)
  208. {
  209. dataNode->GetData(dragCouplingConfiguration.m_enabled);
  210. }
  211. classElement.RemoveElementByName(dragCouplingEnabledId);
  212. dataNode = classElement.FindSubElement(dragCouplingTimeId);
  213. if (dataNode)
  214. {
  215. dataNode->GetData(dragCouplingConfiguration.m_timeMS);
  216. }
  217. classElement.RemoveElementByName(dragCouplingTimeId);
  218. // Drag Splicing
  219. dataNode = classElement.FindSubElement(dragSplicingEnabledId);
  220. if (dataNode)
  221. {
  222. dataNode->GetData(dragSplicingConfiguration.m_timeMS);
  223. }
  224. classElement.RemoveElementByName(dragSplicingEnabledId);
  225. dataNode = classElement.FindSubElement(dragSplicingTimeId);
  226. if (dataNode)
  227. {
  228. dataNode->GetData(dragSplicingConfiguration.m_timeMS);
  229. }
  230. classElement.RemoveElementByName(dragSplicingTimeId);
  231. // Drop Splicing
  232. dataNode = classElement.FindSubElement(dropSplicingEnabledId);
  233. if (dataNode)
  234. {
  235. dataNode->GetData(dropSplicingConfiguration.m_timeMS);
  236. }
  237. classElement.RemoveElementByName(dropSplicingEnabledId);
  238. dataNode = classElement.FindSubElement(dropSplicingTimeId);
  239. if (dataNode)
  240. {
  241. dataNode->GetData(dropSplicingConfiguration.m_timeMS);
  242. }
  243. classElement.RemoveElementByName(dropSplicingTimeId);
  244. classElement.AddElementWithData(context, "DragCouplingConfiguration", dragCouplingConfiguration);
  245. classElement.AddElementWithData(context, "DragSplicingConfiguration", dragSplicingConfiguration);
  246. classElement.AddElementWithData(context, "DropSplicingConfiguration", dropSplicingConfiguration);
  247. }
  248. if (classElement.GetVersion() <= 11)
  249. {
  250. classElement.RemoveElementByName(AZ::Crc32("ConstructPresets"));
  251. }
  252. if (classElement.GetVersion() <= 14)
  253. {
  254. classElement.RemoveElementByName(AZ_CRC_CE("m_showPreviewMessage"));
  255. classElement.RemoveElementByName(AZ_CRC_CE("m_showExcludedNodes"));
  256. }
  257. return true;
  258. }
  259. void ScriptCanvasEditorSettings::Reflect(AZ::ReflectContext* context)
  260. {
  261. StylingSettings::Reflect(context);
  262. AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
  263. if (serialize)
  264. {
  265. serialize->Class<ScriptCanvasConstructPresets, GraphCanvas::EditorConstructPresets>()
  266. ->Version(1)
  267. ;
  268. serialize->Class<ToggleableConfiguration>()
  269. ->Version(1)
  270. ->Field("Enabled", &ToggleableConfiguration::m_enabled)
  271. ->Field("TimeMS", &ToggleableConfiguration::m_timeMS)
  272. ;
  273. serialize->Class<AutoSaveSettings>()
  274. ->Version(1)
  275. ->Field("Enabled", &AutoSaveSettings::m_enabled)
  276. ->Field("TimeSeconds", &AutoSaveSettings::m_timeSeconds)
  277. ;
  278. serialize->Class<ShakeToDespliceSettings>()
  279. ->Version(1)
  280. ->Field("Enabled", &ShakeToDespliceSettings::m_enabled)
  281. ->Field("ShakeCount", &ShakeToDespliceSettings::m_shakeCount)
  282. ->Field("ShakeLength", &ShakeToDespliceSettings::m_minimumShakeLengthPercent)
  283. ->Field("DeadZone", &ShakeToDespliceSettings::m_deadZonePercent)
  284. ->Field("ShakeTime", &ShakeToDespliceSettings::m_maximumShakeTimeMS)
  285. ->Field("Straightness", &ShakeToDespliceSettings::m_straightnessPercent)
  286. ;
  287. serialize->Class<EdgePanningSettings>()
  288. ->Version(1)
  289. ->Field("EdgePercent", &EdgePanningSettings::m_edgeScrollPercent)
  290. ->Field("ScrollSpeed", &EdgePanningSettings::m_edgeScrollSpeed)
  291. ;
  292. serialize->Class<ZoomSettings>()
  293. ->Version(2)
  294. ->Field("MinZoom", &ZoomSettings::m_zoomInSetting)
  295. ;
  296. serialize->Class<ExperimentalSettings>()
  297. ->Version(1)
  298. ->Field("ShowNetworkProperties", &ExperimentalSettings::m_showNetworkProperties)
  299. ;
  300. serialize->Class<ScriptCanvasEditorSettings>()
  301. ->Version(19, ScriptCanvasEditorSettings::VersionConverter)
  302. ->Field("m_snapDistance", &ScriptCanvasEditorSettings::m_snapDistance)
  303. ->Field("m_enableGroupDoubleClickCollapse", &ScriptCanvasEditorSettings::m_enableGroupDoubleClickCollapse)
  304. ->Field("m_pinnedDataTypes", &ScriptCanvasEditorSettings::m_pinnedDataTypes)
  305. ->Field("m_allowBookmarkViewpointControl", &ScriptCanvasEditorSettings::m_allowBookmarkViewpointControl)
  306. ->Field("DragCouplingConfiguration", &ScriptCanvasEditorSettings::m_dragNodeCouplingConfig)
  307. ->Field("DragSplicingConfiguration", &ScriptCanvasEditorSettings::m_dragNodeSplicingConfig)
  308. ->Field("DropSplicingConfiguration", &ScriptCanvasEditorSettings::m_dropNodeSplicingConfig)
  309. ->Field("AutoSaveConfiguration", &ScriptCanvasEditorSettings::m_autoSaveConfig)
  310. ->Field("ShakeToDespliceConfiguration", &ScriptCanvasEditorSettings::m_shakeDespliceConfig)
  311. ->Field("VariableColumnSorting", &ScriptCanvasEditorSettings::m_variablePanelSorting)
  312. ->Field("ShowWarnings", &ScriptCanvasEditorSettings::m_showValidationWarnings)
  313. ->Field("ShowErrors", &ScriptCanvasEditorSettings::m_showValidationErrors)
  314. ->Field("saveRawTranslationOuputToFile", &ScriptCanvasEditorSettings::m_saveRawTranslationOuputToFile)
  315. ->Field("printAbstractCodeModel", &ScriptCanvasEditorSettings::m_printAbstractCodeModel)
  316. ->Field("AllowNodeNudging", &ScriptCanvasEditorSettings::m_allowNodeNudging)
  317. ->Field("AlignmentTime", &ScriptCanvasEditorSettings::m_alignmentTimeMS)
  318. ->Field("EdgePanningSettings", &ScriptCanvasEditorSettings::m_edgePanningSettings)
  319. ->Field("ConstructPresets", &ScriptCanvasEditorSettings::m_constructPresets)
  320. ->Field("StylingSettings", &ScriptCanvasEditorSettings::m_stylingSettings)
  321. ->Field("RememberOpenCanvases", &ScriptCanvasEditorSettings::m_rememberOpenCanvases)
  322. ->Field("ShowUpgradeDialog", &ScriptCanvasEditorSettings::m_showUpgradeDialog)
  323. ->Field("ZoomSettings", &ScriptCanvasEditorSettings::m_zoomSettings)
  324. ->Field("ExperimentalSettings", &ScriptCanvasEditorSettings::m_experimentalSettings)
  325. ->Field("SceneContextMenuNodePaletteWidth", &ScriptCanvasEditorSettings::m_sceneContextMenuNodePaletteWidth)
  326. ;
  327. AZ::EditContext* editContext = serialize->GetEditContext();
  328. if (editContext)
  329. {
  330. editContext->Class<ToggleableConfiguration>("Configuration", "A pair of configuration values for actions that can be enabled/disabled and occur after a certain amount of time.")
  331. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  332. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  333. ->DataElement(AZ::Edit::UIHandlers::Default, &ToggleableConfiguration::m_enabled, "Enabled", "Controls whether or not the action is Enabled.")
  334. ->DataElement(AZ::Edit::UIHandlers::Default, &ToggleableConfiguration::m_timeMS, "Time MS", "Controls how long until the action takes place.")
  335. ->Attribute(AZ::Edit::Attributes::Suffix, "ms")
  336. ->Attribute(AZ::Edit::Attributes::Min, 1)
  337. ;
  338. editContext->Class<AutoSaveSettings>("Auto Save Configuration", "A pair of configuration values for actions that can be enabled/disabled and occur after a certain amount of time.")
  339. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  340. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  341. ->DataElement(AZ::Edit::UIHandlers::Default, &AutoSaveSettings::m_enabled, "Enabled", "Controls whether or not the action is Enabled.")
  342. ->DataElement(AZ::Edit::UIHandlers::Default, &AutoSaveSettings::m_timeSeconds, "Time Seconds", "Controls how long until the action takes place.")
  343. ->Attribute(AZ::Edit::Attributes::Suffix, "seconds")
  344. ->Attribute(AZ::Edit::Attributes::Min, 10)
  345. ;
  346. editContext->Class<ShakeToDespliceSettings>("Shake To Desplice", "Settings that control various parameters of the shake to desplice feature")
  347. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  348. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  349. ->DataElement(AZ::Edit::UIHandlers::Default, &ShakeToDespliceSettings::m_enabled, "Enabled", "Controls whether or not this feature is enabled")
  350. ->DataElement(AZ::Edit::UIHandlers::Default, &ShakeToDespliceSettings::m_shakeCount, "Shake Count", "Controls the number of shakes that must occur in order to trigger the splice")
  351. ->DataElement(AZ::Edit::UIHandlers::Slider, &ShakeToDespliceSettings::m_minimumShakeLengthPercent, "Shake Length", "Controls how long each motion must be in order to be registered as a shake.")
  352. ->Attribute(AZ::Edit::Attributes::Min, 0.0)
  353. ->Attribute(AZ::Edit::Attributes::Max, 100.0)
  354. ->Attribute(AZ::Edit::Attributes::Step, 1.0)
  355. ->DataElement(AZ::Edit::UIHandlers::Slider, &ShakeToDespliceSettings::m_deadZonePercent, "Dead Zone", "Controls how far the cursor must move before a check is initiated.")
  356. ->Attribute(AZ::Edit::Attributes::Min, 0.0)
  357. ->Attribute(AZ::Edit::Attributes::Max, 100.0)
  358. ->Attribute(AZ::Edit::Attributes::Step, 1.0)
  359. ->DataElement(AZ::Edit::UIHandlers::Default, &ShakeToDespliceSettings::m_maximumShakeTimeMS, "Maximum Shake Time", "Sets a cap on how long it consider a series of actions as a single shake gesture")
  360. ->Attribute(AZ::Edit::Attributes::Suffix, "ms")
  361. ->Attribute(AZ::Edit::Attributes::Min, 1)
  362. ->DataElement(AZ::Edit::UIHandlers::Slider, &ShakeToDespliceSettings::m_straightnessPercent, "Straightness Percent", "Controls how aligned the individual motions must be in order to qualify as a shake")
  363. ->Attribute(AZ::Edit::Attributes::Min, 0.0)
  364. ->Attribute(AZ::Edit::Attributes::Max, 100.0)
  365. ->Attribute(AZ::Edit::Attributes::Step, 1.0)
  366. ;
  367. editContext->Class<EdgePanningSettings>("Edge Panning Settings", "Settings that control various parameters of the edge panning feature")
  368. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  369. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  370. ->DataElement(AZ::Edit::UIHandlers::Slider, &EdgePanningSettings::m_edgeScrollPercent, "Percentage from Edge", "The percentage of the visible area to start scrolling when the mouse cursor is dragged into.")
  371. ->Attribute(AZ::Edit::Attributes::Min, 0.0)
  372. ->Attribute(AZ::Edit::Attributes::Max, 50.0)
  373. ->Attribute(AZ::Edit::Attributes::Step, 1.0)
  374. ->DataElement(AZ::Edit::UIHandlers::Default, &EdgePanningSettings::m_edgeScrollSpeed, "Scroll Speed", "How fast the scene will scroll when scrolling")
  375. ->Attribute(AZ::Edit::Attributes::Min, 1.0)
  376. ;
  377. editContext->Class<ZoomSettings>("Zoom Settings", "Settings that control the degree to which the scene can be zoomed in or out.")
  378. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  379. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  380. ->DataElement(AZ::Edit::UIHandlers::Slider, &ZoomSettings::m_zoomInSetting, "Maximum Zoom In", "Controls the maximum magnification for zooming in")
  381. ->Attribute(AZ::Edit::Attributes::Min, 1.0)
  382. ->Attribute(AZ::Edit::Attributes::Max, 5.0)
  383. ->Attribute(AZ::Edit::Attributes::Step, 0.1)
  384. ->Attribute(AZ::Edit::Attributes::Suffix, "X")
  385. ;
  386. editContext->Class<ScriptCanvasEditorSettings>("Script Canvas Editor Preferences", "Preferences relating to the Script Canvas editor.")
  387. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  388. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  389. ->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC_CE("PropertyVisibility_ShowChildrenOnly"))
  390. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_snapDistance, "Connection Snap Distance", "The distance from a slot under which connections will snap to it.")
  391. ->Attribute(AZ::Edit::Attributes::Min, 10.0)
  392. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_enableGroupDoubleClickCollapse, "Double Click to Collapse/Expand Group", "Enables the user to decide whether you can double click on a group to collapse/expand a group.")
  393. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_allowBookmarkViewpointControl, "Bookmark Zooming", "Will cause the bookmarks to force the viewport into the state determined by the bookmark type\nBookmark Anchors - The viewport that exists when the bookmark is created.\nNode Groups - The area the Node Group covers")
  394. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_dragNodeCouplingConfig, "Node Coupling Configuration", "Controls for managing Node Coupling.\nNode Coupling is when you are dragging a node and leave it hovered over another Node, we will try to connect the sides you overlapped with each other.")
  395. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_dragNodeSplicingConfig, "Drag Node Splicing Configuration", "Controls for managing Node Splicing on a Drag.\nNode Splicing on a Drag will let you drag a node onto a connection, and splice that node onto the specified connection.")
  396. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_dropNodeSplicingConfig, "Drop Node Splicing Configuration", "Controls for managing Node Splicing on a Drag.\nNode Splicing on a drop will let you drop a node onto a connection from the Node Palette, and splice that node onto the specified connection.")
  397. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_autoSaveConfig, "AutoSave Configuration", "Controls for managing Auto Saving.\nAuto Saving will occur after the specified time of inactivity on a graph.")
  398. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_shakeDespliceConfig, "Shake To De-splice", "Settings that controls various parameters of the Shake to De-splice feature")
  399. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_allowNodeNudging, "Allow Node Nudging", "Controls whether or not nodes will attempt to nudge each other out of the way under various interactions.")
  400. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_alignmentTimeMS, "Alignment Time", "Controls the amount of time nodes will take to slide into place when performing alignment commands")
  401. ->Attribute(AZ::Edit::Attributes::Min, 0)
  402. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_edgePanningSettings, "Edge Panning Settings", "Settings that control how the panning at the edge of the scene will be handled.")
  403. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_zoomSettings, "Zoom Settings", "Settings that will control the boundaries of the zoom settings")
  404. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_rememberOpenCanvases, "Remember Open Canvases", "Determines whether or ScriptCanvses that were open when the editor is closed will be re-opened on the next open.")
  405. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_showUpgradeDialog, "Show Upgrade Dialog", "Upon opening the Script Canvas editor this will prompt whether to upgrade all existing Script Canvas graphs.")
  406. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_stylingSettings, "Styling Settings", "Settings that will control various visual styling aspects of the Script Canvas Scene")
  407. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_experimentalSettings, "Experimental Settings", "Settings that will control elements that are under development and may not work as expected")
  408. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_saveRawTranslationOuputToFile, "Save Translation File", "Save out the raw result of translation for debug purposes")
  409. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SettingsCpp::UpdateProcessingSettings)
  410. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_printAbstractCodeModel, "Print Abstract Model", "Print out the Abstract Code Model to the console at the end of parsing for debug purposes")
  411. ->Attribute(AZ::Edit::Attributes::ChangeNotify, &SettingsCpp::UpdateProcessingSettings)
  412. ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasEditorSettings::m_sceneContextMenuNodePaletteWidth, "Context Menu Width", "Allows you to configure the width of the context menu that opens on a Script Canvas graph")
  413. ->Attribute(AZ::Edit::Attributes::Min, 120)
  414. ;
  415. editContext->Class<ExperimentalSettings>("Experimental", "Settings for features under development that may not behave as expected yet.")
  416. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  417. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  418. ->DataElement(AZ::Edit::UIHandlers::Default, &ExperimentalSettings::m_showNetworkProperties, "Variable Network Support", "Enables variable replication support over the network")
  419. ;
  420. }
  421. }
  422. }
  423. ScriptCanvasEditorSettings::ScriptCanvasEditorSettings()
  424. : m_snapDistance(10.0)
  425. , m_enableGroupDoubleClickCollapse(true)
  426. , m_allowBookmarkViewpointControl(true)
  427. , m_allowNodeNudging(true)
  428. , m_rememberOpenCanvases(true)
  429. , m_showUpgradeDialog(true)
  430. , m_dragNodeCouplingConfig(true, 750)
  431. , m_dragNodeSplicingConfig(true, 1000)
  432. , m_dropNodeSplicingConfig(true, 1000)
  433. , m_autoSaveConfig(false, 10)
  434. , m_pinnedDataTypes({
  435. ScriptCanvas::Data::ToAZType(ScriptCanvas::Data::Type::Number()),
  436. ScriptCanvas::Data::ToAZType(ScriptCanvas::Data::Type::Boolean()),
  437. ScriptCanvas::Data::ToAZType(ScriptCanvas::Data::Type::String()),
  438. ScriptCanvas::Data::ToAZType(ScriptCanvas::Data::Type::Color()),
  439. ScriptCanvas::Data::ToAZType(ScriptCanvas::Data::Type::EntityID()),
  440. ScriptCanvas::Data::ToAZType(ScriptCanvas::Data::Type::Transform()),
  441. ScriptCanvas::Data::ToAZType(ScriptCanvas::Data::Type::Vector2()),
  442. ScriptCanvas::Data::ToAZType(ScriptCanvas::Data::Type::Vector3()),
  443. ScriptCanvas::Data::ToAZType(ScriptCanvas::Data::Type::Vector4())
  444. })
  445. , m_variablePanelSorting(GraphVariablesModel::Name)
  446. , m_showValidationWarnings(true)
  447. , m_showValidationErrors(true)
  448. , m_alignmentTimeMS(250)
  449. , m_saveRawTranslationOuputToFile(ScriptCanvas::Grammar::g_saveRawTranslationOuputToFile)
  450. , m_printAbstractCodeModel(ScriptCanvas::Grammar::g_printAbstractCodeModel)
  451. {
  452. GraphCanvas::AssetEditorPresetNotificationBus::Handler::BusConnect(ScriptCanvasEditor::AssetEditorId);
  453. }
  454. void ScriptCanvasEditorSettings::OnConstructPresetsChanged(GraphCanvas::ConstructType /*constructType*/)
  455. {
  456. AZ::UserSettingsOwnerRequestBus::Event(AZ::UserSettings::CT_LOCAL, &AZ::UserSettingsOwnerRequests::SaveSettings);
  457. SettingsCpp::UpdateProcessingSettings();
  458. }
  459. }
  460. }