-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleWindow.cpp
More file actions
47 lines (35 loc) · 960 Bytes
/
Copy pathConsoleWindow.cpp
File metadata and controls
47 lines (35 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// Created by Alex on 1/25/2021.
//
#include "ConsoleWindow.hpp"
#include "EditorStats.hpp"
#include <string>
using RPG::ConsoleWindow;
struct ConsoleWindow::Internal {
bool isOpened;
Internal() : isOpened(true) {}
void Render(ImGuiID dockID) {
if (!isOpened) return;
ImGui::SetNextWindowDockID(dockID, ImGuiCond_FirstUseEver);
ImGui::Begin("Console", &isOpened);
for (auto log : RPG::EditorStats::GetInstance().GetLogs()) {
std::string s = "[" + log.caller + "] " + log.message;
ImGui::Text(s.c_str());
}
ImGui::End();
}
};
ConsoleWindow::ConsoleWindow() : internal(RPG::MakeInternalPointer<Internal>()) {}
void ConsoleWindow::Render(ImGuiID dockID) {
internal->Render(dockID);
}
RPG::Action<>::Callback ConsoleWindow::ToggleIsOpen() {
return [this] () {
internal->isOpened = !internal->isOpened;
};
}
RPG::Action<>::Func<bool> ConsoleWindow::IsOpen() {
return [this] () -> bool {
return internal->isOpened;
};
}