36 lines
672 B
C++
36 lines
672 B
C++
|
#include <stdio.h>
|
||
|
#include "EditorConsole.h"
|
||
|
|
||
|
|
||
|
EditorConsole::EditorConsole()
|
||
|
: Items(ImVector<char*>()), AutoScroll(false), ScrollToBottom(false)
|
||
|
{
|
||
|
AddLog("Hello Editor console!");
|
||
|
}
|
||
|
|
||
|
EditorConsole::~EditorConsole() {
|
||
|
|
||
|
}
|
||
|
|
||
|
void EditorConsole::Draw() {
|
||
|
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
|
||
|
|
||
|
|
||
|
for (int i = 0; i < Items.Size; i++)
|
||
|
{
|
||
|
const char* item = Items[i];
|
||
|
ImGui::TextUnformatted(item);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void EditorConsole::AddLog(const char* fmt, ...) {
|
||
|
char buf[1024];
|
||
|
va_list args;
|
||
|
va_start(args, fmt);
|
||
|
vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||
|
buf[IM_ARRAYSIZE(buf) - 1] = 0;
|
||
|
va_end(args);
|
||
|
Items.push_back(strdup(buf));
|
||
|
}
|