IAudioSystemEditor.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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/IO/Path/Path.h>
  11. #include <AzCore/std/string/string_view.h>
  12. #include <AzCore/XML/rapidxml.h>
  13. #include <ACETypes.h>
  14. class QWidget;
  15. namespace AudioControls
  16. {
  17. class IAudioSystemEditor;
  18. }
  19. namespace AudioControlsEditor
  20. {
  21. class EditorImplPluginEvents
  22. : public AZ::EBusTraits
  23. {
  24. public:
  25. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
  26. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
  27. virtual void InitializeEditorImplPlugin() = 0;
  28. virtual void ReleaseEditorImplPlugin() = 0;
  29. virtual AudioControls::IAudioSystemEditor* GetEditorImplPlugin() = 0;
  30. };
  31. using EditorImplPluginEventBus = AZ::EBus<EditorImplPluginEvents>;
  32. } // namespace AudioControlsEditor
  33. namespace AudioControls
  34. {
  35. class IAudioSystemControl;
  36. typedef AZ::u32 TImplControlTypeMask;
  37. //-------------------------------------------------------------------------------------------//
  38. struct SControlDef
  39. {
  40. TImplControlType m_type; //! Middleware type of the control
  41. AZStd::string m_name; //! Name of the control
  42. AZStd::string m_path; //! Subfolder/path of the control
  43. bool m_isLocalized; //! If the control is localized.
  44. IAudioSystemControl* m_parentControl; //! Pointer to the parent
  45. SControlDef(const AZStd::string& name, TImplControlType type, bool localized = false, IAudioSystemControl* parent = nullptr, const AZStd::string& path = "")
  46. : m_type(type)
  47. , m_name(name)
  48. , m_path(path)
  49. , m_isLocalized(localized)
  50. , m_parentControl(parent)
  51. {}
  52. };
  53. //-------------------------------------------------------------------------------------------//
  54. class IAudioSystemEditor
  55. {
  56. public:
  57. IAudioSystemEditor() {}
  58. virtual ~IAudioSystemEditor() {}
  59. //! Reloads all the middleware control data
  60. virtual void Reload() = 0;
  61. //! Creates a new middleware control given the specifications passed in as a parameter.
  62. //! The control is owned by this class.
  63. //! @param controlDefinition Values to use to initialize the new control.
  64. //! @return A pointer to the newly created control.
  65. virtual IAudioSystemControl* CreateControl(const SControlDef& controlDefinition) = 0;
  66. //! This function returns the root of the tree to allow for traversing the tree manually.
  67. //! Middleware controls are organized in a tree structure.
  68. //! @return A pointer to the root of the control tree.
  69. virtual IAudioSystemControl* GetRoot() = 0;
  70. //! Gets the middleware control given its unique id.
  71. //! @param id Unique ID of the control.
  72. //! @return A pointer to the control that corresponds to the passed id. If none is found nullptr is returned.
  73. virtual IAudioSystemControl* GetControl(CID id) const = 0;
  74. //! Convert a middleware control type to an ATL control type.
  75. //! @param type Middleware control type
  76. //! @return An ATL control type that corresponds to the middleware control type passed as argument.
  77. virtual EACEControlType ImplTypeToATLType(TImplControlType type) const = 0;
  78. //! Given an ATL control type this function returns all the middleware control types that can be connected to it.
  79. //! @param atlControlType An ATL control type.
  80. //! @return A mask representing all the middleware control types that can be connected to the ATL control type passed as argument.
  81. virtual TImplControlTypeMask GetCompatibleTypes(EACEControlType atlControlType) const = 0;
  82. //! Creates and returns a connection to a middleware control.
  83. //! The connection object is owned by this class.
  84. //! @param atlControlType The type of the ATL control you are connecting to pMiddlewareControl.
  85. //! @param middlewareControl Middleware control for which to make the connection.
  86. //! @return A pointer to the newly created connection
  87. virtual TConnectionPtr CreateConnectionToControl(EACEControlType atlControlType, IAudioSystemControl* middlewareControl) = 0;
  88. //! Creates and returns a connection defined in an XML node.
  89. //! The format of the XML node should be in sync with the WriteConnectionToXMLNode function which is in charge of writing the node during serialization.
  90. //! If the XML node is unknown to the system NULL should be returned.
  91. //! If the middleware control referenced in the XML node does not exist it should be created and marked as "placeholder".
  92. //! @param node XML node where the connection is defined.
  93. //! @param atlControlType The type of the ATL control you are connecting to.
  94. //! @return A pointer to the newly created connection.
  95. virtual TConnectionPtr CreateConnectionFromXMLNode(AZ::rapidxml::xml_node<char>* node, EACEControlType atlControlType) = 0;
  96. //! When serializing connections between controls this function will be called once per connection to serialize its properties.
  97. //! This function should be in sync with CreateConnectionToControl as whatever it's written here will have to be read there.
  98. //! @param connection Connection to serialize.
  99. //! @param atlControlType Type of the ATL control that has this connection.
  100. //! @return XML node with the connection serialized.
  101. virtual AZ::rapidxml::xml_node<char>* CreateXMLNodeFromConnection(const TConnectionPtr connection, const EACEControlType atlControlType) = 0;
  102. //! Whenever a connection is removed from an ATL control this function should be called.
  103. //! To keep the system informed of which controls have been connected and which ones haven't.
  104. //! @param middlewareControl Middleware control that was disconnected.
  105. virtual void ConnectionRemoved([[maybe_unused]] IAudioSystemControl* middlewareControl) {}
  106. //! Returns the icon corresponding to the middleware control type passed as argument.
  107. //! @param type Middleware control type.
  108. //! @return A string with the path to the icon corresponding to the control type.
  109. virtual const AZStd::string_view GetTypeIcon(TImplControlType type) const = 0;
  110. //! Returns the selected state icon corresponding to the middleware control type passed as argument.
  111. //! @param type Middleware control type.
  112. //! @return A string with the path to the icon corresponding to the control type.
  113. virtual const AZStd::string_view GetTypeIconSelected(TImplControlType type) const = 0;
  114. //! Gets the name of the implementation which might be used in the ACE UI.
  115. //! @return String with the name of the implementation.
  116. virtual AZStd::string GetName() const = 0;
  117. //! Gets the folder where the implementation specific controls data are stored.
  118. //! This is used by the ACE to update if controls are changed while the editor is open.
  119. //! @return String with the path to the folder where the implementation specific controls are stored.
  120. virtual AZ::IO::FixedMaxPath GetDataPath() const = 0;
  121. //! Informs the plugin that the ACE has saved the data in case it needs to do any clean up.
  122. virtual void DataSaved() = 0;
  123. //! Creates a widget for modifying connection properties.
  124. //! The widget must have a "PropertiesChanged()" signal.
  125. //! The widget ownership transferred to the caller.
  126. virtual QWidget* CreateConnectionPropertiesWidget([[maybe_unused]] const TConnectionPtr connection,
  127. [[maybe_unused]] EACEControlType atlControlType) { return nullptr; }
  128. };
  129. } // namespace AudioControls