123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- /*******************************************************************************
- 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.
- *******************************************************************************/
- /*------------------------------------------------------------------------------------
- SAkItemBoolProperties.cpp
- ------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------
- includes.
- ------------------------------------------------------------------------------------*/
- #include "AkWaapiUMG/Components/SAkItemBoolProperties.h"
- #include "AkAudioDevice.h"
- #include "Widgets/Input/SSearchBox.h"
- #include "Widgets/Views/SListView.h"
- #include "Misc/ScopedSlowTask.h"
- #include "AkAudioStyle.h"
- #include "Framework/Application/SlateApplication.h"
- /*------------------------------------------------------------------------------------
- Defines
- ------------------------------------------------------------------------------------*/
- #define LOCTEXT_NAMESPACE "AkAudio"
- /*------------------------------------------------------------------------------------
- Statics and Globals
- ------------------------------------------------------------------------------------*/
- namespace SAkItemBoolProperties_Helpers
- {
- static const FString FullBoolPropertiesList[] =
- {
- TEXT("BypassEffect"),
- TEXT("BypassEffect0"),
- TEXT("BypassEffect1"),
- TEXT("BypassEffect2"),
- TEXT("BypassEffect3"),
- #if AK_WWISESDK_VERSION_MAJOR <= 2017
- TEXT("DynamicPositioning"),
- #endif
- #if AK_WWISESDK_VERSION_MAJOR >= 2019
- TEXT("EnableAttenuation"),
- #endif
- TEXT("EnableLoudnessNormalization"),
- TEXT("EnableMidiNoteTracking"),
- #if AK_WWISESDK_VERSION_MAJOR <= 2017
- TEXT("EnablePanner"),
- TEXT("EnablePositioning"),
- TEXT("FollowListenerOrientation"),
- #endif
- TEXT("HdrEnableEnvelope"),
- #if AK_WWISESDK_VERSION_MAJOR >= 2018
- TEXT("HoldEmitterPositionOrientation"),
- TEXT("HoldListenerOrientation"),
- #endif
- TEXT("IgnoreParentMaxSoundInstance"),
- TEXT("Inclusion"),
- TEXT("IsLoopingEnabled"),
- TEXT("IsLoopingInfinite"),
- TEXT("IsNonCachable"),
- TEXT("IsStreamingEnabled"),
- TEXT("IsZeroLantency"),
- #if AK_WWISESDK_VERSION_MAJOR >= 2018
- TEXT("ListenerRelativeRouting"),
- #endif
- TEXT("MidiBreakOnNoteOff"),
- TEXT("OverrideAnalysis"),
- TEXT("OverrideConversion"),
- TEXT("OverrideEffect"),
- TEXT("OverrideGameAuxSends"),
- TEXT("OverrideHdrEnvelope"),
- TEXT("OverrideMidiEventsBehavior"),
- TEXT("OverrideMidiNoteTracking"),
- TEXT("OverrideOutput"),
- TEXT("OverridePositioning"),
- TEXT("OverridePriority"),
- TEXT("OverrideUserAuxSends"),
- TEXT("OverrideVirtualVoice"),
- TEXT("PriorityDistanceFactor"),
- TEXT("RenderEffect0"),
- TEXT("RenderEffect1"),
- TEXT("RenderEffect2"),
- TEXT("RenderEffect3"),
- #if AK_WWISESDK_VERSION_MAJOR <= 2017
- TEXT("Spatialization"),
- #endif
- TEXT("UseGameAuxSends"),
- TEXT("UseMaxSoundPerInstance")
- };
- enum { FullBoolPropertiesListSize = sizeof(FullBoolPropertiesList) / sizeof(*FullBoolPropertiesList) };
- }
- /*------------------------------------------------------------------------------------
- Helpers
- ------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------
- SAkItemBoolProperties
- ------------------------------------------------------------------------------------*/
- SAkItemBoolProperties::SAkItemBoolProperties()
- {}
- SAkItemBoolProperties::~SAkItemBoolProperties()
- {}
- void SAkItemBoolProperties::Construct(const FArguments& InArgs)
- {
- OnDragDetected = InArgs._OnDragDetected;
- OnSelectionChanged = InArgs._OnSelectionChanged;
- if (InArgs._FocusSearchBoxWhenOpened)
- {
- RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateSP(this, &SAkItemBoolProperties::SetFocusPostConstruct));
- }
- SearchBoxFilter = MakeShareable( new StringFilter( StringFilter::FItemToStringArray::CreateSP( this, &SAkItemBoolProperties::PopulateSearchStrings ) ) );
- SearchBoxFilter->OnChanged().AddSP( this, &SAkItemBoolProperties::FilterUpdated );
-
- ChildSlot
- [
- SNew(SBorder)
- .Padding(4)
- .BorderImage(FAkAudioStyle::GetBrush("AudiokineticTools.GroupBorder"))
- [
- SNew(SVerticalBox)
- // Search
- + SVerticalBox::Slot()
- .AutoHeight()
- .Padding(0, 1, 0, 3)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot()
- .AutoWidth()
- [
- InArgs._SearchContent.Widget
- ]
- + SHorizontalBox::Slot()
- .FillWidth(1.0f)
- [
- SAssignNew(SearchBoxPtr,SSearchBox)
- .HintText( LOCTEXT( "PropertiesSearchHint", "Search an item property" ) )
- .ToolTipText(LOCTEXT("PropertiesSearchTooltip", "Type here to search for a property"))
- .OnTextChanged(SearchBoxFilter.Get(), &StringFilter::SetRawFilterText)
- .SelectAllTextWhenFocused(false)
- .DelayChangeNotificationsWhileTyping(true)
- ]
- ]
- // Tree
- +SVerticalBox::Slot()
- .FillHeight(1.f)
- [
- SAssignNew(ListViewPtr, SListView< TSharedPtr<FString> >)
- .ListItemsSource(&PropertiesList)
- .OnGenerateRow( this, &SAkItemBoolProperties::GenerateRow )
- .ItemHeight(18)
- .SelectionMode(InArgs._SelectionMode)
- .OnSelectionChanged(this, &SAkItemBoolProperties::ListSelectionChanged)
- .ClearSelectionOnClick(false)
- ]
- ]
- ];
-
- for (const auto& Property : SAkItemBoolProperties_Helpers::FullBoolPropertiesList)
- {
- PropertiesList.Add(MakeShareable(new FString(Property)));
- }
- ListViewPtr->RequestListRefresh();
- }
- TSharedRef<ITableRow> SAkItemBoolProperties::GenerateRow( TSharedPtr<FString> ItemProperty, const TSharedRef<STableViewBase>& OwnerTable )
- {
- check(ItemProperty.IsValid());
-
- TSharedPtr<ITableRow> NewRow = SNew(STableRow< TSharedPtr<FString> >, OwnerTable)
- .OnDragDetected(this, &SAkItemBoolProperties::HandleOnDragDetected)
- [
- SNew(STextBlock)
- .Text(FText::FromString(*ItemProperty.Get()))
- .HighlightText(SearchBoxFilter.Get(), &StringFilter::GetRawFilterText)
- ];
- return NewRow.ToSharedRef();
- }
- FReply SAkItemBoolProperties::HandleOnDragDetected(const FGeometry& Geometry, const FPointerEvent& MouseEvent)
- {
- // Refresh the contents
- if(OnDragDetected.IsBound())
- return OnDragDetected.Execute(Geometry,MouseEvent);
- return FReply::Unhandled();
- }
- void SAkItemBoolProperties::PopulateSearchStrings( const FString& PropertyName, OUT TArray< FString >& OutSearchStrings ) const
- {
- OutSearchStrings.Add( PropertyName );
- }
- void SAkItemBoolProperties::FilterUpdated()
- {
- FScopedSlowTask SlowTask(2.f, LOCTEXT("AK_PopulatingPicker", "Populating Properties Picker..."));
- SlowTask.MakeDialog();
- PropertiesList.Empty(SAkItemBoolProperties_Helpers::FullBoolPropertiesListSize);
- FString FilterString = SearchBoxFilter->GetRawFilterText().ToString();
- if (FilterString.IsEmpty())
- {
- for (const auto& Property : SAkItemBoolProperties_Helpers::FullBoolPropertiesList)
- {
- PropertiesList.Add(MakeShareable(new FString(Property)));
- }
- }
- else
- {
- for (const auto& Property : SAkItemBoolProperties_Helpers::FullBoolPropertiesList)
- {
- if (Property.Contains(FilterString))
- {
- PropertiesList.Add(MakeShareable(new FString(Property)));
- }
- }
- }
- ListViewPtr->RequestListRefresh();
- }
- void SAkItemBoolProperties::ListSelectionChanged( TSharedPtr< FString > ItemProperty, ESelectInfo::Type /*SelectInfo*/ )
- {
- if (OnSelectionChanged.IsBound())
- OnSelectionChanged.Execute(ItemProperty, ESelectInfo::OnMouseClick);
- }
- const TArray<TSharedPtr<FString>> SAkItemBoolProperties::GetSelectedProperties() const
- {
- return ListViewPtr->GetSelectedItems();
- }
- const FString SAkItemBoolProperties::GetSearchText() const
- {
- return SearchBoxFilter->GetRawFilterText().ToString();
- }
- const void SAkItemBoolProperties::SetSearchText(const FString& newText)
- {
- SearchBoxPtr->SetText(FText::FromString(newText));
- }
- EActiveTimerReturnType SAkItemBoolProperties::SetFocusPostConstruct(double InCurrentTime, float InDeltaTime)
- {
- FWidgetPath WidgetToFocusPath;
- FSlateApplication::Get().GeneratePathToWidgetUnchecked(SearchBoxPtr.ToSharedRef(), WidgetToFocusPath);
- FSlateApplication::Get().SetKeyboardFocus(WidgetToFocusPath, EFocusCause::SetDirectly);
- return EActiveTimerReturnType::Stop;
- }
- #undef LOCTEXT_NAMESPACE
|