From d2b36e6c65ec8126c0ebc96adb7e011e78a5eacc Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Tue, 1 Nov 2016 00:28:16 -0400 Subject: Initial commit --- src/client/lua_api/load_gui.cpp | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/client/lua_api/load_gui.cpp (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 new file mode 100644 index 0000000..ed7faac --- /dev/null +++ b/src/client/lua_api/load_gui.cpp @@ -0,0 +1,69 @@ +#include +#include +#include +#include +extern "C" { + #include + #include + #include +} +#include + +#include "gui/iguibutton.hpp" +#include "gui/iguilabel.hpp" +#include "../callbackhandeler.hpp" +#include "guiparts.hpp" + +using namespace irr; +using namespace gui; +using namespace core; + +//Things from guiparts.hpp +std::map iguielements; +IrrlichtDevice* guidevice; +long gui_elenum; +std::vector guielements(1); +lua_State* tL; + +int screenwidth(lua_State* L); +int screenheight(lua_State* L); + +void load_guifuncs(lua_State* L, IrrlichtDevice* d){ + tL = L; + guidevice = d; + gui_elenum = 0; + guielements[0] = NULL; + printf("About to initalize guielements vector\n"); + printf("Done initalizeing guilements vector\n"); + + iguibutton_register(L,d); + iguilabel_register(L,d); + lua_pop(L, 1); + + lua_newtable(L); + //lua_pushcfunction(L,createiguibutton); + //lua_setfield(L,-2,"createButton"); + lua_setglobal(L,"gui"); + + lua_pushcfunction(L,screenwidth); + lua_setglobal(L,"scrw"); + + lua_pushcfunction(L,screenheight); + lua_setglobal(L,"scrh"); + +} + + +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; +} + +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; +} -- cgit v1.2.3-70-g09d2