123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- /*******************************************************************************
- 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/AkItemBoolProperties.h"
- #include "AkAudioDevice.h"
- #include "Widgets/Input/SButton.h"
- #include "Framework/MultiBox/MultiBoxBuilder.h"
- #include "AkWaapiUMG/Components/WwiseBoolPropertyDragDropOp.h"
- /*------------------------------------------------------------------------------------
- Defines
- ------------------------------------------------------------------------------------*/
- #define LOCTEXT_NAMESPACE "AkWaapiUMG"
- /*------------------------------------------------------------------------------------
- UAkItemBoolPropertiesConv
- ------------------------------------------------------------------------------------*/
- UAkItemBoolPropertiesConv::UAkItemBoolPropertiesConv(const class FObjectInitializer& ObjectInitializer)
- : Super(ObjectInitializer)
- {
- // Property initialization
- }
- FString UAkItemBoolPropertiesConv::Conv_FAkBoolPropertyToControlToString(const FAkBoolPropertyToControl& INAkBoolPropertyToControl)
- {
- return INAkBoolPropertyToControl.ItemProperty;
- }
- FText UAkItemBoolPropertiesConv::Conv_FAkBoolPropertyToControlToText(const FAkBoolPropertyToControl& INAkBoolPropertyToControl)
- {
- return FText::FromString(*INAkBoolPropertyToControl.ItemProperty);
- }
- /*------------------------------------------------------------------------------------
- Implementation
- ------------------------------------------------------------------------------------*/
- /////////////////////////////////////////////////////
- // UAkItemBoolProperties
- UAkItemBoolProperties::UAkItemBoolProperties(const FObjectInitializer& ObjectInitializer)
- : Super(ObjectInitializer)
- {}
- TSharedRef<SWidget> UAkItemBoolProperties::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 Boolean property")))
- ]
- ]
- + SVerticalBox::Slot()
- [
- SAssignNew(WwiseProperties, SAkItemBoolProperties)
- .FocusSearchBoxWhenOpened(autoFocus)
- .SelectionMode(ESelectionMode::Single)
- .OnSelectionChanged(FOnSelectionChanged::CreateUObject(this, &UAkItemBoolProperties::PropertySelectionChanged))
- .OnDragDetected(FOnDragDetected::CreateUObject(this, &UAkItemBoolProperties::HandleOnDragDetected))
- ]
- ];
- }
- void UAkItemBoolProperties::PropertySelectionChanged(TSharedPtr< FString > PropertySelected, ESelectInfo::Type SelectInfo)
- {
- if (PropertySelected.IsValid())
- {
- const auto& PropertySelectedString = *PropertySelected.Get();
- PropertyTextBlock->SetText(FText::FromString(PropertySelectedString));
- if (OnSelectionChanged.IsBound())
- {
- OnSelectionChanged.Broadcast(PropertySelectedString);
- }
- }
- }
- FReply UAkItemBoolProperties::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());
- }
- return FReply::Handled().BeginDragDrop(FWwiseBoolPropertyDragDropOp::New(PropertySelected));
- }
- }
- return FReply::Unhandled();
- }
- FString UAkItemBoolProperties::GetSelectedProperty() const
- {
- const TArray<TSharedPtr<FString>> selectedList = WwiseProperties->GetSelectedProperties();
- return selectedList.Num()? *selectedList[0] : TEXT("");
- }
- FString UAkItemBoolProperties::GetSearchText() const
- {
- return WwiseProperties->GetSearchText();
- }
- void UAkItemBoolProperties::SetSearchText(const FString& newText)
- {
- WwiseProperties->SetSearchText(newText);
- }
- void UAkItemBoolProperties::ReleaseSlateResources(bool bReleaseChildren)
- {
- Super::ReleaseSlateResources(bReleaseChildren);
- PropertyTextBlock.Reset();
- WwiseProperties.Reset();
- }
- #if WITH_EDITOR
- const FText UAkItemBoolProperties::GetPaletteCategory()
- {
- return LOCTEXT("Wwise", "Wwise");
- }
- #endif
- //
- /////////////////////////////////////////////////////
- #undef LOCTEXT_NAMESPACE
|