#include "CoreMinimal.h" #include "engineutil.hpp" namespace engineutil { void init_wrapper(EngineWrapper* w) { void* DLL = FPlatformProcess::GetDllHandle(TEXT("c:\\Luprex\\build\\visual\\luprexlib.dll")); if (DLL != nullptr) { using InitFn = void (*)(EngineWrapper*); InitFn init = (InitFn)FPlatformProcess::GetDllExport(DLL, TEXT("init_engine_wrapper")); if (init != nullptr) { init(w); } } } static TArray dprints; void DPrint(const FString& fs) { dprints.Emplace(fs); } void DPrint(const char* msg) { dprints.Emplace(msg); } void DPrintHook(const char* msg, size_t len) { dprints.Emplace(len, (const UTF8CHAR*)msg); } const TArray& DPrintGetStored() { return dprints; } void DPrintClearStored() { dprints.Reset(); } 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