From d5cd0c7b4425e25b11a1ceec154a5c752d508a42 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 26 Jun 2019 16:14:00 -0400 Subject: Major refactor of physics code Move all the physics code into the shared directory, and fix the ghost objects (aabb only) --- src/client/lua_api/load_gui.cpp | 42 +++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) (limited to 'src/client/lua_api/load_gui.cpp') diff --git a/src/client/lua_api/load_gui.cpp b/src/client/lua_api/load_gui.cpp index 845661a..64b9711 100644 --- a/src/client/lua_api/load_gui.cpp +++ b/src/client/lua_api/load_gui.cpp @@ -25,6 +25,7 @@ extern "C" { #include "gui/iguispinbox.hpp" #include "gui/iguitreeview.hpp" #include "gui/iguicombobox.hpp" +#include "gui/iguielement.hpp" #include "../callbackhandeler.hpp" #include "guiparts.hpp" @@ -43,6 +44,7 @@ lua_State* tL; int screenwidth(lua_State* L); int screenheight(lua_State* L); +int getroot(lua_State *L); /*** @function gui.scrw() @@ -72,7 +74,12 @@ void load_guifuncs(lua_State* L){ //Various enums lua_newtable(L); + + lua_pushcfunction(L,getroot); + lua_setfield(L,-2,"getroot"); + lua_setglobal(L,"gui"); + iguilabel_register(L); iguicheckbox_register(L); iguiwindow_register(L,device); @@ -90,19 +97,38 @@ void load_guifuncs(lua_State* L){ lua_pushcfunction(L,screenheight); lua_setglobal(L,"scrh"); + + luaL_newmetatable(L, "gui.iguielement");//{m_iguielement} + lua_newtable(L);//{m_iguibutton},{} + luaL_register(L,NULL,iguielement_m); + lua_setfield(L,-2,"__index");//{m_iguielement} + lua_pop(L,1); + } int screenheight(lua_State* L){ - core::rect dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect(); - lua_pushnumber(L,dim.getHeight()); - //printf("Got screen height:%d\n",dim.getWidth()); - return 1; + core::rect dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect(); + lua_pushnumber(L,dim.getHeight()); + //printf("Got screen height:%d\n",dim.getWidth()); + return 1; } int screenwidth(lua_State* L){ - core::rect dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect(); - lua_pushnumber(L,dim.getWidth()); - //printf("Got screen width:%d\n",dim.getWidth()); - return 1; + core::rect dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect(); + lua_pushnumber(L,dim.getWidth()); + //printf("Got screen width:%d\n",dim.getWidth()); + return 1; +} + +//Get the root gui element +int getroot(lua_State* L){ + IGUIElement *ele = device->getGUIEnvironment()->getRootGUIElement(); + lua_newtable(L);//{} + lua_pushlightuserdata(L,ele);//{},ud_iguibutton + lua_setfield(L,-2,"guielement");//{guielement} + luaL_getmetatable(L,"gui.iguielement");//{guielement},{m_iguibutton} + lua_setmetatable(L,-2);//{guielement} + + return 1; } -- cgit v1.2.3-70-g09d2