Headless MCP editor host (MVVM). 更多...
#include <EditorHost.h>
类 | |
| struct | Impl |
Public 成员函数 | |
| EditorHost (const EditorHost &)=delete | |
| EditorHost & | operator= (const EditorHost &)=delete |
| ~EditorHost () | |
| void | start (ssq::VM &vm, const std::string &gameRoot={}, bool allowWindow=true) |
| Attach to the host VM. gameRoot is the project dir for editors/. | |
| void | stop () |
| bool | running () const |
| bool | windowAllowed () const |
| const std::string & | gameRoot () const |
| std::string | openWindow (const std::string &title, int width, int height) |
| std::string | closeWindow () |
| bool | windowOpen () const |
| std::string | windowState () const |
| std::string | applyEditor (const std::string &json) |
| JSON object/string: {id,title,vm,x,y,width,height,theme,children[]}. | |
| std::string | removeEditor (const std::string &id) |
| std::string | listEditors () const |
| std::string | editorState (const std::string &id) const |
| Full state JSON: editors + values + (non-destructive) events. | |
| void | syncBindings () |
| Pull bound ViewModel values into widget state (per-frame + on read). | |
| std::string | setEditorValue (const std::string &editorId, const std::string &widgetId, const std::string &jsonValue) |
| std::string | consumeEvents (const std::string &editorId) |
| Read and clear pending interaction events for one editor ("" = all). | |
| std::string | widgetRect (const std::string &editorId, const std::string &widgetId) const |
| Last-frame widget rect JSON (for script drawing inside viewports). | |
| std::string | registerVM (const std::string &name, const std::string &source) |
Compile Squirrel source in the host VM, then register table name. | |
| std::string | unregisterVM (const std::string &name) |
| std::string | saveEditor (const std::string &id) |
| Write editors/<id>.editor.json + editors/<id>.vm.nut under gameRoot. | |
| std::string | unloadEditor (const std::string &id) |
| Remove an editor from the session (files stay on disk). | |
| void | loadEditorsFromDisk () |
| Load editors/<id>.editor.json (+ matching .vm.nut) on host startup. | |
| std::string | runScript (const std::string &source) |
| std::string | capture (const std::string &path) |
| std::string | status () const |
| void | requestExit () |
| bool | exitRequested () const |
| void | frame () |
| Pump events + update/render hooks + present (no-op without window). | |
| void | renderImGui () |
| Draw editor ImGui windows; call between beginFrameAndRender/present. | |
| void | exposeScriptApi (ssq::VM &vm) |
Expose eve.host table (registerVM/unregisterVM/widgetRect/...). | |
静态 Public 成员函数 | |
| static EditorHost & | instance () |
详细描述
Headless MCP editor host (MVVM).
The AI drives an EVEngine process through MCP: the View is a JSON widget tree (applyEditor), the ViewModel is a Squirrel table (registerVM) that the host binds to the View each frame (two-way bind, one-way commands / onChange / bind:options / bind:label / bind:visible / bind:enabled). Model data lives in the engine (Heightmap / Material / Scene) and is only touched by the ViewModel script.
Window lifecycle: the host OS window is created lazily on the first openWindow / applyEditor; frame() pumps events, runs eve_host_update(dt) and eve_host_render() hooks, then presents. renderImGui() must be called between ui.beginFrameAndRender() and gfx.present().
Desktop-only full implementation; Emscripten builds get a stub so EVUI stays linkable without Poco / DevTools. The header deliberately contains no imgui.h (engine TUs include this header).
在文件 EditorHost.h 第 33 行定义.
构造及析构函数说明
◆ EditorHost()
|
delete |
◆ ~EditorHost()
|
default |
成员函数说明
◆ applyEditor()
| std::string eve::ui::EditorHost::applyEditor | ( | const std::string & | json | ) |
JSON object/string: {id,title,vm,x,y,width,height,theme,children[]}.
在文件 EditorHost.cpp 第 627 行定义.
引用了 editorState(), id, openWindow() , 以及 w.
被这些函数引用 exposeScriptApi() , 以及 loadEditorsFromDisk().
◆ capture()
| std::string eve::ui::EditorHost::capture | ( | const std::string & | path | ) |
在文件 EditorHost.cpp 第 1353 行定义.
引用了 eve::image::ImageData::encode(), frame(), eve::filesystem::FileData::getData(), eve::filesystem::FileData::getSize(), h, p , 以及 w.
被这些函数引用 exposeScriptApi().
◆ closeWindow()
| std::string eve::ui::EditorHost::closeWindow | ( | ) |
在文件 EditorHost.cpp 第 597 行定义.
被这些函数引用 exposeScriptApi(), frame() , 以及 stop().
◆ consumeEvents()
| std::string eve::ui::EditorHost::consumeEvents | ( | const std::string & | editorId | ) |
Read and clear pending interaction events for one editor ("" = all).
在文件 EditorHost.cpp 第 1197 行定义.
被这些函数引用 exposeScriptApi().
◆ editorState()
| std::string eve::ui::EditorHost::editorState | ( | const std::string & | id | ) | const |
Full state JSON: editors + values + (non-destructive) events.
在文件 EditorHost.cpp 第 711 行定义.
引用了 id , 以及 syncBindings().
被这些函数引用 applyEditor().
◆ exitRequested()
|
inline |
在文件 EditorHost.h 第 88 行定义.
◆ exposeScriptApi()
| void eve::ui::EditorHost::exposeScriptApi | ( | ssq::VM & | vm | ) |
Expose eve.host table (registerVM/unregisterVM/widgetRect/...).
在文件 EditorHost.cpp 第 1420 行定义.
引用了 applyEditor(), capture(), closeWindow(), consumeEvents(), h, instance(), name, openWindow(), registerVM(), removeEditor(), runScript(), saveEditor(), setEditorValue(), status(), unregisterVM(), value, vm, w, widget, widgetRect() , 以及 windowState().
◆ frame()
| void eve::ui::EditorHost::frame | ( | ) |
Pump events + update/render hooks + present (no-op without window).
在文件 EditorHost.cpp 第 1132 行定义.
引用了 closeWindow(), m, name, renderImGui() , 以及 requestExit().
被这些函数引用 capture().
◆ gameRoot()
|
inline |
在文件 EditorHost.h 第 46 行定义.
被这些函数引用 start().
◆ instance()
|
static |
在文件 EditorHost.cpp 第 540 行定义.
被这些函数引用 exposeScriptApi().
◆ listEditors()
| std::string eve::ui::EditorHost::listEditors | ( | ) | const |
在文件 EditorHost.cpp 第 671 行定义.
◆ loadEditorsFromDisk()
| void eve::ui::EditorHost::loadEditorsFromDisk | ( | ) |
Load editors/<id>.editor.json (+ matching .vm.nut) on host startup.
在文件 EditorHost.cpp 第 1311 行定义.
引用了 applyEditor(), dir, name, p, registerVM() , 以及 vmName.
被这些函数引用 start().
◆ openWindow()
| std::string eve::ui::EditorHost::openWindow | ( | const std::string & | title, |
| int | width, | ||
| int | height | ||
| ) |
在文件 EditorHost.cpp 第 569 行定义.
引用了 height, s, title, width , 以及 eve::window::WindowSettings::width.
被这些函数引用 applyEditor() , 以及 exposeScriptApi().
◆ operator=()
|
delete |
◆ registerVM()
| std::string eve::ui::EditorHost::registerVM | ( | const std::string & | name, |
| const std::string & | source | ||
| ) |
Compile Squirrel source in the host VM, then register table name.
在文件 EditorHost.cpp 第 1242 行定义.
引用了 name.
被这些函数引用 exposeScriptApi() , 以及 loadEditorsFromDisk().
◆ removeEditor()
| std::string eve::ui::EditorHost::removeEditor | ( | const std::string & | id | ) |
◆ renderImGui()
| void eve::ui::EditorHost::renderImGui | ( | ) |
Draw editor ImGui windows; call between beginFrameAndRender/present.
在文件 EditorHost.cpp 第 1119 行定义.
被这些函数引用 frame().
◆ requestExit()
|
inline |
在文件 EditorHost.h 第 87 行定义.
被这些函数引用 frame().
◆ running()
|
inline |
在文件 EditorHost.h 第 44 行定义.
◆ runScript()
| std::string eve::ui::EditorHost::runScript | ( | const std::string & | source | ) |
在文件 EditorHost.cpp 第 1346 行定义.
被这些函数引用 exposeScriptApi().
◆ saveEditor()
| std::string eve::ui::EditorHost::saveEditor | ( | const std::string & | id | ) |
Write editors/<id>.editor.json + editors/<id>.vm.nut under gameRoot.
在文件 EditorHost.cpp 第 1274 行定义.
被这些函数引用 exposeScriptApi().
◆ setEditorValue()
| std::string eve::ui::EditorHost::setEditorValue | ( | const std::string & | editorId, |
| const std::string & | widgetId, | ||
| const std::string & | jsonValue | ||
| ) |
◆ start()
| void eve::ui::EditorHost::start | ( | ssq::VM & | vm, |
| const std::string & | gameRoot = {}, |
||
| bool | allowWindow = true |
||
| ) |
Attach to the host VM. gameRoot is the project dir for editors/.
在文件 EditorHost.cpp 第 549 行定义.
引用了 gameRoot(), loadEditorsFromDisk() , 以及 vm.
◆ status()
| std::string eve::ui::EditorHost::status | ( | ) | const |
◆ stop()
| void eve::ui::EditorHost::stop | ( | ) |
在文件 EditorHost.cpp 第 561 行定义.
引用了 closeWindow().
◆ syncBindings()
| void eve::ui::EditorHost::syncBindings | ( | ) |
Pull bound ViewModel values into widget state (per-frame + on read).
在文件 EditorHost.cpp 第 727 行定义.
被这些函数引用 editorState().
◆ unloadEditor()
| std::string eve::ui::EditorHost::unloadEditor | ( | const std::string & | id | ) |
◆ unregisterVM()
| std::string eve::ui::EditorHost::unregisterVM | ( | const std::string & | name | ) |
◆ widgetRect()
| std::string eve::ui::EditorHost::widgetRect | ( | const std::string & | editorId, |
| const std::string & | widgetId | ||
| ) | const |
Last-frame widget rect JSON (for script drawing inside viewports).
在文件 EditorHost.cpp 第 1221 行定义.
被这些函数引用 exposeScriptApi().
◆ windowAllowed()
|
inline |
在文件 EditorHost.h 第 45 行定义.
◆ windowOpen()
| bool eve::ui::EditorHost::windowOpen | ( | ) | const |
在文件 EditorHost.cpp 第 611 行定义.
◆ windowState()
| std::string eve::ui::EditorHost::windowState | ( | ) | const |
在文件 EditorHost.cpp 第 615 行定义.
被这些函数引用 exposeScriptApi().
该类的文档由以下文件生成:
- src/modules/ui/EditorHost.h
- src/modules/ui/EditorHost.cpp