Renamed RaiseError to FormatErrorMessage
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
|
||||
#include "K2Node_RaiseError.h"
|
||||
#include "FormatError.h"
|
||||
|
||||
#include "BlueprintActionDatabaseRegistrar.h"
|
||||
#include "BlueprintNodeSpawner.h"
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "Engine/Blueprint.h"
|
||||
#include "HAL/PlatformCrt.h"
|
||||
#include "Internationalization/Internationalization.h"
|
||||
#include "Internationalization/TextFormatter.h"
|
||||
#include "K2Node_CallFunction.h"
|
||||
#include "K2Node_MakeArray.h"
|
||||
#include "K2Node_MakeStruct.h"
|
||||
@@ -38,7 +39,7 @@
|
||||
#include "UObject/WeakObjectPtr.h"
|
||||
#include "UObject/WeakObjectPtrTemplates.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "K2Node_RaiseError"
|
||||
#define LOCTEXT_NAMESPACE "FormatError"
|
||||
|
||||
// All argument pins will have Names that start with "A:"
|
||||
|
||||
@@ -62,19 +63,19 @@ static bool IsFormatPin(const UEdGraphPin *Pin) {
|
||||
return (Pin->PinName == FormatPinName);
|
||||
}
|
||||
|
||||
UK2Node_RaiseError::UK2Node_RaiseError(const FObjectInitializer& ObjectInitializer)
|
||||
UK2Node_FormatError::UK2Node_FormatError(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
NodeTooltip = LOCTEXT("NodeTooltip", "Builds a formatted string using available format argument values.\n \u2022 Use {} to denote format arguments.\n \u2022 Argument types may be Byte, Integer, Float, Text, String, Name, Boolean, Object or ETextGender.");
|
||||
}
|
||||
|
||||
void UK2Node_RaiseError::AllocateDefaultPins()
|
||||
void UK2Node_FormatError::AllocateDefaultPins()
|
||||
{
|
||||
Super::AllocateDefaultPins();
|
||||
CreateCorrectPins();
|
||||
}
|
||||
|
||||
void UK2Node_RaiseError::CreateCorrectPins()
|
||||
void UK2Node_FormatError::CreateCorrectPins()
|
||||
{
|
||||
if (FindPin(UEdGraphSchema_K2::PN_Execute) == nullptr) {
|
||||
UEdGraphPin *P = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Exec, UEdGraphSchema_K2::PN_Execute);
|
||||
@@ -123,7 +124,7 @@ void UK2Node_RaiseError::CreateCorrectPins()
|
||||
}
|
||||
|
||||
|
||||
void UK2Node_RaiseError::SynchronizeArgumentPinType(UEdGraphPin* Pin)
|
||||
void UK2Node_FormatError::SynchronizeArgumentPinType(UEdGraphPin* Pin)
|
||||
{
|
||||
if (IsArgumentPin(Pin))
|
||||
{
|
||||
@@ -167,12 +168,12 @@ void UK2Node_RaiseError::SynchronizeArgumentPinType(UEdGraphPin* Pin)
|
||||
}
|
||||
}
|
||||
|
||||
FText UK2Node_RaiseError::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
||||
FText UK2Node_FormatError::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
||||
{
|
||||
return LOCTEXT("RaiseError_Title", "Raise Error");
|
||||
return LOCTEXT("FormatError_Title", "Format Error Message");
|
||||
}
|
||||
|
||||
FText UK2Node_RaiseError::GetPinDisplayName(const UEdGraphPin* Pin) const
|
||||
FText UK2Node_FormatError::GetPinDisplayName(const UEdGraphPin* Pin) const
|
||||
{
|
||||
// These pins should be unlabeled.
|
||||
if ((Pin->PinType.PinCategory == UEdGraphSchema_K2::PC_Exec) || (IsFormatPin(Pin))) {
|
||||
@@ -188,10 +189,10 @@ FText UK2Node_RaiseError::GetPinDisplayName(const UEdGraphPin* Pin) const
|
||||
return FText::FromName(Pin->PinName);
|
||||
}
|
||||
|
||||
void UK2Node_RaiseError::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
|
||||
void UK2Node_FormatError::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
|
||||
{
|
||||
const FName PropertyName = (PropertyChangedEvent.Property ? PropertyChangedEvent.Property->GetFName() : NAME_None);
|
||||
if (PropertyName == GET_MEMBER_NAME_CHECKED(UK2Node_RaiseError, PinNames))
|
||||
if (PropertyName == GET_MEMBER_NAME_CHECKED(UK2Node_FormatError, PinNames))
|
||||
{
|
||||
ReconstructNode();
|
||||
}
|
||||
@@ -199,13 +200,13 @@ void UK2Node_RaiseError::PostEditChangeProperty(struct FPropertyChangedEvent& Pr
|
||||
GetGraph()->NotifyNodeChanged(this);
|
||||
}
|
||||
|
||||
void UK2Node_RaiseError::PinConnectionListChanged(UEdGraphPin* Pin)
|
||||
void UK2Node_FormatError::PinConnectionListChanged(UEdGraphPin* Pin)
|
||||
{
|
||||
Modify();
|
||||
SynchronizeArgumentPinType(Pin);
|
||||
}
|
||||
|
||||
void UK2Node_RaiseError::PinDefaultValueChanged(UEdGraphPin* Pin)
|
||||
void UK2Node_FormatError::PinDefaultValueChanged(UEdGraphPin* Pin)
|
||||
{
|
||||
if(IsFormatPin(Pin))
|
||||
{
|
||||
@@ -216,13 +217,13 @@ void UK2Node_RaiseError::PinDefaultValueChanged(UEdGraphPin* Pin)
|
||||
}
|
||||
}
|
||||
|
||||
void UK2Node_RaiseError::PinTypeChanged(UEdGraphPin* Pin)
|
||||
void UK2Node_FormatError::PinTypeChanged(UEdGraphPin* Pin)
|
||||
{
|
||||
SynchronizeArgumentPinType(Pin);
|
||||
Super::PinTypeChanged(Pin);
|
||||
}
|
||||
|
||||
FText UK2Node_RaiseError::GetTooltipText() const
|
||||
FText UK2Node_FormatError::GetTooltipText() const
|
||||
{
|
||||
return NodeTooltip;
|
||||
}
|
||||
@@ -244,7 +245,7 @@ UEdGraphPin* FindOutputStructPinChecked(UEdGraphNode* Node)
|
||||
return OutputPin;
|
||||
}
|
||||
|
||||
void UK2Node_RaiseError::PostReconstructNode()
|
||||
void UK2Node_FormatError::PostReconstructNode()
|
||||
{
|
||||
Super::PostReconstructNode();
|
||||
|
||||
@@ -258,12 +259,12 @@ void UK2Node_RaiseError::PostReconstructNode()
|
||||
}
|
||||
}
|
||||
|
||||
void UK2Node_RaiseError::ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph)
|
||||
void UK2Node_FormatError::ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph)
|
||||
{
|
||||
Super::ExpandNode(CompilerContext, SourceGraph);
|
||||
|
||||
/**
|
||||
At the end of this, the UK2Node_RaiseError will not be a part of the Blueprint, it merely handles connecting
|
||||
At the end of this, the UK2Node_FormatError will not be a part of the Blueprint, it merely handles connecting
|
||||
the other nodes into the Blueprint.
|
||||
*/
|
||||
|
||||
@@ -274,18 +275,13 @@ void UK2Node_RaiseError::ExpandNode(class FKismetCompilerContext& CompilerContex
|
||||
MakeArrayNode->AllocateDefaultPins();
|
||||
CompilerContext.MessageLog.NotifyIntermediateObjectCreation(MakeArrayNode, this);
|
||||
|
||||
// This is the node that does all the Format work.
|
||||
// This is the node that does all the Format work and outputs the message.
|
||||
UK2Node_CallFunction* CallFormatFunction = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this, SourceGraph);
|
||||
CallFormatFunction->SetFromFunction(UKismetTextLibrary::StaticClass()->FindFunctionByName(GET_MEMBER_NAME_CHECKED(UKismetTextLibrary, Format)));
|
||||
UFunction *FormatFunction = UlxFormatErrorLibrary::StaticClass()->FindFunctionByName(GET_MEMBER_NAME_CHECKED(UlxFormatErrorLibrary, FormatErrorInternal));
|
||||
CallFormatFunction->SetFromFunction(FormatFunction);
|
||||
CallFormatFunction->AllocateDefaultPins();
|
||||
CompilerContext.MessageLog.NotifyIntermediateObjectCreation(CallFormatFunction, this);
|
||||
|
||||
// This is the node that outputs the text.
|
||||
UK2Node_CallFunction* CallPrintFunction = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this, SourceGraph);
|
||||
CallPrintFunction->SetFromFunction(UKismetSystemLibrary::StaticClass()->FindFunctionByName(GET_MEMBER_NAME_CHECKED(UKismetSystemLibrary, PrintText)));
|
||||
CallPrintFunction->AllocateDefaultPins();
|
||||
CompilerContext.MessageLog.NotifyIntermediateObjectCreation(CallPrintFunction, this);
|
||||
|
||||
// Connect the output of the "Make Array" pin to the function's "InArgs" pin
|
||||
UEdGraphPin* ArrayOut = MakeArrayNode->GetOutputPin();
|
||||
ArrayOut->MakeLinkTo(CallFormatFunction->FindPinChecked(TEXT("InArgs")));
|
||||
@@ -293,14 +289,6 @@ void UK2Node_RaiseError::ExpandNode(class FKismetCompilerContext& CompilerContex
|
||||
// This will set the "Make Array" node's type, only works if one pin is connected.
|
||||
MakeArrayNode->PinConnectionListChanged(ArrayOut);
|
||||
|
||||
// Connect the output of the "Format" node to the PrintText function's "InText" pin
|
||||
UEdGraphPin* FormatOut = CallFormatFunction->GetReturnValuePin();
|
||||
FormatOut->MakeLinkTo(CallPrintFunction->FindPinChecked(TEXT("InText")));
|
||||
|
||||
// Configure the Print function to keep the text onscreen for 30 seconds.
|
||||
UEdGraphPin* DurationIn = CallPrintFunction->FindPinChecked(TEXT("Duration"));
|
||||
CallPrintFunction->GetSchema()->TrySetDefaultValue(*DurationIn, "30");
|
||||
|
||||
// For each argument, we will need to add in a "Make Struct" node.
|
||||
for(int32 ArgIdx = 0; ArgIdx < PinNames.Num(); ++ArgIdx)
|
||||
{
|
||||
@@ -453,18 +441,18 @@ void UK2Node_RaiseError::ExpandNode(class FKismetCompilerContext& CompilerContex
|
||||
FindOutputStructPinChecked(MakeFormatArgumentDataStruct)->MakeLinkTo(InputPin);
|
||||
}
|
||||
|
||||
// Move connection of RaiseError's "Format" pin to the call function's "InPattern" pin
|
||||
// Move connection of "Format" pin to the call function's "InPattern" pin
|
||||
CompilerContext.MovePinLinksToIntermediate(*FindPinChecked(FormatPinName), *CallFormatFunction->FindPinChecked(TEXT("InPattern")));
|
||||
|
||||
// Link up the Exec pins.
|
||||
CompilerContext.MovePinLinksToIntermediate(*GetExecPin(), *CallPrintFunction->GetExecPin());
|
||||
CompilerContext.MovePinLinksToIntermediate(*GetThenPin(), *CallPrintFunction->GetThenPin());
|
||||
CompilerContext.MovePinLinksToIntermediate(*GetExecPin(), *CallFormatFunction->GetExecPin());
|
||||
CompilerContext.MovePinLinksToIntermediate(*GetThenPin(), *CallFormatFunction->GetThenPin());
|
||||
|
||||
BreakAllNodeLinks();
|
||||
}
|
||||
|
||||
|
||||
UK2Node::ERedirectType UK2Node_RaiseError::DoPinsMatchForReconstruction(const UEdGraphPin* NewPin, int32 NewPinIndex, const UEdGraphPin* OldPin, int32 OldPinIndex) const
|
||||
UK2Node::ERedirectType UK2Node_FormatError::DoPinsMatchForReconstruction(const UEdGraphPin* NewPin, int32 NewPinIndex, const UEdGraphPin* OldPin, int32 OldPinIndex) const
|
||||
{
|
||||
ERedirectType RedirectType = ERedirectType_None;
|
||||
|
||||
@@ -509,7 +497,7 @@ UK2Node::ERedirectType UK2Node_RaiseError::DoPinsMatchForReconstruction(const UE
|
||||
return RedirectType;
|
||||
}
|
||||
|
||||
bool UK2Node_RaiseError::IsConnectionDisallowed(const UEdGraphPin* MyPin, const UEdGraphPin* OtherPin, FString& OutReason) const
|
||||
bool UK2Node_FormatError::IsConnectionDisallowed(const UEdGraphPin* MyPin, const UEdGraphPin* OtherPin, FString& OutReason) const
|
||||
{
|
||||
// The format pin cannot be connected to anything. It must be a constant string.
|
||||
if (IsFormatPin(MyPin))
|
||||
@@ -552,7 +540,7 @@ bool UK2Node_RaiseError::IsConnectionDisallowed(const UEdGraphPin* MyPin, const
|
||||
}
|
||||
|
||||
|
||||
void UK2Node_RaiseError::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
|
||||
void UK2Node_FormatError::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
|
||||
{
|
||||
// actions get registered under specific object-keys; the idea is that
|
||||
// actions might have to be updated (or deleted) if their object-key is
|
||||
@@ -572,9 +560,15 @@ void UK2Node_RaiseError::GetMenuActions(FBlueprintActionDatabaseRegistrar& Actio
|
||||
}
|
||||
}
|
||||
|
||||
FText UK2Node_RaiseError::GetMenuCategory() const
|
||||
FText UK2Node_FormatError::GetMenuCategory() const
|
||||
{
|
||||
return FEditorCategoryUtils::GetCommonCategory(FCommonEditorCategory::Text);
|
||||
}
|
||||
|
||||
void UlxFormatErrorLibrary::FormatErrorInternal(FText InPattern, TArray<FFormatArgumentData> InArgs)
|
||||
{
|
||||
FText Message = FTextFormatter::Format(MoveTemp(InPattern), MoveTemp(InArgs), false, false);
|
||||
UKismetSystemLibrary::PrintString(NULL, Message.ToString(), true, true, FLinearColor(0.0, 0.66, 1.0), 30.0, NAME_None);
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "UObject/UObjectGlobals.h"
|
||||
|
||||
#include "K2Node_RaiseError.generated.h"
|
||||
#include "FormatError.generated.h"
|
||||
|
||||
class FBlueprintActionDatabaseRegistrar;
|
||||
class FString;
|
||||
@@ -21,7 +21,17 @@ class UEdGraph;
|
||||
class UObject;
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UK2Node_RaiseError : public UK2Node
|
||||
class UlxFormatErrorLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true"))
|
||||
static void FormatErrorInternal(FText InPattern, TArray<FFormatArgumentData> InArgs);
|
||||
};
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UK2Node_FormatError : public UK2Node
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
Reference in New Issue
Block a user