Lots more work on FormatErrorMessage
This commit is contained in:
@@ -58,6 +58,16 @@ static FString ArgumentNameRemovePrefix(const FName &name) {
|
||||
return name.ToString().Mid(2, FName::StringBufferSize);
|
||||
}
|
||||
|
||||
static const FName VerbosityPinName(TEXT("Verbosity"));
|
||||
static bool IsVerbosityPin(const UEdGraphPin *Pin) {
|
||||
return (Pin->PinName == VerbosityPinName);
|
||||
}
|
||||
|
||||
static const FName DisplayDurationPinName(TEXT("DisplayDuration"));
|
||||
static bool IsDisplayDurationPin(const UEdGraphPin *Pin) {
|
||||
return (Pin->PinName == DisplayDurationPinName);
|
||||
}
|
||||
|
||||
static const FName FormatPinName(TEXT("Format"));
|
||||
static bool IsFormatPin(const UEdGraphPin *Pin) {
|
||||
return (Pin->PinName == FormatPinName);
|
||||
@@ -78,15 +88,28 @@ void UK2Node_FormatError::AllocateDefaultPins()
|
||||
void UK2Node_FormatError::CreateCorrectPins()
|
||||
{
|
||||
if (FindPin(UEdGraphSchema_K2::PN_Execute) == nullptr) {
|
||||
UEdGraphPin *P = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Exec, UEdGraphSchema_K2::PN_Execute);
|
||||
CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Exec, UEdGraphSchema_K2::PN_Execute);
|
||||
}
|
||||
|
||||
if (FindPin(UEdGraphSchema_K2::PN_Then) == nullptr) {
|
||||
UEdGraphPin *P = CreatePin(EGPD_Output, UEdGraphSchema_K2::PC_Exec, UEdGraphSchema_K2::PN_Then);
|
||||
CreatePin(EGPD_Output, UEdGraphSchema_K2::PC_Exec, UEdGraphSchema_K2::PN_Then);
|
||||
}
|
||||
|
||||
if (FindPin(FormatPinName, EGPD_Input) == nullptr) {
|
||||
UEdGraphPin *P = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Text, FormatPinName);
|
||||
P->DefaultTextValue = LOCTEXT("FormatErrorMessage_DefaultMessage", "Error Message");
|
||||
}
|
||||
|
||||
if (FindPin(VerbosityPinName, EGPD_Input) == nullptr) {
|
||||
UEdGraphPin *P = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Byte, StaticEnum<ElxLogVerbosity>(), VerbosityPinName);
|
||||
P->DefaultValue = TEXT("Error");
|
||||
P->AutogeneratedDefaultValue = P->DefaultValue;
|
||||
}
|
||||
|
||||
if (FindPin(DisplayDurationPinName, EGPD_Input) == nullptr) {
|
||||
UEdGraphPin *P = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Byte, StaticEnum<ElxDisplayDuration>(), DisplayDurationPinName);
|
||||
P->DefaultValue = TEXT("No_Display");
|
||||
P->AutogeneratedDefaultValue = P->DefaultValue;
|
||||
}
|
||||
|
||||
// Transfer all Existing Argument pins to the Old Pins Map.
|
||||
@@ -110,7 +133,7 @@ void UK2Node_FormatError::CreateCorrectPins()
|
||||
OldPins.Remove(Name);
|
||||
} else {
|
||||
FName PrefixedName = ArgumentNameAddPrefix(Name);
|
||||
UEdGraphPin *P = CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Wildcard, PrefixedName);
|
||||
CreatePin(EGPD_Input, UEdGraphSchema_K2::PC_Wildcard, PrefixedName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,9 +198,15 @@ FText UK2Node_FormatError::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
||||
|
||||
FText UK2Node_FormatError::GetPinDisplayName(const UEdGraphPin* Pin) const
|
||||
{
|
||||
// These pins should be unlabeled.
|
||||
if ((Pin->PinType.PinCategory == UEdGraphSchema_K2::PC_Exec) || (IsFormatPin(Pin))) {
|
||||
return FText::GetEmpty();
|
||||
// Many pins can go unlabeled if they have default values.
|
||||
if ((Pin->PinType.PinCategory == UEdGraphSchema_K2::PC_Exec) ||
|
||||
IsFormatPin(Pin) || IsVerbosityPin(Pin) || IsDisplayDurationPin(Pin))
|
||||
{
|
||||
if (Pin->LinkedTo.Num() == 0) {
|
||||
return FText::GetEmpty();
|
||||
} else {
|
||||
return FText::FromName(Pin->PinName);
|
||||
}
|
||||
}
|
||||
|
||||
// For argument pins, we must strip off the Argument Pin Prefix.
|
||||
@@ -443,7 +472,9 @@ void UK2Node_FormatError::ExpandNode(class FKismetCompilerContext& CompilerConte
|
||||
|
||||
// Move connection of "Format" pin to the call function's "InPattern" pin
|
||||
CompilerContext.MovePinLinksToIntermediate(*FindPinChecked(FormatPinName), *CallFormatFunction->FindPinChecked(TEXT("InPattern")));
|
||||
|
||||
CompilerContext.MovePinLinksToIntermediate(*FindPinChecked(VerbosityPinName), *CallFormatFunction->FindPinChecked(TEXT("Verbosity")));
|
||||
CompilerContext.MovePinLinksToIntermediate(*FindPinChecked(DisplayDurationPinName), *CallFormatFunction->FindPinChecked(TEXT("DisplayDuration")));
|
||||
|
||||
// Link up the Exec pins.
|
||||
CompilerContext.MovePinLinksToIntermediate(*GetExecPin(), *CallFormatFunction->GetExecPin());
|
||||
CompilerContext.MovePinLinksToIntermediate(*GetThenPin(), *CallFormatFunction->GetThenPin());
|
||||
@@ -499,7 +530,7 @@ UK2Node::ERedirectType UK2Node_FormatError::DoPinsMatchForReconstruction(const U
|
||||
|
||||
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.
|
||||
// The following pins cannot be connected. They are meant to be hardwired constants.
|
||||
if (IsFormatPin(MyPin))
|
||||
{
|
||||
OutReason = LOCTEXT("Error_FormatStringMustBeHardwired", "Format string must be a hardwired constant.").ToString();
|
||||
@@ -565,10 +596,41 @@ FText UK2Node_FormatError::GetMenuCategory() const
|
||||
return FEditorCategoryUtils::GetCommonCategory(FCommonEditorCategory::Text);
|
||||
}
|
||||
|
||||
void UlxFormatErrorLibrary::FormatErrorInternal(FText InPattern, TArray<FFormatArgumentData> InArgs)
|
||||
void UlxFormatErrorLibrary::FormatErrorInternal(ElxLogVerbosity Verbosity, ElxDisplayDuration DisplayDuration, FText InPattern, TArray<FFormatArgumentData> InArgs)
|
||||
{
|
||||
// Generate the formatted string.
|
||||
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);
|
||||
FString MessageString = Message.ToString();
|
||||
|
||||
// Convert the DisplayDuration enum into a number of seconds.
|
||||
int Seconds = int(DisplayDuration);
|
||||
if (Seconds > 100) Seconds = (Seconds - 100) * 60;
|
||||
|
||||
// Choose a color appropriate to the verbosity level.
|
||||
FLinearColor Color;
|
||||
switch (Verbosity) {
|
||||
case ElxLogVerbosity::Fatal : Color = FLinearColor(1.0, 0.6, 0.6); break;
|
||||
case ElxLogVerbosity::Error : Color = FLinearColor(1.0, 0.6, 0.6); break;
|
||||
case ElxLogVerbosity::Warning : Color = FLinearColor(0.9, 0.9, 0.6); break;
|
||||
default: Color = FLinearColor(0.8, 0.8, 0.8); break;
|
||||
}
|
||||
|
||||
// Output to Log
|
||||
switch (Verbosity) {
|
||||
case ElxLogVerbosity::Fatal: UE_LOG(LogBlueprint, Fatal, TEXT("%s"), *MessageString); break;
|
||||
case ElxLogVerbosity::Error: UE_LOG(LogBlueprint, Error, TEXT("%s"), *MessageString); break;
|
||||
case ElxLogVerbosity::Warning: UE_LOG(LogBlueprint, Warning, TEXT("%s"), *MessageString); break;
|
||||
case ElxLogVerbosity::Display: UE_LOG(LogBlueprint, Display, TEXT("%s"), *MessageString); break;
|
||||
case ElxLogVerbosity::Log: UE_LOG(LogBlueprint, Log, TEXT("%s"), *MessageString); break;
|
||||
case ElxLogVerbosity::Verbose: UE_LOG(LogBlueprint, Verbose, TEXT("%s"), *MessageString); break;
|
||||
case ElxLogVerbosity::VeryVerbose: UE_LOG(LogBlueprint, VeryVerbose, TEXT("%s"), *MessageString); break;
|
||||
}
|
||||
|
||||
// Output to Screen (Maybe)
|
||||
if (Seconds != 0) {
|
||||
UKismetSystemLibrary::PrintText(NULL, Message, true, false, Color, Seconds, NAME_None);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
Reference in New Issue
Block a user