Lots of work on several unrelated things.
This commit is contained in:
65
Source/Integration/ConsoleOutput.cpp
Normal file
65
Source/Integration/ConsoleOutput.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "ConsoleOutput.h"
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ConsoleOutput
|
||||
//
|
||||
// Storing the text that goes in the unreal console.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
void FlxConsoleOutput::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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FlxConsoleOutput::MaybeAppendNewline() {
|
||||
int csize = Content.Len();
|
||||
if ((csize > 0) && (Content[csize - 1] != '\n')) {
|
||||
Content += TEXT("\n");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool FlxConsoleOutput::MaybeAppendText(const FString& text) {
|
||||
if (!text.IsEmpty()) {
|
||||
Content += text;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void FlxConsoleOutput::Append(const FString& text) {
|
||||
bool modified = MaybeAppendText(text);
|
||||
if (modified) {
|
||||
Dirty = true;
|
||||
Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
void FlxConsoleOutput::AppendLine(const FString& text) {
|
||||
bool modified = MaybeAppendNewline();
|
||||
modified |= MaybeAppendText(text);
|
||||
modified |= MaybeAppendNewline();
|
||||
if (modified) {
|
||||
Dirty = true;
|
||||
Truncate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user