Files
UnrealEngineUWP/Engine/Source/Editor/BlueprintGraph/Classes/K2Node_CustomEvent.h
Phillip Kavan f64e3e18d7 Some minor refactoring to assist with auto-importing external type object dependency namespaces into the Blueprint editor context in response to user actions.
Change summary:
- Moved base definition of UK2Node::HasExternalDependencies() up one level to UEdGraphNode (to avoid blind casts in a context where we may not necessarily have a UK2Node subtype).
- Updated subtype headers that override HasExternalDependencies() to relocate the declaration into the class declaration's 'UEdGraphNode overrides' section (for clarity).
- Reverted previous UBlueprintNodeSpawner::ImportTarget solution in favor of using node dependencies; this allows auto-import actions to scale more easily to all existing node subtypes and avoids data duplication.
- Modified SBlueprintActionMenu::OnActionSelected() to utilize the new method for determining which namespace(s) to auto-import after executing a node spawner action in response to a context menu item selection (UE-146803).
- Reverted FBlueprintNamespaceUtilities::GetPropertyValueNamespaces() back to its original 5.0 signature so that it uses a TSet<FString> for the output rather than a TArray<FString>; this fits in better with input to other APIs.
- Renamed FBlueprintEditor::FImportNamespaceParameters to FImportNamespaceExParameters (for clarity).
- Changed the 'FBlueprintEditor::FImportNamespaceParameters::AdditionalNamespaces' member to a TSet<FString> containing *all* namespaces to import rather than limiting to only additional ones.
- Reverted FBlueprintEditor::ImportNamespace() back to its original 5.0 signature and added/implemented FBlueprintEditor::ImportNamespaceEx() as the "extended" version that allows for batched imports and future customizations.
- Revised existing FBlueprintEditor::ImportNamespace() call sites to utilize and/or conform to the extended ImportNamespaceEx() API where appropriate.

#jira UE-146803
#rb Benjamin.Fox
#preflight 623cf3a433709ff50128e8d4

[CL 19505118 by Phillip Kavan in ue5-main branch]
2022-03-24 19:50:46 -04:00

119 lines
4.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "Textures/SlateIcon.h"
#include "EdGraph/EdGraphNodeUtils.h"
#include "K2Node_Event.h"
#include "K2Node_CustomEvent.generated.h"
class FBlueprintActionDatabaseRegistrar;
class INameValidatorInterface;
class UEdGraph;
struct FKismetUserDeclaredFunctionMetadata;
UCLASS(MinimalAPI)
class UK2Node_CustomEvent : public UK2Node_Event
{
GENERATED_UCLASS_BODY()
/** Optional message to display when the event is deprecated */
UPROPERTY()
FString DeprecationMessage;
/** Specifies that usage of this event has been deprecated */
UPROPERTY()
bool bIsDeprecated;
/** Specifies that the event can be triggered in Editor */
UPROPERTY()
bool bCallInEditor;
virtual bool IsEditable() const override;
//~ Begin UObject Interface
virtual void Serialize(FArchive& Ar) override;
//~ End UObject Interface
//~ Begin UEdGraphNode Interface
virtual void ReconstructNode() override;
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
virtual void OnRenameNode(const FString& NewName) override;
virtual TSharedPtr<class INameValidatorInterface> MakeNameValidator() const override;
virtual FText GetTooltipText() const override;
virtual FString GetDocumentationLink() const override;
virtual FString GetDocumentationExcerptName() const override;
virtual FSlateIcon GetIconAndTint(FLinearColor& OutColor) const override;
virtual void AutowireNewNode(UEdGraphPin* FromPin) override;
virtual void AddSearchMetaDataInfo(TArray<struct FSearchTagDataPair>& OutTaggedMetaData) const override;
virtual FText GetKeywords() const override;
virtual bool HasDeprecatedReference() const override { return bIsDeprecated; }
virtual FEdGraphNodeDeprecationResponse GetDeprecationResponse(EEdGraphNodeDeprecationType DeprecationType) const override;
virtual bool HasExternalDependencies(TArray<class UStruct*>* OptionalOutput) const override;
//~ End UEdGraphNode Interface
//~ Begin UK2Node Interface
virtual void ValidateNodeDuringCompilation(class FCompilerResultsLog& MessageLog) const override;
virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override;
virtual void FixupPinStringDataReferences(FArchive* SavingArchive) override;
virtual bool NodeCausesStructuralBlueprintChange() const override { return true; }
//~ End UK2Node Interface
//~ Begin UK2Node_EditablePinBase Interface
virtual bool ShouldUseConstRefParams() const override { return true; }
virtual UEdGraphPin* CreatePinFromUserDefinition(const TSharedPtr<FUserPinInfo> NewPinInfo) override;
virtual bool CanCreateUserDefinedPin(const FEdGraphPinType& InPinType, EEdGraphPinDirection InDesiredDirection, FText& OutErrorMessage) override;
virtual bool ModifyUserDefinedPinDefaultValue(TSharedPtr<FUserPinInfo> PinInfo, const FString& NewDefaultValue) override;
//~ Begin UK2Node_EditablePinBase Interface
virtual bool IsUsedByAuthorityOnlyDelegate() const override;
// Rename this custom event to have unique name
BLUEPRINTGRAPH_API void RenameCustomEventCloseToName(int32 StartIndex = 1);
BLUEPRINTGRAPH_API static UK2Node_CustomEvent* CreateFromFunction(FVector2D GraphPosition, UEdGraph* ParentGraph, const FString& Name, const UFunction* Function, bool bSelectNewNode = true);
/**
* Discernible from the base UK2Node_Event's bOverrideFunction field. This
* checks to see if this UK2Node_CustomEvent overrides another CustomEvent
* declared in a parent blueprint.
*
* @return True if this CustomEvent's name matches another CustomEvent's name, declared in a parent (false if not).
*/
BLUEPRINTGRAPH_API bool IsOverride() const;
/**
* If a CustomEvent overrides another CustomEvent, then it inherits the
* super's net flags. This method does that work for you, either returning
* the super function's flags, or this node's flags (if it's not an override).
*
* @return If this CustomEvent is an override, then this is the super's net flags, otherwise it's from the FunctionFlags set on this node.
*/
BLUEPRINTGRAPH_API uint32 GetNetFlags() const;
/**
* Updates the Signature of this event. Empties current pins and adds the new given parameters.
* Does nothing if DelegateSignature is nullptr
*
* @param DelegateSignature The new signature for this function to have
*/
BLUEPRINTGRAPH_API void SetDelegateSignature(const UFunction* DelegateSignature);
private:
/** Constructing FText strings can be costly, so we cache the node's title */
FNodeTextCache CachedNodeTitle;
/** Custom event metadata that can be used for adding custom keywords */
UPROPERTY()
FKismetUserDeclaredFunctionMetadata MetaData;
public:
FKismetUserDeclaredFunctionMetadata& GetUserDefinedMetaData()
{
return MetaData;
}
};