载入中...
搜索中...
未找到
ConsolePanel.hpp
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
4
5#include <cstdint>
6#include <deque>
7#include <mutex>
8#include <string>
9#include <vector>
10
11struct SQVM;
12typedef struct SQVM* HSQUIRRELVM;
13
14namespace eve::dev {
15
17 std::string timestamp; // HH:MM:SS
18 std::string level; // debug | info | warn | error | print | cmd | result
19 std::string text;
20};
21
39public:
40 static ConsolePanel& instance();
41
42 ConsolePanel(const ConsolePanel&) = delete;
44
45 void setVisible(bool on);
46 bool isVisible() const;
47 void toggleVisible();
48
50 void addLog(std::string level, std::string text);
51 void addInfo(std::string text);
52 void addWarn(std::string text);
53 void addError(std::string text);
54
55 void clear();
56 void setMaxEntries(size_t n);
57 std::vector<ConsoleLine> recent(size_t max = 128) const;
58 std::string format(size_t max = 128) const;
59
61 void attach(HSQUIRRELVM vm);
62 void detach();
63 bool isAttached() const { return vm_ != nullptr; }
64
69 std::string eval(const std::string& expression);
70
75 void drawImGui();
76
77 using ImGuiDrawer = void (*)(ConsolePanel& panel);
78 static void setImGuiDrawer(ImGuiDrawer fn);
79
80private:
81 // Immortal<ConsolePanel> constructs the singleton (devtools/Immortal.hpp).
82 template <typename> friend struct Immortal;
83 ConsolePanel() = default;
84
85 static std::string nowStamp();
86
87 mutable std::mutex mu_;
88 bool visible_ = true;
89 size_t maxEntries_ = 500;
90 std::deque<ConsoleLine> log_;
91 HSQUIRRELVM vm_ = nullptr;
92};
93
94} // namespace eve::dev
struct SQVM * HSQUIRRELVM
HSQUIRRELVM vm
Definition ECS.cpp:20
#define EVENGINE_API
宿主(eve / libmain)导出宏;插件从进程导入同一批符号。
Definition Export.h:16
glm::vec3 n
Definition Grass.cpp:64
SettlementPipeline::Stage fn
In-engine runtime console / log ring buffer for DevTools.
void(*)(ConsolePanel &panel) ImGuiDrawer
ConsolePanel(const ConsolePanel &)=delete
ConsolePanel & operator=(const ConsolePanel &)=delete
Process-immortal singleton holder for DevTools objects.
Definition Immortal.hpp:19