diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/lua_api/gui/iguibutton.cpp | 12 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguielement.cpp | 8 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguifiledialog.cpp | 10 |
3 files changed, 13 insertions, 17 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; } diff --git a/src/client/lua_api/gui/iguielement.cpp b/src/client/lua_api/gui/iguielement.cpp index e63d986..7132441 100644 --- a/src/client/lua_api/gui/iguielement.cpp +++ b/src/client/lua_api/gui/iguielement.cpp @@ -95,9 +95,11 @@ int getiguitext(lua_State* L){ irr::gui::IGUIElement *el = (IGUIElement*)lua_touserdata(L,-1); lua_pop(L,2);// const wchar_t *t = el->getText(); - size_t strlen = wcslen(t); - char output[strlen]; - wcstombs(output,t,strlen); + size_t cstrlen = wcslen(t); + __mingw_printf("In gui get text, cstrlen is %zu\n",cstrlen); + char output[cstrlen + 1];//+1 for \0 + wcstombs(output,t,cstrlen); + output[cstrlen] = '\0'; lua_pushstring(L,output);//"str" return 1; } diff --git a/src/client/lua_api/gui/iguifiledialog.cpp b/src/client/lua_api/gui/iguifiledialog.cpp index c277ce4..ad95b13 100644 --- a/src/client/lua_api/gui/iguifiledialog.cpp +++ b/src/client/lua_api/gui/iguifiledialog.cpp @@ -57,10 +57,6 @@ static int newfileopendialog(lua_State* L){ const char *pathc = lua_tostring(L,-1);//"title","path" lua_pop(L,1);//"title" path = (io::path::char_type*)pathc; - //size_t pathcslen = strlen(pathc); - //path = (wchar_t*)malloc(sizeof(wchar_t) * (pathcslen + 1));// +1 for null - //mbstowcs(path,pathc,pathcslen); - //path[pathcslen] = L'\0'; } if(nargs > 0){ const char *titlec = lua_tostring(L,-1); @@ -74,18 +70,18 @@ static int newfileopendialog(lua_State* L){ IGUIEnvironment *env = device->getGUIEnvironment(); IGUIFileOpenDialog *but = env->addFileOpenDialog(title,modal,parent,-1,false,path); - printf("Added file open dialog\n"); + //printf("Added file open dialog\n"); lua_newtable(L);//{} lua_pushlightuserdata(L,but);//{},ud_iguibutton lua_setfield(L,-2,"guielement");//{guielement} luaL_getmetatable(L,"gui.iguifileopendialog");//{guielement},{m_iguibutton} lua_setmetatable(L,-2);//{guielement} - printf("Created lua representation\n"); + //printf("Created lua representation\n"); setelementcallback(L,EGET_DIRECTORY_SELECTED,"onDirectory");// setelementcallback(L,EGET_FILE_SELECTED,"onFileSelected"); setelementcallback(L,EGET_FILE_CHOOSE_DIALOG_CANCELLED,"onCanceled"); - printf("Finished registering callback\n"); + //printf("Finished registering callback\n"); free(title); free(path); |
