// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Containers/Array.h" #include "Containers/Map.h" #include "Containers/UnrealString.h" #include "CoreMinimal.h" #include "CoreTypes.h" #include "Delegates/Delegate.h" #include "Engine/Blueprint.h" #include "Framework/Commands/UICommandList.h" #include "K2Node_EditablePinBase.h" #include "Math/Vector2D.h" #include "Modules/ModuleInterface.h" #include "Templates/SharedPointer.h" #include "Templates/SubclassOf.h" #include "Templates/UniquePtr.h" #include "Toolkits/AssetEditorToolkit.h" #include "Toolkits/IToolkit.h" #include "UObject/NameTypes.h" #include "UObject/SoftObjectPath.h" #include "WorkflowOrientedApp/WorkflowCentricApplication.h" class FBlueprintEditor; class FExtender; class FFieldClass; class FKismetCompilerContext; class FLayoutExtender; class FSCSEditorTreeNode; class FSubobjectEditorTreeNode; class FUICommandList; class FWorkflowAllowedTabSet; class IBlueprintEditor; class IDetailCustomization; class IToolkitHost; class SWidget; class UEdGraphNode; class UEdGraphPin; class UEdGraphSchema; class UK2Node_EditablePinBase; class UObject; class UUserDefinedEnum; class UUserDefinedEnum; class UUserDefinedStruct; class UUserDefinedStruct; struct FBlueprintDebugger; struct Rect; /** Delegate used to customize variable display */ DECLARE_DELEGATE_RetVal_OneParam(TSharedPtr, FOnGetVariableCustomizationInstance, TSharedPtr /*BlueprintEditor*/); /** Delegate used to customize local variable display */ DECLARE_DELEGATE_RetVal_OneParam(TSharedPtr, FOnGetLocalVariableCustomizationInstance, TSharedPtr /*BlueprintEditor*/); /** Delegate used to customize function display */ DECLARE_DELEGATE_RetVal_OneParam(TSharedPtr, FOnGetFunctionCustomizationInstance, TSharedPtr /*BlueprintEditor*/); /** Delegate used to customize graph display */ DECLARE_DELEGATE_RetVal_OneParam(TSharedPtr, FOnGetGraphCustomizationInstance, TSharedPtr /*BlueprintEditor*/); /** Describes the reason for Refreshing the editor */ namespace ERefreshBlueprintEditorReason { enum Type { BlueprintCompiled, PostUndo, UnknownReason }; } /** * Enum editor public interface */ class KISMET_API IUserDefinedEnumEditor : public FAssetEditorToolkit { }; /** * Enum editor public interface */ class KISMET_API IUserDefinedStructureEditor : public FAssetEditorToolkit { }; /** * Blueprint editor public interface */ class KISMET_API IBlueprintEditor : public FWorkflowCentricApplication { public: virtual void JumpToHyperlink(const UObject* ObjectReference, bool bRequestRename) = 0; virtual void JumpToPin(const UEdGraphPin* PinToFocusOn) = 0; /** Invokes the search UI and sets the mode and search terms optionally */ virtual void SummonSearchUI(bool bSetFindWithinBlueprint, FString NewSearchTerms = FString(), bool bSelectFirstResult = false) = 0; /** Invokes the Find and Replace UI */ virtual void SummonFindAndReplaceUI() = 0; /** Returns the currently focused graph context, or NULL if no graph is available. */ virtual UEdGraph* GetFocusedGraph() const = 0; /** Tries to open the specified graph and bring it's document to the front (note: this can return NULL) */ virtual TSharedPtr OpenGraphAndBringToFront(class UEdGraph* Graph, bool bSetFocus = true) = 0; virtual void RefreshEditors(ERefreshBlueprintEditorReason::Type Reason = ERefreshBlueprintEditorReason::UnknownReason) = 0; virtual void RefreshMyBlueprint() = 0; virtual void RefreshInspector() = 0; virtual void AddToSelection(UEdGraphNode* InNode) = 0; virtual bool CanPasteNodes() const= 0; UE_DEPRECATED(5.6, "Slate positions are represented in FVector2f. Please update to use the function acceping FVector2f.") virtual void PasteNodesHere(class UEdGraph* Graph, const FVector2D& Location) UE_SLATE_DEPRECATED_VECTOR_VIRTUAL_FUNCTION { PasteNodesHere(Graph, UE::Slate::CastToVector2f(Location)); }; virtual void PasteNodesHere(class UEdGraph* Graph, const FVector2f& Location) = 0; virtual bool GetBoundsForSelectedNodes(class FSlateRect& Rect, float Padding ) = 0; /** Util to get the currently selected Subobject editor tree Nodes */ virtual TArray> GetSelectedSubobjectEditorTreeNodes() const = 0; /** Get number of currently selected nodes in the SCS editor tree */ virtual int32 GetNumberOfSelectedNodes() const = 0; /** Find and select a specific SCS editor tree node associated with the given component */ virtual TSharedPtr FindAndSelectSubobjectEditorTreeNode(const class UActorComponent* InComponent, bool IsCntrlDown) = 0; /** Used to track node create/delete events for Analytics */ virtual void AnalyticsTrackNodeEvent( UBlueprint* Blueprint, UEdGraphNode *GraphNode, bool bNodeDelete = false ) const = 0; /** Return the class viewer filter associated with the current set of imported namespaces within this editor context. Default is NULL (no filter). */ virtual TSharedPtr GetImportedClassViewerFilter() const { return nullptr; } /** Return the pin type selector filter associated with the current set of imported namespaces within this editor context. Default is NULL (no filter). */ UE_DEPRECATED(5.1, "Please use GetPinTypeSelectorFilters") virtual TSharedPtr GetImportedPinTypeSelectorFilter() const { return nullptr; } /** Get all the the pin type selector filters within this editor context. */ virtual void GetPinTypeSelectorFilters(TArray>& OutFilters) const {} /** Return whether the given object falls outside the scope of the current set of imported namespaces within this editor context. Default is FALSE (imported). */ virtual bool IsNonImportedObject(const UObject* InObject) const { return false; } /** Return whether the given object (referenced by path) falls outside the scope of the current set of imported namespaces within this editor context. Default is FALSE (imported). */ virtual bool IsNonImportedObject(const FSoftObjectPath& InObject) const { return false; } UE_DEPRECATED(5.0, "GetSelectedSCSEditorTreeNodes has been deprecated. Use GetSelectedSubobjectEditorTreeNodes instead.") virtual TArray > GetSelectedSCSEditorTreeNodes() const = 0; UE_DEPRECATED(5.0, "FindAndSelectSCSEditorTreeNode has been deprecated. Use FindAndSelectSubobjectEditorTreeNode instead.") virtual TSharedPtr FindAndSelectSCSEditorTreeNode(const class UActorComponent* InComponent, bool IsCntrlDown) = 0; }; DECLARE_DELEGATE_RetVal_OneParam(TSharedRef, FSCSEditorCustomizationBuilder, TSharedRef< IBlueprintEditor > /* InBlueprintEditor */); /** * The blueprint editor module provides the blueprint editor application. */ class FBlueprintEditorModule : public IModuleInterface, public IHasMenuExtensibility { public: // IModuleInterface interface virtual void StartupModule() override; virtual void ShutdownModule() override; // End of IModuleInterface interface /** * Creates an instance of a Kismet editor object. Only virtual so that it can be called across the DLL boundary. * * Note: This function should not be called directly, use one of the following instead: * - FKismetEditorUtilities::BringKismetToFocusAttentionOnObject * - GEditor->GetEditorSubsystem()->OpenEditorForAsset * * @param Mode Mode that this editor should operate in * @param InitToolkitHost When Mode is WorldCentric, this is the level editor instance to spawn this editor within * @param Blueprint The blueprint object to start editing * @param bShouldOpenInDefaultsMode If true, the editor will open in defaults editing mode * * @return Interface to the new Blueprint editor */ virtual TSharedRef CreateBlueprintEditor(const EToolkitMode::Type Mode, const TSharedPtr< IToolkitHost >& InitToolkitHost, UBlueprint* Blueprint, bool bShouldOpenInDefaultsMode = false); virtual TSharedRef CreateBlueprintEditor( const EToolkitMode::Type Mode, const TSharedPtr< IToolkitHost >& InitToolkitHost, const TArray< UBlueprint* >& BlueprintsToEdit, bool bShouldOpenInDefaultsMode = true); /** Get all blueprint editor instances */ virtual TArray> GetBlueprintEditors() const; /** * Creates an instance of a Enum editor object. * * @param Mode Mode that this editor should operate in * @param InitToolkitHost When Mode is WorldCentric, this is the level editor instance to spawn this editor within * @param UDEnum The user-defined Enum to start editing * * @return Interface to the new Enum editor */ virtual TSharedRef CreateUserDefinedEnumEditor(const EToolkitMode::Type Mode, const TSharedPtr& InitToolkitHost, UUserDefinedEnum* UDEnum); /** * Creates an instance of a Structure editor object. * * @param Mode Mode that this editor should operate in * @param InitToolkitHost When Mode is WorldCentric, this is the level editor instance to spawn this editor within * @param UDEnum The user-defined structure to start editing * * @return Interface to the new Struct editor */ virtual TSharedRef CreateUserDefinedStructEditor(const EToolkitMode::Type Mode, const TSharedPtr& InitToolkitHost, UUserDefinedStruct* UDStruct); /** Gets the extensibility managers for outside entities to extend blueprint editor's menus and toolbars */ virtual TSharedPtr GetMenuExtensibilityManager() override { return MenuExtensibilityManager; } /** */ DECLARE_EVENT_TwoParams(FBlueprintEditorModule, FBlueprintMenuExtensionEvent, TSharedPtr, UBlueprint*); FBlueprintMenuExtensionEvent& OnGatherBlueprintMenuExtensions() { return GatherBlueprintMenuExtensions; } DECLARE_EVENT_ThreeParams(IBlueprintEditor, FOnRegisterTabs, FWorkflowAllowedTabSet&, FName /** ModeName */, TSharedPtr); FOnRegisterTabs& OnRegisterTabsForEditor() { return RegisterTabsForEditor; } DECLARE_EVENT_OneParam(IBlueprintEditor, FOnRegisterLayoutExtensions, FLayoutExtender&); FOnRegisterLayoutExtensions& OnRegisterLayoutExtensions() { return RegisterLayoutExtensions; } /** Sets customizations for the BP editor details panel. */ virtual void SetDetailsCustomization(TSharedPtr InDetailsObjectFilter, TSharedPtr InDetailsRootCustomization); /** Sets SCS editor UI customization */ virtual void SetSubobjectEditorUICustomization(TSharedPtr InSCSEditorUICustomization); /** * Register a customization for interacting with the SCS editor * @param InComponentName The name of the component to customize behavior for * @param InCustomizationBuilder The delegate used to create customization instances */ virtual void RegisterSCSEditorCustomization(const FName& InComponentName, FSCSEditorCustomizationBuilder InCustomizationBuilder); /** * Unregister a previously registered customization for interacting with the SCS editor * @param InComponentName The name of the component to customize behavior for */ virtual void UnregisterSCSEditorCustomization(const FName& InComponentName); /** * Register a customization for for Blueprint variables * @param InStruct The type of the variable to create the customization for * @param InOnGetDetailCustomization The delegate used to create customization instances */ virtual FDelegateHandle RegisterVariableCustomization(FFieldClass* InFieldClass, FOnGetVariableCustomizationInstance InOnGetVariableCustomization); /** * Unregister a previously registered customization for BP variables * @param InStruct The type to create the customization for */ UE_DEPRECATED(5.1, "UnregisterVariableCustomization without a delegate handle is deprecated.") virtual void UnregisterVariableCustomization(FFieldClass* InFieldClass); /** * Unregister a previously registered customization for BP variables * @param InStruct The type to create the customization for * @param InHandle The handle returned by RegisterVariableCustomization */ virtual void UnregisterVariableCustomization(FFieldClass* InFieldClass, FDelegateHandle InHandle); /** * Register a customization for for Blueprint local variables * @param InFieldClass The type of the variable to create the customization for * @param InOnGetLocalVariableCustomization The delegate used to create customization instances */ virtual FDelegateHandle RegisterLocalVariableCustomization(FFieldClass* InFieldClass, FOnGetLocalVariableCustomizationInstance InOnGetLocalVariableCustomization); /** * Unregister a previously registered customization for BP local variables * @param InFieldClass The type to create the customization for */ UE_DEPRECATED(5.1, "UnregisterLocalVariableCustomization without a delegate handle is deprecated.") virtual void UnregisterLocalVariableCustomization(FFieldClass* InFieldClass); /** * Unregister a previously registered customization for BP local variables * @param InFieldClass The type to create the customization for * @param InHandle The handle returned by RegisterLocalVariableCustomization */ virtual void UnregisterLocalVariableCustomization(FFieldClass* InFieldClass, FDelegateHandle InHandle); /** * Register a customization for for Blueprint graphs * @param InGraphSchema The schema of the graph to create the customization for * @param InOnGetDetailCustomization The delegate used to create customization instances */ virtual void RegisterGraphCustomization(const UEdGraphSchema* InGraphSchema, FOnGetGraphCustomizationInstance InOnGetGraphCustomization); /** * Unregister a previously registered customization for BP graphs * @param InGraphSchema The schema of the graph to create the customization for */ virtual void UnregisterGraphCustomization(const UEdGraphSchema* InGraphSchema); /** * Register a customization for for Blueprint functions * @param InStruct The type of the pin to create the customization for * @param InOnGetFunctionCustomization The delegate used to create customization instances */ virtual FDelegateHandle RegisterFunctionCustomization(TSubclassOf InFieldClass, FOnGetFunctionCustomizationInstance InOnGetFunctionCustomization); /** * Unregister a previously registered customization for BP functions * @param InStruct The type to create the customization for * @param InHandle The handle returned by UnregisterFunctionCustomization */ virtual void UnregisterFunctionCustomization(TSubclassOf InFieldClass, FDelegateHandle InHandle); /** * Build a set of details customizations for the passed-in type, if possible. * @param InStruct The type to create the customization for * @param InBlueprintEditor The Blueprint Editor the customization will be created for */ virtual TArray> CustomizeVariable(FFieldClass* InFieldClass, TSharedPtr InBlueprintEditor); /** * Build a set of details customizations for graphs with the passed-in schema, if possible. * @param InGraphSchema The schema to create the customization for * @param InBlueprintEditor The Blueprint Editor the customization will be created for */ virtual TArray> CustomizeGraph(const UEdGraphSchema* InGraphSchema, TSharedPtr InBlueprintEditor); /** * Build a set of details customizations for function with the passed-in type, if possible. * @param InFunctionClass The type to create the customization for * @param InBlueprintEditor The Blueprint Editor the customization will be created for */ virtual TArray> CustomizeFunction(TSubclassOf InFunctionClass, TSharedPtr InBlueprintEditor); /** Delegate for binding functions to be called when the blueprint editor finishes getting created */ DECLARE_EVENT_OneParam( FBlueprintEditorModule, FBlueprintEditorOpenedEvent, EBlueprintType ); FBlueprintEditorOpenedEvent& OnBlueprintEditorOpened() { return BlueprintEditorOpened; } /** * Exposes a way for other modules to fold in their own Blueprint editor * commands (folded in with other BP editor commands, when the editor is * first opened). */ virtual const TSharedRef GetsSharedBlueprintEditorCommands() const { return SharedBlueprintEditorCommands.ToSharedRef(); } /** Returns a reference to the Blueprint Debugger state object */ const TUniquePtr& GetBlueprintDebugger() const { return BlueprintDebugger; } private: /** Loads from ini a list of all events that should be auto created for Blueprints of a specific class */ void PrepareAutoGeneratedDefaultEvents(); private: /** List of all blueprint editors that were created. */ TArray> BlueprintEditors; TSharedPtr MenuExtensibilityManager; // FBlueprintMenuExtensionEvent GatherBlueprintMenuExtensions; /** Event called to allow external clients to register additional tabs for the specified editor */ FOnRegisterTabs RegisterTabsForEditor; FOnRegisterLayoutExtensions RegisterLayoutExtensions; // Event to be called when the blueprint editor is opened FBlueprintEditorOpenedEvent BlueprintEditorOpened; /** Customizations for the SCS editor */ TMap SCSEditorCustomizations; /** Customizations for Blueprint variables */ TMultiMap VariableCustomizations; /** Customizations for Blueprint local variables */ TMultiMap LocalVariableCustomizations; /** Customizations for Blueprint graphs */ TMap GraphCustomizations; /** Customizations for Blueprint functions */ TMultiMap, FOnGetFunctionCustomizationInstance> FunctionCustomizations; /** Root customization for the BP editor details panel. */ TSharedPtr DetailsRootCustomization; /** Filter used to determine the set of objects shown in the BP editor details panel. */ TSharedPtr DetailsObjectFilter; /** UI customizations for the SCS editor inside the blueprint editor */ TSharedPtr SCSEditorUICustomization; /** * A command list that can be passed around and isn't bound to an instance * of the blueprint editor. */ TSharedPtr SharedBlueprintEditorCommands; /** Handle to a registered LevelViewportContextMenuBlueprintExtender delegate */ FDelegateHandle LevelViewportContextMenuBlueprintExtenderDelegateHandle; /** Reference to keep our custom configuration panel alive */ TSharedPtr ConfigurationPanel; /** Blueprint debugger state - refactor into SBlueprintDebugger if needed */ TUniquePtr BlueprintDebugger; };