2022-07-21 12:35:25 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-01-13 01:54:01 -05:00
|
|
|
#include "Containers/Map.h"
|
2023-08-21 08:46:45 -04:00
|
|
|
#include "Templates/Function.h"
|
|
|
|
|
#include "Templates/SubclassOf.h"
|
2023-11-22 14:33:59 -05:00
|
|
|
#include "Templates/ValueOrError.h"
|
2023-01-13 01:54:01 -05:00
|
|
|
|
2023-12-19 11:31:33 -05:00
|
|
|
struct FMVVMBlueprintFunctionReference;
|
2023-01-13 01:54:01 -05:00
|
|
|
struct FMVVMBlueprintPropertyPath;
|
2023-07-26 14:04:59 -04:00
|
|
|
struct FMVVMBlueprintViewBinding;
|
2022-07-21 12:35:25 -04:00
|
|
|
|
2023-07-26 14:04:59 -04:00
|
|
|
class UBlueprint;
|
2022-07-21 12:35:25 -04:00
|
|
|
class UClass;
|
|
|
|
|
class UEdGraph;
|
2023-12-19 11:31:33 -05:00
|
|
|
class UEdGraphNode;
|
2023-07-26 14:04:59 -04:00
|
|
|
class UEdGraphPin;
|
|
|
|
|
class UK2Node;
|
2022-10-05 16:05:24 -04:00
|
|
|
class UK2Node_CallFunction;
|
2023-07-26 14:04:59 -04:00
|
|
|
class FKismetCompilerContext;
|
2022-07-21 12:35:25 -04:00
|
|
|
class UMVVMBlueprintView;
|
2023-11-22 14:33:59 -05:00
|
|
|
namespace UE::MVVM { struct FMVVMConstFieldVariant; }
|
2022-07-21 12:35:25 -04:00
|
|
|
|
|
|
|
|
namespace UE::MVVM::ConversionFunctionHelper
|
|
|
|
|
{
|
2023-07-26 14:04:59 -04:00
|
|
|
/** Conversion function requires a wrapper. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API bool RequiresWrapper(const UFunction* Function);
|
|
|
|
|
|
2023-12-19 11:31:33 -05:00
|
|
|
/** The pin is valid to use with a PropertyPath. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API bool IsInputPin(const UEdGraphPin* Pin);
|
2022-10-05 16:05:24 -04:00
|
|
|
|
|
|
|
|
/** Find the property path of a given argument in the conversion function. */
|
2023-07-26 14:04:59 -04:00
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API FMVVMBlueprintPropertyPath GetPropertyPathForPin(const UBlueprint* WidgetBlueprint, const UEdGraphPin* Pin, bool bSkipResolve);
|
|
|
|
|
|
|
|
|
|
/** Set the property path of a given argument in the conversion function. */
|
2023-11-22 14:33:59 -05:00
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API void SetPropertyPathForPin(const UBlueprint* Blueprint, const FMVVMBlueprintPropertyPath& PropertyPath, UEdGraphPin* Pin);
|
2023-07-26 14:04:59 -04:00
|
|
|
|
|
|
|
|
/** Find the property path of a given argument in the conversion function. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API FMVVMBlueprintPropertyPath GetPropertyPathForArgument(const UBlueprint* WidgetBlueprint, const UK2Node_CallFunction* Function, FName ArgumentName, bool bSkipResolve);
|
2022-07-21 12:35:25 -04:00
|
|
|
|
2022-10-05 16:05:24 -04:00
|
|
|
/** Create the name of the conversion function wrapper this binding should have. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API FName CreateWrapperName(const FMVVMBlueprintViewBinding& Binding, bool bSourceToDestination);
|
2022-07-22 07:39:25 -04:00
|
|
|
|
2023-11-22 14:33:59 -05:00
|
|
|
/**
|
|
|
|
|
* If we can create a graph to set a property/function.
|
|
|
|
|
*/
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API TValueOrError<void, FText> CanCreateSetterGraph(UBlueprint* WidgetBlueprint, const FMVVMBlueprintPropertyPath& PropertyPath);
|
|
|
|
|
|
2024-08-14 10:34:15 -04:00
|
|
|
struct MODELVIEWVIEWMODELBLUEPRINT_API FCreateGraphResult
|
2023-11-22 14:33:59 -05:00
|
|
|
{
|
|
|
|
|
/** The new graph created. */
|
|
|
|
|
UEdGraph* NewGraph = nullptr;
|
|
|
|
|
/** Node that owns the pins. */
|
|
|
|
|
UK2Node* WrappedNode = nullptr;
|
2024-08-14 09:59:16 -04:00
|
|
|
/** Nodes of relevance beyond the wrapped node, keyed by name. */
|
|
|
|
|
TMap<FName, UK2Node*> NamedNodes;
|
|
|
|
|
/** True if this graph belongs in an ubergraph page */
|
|
|
|
|
bool bIsUbergraphPage = false;
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-14 10:34:15 -04:00
|
|
|
struct MODELVIEWVIEWMODELBLUEPRINT_API FCreateGraphParams
|
2024-08-14 09:59:16 -04:00
|
|
|
{
|
|
|
|
|
bool bIsConst = false;
|
|
|
|
|
bool bTransient = false;
|
|
|
|
|
bool bIsForEvent = false;
|
|
|
|
|
|
|
|
|
|
/** If true implies this graph will create events*/
|
|
|
|
|
bool bCreateUbergraphPage = false;
|
2023-11-22 14:33:59 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2024-08-14 09:59:16 -04:00
|
|
|
* Create a graph to set a property/function. Used by Event Bindings
|
2023-11-22 14:33:59 -05:00
|
|
|
*/
|
2024-08-14 09:59:16 -04:00
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API TValueOrError<FCreateGraphResult, FText> CreateSetterGraph(UBlueprint* WidgetBlueprint, FName GraphName, const UFunction* Signature, const FMVVMBlueprintPropertyPath& PropertyPath, FCreateGraphParams InParams);
|
2023-11-22 14:33:59 -05:00
|
|
|
|
2024-08-14 09:59:16 -04:00
|
|
|
/**
|
|
|
|
|
* Create a graph to set a property/function. Used by conversion functions for async K2 Nodes.
|
|
|
|
|
*/
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API TValueOrError<FCreateGraphResult, FText> CreateSetterGraph(UBlueprint* WidgetBlueprint, FName GraphName, const TSubclassOf<UK2Node> Node, const FMVVMBlueprintPropertyPath& PropertyPath, FCreateGraphParams InParams);
|
|
|
|
|
|
|
|
|
|
/** Create a graph, used by conversion functions for UFunctions */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API FCreateGraphResult CreateGraph(UBlueprint* WidgetBlueprint, FName GraphName, const UFunction* Signature, const UFunction* FunctionToWrap, FCreateGraphParams FCreateGraInParamsphParams);
|
|
|
|
|
|
|
|
|
|
/** Create a graph, used by conversion functions for K2 Nodes */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API FCreateGraphResult CreateGraph(UBlueprint* WidgetBlueprint, FName GraphName, const UFunction* Signature, const TSubclassOf<UK2Node> Node, FCreateGraphParams InParams, TFunctionRef<void(UK2Node*)> InitNodeCallback);
|
|
|
|
|
|
|
|
|
|
UE_DEPRECATED(5.5, "Call the version of CreateSetterGraph that takes a FCreateGraphParams instead.")
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API TValueOrError<FCreateGraphResult, FText> CreateSetterGraph(UBlueprint* WidgetBlueprint, FName GraphName, const UFunction* Signature, const FMVVMBlueprintPropertyPath& PropertyPath, bool bIsConst, bool bTransient, const bool bIsForEvent);
|
|
|
|
|
UE_DEPRECATED(5.5, "Call the version of CreateGraph that takes a FCreateGraphParams instead.")
|
2024-01-12 10:07:58 -05:00
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API FCreateGraphResult CreateGraph(UBlueprint* WidgetBlueprint, FName GraphName, const UFunction* Signature, const UFunction* FunctionToWrap, bool bIsConst, bool bTransient);
|
2024-08-14 09:59:16 -04:00
|
|
|
UE_DEPRECATED(5.5, "Call the version of CreateGraph that takes a FCreateGraphParams instead.")
|
2024-01-12 10:07:58 -05:00
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API FCreateGraphResult CreateGraph(UBlueprint* WidgetBlueprint, FName GraphName, const UFunction* Signature, const TSubclassOf<UK2Node> Node, bool bIsConst, bool bTransient, TFunctionRef<void(UK2Node*)> InitNodeCallback);
|
2022-07-22 07:39:25 -04:00
|
|
|
|
2024-03-08 14:09:12 -05:00
|
|
|
/** Insert a branch node to the existing graph to test before executing the rest of the . */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API UK2Node* InsertEarlyExitBranchNode(UEdGraph* Graph, TSubclassOf<UK2Node> BranchNode);
|
|
|
|
|
|
2023-12-19 11:31:33 -05:00
|
|
|
/** Find the main conversion function node from the given graph. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API UK2Node* GetWrapperNode(const UEdGraph* Graph);
|
|
|
|
|
|
2022-10-05 16:05:24 -04:00
|
|
|
/** Find the conversion function node from the given graph. */
|
2023-12-19 11:31:33 -05:00
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API UEdGraphPin* FindPin(const UEdGraph* Graph, const TArrayView<const FName> PinNames);
|
|
|
|
|
|
2024-10-01 18:59:25 -04:00
|
|
|
/** Find the conversion function node from the given graph. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API UEdGraphPin* FindPin(const UEdGraphNode* Node, const TArrayView<const FName> PinNames);
|
|
|
|
|
|
2023-12-19 11:31:33 -05:00
|
|
|
/** Find the conversion function node from the given graph. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API TArray<FName> FindPinId(const UEdGraphPin* GraphPin);
|
2024-01-12 10:07:58 -05:00
|
|
|
|
|
|
|
|
/** Return the pin used for arguments. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API TArray<UEdGraphPin*> FindInputPins(const UK2Node* Node);
|
|
|
|
|
|
|
|
|
|
/** Return the pin used as the return value. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API UEdGraphPin* FindOutputPin(const UK2Node* Node);
|
2024-05-02 14:03:27 -04:00
|
|
|
|
|
|
|
|
/** Add metadata to the Graph/Function. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API void SetMetaData(UEdGraph* NewGraph, FName MetaData, FStringView Value);
|
2024-05-31 11:27:14 -04:00
|
|
|
|
|
|
|
|
/** Mark the node a auto promote. We try to hide those node in the editor. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API void MarkNodeAsAutoPromote(UEdGraphNode* Node);
|
|
|
|
|
|
|
|
|
|
/** Is the node an auto promote node. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API bool IsAutoPromoteNode(const UEdGraphNode* Node);
|
2024-08-14 09:59:16 -04:00
|
|
|
|
|
|
|
|
/** Is the node an async node. */
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API bool IsAsyncNode(const TSubclassOf<UK2Node> Node);
|
2024-10-01 18:59:25 -04:00
|
|
|
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API bool IsNodeMarkedToKeepConnections(const UK2Node* Node);
|
|
|
|
|
MODELVIEWVIEWMODELBLUEPRINT_API void MarkNodeToKeepConnections(const UK2Node* Node);
|
|
|
|
|
|
2023-01-13 01:54:01 -05:00
|
|
|
} //namespace
|
|
|
|
|
|
|
|
|
|
#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "MVVMPropertyPath.h"
|
|
|
|
|
#endif
|