mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
lua api refactor
This commit is contained in:
parent
5309cbe67f
commit
6bf6e8e011
20 changed files with 663 additions and 710 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "libgui.h"
|
||||
#include "lua_commons.h"
|
||||
#include "api_lua.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "../scripting.h"
|
||||
|
|
@ -161,7 +162,7 @@ static bool setattr(lua_State* L, gui::Label* label, const std::string& attr) {
|
|||
return false;
|
||||
}
|
||||
|
||||
int l_gui_getattr(lua_State* L) {
|
||||
static int l_gui_getattr(lua_State* L) {
|
||||
auto docname = lua_tostring(L, 1);
|
||||
auto element = lua_tostring(L, 2);
|
||||
const std::string attr = lua_tostring(L, 3);
|
||||
|
|
@ -197,12 +198,12 @@ int l_gui_getattr(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int l_gui_getviewport(lua_State* L) {
|
||||
static int l_gui_getviewport(lua_State* L) {
|
||||
lua::pushvec2_arr(L, scripting::engine->getGUI()->getContainer()->getSize());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_gui_setattr(lua_State* L) {
|
||||
static int l_gui_setattr(lua_State* L) {
|
||||
auto docname = lua_tostring(L, 1);
|
||||
auto element = lua_tostring(L, 2);
|
||||
const std::string attr = lua_tostring(L, 3);
|
||||
|
|
@ -235,7 +236,7 @@ int l_gui_setattr(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int l_gui_get_env(lua_State* L) {
|
||||
static int l_gui_get_env(lua_State* L) {
|
||||
auto name = lua_tostring(L, 1);
|
||||
auto doc = scripting::engine->getAssets()->getLayout(name);
|
||||
if (doc == nullptr) {
|
||||
|
|
@ -244,3 +245,11 @@ int l_gui_get_env(lua_State* L) {
|
|||
lua_getglobal(L, lua::LuaState::envName(doc->getEnvironment()).c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg guilib [] = {
|
||||
{"get_viewport", lua_wrap_errors<l_gui_getviewport>},
|
||||
{"getattr", lua_wrap_errors<l_gui_getattr>},
|
||||
{"setattr", lua_wrap_errors<l_gui_setattr>},
|
||||
{"get_env", lua_wrap_errors<l_gui_get_env>},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue