2020-10-28 06:51:40 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "DataLayerEditorModule.h"
|
2022-08-30 23:03:03 -04:00
|
|
|
|
2022-06-09 12:13:16 -04:00
|
|
|
#include "DataLayer/DataLayerEditorSubsystem.h"
|
2022-08-30 23:03:03 -04:00
|
|
|
#include "DataLayer/DataLayerInstanceCustomization.h"
|
|
|
|
|
#include "DataLayer/DataLayerNameEditSink.h"
|
|
|
|
|
#include "DataLayer/DataLayerPropertyTypeCustomization.h"
|
|
|
|
|
#include "DataLayer/SDataLayerBrowser.h"
|
|
|
|
|
#include "EditorWidgetsModule.h"
|
|
|
|
|
#include "HAL/Platform.h"
|
|
|
|
|
#include "Modules/ModuleManager.h"
|
|
|
|
|
#include "ObjectNameEditSinkRegistry.h"
|
|
|
|
|
#include "PropertyEditorDelegates.h"
|
|
|
|
|
#include "PropertyEditorModule.h"
|
|
|
|
|
#include "UObject/NameTypes.h"
|
|
|
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
|
|
|
#include "Widgets/SWidget.h"
|
|
|
|
|
|
|
|
|
|
class AActor;
|
2020-10-28 06:51:40 -04:00
|
|
|
|
|
|
|
|
IMPLEMENT_MODULE(FDataLayerEditorModule, DataLayerEditor );
|
|
|
|
|
|
2020-12-04 12:48:56 -04:00
|
|
|
static const FName NAME_ActorDataLayer(TEXT("ActorDataLayer"));
|
2022-06-23 17:08:58 -04:00
|
|
|
static const FName NAME_DataLayerInstance(TEXT("DataLayerInstance"));
|
2022-03-15 13:52:28 -04:00
|
|
|
|
2020-10-28 06:51:40 -04:00
|
|
|
void FDataLayerEditorModule::StartupModule()
|
|
|
|
|
{
|
|
|
|
|
FPropertyEditorModule& PropertyModule = FModuleManager::LoadModuleChecked<FPropertyEditorModule>("PropertyEditor");
|
2020-12-04 12:48:56 -04:00
|
|
|
PropertyModule.RegisterCustomPropertyTypeLayout(NAME_ActorDataLayer, FOnGetPropertyTypeCustomizationInstance::CreateLambda([] { return MakeShared<FDataLayerPropertyTypeCustomization>(); }));
|
2022-06-23 17:08:58 -04:00
|
|
|
PropertyModule.RegisterCustomClassLayout(NAME_DataLayerInstance, FOnGetDetailCustomizationInstance::CreateStatic(&FDataLayerInstanceDetails::MakeInstance));
|
2021-11-07 23:43:01 -05:00
|
|
|
|
|
|
|
|
FEditorWidgetsModule& EditorWidgetsModule = FModuleManager::LoadModuleChecked<FEditorWidgetsModule>("EditorWidgets");
|
|
|
|
|
EditorWidgetsModule.GetObjectNameEditSinkRegistry()->RegisterObjectNameEditSink(MakeShared<FDataLayerNameEditSink>());
|
2020-10-28 06:51:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FDataLayerEditorModule::ShutdownModule()
|
|
|
|
|
{
|
|
|
|
|
if (FPropertyEditorModule* PropertyModule = FModuleManager::GetModulePtr<FPropertyEditorModule>("PropertyEditor"))
|
|
|
|
|
{
|
2020-12-04 12:48:56 -04:00
|
|
|
PropertyModule->UnregisterCustomPropertyTypeLayout(NAME_ActorDataLayer);
|
2022-06-23 17:08:58 -04:00
|
|
|
PropertyModule->UnregisterCustomPropertyTypeLayout(NAME_DataLayerInstance);
|
2020-10-28 06:51:40 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedRef<SWidget> FDataLayerEditorModule::CreateDataLayerBrowser()
|
|
|
|
|
{
|
2021-11-07 23:43:01 -05:00
|
|
|
TSharedRef<SWidget> NewDataLayerBrowser = SNew(SDataLayerBrowser);
|
|
|
|
|
DataLayerBrowser = NewDataLayerBrowser;
|
|
|
|
|
return NewDataLayerBrowser;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 13:52:28 -04:00
|
|
|
void FDataLayerEditorModule::SyncDataLayerBrowserToDataLayer(const UDataLayerInstance* DataLayerInstance)
|
2021-11-07 23:43:01 -05:00
|
|
|
{
|
|
|
|
|
if (DataLayerBrowser.IsValid())
|
|
|
|
|
{
|
|
|
|
|
TSharedRef<SDataLayerBrowser> Browser = StaticCastSharedRef<SDataLayerBrowser>(DataLayerBrowser.Pin().ToSharedRef());
|
2022-03-15 13:52:28 -04:00
|
|
|
Browser->SyncDataLayerBrowserToDataLayer(DataLayerInstance);
|
2021-11-07 23:43:01 -05:00
|
|
|
}
|
2022-03-15 13:52:28 -04:00
|
|
|
}
|
2022-06-09 12:13:16 -04:00
|
|
|
|
|
|
|
|
bool FDataLayerEditorModule::AddActorToDataLayers(AActor* Actor, const TArray<UDataLayerInstance*>& DataLayers)
|
|
|
|
|
{
|
|
|
|
|
return UDataLayerEditorSubsystem::Get()->AddActorToDataLayers(Actor, DataLayers);
|
|
|
|
|
}
|