2026-02-14 02:14:19 -05:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// FormatMessage.h
|
|
|
|
|
//
|
|
|
|
|
// Two K2Nodes: FormatMessage and FormatLogMessage.
|
|
|
|
|
// FormatMessage outputs a formatted string as a pin.
|
|
|
|
|
// FormatLogMessage outputs it to the log instead.
|
|
|
|
|
//
|
|
|
|
|
// FormatLogMessage is a derived class that just sets
|
|
|
|
|
// a flag to alter the base class behavior.
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////
|
2024-10-28 17:40:29 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2026-02-14 01:25:04 -05:00
|
|
|
#include "BreakToDebugger.h"
|
2026-02-13 23:24:18 -05:00
|
|
|
#include "FormatDataLibrary.h"
|
2026-03-04 03:00:44 -05:00
|
|
|
#include "LuprexK2Node.h"
|
2024-10-28 17:40:29 -04:00
|
|
|
|
2026-02-13 23:24:18 -05:00
|
|
|
#include "FormatMessage.generated.h"
|
2024-10-28 17:40:29 -04:00
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// 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.
|
|
|
|
|
//
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
2026-02-14 01:25:04 -05:00
|
|
|
UENUM(BlueprintType)
|
|
|
|
|
enum class ElxFormatLogVerbosity : uint8 {
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
/** Prints an error to the console and log file. The editor collects and reports errors. */
|
2026-02-14 01:25:04 -05:00
|
|
|
Error,
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
/** Prints a warning to the console and log file. The editor collects and reports warnings. */
|
2026-02-14 01:25:04 -05:00
|
|
|
Warning,
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
/** Prints a message to the console and log file. */
|
2026-02-14 01:25:04 -05:00
|
|
|
Display,
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
/** Prints a message to the log file, but not to the console. */
|
2026-02-14 01:25:04 -05:00
|
|
|
Log,
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
/** Like Display, but suppresses repeated messages with the same format pattern (at most once per second). */
|
2026-02-14 01:25:04 -05:00
|
|
|
ThrottledDisplay,
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
/** Like Log, but suppresses repeated messages with the same format pattern (at most once per second). */
|
2026-02-14 01:25:04 -05:00
|
|
|
ThrottledLog,
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
/** Prints a message to the log file only if Verbose logging is enabled for the given category. */
|
2026-02-14 01:25:04 -05:00
|
|
|
Verbose,
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
/** Prints a message to the log file only if VeryVerbose logging is enabled. */
|
2026-02-14 01:25:04 -05:00
|
|
|
VeryVerbose,
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
/** Prints a fatal error to the console and log file, then crashes (this crashes the editor too). */
|
2026-02-14 01:25:04 -05:00
|
|
|
Fatal,
|
|
|
|
|
};
|
|
|
|
|
|
2024-10-28 17:40:29 -04:00
|
|
|
class FBlueprintActionDatabaseRegistrar;
|
|
|
|
|
class FString;
|
|
|
|
|
class UEdGraph;
|
|
|
|
|
class UObject;
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
////////////////////////////////////////////////////////////
|
2024-11-14 23:57:04 -05:00
|
|
|
//
|
2026-02-14 02:14:19 -05:00
|
|
|
// UK2Node_FormatMessage
|
2024-11-14 23:57:04 -05:00
|
|
|
//
|
2026-02-14 02:14:19 -05:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
2024-11-13 19:44:27 -05:00
|
|
|
UCLASS(MinimalAPI)
|
2026-03-04 03:00:44 -05:00
|
|
|
class UK2Node_FormatMessage : public UlxK2Node
|
2024-10-28 17:40:29 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_UCLASS_BODY()
|
|
|
|
|
|
|
|
|
|
//~ Begin UObject Interface
|
|
|
|
|
virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
|
|
|
|
|
//~ End UObject Interface
|
|
|
|
|
|
|
|
|
|
//~ 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.
|
2024-11-13 18:18:32 -05:00
|
|
|
virtual bool IsNodePure() const override { return false; }
|
2024-10-28 17:40:29 -04:00
|
|
|
virtual void PostReconstructNode() override;
|
|
|
|
|
virtual bool NodeCausesStructuralBlueprintChange() const override { return true; }
|
|
|
|
|
virtual void ExpandNode(class FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) override;
|
|
|
|
|
virtual ERedirectType DoPinsMatchForReconstruction(const UEdGraphPin* NewPin, int32 NewPinIndex, const UEdGraphPin* OldPin, int32 OldPinIndex) const override;
|
|
|
|
|
virtual bool IsConnectionDisallowed(const UEdGraphPin* MyPin, const UEdGraphPin* OtherPin, FString& OutReason) const override;
|
|
|
|
|
virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override;
|
|
|
|
|
virtual FText GetMenuCategory() const override;
|
|
|
|
|
virtual int32 GetNodeRefreshPriority() const override { return EBaseNodeRefreshPriority::Low_UsesDependentWildcard; }
|
|
|
|
|
//~ End UK2Node Interface.
|
|
|
|
|
|
2025-03-24 21:49:09 -04:00
|
|
|
protected:
|
2026-02-14 02:14:19 -05:00
|
|
|
// Create all necessary pins.
|
|
|
|
|
//
|
2024-11-11 19:20:13 -05:00
|
|
|
void CreateCorrectPins();
|
2024-10-28 17:40:29 -04:00
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
// 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.
|
|
|
|
|
//
|
2024-10-28 17:40:29 -04:00
|
|
|
void SynchronizeArgumentPinType(UEdGraphPin* Pin);
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
// Derived class sets this to true, altering
|
|
|
|
|
// the behavior of this K2Node.
|
|
|
|
|
//
|
2025-03-24 21:49:09 -04:00
|
|
|
virtual bool IsFormatErrorMessage() const { return false; }
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
// When IsFormatErrorMessage is true, the K2Node
|
|
|
|
|
// macroexpands to call this function, which
|
|
|
|
|
// formats the message and outputs it to the log.
|
2026-02-13 23:24:18 -05:00
|
|
|
//
|
|
|
|
|
UFUNCTION(BlueprintCallable, meta=(WorldContext = "Context", BlueprintInternalUseOnly = "true"))
|
2026-02-14 01:25:04 -05:00
|
|
|
static void FormatLogMessageInternal(UObject *Context, ElxFormatLogVerbosity Verbosity, const FString &InPattern, TArray<FFormatArgumentData> InArgs);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static ELogVerbosity::Type ConvertElxFormatLogVerbosity(ElxFormatLogVerbosity Verbosity);
|
2026-02-13 23:24:18 -05:00
|
|
|
|
2025-03-24 21:49:09 -04:00
|
|
|
protected:
|
2026-02-14 02:14:19 -05:00
|
|
|
// Argument names added to the node, generated as pins
|
|
|
|
|
// during construction.
|
|
|
|
|
//
|
2024-10-28 17:40:29 -04:00
|
|
|
UPROPERTY()
|
2024-11-13 18:18:32 -05:00
|
|
|
TArray<FString> PinNames;
|
2024-10-28 17:40:29 -04:00
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
// Tooltip text for this node.
|
|
|
|
|
//
|
2024-10-28 17:40:29 -04:00
|
|
|
FText NodeTooltip;
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-14 02:14:19 -05:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// UK2Node_FormatLogMessage
|
2025-03-24 21:49:09 -04:00
|
|
|
//
|
2026-02-14 02:14:19 -05:00
|
|
|
// Derives from FormatMessage. Sets a flag to make
|
|
|
|
|
// the base class output to the log instead of to
|
|
|
|
|
// a pin.
|
2025-03-24 21:49:09 -04:00
|
|
|
//
|
2026-02-14 02:14:19 -05:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
2025-03-24 21:49:09 -04:00
|
|
|
UCLASS(MinimalAPI)
|
2026-02-13 23:24:18 -05:00
|
|
|
class UK2Node_FormatLogMessage : public UK2Node_FormatMessage
|
2025-03-24 21:49:09 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_UCLASS_BODY()
|
|
|
|
|
|
|
|
|
|
virtual bool IsFormatErrorMessage() const override { return true; }
|
|
|
|
|
};
|