Files
UnrealEngineUWP/Engine/Source/Editor/CurveEditor/Private/CurveEditorModule.cpp
lauren barnes f4a7a3694d Delaying CurveEditor command registration until PostEngineInit
#rb trivial
[FYI] Max.Chen
#preflight 627ad8251e749933433e1e4d

#ROBOMERGE-AUTHOR: lauren.barnes
#ROBOMERGE-SOURCE: CL 20132075 via CL 20143953 via CL 20145123 via CL 20145967
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v943-19904690)

[CL 20149261 by lauren barnes in ue5-main branch]
2022-05-11 16:35:41 -04:00

98 lines
2.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Modules/ModuleManager.h"
#include "ICurveEditorModule.h"
#include "CurveEditorCommands.h"
#include "CurveEditor.h"
#include "CurveEditorViewRegistry.h"
#include "Framework/MultiBox/MultiBoxExtender.h"
#include "ToolMenus.h"
class FCurveEditorModule : public ICurveEditorModule
{
public:
virtual void StartupModule() override
{
if (GIsEditor)
{
if (UToolMenus::TryGet())
{
FCurveEditorCommands::Register();
}
else
{
FCoreDelegates::OnPostEngineInit.AddStatic(&FCurveEditorCommands::Register);
}
}
}
virtual void ShutdownModule() override
{
FCurveEditorCommands::Unregister();
}
virtual FDelegateHandle RegisterEditorExtension(FOnCreateCurveEditorExtension InOnCreateCurveEditorExtension) override
{
EditorExtensionDelegates.Add(InOnCreateCurveEditorExtension);
FDelegateHandle Handle = EditorExtensionDelegates.Last().GetHandle();
return Handle;
}
virtual void UnregisterEditorExtension(FDelegateHandle InHandle) override
{
EditorExtensionDelegates.RemoveAll([=](const FOnCreateCurveEditorExtension& Delegate) { return Delegate.GetHandle() == InHandle; });
}
virtual FDelegateHandle RegisterToolExtension(FOnCreateCurveEditorToolExtension InOnCreateCurveEditorToolExtension) override
{
ToolExtensionDelegates.Add(InOnCreateCurveEditorToolExtension);
FDelegateHandle Handle = ToolExtensionDelegates.Last().GetHandle();
return Handle;
}
virtual void UnregisterToolExtension(FDelegateHandle InHandle) override
{
ToolExtensionDelegates.RemoveAll([=](const FOnCreateCurveEditorToolExtension& Delegate) { return Delegate.GetHandle() == InHandle; });
}
virtual ECurveEditorViewID RegisterView(FOnCreateCurveEditorView InCreateViewDelegate) override
{
return FCurveEditorViewRegistry::Get().RegisterCustomView(InCreateViewDelegate);
}
virtual void UnregisterView(ECurveEditorViewID InViewID) override
{
return FCurveEditorViewRegistry::Get().UnregisterCustomView(InViewID);
}
virtual TArray<FCurveEditorMenuExtender>& GetAllToolBarMenuExtenders() override
{
return ToolBarMenuExtenders;
}
virtual TArrayView<const FOnCreateCurveEditorExtension> GetEditorExtensions() const override
{
return EditorExtensionDelegates;
}
virtual TArrayView<const FOnCreateCurveEditorToolExtension> GetToolExtensions() const override
{
return ToolExtensionDelegates;
}
private:
/** List of editor extension handler delegates Curve Editors will execute when they are created. */
TArray<FOnCreateCurveEditorExtension> EditorExtensionDelegates;
/** List of tool extension handler delegates Curve Editors will execute when they are created. */
TArray<FOnCreateCurveEditorToolExtension> ToolExtensionDelegates;
/** List of Extenders that that should be called when building the Curve Editor toolbar. */
TArray<FCurveEditorMenuExtender> ToolBarMenuExtenders;
};
IMPLEMENT_MODULE(FCurveEditorModule, CurveEditor)