123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- /*******************************************************************************
- 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.
- *******************************************************************************/
- /*------------------------------------------------------------------------------------
- includes.
- ------------------------------------------------------------------------------------*/
- #include "AkWaapiUMG/Components/AkItemProperties.h"
- #include "AkAudioDevice.h"
- #include "Widgets/Input/SButton.h"
- #include "Framework/MultiBox/MultiBoxBuilder.h"
- #include "AkWaapiUMG/Components/WwisePropertyDragDropOp.h"
- #include "AkWaapiSlate/Widgets/Input/AkSSlider.h"
- #include "AkAudioStyle.h"
- /*------------------------------------------------------------------------------------
- Defines
- ------------------------------------------------------------------------------------*/
- #define LOCTEXT_NAMESPACE "AkWaapiUMG"
- /*------------------------------------------------------------------------------------
- UAkItemPropertiesConv
- ------------------------------------------------------------------------------------*/
- UAkItemPropertiesConv::UAkItemPropertiesConv(const class FObjectInitializer& ObjectInitializer)
- : Super(ObjectInitializer)
- {
- // Property initialization
- }
- FString UAkItemPropertiesConv::Conv_FAkPropertyToControlToString(const FAkPropertyToControl& INAkPropertyToControl)
- {
- return INAkPropertyToControl.ItemProperty;
- }
- FText UAkItemPropertiesConv::Conv_FAkPropertyToControlToText(const FAkPropertyToControl& INAkPropertyToControl)
- {
- return FText::FromString(*INAkPropertyToControl.ItemProperty);
- }
- /*------------------------------------------------------------------------------------
- Implementation
- ------------------------------------------------------------------------------------*/
- /////////////////////////////////////////////////////
- // UAkItemProperties
- UAkItemProperties::UAkItemProperties(const FObjectInitializer& ObjectInitializer)
- : Super(ObjectInitializer)
- {
- AkSSlider::FArguments Defaults;
- }
- TSharedRef<SWidget> UAkItemProperties::RebuildWidget()
- {
- bool autoFocus = GetWorld()->WorldType != EWorldType::Game &&
- GetWorld()->WorldType != EWorldType::PIE &&
- GetWorld()->WorldType != EWorldType::GamePreview;
- return
- SNew(SBorder)
- .BorderImage(FAkAudioStyle::GetBrush("AudiokineticTools.GroupBorder"))
- .Padding(FMargin(0.0f, 3.0f))
- .BorderBackgroundColor(FLinearColor(.6, .6, .6, 1.0f))
- [
- SNew(SVerticalBox)
- + SVerticalBox::Slot()
- .AutoHeight()
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot()
- .Padding(FMargin(10.0f, 0.0f, 0.0f, 0.0f))
- .AutoWidth()
- .VAlign(VAlign_Center)
- [
- SAssignNew(PropertyTextBlock, STextBlock)
- .IsEnabled(true)
- .ToolTipText(LOCTEXT("editable_Tooltip", "Property Name"))
- .MinDesiredWidth(300.f)
- .Text(FText::FromString(TEXT("Choose a property")))
- ]
- ]
- + SVerticalBox::Slot()
- [
- SAssignNew(WwiseProperties, SAkItemProperties)
- .FocusSearchBoxWhenOpened(autoFocus)
- .SelectionMode(ESelectionMode::Single)
- .OnSelectionChanged(FOnSelectionChanged::CreateUObject(this, &UAkItemProperties::PropertySelectionChanged))
- .OnDragDetected(FOnDragDetected::CreateUObject(this, &UAkItemProperties::HandleOnDragDetected))
- ]
- ];
- }
- void UAkItemProperties::PropertySelectionChanged(TSharedPtr< FString > PropertySelected, ESelectInfo::Type SelectInfo)
- {
- if (PropertySelected.IsValid())
- {
- const auto& PropertyString = *PropertySelected.Get();
- PropertyTextBlock->SetText(FText::FromString(PropertyString));
- if (OnSelectionChanged.IsBound())
- {
- OnSelectionChanged.Broadcast(PropertyString);
- }
- }
- }
- FReply UAkItemProperties::HandleOnDragDetected(const FGeometry& Geometry, const FPointerEvent& MouseEvent)
- {
- if (MouseEvent.IsMouseButtonDown(EKeys::LeftMouseButton) && WwiseProperties.IsValid())
- {
- const TArray<TSharedPtr<FString>>& PropertySelected = WwiseProperties->GetSelectedProperties();
- if (PropertySelected.Num() == 1)
- {
- if(OnPropertyDragged.IsBound())
- {
- OnPropertyDragged.Broadcast(*PropertySelected[0].Get());
- }
- TSharedRef<FWwisePropertyDragDropOp> Operation = FWwisePropertyDragDropOp::New(PropertySelected);
- return FReply::Handled().BeginDragDrop(Operation);
- }
- }
- return FReply::Unhandled();
- }
- FString UAkItemProperties::GetSelectedProperty() const
- {
- return *WwiseProperties->GetSelectedProperties()[0];
- }
- FString UAkItemProperties::GetSearchText() const
- {
- return WwiseProperties->GetSearchText();
- }
- void UAkItemProperties::SetSearchText(const FString& newText)
- {
- WwiseProperties->SetSearchText(newText);
- }
- void UAkItemProperties::ReleaseSlateResources(bool bReleaseChildren)
- {
- Super::ReleaseSlateResources(bReleaseChildren);
- PropertyTextBlock.Reset();
- WwiseProperties.Reset();
- }
- #if WITH_EDITOR
- const FText UAkItemProperties::GetPaletteCategory()
- {
- return LOCTEXT("Wwise", "Wwise");
- }
- #endif
- //
- /////////////////////////////////////////////////////
- #undef LOCTEXT_NAMESPACE
|