Files
UnrealEngineUWP/Engine/Source/Editor/BlueprintGraph/Classes/K2Node_Composite.h
phillip kavan 7ef9563646 Don't allow composite nodes to be pasted into Blueprint graphs that aren't schema-compatible.
Change summary:
- Added UEdGraphSchema_K2::DoesSupportCollapsedNodes() as an overridable API for K2-based schema types. Also added overrides for derived schemas that do not currently support collapsed subgraphs as a feature (e.g. AnimBPs).
- Added a UK2Node_Composite::CanCreateUnderSpecifiedSchema() override. This will be called when determining node types that can be created from clipboard content (see FGraphObjectTextFactory in EdGraphUtilities.cpp).
- Modified UK2Node_Composite::PostPasteNode() to exclude nodes that are not schema-compatible from the pasted subgraph. Also updated to reassign the subgraph schema to match the target graph.
- Modified FEdGraphUtilities::MergeChildrenGraphsIn() to emit an error to the message log when a subgraph cannot be merged into a parent graph due to schema incompatibility. This also adds an appropriate error context to the source node(s).
- Modified FKismetCompilerContext::ProcessOneFunctionGraph() to early exit if we fail to merge subgraphs while processing the intermediate function graph. This prevents us from attempting to further compile an intermediate graph that's in an invalid state, which previously would lead to an ensure() and later fail due to a non-specific compile error.

#jira UE-157885
#rb Dan.OConnor, Thomas.Sarkanen
#preflight 6331e2fd10030508069622f2

[CL 22205520 by phillip kavan in ue5-main branch]
2022-09-27 10:17:29 -04:00

82 lines
3.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Containers/Array.h"
#include "Containers/UnrealString.h"
#include "CoreMinimal.h"
#include "EdGraph/EdGraph.h"
#include "EdGraph/EdGraphNode.h"
#include "EdGraph/EdGraphNodeUtils.h"
#include "Internationalization/Text.h"
#include "K2Node_Tunnel.h"
#include "Math/Color.h"
#include "Templates/SharedPointer.h"
#include "UObject/ObjectMacros.h"
#include "UObject/ObjectPtr.h"
#include "UObject/UObjectGlobals.h"
#include "K2Node_Composite.generated.h"
class INameValidatorInterface;
class UObject;
UCLASS()
class BLUEPRINTGRAPH_API UK2Node_Composite : public UK2Node_Tunnel
{
GENERATED_UCLASS_BODY()
// The graph that this composite node is representing
UPROPERTY()
TObjectPtr<class UEdGraph> BoundGraph;
//~ Begin UObject Interface
virtual void PostEditUndo() override;
//~ End UObject Interface
//~ Begin UEdGraphNode Interface
virtual void AllocateDefaultPins() override;
virtual void DestroyNode() override;
virtual void PostPasteNode() override;
virtual FText GetTooltipText() const override;
virtual FLinearColor GetNodeTitleColor() const override;
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
virtual bool CanUserDeleteNode() const override;
virtual UObject* GetJumpTargetForDoubleClick() const override;
virtual void PostPlacedNewNode() override;
virtual void OnRenameNode(const FString& NewName) override;
virtual TSharedPtr<class INameValidatorInterface> MakeNameValidator() const override;
virtual TArray<UEdGraph*> GetSubGraphs() const override { return TArray<UEdGraph*>( { BoundGraph } ); }
virtual bool CanCreateUnderSpecifiedSchema(const UEdGraphSchema* DesiredSchema) const override;
//~ End UEdGraphNode Interface
//~ Begin UK2Node Interface
virtual bool DrawNodeAsExit() const override { return false; }
virtual bool DrawNodeAsEntry() const override { return false; }
virtual bool NodeCausesStructuralBlueprintChange() const override { return true; }
//~ End UK2Node Interface
// Get the entry/exit nodes inside this collapsed graph
UK2Node_Tunnel* GetEntryNode() const;
UK2Node_Tunnel* GetExitNode() const;
protected:
/** Fixes up the input and output sink when needed, useful after PostEditUndo which changes which graph these nodes point to */
void FixupInputAndOutputSink();
private:
/** Rename the BoundGraph to a unique name
- this is a special case rename: RenameGraphCloseToName() assumes that we are only concurrned with the immediate Outer() scope,
but in the case of the BoundGraph we must also look into the Outer of the composite node(a Graph), and make sure no graphs in its SubGraph
array are already using the name. */
void RenameBoundGraphCloseToName(const FString& Name);
/** Determine if the name already used by another graph in composite nodes chain */
bool IsCompositeNameAvailable( const FString& NewName );
/** Constructing FText strings can be costly, so we cache the node's title */
FNodeTextCache CachedNodeTitle;
};