载入中...
搜索中...
未找到

Headless MCP editor host (MVVM). 更多...

#include <EditorHost.h>

struct  Impl
 

Public 成员函数

 EditorHost (const EditorHost &)=delete
 
EditorHostoperator= (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 EditorHostinstance ()
 

详细描述

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.h33 行定义.

构造及析构函数说明

◆ EditorHost()

eve::ui::EditorHost::EditorHost ( const EditorHost )
delete

◆ ~EditorHost()

eve::ui::EditorHost::~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.cpp627 行定义.

引用了 editorState(), id, openWindow() , 以及 w.

被这些函数引用 exposeScriptApi() , 以及 loadEditorsFromDisk().

◆ capture()

std::string eve::ui::EditorHost::capture ( const std::string &  path)

◆ closeWindow()

std::string eve::ui::EditorHost::closeWindow ( )

在文件 EditorHost.cpp597 行定义.

被这些函数引用 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.cpp1197 行定义.

被这些函数引用 exposeScriptApi().

◆ editorState()

std::string eve::ui::EditorHost::editorState ( const std::string &  id) const

Full state JSON: editors + values + (non-destructive) events.

在文件 EditorHost.cpp711 行定义.

引用了 id , 以及 syncBindings().

被这些函数引用 applyEditor().

◆ exitRequested()

bool eve::ui::EditorHost::exitRequested ( ) const
inline

在文件 EditorHost.h88 行定义.

◆ exposeScriptApi()

void eve::ui::EditorHost::exposeScriptApi ( ssq::VM &  vm)

Expose eve.host table (registerVM/unregisterVM/widgetRect/...).

在文件 EditorHost.cpp1420 行定义.

引用了 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.cpp1132 行定义.

引用了 closeWindow(), m, name, renderImGui() , 以及 requestExit().

被这些函数引用 capture().

◆ gameRoot()

const std::string & eve::ui::EditorHost::gameRoot ( ) const
inline

在文件 EditorHost.h46 行定义.

被这些函数引用 start().

◆ instance()

EditorHost & eve::ui::EditorHost::instance ( )
static

在文件 EditorHost.cpp540 行定义.

被这些函数引用 exposeScriptApi().

◆ listEditors()

std::string eve::ui::EditorHost::listEditors ( ) const

在文件 EditorHost.cpp671 行定义.

◆ loadEditorsFromDisk()

void eve::ui::EditorHost::loadEditorsFromDisk ( )

Load editors/<id>.editor.json (+ matching .vm.nut) on host startup.

在文件 EditorHost.cpp1311 行定义.

引用了 applyEditor(), dir, name, p, registerVM() , 以及 vmName.

被这些函数引用 start().

◆ openWindow()

std::string eve::ui::EditorHost::openWindow ( const std::string &  title,
int  width,
int  height 
)

在文件 EditorHost.cpp569 行定义.

引用了 height, s, title, width , 以及 eve::window::WindowSettings::width.

被这些函数引用 applyEditor() , 以及 exposeScriptApi().

◆ operator=()

EditorHost & eve::ui::EditorHost::operator= ( const EditorHost )
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.cpp1242 行定义.

引用了 name.

被这些函数引用 exposeScriptApi() , 以及 loadEditorsFromDisk().

◆ removeEditor()

std::string eve::ui::EditorHost::removeEditor ( const std::string &  id)

在文件 EditorHost.cpp663 行定义.

引用了 id.

被这些函数引用 exposeScriptApi().

◆ renderImGui()

void eve::ui::EditorHost::renderImGui ( )

Draw editor ImGui windows; call between beginFrameAndRender/present.

在文件 EditorHost.cpp1119 行定义.

被这些函数引用 frame().

◆ requestExit()

void eve::ui::EditorHost::requestExit ( )
inline

在文件 EditorHost.h87 行定义.

被这些函数引用 frame().

◆ running()

bool eve::ui::EditorHost::running ( ) const
inline

在文件 EditorHost.h44 行定义.

◆ runScript()

std::string eve::ui::EditorHost::runScript ( const std::string &  source)

在文件 EditorHost.cpp1346 行定义.

被这些函数引用 exposeScriptApi().

◆ saveEditor()

std::string eve::ui::EditorHost::saveEditor ( const std::string &  id)

Write editors/<id>.editor.json + editors/<id>.vm.nut under gameRoot.

在文件 EditorHost.cpp1274 行定义.

引用了 dir , 以及 id.

被这些函数引用 exposeScriptApi().

◆ setEditorValue()

std::string eve::ui::EditorHost::setEditorValue ( const std::string &  editorId,
const std::string &  widgetId,
const std::string &  jsonValue 
)

在文件 EditorHost.cpp1168 行定义.

引用了 d, p , 以及 v.

被这些函数引用 exposeScriptApi().

◆ 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.cpp549 行定义.

引用了 gameRoot(), loadEditorsFromDisk() , 以及 vm.

◆ status()

std::string eve::ui::EditorHost::status ( ) const

在文件 EditorHost.cpp1399 行定义.

引用了 v.

被这些函数引用 exposeScriptApi().

◆ stop()

void eve::ui::EditorHost::stop ( )

在文件 EditorHost.cpp561 行定义.

引用了 closeWindow().

◆ syncBindings()

void eve::ui::EditorHost::syncBindings ( )

Pull bound ViewModel values into widget state (per-frame + on read).

在文件 EditorHost.cpp727 行定义.

被这些函数引用 editorState().

◆ unloadEditor()

std::string eve::ui::EditorHost::unloadEditor ( const std::string &  id)

Remove an editor from the session (files stay on disk).

在文件 EditorHost.cpp1303 行定义.

引用了 id.

◆ unregisterVM()

std::string eve::ui::EditorHost::unregisterVM ( const std::string &  name)

在文件 EditorHost.cpp1257 行定义.

引用了 name , 以及 v.

被这些函数引用 exposeScriptApi().

◆ 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.cpp1221 行定义.

被这些函数引用 exposeScriptApi().

◆ windowAllowed()

bool eve::ui::EditorHost::windowAllowed ( ) const
inline

在文件 EditorHost.h45 行定义.

◆ windowOpen()

bool eve::ui::EditorHost::windowOpen ( ) const

在文件 EditorHost.cpp611 行定义.

◆ windowState()

std::string eve::ui::EditorHost::windowState ( ) const

在文件 EditorHost.cpp615 行定义.

被这些函数引用 exposeScriptApi().


该类的文档由以下文件生成: