EditorAudioSwitchComponent.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 "EditorAudioSwitchComponent.h"
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. namespace LmbrCentral
  12. {
  13. //=========================================================================
  14. void EditorAudioSwitchComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  17. if (serializeContext)
  18. {
  19. serializeContext->Class<EditorAudioSwitchComponent, EditorComponentBase>()
  20. ->Version(1)
  21. ->Field("Switch name", &EditorAudioSwitchComponent::m_defaultSwitch)
  22. ->Field("State name", &EditorAudioSwitchComponent::m_defaultState)
  23. ;
  24. if (auto editContext = serializeContext->GetEditContext())
  25. {
  26. editContext->Class<EditorAudioSwitchComponent>("Audio Switch", "The Audio Switch component provides basic Audio Translation Layer (ATL) switch functionality to specify the state of an entity")
  27. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  28. ->Attribute(AZ::Edit::Attributes::Category, "Audio")
  29. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/AudioSwitch.svg")
  30. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioSwitch.svg")
  31. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  32. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  33. ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/switch/")
  34. ->DataElement("AudioControl", &EditorAudioSwitchComponent::m_defaultSwitch, "Default Switch", "The default ATL Switch to use when Activated")
  35. ->DataElement("AudioControl", &EditorAudioSwitchComponent::m_defaultState, "Default State", "The default ATL State to set on the default Switch when Activated")
  36. ;
  37. }
  38. }
  39. }
  40. //=========================================================================
  41. EditorAudioSwitchComponent::EditorAudioSwitchComponent()
  42. {
  43. m_defaultSwitch.m_propertyType = AzToolsFramework::AudioPropertyType::Switch;
  44. m_defaultState.m_propertyType = AzToolsFramework::AudioPropertyType::SwitchState;
  45. }
  46. //=========================================================================
  47. void EditorAudioSwitchComponent::BuildGameEntity(AZ::Entity* gameEntity)
  48. {
  49. gameEntity->CreateComponent<AudioSwitchComponent>(m_defaultSwitch.m_controlName, m_defaultState.m_controlName);
  50. }
  51. } // namespace LmbrCentral