3
0

${Name}EditorSystemComponent.cpp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // {BEGIN_LICENSE}
  2. /*
  3. * Copyright (c) Contributors to the Open 3D Engine Project.
  4. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0 OR MIT
  7. *
  8. */
  9. // {END_LICENSE}
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <AzToolsFramework/API/ViewPaneOptions.h>
  12. #include "${Name}Widget.h"
  13. #include "${Name}EditorSystemComponent.h"
  14. #include <${Name}/${Name}TypeIds.h>
  15. namespace ${SanitizedCppName}
  16. {
  17. AZ_COMPONENT_IMPL(${SanitizedCppName}EditorSystemComponent, "${SanitizedCppName}EditorSystemComponent",
  18. ${SanitizedCppName}EditorSystemComponentTypeId, BaseSystemComponent);
  19. void ${SanitizedCppName}EditorSystemComponent::Reflect(AZ::ReflectContext* context)
  20. {
  21. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  22. {
  23. serializeContext->Class<${SanitizedCppName}EditorSystemComponent, ${SanitizedCppName}SystemComponent>()
  24. ->Version(0);
  25. }
  26. }
  27. ${SanitizedCppName}EditorSystemComponent::${SanitizedCppName}EditorSystemComponent() = default;
  28. ${SanitizedCppName}EditorSystemComponent::~${SanitizedCppName}EditorSystemComponent() = default;
  29. void ${SanitizedCppName}EditorSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  30. {
  31. BaseSystemComponent::GetProvidedServices(provided);
  32. provided.push_back(AZ_CRC_CE("${SanitizedCppName}EditorService"));
  33. }
  34. void ${SanitizedCppName}EditorSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  35. {
  36. BaseSystemComponent::GetIncompatibleServices(incompatible);
  37. incompatible.push_back(AZ_CRC_CE("${SanitizedCppName}EditorService"));
  38. }
  39. void ${SanitizedCppName}EditorSystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
  40. {
  41. BaseSystemComponent::GetRequiredServices(required);
  42. }
  43. void ${SanitizedCppName}EditorSystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
  44. {
  45. BaseSystemComponent::GetDependentServices(dependent);
  46. }
  47. void ${SanitizedCppName}EditorSystemComponent::Activate()
  48. {
  49. ${SanitizedCppName}SystemComponent::Activate();
  50. AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
  51. }
  52. void ${SanitizedCppName}EditorSystemComponent::Deactivate()
  53. {
  54. AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
  55. ${SanitizedCppName}SystemComponent::Deactivate();
  56. }
  57. void ${SanitizedCppName}EditorSystemComponent::NotifyRegisterViews()
  58. {
  59. AzToolsFramework::ViewPaneOptions options;
  60. options.paneRect = QRect(100, 100, 500, 400);
  61. options.showOnToolsToolbar = true;
  62. options.toolbarIcon = ":/${Name}/toolbar_icon.svg";
  63. // Register our custom widget as a dockable tool with the Editor under an Examples sub-menu
  64. AzToolsFramework::RegisterViewPane<${SanitizedCppName}Widget>("${Name}", "Examples", options);
  65. }
  66. } // namespace ${SanitizedCppName}