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-22 14:52:03 -04:00
|
|
|
#include "CoreMinimal.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"
|
2020-07-23 16:39:56 -04:00
|
|
|
#include "IDetailGroup.h"
|
2021-03-19 15:10:57 -04:00
|
|
|
#include "Input/Events.h"
|
2020-07-30 16:57:04 -04:00
|
|
|
#include "MetasoundAssetBase.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"
|
2020-12-14 15:48:27 -04:00
|
|
|
#include "MetasoundUObjectRegistry.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"
|
2020-08-05 12:47:19 -04:00
|
|
|
#include "SlateCore/Public/Styling/SlateColor.h"
|
2021-03-24 18:13:33 -04:00
|
|
|
#include "Sound/SoundWave.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"
|
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)
|
|
|
|
|
{
|
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
|
|
|
|
using namespace Metasound::Editor;
|
2020-07-30 16:57:04 -04:00
|
|
|
|
2021-03-24 16:42:25 -04:00
|
|
|
EMetasoundActiveDetailView DetailsView = EMetasoundActiveDetailView::Metasound;
|
|
|
|
|
if (const UMetasoundEditorSettings* EditorSettings = GetDefault<UMetasoundEditorSettings>())
|
|
|
|
|
{
|
|
|
|
|
DetailsView = EditorSettings->DetailView;
|
|
|
|
|
}
|
2020-07-22 14:52:03 -04:00
|
|
|
|
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-03-24 16:42:25 -04:00
|
|
|
const FName AuthorPropertyPath = BuildChildPath(GetMetadataPropertyPath(), GET_MEMBER_NAME_CHECKED(FMetasoundFrontendClassMetadata, Author));
|
|
|
|
|
const FName DescPropertyPath = BuildChildPath(GetMetadataPropertyPath(), GET_MEMBER_NAME_CHECKED(FMetasoundFrontendClassMetadata, Description));
|
|
|
|
|
const FName VersionPropertyPath = BuildChildPath(GetMetadataPropertyPath(), GET_MEMBER_NAME_CHECKED(FMetasoundFrontendClassMetadata, Version));
|
|
|
|
|
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-03-24 16:42:25 -04:00
|
|
|
TSharedPtr<IPropertyHandle> AuthorHandle = DetailLayout.GetProperty(AuthorPropertyPath);
|
|
|
|
|
TSharedPtr<IPropertyHandle> DescHandle = DetailLayout.GetProperty(DescPropertyPath);
|
|
|
|
|
TSharedPtr<IPropertyHandle> MajorVersionHandle = DetailLayout.GetProperty(MajorVersionPropertyPath);
|
|
|
|
|
TSharedPtr<IPropertyHandle> MinorVersionHandle = DetailLayout.GetProperty(MinorVersionPropertyPath);
|
2020-07-22 14:52:03 -04:00
|
|
|
|
2021-03-24 16:42:25 -04:00
|
|
|
GeneralCategoryBuilder.AddProperty(AuthorHandle);
|
|
|
|
|
GeneralCategoryBuilder.AddProperty(DescHandle);
|
|
|
|
|
GeneralCategoryBuilder.AddProperty(MajorVersionHandle);
|
|
|
|
|
GeneralCategoryBuilder.AddProperty(MinorVersionHandle);
|
2020-07-23 16:39:56 -04:00
|
|
|
|
2021-04-20 18:16:21 -04:00
|
|
|
DetailLayout.HideCategory("Advanced");
|
2021-03-24 16:42:25 -04:00
|
|
|
DetailLayout.HideCategory("Analysis");
|
|
|
|
|
DetailLayout.HideCategory("Attenuation");
|
|
|
|
|
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
|
|
|
|
2021-03-24 16:42:25 -04:00
|
|
|
const bool bShouldBeInitiallyCollapsed = true;
|
2021-03-24 18:13:33 -04:00
|
|
|
IDetailCategoryBuilder& SoundCategory = DetailLayout.EditCategory("Sound");
|
|
|
|
|
SoundCategory.InitiallyCollapsed(bShouldBeInitiallyCollapsed);
|
|
|
|
|
|
|
|
|
|
static const TSet<FName> SoundPropsToHide =
|
|
|
|
|
{
|
|
|
|
|
GET_MEMBER_NAME_CHECKED(USoundWave, bLooping),
|
|
|
|
|
GET_MEMBER_NAME_CHECKED(USoundWave, SoundGroup)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TArray<TSharedRef<IPropertyHandle>>SoundProperties;
|
|
|
|
|
SoundCategory.GetDefaultProperties(SoundProperties);
|
|
|
|
|
for (TSharedRef<IPropertyHandle> Property : SoundProperties)
|
|
|
|
|
{
|
|
|
|
|
if (SoundPropsToHide.Contains(Property->GetProperty()->GetFName()))
|
|
|
|
|
{
|
|
|
|
|
Property->MarkHiddenByCustomization();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-24 16:42:25 -04:00
|
|
|
DetailLayout.EditCategory("Attenuation").InitiallyCollapsed(bShouldBeInitiallyCollapsed);
|
|
|
|
|
DetailLayout.EditCategory("Effects").InitiallyCollapsed(bShouldBeInitiallyCollapsed);
|
|
|
|
|
DetailLayout.EditCategory("Modulation").InitiallyCollapsed(bShouldBeInitiallyCollapsed);
|
|
|
|
|
DetailLayout.EditCategory("Voice Management").InitiallyCollapsed(bShouldBeInitiallyCollapsed);
|
|
|
|
|
|
2021-03-24 18:13:33 -04:00
|
|
|
DetailLayout.EditCategory("Analysis").InitiallyCollapsed(bShouldBeInitiallyCollapsed);
|
|
|
|
|
DetailLayout.EditCategory("Advanced").InitiallyCollapsed(bShouldBeInitiallyCollapsed);
|
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");
|
|
|
|
|
|
|
|
|
|
DetailLayout.HideCategory("Curves");
|
2021-01-20 00:42:47 -04:00
|
|
|
DetailLayout.HideCategory("Developer");
|
2020-08-05 12:47:19 -04:00
|
|
|
DetailLayout.HideCategory("File Path");
|
|
|
|
|
DetailLayout.HideCategory("Format");
|
|
|
|
|
DetailLayout.HideCategory("Info");
|
|
|
|
|
DetailLayout.HideCategory("Loading");
|
|
|
|
|
DetailLayout.HideCategory("Playback");
|
|
|
|
|
DetailLayout.HideCategory("Subtitles");
|
|
|
|
|
}
|
|
|
|
|
} // namespace Editor
|
|
|
|
|
} // namespace Metasound
|
2020-07-31 11:59:52 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE
|