diff --git a/Content/Luprex/lxGameMode.uasset b/Content/Luprex/lxGameMode.uasset index 497fe07b..0248630a 100644 --- a/Content/Luprex/lxGameMode.uasset +++ b/Content/Luprex/lxGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ac42935b15f61f76f98a2374bbdc14fffb3eaf765c065c1a03fc77cf2cb6e93c -size 128073 +oid sha256:07e6c90d149a324d8ef2bd9317fd018c425363fe84dedb598a8ef1b3c46c3015 +size 137194 diff --git a/Source/Integration/BlueprintErrors.cpp b/Source/Integration/BlueprintErrors.cpp index 6271ec76..ea758844 100644 --- a/Source/Integration/BlueprintErrors.cpp +++ b/Source/Integration/BlueprintErrors.cpp @@ -3,7 +3,6 @@ #include "Internationalization/TextFormatter.h" #include "Kismet/KismetSystemLibrary.h" #include "Kismet2/KismetDebugUtilities.h" - #include "Kismet/KismetTextLibrary.h" ELogVerbosity::Type UlxBlueprintErrorLibrary::ConvertElxLogVerbosity(ElxLogVerbosity Verbosity) { @@ -75,6 +74,140 @@ void UlxBlueprintErrorLibrary::FormatErrorInternal(UObject *Context, ElxLogVerbo } } +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataBool(bool Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Text; + Result.ArgumentName = Name; + Result.ArgumentValue = UKismetTextLibrary::Conv_BoolToText(Value); + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataInt(int Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Int; + Result.ArgumentName = Name; + Result.ArgumentValueInt = Value; + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataInt64(int64 Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Int; + Result.ArgumentName = Name; + Result.ArgumentValueInt = Value; + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataFloat(float Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Float; + Result.ArgumentName = Name; + Result.ArgumentValueFloat = Value; + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataDouble(double Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Double; + Result.ArgumentName = Name; + Result.ArgumentValueDouble = Value; + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataText(FText Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Text; + Result.ArgumentName = Name; + Result.ArgumentValue = Value; + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataString(FString Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Text; + Result.ArgumentName = Name; + Result.ArgumentValue = UKismetTextLibrary::Conv_StringToText(Value); + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataName(FName Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Text; + Result.ArgumentName = Name; + Result.ArgumentValue = UKismetTextLibrary::Conv_NameToText(Value); + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataGender(ETextGender Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Gender; + Result.ArgumentName = Name; + Result.ArgumentValueGender = Value; + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataObject(UObject *Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Text; + Result.ArgumentName = Name; + Result.ArgumentValue = UKismetTextLibrary::Conv_ObjectToText(Value); + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataVector(const FVector &Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Text; + Result.ArgumentName = Name; + Result.ArgumentValue = UKismetTextLibrary::Conv_VectorToText(Value); + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataVector2D(const FVector2D &Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Text; + Result.ArgumentName = Name; + Result.ArgumentValue = UKismetTextLibrary::Conv_Vector2dToText(Value); + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataRotator(const FRotator &Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Text; + Result.ArgumentName = Name; + Result.ArgumentValue = UKismetTextLibrary::Conv_RotatorToText(Value); + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataTransform(const FTransform &Value, const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Text; + Result.ArgumentName = Name; + Result.ArgumentValue = UKismetTextLibrary::Conv_TransformToText(Value); + return Result; +} + +FFormatArgumentData UlxFormatDataLibrary::FormatArgumentDataBlank(const FString &Name) +{ + FFormatArgumentData Result; + Result.ArgumentValueType = EFormatArgumentType::Text; + Result.ArgumentName = Name; + Result.ArgumentValue = FText(); + return Result; +} FlxDebugBlueprintErrorsOutputDevice::FlxDebugBlueprintErrorsOutputDevice(const ElxLogVerbosity &SensitivityRef) : Sensitivity(SensitivityRef) diff --git a/Source/Integration/BlueprintErrors.h b/Source/Integration/BlueprintErrors.h index b7cd6240..e902447d 100644 --- a/Source/Integration/BlueprintErrors.h +++ b/Source/Integration/BlueprintErrors.h @@ -149,6 +149,62 @@ public: static ELogVerbosity::Type ConvertElxLogVerbosity(ElxLogVerbosity Verbosity); }; +/* + * A library that contains functions that convert data into FFormatArgumentData + * structs, so that the data can be passed to FText::Format. + */ +UCLASS(MinimalAPI) +class UlxFormatDataLibrary : public UBlueprintFunctionLibrary +{ + GENERATED_BODY() + +public: + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataBool(bool Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataInt(int Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataInt64(int64 Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataFloat(float Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataDouble(double Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataText(FText Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataString(FString Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataName(FName Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataGender(ETextGender Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataObject(UObject *Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataVector(const FVector &Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataVector2D(const FVector2D &Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataRotator(const FRotator &Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataTransform(const FTransform &Value, const FString &Name); + + UFUNCTION(BlueprintPure, meta = (BlueprintInternalUseOnly = "true"), Category = "Luprex|Utility") + static FFormatArgumentData FormatArgumentDataBlank(const FString &Name); +}; + /* Debug Blueprint Errors output device. * * When an error message gets written to the log, using "Format Error Message," diff --git a/Source/Integration/FormatError.cpp b/Source/Integration/FormatError.cpp index 1eaf4e98..bba75af2 100644 --- a/Source/Integration/FormatError.cpp +++ b/Source/Integration/FormatError.cpp @@ -78,7 +78,6 @@ UK2Node_FormatError::UK2Node_FormatError(const FObjectInitializer& ObjectInitial "Output an error, warning, or informational message to the log file.\n" "\n" " \u2022 Use {ArgName} to denote format arguments, giving each argument a different ArgName.\n" - " \u2022 Arguments may be Byte, Integer, Float, Text, String, Name, Boolean, Object or ETextGender.\n" "\n" "It is often desirable to use this in conjunction with a separate utility that\n" "pauses the execution of the blueprint whenever an error is logged." @@ -267,22 +266,6 @@ FText UK2Node_FormatError::GetTooltipText() const return NodeTooltip; } -static UEdGraphPin* FindOutputStructPinChecked(UEdGraphNode* Node) -{ - check(NULL != Node); - UEdGraphPin* OutputPin = NULL; - for (int32 PinIndex = 0; PinIndex < Node->Pins.Num(); ++PinIndex) - { - UEdGraphPin* Pin = Node->Pins[PinIndex]; - if (Pin && (EGPD_Output == Pin->Direction)) - { - OutputPin = Pin; - break; - } - } - check(NULL != OutputPin); - return OutputPin; -} void UK2Node_FormatError::PostReconstructNode() { @@ -298,6 +281,45 @@ void UK2Node_FormatError::PostReconstructNode() } } + +// Get a function that can convert the specified type into a FFormatArgumentData. +// +UFunction *ToFormatArgumentData(const UEdGraphSchema_K2 *Schema, const FEdGraphPinType& PinType, bool AllowWild) +{ + // Special case. Wildcard Pins are unconnected pins. + // + if (PinType.PinCategory == UEdGraphSchema_K2::PC_Wildcard && AllowWild) + { + return UlxFormatDataLibrary::StaticClass()->FindFunctionByName(GET_MEMBER_NAME_CHECKED(UlxFormatDataLibrary, FormatArgumentDataBlank)); + } + + // Try to find an exact match in the UlxFormatDataLibrary. + // + for (auto It = TFieldIterator(UlxFormatDataLibrary::StaticClass()); It; ++It) + { + UFunction* Function = *It; + FProperty* ValueProperty = Function->FindPropertyByName(TEXT("Value")); + FEdGraphPinType ValuePinType; + bool Convertible = Schema->ConvertPropertyToPinType(ValueProperty, ValuePinType); + if (!Convertible) continue; + if (!Schema->ArePinTypesEquivalent(PinType, ValuePinType)) continue; + return Function; + } + + // A case for subclasses of 'Object' which are not exactly 'Object' + // + if (PinType.PinCategory == UEdGraphSchema_K2::PC_Object) + { + return UlxFormatDataLibrary::StaticClass()->FindFunctionByName(GET_MEMBER_NAME_CHECKED(UlxFormatDataLibrary, FormatArgumentDataObject)); + } + + // We don't have a match. + // + return nullptr; +}; + + + void UK2Node_FormatError::ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) { Super::ExpandNode(CompilerContext, SourceGraph); @@ -334,136 +356,30 @@ void UK2Node_FormatError::ExpandNode(class FKismetCompilerContext& CompilerConte FString OriginalName = PinNames[ArgIdx]; UEdGraphPin* ArgumentPin = FindPin(ArgumentNameAddPrefix(OriginalName), EGPD_Input); - static UScriptStruct* FormatArgumentDataStruct = FindObjectChecked(FindObjectChecked(nullptr, TEXT("/Script/Engine")), TEXT("FormatArgumentData")); - // Spawn a "Make Struct" node to create the struct needed for formatting the text. - UK2Node_MakeStruct* MakeFormatArgumentDataStruct = CompilerContext.SpawnIntermediateNode(this, SourceGraph); - MakeFormatArgumentDataStruct->StructType = FormatArgumentDataStruct; - MakeFormatArgumentDataStruct->AllocateDefaultPins(); - MakeFormatArgumentDataStruct->bMadeAfterOverridePinRemoval = true; - CompilerContext.MessageLog.NotifyIntermediateObjectCreation(MakeFormatArgumentDataStruct, this); - - // Set the struct's "ArgumentName" pin literal to be the argument pin's name. - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentName)), OriginalName); - - UEdGraphPin* ArgumentTypePin = MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValueType)); - - // Move the connection of the argument pin to the correct argument value pin, and also set the correct argument type based on the pin that was hooked up. - if (ArgumentPin->LinkedTo.Num() > 0) + // Find a function that can convert the input into an FFormatArgumentData. + UFunction *Converter = ToFormatArgumentData(Schema, ArgumentPin->PinType, true); + if (Converter == nullptr) { - const FName& ArgumentPinCategory = ArgumentPin->PinType.PinCategory; - - // Adds an implicit conversion node to this argument based on its function and pin name - auto AddConversionNode = [&](const FName FuncName, const TCHAR* PinName) - { - // Set the default value if there was something passed in, or default to "Text" - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*ArgumentTypePin, TEXT("Text")); - - // Spawn conversion node based on the given function name - UK2Node_CallFunction* ToTextFunction = CompilerContext.SpawnIntermediateNode(this, SourceGraph); - ToTextFunction->SetFromFunction(UKismetTextLibrary::StaticClass()->FindFunctionByName(FuncName)); - ToTextFunction->AllocateDefaultPins(); - CompilerContext.MessageLog.NotifyIntermediateObjectCreation(ToTextFunction, this); - - CompilerContext.MovePinLinksToIntermediate(*ArgumentPin, *ToTextFunction->FindPinChecked(PinName)); - - ToTextFunction->FindPinChecked(UEdGraphSchema_K2::PN_ReturnValue)->MakeLinkTo(MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValue))); - }; - - if (ArgumentPinCategory == UEdGraphSchema_K2::PC_Int) - { - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*ArgumentTypePin, TEXT("Int")); - // Need a manual cast from int -> int64 - UK2Node_CallFunction* CallFloatToDoubleFunction = CompilerContext.SpawnIntermediateNode(this, SourceGraph); - CallFloatToDoubleFunction->SetFromFunction(UKismetMathLibrary::StaticClass()->FindFunctionByName(GET_MEMBER_NAME_CHECKED(UKismetMathLibrary, Conv_IntToInt64))); - CallFloatToDoubleFunction->AllocateDefaultPins(); - CompilerContext.MessageLog.NotifyIntermediateObjectCreation(CallFloatToDoubleFunction, this); - - // Move the byte output pin to the input pin of the conversion node - CompilerContext.MovePinLinksToIntermediate(*ArgumentPin, *CallFloatToDoubleFunction->FindPinChecked(TEXT("InInt"))); - - // Connect the int output pin to the argument value - CallFloatToDoubleFunction->FindPinChecked(UEdGraphSchema_K2::PN_ReturnValue)->MakeLinkTo(MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValueInt))); - } - else if (ArgumentPinCategory == UEdGraphSchema_K2::PC_Real) - { - if (ArgumentPin->PinType.PinSubCategory == UEdGraphSchema_K2::PC_Float) - { - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*ArgumentTypePin, TEXT("Float")); - CompilerContext.MovePinLinksToIntermediate(*ArgumentPin, *MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValueFloat))); - } - else if (ArgumentPin->PinType.PinSubCategory == UEdGraphSchema_K2::PC_Double) - { - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*ArgumentTypePin, TEXT("Double")); - CompilerContext.MovePinLinksToIntermediate(*ArgumentPin, *MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValueDouble))); - } - else - { - check(false); - } - } - else if (ArgumentPinCategory == UEdGraphSchema_K2::PC_Int64) - { - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*ArgumentTypePin, TEXT("Int64")); - CompilerContext.MovePinLinksToIntermediate(*ArgumentPin, *MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValueInt))); - } - else if (ArgumentPinCategory == UEdGraphSchema_K2::PC_Text) - { - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*ArgumentTypePin, TEXT("Text")); - CompilerContext.MovePinLinksToIntermediate(*ArgumentPin, *MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValue))); - } - else if (ArgumentPinCategory == UEdGraphSchema_K2::PC_Byte && !ArgumentPin->PinType.PinSubCategoryObject.IsValid()) - { - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*ArgumentTypePin, TEXT("Int")); - - // Need a manual cast from byte -> int - UK2Node_CallFunction* CallByteToIntFunction = CompilerContext.SpawnIntermediateNode(this, SourceGraph); - CallByteToIntFunction->SetFromFunction(UKismetMathLibrary::StaticClass()->FindFunctionByName(GET_MEMBER_NAME_CHECKED(UKismetMathLibrary, Conv_ByteToInt64))); - CallByteToIntFunction->AllocateDefaultPins(); - CompilerContext.MessageLog.NotifyIntermediateObjectCreation(CallByteToIntFunction, this); - - // Move the byte output pin to the input pin of the conversion node - CompilerContext.MovePinLinksToIntermediate(*ArgumentPin, *CallByteToIntFunction->FindPinChecked(TEXT("InByte"))); - - // Connect the int output pin to the argument value - CallByteToIntFunction->FindPinChecked(UEdGraphSchema_K2::PN_ReturnValue)->MakeLinkTo(MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValueInt))); - } - else if (ArgumentPinCategory == UEdGraphSchema_K2::PC_Byte || ArgumentPinCategory == UEdGraphSchema_K2::PC_Enum) - { - static UEnum* TextGenderEnum = FindObjectChecked(nullptr, TEXT("/Script/Engine.ETextGender"), /*ExactClass*/true); - if (ArgumentPin->PinType.PinSubCategoryObject == TextGenderEnum) - { - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*ArgumentTypePin, TEXT("Gender")); - CompilerContext.MovePinLinksToIntermediate(*ArgumentPin, *MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValueGender))); - } - } - else if (ArgumentPinCategory == UEdGraphSchema_K2::PC_Boolean) - { - AddConversionNode(GET_MEMBER_NAME_CHECKED(UKismetTextLibrary, Conv_BoolToText), TEXT("InBool")); - } - else if (ArgumentPinCategory == UEdGraphSchema_K2::PC_Name) - { - AddConversionNode(GET_MEMBER_NAME_CHECKED(UKismetTextLibrary, Conv_NameToText), TEXT("InName")); - } - else if (ArgumentPinCategory == UEdGraphSchema_K2::PC_String) - { - AddConversionNode(GET_MEMBER_NAME_CHECKED(UKismetTextLibrary, Conv_StringToText), TEXT("InString")); - } - else if (ArgumentPinCategory == UEdGraphSchema_K2::PC_Object) - { - AddConversionNode(GET_MEMBER_NAME_CHECKED(UKismetTextLibrary, Conv_ObjectToText), TEXT("InObj")); - } - else - { - // Unexpected pin type! - CompilerContext.MessageLog.Error(*FText::Format(LOCTEXT("Error_UnexpectedPinType", "Pin '{0}' has an unexpected type: {1}"), FText::FromString(OriginalName), FText::FromName(ArgumentPinCategory)).ToString()); - } + CompilerContext.MessageLog.Error(TEXT("Cannot convert Pin to a Format Argument")); + continue; } - else + + // Add a node to call the converter. + UK2Node_CallFunction* ConvertNode = CompilerContext.SpawnIntermediateNode(this, SourceGraph); + ConvertNode->SetFromFunction(Converter); + ConvertNode->AllocateDefaultPins(); + CompilerContext.MessageLog.NotifyIntermediateObjectCreation(ConvertNode, this); + UEdGraphPin *ValuePin = ConvertNode->FindPin(TEXT("Value")); + UEdGraphPin *NamePin = ConvertNode->FindPinChecked(TEXT("Name")); + + // Set a value for the 'Name' pin of the converter. + ConvertNode->GetSchema()->TrySetDefaultValue(*NamePin, OriginalName); + + // Connect the Value pin of the converter. + if (ValuePin != nullptr) { - // No connected pin - just default to an empty text - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*ArgumentTypePin, TEXT("Text")); - MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultText(*MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValue)), FText::GetEmpty()); + CompilerContext.MovePinLinksToIntermediate(*ArgumentPin, *ValuePin); } // The "Make Array" node already has one pin available, so don't create one for ArgIdx == 0 @@ -477,7 +393,7 @@ void UK2Node_FormatError::ExpandNode(class FKismetCompilerContext& CompilerConte UEdGraphPin* InputPin = MakeArrayNode->FindPinChecked(PinName); // Find the output for the pin's "Make Struct" node and link it to the corresponding pin on the "Make Array" node. - FindOutputStructPinChecked(MakeFormatArgumentDataStruct)->MakeLinkTo(InputPin); + ConvertNode->GetReturnValuePin()->MakeLinkTo(InputPin); } // Move connection of "Format" pin to the call function's "InPattern" pin @@ -553,26 +469,10 @@ bool UK2Node_FormatError::IsConnectionDisallowed(const UEdGraphPin* MyPin, const const UEdGraphSchema_K2* K2Schema = Cast(GetSchema()); const FName& OtherPinCategory = OtherPin->PinType.PinCategory; - bool bIsValidType = false; - if (OtherPinCategory == UEdGraphSchema_K2::PC_Int || OtherPinCategory == UEdGraphSchema_K2::PC_Real || OtherPinCategory == UEdGraphSchema_K2::PC_Text || - (OtherPinCategory == UEdGraphSchema_K2::PC_Byte && !OtherPin->PinType.PinSubCategoryObject.IsValid()) || - OtherPinCategory == UEdGraphSchema_K2::PC_Boolean || OtherPinCategory == UEdGraphSchema_K2::PC_String || OtherPinCategory == UEdGraphSchema_K2::PC_Name || OtherPinCategory == UEdGraphSchema_K2::PC_Object || - OtherPinCategory == UEdGraphSchema_K2::PC_Wildcard || OtherPinCategory == UEdGraphSchema_K2::PC_Int64) - { - bIsValidType = true; - } - else if (OtherPinCategory == UEdGraphSchema_K2::PC_Byte || OtherPinCategory == UEdGraphSchema_K2::PC_Enum) + UFunction *Converter = ToFormatArgumentData(K2Schema, OtherPin->PinType, false); + if (Converter == nullptr) { - static UEnum* TextGenderEnum = FindObjectChecked(nullptr, TEXT("/Script/Engine.ETextGender"), /*ExactClass*/true); - if (OtherPin->PinType.PinSubCategoryObject == TextGenderEnum) - { - bIsValidType = true; - } - } - - if (!bIsValidType) - { - OutReason = LOCTEXT("Error_InvalidArgumentType", "Format arguments may only be Byte, Integer, Int64, Float, Double, Text, String, Name, Boolean, Object, Wildcard or ETextGender.").ToString(); + OutReason = LOCTEXT("Error_InvalidArgumentType", "Data cannot be converted to text.").ToString(); return true; } }