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

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

#include <EditorHost.h>

类

struct  Impl
 

Public 成员函数

 EditorHost (const EditorHost &)=delete
 
EditorHost & operator= (const EditorHost &)=delete
 
 ~EditorHost ()
 Editor host.
 
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 ()
 Stops .
 
bool running () const
 Running.
 
bool windowAllowed () const
 Window allowed.
 
const std::string & gameRoot () const
 Game root.
 
std::string openWindow (const std::string &title, int width, int height)
 Opens window.
 
std::string closeWindow ()
 Closes window.
 
bool isWindowOpen () const
 True when window open.
 
std::string windowState () const
 Window state.
 
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)
 Removes editor.
 
std::string listEditors () const
 List editors.
 
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)
 Sets the editor value.
 
std::string restoreEditorValue (const std::string &editorId, const std::string &widgetId, const std::string &jsonValue)
 Restore a widget and its binding without emitting events or onChange.
 
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, const std::string &sourceName={})
 Compile Squirrel source in the host VM, then register table name.
 
std::string unregisterVM (const std::string &name)
 Unregisters vm.
 
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, const std::string &sourceName={})
 Compile and run Squirrel source in the host VM.
 
std::string capture (const std::string &path)
 Capture.
 
std::string reloadResource (const std::string &path)
 Reload mcp.nut, scripts under mcp, or editor VM and manifest files.
 
std::string hotReloadStatus () const
 Watch count, reload counters and latest diagnostic as compact JSON.
 
void setHotReloadWatchCount (int count)
 Set active project watch count reported by hotReloadStatus().
 
std::string status () const
 Status.
 
void requestExit ()
 Request exit.
 
bool exitRequested () const
 Exit requested.
 
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 ()
 Instance.
 

详细描述

Headless MCP editor host (MVVM).

The AI drives an EVEngine process through MCP: the View is a JSON widget tree assembled by applyEditor, and the ViewModel is a Squirrel table registered by 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 第 34 行定义.

构造及析构函数说明

◆ EditorHost()

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

◆ ~EditorHost()

eve::ui::EditorHost::~EditorHost ( )
default

Editor host.

成员函数说明

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

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

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

◆ capture()

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

◆ closeWindow()

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

Closes window.

在文件 EditorHost.cpp 第 641 行定义.

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

引用了 eve::Array , 以及 eve::Object.

被这些函数引用 exposeScriptApi().

◆ editorState()

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

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

在文件 EditorHost.cpp 第 767 行定义.

引用了 eve::Array, id, eve::Object, root , 以及 syncBindings().

被这些函数引用 applyEditor().

◆ exitRequested()

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

Exit requested.

在文件 EditorHost.h 第 124 行定义.

◆ exposeScriptApi()

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

◆ frame()

void eve::ui::EditorHost::frame ( )

Pump events + update/render hooks + present (no-op without window).

在文件 EditorHost.cpp 第 1192 行定义.

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

被这些函数引用 capture().

◆ gameRoot()

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

Game root.

在文件 EditorHost.h 第 53 行定义.

被这些函数引用 reloadResource() , 以及 start().

◆ hotReloadStatus()

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

Watch count, reload counters and latest diagnostic as compact JSON.

在文件 EditorHostHotReload.cpp 第 223 行定义.

被这些函数引用 exposeScriptApi().

◆ instance()

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

Instance.

在文件 EditorHost.cpp 第 573 行定义.

被这些函数引用 exposeScriptApi().

◆ isWindowOpen()

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

True when window open.

在文件 EditorHost.cpp 第 655 行定义.

◆ listEditors()

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

List editors.

在文件 EditorHost.cpp 第 727 行定义.

引用了 eve::Array, eve::Object , 以及 root.

◆ loadEditorsFromDisk()

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

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

在文件 EditorHost.cpp 第 1401 行定义.

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

被这些函数引用 start().

◆ openWindow()

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

Opens window.

在文件 EditorHost.cpp 第 602 行定义.

引用了 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,
const std::string &  sourceName = {} 
)

Compile Squirrel source in the host VM, then register table name.

参数
sourceNameCanonical script URI for import resolution. Empty uses host_vm.nut.

在文件 EditorHost.cpp 第 1330 行定义.

引用了 name, source , 以及 uri.

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

◆ reloadResource()

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

Reload mcp.nut, scripts under mcp, or editor VM and manifest files.

在文件 EditorHostHotReload.cpp 第 160 行定义.

引用了 applyEditor(), error, gameRoot(), input, path, registerVM(), running(), runScript(), eve::ModuleManager::runtime(), source, sourceId, uri, values , 以及 vmName.

被这些函数引用 exposeScriptApi().

◆ removeEditor()

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

Removes editor.

在文件 EditorHost.cpp 第 719 行定义.

引用了 id.

被这些函数引用 exposeScriptApi().

◆ renderImGui()

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

Draw editor ImGui windows; call between beginFrameAndRender/present.

在文件 EditorHost.cpp 第 1179 行定义.

被这些函数引用 frame().

◆ requestExit()

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

Request exit.

在文件 EditorHost.h 第 122 行定义.

被这些函数引用 frame().

◆ restoreEditorValue()

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

Restore a widget and its binding without emitting events or onChange.

在文件 EditorHost.cpp 第 1268 行定义.

引用了 v , 以及 widget.

◆ running()

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

Running.

在文件 EditorHost.h 第 49 行定义.

被这些函数引用 reloadResource().

◆ runScript()

std::string eve::ui::EditorHost::runScript ( const std::string &  source,
const std::string &  sourceName = {} 
)

Compile and run Squirrel source in the host VM.

参数
sourceNameCanonical script URI for import resolution. Empty uses host_snippet.nut.

在文件 EditorHost.cpp 第 1436 行定义.

引用了 source , 以及 uri.

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

◆ saveEditor()

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

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

在文件 EditorHost.cpp 第 1364 行定义.

引用了 dir , 以及 id.

被这些函数引用 exposeScriptApi().

◆ setEditorValue()

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

Sets the editor value.

在文件 EditorHost.cpp 第 1257 行定义.

引用了 v.

被这些函数引用 exposeScriptApi().

◆ setHotReloadWatchCount()

void eve::ui::EditorHost::setHotReloadWatchCount ( int  count)

Set active project watch count reported by hotReloadStatus().

在文件 EditorHostHotReload.cpp 第 235 行定义.

引用了 count.

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

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

◆ status()

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

Status.

在文件 EditorHost.cpp 第 1490 行定义.

引用了 eve::Array, eve::Object , 以及 v.

被这些函数引用 exposeScriptApi().

◆ stop()

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

Stops .

在文件 EditorHost.cpp 第 594 行定义.

引用了 closeWindow().

◆ syncBindings()

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

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

在文件 EditorHost.cpp 第 783 行定义.

被这些函数引用 editorState().

◆ unloadEditor()

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

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

在文件 EditorHost.cpp 第 1393 行定义.

引用了 id.

◆ unregisterVM()

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

Unregisters vm.

在文件 EditorHost.cpp 第 1347 行定义.

引用了 name, top , 以及 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.cpp 第 1309 行定义.

引用了 eve::Object.

被这些函数引用 exposeScriptApi().

◆ windowAllowed()

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

Window allowed.

在文件 EditorHost.h 第 51 行定义.

◆ windowState()

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

Window state.

在文件 EditorHost.cpp 第 659 行定义.

引用了 eve::Object.

被这些函数引用 exposeScriptApi().


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