EditorAudioPreloadComponent.cpp 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 "EditorAudioPreloadComponent.h"
  9. #include <AzCore/Serialization/EditContext.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. namespace LmbrCentral
  12. {
  13. //=========================================================================
  14. void EditorAudioPreloadComponent::Reflect(AZ::ReflectContext* context)
  15. {
  16. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  17. {
  18. serializeContext->Class<EditorAudioPreloadComponent, EditorComponentBase>()
  19. ->Version(1)
  20. ->Field("Preload Name", &EditorAudioPreloadComponent::m_defaultPreload)
  21. ->Field("Load Type", &EditorAudioPreloadComponent::m_loadType)
  22. ;
  23. serializeContext->Enum<AudioPreloadComponent::LoadType>()
  24. ->Value("Auto", AudioPreloadComponent::LoadType::Auto)
  25. ->Value("Manual", AudioPreloadComponent::LoadType::Manual)
  26. ;
  27. if (auto editContext = serializeContext->GetEditContext())
  28. {
  29. editContext->Enum<AudioPreloadComponent::LoadType>("Load Type", "Automatic or Manual loading and unloading")
  30. ->Value("Auto", AudioPreloadComponent::LoadType::Auto)
  31. ->Value("Manual", AudioPreloadComponent::LoadType::Manual)
  32. ;
  33. editContext->Class<EditorAudioPreloadComponent>("Audio Preload", "The Audio Preload component is used to load and unload soundbanks contained in Audio Translation Layer (ATL) preloads")
  34. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  35. ->Attribute(AZ::Edit::Attributes::Category, "Audio")
  36. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/AudioPreload.svg")
  37. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioPreload.svg")
  38. ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  39. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  40. // Icon todo:
  41. //->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioPreload.png")
  42. ->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/audio/preload/")
  43. ->DataElement("AudioControl", &EditorAudioPreloadComponent::m_defaultPreload, "Preload Name", "The default ATL Preload control to use")
  44. ->DataElement(AZ::Edit::UIHandlers::ComboBox, &EditorAudioPreloadComponent::m_loadType, "Load Type", "Automatically when the component activates/deactivates, or Manually at user's request")
  45. ;
  46. }
  47. }
  48. }
  49. //=========================================================================
  50. EditorAudioPreloadComponent::EditorAudioPreloadComponent()
  51. {
  52. m_defaultPreload.m_propertyType = AzToolsFramework::AudioPropertyType::Preload;
  53. }
  54. //=========================================================================
  55. void EditorAudioPreloadComponent::BuildGameEntity(AZ::Entity* gameEntity)
  56. {
  57. gameEntity->CreateComponent<AudioPreloadComponent>(m_loadType, m_defaultPreload.m_controlName);
  58. }
  59. } // namespace LmbrCentral