diff --git a/Content/Tangibles/tangiblecharacter.uasset b/Content/Tangibles/tangiblecharacter.uasset index ca76ff05..a5e04f15 100644 --- a/Content/Tangibles/tangiblecharacter.uasset +++ b/Content/Tangibles/tangiblecharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:194d5501fcb3c950dcdf1f0b80bbd664090f71d7c20dc423b51d0be004d76402 -size 375711 +oid sha256:d007d75d8a5cbe759673a17a353f2fb5fd4f7892256aedcea40f84f8aaf91f45 +size 377808 diff --git a/Source/Integration/FormatError.cpp b/Source/Integration/FormatError.cpp index ed59e121..d8baac87 100644 --- a/Source/Integration/FormatError.cpp +++ b/Source/Integration/FormatError.cpp @@ -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(), 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(), 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 InArgs) +void UlxFormatErrorLibrary::FormatErrorInternal(ElxLogVerbosity Verbosity, ElxDisplayDuration DisplayDuration, FText InPattern, TArray 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 diff --git a/Source/Integration/FormatError.h b/Source/Integration/FormatError.h index e9a4476b..8cfa1647 100644 --- a/Source/Integration/FormatError.h +++ b/Source/Integration/FormatError.h @@ -20,6 +20,51 @@ class FString; class UEdGraph; class UObject; + +// +// Export log verbosity to blueprints. +// +UENUM(BlueprintType) +enum class ElxLogVerbosity : uint8 { + Fatal, + Error, + Warning, + Display, + Log, + Verbose, + VeryVerbose, +}; + +// +// Display Duration - how long to show a message on-screen. +// +UENUM(BlueprintType) +enum class ElxDisplayDuration : uint8 { + No_Display = 0, + Display_1_Seconds = 1, + Display_2_Seconds = 2, + Display_3_Seconds = 3, + Display_4_Seconds = 4, + Display_5_Seconds = 5, + Display_10_Seconds = 10, + Display_20_Seconds = 20, + Display_30_Seconds = 30, + Display_40_Seconds = 40, + Display_50_Seconds = 50, + Display_60_Seconds = 60, + Display_70_Seconds = 70, + Display_80_Seconds = 80, + Display_90_Seconds = 90, + Display_1_Minute = 101, + Display_2_Minutes = 102, + Display_3_Minutes = 103, + Display_4_Minutes = 104, + Display_5_Minutes = 105, +}; + +// +// Library functions used by Format Error Message. +// UCLASS(MinimalAPI) class UlxFormatErrorLibrary : public UBlueprintFunctionLibrary { @@ -27,9 +72,13 @@ class UlxFormatErrorLibrary : public UBlueprintFunctionLibrary public: UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true")) - static void FormatErrorInternal(FText InPattern, TArray InArgs); + static void FormatErrorInternal(ElxLogVerbosity Verbosity, ElxDisplayDuration DisplayDuration, FText InPattern, TArray InArgs); }; +// +// Library functions used by Format Error Message, and also +// by scripters writing their own Error Message Handler classes. +// UCLASS(MinimalAPI) class UK2Node_FormatError : public UK2Node {