AkLateReverbComponentDetailsCustomization.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. #include "AkLateReverbComponentDetailsCustomization.h"
  16. #include "AkComponent.h"
  17. #include "AkLateReverbComponent.h"
  18. #include "DetailLayoutBuilder.h"
  19. #include "DetailCategoryBuilder.h"
  20. #include "ScopedTransaction.h"
  21. #include "IPropertyUtilities.h"
  22. #include "Widgets/Text/STextBlock.h"
  23. #define LOCTEXT_NAMESPACE "AudiokineticTools"
  24. //////////////////////////////////////////////////////////////////////////
  25. // FAkLateReverbComponentDetailsCustomization
  26. FAkLateReverbComponentDetailsCustomization::FAkLateReverbComponentDetailsCustomization()
  27. {
  28. }
  29. TSharedRef<IDetailCustomization> FAkLateReverbComponentDetailsCustomization::MakeInstance()
  30. {
  31. return MakeShareable(new FAkLateReverbComponentDetailsCustomization());
  32. }
  33. void FAkLateReverbComponentDetailsCustomization::CustomizeDetails(const TSharedPtr<IDetailLayoutBuilder>& InDetailBuilder)
  34. {
  35. InDetailBuilder->EditCategory("EnableComponent", FText::GetEmpty(), ECategoryPriority::Important);
  36. InDetailBuilder->EditCategory("Late Reverb", FText::GetEmpty(), ECategoryPriority::TypeSpecific);
  37. DetailBuilder = InDetailBuilder;
  38. CustomizeDetails(*InDetailBuilder);
  39. }
  40. void FAkLateReverbComponentDetailsCustomization::CustomizeDetails(IDetailLayoutBuilder& InDetailBuilder)
  41. {
  42. TArray<TWeakObjectPtr<UObject>> ObjectsBeingCustomized;
  43. InDetailBuilder.GetObjectsBeingCustomized(ObjectsBeingCustomized);
  44. InDetailBuilder.HideProperty("AuxBusManual");
  45. for (TWeakObjectPtr<UObject>& Object : ObjectsBeingCustomized)
  46. {
  47. UAkLateReverbComponent* LateReverbBeingCustomized = Cast<UAkLateReverbComponent>(Object.Get());
  48. if (LateReverbBeingCustomized)
  49. {
  50. UObject* OuterObj = LateReverbBeingCustomized->GetOuter();
  51. UActorComponent* OuterComponent = Cast<UActorComponent>(OuterObj);
  52. AActor* OuterActor = Cast<AActor>(OuterObj);
  53. // Do not hide the transform if the component has been created from within a component or actor, as this will hide the transform for that component / actor as well
  54. // (i.e. - only hide the transform if the component has been added to the hierarchy of a blueprint class or actor instance from the editor)
  55. if (OuterComponent == nullptr && OuterActor == nullptr)
  56. {
  57. IDetailCategoryBuilder& TransformCategory = InDetailBuilder.EditCategory("TransformCommon", LOCTEXT("TransformCommonCategory", "Transform"), ECategoryPriority::Transform);
  58. TransformCategory.SetCategoryVisibility(false);
  59. break;
  60. }
  61. }
  62. }
  63. if (ObjectsBeingCustomized.Num() != 1)
  64. {
  65. return;
  66. }
  67. UAkLateReverbComponent* LateReverbBeingCustomized = Cast<UAkLateReverbComponent>(ObjectsBeingCustomized[0].Get());
  68. if (LateReverbBeingCustomized)
  69. {
  70. IDetailCategoryBuilder& ToggleDetailCategory = InDetailBuilder.EditCategory("EnableComponent");
  71. auto EnableHandle = InDetailBuilder.GetProperty("bEnable");
  72. EnableHandle->SetOnPropertyValueChanged(FSimpleDelegate::CreateSP(this, &FAkLateReverbComponentDetailsCustomization::OnEnableValueChanged));
  73. if (!LateReverbBeingCustomized->bEnable)
  74. {
  75. InDetailBuilder.HideCategory("Late Reverb");
  76. }
  77. }
  78. }
  79. void FAkLateReverbComponentDetailsCustomization::OnEnableValueChanged()
  80. {
  81. if (DetailBuilder.IsValid())
  82. {
  83. IDetailLayoutBuilder* Layout = nullptr;
  84. if (auto LockedDetailBuilder = DetailBuilder.Pin())
  85. {
  86. Layout = LockedDetailBuilder.Get();
  87. }
  88. if (LIKELY(Layout))
  89. {
  90. Layout->ForceRefreshDetails();
  91. }
  92. }
  93. }
  94. //////////////////////////////////////////////////////////////////////////
  95. #undef LOCTEXT_NAMESPACE