aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/load_gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/load_gui.cpp')
-rw-r--r--src/client/lua_api/load_gui.cpp42
1 files changed, 34 insertions, 8 deletions
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<s32> dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect();
- lua_pushnumber(L,dim.getHeight());
- //printf("Got screen height:%d\n",dim.getWidth());
- return 1;
+ core::rect<s32> 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<s32> dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect();
- lua_pushnumber(L,dim.getWidth());
- //printf("Got screen width:%d\n",dim.getWidth());
- return 1;
+ core::rect<s32> 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;
}