123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- /*******************************************************************************
- 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.
- *******************************************************************************/
- /*------------------------------------------------------------------------------------
- SAkItemProperties.cpp
- ------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------
- includes.
- ------------------------------------------------------------------------------------*/
- #include "AkWaapiUMG/Components/SAkItemProperties.h"
- #include "AkAudioDevice.h"
- #include "Widgets/Input/SSearchBox.h"
- #include "Layout/WidgetPath.h"
- #include "Misc/ScopedSlowTask.h"
- #include "AkAudioStyle.h"
- #include "Framework/Application/SlateApplication.h"
- /*------------------------------------------------------------------------------------
- Defines
- ------------------------------------------------------------------------------------*/
- #define LOCTEXT_NAMESPACE "AkAudio"
- /*------------------------------------------------------------------------------------
- Statics and Globals
- ------------------------------------------------------------------------------------*/
- namespace SAkItemProperties_Helpers
- {
- static const FString FullPropertiesList[] =
- {
- #if AK_WWISESDK_VERSION_MAJOR >= 2018
- TEXT("CenterPercentage"),
- #endif
- #if AK_WWISESDK_VERSION_MAJOR <= 2017
- TEXT("DivergenceCenter"),
- #endif
- TEXT("GameAuxSendHPF"),
- TEXT("GameAuxSendLPF"),
- TEXT("GameAuxSendVolume"),
- TEXT("HdrActiveRange"),
- TEXT("HdrEnvelopeSensitivity"),
- TEXT("Highpass"),
- TEXT("InitialDelay"),
- TEXT("LoopCount"),
- TEXT("Lowpass"),
- TEXT("MakeUpGain"),
- TEXT("MaxSoundPerInstance"),
- TEXT("MidiChannelFilter"),
- TEXT("MidiKeyFilterMax"),
- TEXT("MidiKeyFilterMin"),
- TEXT("MidiTrackingRootNote"),
- TEXT("MidiTransposition"),
- TEXT("MidiVelocityFilterMax"),
- TEXT("MidiVelocityFilterMin"),
- TEXT("MidiVelocityOffset"),
- #if AK_WWISESDK_VERSION_MAJOR <= 2017
- TEXT("MotionLowpass"),
- TEXT("MotionVolume"),
- #endif
- TEXT("OutputBusHighpass"),
- TEXT("OutputBusLowpass"),
- TEXT("OutputBusVolume"),
- TEXT("Pitch"),
- TEXT("PreFetchLength"),
- TEXT("Priority"),
- TEXT("PriorityDistanceOffset"),
- #if AK_WWISESDK_VERSION_MAJOR >= 2018
- TEXT("SpeakerPanning3DSpatializationMix"),
- #endif
- TEXT("UserAuxSendVolume0"),
- TEXT("UserAuxSendVolume1"),
- TEXT("UserAuxSendVolume2"),
- TEXT("UserAuxSendVolume3"),
- TEXT("Volume"),
- TEXT("Weight")
- };
- enum { FullPropertiesListSize = sizeof(FullPropertiesList) / sizeof(*FullPropertiesList) };
- }
- /*------------------------------------------------------------------------------------
- Helpers
- ------------------------------------------------------------------------------------*/
- /*------------------------------------------------------------------------------------
- Implementation
- ------------------------------------------------------------------------------------*/
- SAkItemProperties::SAkItemProperties()
- {}
- SAkItemProperties::~SAkItemProperties()
- {}
- void SAkItemProperties::Construct(const FArguments& InArgs)
- {
- OnDragDetected = InArgs._OnDragDetected;
- OnSelectionChanged = InArgs._OnSelectionChanged;
- if (InArgs._FocusSearchBoxWhenOpened)
- {
- RegisterActiveTimer(0.f, FWidgetActiveTimerDelegate::CreateSP(this, &SAkItemProperties::SetFocusPostConstruct));
- }
- SearchBoxFilter = MakeShareable( new StringFilter( StringFilter::FItemToStringArray::CreateSP( this, &SAkItemProperties::PopulateSearchStrings ) ) );
- SearchBoxFilter->OnChanged().AddSP( this, &SAkItemProperties::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( this, &SAkItemProperties::OnSearchBoxChanged )
- .SelectAllTextWhenFocused(false)
- .DelayChangeNotificationsWhileTyping(true)
- ]
- ]
- // Tree
- +SVerticalBox::Slot()
- .FillHeight(1.f)
- [
- SAssignNew(ListViewPtr, SListView< TSharedPtr<FString> >)
- .ListItemsSource(&PropertiesList)
- .OnGenerateRow( this, &SAkItemProperties::GenerateRow )
- .ItemHeight(18)
- .SelectionMode(InArgs._SelectionMode)
- .OnSelectionChanged(this, &SAkItemProperties::ListSelectionChanged)
- .ClearSelectionOnClick(false)
- ]
- ]
- ];
- for (const auto& Property : SAkItemProperties_Helpers::FullPropertiesList)
- {
- PropertiesList.Add(MakeShareable(new FString(Property)));
- }
- ListViewPtr->RequestListRefresh();
- }
- TSharedRef<ITableRow> SAkItemProperties::GenerateRow( TSharedPtr<FString> ItemProperty, const TSharedRef<STableViewBase>& OwnerTable )
- {
- check(ItemProperty.IsValid());
-
- TSharedPtr<ITableRow> NewRow = SNew(STableRow< TSharedPtr<FString> >, OwnerTable)
- .OnDragDetected(this, &SAkItemProperties::HandleOnDragDetected)
- [
- SNew(STextBlock)
- .Text(FText::FromString(*ItemProperty.Get()))
- .HighlightText(SearchBoxFilter.Get(), &StringFilter::GetRawFilterText)
- ];
- return NewRow.ToSharedRef();
- }
- FReply SAkItemProperties::HandleOnDragDetected(const FGeometry& Geometry, const FPointerEvent& MouseEvent)
- {
- // Refresh the contents
- if(OnDragDetected.IsBound())
- return OnDragDetected.Execute(Geometry,MouseEvent);
- return FReply::Unhandled();
- }
- void SAkItemProperties::PopulateSearchStrings( const FString& PropertyName, OUT TArray< FString >& OutSearchStrings ) const
- {
- OutSearchStrings.Add( PropertyName );
- }
- void SAkItemProperties::OnSearchBoxChanged( const FText& InSearchText )
- {
- SearchBoxFilter->SetRawFilterText( InSearchText );
- }
- void SAkItemProperties::FilterUpdated()
- {
- FScopedSlowTask SlowTask(2.f, LOCTEXT("AK_PopulatingPicker", "Populating Properties Picker..."));
- SlowTask.MakeDialog();
- PropertiesList.Empty(SAkItemProperties_Helpers::FullPropertiesListSize);
- const FString& FilterString = SearchBoxFilter->GetRawFilterText().ToString();
- if (FilterString.IsEmpty())
- {
- for (const auto& Property : SAkItemProperties_Helpers::FullPropertiesList)
- {
- PropertiesList.Add(MakeShareable(new FString(Property)));
- }
- }
- else
- {
- for (const auto& Property : SAkItemProperties_Helpers::FullPropertiesList)
- {
- if (Property.Contains(FilterString))
- {
- PropertiesList.Add(MakeShareable(new FString(Property)));
- }
- }
- }
- ListViewPtr->RequestListRefresh();
- }
- void SAkItemProperties::ListSelectionChanged( TSharedPtr< FString > ItemProperty, ESelectInfo::Type /*SelectInfo*/ )
- {
- if (OnSelectionChanged.IsBound())
- OnSelectionChanged.Execute(ItemProperty, ESelectInfo::OnMouseClick);
- }
- const TArray<TSharedPtr<FString>> SAkItemProperties::GetSelectedProperties() const
- {
- return ListViewPtr->GetSelectedItems();
- }
- const FString SAkItemProperties::GetSearchText() const
- {
- return SearchBoxFilter->GetRawFilterText().ToString();
- }
- const void SAkItemProperties::SetSearchText(const FString& newText)
- {
- SearchBoxPtr->SetText(FText::FromString(newText));
- }
- EActiveTimerReturnType SAkItemProperties::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
|