mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 05:51:51 +00:00
add gui.root & add 'app' library to project scripts
This commit is contained in:
parent
e6812371ec
commit
bfbfe59f9b
5 changed files with 20 additions and 1 deletions
|
|
@ -103,3 +103,9 @@ gui.load_document(
|
||||||
```
|
```
|
||||||
|
|
||||||
Loads a UI document with its script, returns the name of the document if successfully loaded.
|
Loads a UI document with its script, returns the name of the document if successfully loaded.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
gui.root: Document
|
||||||
|
```
|
||||||
|
|
||||||
|
Root UI document
|
||||||
|
|
|
||||||
|
|
@ -100,3 +100,9 @@ gui.load_document(
|
||||||
```
|
```
|
||||||
|
|
||||||
Загружает UI документ с его скриптом, возвращает имя документа, если успешно загружен.
|
Загружает UI документ с его скриптом, возвращает имя документа, если успешно загружен.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
gui.root: Document
|
||||||
|
```
|
||||||
|
|
||||||
|
Корневой UI документ
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ local function configure_menu()
|
||||||
end
|
end
|
||||||
return w, h
|
return w, h
|
||||||
end
|
end
|
||||||
_GUI_ROOT.root:add(
|
gui.root.root:add(
|
||||||
"<image id='menubg' src='gui/menubg' size-func='DATA.resize_menu_bg' "..
|
"<image id='menubg' src='gui/menubg' size-func='DATA.resize_menu_bg' "..
|
||||||
"z-index='-1' interactive='true'/>", controller)
|
"z-index='-1' interactive='true'/>", controller)
|
||||||
menubg = _GUI_ROOT.menubg
|
menubg = _GUI_ROOT.menubg
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,7 @@ end
|
||||||
_GUI_ROOT = Document.new("core:root")
|
_GUI_ROOT = Document.new("core:root")
|
||||||
_MENU = _GUI_ROOT.menu
|
_MENU = _GUI_ROOT.menu
|
||||||
menu = _MENU
|
menu = _MENU
|
||||||
|
gui.root = _GUI_ROOT
|
||||||
|
|
||||||
--- Console library extension ---
|
--- Console library extension ---
|
||||||
console.cheats = {}
|
console.cheats = {}
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,12 @@ std::unique_ptr<IProjectScript> scripting::load_project_script(
|
||||||
auto L = lua::get_main_state();
|
auto L = lua::get_main_state();
|
||||||
auto source = io::read_string(script);
|
auto source = io::read_string(script);
|
||||||
auto env = create_environment(nullptr);
|
auto env = create_environment(nullptr);
|
||||||
|
lua::pushenv(L, *env);
|
||||||
|
if (lua::getglobal(L, "__vc_app")) {
|
||||||
|
lua::setfield(L, "app");
|
||||||
|
}
|
||||||
|
lua::pop(L);
|
||||||
|
|
||||||
lua::loadbuffer(L, *env, source, script.name());
|
lua::loadbuffer(L, *env, source, script.name());
|
||||||
lua::call(L, 0);
|
lua::call(L, 0);
|
||||||
return std::make_unique<LuaProjectScript>(L, std::move(env));
|
return std::make_unique<LuaProjectScript>(L, std::move(env));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue