2020-07-22 14:52:03 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
#include "MetasoundDetailCustomization.h"
|
|
|
|
|
|
2020-08-05 12:47:19 -04:00
|
|
|
#include "Containers/Set.h"
|
2020-07-30 16:57:04 -04:00
|
|
|
#include "Delegates/Delegate.h"
|
2020-07-22 14:52:03 -04:00
|
|
|
#include "DetailCategoryBuilder.h"
|
|
|
|
|
#include "DetailLayoutBuilder.h"
|
2020-07-30 16:57:04 -04:00
|
|
|
#include "DetailWidgetRow.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "Framework/Notifications/NotificationManager.h"
|
2021-12-10 20:37:31 -05:00
|
|
|
#include "IAudioParameterInterfaceRegistry.h"
|
2021-11-22 15:55:50 -05:00
|
|
|
#include "IAudioParameterTransmitter.h"
|
2020-07-23 16:39:56 -04:00
|
|
|
#include "IDetailGroup.h"
|
2021-03-19 15:10:57 -04:00
|
|
|
#include "Input/Events.h"
|
2023-03-13 17:23:05 -04:00
|
|
|
#include "Interfaces/MetasoundFrontendInterfaceRegistry.h"
|
2020-07-30 16:57:04 -04:00
|
|
|
#include "MetasoundAssetBase.h"
|
2023-05-10 20:28:39 -04:00
|
|
|
#include "MetasoundBuilderSubsystem.h"
|
2021-09-20 13:55:48 -04:00
|
|
|
#include "MetasoundEditor.h"
|
|
|
|
|
#include "MetasoundEditorGraphBuilder.h"
|
2021-03-24 16:42:25 -04:00
|
|
|
#include "MetasoundEditorSettings.h"
|
2020-08-05 12:47:19 -04:00
|
|
|
#include "MetasoundFrontend.h"
|
2021-01-23 12:59:01 -04:00
|
|
|
#include "MetasoundFrontendController.h"
|
2021-11-22 15:55:50 -05:00
|
|
|
#include "MetasoundFrontendSearchEngine.h"
|
2021-08-18 15:16:57 -04:00
|
|
|
#include "MetasoundSource.h"
|
2020-12-14 15:48:27 -04:00
|
|
|
#include "MetasoundUObjectRegistry.h"
|
2021-11-22 15:55:50 -05:00
|
|
|
#include "PropertyCustomizationHelpers.h"
|
2020-07-22 14:52:03 -04:00
|
|
|
#include "PropertyEditorDelegates.h"
|
|
|
|
|
#include "PropertyHandle.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "PropertyRestriction.h"
|
2021-03-19 15:10:57 -04:00
|
|
|
#include "SGraphPalette.h"
|
2022-10-19 06:39:08 -04:00
|
|
|
#include "ScopedTransaction.h"
|
2021-03-24 18:13:33 -04:00
|
|
|
#include "Sound/SoundWave.h"
|
2022-10-19 06:39:08 -04:00
|
|
|
#include "Styling/CoreStyle.h"
|
|
|
|
|
#include "Styling/SlateColor.h"
|
|
|
|
|
#include "Styling/SlateTypes.h"
|
2020-07-22 14:52:03 -04:00
|
|
|
#include "Templates/Casts.h"
|
|
|
|
|
#include "Templates/SharedPointer.h"
|
2020-08-05 12:47:19 -04:00
|
|
|
#include "UObject/WeakObjectPtr.h"
|
2020-07-30 16:57:04 -04:00
|
|
|
#include "UObject/WeakObjectPtrTemplates.h"
|
2022-10-19 06:39:08 -04:00
|
|
|
#include "Widgets/Input/SCheckBox.h"
|
2021-01-20 00:42:47 -04:00
|
|
|
#include "Widgets/Notifications/SNotificationList.h"
|
2020-07-31 11:59:52 -04:00
|
|
|
#include "Widgets/Text/STextBlock.h"
|
2020-07-22 14:52:03 -04:00
|
|
|
|
|
|
|
|
|
2021-04-02 03:03:27 -04:00
|
|
|
#define LOCTEXT_NAMESPACE "MetaSoundEditor"
|
2020-07-23 16:39:56 -04:00
|
|
|
|
2021-01-23 12:59:01 -04:00
|
|
|
|
2020-07-30 16:57:04 -04:00
|
|
|
namespace Metasound
|
|
|
|
|
{
|
|
|
|
|
namespace Editor
|
|
|
|
|
{
|
|
|
|
|
FName BuildChildPath(const FString& InBasePath, FName InPropertyName)
|
|
|
|
|
{
|
|
|
|
|
return FName(InBasePath + TEXT(".") + InPropertyName.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FName BuildChildPath(const FName& InBasePath, FName InPropertyName)
|
|
|
|
|
{
|
|
|
|
|
return FName(InBasePath.ToString() + TEXT(".") + InPropertyName.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-05 12:47:19 -04:00
|
|
|
FMetasoundDetailCustomization::FMetasoundDetailCustomization(FName InDocumentPropertyName)
|
|
|
|
|
: IDetailCustomization()
|
|
|
|
|
, DocumentPropertyName(InDocumentPropertyName)
|
|
|
|
|
{
|
2021-11-22 15:55:50 -05:00
|
|
|
IsGraphEditableAttribute = TAttribute<bool>::Create([this]()
|
|
|
|
|
{
|
|
|
|
|
using namespace Metasound;
|
|
|
|
|
using namespace Metasound::Frontend;
|
|
|
|
|
if (const FMetasoundAssetBase* MetaSoundAsset = IMetasoundUObjectRegistry::Get().GetObjectAsAssetBase(MetaSound.Get()))
|
|
|
|
|
{
|
|
|
|
|
FConstGraphHandle GraphHandle = MetaSoundAsset->GetRootGraphHandle();
|
|
|
|
|
return GraphHandle->GetGraphStyle().bIsGraphEditable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FName FMetasoundDetailCustomization::GetInterfaceVersionsPath() const
|
|
|
|
|
{
|
2021-12-10 20:37:31 -05:00
|
|
|
return Metasound::Editor::BuildChildPath(DocumentPropertyName, GET_MEMBER_NAME_CHECKED(FMetasoundFrontendDocument, Interfaces));
|
2020-08-05 12:47:19 -04:00
|
|
|
}
|
2020-07-30 16:57:04 -04:00
|
|
|
|
2020-08-05 12:47:19 -04:00
|
|
|
FName FMetasoundDetailCustomization::GetMetadataRootClassPath() const
|
|
|
|
|
{
|
2021-01-13 10:48:59 -04:00
|
|
|
return Metasound::Editor::BuildChildPath(DocumentPropertyName, GET_MEMBER_NAME_CHECKED(FMetasoundFrontendDocument, RootGraph));
|
2020-08-05 12:47:19 -04:00
|
|
|
}
|
2020-07-30 16:57:04 -04:00
|
|
|
|
2020-08-05 12:47:19 -04:00
|
|
|
FName FMetasoundDetailCustomization::GetMetadataPropertyPath() const
|
|
|
|
|
{
|
|
|
|
|
const FName RootClass = FName(GetMetadataRootClassPath());
|
2021-01-13 10:48:59 -04:00
|
|
|
return Metasound::Editor::BuildChildPath(RootClass, GET_MEMBER_NAME_CHECKED(FMetasoundFrontendClass, Metadata));
|
2020-08-05 12:47:19 -04:00
|
|
|
}
|
2020-07-30 16:57:04 -04:00
|
|
|
|
2020-08-05 12:47:19 -04:00
|
|
|
void FMetasoundDetailCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailLayout)
|
|
|
|
|
{
|
2021-09-20 13:55:48 -04:00
|
|
|
using namespace Frontend;
|
2020-07-30 16:57:04 -04:00
|
|
|
|
2021-08-18 15:16:57 -04:00
|
|
|
TArray<TWeakObjectPtr<UObject>> Objects;
|
|
|
|
|
DetailLayout.GetObjectsBeingCustomized(Objects);
|
2021-11-22 15:55:50 -05:00
|
|
|
|
|
|
|
|
// Only support modifying a single MetaSound at a time (Multiple
|
|
|
|
|
// MetaSound editing will be covered most likely by separate tool).
|
2021-08-18 15:16:57 -04:00
|
|
|
if (Objects.Num() > 1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-11-22 15:55:50 -05:00
|
|
|
MetaSound = Objects.Last();
|
|
|
|
|
if (!MetaSound.IsValid())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-08-18 15:16:57 -04:00
|
|
|
|
2021-11-22 15:55:50 -05:00
|
|
|
TWeakObjectPtr<UMetaSoundSource> MetaSoundSource = Cast<UMetaSoundSource>(MetaSound.Get());
|
2021-08-18 15:16:57 -04:00
|
|
|
|
2023-11-13 17:11:15 -05:00
|
|
|
// MetaSound patches don't have source settings, so view MetaSound settings by default
|
|
|
|
|
EMetasoundActiveDetailView DetailsView = EMetasoundActiveDetailView::Metasound;
|
|
|
|
|
if (MetaSoundSource.IsValid())
|
|
|
|
|
{
|
|
|
|
|
// Show source settings by default unless previously set
|
|
|
|
|
DetailsView = EMetasoundActiveDetailView::General;
|
|
|
|
|
if (const UMetasoundEditorSettings* EditorSettings = GetDefault<UMetasoundEditorSettings>())
|
|
|
|
|
{
|
|
|
|
|
DetailsView = EditorSettings->DetailView;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-24 16:42:25 -04:00
|
|
|
switch (DetailsView)
|
|
|
|
|
{
|
|
|
|
|
case EMetasoundActiveDetailView::Metasound:
|
|
|
|
|
{
|
2021-04-02 02:09:50 -04:00
|
|
|
IDetailCategoryBuilder& GeneralCategoryBuilder = DetailLayout.EditCategory("MetaSound");
|
2021-07-27 15:36:03 -04:00
|
|
|
const FName AuthorPropertyPath = BuildChildPath(GetMetadataPropertyPath(), FMetasoundFrontendClassMetadata::GetAuthorPropertyName());
|
2021-08-09 15:13:40 -04:00
|
|
|
const FName CategoryHierarchyPropertyPath = BuildChildPath(GetMetadataPropertyPath(), FMetasoundFrontendClassMetadata::GetCategoryHierarchyPropertyName());
|
2021-07-27 15:36:03 -04:00
|
|
|
const FName DescPropertyPath = BuildChildPath(GetMetadataPropertyPath(), FMetasoundFrontendClassMetadata::GetDescriptionPropertyName());
|
2022-02-02 02:19:16 -05:00
|
|
|
const FName DisplayNamePropertyPath = BuildChildPath(GetMetadataPropertyPath(), FMetasoundFrontendClassMetadata::GetDisplayNamePropertyName());
|
|
|
|
|
const FName KeywordsPropertyPath = BuildChildPath(GetMetadataPropertyPath(), FMetasoundFrontendClassMetadata::GetKeywordsPropertyName());
|
|
|
|
|
const FName IsDeprecatedPropertyPath = BuildChildPath(GetMetadataPropertyPath(), FMetasoundFrontendClassMetadata::GetIsDeprecatedPropertyName());
|
2021-08-09 15:13:40 -04:00
|
|
|
|
|
|
|
|
const FName ClassNamePropertyPath = BuildChildPath(GetMetadataPropertyPath(), FMetasoundFrontendClassMetadata::GetClassNamePropertyName());
|
|
|
|
|
const FName ClassNameNamePropertyPath = BuildChildPath(ClassNamePropertyPath, GET_MEMBER_NAME_CHECKED(FMetasoundFrontendClassName, Name));
|
|
|
|
|
|
2021-07-27 15:36:03 -04:00
|
|
|
const FName VersionPropertyPath = BuildChildPath(GetMetadataPropertyPath(), FMetasoundFrontendClassMetadata::GetVersionPropertyName());
|
2021-03-24 16:42:25 -04:00
|
|
|
const FName MajorVersionPropertyPath = BuildChildPath(VersionPropertyPath, GET_MEMBER_NAME_CHECKED(FMetasoundFrontendVersionNumber, Major));
|
|
|
|
|
const FName MinorVersionPropertyPath = BuildChildPath(VersionPropertyPath, GET_MEMBER_NAME_CHECKED(FMetasoundFrontendVersionNumber, Minor));
|
2020-07-30 16:57:04 -04:00
|
|
|
|
2021-11-22 15:55:50 -05:00
|
|
|
const FName InterfaceVersionsPropertyPath = GetInterfaceVersionsPath();
|
|
|
|
|
|
2021-03-24 16:42:25 -04:00
|
|
|
TSharedPtr<IPropertyHandle> AuthorHandle = DetailLayout.GetProperty(AuthorPropertyPath);
|
2021-08-09 15:13:40 -04:00
|
|
|
TSharedPtr<IPropertyHandle> CategoryHierarchyHandle = DetailLayout.GetProperty(CategoryHierarchyPropertyPath);
|
|
|
|
|
TSharedPtr<IPropertyHandle> ClassNameHandle = DetailLayout.GetProperty(ClassNameNamePropertyPath);
|
2022-02-02 02:19:16 -05:00
|
|
|
TSharedPtr<IPropertyHandle> DisplayNameHandle = DetailLayout.GetProperty(DisplayNamePropertyPath);
|
2021-03-24 16:42:25 -04:00
|
|
|
TSharedPtr<IPropertyHandle> DescHandle = DetailLayout.GetProperty(DescPropertyPath);
|
2022-02-02 02:19:16 -05:00
|
|
|
TSharedPtr<IPropertyHandle> KeywordsHandle = DetailLayout.GetProperty(KeywordsPropertyPath);
|
|
|
|
|
TSharedPtr<IPropertyHandle> IsDeprecatedHandle = DetailLayout.GetProperty(IsDeprecatedPropertyPath);
|
|
|
|
|
TSharedPtr<IPropertyHandle> InterfaceVersionsHandle = DetailLayout.GetProperty(InterfaceVersionsPropertyPath);
|
2021-03-24 16:42:25 -04:00
|
|
|
TSharedPtr<IPropertyHandle> MajorVersionHandle = DetailLayout.GetProperty(MajorVersionPropertyPath);
|
|
|
|
|
TSharedPtr<IPropertyHandle> MinorVersionHandle = DetailLayout.GetProperty(MinorVersionPropertyPath);
|
2020-07-22 14:52:03 -04:00
|
|
|
|
2021-08-18 15:16:57 -04:00
|
|
|
// Invalid for UMetaSounds
|
|
|
|
|
TSharedPtr<IPropertyHandle> OutputFormat = DetailLayout.GetProperty(GET_MEMBER_NAME_CHECKED(UMetaSoundSource, OutputFormat));
|
|
|
|
|
if (OutputFormat.IsValid())
|
|
|
|
|
{
|
2021-09-20 13:55:48 -04:00
|
|
|
if (MetaSoundSource.IsValid())
|
|
|
|
|
{
|
|
|
|
|
OutputFormat->SetOnPropertyValuePreChange(FSimpleDelegate::CreateLambda([Source = MetaSoundSource]()
|
|
|
|
|
{
|
|
|
|
|
if (Source.IsValid())
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<FEditor> ParentEditor = FGraphBuilder::GetEditorForMetasound(*Source.Get());
|
|
|
|
|
if (ParentEditor.IsValid())
|
|
|
|
|
{
|
2024-02-06 06:24:44 -05:00
|
|
|
ParentEditor->Stop();
|
2021-09-20 13:55:48 -04:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
OutputFormat->SetOnPropertyValueChanged(FSimpleDelegate::CreateLambda([Source = MetaSoundSource]()
|
|
|
|
|
{
|
|
|
|
|
if (Source.IsValid())
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<FEditor> ParentEditor = FGraphBuilder::GetEditorForMetasound(*Source.Get());
|
|
|
|
|
if (ParentEditor.IsValid())
|
|
|
|
|
{
|
|
|
|
|
ParentEditor->CreateAnalyzers();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-18 15:16:57 -04:00
|
|
|
TSharedRef<SWidget> OutputFormatValueWidget = OutputFormat->CreatePropertyValueWidget();
|
2021-11-22 15:55:50 -05:00
|
|
|
OutputFormatValueWidget->SetEnabled(IsGraphEditableAttribute);
|
2021-08-18 15:16:57 -04:00
|
|
|
|
|
|
|
|
static const FText OutputFormatName = LOCTEXT("MetasoundOutputFormatPropertyName", "Output Format");
|
|
|
|
|
GeneralCategoryBuilder.AddCustomRow(OutputFormatName)
|
|
|
|
|
.NameContent()
|
|
|
|
|
[
|
|
|
|
|
OutputFormat->CreatePropertyNameWidget()
|
|
|
|
|
]
|
|
|
|
|
.ValueContent()
|
|
|
|
|
[
|
|
|
|
|
OutputFormatValueWidget
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
OutputFormat->MarkHiddenByCustomization();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-02 02:19:16 -05:00
|
|
|
// Updates FText properties on open editors if required
|
|
|
|
|
{
|
|
|
|
|
FSimpleDelegate RegisterOnChange = FSimpleDelegate::CreateLambda([this]()
|
|
|
|
|
{
|
|
|
|
|
if (MetaSound.IsValid())
|
|
|
|
|
{
|
|
|
|
|
if (FMetasoundAssetBase* MetaSoundAsset = IMetasoundUObjectRegistry::Get().GetObjectAsAssetBase(MetaSound.Get()))
|
|
|
|
|
{
|
|
|
|
|
MetaSoundAsset->GetDocumentChecked().RootGraph.Style.UpdateChangeID();
|
|
|
|
|
}
|
|
|
|
|
constexpr bool bForceViewSynchronization = true;
|
|
|
|
|
FGraphBuilder::RegisterGraphWithFrontend(*MetaSound.Get(), bForceViewSynchronization);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
AuthorHandle->SetOnChildPropertyValueChanged(RegisterOnChange);
|
|
|
|
|
DescHandle->SetOnPropertyValueChanged(RegisterOnChange);
|
|
|
|
|
DisplayNameHandle->SetOnPropertyValueChanged(RegisterOnChange);
|
|
|
|
|
KeywordsHandle->SetOnPropertyValueChanged(RegisterOnChange);
|
|
|
|
|
KeywordsHandle->SetOnChildPropertyValueChanged(RegisterOnChange);
|
|
|
|
|
IsDeprecatedHandle->SetOnPropertyValueChanged(RegisterOnChange);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GeneralCategoryBuilder.AddProperty(DisplayNameHandle);
|
2021-03-24 16:42:25 -04:00
|
|
|
GeneralCategoryBuilder.AddProperty(DescHandle);
|
2022-02-02 02:19:16 -05:00
|
|
|
GeneralCategoryBuilder.AddProperty(AuthorHandle);
|
|
|
|
|
GeneralCategoryBuilder.AddProperty(IsDeprecatedHandle);
|
2021-03-24 16:42:25 -04:00
|
|
|
GeneralCategoryBuilder.AddProperty(MajorVersionHandle);
|
|
|
|
|
GeneralCategoryBuilder.AddProperty(MinorVersionHandle);
|
2020-07-23 16:39:56 -04:00
|
|
|
|
2021-08-09 15:13:40 -04:00
|
|
|
static const FText ClassGuidName = LOCTEXT("MetasoundClassGuidPropertyName", "Class Guid");
|
|
|
|
|
GeneralCategoryBuilder.AddCustomRow(ClassGuidName).NameContent()
|
|
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
[
|
|
|
|
|
SNew(STextBlock)
|
|
|
|
|
.Text(ClassGuidName)
|
2022-05-09 13:12:28 -04:00
|
|
|
.Font(FAppStyle::GetFontStyle(TEXT("PropertyWindow.NormalFont")))
|
2021-08-09 15:13:40 -04:00
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
.ValueContent()
|
|
|
|
|
[
|
|
|
|
|
ClassNameHandle->CreatePropertyValueWidget()
|
|
|
|
|
];
|
|
|
|
|
GeneralCategoryBuilder.AddProperty(CategoryHierarchyHandle);
|
2022-02-02 02:19:16 -05:00
|
|
|
GeneralCategoryBuilder.AddProperty(KeywordsHandle);
|
2021-08-09 15:13:40 -04:00
|
|
|
|
2021-03-24 16:42:25 -04:00
|
|
|
DetailLayout.HideCategory("Attenuation");
|
2022-09-08 13:29:35 -04:00
|
|
|
DetailLayout.HideCategory("Developer");
|
2021-03-24 16:42:25 -04:00
|
|
|
DetailLayout.HideCategory("Effects");
|
|
|
|
|
DetailLayout.HideCategory("Loading");
|
|
|
|
|
DetailLayout.HideCategory("Modulation");
|
|
|
|
|
DetailLayout.HideCategory("Sound");
|
|
|
|
|
DetailLayout.HideCategory("Voice Management");
|
|
|
|
|
}
|
|
|
|
|
break;
|
2020-07-23 16:39:56 -04:00
|
|
|
|
2021-03-24 16:42:25 -04:00
|
|
|
case EMetasoundActiveDetailView::General:
|
|
|
|
|
default:
|
2021-04-02 02:09:50 -04:00
|
|
|
DetailLayout.HideCategory("MetaSound");
|
2020-07-22 14:52:03 -04:00
|
|
|
|
2022-09-08 13:29:35 -04:00
|
|
|
TArray<TSharedRef<IPropertyHandle>>DeveloperProperties;
|
|
|
|
|
TArray<TSharedRef<IPropertyHandle>>SoundProperties;
|
|
|
|
|
|
|
|
|
|
DetailLayout.EditCategory("Sound")
|
|
|
|
|
.GetDefaultProperties(SoundProperties);
|
|
|
|
|
DetailLayout.EditCategory("Developer")
|
|
|
|
|
.GetDefaultProperties(DeveloperProperties);
|
|
|
|
|
|
|
|
|
|
auto HideProperties = [](const TSet<FName>& PropsToHide, const TArray<TSharedRef<IPropertyHandle>>& Properties)
|
|
|
|
|
{
|
|
|
|
|
for (TSharedRef<IPropertyHandle> Property : Properties)
|
|
|
|
|
{
|
|
|
|
|
if (PropsToHide.Contains(Property->GetProperty()->GetFName()))
|
|
|
|
|
{
|
|
|
|
|
Property->MarkHiddenByCustomization();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-03-24 18:13:33 -04:00
|
|
|
|
|
|
|
|
static const TSet<FName> SoundPropsToHide =
|
|
|
|
|
{
|
|
|
|
|
GET_MEMBER_NAME_CHECKED(USoundWave, bLooping),
|
|
|
|
|
GET_MEMBER_NAME_CHECKED(USoundWave, SoundGroup)
|
|
|
|
|
};
|
2022-09-08 13:29:35 -04:00
|
|
|
HideProperties(SoundPropsToHide, SoundProperties);
|
2021-03-24 18:13:33 -04:00
|
|
|
|
2022-09-08 13:29:35 -04:00
|
|
|
static const TSet<FName> DeveloperPropsToHide =
|
2021-03-24 18:13:33 -04:00
|
|
|
{
|
2022-09-08 13:29:35 -04:00
|
|
|
GET_MEMBER_NAME_CHECKED(USoundBase, Duration),
|
|
|
|
|
GET_MEMBER_NAME_CHECKED(USoundBase, MaxDistance),
|
|
|
|
|
GET_MEMBER_NAME_CHECKED(USoundBase, TotalSamples)
|
|
|
|
|
};
|
|
|
|
|
HideProperties(DeveloperPropsToHide, DeveloperProperties);
|
2021-03-24 16:42:25 -04:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-08-05 12:47:19 -04:00
|
|
|
|
|
|
|
|
// Hack to hide parent structs for nested metadata properties
|
|
|
|
|
DetailLayout.HideCategory("CustomView");
|
|
|
|
|
|
2022-09-08 13:29:35 -04:00
|
|
|
DetailLayout.HideCategory("Advanced");
|
|
|
|
|
DetailLayout.HideCategory("Analysis");
|
2020-08-05 12:47:19 -04:00
|
|
|
DetailLayout.HideCategory("Curves");
|
|
|
|
|
DetailLayout.HideCategory("File Path");
|
|
|
|
|
DetailLayout.HideCategory("Format");
|
|
|
|
|
DetailLayout.HideCategory("Info");
|
|
|
|
|
DetailLayout.HideCategory("Loading");
|
|
|
|
|
DetailLayout.HideCategory("Playback");
|
|
|
|
|
DetailLayout.HideCategory("Subtitles");
|
2022-10-13 16:42:33 -04:00
|
|
|
DetailLayout.HideCategory("Waveform Processing");;
|
2020-08-05 12:47:19 -04:00
|
|
|
}
|
2022-03-01 14:29:17 -05:00
|
|
|
|
|
|
|
|
FMetasoundInterfacesDetailCustomization::FMetasoundInterfacesDetailCustomization()
|
|
|
|
|
{
|
|
|
|
|
IsGraphEditableAttribute = TAttribute<bool>::Create([this]()
|
|
|
|
|
{
|
|
|
|
|
using namespace Metasound;
|
|
|
|
|
using namespace Metasound::Frontend;
|
|
|
|
|
if (const FMetasoundAssetBase* MetaSoundAsset = IMetasoundUObjectRegistry::Get().GetObjectAsAssetBase(MetaSound.Get()))
|
|
|
|
|
{
|
|
|
|
|
FConstGraphHandle GraphHandle = MetaSoundAsset->GetRootGraphHandle();
|
|
|
|
|
return GraphHandle->GetGraphStyle().bIsGraphEditable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FMetasoundInterfacesDetailCustomization::CustomizeDetails(IDetailLayoutBuilder& DetailLayout)
|
|
|
|
|
{
|
|
|
|
|
TArray<TWeakObjectPtr<UObject>> Objects;
|
|
|
|
|
DetailLayout.GetObjectsBeingCustomized(Objects);
|
|
|
|
|
|
|
|
|
|
// Only support modifying a single MetaSound at a time (Multiple
|
|
|
|
|
// MetaSound editing will be covered most likely by separate tool).
|
|
|
|
|
if (Objects.Num() > 1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (UMetasoundInterfacesView* InterfacesView = CastChecked<UMetasoundInterfacesView>(Objects.Last()))
|
|
|
|
|
{
|
|
|
|
|
MetaSound = InterfacesView->GetMetasound();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateInterfaceNames();
|
|
|
|
|
|
|
|
|
|
SAssignNew(InterfaceComboBox, SSearchableComboBox)
|
|
|
|
|
.OptionsSource(&AddableInterfaceNames)
|
|
|
|
|
.OnGenerateWidget_Lambda([](TSharedPtr<FString> InItem)
|
|
|
|
|
{
|
|
|
|
|
return SNew(STextBlock)
|
|
|
|
|
.Text(FText::FromString(*InItem));
|
|
|
|
|
})
|
|
|
|
|
.OnSelectionChanged_Lambda([this](TSharedPtr<FString> NameToAdd, ESelectInfo::Type InSelectInfo)
|
|
|
|
|
{
|
|
|
|
|
using namespace Metasound;
|
|
|
|
|
using namespace Metasound::Frontend;
|
|
|
|
|
|
|
|
|
|
FMetasoundAssetBase* MetaSoundAsset = IMetasoundUObjectRegistry::Get().GetObjectAsAssetBase(MetaSound.Get());
|
|
|
|
|
if (!ensure(MetaSoundAsset))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (InSelectInfo != ESelectInfo::OnNavigation)
|
|
|
|
|
{
|
|
|
|
|
FMetasoundFrontendInterface InterfaceToAdd;
|
2022-09-22 15:02:24 -04:00
|
|
|
const FName InterfaceName { *NameToAdd.Get() };
|
|
|
|
|
if (ensure(ISearchEngine::Get().FindInterfaceWithHighestVersion(InterfaceName, InterfaceToAdd)))
|
2022-03-01 14:29:17 -05:00
|
|
|
{
|
2022-09-08 21:30:48 -04:00
|
|
|
const FScopedTransaction Transaction(FText::Format(LOCTEXT("AddInterfaceTransactionFormat", "Add MetaSound Interface '{0}'"), FText::FromString(InterfaceToAdd.Version.ToString())));
|
2022-03-01 14:29:17 -05:00
|
|
|
MetaSound.Get()->Modify();
|
|
|
|
|
MetaSoundAsset->GetGraphChecked().Modify();
|
|
|
|
|
|
2023-05-10 20:28:39 -04:00
|
|
|
TScriptInterface<IMetaSoundDocumentInterface> MetaSoundPatchDocInterface = MetaSound.Get();
|
|
|
|
|
FMetaSoundFrontendDocumentBuilder Builder(MetaSoundPatchDocInterface);
|
|
|
|
|
FModifyInterfaceOptions Options({ }, { InterfaceToAdd });
|
|
|
|
|
Options.bSetDefaultNodeLocations = false; // Don't automatically add nodes to ed graph
|
|
|
|
|
Builder.ModifyInterfaces(MoveTemp(Options));
|
2022-03-01 14:29:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateInterfaceNames();
|
|
|
|
|
InterfaceComboBox->RefreshOptions();
|
2022-03-02 16:52:01 -05:00
|
|
|
FGraphBuilder::RegisterGraphWithFrontend(*MetaSound.Get());
|
2022-03-01 14:29:17 -05:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.Content()
|
|
|
|
|
[
|
|
|
|
|
SNew(STextBlock)
|
|
|
|
|
.Text(LOCTEXT("UpdateInterfaceAction", "Add Interface..."))
|
|
|
|
|
.IsEnabled(IsGraphEditableAttribute)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> InterfaceUtilities = SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.Padding(2.0f)
|
|
|
|
|
.HAlign(HAlign_Left)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
InterfaceComboBox->AsShared()
|
|
|
|
|
]
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.Padding(2.0f)
|
|
|
|
|
.HAlign(HAlign_Left)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
PropertyCustomizationHelpers::MakeDeleteButton(FSimpleDelegate::CreateLambda([this]()
|
|
|
|
|
{
|
|
|
|
|
using namespace Frontend;
|
|
|
|
|
|
|
|
|
|
FMetasoundAssetBase* MetaSoundAsset = IMetasoundUObjectRegistry::Get().GetObjectAsAssetBase(MetaSound.Get());
|
|
|
|
|
if (!ensure(MetaSoundAsset))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<FMetasoundFrontendInterface> ImplementedInterfaces;
|
|
|
|
|
Algo::Transform(ImplementedInterfaceNames, ImplementedInterfaces, [](const FName& Name)
|
|
|
|
|
{
|
|
|
|
|
FMetasoundFrontendInterface Interface;
|
|
|
|
|
ISearchEngine::Get().FindInterfaceWithHighestVersion(Name, Interface);
|
|
|
|
|
return Interface;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
{
|
2022-09-08 21:30:48 -04:00
|
|
|
const FScopedTransaction Transaction(LOCTEXT("RemoveAllInterfacesTransaction", "Remove All MetaSound Interfaces"));
|
2022-03-01 14:29:17 -05:00
|
|
|
MetaSound.Get()->Modify();
|
|
|
|
|
MetaSoundAsset->GetGraphChecked().Modify();
|
|
|
|
|
|
|
|
|
|
FDocumentHandle DocumentHandle = MetaSoundAsset->GetDocumentHandle();
|
|
|
|
|
FModifyRootGraphInterfaces({ ImplementedInterfaces }, { }).Transform(DocumentHandle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateInterfaceNames();
|
|
|
|
|
InterfaceComboBox->RefreshOptions();
|
2022-03-02 16:52:01 -05:00
|
|
|
FGraphBuilder::RegisterGraphWithFrontend(*MetaSound.Get());
|
|
|
|
|
|
2022-03-01 14:29:17 -05:00
|
|
|
}), LOCTEXT("RemoveInterfaceTooltip1", "Removes all interfaces from the given MetaSound."))
|
|
|
|
|
];
|
2022-03-02 22:11:18 -05:00
|
|
|
InterfaceUtilities->SetEnabled(IsGraphEditableAttribute);
|
2022-03-01 14:29:17 -05:00
|
|
|
|
|
|
|
|
const FText HeaderName = LOCTEXT("InterfacesGroupDisplayName", "Interfaces");
|
|
|
|
|
IDetailCategoryBuilder& InterfaceCategory = DetailLayout.EditCategory("Interfaces", HeaderName);
|
|
|
|
|
|
|
|
|
|
InterfaceCategory.AddCustomRow(HeaderName)
|
|
|
|
|
[
|
|
|
|
|
InterfaceUtilities
|
|
|
|
|
];
|
|
|
|
|
|
2022-03-02 22:11:18 -05:00
|
|
|
auto CreateInterfaceEntryWidget = [&](FName InInterfaceName) -> TSharedRef<SWidget>
|
2022-03-01 14:29:17 -05:00
|
|
|
{
|
|
|
|
|
using namespace Frontend;
|
|
|
|
|
|
|
|
|
|
FMetasoundFrontendInterface InterfaceEntry;
|
|
|
|
|
if (!ensure(ISearchEngine::Get().FindInterfaceWithHighestVersion(InInterfaceName, InterfaceEntry)))
|
|
|
|
|
{
|
|
|
|
|
return SNullWidget::NullWidget;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 15:02:24 -04:00
|
|
|
TSharedRef<SWidget> RemoveButtonWidget = PropertyCustomizationHelpers::MakeDeleteButton(FSimpleDelegate::CreateLambda([this, InInterfaceName, InterfaceEntry]()
|
2022-03-01 14:29:17 -05:00
|
|
|
{
|
|
|
|
|
using namespace Frontend;
|
|
|
|
|
|
|
|
|
|
FMetasoundAssetBase* MetaSoundAsset = IMetasoundUObjectRegistry::Get().GetObjectAsAssetBase(MetaSound.Get());
|
|
|
|
|
if (!ensure(MetaSoundAsset))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
2022-09-08 21:30:48 -04:00
|
|
|
const FScopedTransaction Transaction(FText::Format(LOCTEXT("RemoveInterfaceTransactionFormat", "Remove MetaSound Interface '{0}'"), FText::FromString(InterfaceEntry.Version.ToString())));
|
2022-03-01 14:29:17 -05:00
|
|
|
MetaSound.Get()->Modify();
|
|
|
|
|
MetaSoundAsset->GetGraphChecked().Modify();
|
|
|
|
|
|
|
|
|
|
FDocumentHandle DocumentHandle = MetaSoundAsset->GetDocumentHandle();
|
|
|
|
|
FModifyRootGraphInterfaces({ InterfaceEntry }, { }).Transform(DocumentHandle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateInterfaceNames();
|
|
|
|
|
InterfaceComboBox->RefreshOptions();
|
2022-06-09 20:28:06 -04:00
|
|
|
FGraphBuilder::RegisterGraphWithFrontend(*MetaSound.Get());
|
|
|
|
|
|
2022-03-01 14:29:17 -05:00
|
|
|
}), LOCTEXT("RemoveInterfaceTooltip2", "Removes the associated interface from the MetaSound."));
|
|
|
|
|
|
2022-03-02 22:11:18 -05:00
|
|
|
TSharedRef<SWidget> EntryWidget = SNew(SHorizontalBox)
|
2022-03-01 14:29:17 -05:00
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.Padding(2.0f)
|
|
|
|
|
.HAlign(HAlign_Center)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
SNew(STextBlock)
|
|
|
|
|
.Text(FText::FromName(InterfaceEntry.Version.Name))
|
|
|
|
|
]
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.Padding(2.0f)
|
|
|
|
|
.HAlign(HAlign_Center)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
RemoveButtonWidget
|
|
|
|
|
];
|
2022-03-02 22:11:18 -05:00
|
|
|
|
|
|
|
|
EntryWidget->SetEnabled(IsGraphEditableAttribute);
|
|
|
|
|
return EntryWidget;
|
2022-03-01 14:29:17 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TArray<FName> InterfaceNames = ImplementedInterfaceNames.Array();
|
|
|
|
|
InterfaceNames.Sort([](const FName& A, const FName& B) { return A.LexicalLess(B); });
|
|
|
|
|
for (const FName& InterfaceName : InterfaceNames)
|
|
|
|
|
{
|
|
|
|
|
InterfaceCategory.AddCustomRow(FText::FromName(InterfaceName))
|
|
|
|
|
[
|
2022-03-02 22:11:18 -05:00
|
|
|
CreateInterfaceEntryWidget(InterfaceName)
|
2022-03-01 14:29:17 -05:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FMetasoundInterfacesDetailCustomization::UpdateInterfaceNames()
|
|
|
|
|
{
|
|
|
|
|
AddableInterfaceNames.Reset();
|
|
|
|
|
ImplementedInterfaceNames.Reset();
|
|
|
|
|
|
2023-03-07 17:01:52 -05:00
|
|
|
const UObject* MetaSoundObject = MetaSound.Get();
|
|
|
|
|
if (const FMetasoundAssetBase* MetaSoundAsset = IMetasoundUObjectRegistry::Get().GetObjectAsAssetBase(MetaSoundObject))
|
2022-03-01 14:29:17 -05:00
|
|
|
{
|
|
|
|
|
auto GetVersionName = [](const FMetasoundFrontendVersion& Version) { return Version.Name; };
|
2023-03-07 17:01:52 -05:00
|
|
|
const UClass* MetaSoundClass = MetaSoundObject->GetClass();
|
2023-04-04 19:14:26 -04:00
|
|
|
auto CanAddOrRemoveInterface = [ClassName = MetaSoundClass->GetClassPathName()](const FMetasoundFrontendVersion& Version)
|
2022-03-01 14:29:17 -05:00
|
|
|
{
|
2023-04-04 19:14:26 -04:00
|
|
|
using namespace Frontend;
|
2022-03-01 14:29:17 -05:00
|
|
|
|
|
|
|
|
const FInterfaceRegistryKey Key = GetInterfaceRegistryKey(Version);
|
|
|
|
|
if (const IInterfaceRegistryEntry* Entry = IInterfaceRegistry::Get().FindInterfaceRegistryEntry(Key))
|
|
|
|
|
{
|
2023-04-04 19:14:26 -04:00
|
|
|
if (const FMetasoundFrontendInterfaceUClassOptions* Options = Entry->GetInterface().FindClassOptions(ClassName))
|
|
|
|
|
{
|
|
|
|
|
return Options->bIsModifiable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If no options are found for the given class, interface is modifiable by default.
|
|
|
|
|
return true;
|
2022-03-01 14:29:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TSet<FMetasoundFrontendVersion>& ImplementedInterfaces = MetaSoundAsset->GetDocumentChecked().Interfaces;
|
|
|
|
|
Algo::TransformIf(ImplementedInterfaces, ImplementedInterfaceNames, CanAddOrRemoveInterface, GetVersionName);
|
|
|
|
|
|
2023-04-04 19:14:26 -04:00
|
|
|
TArray<FMetasoundFrontendInterface> Interfaces = Frontend::ISearchEngine::Get().FindAllInterfaces();
|
2022-03-01 14:29:17 -05:00
|
|
|
for (const FMetasoundFrontendInterface& Interface : Interfaces)
|
|
|
|
|
{
|
|
|
|
|
if (!ImplementedInterfaceNames.Contains(Interface.Version.Name))
|
|
|
|
|
{
|
|
|
|
|
if (CanAddOrRemoveInterface(Interface.Version))
|
|
|
|
|
{
|
|
|
|
|
FString Name = Interface.Version.Name.ToString();
|
|
|
|
|
AddableInterfaceNames.Add(MakeShared<FString>(MoveTemp(Name)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-07 17:01:52 -05:00
|
|
|
|
|
|
|
|
AddableInterfaceNames.Sort([](const TSharedPtr<FString>& A, const TSharedPtr<FString>& B) { return A->Compare(*B) < 0; });
|
2022-03-01 14:29:17 -05:00
|
|
|
}
|
|
|
|
|
}
|
2020-08-05 12:47:19 -04:00
|
|
|
} // namespace Editor
|
|
|
|
|
} // namespace Metasound
|
2020-07-31 11:59:52 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE
|