mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
add gui.get_active_frame, set_active_frame & update cursor lock behavior
This commit is contained in:
parent
463098aa1e
commit
8468ab184d
11 changed files with 123 additions and 50 deletions
|
|
@ -1154,21 +1154,44 @@ static int l_create_frame(lua::State* L) {
|
|||
if (engine->isHeadless()) {
|
||||
return 0;
|
||||
}
|
||||
std::string outputTexture = lua::require_string(L, 1);
|
||||
auto size = lua::tovec2(L, 2);
|
||||
std::string id = lua::require_string(L, 1);
|
||||
std::string outputTexture = lua::require_string(L, 2);
|
||||
auto size = lua::tovec2(L, 3);
|
||||
|
||||
auto& gui = engine->getGUI();
|
||||
auto frame = std::make_shared<gui::Frame>(gui, outputTexture);
|
||||
auto frame = std::make_shared<gui::Frame>(gui, id, outputTexture);
|
||||
frame->setSize(std::move(size));
|
||||
auto& assets = *engine->getAssets();
|
||||
auto document = std::make_shared<UiDocument>(
|
||||
outputTexture, UiDocScript {}, frame, nullptr
|
||||
id, UiDocScript {}, frame, nullptr
|
||||
);
|
||||
assets.store(document, document->getId());
|
||||
assets.store(document, id);
|
||||
gui.addFrame(std::move(frame));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_set_active_frame(lua::State* L) {
|
||||
if (engine->isHeadless()) {
|
||||
return 0;
|
||||
}
|
||||
std::string id = lua::require_string(L, 1);
|
||||
auto& gui = engine->getGUI();
|
||||
gui.setActiveFrame(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_get_active_frame(lua::State* L) {
|
||||
if (engine->isHeadless()) {
|
||||
return 0;
|
||||
}
|
||||
auto& gui = engine->getGUI();
|
||||
auto frame = gui.getActiveFrame();
|
||||
if (frame == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return lua::pushstring(L, frame->getId());
|
||||
}
|
||||
|
||||
const luaL_Reg guilib[] = {
|
||||
{"get_viewport", lua::wrap<l_gui_getviewport>},
|
||||
{"getattr", lua::wrap<l_gui_getattr>},
|
||||
|
|
@ -1183,6 +1206,8 @@ const luaL_Reg guilib[] = {
|
|||
{"load_document", lua::wrap<l_gui_load_document>},
|
||||
{"set_syntax_styles", lua::wrap<l_set_syntax_styles>},
|
||||
{"create_frame", lua::wrap<l_create_frame>},
|
||||
{"set_active_frame", lua::wrap<l_set_active_frame>},
|
||||
{"get_active_frame", lua::wrap<l_get_active_frame>},
|
||||
{"__reindex", lua::wrap<l_gui_reindex>},
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue