diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-12-26 00:57:52 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-12-26 00:57:52 -0500 |
| commit | 35b7c646fd7f80b64c1ef49b6d81f9df9bc1b940 (patch) | |
| tree | d345f620b51ae1ad1d7923e572a6b07ed8731ee5 /src/client/lua_api/gui/iguicheckbox.cpp | |
| parent | cc12503339004bae2f945e7f7339fc845b2a194f (diff) | |
| download | brokengine-35b7c646fd7f80b64c1ef49b6d81f9df9bc1b940.tar.gz brokengine-35b7c646fd7f80b64c1ef49b6d81f9df9bc1b940.tar.bz2 brokengine-35b7c646fd7f80b64c1ef49b6d81f9df9bc1b940.zip | |
Major update
Diffstat (limited to 'src/client/lua_api/gui/iguicheckbox.cpp')
| -rw-r--r-- | src/client/lua_api/gui/iguicheckbox.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/client/lua_api/gui/iguicheckbox.cpp b/src/client/lua_api/gui/iguicheckbox.cpp new file mode 100644 index 0000000..c6e5955 --- /dev/null +++ b/src/client/lua_api/gui/iguicheckbox.cpp @@ -0,0 +1,55 @@ +/*This file defines some things that all igui stuff can do*/ +extern "C" { + #include <lua.h> + #include <lauxlib.h> + #include <lualib.h> +} +#include <irrlicht.h> +#include "../guiparts.hpp" +#include "iguielement.hpp" +#include "../../../shared/lua_api/common.h" + +using namespace irr; +using namespace core; + +extern IrrlichtDevice* device; + +//new({startx,starty},{endx,endy},"checkbox_name",parent) +int newiguicheckbox(lua_State* L){ + int parentid = lua_tointeger(L,-1); + lua_pop(L,1);//{startx,starty},{endx,endy},"checkbox_name" + const char* text = lua_tostring(L,-1); + int tlen = strlen(text); + lua_pop(L,1);//{startx,starty},{endx,endy} + long startx,starty,endx,endy; + popvector2i(L,&endx,&endy);//{startx,starty} + popvector2i(L,&startx, &starty);// + irr::gui::IGUICheckBox* cb = device->getGUIEnvironment()->addCheckBox(false,core::rect<int>(startx,starty,endx,endy),0,-1,stringw(text).c_str()); + lua_pushlightuserdata(L,cb);//*checkbox + luaL_getmetatable(L,"gui.checkbox");//*checkbox,m{gui.checkbox} + lua_setmetatable(L,-2);//*checkbox + + return 1; +} + +static const luaL_reg iguicheckbox_m[] = { + {"move", moveiguielement}, + {"setText", setiguitext}, + {"remove", guisethandeler}, + {0,0}, +}; + +int iguicheckbox_register(lua_State* L){// + + luaL_newmetatable(L,"gui.checkbox");//m{gui.checkbox} + luaL_register(L,NULL,iguicheckbox_m); + lua_pop(L,1);// + + lua_getglobal(L,"gui");//{gui} + lua_pushstring(L,"newcheckbox");//{gui},new(),"newcheckbox" + lua_pushcfunction(L,newiguicheckbox);//{gui},new() + printf("I have registered the newcheckbox function\n"); + lua_settable(L,-3);//{gui} + lua_pop(L,1); + return 0; +} |
