ActionManagerBus.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include <AzCore/EBus/EBus.h>
  10. #include <AzCore/Outcome/Outcome.h>
  11. #include <AzCore/std/string/string.h>
  12. #include <AzToolsFramework/ActionManager/Action/ActionManagerInterface.h>
  13. #include <Source/ActionManager/PythonEditorAction.h>
  14. namespace EditorPythonBindings
  15. {
  16. //! ActionManagerRequestBus
  17. //! Bus to register and trigger actions in the Editor via Python.
  18. //! If writing C++ code, use the ActionManagerInterface instead.
  19. class ActionManagerRequests : public AZ::EBusTraits
  20. {
  21. public:
  22. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
  23. //! Register a new Action to the Action Manager.
  24. virtual AzToolsFramework::ActionManagerOperationResult RegisterAction(
  25. const AZStd::string& contextIdentifier,
  26. const AZStd::string& identifier,
  27. const AzToolsFramework::ActionProperties& properties,
  28. PythonEditorAction handler
  29. ) = 0;
  30. //! Register a new Checkable Action to the Action Manager.
  31. virtual AzToolsFramework::ActionManagerOperationResult RegisterCheckableAction(
  32. const AZStd::string& contextIdentifier,
  33. const AZStd::string& actionIdentifier,
  34. const AzToolsFramework::ActionProperties& properties,
  35. PythonEditorAction handler,
  36. PythonEditorAction updateCallback
  37. ) = 0;
  38. //! Trigger an Action via its identifier.
  39. virtual AzToolsFramework::ActionManagerOperationResult TriggerAction(const AZStd::string& actionIdentifier) = 0;
  40. //! Update the state of a Checkable Action via its identifier.
  41. virtual AzToolsFramework::ActionManagerOperationResult UpdateAction(const AZStd::string& actionIdentifier) = 0;
  42. };
  43. using ActionManagerRequestBus = AZ::EBus<ActionManagerRequests>;
  44. } // namespace EditorPythonBindings