diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-11-01 00:28:16 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-11-01 00:28:16 -0400 |
| commit | d2b36e6c65ec8126c0ebc96adb7e011e78a5eacc (patch) | |
| tree | 9e005502ea2c125c90b5011f573f381f84ade0ef /src/client/lua_api/load_gui.cpp | |
| download | brokengine-d2b36e6c65ec8126c0ebc96adb7e011e78a5eacc.tar.gz brokengine-d2b36e6c65ec8126c0ebc96adb7e011e78a5eacc.tar.bz2 brokengine-d2b36e6c65ec8126c0ebc96adb7e011e78a5eacc.zip | |
Initial commit
Diffstat (limited to 'src/client/lua_api/load_gui.cpp')
| -rw-r--r-- | src/client/lua_api/load_gui.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
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 <stdio.h> +#include <stdlib.h> +#include <vector> +#include <map> +extern "C" { + #include <lua.h> + #include <lauxlib.h> + #include <lualib.h> +} +#include <irrlicht.h> + +#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<irr::gui::IGUIElement*,int> iguielements; +IrrlichtDevice* guidevice; +long gui_elenum; +std::vector<irr::gui::IGUIElement*> 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<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; +} |
