/******************************************************************************* 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. *******************************************************************************/ #if WITH_EDITOR #include "AkWaapiUMG/Components/AkWwiseObjectDetailsStructCustomization.h" #include "AkAudioDevice.h" #include "Framework/Application/SlateApplication.h" #include "Widgets/Images/SImage.h" #include "Widgets/Input/SButton.h" #include "DetailWidgetRow.h" #include "AkAudioStyle.h" #if UE_5_0_OR_LATER #include "Framework/Docking/TabManager.h" #endif #define LOCTEXT_NAMESPACE "AkWwiseObjectDetailsStructCustomization" TSharedRef FAkWwiseObjectDetailsStructCustomization::MakeInstance() { return MakeShareable(new FAkWwiseObjectDetailsStructCustomization()); } void FAkWwiseObjectDetailsStructCustomization::CustomizeHeader( TSharedRef StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils ) { ItemNameProperty = StructPropertyHandle->GetChildHandle("ItemName"); ItemPathProperty = StructPropertyHandle->GetChildHandle("ItemPath"); ItemIdProperty = StructPropertyHandle->GetChildHandle("ItemId"); if(ItemNameProperty.IsValid()) { TSharedPtr PickerWidget = nullptr; PickerWidget = SAssignNew(PickerButton, SButton) .ButtonStyle(FAkAudioStyle::Get(), "AudiokineticTools.HoverHintOnly" ) .ToolTipText( LOCTEXT( "WwiseItemToolTipText", "Choose a Wwise Item") ) .OnClicked(FOnClicked::CreateSP(this, &FAkWwiseObjectDetailsStructCustomization::OnPickContent, ItemNameProperty.ToSharedRef())) .ContentPadding(2.0f) .ForegroundColor( FSlateColor::UseForeground() ) .IsFocusable(false) [ SNew(SImage) .Image(FAkAudioStyle::GetBrush("AudiokineticTools.Button_EllipsisIcon")) .ColorAndOpacity(FSlateColor::UseForeground()) ]; HeaderRow.ValueContent() .MinDesiredWidth(125.0f) .MaxDesiredWidth(600.0f) [ SNew(SHorizontalBox) + SHorizontalBox::Slot() .FillWidth(1.0f) .VAlign(VAlign_Center) [ ItemNameProperty->CreatePropertyValueWidget() ] + SHorizontalBox::Slot() .AutoWidth() .Padding(FMargin(4.0f, 0.0f, 0.0f, 0.0f)) .VAlign(VAlign_Center) [ PickerWidget.ToSharedRef() ] ] .NameContent() [ StructPropertyHandle->CreatePropertyNameWidget() ]; } } void FAkWwiseObjectDetailsStructCustomization::CustomizeChildren( TSharedRef StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils ) { } FReply FAkWwiseObjectDetailsStructCustomization::OnPickContent(TSharedRef PropertyHandle) { TSharedRef Window = SNew(SWindow) .Title(LOCTEXT("PropertyPickerWindowTitle", "Choose A Wwise Item")) .SizingRule(ESizingRule::UserSized) .AutoCenter(EAutoCenter::PreferredWorkArea) .ClientSize(FVector2D(350, 400)); Window->SetContent( SNew(SBorder) [ SAssignNew(WaapiPicker, SWaapiPicker) .FocusSearchBoxWhenOpened(true) .SelectionMode(ESelectionMode::Single) .OnSelectionChanged(this, &FAkWwiseObjectDetailsStructCustomization::TreeSelectionChanged) ] ); TSharedPtr RootWindow = FGlobalTabmanager::Get()->GetRootWindow(); FSlateApplication::Get().AddWindowAsNativeChild(Window, RootWindow.ToSharedRef()); return FReply::Handled(); } void FAkWwiseObjectDetailsStructCustomization::TreeSelectionChanged(TSharedPtr< FWwiseTreeItem > TreeItem, ESelectInfo::Type SelectInfo) { if (TreeItem.IsValid()) { ItemNameProperty->SetValue(TreeItem->DisplayName); ItemIdProperty->SetValue(TreeItem->ItemId.ToString(EGuidFormats::DigitsWithHyphensInBraces)); ItemPathProperty->SetValue(TreeItem->FolderPath); } } #undef LOCTEXT_NAMESPACE #endif//WITH_EDITOR