You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
3.1 KiB
C++
67 lines
3.1 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#include "LmbrCentral_precompiled.h"
|
|
#include "EditorAudioPreloadComponent.h"
|
|
|
|
#include <AzCore/Serialization/EditContext.h>
|
|
#include <AzCore/Serialization/SerializeContext.h>
|
|
|
|
|
|
namespace LmbrCentral
|
|
{
|
|
//=========================================================================
|
|
void EditorAudioPreloadComponent::Reflect(AZ::ReflectContext* context)
|
|
{
|
|
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
|
|
{
|
|
serializeContext->Class<EditorAudioPreloadComponent, EditorComponentBase>()
|
|
->Version(1)
|
|
->Field("Preload Name", &EditorAudioPreloadComponent::m_defaultPreload)
|
|
->Field("Load Type", &EditorAudioPreloadComponent::m_loadType)
|
|
;
|
|
|
|
if (auto editContext = serializeContext->GetEditContext())
|
|
{
|
|
editContext->Enum<AudioPreloadComponent::LoadType>("Load Type", "Automatic or Manual loading and unloading")
|
|
->Value("Auto", AudioPreloadComponent::LoadType::Auto)
|
|
->Value("Manual", AudioPreloadComponent::LoadType::Manual)
|
|
;
|
|
|
|
editContext->Class<EditorAudioPreloadComponent>("Audio Preload", "The Audio Preload component is used to load and unload soundbanks contained in Audio Translation Layer (ATL) preloads")
|
|
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
|
->Attribute(AZ::Edit::Attributes::Category, "Audio")
|
|
->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/AudioPreload.svg")
|
|
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c))
|
|
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
|
|
|
// Icon todo:
|
|
//->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/AudioPreload.png")
|
|
|
|
->Attribute(AZ::Edit::Attributes::HelpPageURL, "https://docs.o3de.org/docs/user-guide/components/reference/audio-preload/")
|
|
|
|
->DataElement("AudioControl", &EditorAudioPreloadComponent::m_defaultPreload, "Preload Name", "The default ATL Preload control to use")
|
|
->DataElement(AZ::Edit::UIHandlers::ComboBox, &EditorAudioPreloadComponent::m_loadType, "Load Type", "Automatically when the component activates/deactivates, or Manually at user's request")
|
|
;
|
|
}
|
|
}
|
|
}
|
|
|
|
//=========================================================================
|
|
EditorAudioPreloadComponent::EditorAudioPreloadComponent()
|
|
{
|
|
m_defaultPreload.m_propertyType = AzToolsFramework::AudioPropertyType::Preload;
|
|
}
|
|
|
|
//=========================================================================
|
|
void EditorAudioPreloadComponent::BuildGameEntity(AZ::Entity* gameEntity)
|
|
{
|
|
gameEntity->CreateComponent<AudioPreloadComponent>(m_loadType, m_defaultPreload.m_controlName);
|
|
}
|
|
|
|
} // namespace LmbrCentral
|