Files
integration/Source/Integration/ConsoleOutput.h

80 lines
1.7 KiB
C
Raw Normal View History

////////////////////////////////////////////////////////////
//
// ConsoleOutput.h
//
// Optional helper for the console window. The
// GameMode blueprint can use this class to store
// console text as one big string with newlines.
//
// A dirty bit is set whenever text is appended,
// so the blueprint only needs to update the widget
// when the text has actually changed.
//
////////////////////////////////////////////////////////////
#pragma once
#include "Containers/UnrealString.h"
#include "ConsoleOutput.generated.h"
////////////////////////////////////////////////////////////
//
// UlxConsoleOutput
//
////////////////////////////////////////////////////////////
2025-12-09 02:42:13 -05:00
UCLASS(BlueprintType)
class UlxConsoleOutput : public UObject
{
GENERATED_BODY()
private:
FString Content;
bool Dirty;
2025-12-09 02:42:13 -05:00
private:
// Truncate the console to a reasonable number of lines.
// The length is hardwired.
//
void Truncate();
// Add a newline if there isn't one.
//
// Returns true if it changed anything.
//
bool MaybeAppendNewline();
// Append text.
//
// Returns true if it changed anything.
//
bool MaybeAppendText(const FString& text);
public:
// Append text to the console.
//
2025-12-09 02:42:13 -05:00
UFUNCTION(BlueprintCallable)
void Append(const FString& text);
// Append text on a line by itself.
//
2025-12-09 02:42:13 -05:00
UFUNCTION(BlueprintCallable)
void AppendLine(const FString& text);
// Get the console text as a string.
//
2025-12-09 02:42:13 -05:00
UFUNCTION(BlueprintCallable)
const FString& Get() const { return Content; }
// Return if the dirty flag is set.
//
2025-12-09 02:42:13 -05:00
UFUNCTION(BlueprintCallable)
bool IsDirty() const { return Dirty; }
// Clear the dirty flag.
//
2025-12-09 02:42:13 -05:00
UFUNCTION(BlueprintCallable)
void ClearDirty() { Dirty = false; }
};