Massive refactoring in FormatMessage and LuaCallNode

This commit is contained in:
2026-03-04 06:47:37 -05:00
parent 6428194393
commit cb6f9ebe1d
7 changed files with 318 additions and 467 deletions

View File

@@ -19,52 +19,6 @@
#include "FormatMessage.generated.h"
////////////////////////////////////////////////////////////
//
// ElxFormatLogVerbosity
//
// Controls the ELogVerbosity of the UE_LOG directive inside
// FormatLogMessage. Also controls the throttling of log
// messages.
//
// Fatal is deliberately placed at the end so that the
// editor defaults to Error (value 0) when the dropdown is
// uninitialized. The numeric values don't match
// ELogVerbosity, so a conversion function is needed.
//
////////////////////////////////////////////////////////////
UENUM(BlueprintType)
enum class ElxFormatLogVerbosity : uint8 {
/** Prints an error to the console and log file. The editor collects and reports errors. */
Error,
/** Prints a warning to the console and log file. The editor collects and reports warnings. */
Warning,
/** Prints a message to the console and log file. */
Display,
/** Prints a message to the log file, but not to the console. */
Log,
/** Like Display, but suppresses repeated messages with the same format pattern (at most once per second). */
ThrottledDisplay,
/** Like Log, but suppresses repeated messages with the same format pattern (at most once per second). */
ThrottledLog,
/** Prints a message to the log file only if Verbose logging is enabled for the given category. */
Verbose,
/** Prints a message to the log file only if VeryVerbose logging is enabled. */
VeryVerbose,
/** Prints a fatal error to the console and log file, then crashes (this crashes the editor too). */
Fatal,
};
class FBlueprintActionDatabaseRegistrar;
class FString;
class UEdGraph;
@@ -79,25 +33,22 @@ class UObject;
UCLASS(MinimalAPI)
class UK2Node_FormatMessage : public UlxK2Node
{
GENERATED_UCLASS_BODY()
//~ Begin UObject Interface
virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
//~ End UObject Interface
GENERATED_BODY()
public:
//~ Begin UEdGraphNode Interface.
virtual void AllocateDefaultPins() override;
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
virtual bool ShouldShowNodeProperties() const override { return true; }
virtual void PinConnectionListChanged(UEdGraphPin* Pin) override;
virtual void PinDefaultValueChanged(UEdGraphPin* Pin) override;
virtual void PinTypeChanged(UEdGraphPin* Pin) override;
virtual FText GetTooltipText() const override;
virtual FText GetPinDisplayName(const UEdGraphPin* Pin) const override;
//~ End UEdGraphNode Interface.
//~ Begin UK2Node Interface.
virtual bool IsNodePure() const override { return false; }
virtual void ReconstructNode() override;
virtual void PostReconstructNode() override;
virtual bool NodeCausesStructuralBlueprintChange() const override { return true; }
virtual void ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) override;
@@ -109,41 +60,38 @@ class UK2Node_FormatMessage : public UlxK2Node
//~ End UK2Node Interface.
protected:
// Create all necessary pins.
//
void CreateCorrectPins();
// Synchronize the type of the given argument pin
// with the type its connected to, or reset it to
// a wildcard pin if there's no connection.
//
void SynchronizeArgumentPinType(UEdGraphPin* Pin);
// During ExpandNode, expand a single argument pin into
// a converter node. Returns the converter's output pin.
//
UEdGraphPin* ExpandArgumentPin(UEdGraphPin* ArgumentPin, class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph);
// Derived class sets this to true, altering
// the behavior of this K2Node.
//
virtual bool IsFormatErrorMessage() const { return false; }
// When IsFormatErrorMessage is true, the K2Node
// macroexpands to call this function, which
// formats the message and outputs it to the log.
//
UFUNCTION(BlueprintCallable, meta=(WorldContext = "Context", BlueprintInternalUseOnly = "true"))
static void FormatLogMessageInternal(UObject *Context, ElxFormatLogVerbosity Verbosity, const FString &InPattern, TArray<FFormatArgumentData> InArgs);
private:
static ELogVerbosity::Type ConvertElxFormatLogVerbosity(ElxFormatLogVerbosity Verbosity);
static const FName VerbosityPinName;
static const FName FormatPinName;
static const FName ResultPinName;
protected:
// Argument names added to the node, generated as pins
// during construction.
// Whenever the format pin value changes, we call
// ReconstructNode, which backs up the value into this
// property. This cache is needed because during
// ReconstructNode, we blow away the format pin. The
// format pin is also absent when the node is first
// created.
//
UPROPERTY()
TArray<FString> PinNames;
FString FormatPattern = TEXT("Message");
// Tooltip text for this node.
//
FText NodeTooltip;
};
////////////////////////////////////////////////////////////
@@ -159,7 +107,7 @@ protected:
UCLASS(MinimalAPI)
class UK2Node_FormatLogMessage : public UK2Node_FormatMessage
{
GENERATED_UCLASS_BODY()
GENERATED_BODY()
virtual bool IsFormatErrorMessage() const override { return true; }
};