AkWwiseObjectDetailsStructCustomization.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. #if WITH_EDITOR
  16. #include "AkWaapiUMG/Components/AkWwiseObjectDetailsStructCustomization.h"
  17. #include "AkAudioDevice.h"
  18. #include "Framework/Application/SlateApplication.h"
  19. #include "Widgets/Images/SImage.h"
  20. #include "Widgets/Input/SButton.h"
  21. #include "DetailWidgetRow.h"
  22. #include "AkAudioStyle.h"
  23. #if UE_5_0_OR_LATER
  24. #include "Framework/Docking/TabManager.h"
  25. #endif
  26. #define LOCTEXT_NAMESPACE "AkWwiseObjectDetailsStructCustomization"
  27. TSharedRef<IPropertyTypeCustomization> FAkWwiseObjectDetailsStructCustomization::MakeInstance()
  28. {
  29. return MakeShareable(new FAkWwiseObjectDetailsStructCustomization());
  30. }
  31. void FAkWwiseObjectDetailsStructCustomization::CustomizeHeader( TSharedRef<IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils )
  32. {
  33. ItemNameProperty = StructPropertyHandle->GetChildHandle("ItemName");
  34. ItemPathProperty = StructPropertyHandle->GetChildHandle("ItemPath");
  35. ItemIdProperty = StructPropertyHandle->GetChildHandle("ItemId");
  36. if(ItemNameProperty.IsValid())
  37. {
  38. TSharedPtr<SWidget> PickerWidget = nullptr;
  39. PickerWidget = SAssignNew(PickerButton, SButton)
  40. .ButtonStyle(FAkAudioStyle::Get(), "AudiokineticTools.HoverHintOnly" )
  41. .ToolTipText( LOCTEXT( "WwiseItemToolTipText", "Choose a Wwise Item") )
  42. .OnClicked(FOnClicked::CreateSP(this, &FAkWwiseObjectDetailsStructCustomization::OnPickContent, ItemNameProperty.ToSharedRef()))
  43. .ContentPadding(2.0f)
  44. .ForegroundColor( FSlateColor::UseForeground() )
  45. .IsFocusable(false)
  46. [
  47. SNew(SImage)
  48. .Image(FAkAudioStyle::GetBrush("AudiokineticTools.Button_EllipsisIcon"))
  49. .ColorAndOpacity(FSlateColor::UseForeground())
  50. ];
  51. HeaderRow.ValueContent()
  52. .MinDesiredWidth(125.0f)
  53. .MaxDesiredWidth(600.0f)
  54. [
  55. SNew(SHorizontalBox)
  56. + SHorizontalBox::Slot()
  57. .FillWidth(1.0f)
  58. .VAlign(VAlign_Center)
  59. [
  60. ItemNameProperty->CreatePropertyValueWidget()
  61. ]
  62. + SHorizontalBox::Slot()
  63. .AutoWidth()
  64. .Padding(FMargin(4.0f, 0.0f, 0.0f, 0.0f))
  65. .VAlign(VAlign_Center)
  66. [
  67. PickerWidget.ToSharedRef()
  68. ]
  69. ]
  70. .NameContent()
  71. [
  72. StructPropertyHandle->CreatePropertyNameWidget()
  73. ];
  74. }
  75. }
  76. void FAkWwiseObjectDetailsStructCustomization::CustomizeChildren( TSharedRef<IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils )
  77. {
  78. }
  79. FReply FAkWwiseObjectDetailsStructCustomization::OnPickContent(TSharedRef<IPropertyHandle> PropertyHandle)
  80. {
  81. TSharedRef<SWindow> Window = SNew(SWindow)
  82. .Title(LOCTEXT("PropertyPickerWindowTitle", "Choose A Wwise Item"))
  83. .SizingRule(ESizingRule::UserSized)
  84. .AutoCenter(EAutoCenter::PreferredWorkArea)
  85. .ClientSize(FVector2D(350, 400));
  86. Window->SetContent(
  87. SNew(SBorder)
  88. [
  89. SAssignNew(WaapiPicker, SWaapiPicker)
  90. .FocusSearchBoxWhenOpened(true)
  91. .SelectionMode(ESelectionMode::Single)
  92. .OnSelectionChanged(this, &FAkWwiseObjectDetailsStructCustomization::TreeSelectionChanged)
  93. ]
  94. );
  95. TSharedPtr<SWindow> RootWindow = FGlobalTabmanager::Get()->GetRootWindow();
  96. FSlateApplication::Get().AddWindowAsNativeChild(Window, RootWindow.ToSharedRef());
  97. return FReply::Handled();
  98. }
  99. void FAkWwiseObjectDetailsStructCustomization::TreeSelectionChanged(TSharedPtr< FWwiseTreeItem > TreeItem, ESelectInfo::Type SelectInfo)
  100. {
  101. if (TreeItem.IsValid())
  102. {
  103. ItemNameProperty->SetValue(TreeItem->DisplayName);
  104. ItemIdProperty->SetValue(TreeItem->ItemId.ToString(EGuidFormats::DigitsWithHyphensInBraces));
  105. ItemPathProperty->SetValue(TreeItem->FolderPath);
  106. }
  107. }
  108. #undef LOCTEXT_NAMESPACE
  109. #endif//WITH_EDITOR