2024-10-28 17:40:29 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2026-02-14 01:25:04 -05:00
|
|
|
#include "BreakToDebugger.h"
|
2026-02-13 23:24:18 -05:00
|
|
|
#include "FormatDataLibrary.h"
|
2024-10-28 17:40:29 -04:00
|
|
|
#include "Containers/Array.h"
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "EdGraph/EdGraphNode.h"
|
|
|
|
|
#include "EdGraph/EdGraphPin.h"
|
|
|
|
|
#include "HAL/Platform.h"
|
|
|
|
|
#include "Internationalization/Text.h"
|
|
|
|
|
#include "K2Node.h"
|
|
|
|
|
#include "UObject/NameTypes.h"
|
|
|
|
|
#include "UObject/ObjectMacros.h"
|
|
|
|
|
#include "UObject/UObjectGlobals.h"
|
|
|
|
|
|
2026-02-13 23:24:18 -05:00
|
|
|
#include "FormatMessage.generated.h"
|
2024-10-28 17:40:29 -04:00
|
|
|
|
2026-02-14 01:25:04 -05:00
|
|
|
/** Format Log Verbosity: controls how a message from the "Format Log Message"
|
|
|
|
|
* K2Node gets written to the log.
|
|
|
|
|
*
|
|
|
|
|
* 'Fatal' is deliberately placed at the end so that the editor defaults to
|
|
|
|
|
* 'Error' (value 0) when the dropdown is uninitialized. This means the
|
|
|
|
|
* numeric values don't match ELogVerbosity, so a conversion function is needed.
|
|
|
|
|
*
|
|
|
|
|
* ThrottledDisplay and ThrottledLog behave like Display and Log respectively,
|
|
|
|
|
* but suppress repeated messages with the same format pattern, logging at most
|
|
|
|
|
* once per second.
|
|
|
|
|
*/
|
|
|
|
|
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 report warnings. */
|
|
|
|
|
Warning,
|
|
|
|
|
|
|
|
|
|
/* Prints a message to the console and log file. */
|
|
|
|
|
Display,
|
|
|
|
|
|
|
|
|
|
/* Prints a message to the log file, however, it does not print 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 a log file only if Verbose logging is enabled for the given category. This is usually used for detailed logging. */
|
|
|
|
|
Verbose,
|
|
|
|
|
|
|
|
|
|
/* Prints a message to a log file. If VeryVerbose logging is enabled, then this is used for detailed logging that would otherwise spam output. */
|
|
|
|
|
VeryVerbose,
|
|
|
|
|
|
|
|
|
|
/* Danger! Prints a fatal error to the console and log file, then crashes (this crashes the editor too). */
|
|
|
|
|
Fatal,
|
|
|
|
|
};
|
|
|
|
|
|
2024-10-28 17:40:29 -04:00
|
|
|
class FBlueprintActionDatabaseRegistrar;
|
|
|
|
|
class FString;
|
|
|
|
|
class UEdGraph;
|
|
|
|
|
class UObject;
|
|
|
|
|
|
2024-11-14 23:57:04 -05:00
|
|
|
//
|
2025-03-24 21:49:09 -04:00
|
|
|
// FormatMessage and FormatErrorMessage
|
|
|
|
|
//
|
|
|
|
|
// This file defines two K2Nodes: FormatMessage, and FormatErrorMessage. The
|
|
|
|
|
// only difference between them is that the former outputs the message as an
|
|
|
|
|
// output pin. The latter outputs the message to the log instead.
|
|
|
|
|
//
|
|
|
|
|
// To implement code reuse, we put all the code into FormatMessage, and made
|
|
|
|
|
// FormatErrorMessage a derived class of FormatMessage. The derived class
|
|
|
|
|
// doesn't override anything - all it does is set a flag, the flag changes
|
|
|
|
|
// the behavior of FormatMessage.
|
|
|
|
|
//
|
2024-11-14 23:57:04 -05:00
|
|
|
//
|
2024-11-13 19:44:27 -05:00
|
|
|
UCLASS(MinimalAPI)
|
2025-03-24 21:49:09 -04:00
|
|
|
class UK2Node_FormatMessage : public UK2Node
|
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:
|
2024-11-11 19:20:13 -05:00
|
|
|
/** Create all necessary pins */
|
|
|
|
|
void CreateCorrectPins();
|
2024-10-28 17:40:29 -04: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 */
|
|
|
|
|
void SynchronizeArgumentPinType(UEdGraphPin* Pin);
|
|
|
|
|
|
2025-03-24 21:49:09 -04:00
|
|
|
/** Our derived class will set this to true, altering the behavior of this K2Node. **/
|
|
|
|
|
virtual bool IsFormatErrorMessage() const { return false; }
|
|
|
|
|
|
2026-02-13 23:24:18 -05:00
|
|
|
// 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"))
|
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:
|
2024-10-28 17:40:29 -04:00
|
|
|
/** When adding arguments to the node, their names are placed here and are generated as pins during construction */
|
|
|
|
|
UPROPERTY()
|
2024-11-13 18:18:32 -05:00
|
|
|
TArray<FString> PinNames;
|
2024-10-28 17:40:29 -04:00
|
|
|
|
|
|
|
|
/** Tooltip text for this node. */
|
|
|
|
|
FText NodeTooltip;
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-24 21:49:09 -04:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// This derives from FormatMessage.
|
|
|
|
|
//
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
// Setting this flag alters the behavior of FormatMessage, making it
|
|
|
|
|
// output to the log instead of to a pin.
|
|
|
|
|
//
|
|
|
|
|
virtual bool IsFormatErrorMessage() const override { return true; }
|
|
|
|
|
};
|
|
|
|
|
|