#include "CoreMinimal.h" #include "engineutil.hpp" namespace engineutil { // The DPrint array. This stores the dprints // until they can be collected by the console implementation. static TArray dprint_array; static FCriticalSection dprint_mutex; void DPrint(const FString& fs) { FScopeLock lk(&dprint_mutex); dprint_array.Emplace(fs); } void DPrint(const char* msg) { FScopeLock lk(&dprint_mutex); dprint_array.Emplace(msg); } void DPrintHook(const char* msg, size_t len) { FScopeLock lk(&dprint_mutex); dprint_array.Emplace(len, (const UTF8CHAR*)msg); } TArray DPrintGetStored() { FScopeLock lk(&dprint_mutex); TArray result = std::move(dprint_array); dprint_array.Empty(); return result; } void ConsoleOutput::Append(const FString& text) { if (!text.IsEmpty()) { Content += text; Truncate(); Dirty = true; } } void ConsoleOutput::AppendLine(const FString& text) { int csize = Content.Len(); if ((csize > 0) && (Content[csize - 1] != '\n')) { Content += TEXT("\n"); } Content += text; Content += TEXT("\n"); Truncate(); Dirty = true; } void ConsoleOutput::Truncate() { int lines = 50; int csize = Content.Len(); int total = 0; for (int i = csize - 1; i >= 0; i--) { if (Content[i] == '\n') { total += 1; if (total == lines) { Content = Content.RightChop(i + 1); return; } } } } } // namespace engineutil