2019-12-27 09:26:59 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2018-04-12 16:57:51 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "EdGraph/EdGraphSchema.h"
|
2021-01-14 15:00:40 -04:00
|
|
|
#include "GraphEditorDragDropAction.h"
|
2021-06-07 06:49:07 -04:00
|
|
|
#include "RigVMModel/RigVMGraph.h"
|
|
|
|
|
#include "EdGraphSchema_K2_Actions.h"
|
2021-09-14 10:59:08 -04:00
|
|
|
#include "Kismet2/Kismet2NameValidators.h"
|
2021-06-07 06:49:07 -04:00
|
|
|
|
2018-04-12 16:57:51 -04:00
|
|
|
#include "ControlRigGraphSchema.generated.h"
|
|
|
|
|
|
|
|
|
|
class UControlRigBlueprint;
|
|
|
|
|
class UControlRigGraph;
|
|
|
|
|
class UControlRigGraphNode;
|
|
|
|
|
class UControlRigGraphNode_Unit;
|
|
|
|
|
class UControlRigGraphNode_Property;
|
|
|
|
|
|
|
|
|
|
/** Extra operations that can be performed on pin connection */
|
|
|
|
|
enum class ECanCreateConnectionResponse_Extended
|
|
|
|
|
{
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
|
|
BreakChildren,
|
|
|
|
|
|
|
|
|
|
BreakParent,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** Struct used to extend the response to a conneciton request to include breaking parents/children */
|
|
|
|
|
struct FControlRigPinConnectionResponse
|
|
|
|
|
{
|
|
|
|
|
FControlRigPinConnectionResponse(const ECanCreateConnectionResponse InResponse, FText InMessage, ECanCreateConnectionResponse_Extended InExtendedResponse = ECanCreateConnectionResponse_Extended::None)
|
|
|
|
|
: Response(InResponse, MoveTemp(InMessage))
|
|
|
|
|
, ExtendedResponse(InExtendedResponse)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
friend bool operator==(const FControlRigPinConnectionResponse& A, const FControlRigPinConnectionResponse& B)
|
|
|
|
|
{
|
|
|
|
|
return (A.Response == B.Response) && (A.ExtendedResponse == B.ExtendedResponse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FPinConnectionResponse Response;
|
|
|
|
|
ECanCreateConnectionResponse_Extended ExtendedResponse;
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-14 10:59:08 -04:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
// FControlRigLocalVariableNameValidator
|
|
|
|
|
class CONTROLRIGDEVELOPER_API FControlRigLocalVariableNameValidator : public FStringSetNameValidator
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FControlRigLocalVariableNameValidator(const class UBlueprint* Blueprint, const URigVMGraph* Graph, FName InExistingName = NAME_None);
|
2021-10-22 05:17:33 -04:00
|
|
|
|
|
|
|
|
// Begin FNameValidatorInterface
|
|
|
|
|
virtual EValidatorResult IsValid(const FString& Name, bool bOriginal) override;
|
|
|
|
|
virtual EValidatorResult IsValid(const FName& Name, bool bOriginal) override;
|
|
|
|
|
// End FNameValidatorInterface
|
2021-09-14 10:59:08 -04:00
|
|
|
};
|
|
|
|
|
|
2021-11-24 05:33:15 -05:00
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
// FControlRigNameValidator
|
|
|
|
|
class CONTROLRIGDEVELOPER_API FControlRigNameValidator : public FStringSetNameValidator
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
FControlRigNameValidator(const class UBlueprint* Blueprint, const UStruct* ValidationScope, FName InExistingName = NAME_None);
|
|
|
|
|
|
|
|
|
|
// Begin FNameValidatorInterface
|
|
|
|
|
virtual EValidatorResult IsValid(const FString& Name, bool bOriginal) override;
|
|
|
|
|
virtual EValidatorResult IsValid(const FName& Name, bool bOriginal) override;
|
|
|
|
|
// End FNameValidatorInterface
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-07 06:49:07 -04:00
|
|
|
USTRUCT()
|
|
|
|
|
struct CONTROLRIGDEVELOPER_API FControlRigGraphSchemaAction_LocalVar : public FEdGraphSchemaAction_BlueprintVariableBase
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// Simple type info
|
|
|
|
|
static FName StaticGetTypeId() {static FName Type("FControlRigGraphSchemaAction_LocalVar"); return Type;}
|
|
|
|
|
virtual FName GetTypeId() const override { return StaticGetTypeId(); }
|
|
|
|
|
|
|
|
|
|
FControlRigGraphSchemaAction_LocalVar()
|
|
|
|
|
: FEdGraphSchemaAction_BlueprintVariableBase()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
FControlRigGraphSchemaAction_LocalVar(FText InNodeCategory, FText InMenuDesc, FText InToolTip, const int32 InGrouping, const int32 InSectionID)
|
|
|
|
|
: FEdGraphSchemaAction_BlueprintVariableBase(MoveTemp(InNodeCategory), MoveTemp(InMenuDesc), MoveTemp(InToolTip), InGrouping, InSectionID)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
virtual bool IsA(const FName& InType) const override
|
|
|
|
|
{
|
|
|
|
|
return InType == GetTypeId() || InType == FEdGraphSchemaAction_BlueprintVariableBase::StaticGetTypeId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual FEdGraphPinType GetPinType() const override;
|
|
|
|
|
|
|
|
|
|
virtual void ChangeVariableType(const FEdGraphPinType& NewPinType) override;
|
|
|
|
|
|
|
|
|
|
virtual void RenameVariable(const FName& NewName) override;
|
|
|
|
|
|
|
|
|
|
virtual bool IsValidName(const FName& NewName, FText& OutErrorMessage) const override;
|
|
|
|
|
|
|
|
|
|
virtual void DeleteVariable() override;
|
|
|
|
|
|
|
|
|
|
virtual bool IsVariableUsed() override;
|
|
|
|
|
};
|
|
|
|
|
|
2021-08-31 14:14:38 -04:00
|
|
|
USTRUCT()
|
|
|
|
|
struct CONTROLRIGDEVELOPER_API FControlRigGraphSchemaAction_PromoteToVariable : public FEdGraphSchemaAction
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// Simple type info
|
|
|
|
|
static FName StaticGetTypeId() {static FName Type("FControlRigGraphSchemaAction_PromoteToVariable"); return Type;}
|
|
|
|
|
virtual FName GetTypeId() const override { return StaticGetTypeId(); }
|
|
|
|
|
|
|
|
|
|
FControlRigGraphSchemaAction_PromoteToVariable()
|
|
|
|
|
: FEdGraphSchemaAction()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
FControlRigGraphSchemaAction_PromoteToVariable(UEdGraphPin* InEdGraphPin, bool InLocalVariable);
|
|
|
|
|
|
|
|
|
|
virtual bool IsA(const FName& InType) const override
|
|
|
|
|
{
|
|
|
|
|
return InType == GetTypeId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual UEdGraphNode* PerformAction(UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
UEdGraphPin* EdGraphPin;
|
|
|
|
|
bool bLocalVariable;
|
|
|
|
|
};
|
|
|
|
|
|
2021-01-14 15:00:40 -04:00
|
|
|
/** DragDropAction class for drag and dropping an item from the My Blueprints tree (e.g., variable or function) */
|
|
|
|
|
class CONTROLRIGDEVELOPER_API FControlRigFunctionDragDropAction : public FGraphSchemaActionDragDropAction
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
DRAG_DROP_OPERATOR_TYPE(FControlRigFunctionDragDropAction, FGraphSchemaActionDragDropAction)
|
|
|
|
|
|
|
|
|
|
// FGraphEditorDragDropAction interface
|
|
|
|
|
virtual FReply DroppedOnPanel(const TSharedRef< class SWidget >& Panel, FVector2D ScreenPosition, FVector2D GraphPosition, UEdGraph& Graph) override;
|
|
|
|
|
virtual FReply DroppedOnPin(FVector2D ScreenPosition, FVector2D GraphPosition) override;
|
|
|
|
|
virtual FReply DroppedOnAction(TSharedRef<FEdGraphSchemaAction> Action) override;
|
|
|
|
|
virtual FReply DroppedOnCategory(FText Category) override;
|
|
|
|
|
virtual void HoverTargetChanged() override;
|
|
|
|
|
// End of FGraphEditorDragDropAction
|
|
|
|
|
|
|
|
|
|
/** Set if operation is modified by alt */
|
|
|
|
|
void SetAltDrag(bool InIsAltDrag) { bAltDrag = InIsAltDrag; }
|
|
|
|
|
|
|
|
|
|
/** Set if operation is modified by the ctrl key */
|
|
|
|
|
void SetCtrlDrag(bool InIsCtrlDrag) { bControlDrag = InIsCtrlDrag; }
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
|
FControlRigFunctionDragDropAction();
|
|
|
|
|
|
|
|
|
|
static TSharedRef<FControlRigFunctionDragDropAction> New(TSharedPtr<FEdGraphSchemaAction> InAction, UControlRigBlueprint* InRigBlueprint, UControlRigGraph* InRigGraph);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
UControlRigBlueprint* SourceRigBlueprint;
|
|
|
|
|
UControlRigGraph* SourceRigGraph;
|
|
|
|
|
bool bControlDrag;
|
|
|
|
|
bool bAltDrag;
|
|
|
|
|
|
|
|
|
|
friend class UControlRigGraphSchema;
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-12 16:57:51 -04:00
|
|
|
UCLASS()
|
2019-01-08 11:38:48 -05:00
|
|
|
class CONTROLRIGDEVELOPER_API UControlRigGraphSchema : public UEdGraphSchema
|
2018-04-12 16:57:51 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/** Name constants */
|
|
|
|
|
static const FName GraphName_ControlRig;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
UControlRigGraphSchema();
|
|
|
|
|
|
|
|
|
|
// UEdGraphSchema interface
|
|
|
|
|
virtual void GetGraphContextActions(FGraphContextMenuBuilder& ContextMenuBuilder) const override;
|
2019-09-10 11:35:20 -04:00
|
|
|
virtual void GetContextMenuActions(class UToolMenu* Menu, class UGraphNodeContextMenuContext* Context) const override;
|
2018-04-12 16:57:51 -04:00
|
|
|
virtual bool TryCreateConnection(UEdGraphPin* PinA, UEdGraphPin* PinB) const override;
|
|
|
|
|
virtual const FPinConnectionResponse CanCreateConnection(const UEdGraphPin* A, const UEdGraphPin* B) const override;
|
|
|
|
|
virtual FLinearColor GetPinTypeColor(const FEdGraphPinType& PinType) const override;
|
2021-06-09 04:45:19 -04:00
|
|
|
virtual bool SupportsPinType(TWeakPtr<const FEdGraphSchemaAction> SchemaAction, const FEdGraphPinType& PinType) const override;
|
|
|
|
|
virtual bool SupportsPinTypeContainer(TWeakPtr<const FEdGraphSchemaAction> SchemaAction, const FEdGraphPinType& PinType, const EPinContainerType& ContainerType) const override;
|
2018-04-12 16:57:51 -04:00
|
|
|
virtual void BreakPinLinks(UEdGraphPin& TargetPin, bool bSendsNodeNotifcation) const override;
|
|
|
|
|
virtual void BreakSinglePinLink(UEdGraphPin* SourcePin, UEdGraphPin* TargetPin) const override;
|
2021-01-14 15:00:40 -04:00
|
|
|
virtual bool CanGraphBeDropped(TSharedPtr<FEdGraphSchemaAction> InAction) const override;
|
2021-06-07 06:49:07 -04:00
|
|
|
virtual FReply BeginGraphDragAction(TSharedPtr<FEdGraphSchemaAction> InAction, const FPointerEvent& MouseEvent = FPointerEvent() ) const override;
|
2018-04-12 16:57:51 -04:00
|
|
|
virtual class FConnectionDrawingPolicy* CreateConnectionDrawingPolicy(int32 InBackLayerID, int32 InFrontLayerID, float InZoomFactor, const FSlateRect& InClippingRect, class FSlateWindowElementList& InDrawElements, class UEdGraph* InGraphObj) const override;
|
|
|
|
|
virtual bool ShouldHidePinDefaultValue(UEdGraphPin* Pin) const override;
|
2019-07-16 11:49:59 -04:00
|
|
|
virtual void TrySetDefaultValue(UEdGraphPin& InPin, const FString& InNewDefaultValue, bool bMarkAsModified = true) const override;
|
|
|
|
|
virtual void TrySetDefaultObject(UEdGraphPin& InPin, UObject* InNewDefaultObject, bool bMarkAsModified) const override;
|
|
|
|
|
virtual void TrySetDefaultText(UEdGraphPin& InPin, const FText& InNewDefaultText, bool bMarkAsModified) const override;
|
2018-04-12 16:57:51 -04:00
|
|
|
virtual bool ShouldAlwaysPurgeOnModification() const override { return false; }
|
|
|
|
|
virtual bool ArePinsCompatible(const UEdGraphPin* PinA, const UEdGraphPin* PinB, const UClass* CallingContext, bool bIgnoreArray /*= false*/) const override;
|
2019-03-25 14:19:45 -04:00
|
|
|
virtual bool DoesSupportPinWatching() const override { return true; }
|
2020-01-22 17:58:55 -05:00
|
|
|
virtual bool IsPinBeingWatched(UEdGraphPin const* Pin) const override;
|
|
|
|
|
virtual void ClearPinWatch(UEdGraphPin const* Pin) const override;
|
|
|
|
|
virtual void OnPinConnectionDoubleCicked(UEdGraphPin* PinA, UEdGraphPin* PinB, const FVector2D& GraphPosition) const override;
|
|
|
|
|
virtual bool MarkBlueprintDirtyFromNewNode(UBlueprint* InBlueprint, UEdGraphNode* InEdGraphNode) const override;
|
2020-02-04 11:06:23 -05:00
|
|
|
virtual bool SafeDeleteNodeFromGraph(UEdGraph* Graph, UEdGraphNode* Node) const override;
|
2020-09-24 00:43:27 -04:00
|
|
|
virtual bool CanVariableBeDropped(UEdGraph* InGraph, FProperty* InVariableToDrop) const override;
|
|
|
|
|
virtual bool RequestVariableDropOnPanel(UEdGraph* InGraph, FProperty* InVariableToDrop, const FVector2D& InDropPosition, const FVector2D& InScreenPosition) override;
|
2020-10-26 06:51:31 -04:00
|
|
|
virtual bool RequestVariableDropOnPin(UEdGraph* InGraph, FProperty* InVariableToDrop, UEdGraphPin* InPin, const FVector2D& InDropPosition, const FVector2D& InScreenPosition) override;
|
2020-01-22 17:58:55 -05:00
|
|
|
virtual bool IsStructEditable(UStruct* InStruct) const;
|
2020-10-26 11:32:22 -04:00
|
|
|
virtual void SetNodePosition(UEdGraphNode* Node, const FVector2D& Position) const override;
|
2021-06-11 05:36:36 -04:00
|
|
|
void SetNodePosition(UEdGraphNode* Node, const FVector2D& Position, bool bSetupUndo) const;
|
2020-12-14 08:58:12 -04:00
|
|
|
virtual void GetGraphDisplayInformation(const UEdGraph& Graph, /*out*/ FGraphDisplayInfo& DisplayInfo) const override;
|
2021-06-07 06:49:07 -04:00
|
|
|
virtual bool GetLocalVariables(const UEdGraph* InGraph, TArray<FBPVariableDescription>& OutLocalVariables) const override;
|
|
|
|
|
virtual TSharedPtr<FEdGraphSchemaAction> MakeActionFromVariableDescription(const UEdGraph* InEdGraph, const FBPVariableDescription& Variable) const override;
|
2021-01-27 05:06:20 -04:00
|
|
|
virtual FText GetGraphCategory(const UEdGraph* InGraph) const override;
|
|
|
|
|
virtual FReply TrySetGraphCategory(const UEdGraph* InGraph, const FText& InCategory) override;
|
2020-12-14 08:58:12 -04:00
|
|
|
virtual bool TryDeleteGraph(UEdGraph* GraphToDelete) const override;
|
|
|
|
|
virtual bool TryRenameGraph(UEdGraph* GraphToRename, const FName& InNewName) const override;
|
2020-12-14 12:47:18 -04:00
|
|
|
virtual bool CanDuplicateGraph(UEdGraph* InSourceGraph) const { return false; }
|
2021-01-05 09:12:57 -04:00
|
|
|
virtual UEdGraphPin* DropPinOnNode(UEdGraphNode* InTargetNode, const FName& InSourcePinName, const FEdGraphPinType& InSourcePinType, EEdGraphPinDirection InSourcePinDirection) const override;
|
|
|
|
|
virtual bool SupportsDropPinOnNode(UEdGraphNode* InTargetNode, const FEdGraphPinType& InSourcePinType, EEdGraphPinDirection InSourcePinDirection, FText& OutErrorMessage) const override;
|
2021-01-14 15:00:40 -04:00
|
|
|
virtual void SetPinBeingDroppedOnNode(UEdGraphPin* InSourcePin) const override { PinBeingDropped = InSourcePin; }
|
2021-08-31 14:14:38 -04:00
|
|
|
virtual void InsertAdditionalActions(TArray<UBlueprint*> InBlueprints, TArray<UEdGraph*> InGraphs, TArray<UEdGraphPin*> InPins, FGraphActionListBuilderBase& OutAllActions) const override;
|
2021-11-24 05:33:15 -05:00
|
|
|
virtual TSharedPtr<INameValidatorInterface> GetNameValidator(const UBlueprint* BlueprintObj, const FName& OriginalName, const UStruct* ValidationScope, const FName& ActionTypeId) const override;
|
2018-04-12 16:57:51 -04:00
|
|
|
|
2021-06-09 04:45:19 -04:00
|
|
|
/** Returns true if the schema supports the script type */
|
|
|
|
|
bool SupportsPinType(UScriptStruct* ScriptStruct) const;
|
|
|
|
|
|
2018-04-12 16:57:51 -04:00
|
|
|
/** Create a graph node for a rig */
|
|
|
|
|
UControlRigGraphNode* CreateGraphNode(UControlRigGraph* InGraph, const FName& InPropertyName) const;
|
|
|
|
|
|
|
|
|
|
/** Automatically layout the passed-in nodes */
|
|
|
|
|
void LayoutNodes(UControlRigGraph* InGraph, const TArray<UControlRigGraphNode*>& InNodes) const;
|
|
|
|
|
|
2019-04-02 11:26:55 -04:00
|
|
|
/** Helper function to rename a node */
|
|
|
|
|
void RenameNode(UControlRigGraphNode* Node, const FName& InNewNodeName) const;
|
2019-04-12 10:01:39 -04:00
|
|
|
|
|
|
|
|
/** Helper function to recursively reset the pin defaults */
|
|
|
|
|
virtual void ResetPinDefaultsRecursive(UEdGraphPin* InPin) const;
|
2019-04-24 18:34:05 -04:00
|
|
|
|
|
|
|
|
/** Returns all of the applicable pin types for variables within a control rig */
|
|
|
|
|
virtual void GetVariablePinTypes(TArray<FEdGraphPinType>& PinTypes) const;
|
2020-01-22 17:58:55 -05:00
|
|
|
|
2021-06-11 05:36:36 -04:00
|
|
|
void StartGraphNodeInteraction(UEdGraphNode* InNode) const;
|
2020-09-24 00:43:27 -04:00
|
|
|
void EndGraphNodeInteraction(UEdGraphNode* InNode) const;
|
2021-06-11 05:36:36 -04:00
|
|
|
static TArray<UEdGraphNode*> GetNodesToMoveForNode(UEdGraphNode* InNode);
|
2021-06-11 06:33:25 -04:00
|
|
|
FVector2D GetNodePositionAtStartOfInteraction(UEdGraphNode* InNode) const;
|
2020-09-24 00:43:27 -04:00
|
|
|
|
2021-09-08 10:41:30 -04:00
|
|
|
void HandleModifiedEvent(ERigVMGraphNotifType InNotifType, URigVMGraph* InGraph, UObject* InSubject);
|
|
|
|
|
|
2020-01-22 17:58:55 -05:00
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
const UEdGraphPin* LastPinForCompatibleCheck = nullptr;
|
|
|
|
|
bool bLastPinWasInput;
|
2021-01-14 15:00:40 -04:00
|
|
|
mutable UEdGraphPin* PinBeingDropped = nullptr;
|
2020-01-22 17:58:55 -05:00
|
|
|
|
2021-06-11 05:36:36 -04:00
|
|
|
#if WITH_EDITOR
|
|
|
|
|
mutable TArray<UEdGraphNode*> NodesBeingInteracted;
|
|
|
|
|
mutable TMap<FName, FVector2D> NodePositionsDuringStart;
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-01-22 17:58:55 -05:00
|
|
|
friend class UControlRigRerouteNodeSpawner;
|
2020-09-24 00:43:27 -04:00
|
|
|
friend class UControlRigIfNodeSpawner;
|
|
|
|
|
friend class UControlRigSelectNodeSpawner;
|
|
|
|
|
friend class UControlRigUnitNodeSpawner;
|
2021-08-18 06:18:21 -04:00
|
|
|
friend class UControlRigArrayNodeSpawner;
|
2018-04-12 16:57:51 -04:00
|
|
|
};
|
|
|
|
|
|