aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/gui/iguibutton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/gui/iguibutton.cpp')
-rw-r--r--src/client/lua_api/gui/iguibutton.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/client/lua_api/gui/iguibutton.cpp b/src/client/lua_api/gui/iguibutton.cpp
index 5da3773..fa4370f 100644
--- a/src/client/lua_api/gui/iguibutton.cpp
+++ b/src/client/lua_api/gui/iguibutton.cpp
@@ -38,7 +38,7 @@ it is offset from the upper-left of the parent element.
*/
//gui.newbutton({{sx,sy},{ex,ey}},"text"[,parent])
static int newiguibutton(lua_State* L){
- printf("Createing gui button!\n");
+ //printf("Createing gui button!\n");
int nargs = lua_gettop(L);
IGUIElement* parent = NULL;
@@ -49,27 +49,25 @@ static int newiguibutton(lua_State* L){
}
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"
+ size_t label_c_len = strlen(label_c);
+ wchar_t label_w[label_c_len + 1] = L"";
+ mbstowcs(label_w,label_c,label_c_len);
+ label_w[label_c_len] = L'\0';
lua_pop(L,1);//{{sx,sy},{ex,ey}}
- printf("Created title\n");
long 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,-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;
}