ScriptCanvasDeveloperEditorComponent.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 <QMainWindow>
  9. #include <QMenuBar>
  10. #include <AzToolsFramework/UI/PropertyEditor/GenericComboBoxCtrl.h>
  11. #include <ScriptCanvas/Libraries/Libraries.h>
  12. #include <ScriptCanvas/Data/Data.h>
  13. #include <ScriptCanvasDeveloperEditor/ScriptCanvasDeveloperEditorComponent.h>
  14. #include <ScriptCanvasDeveloperEditor/NodeListDumpAction.h>
  15. #include <ScriptCanvasDeveloperEditor/TSGenerateAction.h>
  16. #include <ScriptCanvasDeveloperEditor/AutomationActions/DynamicSlotFullCreation.h>
  17. #include <ScriptCanvasDeveloperEditor/AutomationActions/NodePaletteFullCreation.h>
  18. #include <ScriptCanvasDeveloperEditor/AutomationActions/VariableListFullCreation.h>
  19. #include <ScriptCanvasDeveloperEditor/Developer.h>
  20. #include <EditorAutomationTestDialog.h>
  21. #include <Editor/GraphCanvas/GraphCanvasEditorNotificationBusId.h>
  22. namespace ScriptCanvasDeveloperEditor
  23. {
  24. ////////////////////
  25. // SystemComponent
  26. ////////////////////
  27. void SystemComponent::Reflect(AZ::ReflectContext* context)
  28. {
  29. if (auto serialize = azrtti_cast<AZ::SerializeContext*>(context))
  30. {
  31. serialize->Class<SystemComponent, AZ::Component>()
  32. ->Version(0)
  33. ;
  34. }
  35. }
  36. void SystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  37. {
  38. required.push_back(AZ_CRC_CE("ScriptCanvasEditorService"));
  39. }
  40. void SystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  41. {
  42. provided.push_back(AZ_CRC_CE("ScriptCanvasDeveloperEditorService"));
  43. }
  44. void SystemComponent::Init()
  45. {
  46. ScriptCanvas::Developer::InitNodeRegistry();
  47. }
  48. void SystemComponent::Activate()
  49. {
  50. QMainWindow* mainWindow = nullptr;
  51. ScriptCanvasEditor::UIRequestBus::BroadcastResult(mainWindow, &ScriptCanvasEditor::UIRequests::GetMainWindow);
  52. if (mainWindow)
  53. {
  54. MainWindowCreationEvent(mainWindow);
  55. }
  56. ScriptCanvasEditor::UINotificationBus::Handler::BusConnect();
  57. AzToolsFramework::RegisterGenericComboBoxHandler<ScriptCanvas::Data::Type>();
  58. }
  59. void SystemComponent::Deactivate()
  60. {
  61. ScriptCanvasEditor::UINotificationBus::Handler::BusDisconnect();
  62. }
  63. void SystemComponent::MainWindowCreationEvent(QMainWindow* mainWindow)
  64. {
  65. QMenuBar* menuBar = mainWindow->menuBar();
  66. QMenu* developerMenu = menuBar->addMenu("Developer");
  67. VariablePaletteFullCreation::CreateVariablePaletteFullCreationAction(developerMenu);
  68. developerMenu->addSeparator();
  69. NodePaletteFullCreation::CreateNodePaletteFullCreationAction(developerMenu);
  70. DynamicSlotFullCreation::CreateDynamicSlotFullCreationAction(developerMenu);
  71. developerMenu->addSeparator();
  72. NodeListDumpAction::CreateNodeListDumpAction(developerMenu);
  73. developerMenu->addSeparator();
  74. TranslationDatabaseFileAction(developerMenu, mainWindow);
  75. QAction* action = developerMenu->addAction("Open Menu Test");
  76. QObject::connect(action, &QAction::triggered, [mainWindow]()
  77. {
  78. ScriptCanvas::Developer::EditorAutomationTestDialogRequests* requests = ScriptCanvas::Developer::EditorAutomationTestDialogRequestBus::FindFirstHandler(ScriptCanvasEditor::AssetEditorId);
  79. if (requests)
  80. {
  81. requests->ShowTestDialog();
  82. }
  83. else
  84. {
  85. ScriptCanvas::Developer::EditorAutomationTestDialog* testDialog = new ScriptCanvas::Developer::EditorAutomationTestDialog(mainWindow);
  86. testDialog->ShowTestDialog();
  87. }
  88. });
  89. }
  90. }