add gui.load_document namespace extension table argument & pass app library from standard pages loader

This commit is contained in:
MihailRis 2026-01-07 01:54:47 +03:00
parent d6b6c6903a
commit e794aa864d
2 changed files with 11 additions and 1 deletions

View file

@ -34,7 +34,7 @@ function gui_util.load_page(query)
local filename = file.find(string.format("layouts/pages/%s.xml", name))
if filename then
name = file.prefix(filename)..":pages/"..name
gui.load_document(filename, name, args)
gui.load_document(filename, name, args, { app = __vc_app })
return name
end
end

View file

@ -1111,6 +1111,16 @@ static int l_gui_load_document(lua::State* L) {
);
auto document = documentPtr.get();
engine->getAssets()->store(std::move(documentPtr), alias);
// namespace extension
if (lua::istable(L, 4)) {
if (lua::get_from(L, "table", "merge")) {
lua::pushenv(L, *document->getEnvironment());
lua::pushvalue(L, 4);
lua::call(L, 2, 0);
lua::pop(L);
}
}
scripting::on_ui_open(document, {args});
return 0;
}