Worked on the code for Format Error Message, better design overall.
This commit is contained in:
BIN
Content/Luprex/lxGameMode.uasset
LFS
BIN
Content/Luprex/lxGameMode.uasset
LFS
Binary file not shown.
@@ -3,7 +3,6 @@
|
|||||||
#include "Internationalization/TextFormatter.h"
|
#include "Internationalization/TextFormatter.h"
|
||||||
#include "Kismet/KismetSystemLibrary.h"
|
#include "Kismet/KismetSystemLibrary.h"
|
||||||
#include "Kismet2/KismetDebugUtilities.h"
|
#include "Kismet2/KismetDebugUtilities.h"
|
||||||
|
|
||||||
#include "Kismet/KismetTextLibrary.h"
|
#include "Kismet/KismetTextLibrary.h"
|
||||||
|
|
||||||
ELogVerbosity::Type UlxBlueprintErrorLibrary::ConvertElxLogVerbosity(ElxLogVerbosity Verbosity) {
|
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)
|
FlxDebugBlueprintErrorsOutputDevice::FlxDebugBlueprintErrorsOutputDevice(const ElxLogVerbosity &SensitivityRef)
|
||||||
: Sensitivity(SensitivityRef)
|
: Sensitivity(SensitivityRef)
|
||||||
|
|||||||
@@ -149,6 +149,62 @@ public:
|
|||||||
static ELogVerbosity::Type ConvertElxLogVerbosity(ElxLogVerbosity Verbosity);
|
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.
|
/* Debug Blueprint Errors output device.
|
||||||
*
|
*
|
||||||
* When an error message gets written to the log, using "Format Error Message,"
|
* When an error message gets written to the log, using "Format Error Message,"
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ UK2Node_FormatError::UK2Node_FormatError(const FObjectInitializer& ObjectInitial
|
|||||||
"Output an error, warning, or informational message to the log file.\n"
|
"Output an error, warning, or informational message to the log file.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" \u2022 Use {ArgName} to denote format arguments, giving each argument a different ArgName.\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"
|
"\n"
|
||||||
"It is often desirable to use this in conjunction with a separate utility that\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."
|
"pauses the execution of the blueprint whenever an error is logged."
|
||||||
@@ -267,22 +266,6 @@ FText UK2Node_FormatError::GetTooltipText() const
|
|||||||
return NodeTooltip;
|
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()
|
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<UFunction>(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)
|
void UK2Node_FormatError::ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph)
|
||||||
{
|
{
|
||||||
Super::ExpandNode(CompilerContext, SourceGraph);
|
Super::ExpandNode(CompilerContext, SourceGraph);
|
||||||
@@ -334,136 +356,30 @@ void UK2Node_FormatError::ExpandNode(class FKismetCompilerContext& CompilerConte
|
|||||||
FString OriginalName = PinNames[ArgIdx];
|
FString OriginalName = PinNames[ArgIdx];
|
||||||
UEdGraphPin* ArgumentPin = FindPin(ArgumentNameAddPrefix(OriginalName), EGPD_Input);
|
UEdGraphPin* ArgumentPin = FindPin(ArgumentNameAddPrefix(OriginalName), EGPD_Input);
|
||||||
|
|
||||||
static UScriptStruct* FormatArgumentDataStruct = FindObjectChecked<UScriptStruct>(FindObjectChecked<UPackage>(nullptr, TEXT("/Script/Engine")), TEXT("FormatArgumentData"));
|
|
||||||
|
|
||||||
// Spawn a "Make Struct" node to create the struct needed for formatting the text.
|
// Find a function that can convert the input into an FFormatArgumentData.
|
||||||
UK2Node_MakeStruct* MakeFormatArgumentDataStruct = CompilerContext.SpawnIntermediateNode<UK2Node_MakeStruct>(this, SourceGraph);
|
UFunction *Converter = ToFormatArgumentData(Schema, ArgumentPin->PinType, true);
|
||||||
MakeFormatArgumentDataStruct->StructType = FormatArgumentDataStruct;
|
if (Converter == nullptr)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
const FName& ArgumentPinCategory = ArgumentPin->PinType.PinCategory;
|
CompilerContext.MessageLog.Error(TEXT("Cannot convert Pin to a Format Argument"));
|
||||||
|
continue;
|
||||||
// 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<UK2Node_CallFunction>(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<UK2Node_CallFunction>(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<UK2Node_CallFunction>(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<UEnum>(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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Add a node to call the converter.
|
||||||
|
UK2Node_CallFunction* ConvertNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(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
|
CompilerContext.MovePinLinksToIntermediate(*ArgumentPin, *ValuePin);
|
||||||
MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultValue(*ArgumentTypePin, TEXT("Text"));
|
|
||||||
MakeFormatArgumentDataStruct->GetSchema()->TrySetDefaultText(*MakeFormatArgumentDataStruct->FindPinChecked(GET_MEMBER_NAME_STRING_CHECKED(FFormatArgumentData, ArgumentValue)), FText::GetEmpty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The "Make Array" node already has one pin available, so don't create one for ArgIdx == 0
|
// 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);
|
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.
|
// 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
|
// 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<const UEdGraphSchema_K2>(GetSchema());
|
const UEdGraphSchema_K2* K2Schema = Cast<const UEdGraphSchema_K2>(GetSchema());
|
||||||
const FName& OtherPinCategory = OtherPin->PinType.PinCategory;
|
const FName& OtherPinCategory = OtherPin->PinType.PinCategory;
|
||||||
|
|
||||||
bool bIsValidType = false;
|
UFunction *Converter = ToFormatArgumentData(K2Schema, OtherPin->PinType, false);
|
||||||
if (OtherPinCategory == UEdGraphSchema_K2::PC_Int || OtherPinCategory == UEdGraphSchema_K2::PC_Real || OtherPinCategory == UEdGraphSchema_K2::PC_Text ||
|
if (Converter == nullptr)
|
||||||
(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)
|
|
||||||
{
|
{
|
||||||
static UEnum* TextGenderEnum = FindObjectChecked<UEnum>(nullptr, TEXT("/Script/Engine.ETextGender"), /*ExactClass*/true);
|
OutReason = LOCTEXT("Error_InvalidArgumentType", "Data cannot be converted to text.").ToString();
|
||||||
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();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user