SAkItemBoolProperties.cpp 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. /*------------------------------------------------------------------------------------
  16. SAkItemBoolProperties.cpp
  17. ------------------------------------------------------------------------------------*/
  18. /*------------------------------------------------------------------------------------
  19. includes.
  20. ------------------------------------------------------------------------------------*/
  21. #include "AkWaapiUMG/Components/SAkItemBoolProperties.h"
  22. #include "AkAudioDevice.h"
  23. #include "Widgets/Input/SSearchBox.h"
  24. #include "Widgets/Views/SListView.h"
  25. #include "Misc/ScopedSlowTask.h"
  26. #include "AkAudioStyle.h"
  27. #include "Framework/Application/SlateApplication.h"
  28. /*------------------------------------------------------------------------------------
  29. Defines
  30. ------------------------------------------------------------------------------------*/
  31. #define LOCTEXT_NAMESPACE "AkAudio"
  32. /*------------------------------------------------------------------------------------
  33. Statics and Globals
  34. ------------------------------------------------------------------------------------*/
  35. namespace SAkItemBoolProperties_Helpers
  36. {
  37. static const FString FullBoolPropertiesList[] =
  38. {
  39. TEXT("BypassEffect"),
  40. TEXT("BypassEffect0"),
  41. TEXT("BypassEffect1"),
  42. TEXT("BypassEffect2"),
  43. TEXT("BypassEffect3"),
  44. #if AK_WWISESDK_VERSION_MAJOR <= 2017
  45. TEXT("DynamicPositioning"),
  46. #endif
  47. #if AK_WWISESDK_VERSION_MAJOR >= 2019
  48. TEXT("EnableAttenuation"),
  49. #endif
  50. TEXT("EnableLoudnessNormalization"),
  51. TEXT("EnableMidiNoteTracking"),
  52. #if AK_WWISESDK_VERSION_MAJOR <= 2017
  53. TEXT("EnablePanner"),
  54. TEXT("EnablePositioning"),
  55. TEXT("FollowListenerOrientation"),
  56. #endif
  57. TEXT("HdrEnableEnvelope"),
  58. #if AK_WWISESDK_VERSION_MAJOR >= 2018
  59. TEXT("HoldEmitterPositionOrientation"),
  60. TEXT("HoldListenerOrientation"),
  61. #endif
  62. TEXT("IgnoreParentMaxSoundInstance"),
  63. TEXT("Inclusion"),
  64. TEXT("IsLoopingEnabled"),
  65. TEXT("IsLoopingInfinite"),
  66. TEXT("IsNonCachable"),
  67. TEXT("IsStreamingEnabled"),
  68. TEXT("IsZeroLantency"),
  69. #if AK_WWISESDK_VERSION_MAJOR >= 2018
  70. TEXT("ListenerRelativeRouting"),
  71. #endif
  72. TEXT("MidiBreakOnNoteOff"),
  73. TEXT("OverrideAnalysis"),
  74. TEXT("OverrideConversion"),
  75. TEXT("OverrideEffect"),
  76. TEXT("OverrideGameAuxSends"),
  77. TEXT("OverrideHdrEnvelope"),
  78. TEXT("OverrideMidiEventsBehavior"),
  79. TEXT("OverrideMidiNoteTracking"),
  80. TEXT("OverrideOutput"),
  81. TEXT("OverridePositioning"),
  82. TEXT("OverridePriority"),
  83. TEXT("OverrideUserAuxSends"),
  84. TEXT("OverrideVirtualVoice"),
  85. TEXT("PriorityDistanceFactor"),
  86. TEXT("RenderEffect0"),
  87. TEXT("RenderEffect1"),
  88. TEXT("RenderEffect2"),
  89. TEXT("RenderEffect3"),
  90. #if AK_WWISESDK_VERSION_MAJOR <= 2017
  91. TEXT("Spatialization"),
  92. #endif
  93. TEXT("UseGameAuxSends"),
  94. TEXT("UseMaxSoundPerInstance")
  95. };
  96. enum { FullBoolPropertiesListSize = sizeof(FullBoolPropertiesList) / sizeof(*FullBoolPropertiesList) };
  97. }
  98. /*------------------------------------------------------------------------------------
  99. Helpers
  100. ------------------------------------------------------------------------------------*/
  101. /*------------------------------------------------------------------------------------
  102. SAkItemBoolProperties
  103. ------------------------------------------------------------------------------------*/
  104. SAkItemBoolProperties::SAkItemBoolProperties()
  105. {}
  106. SAkItemBoolProperties::~SAkItemBoolProperties()
  107. {}
  108. void SAkItemBoolProperties::Construct(const FArguments& InArgs)
  109. {
  110. OnDragDetected = InArgs._OnDragDetected;
  111. OnSelectionChanged = InArgs._OnSelectionChanged;
  112. if (InArgs._FocusSearchBoxWhenOpened)
  113. {
  114. RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateSP(this, &SAkItemBoolProperties::SetFocusPostConstruct));
  115. }
  116. SearchBoxFilter = MakeShareable( new StringFilter( StringFilter::FItemToStringArray::CreateSP( this, &SAkItemBoolProperties::PopulateSearchStrings ) ) );
  117. SearchBoxFilter->OnChanged().AddSP( this, &SAkItemBoolProperties::FilterUpdated );
  118. ChildSlot
  119. [
  120. SNew(SBorder)
  121. .Padding(4)
  122. .BorderImage(FAkAudioStyle::GetBrush("AudiokineticTools.GroupBorder"))
  123. [
  124. SNew(SVerticalBox)
  125. // Search
  126. + SVerticalBox::Slot()
  127. .AutoHeight()
  128. .Padding(0, 1, 0, 3)
  129. [
  130. SNew(SHorizontalBox)
  131. + SHorizontalBox::Slot()
  132. .AutoWidth()
  133. [
  134. InArgs._SearchContent.Widget
  135. ]
  136. + SHorizontalBox::Slot()
  137. .FillWidth(1.0f)
  138. [
  139. SAssignNew(SearchBoxPtr,SSearchBox)
  140. .HintText( LOCTEXT( "PropertiesSearchHint", "Search an item property" ) )
  141. .ToolTipText(LOCTEXT("PropertiesSearchTooltip", "Type here to search for a property"))
  142. .OnTextChanged(SearchBoxFilter.Get(), &StringFilter::SetRawFilterText)
  143. .SelectAllTextWhenFocused(false)
  144. .DelayChangeNotificationsWhileTyping(true)
  145. ]
  146. ]
  147. // Tree
  148. +SVerticalBox::Slot()
  149. .FillHeight(1.f)
  150. [
  151. SAssignNew(ListViewPtr, SListView< TSharedPtr<FString> >)
  152. .ListItemsSource(&PropertiesList)
  153. .OnGenerateRow( this, &SAkItemBoolProperties::GenerateRow )
  154. .ItemHeight(18)
  155. .SelectionMode(InArgs._SelectionMode)
  156. .OnSelectionChanged(this, &SAkItemBoolProperties::ListSelectionChanged)
  157. .ClearSelectionOnClick(false)
  158. ]
  159. ]
  160. ];
  161. for (const auto& Property : SAkItemBoolProperties_Helpers::FullBoolPropertiesList)
  162. {
  163. PropertiesList.Add(MakeShareable(new FString(Property)));
  164. }
  165. ListViewPtr->RequestListRefresh();
  166. }
  167. TSharedRef<ITableRow> SAkItemBoolProperties::GenerateRow( TSharedPtr<FString> ItemProperty, const TSharedRef<STableViewBase>& OwnerTable )
  168. {
  169. check(ItemProperty.IsValid());
  170. TSharedPtr<ITableRow> NewRow = SNew(STableRow< TSharedPtr<FString> >, OwnerTable)
  171. .OnDragDetected(this, &SAkItemBoolProperties::HandleOnDragDetected)
  172. [
  173. SNew(STextBlock)
  174. .Text(FText::FromString(*ItemProperty.Get()))
  175. .HighlightText(SearchBoxFilter.Get(), &StringFilter::GetRawFilterText)
  176. ];
  177. return NewRow.ToSharedRef();
  178. }
  179. FReply SAkItemBoolProperties::HandleOnDragDetected(const FGeometry& Geometry, const FPointerEvent& MouseEvent)
  180. {
  181. // Refresh the contents
  182. if(OnDragDetected.IsBound())
  183. return OnDragDetected.Execute(Geometry,MouseEvent);
  184. return FReply::Unhandled();
  185. }
  186. void SAkItemBoolProperties::PopulateSearchStrings( const FString& PropertyName, OUT TArray< FString >& OutSearchStrings ) const
  187. {
  188. OutSearchStrings.Add( PropertyName );
  189. }
  190. void SAkItemBoolProperties::FilterUpdated()
  191. {
  192. FScopedSlowTask SlowTask(2.f, LOCTEXT("AK_PopulatingPicker", "Populating Properties Picker..."));
  193. SlowTask.MakeDialog();
  194. PropertiesList.Empty(SAkItemBoolProperties_Helpers::FullBoolPropertiesListSize);
  195. FString FilterString = SearchBoxFilter->GetRawFilterText().ToString();
  196. if (FilterString.IsEmpty())
  197. {
  198. for (const auto& Property : SAkItemBoolProperties_Helpers::FullBoolPropertiesList)
  199. {
  200. PropertiesList.Add(MakeShareable(new FString(Property)));
  201. }
  202. }
  203. else
  204. {
  205. for (const auto& Property : SAkItemBoolProperties_Helpers::FullBoolPropertiesList)
  206. {
  207. if (Property.Contains(FilterString))
  208. {
  209. PropertiesList.Add(MakeShareable(new FString(Property)));
  210. }
  211. }
  212. }
  213. ListViewPtr->RequestListRefresh();
  214. }
  215. void SAkItemBoolProperties::ListSelectionChanged( TSharedPtr< FString > ItemProperty, ESelectInfo::Type /*SelectInfo*/ )
  216. {
  217. if (OnSelectionChanged.IsBound())
  218. OnSelectionChanged.Execute(ItemProperty, ESelectInfo::OnMouseClick);
  219. }
  220. const TArray<TSharedPtr<FString>> SAkItemBoolProperties::GetSelectedProperties() const
  221. {
  222. return ListViewPtr->GetSelectedItems();
  223. }
  224. const FString SAkItemBoolProperties::GetSearchText() const
  225. {
  226. return SearchBoxFilter->GetRawFilterText().ToString();
  227. }
  228. const void SAkItemBoolProperties::SetSearchText(const FString& newText)
  229. {
  230. SearchBoxPtr->SetText(FText::FromString(newText));
  231. }
  232. EActiveTimerReturnType SAkItemBoolProperties::SetFocusPostConstruct(double InCurrentTime, float InDeltaTime)
  233. {
  234. FWidgetPath WidgetToFocusPath;
  235. FSlateApplication::Get().GeneratePathToWidgetUnchecked(SearchBoxPtr.ToSharedRef(), WidgetToFocusPath);
  236. FSlateApplication::Get().SetKeyboardFocus(WidgetToFocusPath, EFocusCause::SetDirectly);
  237. return EActiveTimerReturnType::Stop;
  238. }
  239. #undef LOCTEXT_NAMESPACE