extern "C" { #include #include #include } #include #include "../guiparts.hpp" #include "iguielement.hpp" #include /*** @module gui */ using namespace irr; using namespace gui; using namespace core; extern IrrlichtDevice* device; /*** @function newcheckbox() Creates a new checkbox @tparam dimensions rect The rectangle to place the box at. If the box has a parent, it is offset from the upper-left of the parent element. @tparam parent (iguielement | nil) parent The parent element of the edit box @tparam default_text (string | nil) default_text The default text to have in the edit box @treturn iguieditbox The edit box element */ //new({startx,starty},{endx,endy},"checkbox_name"[,ud_parent]) int newiguicheckbox(lua_State* L){ IGUIElement* par = NULL; int nargs = lua_gettop(L); if(nargs == 3){ lua_getfield(L,-1,"guielement");//{{sx,sy},{ex,ey}},"label",{parent},ud_parent par = (IGUIElement*)lua_touserdata(L,-1); lua_pop(L,2);//{{sx,sy},{ex,ey}},"chekboxname" } const char* text = lua_tostring(L,-1);//{{sx,sy},{ex,ey}},"label" //int tlen = strlen(text); lua_pop(L,1);//{startx,starty},{endx,endy} long startx,starty,endx,endy; poprecti(L,&startx,&starty,&endx,&endy); irr::gui::IGUICheckBox* cb = device->getGUIEnvironment()->addCheckBox(false,core::rect(startx,starty,endx,endy),par,-1,stringw(text).c_str()); lua_newtable(L);//{} lua_pushlightuserdata(L,cb);//*checkbox lua_setfield(L,-2,"guielement");//{checkbox} luaL_getmetatable(L,"gui.checkbox");//{checkbox},m{gui.checkbox} lua_setmetatable(L,-2);//{checkbox} return 1; } static const luaL_reg iguicheckbox_m[] = { {0,0}, }; int iguicheckbox_register(lua_State* L){// luaL_newmetatable(L,"gui.checkbox");//m{gui.checkbox} lua_newtable(L); luaL_register(L,NULL,iguielement_m); luaL_register(L,NULL,iguicheckbox_m); lua_setfield(L,-2,"__index"); lua_pop(L,1);// lua_getglobal(L,"gui");//{gui} lua_pushstring(L,"newcheckbox");//{gui},new(),"newcheckbox" lua_pushcfunction(L,newiguicheckbox);//{gui},new() lua_settable(L,-3);//{gui} lua_pop(L,1); return 0; }