2020-10-28 06:51:40 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "DataLayerEditorModule.h"
|
|
|
|
|
#include "PropertyEditorModule.h"
|
2021-11-07 23:43:01 -05:00
|
|
|
#include "EditorWidgetsModule.h"
|
|
|
|
|
#include "ObjectNameEditSinkRegistry.h"
|
2020-10-28 06:51:40 -04:00
|
|
|
#include "Widgets/SWidget.h"
|
|
|
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
|
|
|
#include "Editor.h"
|
|
|
|
|
#include "Modules/ModuleManager.h"
|
|
|
|
|
#include "DataLayer/DataLayerPropertyTypeCustomization.h"
|
|
|
|
|
#include "DataLayer/SDataLayerBrowser.h"
|
2021-11-07 23:43:01 -05:00
|
|
|
#include "DataLayer/DataLayerNameEditSink.h"
|
2020-10-28 06:51:40 -04:00
|
|
|
#include "WorldPartition/DataLayer/DataLayer.h"
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_MODULE(FDataLayerEditorModule, DataLayerEditor );
|
|
|
|
|
|
2020-12-04 12:48:56 -04:00
|
|
|
static const FName NAME_ActorDataLayer(TEXT("ActorDataLayer"));
|
|
|
|
|
|
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>(); }));
|
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);
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FDataLayerEditorModule::SyncDataLayerBrowserToDataLayer(const UDataLayer* DataLayer)
|
|
|
|
|
{
|
|
|
|
|
if (DataLayerBrowser.IsValid())
|
|
|
|
|
{
|
|
|
|
|
TSharedRef<SDataLayerBrowser> Browser = StaticCastSharedRef<SDataLayerBrowser>(DataLayerBrowser.Pin().ToSharedRef());
|
|
|
|
|
Browser->SyncDataLayerBrowserToDataLayer(DataLayer);
|
|
|
|
|
}
|
2020-10-28 06:51:40 -04:00
|
|
|
}
|