diff options
| author | Alexander Pickering <alex@cogarr.net> | 2018-08-05 19:46:14 -0400 |
|---|---|---|
| committer | Alexander Pickering <alex@cogarr.net> | 2018-08-05 19:46:14 -0400 |
| commit | 76b44e3d9b2b9f146866ad66154fecdf3cb8dfd4 (patch) | |
| tree | f50af2409c698773005ad3e463d869553e608a46 /src/client/lua_api/gui | |
| parent | 2f814449ff099747e50e13a78503d4ce17920203 (diff) | |
| download | brokengine-76b44e3d9b2b9f146866ad66154fecdf3cb8dfd4.tar.gz brokengine-76b44e3d9b2b9f146866ad66154fecdf3cb8dfd4.tar.bz2 brokengine-76b44e3d9b2b9f146866ad66154fecdf3cb8dfd4.zip | |
Buttons can be parrented to elements
Diffstat (limited to 'src/client/lua_api/gui')
| -rw-r--r-- | src/client/lua_api/gui/iguibutton.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/client/lua_api/gui/iguibutton.cpp b/src/client/lua_api/gui/iguibutton.cpp index 2d04fd1..0e16ef6 100644 --- a/src/client/lua_api/gui/iguibutton.cpp +++ b/src/client/lua_api/gui/iguibutton.cpp @@ -30,31 +30,33 @@ static int newiguibutton(lua_State* L){ int nargs = lua_gettop(L); IGUIElement* parent = NULL; - if(nargs == 4){ + if(nargs == 3){ + lua_getfield(L,-1,"guielement"); parent = (IGUIElement*)lua_touserdata(L,-1); - lua_pop(L,1); + lua_pop(L,2);//{{sx,sy},{ex,ey}},"text" } - - const char* label_c = lua_tostring(L,-1); - const wchar_t* label_w = irr::core::stringw(label_c).c_str(); - lua_pop(L,1); - + const char* label_c = lua_tostring(L,-1);//{{sx,sy},{ex,ey}},"text" + const wchar_t* label_w = irr::core::stringw(label_c).c_str();//{{sx,sy},{ex,ey}},"text" + lua_pop(L,1);//{{sx,sy},{ex,ey}} + printf("Created title\n"); long sx,sy,ex,ey; - poprecti(L,&sx,&sy,&ex,&ey); + poprecti(L,&sx,&sy,&ex,&ey);// + printf("Got coords\n"); rect<s32> dim = rect<s32>(sx,sy,ex,ey); IGUIEnvironment* env = device->getGUIEnvironment(); - IGUIButton* but = env->addButton(dim,parent,-2,label_w,L""); + IGUIButton* but = env->addButton(dim,parent,-1,label_w,L""); + printf("Added button\n"); lua_newtable(L);//{} lua_pushlightuserdata(L,but);//{},ud_iguibutton lua_setfield(L,-2,"guielement");//{guielement} luaL_getmetatable(L,"gui.iguibutton");//{guielement},{m_iguibutton} lua_setmetatable(L,-2);//{guielement} + printf("Created lua representation\n"); setelementcallback(L,EGET_BUTTON_CLICKED,"onClicked");// - printf("Finished registering callback\n"); return 1; |
