123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332 |
- /*******************************************************************************
- 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.
- *******************************************************************************/
- #include "AkSettingsDetailsCustomization.h"
- #include "AkSettings.h"
- #include "AkUEFeatures.h"
- #include "DetailCategoryBuilder.h"
- #include "DetailLayoutBuilder.h"
- #include "DetailWidgetRow.h"
- #include "IStructureDetailsView.h"
- #include "Widgets/Input/SNumericEntryBox.h"
- #include "Widgets/Input/SButton.h"
- #include "Editor.h"
- #define LOCTEXT_NAMESPACE "AudiokineticTools"
- /** Dialog widget used to display function properties */
- class SDecayKeyEntryDialog : public SCompoundWidget
- {
- SLATE_BEGIN_ARGS(SDecayKeyEntryDialog) {}
- SLATE_END_ARGS()
- // We call this from a delegate that is called when the window has correctly been added to the slate application.
- // See FAkSettingsDetailsCustomization::InsertKeyModal.
- void FocusNumericEntryBox()
- {
- if (numberBox != nullptr)
- {
- FSlateApplication::Get().ClearAllUserFocus();
- FSlateApplication::Get().SetAllUserFocus(numberBox);
- FSlateApplication::Get().ClearKeyboardFocus();
- FSlateApplication::Get().SetKeyboardFocus(numberBox);
- }
- }
- void Construct(const FArguments& InArgs, TWeakPtr<SWindow> InParentWindow, float& decay)
- {
- bCommitted = false;
- ChildSlot
- [
- SNew(SVerticalBox)
- + SVerticalBox::Slot()
- .AutoHeight()
- [
- SNew(SBorder)
- .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
- .VAlign(VAlign_Center)
- .HAlign(HAlign_Center)
- [
- SNew(SVerticalBox)
- + SVerticalBox::Slot()
- .Padding(2.0f)
- .AutoHeight()
- [
- SAssignNew(numberBox, SNumericEntryBox<float>)
- .MinValue(0.0f)
- .MaxValue(100.0f)
- .Value_Lambda([&decay]() {return decay;})
- .OnValueCommitted_Lambda([this, InParentWindow, &decay](const float& value, ETextCommit::Type commitType)
- {
- if (commitType == ETextCommit::Type::OnCleared)
- decay = 0.0f;
- else
- decay = value;
- if (commitType == ETextCommit::OnEnter)
- {
- bCommitted = true;
- if (InParentWindow.IsValid())
- {
- InParentWindow.Pin()->RequestDestroyWindow();
- }
- }
- })
- .OnValueChanged_Lambda([&decay](const float& value)
- {
- decay = value;
- })
- ]
- + SVerticalBox::Slot()
- .Padding(2.0f)
- .AutoHeight()
- [
- SNew(SButton)
- .ForegroundColor(FLinearColor::White)
- .OnClicked_Lambda([this, InParentWindow, InArgs]()
- {
- if (InParentWindow.IsValid())
- {
- InParentWindow.Pin()->RequestDestroyWindow();
- }
- bCommitted = true;
- return FReply::Handled();
- })
- .ToolTipText(FText::FromString("Insert given key value"))
- [
- SNew(STextBlock)
- .TextStyle(FAkAppStyle::Get(), "FlatButton.DefaultTextStyle")
- .Text(FText::FromString("Insert"))
- ]
- ]
- ]
- ]
- ];
- }
- bool bCommitted = false;
- TSharedPtr<SNumericEntryBox<float>> numberBox = nullptr;
- };
- /** Dialog widget used to display function properties */
- class SClearWarningDialog : public SCompoundWidget
- {
- SLATE_BEGIN_ARGS(SClearWarningDialog) {}
- SLATE_END_ARGS()
- void Construct(const FArguments& InArgs, TWeakPtr<SWindow> InParentWindow)
- {
- bOKPressed = false;
- ChildSlot
- [
- SNew(SVerticalBox)
- + SVerticalBox::Slot()
- .AutoHeight()
- [
- SNew(SBorder)
- .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
- .VAlign(VAlign_Center)
- .HAlign(HAlign_Center)
- [
- SNew(SVerticalBox)
- + SVerticalBox::Slot()
- .Padding(2.0f)
- .AutoHeight()
- [
- SNew(STextBlock)
- .Text(FText::FromString("Warning: This will remove all aux bus values in the map. Do you want to continue?"))
- ]
- ]
- ]
- + SVerticalBox::Slot()
- .AutoHeight()
- [
- SNew(SBorder)
- .BorderImage(FAkAppStyle::Get().GetBrush("ToolPanel.GroupBorder"))
- .VAlign(VAlign_Center)
- .HAlign(HAlign_Center)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot()
- .Padding(2.0f)
- .AutoWidth()
- [
- SNew(SButton)
- .ButtonStyle(FAkAppStyle::Get(), "FlatButton.Success")
- .ForegroundColor(FLinearColor::White)
- .OnClicked_Lambda([this, InParentWindow, InArgs]()
- {
- if (InParentWindow.IsValid())
- {
- InParentWindow.Pin()->RequestDestroyWindow();
- }
- bOKPressed = true;
- return FReply::Handled();
- })
- .ToolTipText(FText::FromString("Clear aux bus assignment map"))
- [
- SNew(STextBlock)
- .TextStyle(FAkAppStyle::Get(), "FlatButton.DefaultTextStyle")
- .Text(FText::FromString("Clear"))
- ]
- ]
- + SHorizontalBox::Slot()
- .Padding(2.0f)
- .AutoWidth()
- [
- SNew(SButton)
- .ButtonStyle(FAkAppStyle::Get(), "FlatButton.Default")
- .ForegroundColor(FLinearColor::White)
- .OnClicked_Lambda([this, InParentWindow, InArgs]()
- {
- if (InParentWindow.IsValid())
- {
- InParentWindow.Pin()->RequestDestroyWindow();
- }
- return FReply::Handled();
- })
- .ToolTipText(FText::FromString("Cancel"))
- [
- SNew(STextBlock)
- .TextStyle(FAkAppStyle::Get(), "FlatButton.DefaultTextStyle")
- .Text(FText::FromString("Cancel"))
- ]
- ]
- ]
- ]
- ];
- }
- bool bOKPressed;
- };
- TSharedRef<IDetailCustomization> FAkSettingsDetailsCustomization::MakeInstance()
- {
- return MakeShareable(new FAkSettingsDetailsCustomization);
- }
- void FAkSettingsDetailsCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailLayout)
- {
- IDetailCategoryBuilder& CategoryBuilder = DetailLayout.EditCategory("Reverb Assignment Map", FText::GetEmpty(), ECategoryPriority::Uncommon);
- CategoryBuilder.AddCustomRow(FText::FromString("Clear Map")).WholeRowContent()
- [
- SNew(SVerticalBox)
- + SVerticalBox::Slot().AutoHeight().Padding(2)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot().AutoWidth()
- [
- SNew(SButton)
- .Text(FText::FromString("Clear Map"))
- .ToolTipText(FText::FromString("Clear all of the entries in the map"))
- .OnClicked_Raw(this, &FAkSettingsDetailsCustomization::ClearAkSettingsRoomDecayAuxBusMap)
- ]
- + SHorizontalBox::Slot().FillWidth(8)
- ]
- + SVerticalBox::Slot().AutoHeight().Padding(2)
- [
- SNew(SHorizontalBox)
- + SHorizontalBox::Slot().AutoWidth()
- [
- SNew(SButton)
- .Text(FText::FromString("Insert Decay Key"))
- .OnClicked_Raw(this, &FAkSettingsDetailsCustomization::InsertKeyModal)
- ]
- + SHorizontalBox::Slot().FillWidth(8)
- ]
- ];
- TArray<TSharedRef<IPropertyHandle>> Properties;
- CategoryBuilder.GetDefaultProperties(Properties);
- for (TSharedRef<IPropertyHandle> Property : Properties)
- {
- CategoryBuilder.AddProperty(Property);
- }
- }
- FReply FAkSettingsDetailsCustomization::ClearAkSettingsRoomDecayAuxBusMap()
- {
- // pop up a dialog to input params to the function
- TSharedRef<SWindow> Window = SNew(SWindow)
- .Title(FText::FromString("Clear aux bus assignment map?"))
- .ScreenPosition(FSlateApplication::Get().GetCursorPos())
- .AutoCenter(EAutoCenter::None)
- .SizingRule(ESizingRule::Autosized)
- .SupportsMinimize(false)
- .SupportsMaximize(false);
- TSharedPtr<SClearWarningDialog> Dialog;
- Window->SetContent(SAssignNew(Dialog, SClearWarningDialog, Window));
- GEditor->EditorAddModalWindow(Window);
- if (Dialog->bOKPressed)
- {
- UAkSettings* AkSettings = GetMutableDefault<UAkSettings>();
- if (AkSettings != nullptr)
- AkSettings->ClearAkRoomDecayAuxBusMap();
- }
- return FReply::Handled();
- }
- FReply FAkSettingsDetailsCustomization::InsertKeyModal()
- {
- // pop up a dialog to input params to the function
- TSharedRef<SWindow> Window = SNew(SWindow)
- .Title(FText::FromString("Insert Decay Key"))
- .ScreenPosition(FSlateApplication::Get().GetCursorPos())
- .AutoCenter(EAutoCenter::None)
- .SizingRule(ESizingRule::Autosized)
- .SupportsMinimize(false)
- .SupportsMaximize(false);
- float decay = 0.0f;
- TSharedPtr<SDecayKeyEntryDialog> Dialog;
- Window->SetContent(SAssignNew(Dialog, SDecayKeyEntryDialog, Window, decay));
- // In order to give focus to the textbox in SDecayKeyEntryDialog when the dialog is created,
- // we need to wait until the window has been added to the slate application. If we try to focus the
- // text box during the construction of the dialog, the window will not be found in the slate application's
- // list of top level windows, and the text box will not be focused.
- // To achieve this, we need to set up a delegate to call after the modal window has been added to the slate application.
- FModalWindowStackStarted modalWindowCallback;
- modalWindowCallback.BindLambda([&Dialog]()
- {
- if (Dialog.IsValid())
- Dialog->FocusNumericEntryBox();
- });
- FSlateApplication::Get().SetModalWindowStackStartedDelegate(modalWindowCallback);
- // During this call, the ModalWindowStackStartedDelegate will be called.
- GEditor->EditorAddModalWindow(Window);
- // Clear the ModalWindowStackStartedDelegate.
- FSlateApplication::Get().SetModalWindowStackStartedDelegate(nullptr);
- if (Dialog->bCommitted)
- {
- UAkSettings* AkSettings = GetMutableDefault<UAkSettings>();
- if (AkSettings != nullptr)
- AkSettings->InsertDecayKeyValue(decay);
- }
- return FReply::Handled();
- }
- #undef LOCTEXT_NAMESPACE
|