ScriptCanvasEditorGem.cpp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. #if defined (SCRIPTCANVAS_EDITOR)
  9. #include <ScriptCanvasGem.h>
  10. #include <AzCore/Component/Entity.h>
  11. #include <AzCore/Component/Component.h>
  12. #include <AzCore/Serialization/SerializeContext.h>
  13. #include <AzCore/Component/ComponentApplication.h>
  14. #include <AzCore/Component/ComponentApplicationBus.h>
  15. #include <AzFramework/API/ApplicationAPI.h>
  16. #include <AzFramework/Asset/SimpleAsset.h>
  17. #include <ScriptCanvas/Asset/RuntimeAssetHandler.h>
  18. #include <ScriptCanvas/Asset/RuntimeAsset.h>
  19. #include <ScriptCanvas/Core/Graph.h>
  20. #include <ScriptCanvas/Data/DataRegistry.h>
  21. #include <Editor/ReflectComponent.h>
  22. #include <Editor/SystemComponent.h>
  23. #include <Editor/Components/IconComponent.h>
  24. #include <Editor/Model/EntityMimeDataHandler.h>
  25. #include <Libraries/Libraries.h>
  26. #include <ScriptCanvas/Components/EditorGraph.h>
  27. #include <ScriptCanvas/Components/EditorGraphVariableManagerComponent.h>
  28. #include <ScriptCanvas/Components/EditorScriptCanvasComponent.h>
  29. #include <Asset/EditorAssetSystemComponent.h>
  30. #include <Builder/ScriptCanvasBuilderComponent.h>
  31. #include <Editor/GraphCanvas/Components/DynamicOrderingDynamicSlotComponent.h>
  32. #include <Editor/GraphCanvas/Components/DynamicSlotComponent.h>
  33. #include <Editor/GraphCanvas/Components/NodeDescriptors/AzEventHandlerNodeDescriptorComponent.h>
  34. #include <Editor/GraphCanvas/Components/NodeDescriptors/ClassMethodNodeDescriptorComponent.h>
  35. #include <Editor/GraphCanvas/Components/NodeDescriptors/EBusHandlerNodeDescriptorComponent.h>
  36. #include <Editor/GraphCanvas/Components/NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.h>
  37. #include <Editor/GraphCanvas/Components/NodeDescriptors/ScriptEventReceiverEventNodeDescriptorComponent.h>
  38. #include <Editor/GraphCanvas/Components/NodeDescriptors/ScriptEventReceiverNodeDescriptorComponent.h>
  39. #include <Editor/GraphCanvas/Components/NodeDescriptors/ScriptEventSenderNodeDescriptorComponent.h>
  40. #include <Editor/GraphCanvas/Components/NodeDescriptors/EBusSenderNodeDescriptorComponent.h>
  41. #include <Editor/GraphCanvas/Components/NodeDescriptors/GetVariableNodeDescriptorComponent.h>
  42. #include <Editor/GraphCanvas/Components/NodeDescriptors/NodeDescriptorComponent.h>
  43. #include <Editor/GraphCanvas/Components/NodeDescriptors/NodelingDescriptorComponent.h>
  44. #include <Editor/GraphCanvas/Components/NodeDescriptors/SetVariableNodeDescriptorComponent.h>
  45. #include <Editor/GraphCanvas/Components/NodeDescriptors/UserDefinedNodeDescriptorComponent.h>
  46. #include <Editor/GraphCanvas/Components/NodeDescriptors/VariableNodeDescriptorComponent.h>
  47. #include <Editor/GraphCanvas/Components/NodeDescriptors/FunctionNodeDescriptorComponent.h>
  48. #include <Editor/GraphCanvas/Components/NodeDescriptors/FunctionDefinitionNodeDescriptorComponent.h>
  49. #include <Editor/GraphCanvas/Components/MappingComponent.h>
  50. #include <Editor/View/Widgets/VariablePanel/VariableDockWidget.h>
  51. namespace ScriptCanvas
  52. {
  53. ////////////////////////////////////////////////////////////////////////////
  54. // ScriptCanvasModule
  55. ////////////////////////////////////////////////////////////////////////////
  56. //! Create ComponentDescriptors and add them to the list.
  57. //! The descriptors will be registered at the appropriate time.
  58. //! The descriptors will be destroyed (and thus unregistered) at the appropriate time.
  59. ScriptCanvasModule::ScriptCanvasModule()
  60. : ScriptCanvasModuleCommon()
  61. {
  62. m_descriptors.insert(m_descriptors.end(), {
  63. ScriptCanvasBuilder::PluginComponent::CreateDescriptor(),
  64. ScriptCanvasEditor::EditorAssetSystemComponent::CreateDescriptor(),
  65. ScriptCanvasEditor::EditorScriptCanvasComponent::CreateDescriptor(),
  66. ScriptCanvasEditor::EntityMimeDataHandler::CreateDescriptor(),
  67. ScriptCanvasEditor::EditorGraph::CreateDescriptor(),
  68. ScriptCanvasEditor::IconComponent::CreateDescriptor(),
  69. ScriptCanvasEditor::ReflectComponent::CreateDescriptor(),
  70. ScriptCanvasEditor::SystemComponent::CreateDescriptor(),
  71. ScriptCanvasEditor::EditorGraphVariableManagerComponent::CreateDescriptor(),
  72. ScriptCanvasEditor::VariablePropertiesComponent::CreateDescriptor(),
  73. ScriptCanvasEditor::SlotMappingComponent::CreateDescriptor(),
  74. ScriptCanvasEditor::SceneMemberMappingComponent::CreateDescriptor(),
  75. // GraphCanvas additions
  76. ScriptCanvasEditor::DynamicSlotComponent::CreateDescriptor(),
  77. ScriptCanvasEditor::DynamicOrderingDynamicSlotComponent::CreateDescriptor(),
  78. // Base Descriptor
  79. ScriptCanvasEditor::NodeDescriptorComponent::CreateDescriptor(),
  80. // Node Type Descriptor
  81. ScriptCanvasEditor::AzEventHandlerNodeDescriptorComponent::CreateDescriptor(),
  82. ScriptCanvasEditor::ClassMethodNodeDescriptorComponent::CreateDescriptor(),
  83. ScriptCanvasEditor::EBusHandlerNodeDescriptorComponent::CreateDescriptor(),
  84. ScriptCanvasEditor::EBusHandlerEventNodeDescriptorComponent::CreateDescriptor(),
  85. ScriptCanvasEditor::ScriptEventReceiverEventNodeDescriptorComponent::CreateDescriptor(),
  86. ScriptCanvasEditor::ScriptEventReceiverNodeDescriptorComponent::CreateDescriptor(),
  87. ScriptCanvasEditor::ScriptEventSenderNodeDescriptorComponent::CreateDescriptor(),
  88. ScriptCanvasEditor::EBusSenderNodeDescriptorComponent::CreateDescriptor(),
  89. ScriptCanvasEditor::VariableNodeDescriptorComponent::CreateDescriptor(),
  90. ScriptCanvasEditor::GetVariableNodeDescriptorComponent::CreateDescriptor(),
  91. ScriptCanvasEditor::SetVariableNodeDescriptorComponent::CreateDescriptor(),
  92. ScriptCanvasEditor::UserDefinedNodeDescriptorComponent::CreateDescriptor(),
  93. ScriptCanvasEditor::FunctionNodeDescriptorComponent::CreateDescriptor(),
  94. ScriptCanvasEditor::FunctionDefinitionNodeDescriptorComponent::CreateDescriptor(),
  95. ScriptCanvasEditor::NodelingDescriptorComponent::CreateDescriptor()
  96. });
  97. }
  98. AZ::ComponentTypeList ScriptCanvasModule::GetRequiredSystemComponents() const
  99. {
  100. AZ::ComponentTypeList components = GetCommonSystemComponents();
  101. components.insert(components.end(), std::initializer_list<AZ::Uuid> {
  102. azrtti_typeid<ScriptCanvasEditor::EditorAssetSystemComponent>(),
  103. azrtti_typeid<ScriptCanvasEditor::ReflectComponent>(),
  104. azrtti_typeid<ScriptCanvasEditor::SystemComponent>()
  105. });
  106. return components;
  107. }
  108. }
  109. #include <QDir>
  110. // Qt resources are defined in the ScriptCanvas static library, so we must
  111. // initialize them manually
  112. extern int qInitResources_ScriptCanvasEditorResources();
  113. extern int qCleanupResources_ScriptCanvasEditorResources();
  114. namespace {
  115. struct initializer {
  116. initializer() { qInitResources_ScriptCanvasEditorResources(); }
  117. ~initializer() { qCleanupResources_ScriptCanvasEditorResources(); }
  118. } dummy;
  119. }
  120. #if defined(O3DE_GEM_NAME)
  121. AZ_DECLARE_MODULE_CLASS(AZ_JOIN(Gem_, O3DE_GEM_NAME, _Editor), ScriptCanvas::ScriptCanvasModule)
  122. #else
  123. AZ_DECLARE_MODULE_CLASS(Gem_ScriptCanvas_Editor, ScriptCanvas::ScriptCanvasModule)
  124. #endif
  125. #endif // SCRIPTCANVAS_EDITOR