13#if !defined(EVENGINE_ANDROID) && !defined(EVENGINE_IOS) && !defined(EVENGINE_WEBGPU)
18void drawAiWindow(AiPanel& panel) {
19 if (!panel.isVisible())
return;
20 bool visible = panel.isVisible();
21 if (ImGui::Begin(
"AI / MCP", &visible, ImGuiWindowFlags_AlwaysAutoResize)) {
22 ImGui::TextUnformatted(panel.statusLine().c_str());
24 const auto log = panel.recentLog(64);
25 if (ImGui::BeginChild(
"ai_log", ImVec2(480, 260),
true)) {
26 for (
const auto& e : log) {
27 ImGui::TextWrapped(
"[%s] %s | %s", e.timestamp.c_str(), e.kind.c_str(),
29 if (!e.detail.empty()) ImGui::TextWrapped(
" %s", e.detail.c_str());
31 if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
32 ImGui::SetScrollHereY(1.0f);
35 if (ImGui::Button(
"Clear")) panel.clearLog();
37 if (ImGui::Button(
"Hide")) panel.setVisible(
false);
40 if (!visible) panel.setVisible(
false);
44void drawConsoleWindow(ConsolePanel& panel) {
45 if (!panel.isVisible())
return;
46 bool visible = panel.isVisible();
47 if (ImGui::Begin(
"Console", &visible,
48 ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoScrollbar)) {
49 if (ImGui::BeginMenuBar()) {
50 if (ImGui::BeginMenu(
"Log")) {
51 if (ImGui::MenuItem(
"Clear")) panel.clear();
52 if (ImGui::MenuItem(
"Copy all"))
53 ImGui::SetClipboardText(panel.format(4096).c_str());
59 ImGui::BeginChild(
"console_log", ImVec2(0, ImGui::GetContentRegionAvail().
y - 30),
61 const auto lines = panel.recent(500);
62 for (
const auto& l : lines) {
63 ImVec4
color = ImVec4(0.80f, 0.80f, 0.80f, 1.0f);
64 if (l.level ==
"error")
65 color = ImVec4(1.0f, 0.35f, 0.35f, 1.0f);
66 else if (l.level ==
"warn")
67 color = ImVec4(1.0f, 0.85f, 0.35f, 1.0f);
68 else if (l.level ==
"cmd" || l.level ==
"result")
69 color = ImVec4(0.45f, 0.80f, 1.0f, 1.0f);
70 ImGui::PushStyleColor(ImGuiCol_Text,
color);
71 ImGui::TextUnformatted((
"[" + l.timestamp +
"] " + l.level +
" | " + l.text).c_str());
72 ImGui::PopStyleColor();
74 if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) ImGui::SetScrollHereY(1.0f);
77 static char input[512] =
"";
78 ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().
x - 90);
79 const bool enter = ImGui::InputText(
"##repl", input,
sizeof(input),
80 ImGuiInputTextFlags_EnterReturnsTrue);
82 if (ImGui::Button(
"Run") || enter) {
83 std::string expr = input;
85 const std::string result = panel.eval(expr);
86 ImGui::SetClipboardText(result.c_str());
90 if (ImGui::Button(
"Hide")) panel.setVisible(
false);
93 if (!visible) panel.setVisible(
false);
106static eve::dev::HostPanels gHostPanels;
image::ImageData::Colorf color
static void setImGuiDrawer(ImGuiDrawer fn)
static void setImGuiDrawer(ImGuiDrawer fn)