mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
add cursorLocator argument to gui.set_active_frame
This commit is contained in:
parent
8ee2edef5c
commit
239ada8e3d
4 changed files with 36 additions and 12 deletions
|
|
@ -1175,8 +1175,22 @@ static int l_set_active_frame(lua::State* L) {
|
|||
return 0;
|
||||
}
|
||||
std::string id = lua::require_string(L, 1);
|
||||
vec2supplier cursorLocator = nullptr;
|
||||
if (lua::isfunction(L, 2)) {
|
||||
auto lambda = lua::create_lambda(L);
|
||||
cursorLocator = [lambda]() -> glm::vec2 {
|
||||
auto table = lambda({});
|
||||
if (!table.isList()) {
|
||||
throw std::runtime_error("invalid value returned from locator");
|
||||
}
|
||||
glm::vec2 pos {};
|
||||
table.at(0).get(pos.x);
|
||||
table.at(1).get(pos.y);
|
||||
return pos;
|
||||
};
|
||||
}
|
||||
auto& gui = engine->getGUI();
|
||||
gui.setActiveFrame(id);
|
||||
gui.setActiveFrame(id, std::move(cursorLocator));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue