AkWaapiUriCustomization.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 "AkWaapiBlueprints/AkWaapiUriCustomization.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 "AkWaapiBlueprints/AkWaapiUri.h"
  23. #include "AkAudioStyle.h"
  24. #if UE_5_0_OR_LATER
  25. #include "Framework/Docking/TabManager.h"
  26. #endif
  27. #define LOCTEXT_NAMESPACE "AkWaapiUriCustomization"
  28. TSharedRef<IPropertyTypeCustomization> FAkWaapiUriCustomization::MakeInstance()
  29. {
  30. return MakeShareable(new FAkWaapiUriCustomization());
  31. }
  32. void FAkWaapiUriCustomization::CustomizeHeader(TSharedRef<IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
  33. {
  34. UriHandle = StructPropertyHandle->GetChildHandle("Uri");
  35. if (UriHandle.IsValid())
  36. {
  37. TSharedPtr<SWidget> PickerWidget = nullptr;
  38. PickerWidget = SAssignNew(PickerButton, SButton)
  39. .ButtonStyle(FAkAudioStyle::Get(), "AudiokineticTools.HoverHintOnly")
  40. .ToolTipText(LOCTEXT("WwiseUriToolTipText", "Choose A Uri"))
  41. .OnClicked(FOnClicked::CreateSP(this, &FAkWaapiUriCustomization::OnPickContent, UriHandle.ToSharedRef()))
  42. .ContentPadding(2.0f)
  43. .ForegroundColor(FSlateColor::UseForeground())
  44. .IsFocusable(false)
  45. [
  46. SNew(SImage)
  47. .Image(FAkAudioStyle::GetBrush("AudiokineticTools.Button_EllipsisIcon"))
  48. .ColorAndOpacity(FSlateColor::UseForeground())
  49. ];
  50. HeaderRow.ValueContent()
  51. .MinDesiredWidth(125.0f)
  52. .MaxDesiredWidth(600.0f)
  53. [
  54. SNew(SHorizontalBox)
  55. + SHorizontalBox::Slot()
  56. .FillWidth(1.0f)
  57. .VAlign(VAlign_Center)
  58. [
  59. UriHandle->CreatePropertyValueWidget()
  60. ]
  61. + SHorizontalBox::Slot()
  62. .AutoWidth()
  63. .Padding(FMargin(4.0f, 0.0f, 0.0f, 0.0f))
  64. .VAlign(VAlign_Center)
  65. [
  66. PickerWidget.ToSharedRef()
  67. ]
  68. ]
  69. .NameContent()
  70. [
  71. StructPropertyHandle->CreatePropertyNameWidget()
  72. ];
  73. }
  74. }
  75. void FAkWaapiUriCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> StructPropertyHandle, class IDetailChildrenBuilder& StructBuilder, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
  76. {
  77. }
  78. FReply FAkWaapiUriCustomization::OnPickContent(TSharedRef<IPropertyHandle> PropertyHandle)
  79. {
  80. Window = SNew(SWindow)
  81. .Title(LOCTEXT("UriPickerWindowTitle", "Choose A Uri"))
  82. .SizingRule(ESizingRule::UserSized)
  83. .AutoCenter(EAutoCenter::PreferredWorkArea)
  84. .ClientSize(FVector2D(350, 400));
  85. Window->SetContent(
  86. SNew(SBorder)
  87. [
  88. SNew(SAkWaapiUri)
  89. .FocusSearchBoxWhenOpened(true)
  90. .SelectionMode(ESelectionMode::Single)
  91. .OnSelectionChanged(this, &FAkWaapiUriCustomization::UriSelectionChanged)
  92. ]
  93. );
  94. TSharedPtr<SWindow> RootWindow = FGlobalTabmanager::Get()->GetRootWindow();
  95. FSlateApplication::Get().AddWindowAsNativeChild(Window.ToSharedRef(), RootWindow.ToSharedRef());
  96. return FReply::Handled();
  97. }
  98. void FAkWaapiUriCustomization::UriSelectionChanged(TSharedPtr< FString > in_Uri, ESelectInfo::Type SelectInfo)
  99. {
  100. if (in_Uri.IsValid())
  101. {
  102. UriHandle->SetValue(*in_Uri.Get());
  103. Window->RequestDestroyWindow();
  104. }
  105. }
  106. #undef LOCTEXT_NAMESPACE
  107. #endif//WITH_EDITOR