123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- /*******************************************************************************
- The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
- Technology released in source code form as part of the game integration package.
- The content of this file may not be used without valid licenses to the
- AUDIOKINETIC Wwise Technology.
- Note that the use of the game engine is subject to the Unreal(R) Engine End User
- License Agreement at https://www.unrealengine.com/en-US/eula/unreal
-
- License Usage
-
- Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
- this file in accordance with the end user license agreement provided with the
- software or, alternatively, in accordance with the terms contained
- in a written agreement between you and Audiokinetic Inc.
- Copyright (c) 2023 Audiokinetic Inc.
- *******************************************************************************/
- #include "SAkGeometrySurfaceOverrideController.h"
- #include "DetailCategoryBuilder.h"
- #include "DetailLayoutBuilder.h"
- #include "PropertyCustomizationHelpers.h"
- #include "Editor/TransBuffer.h"
- #include "Widgets/Input/SCheckBox.h"
- #include "Widgets/Input/SNumericEntryBox.h"
- #include "Widgets/Layout/SBox.h"
- #include "AkGeometryComponent.h"
- #include "WwiseUEFeatures.h"
- namespace AkGeometryUI
- {
- static int LabelWidth = 146;
- }
- void SSurfacePropertiesLabels::Construct(const FArguments& InArgs, FAkGeometrySurfaceOverride* InSurfaceOverride)
- {
- SurfaceOverride = InSurfaceOverride;
- ChildSlot
- [
- SNew(SVerticalBox)
- + SVerticalBox::Slot() // Acoustic Surface Parameters
- .FillHeight(1.0f)
- [
- SNew(SVerticalBox)
- + SVerticalBox::Slot() // Texture
- .FillHeight(0.33f)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot() // Label
- .HAlign(HAlign_Left)
- .VAlign(VAlign_Center)
- .AutoWidth()
- [
- SNew(SBox)
- .WidthOverride(AkGeometryUI::LabelWidth)
- [
- SNew(STextBlock)
- .ToolTipText(FText::FromString("The Audiokinetic Texture associated with the surface."))
- .Text(FText::FromString(FString(TEXT("AkAcousticTexture"))))
- .Font(IDetailLayoutBuilder::GetDetailFont())
- ]
- ]
- ]
- + SVerticalBox::Slot() // Transmission Loss
- .FillHeight(0.33f)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot() // Label
- .HAlign(HAlign_Left)
- .VAlign(VAlign_Center)
- .AutoWidth()
- [
- SNew(SBox)
- .WidthOverride(AkGeometryUI::LabelWidth)
- [
- SNew(STextBlock)
- .ToolTipText(FText::FromString("Indicates whether the surface overrides the transmission loss value."))
- .Text(FText::FromString(FString(TEXT("Override Transmission Loss"))))
- .Font(IDetailLayoutBuilder::GetDetailFont())
- ]
- ]
- ]
- + SVerticalBox::Slot() // Enable Transmission Loss Override
- .FillHeight(0.33f)
- [
- SNew(SBox)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot() // Label
- .HAlign(HAlign_Left)
- .VAlign(VAlign_Center)
- .AutoWidth()
- [
- SNew(SBox)
- .WidthOverride(AkGeometryUI::LabelWidth)
- .Visibility_Lambda([this]() { return TransmissionLossVisibility(); })
- [
- SNew(STextBlock)
- .ToolTipText(FText::FromString("Indicates how much sound is transmitted through the surface."))
- .Text(FText::FromString(FString(TEXT("Transmission Loss"))))
- .Font(IDetailLayoutBuilder::GetDetailFont())
- ]
- ]
- ]
- ]
- ]
- ];
- }
- EVisibility SSurfacePropertiesLabels::TransmissionLossVisibility() const
- {
- if (SurfaceOverride == nullptr)
- return EVisibility::Visible;
- return SurfaceOverride->bEnableOcclusionOverride ? EVisibility::Visible : EVisibility::Collapsed;
- }
- // ==================================================
- // SAkGeometrySurfaceController
- // ==================================================
- void SAkGeometrySurfaceController::Construct(const FArguments& InArgs, TWeakObjectPtr<UObject> ObjectBeingCustomized, const TSharedPtr<IDetailLayoutBuilder>& InLayoutBuilder)
- {
- LayoutBuilder = InLayoutBuilder;
- ComponentBeingCustomized = Cast<UAkGeometryComponent>(ObjectBeingCustomized);
- BuildSlate();
- }
- SAkGeometrySurfaceController::~SAkGeometrySurfaceController()
- {
- }
- void SAkGeometrySurfaceController::BeginModify(FText TransactionText)
- {
- if (GEditor && GEditor->Trans)
- {
- UTransBuffer* TransBuffer = CastChecked<UTransBuffer>(GEditor->Trans);
- if (TransBuffer != nullptr)
- TransBuffer->Begin(*FString("AkGeometry Acoustic Surfaces"), TransactionText);
- }
- if (ComponentBeingCustomized != nullptr)
- ComponentBeingCustomized->Modify();
- }
- void SAkGeometrySurfaceController::EndModify()
- {
- if (GEditor && GEditor->Trans)
- {
- UTransBuffer* TransBuffer = CastChecked<UTransBuffer>(GEditor->Trans);
- if (TransBuffer != nullptr)
- TransBuffer->End();
- }
- }
- FString SAkGeometrySurfaceController::GetSelectedTextureAssetPath() const
- {
- FAkGeometrySurfaceOverride* SurfaceProperties = GetSurfaceOverride();
- if (SurfaceProperties == nullptr)
- return "";
- FSoftObjectPath Path(SurfaceProperties->AcousticTexture);
- return Path.GetAssetPathString();
- }
- void SAkGeometrySurfaceController::OnTextureAssetChanged(const FAssetData& InAssetData)
- {
- BeginModify(FText::FromString(FString("Set AkGeometry Texture")));
- FAkGeometrySurfaceOverride* SurfaceProperties = GetSurfaceOverride();
- if (SurfaceProperties != nullptr)
- {
- SurfaceProperties->AcousticTexture = Cast<UAkAcousticTexture>(InAssetData.GetAsset());
- }
- EndModify();
- }
- TOptional<float> SAkGeometrySurfaceController::GetTransmissionLossValue() const
- {
- if (GetSurfaceOverride() != nullptr)
- return GetSurfaceOverride()->OcclusionValue;
- return 0.0f;
- }
- void SAkGeometrySurfaceController::OnTransmissionLossChanged(float NewValue, ETextCommit::Type Commit)
- {
- // Only apply valid values
- if (NewValue >= 0.0f && NewValue <= 1.0f)
- {
- if (GetSurfaceOverride() != nullptr)
- {
- BeginModify(FText::FromString(FString("AkGeometry: Set Transmission Loss Value")));
- GetSurfaceOverride()->OcclusionValue = NewValue;
- EndModify();
- }
- }
- }
- EVisibility SAkGeometrySurfaceController::TransmissionLossVisibility() const
- {
- if (GetSurfaceOverride() == nullptr)
- return EVisibility::Visible;
- return GetSurfaceOverride()->bEnableOcclusionOverride ? EVisibility::Visible : EVisibility::Collapsed;
- }
- ECheckBoxState SAkGeometrySurfaceController::GetEnableTransmissionLossOverrideCheckBoxState() const
- {
- if (GetSurfaceOverride() == nullptr)
- return ECheckBoxState::Undetermined;
- bool bEnabled = GetSurfaceOverride()->bEnableOcclusionOverride;
- return bEnabled ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
- }
- void SAkGeometrySurfaceController::OnEnableTransmissionLossOverrideChanged(ECheckBoxState NewState)
- {
- if (GetSurfaceOverride() != nullptr)
- {
- bool bEnable = NewState == ECheckBoxState::Checked;
- FString ModifyString = bEnable ? "AkGeometry: Enable Transmission Loss Override"
- : "AkGeometry: Disable Transmission Loss Override";
- BeginModify(FText::FromString(ModifyString));
- GetSurfaceOverride()->bEnableOcclusionOverride = bEnable;
- EndModify();
- }
- }
- void SAkGeometrySurfaceController::BuildSlate()
- {
- FSlateFontInfo selectionInfoFont = LayoutBuilder.IsValid() ? LayoutBuilder.Pin()->GetDetailFontItalic() : FAkAppStyle::Get().GetFontStyle("TinyText");
- ChildSlot
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot() // Controls
- .AutoWidth()
- [
- SNew(SVerticalBox)
- + SVerticalBox::Slot() // Texture
- .FillHeight(0.33f)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot() // Control
- .HAlign(HAlign_Left)
- .VAlign(VAlign_Center)
- .AutoWidth()
- [
- SNew(SOverlay)
- + SOverlay::Slot()
- [
- SNew(SObjectPropertyEntryBox)
- .AllowedClass(UAkAcousticTexture::StaticClass())
- .OnObjectChanged(this, &SAkGeometrySurfaceController::OnTextureAssetChanged)
- .ObjectPath(this, &SAkGeometrySurfaceController::GetSelectedTextureAssetPath)
- .ToolTipText(FText::FromString("The Audiokinetic Texture associated with the surface."))
- ]
- ]
- ]
- + SVerticalBox::Slot() // Enable Transmission Loss Override
- .FillHeight(0.33f)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot() // Control
- .HAlign(HAlign_Left)
- .VAlign(VAlign_Center)
- .AutoWidth()
- [
- SNew(SCheckBox)
- .OnCheckStateChanged(this, &SAkGeometrySurfaceController::OnEnableTransmissionLossOverrideChanged)
- .IsChecked(this, &SAkGeometrySurfaceController::GetEnableTransmissionLossOverrideCheckBoxState)
- .ToolTipText(FText::FromString("Indicates whether the surface overrides the transmission loss value."))
- ]
- ]
- + SVerticalBox::Slot() // Transmission Loss
- .FillHeight(0.33f)
- [
- SNew(SBox)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot() // Control
- .HAlign(HAlign_Left)
- .VAlign(VAlign_Center)
- .AutoWidth()
- [
- SNew(SOverlay)
- + SOverlay::Slot()
- [
- SNew(SBox)
- .Visibility_Lambda([this]() { return TransmissionLossVisibility(); })
- [
- SNew(SNumericEntryBox<float>)
- .MinValue(0.0f)
- .MaxValue(1.0f)
- .MinSliderValue(0.0f)
- .MaxSliderValue(1.0f)
- .ToolTipText(FText::FromString("Indicates how much sound is transmitted through the surface."))
- .Value(this, &SAkGeometrySurfaceController::GetTransmissionLossValue)
- .OnValueCommitted(this, &SAkGeometrySurfaceController::OnTransmissionLossChanged)
- ]
- ]
- ]
- ]
- ]
- ]
- + SHorizontalBox::Slot() // Labels
- .AutoWidth()
- [
- SNew(SSurfacePropertiesLabels, GetSurfaceOverride())
- ]
- ];
- }
- FAkGeometrySurfaceOverride* SAkGeometryCollisionMeshSurfaceController::GetSurfaceOverride() const
- {
- if (ComponentBeingCustomized == nullptr)
- return nullptr;
- return &(ComponentBeingCustomized->CollisionMeshSurfaceOverride);
- }
- void SAkGeometryStaticMeshSurfaceController::Construct(const FArguments& InArgs, TWeakObjectPtr<UObject> ObjectBeingCustomized, const TSharedPtr<IDetailLayoutBuilder>& InLayoutBuilder, UMaterialInterface* InMaterialKey)
- {
- MaterialKey = InMaterialKey;
- SAkGeometrySurfaceController::Construct(InArgs, ObjectBeingCustomized, InLayoutBuilder);
- }
- FAkGeometrySurfaceOverride* SAkGeometryStaticMeshSurfaceController::GetSurfaceOverride() const
- {
- if (ComponentBeingCustomized == nullptr)
- return nullptr;
- return ComponentBeingCustomized->StaticMeshSurfaceOverride.Find(MaterialKey);
- }
|