From 2c97dada7b9c7fedc511f1ecf012346c198d92f8 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sat, 11 Aug 2018 08:17:13 -0400 Subject: Various updates Edit boxes can have their contents retreived Fixed a typo for edit box methods various updates to the net api --- src/client/lua_api/gui/iguieditbox.cpp | 14 ++++++++++++++ src/client/lua_api/gui/iguielement.cpp | 27 +++++++++++++++++++++++++++ src/client/lua_api/gui/iguiwindow.cpp | 4 +++- src/client/lua_api/load_gui.cpp | 9 +++++++++ src/client/lua_api/load_video.cpp | 1 + src/client/lua_api/video/iimage.cpp | 2 +- 6 files changed, 55 insertions(+), 2 deletions(-) (limited to 'src/client/lua_api') diff --git a/src/client/lua_api/gui/iguieditbox.cpp b/src/client/lua_api/gui/iguieditbox.cpp index 7b79f34..1ceab1f 100644 --- a/src/client/lua_api/gui/iguieditbox.cpp +++ b/src/client/lua_api/gui/iguieditbox.cpp @@ -61,6 +61,19 @@ static int newiguieditbox(lua_State* L){ return 1; } +//{guieditbox}:getinput() +int getinputtext(lua_State* L){ + lua_getfield(L, -1, "guielement");//{guieditbox},ud_guielement + 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); + lua_pushstring(L,output);//"str" + return 1; +} + static const luaL_reg iguieditbox_f[] = { {"neweditbox",newiguieditbox}, {0,0}, @@ -69,6 +82,7 @@ static const luaL_reg iguieditbox_f[] = { static const luaL_reg iguieditbox_m[] = { {"move", moveiguielement}, {"settext", setiguitext}, + {"getinput", getinputtext}, {"remove", removeiguielement}, {0,0}, }; diff --git a/src/client/lua_api/gui/iguielement.cpp b/src/client/lua_api/gui/iguielement.cpp index fa3d480..5ba998f 100644 --- a/src/client/lua_api/gui/iguielement.cpp +++ b/src/client/lua_api/gui/iguielement.cpp @@ -1,4 +1,9 @@ /*This file defines some things that all igui stuff can do*/ +/*** +@module gui + + +*/ extern "C" { #include #include @@ -15,6 +20,11 @@ using namespace irr; using namespace core; using namespace gui; +/*** +Move a window (by an offset) +@function guielement:move() +@tparam vec2 position The offset to move this element by +*/ //move({element},{x,y}) -> nil int moveiguielement(lua_State* L){ //printf("Got call to move element\n"); @@ -31,6 +41,11 @@ int moveiguielement(lua_State* L){ return 0; } +/*** +Find the rectangle that an element occupies +@function guielement:getabsrect() +@treturn rect The rectangle that this element occupies +*/ //getabsrect({element})-> {{sx,sy},{ex,ey}} int getiguiclippingrect(lua_State* L){ printf("Getting iguiclipping elemnt\n"); @@ -48,6 +63,14 @@ int getiguiclippingrect(lua_State* L){ return 1; } +/*** +Sets the text of the element +This function may do different things to different gui elements. +For example, on a window, it sets the title. +On a button, it sets the button's text. +@function guielement:settext() +@tparam string text The text to set on the element +*/ //setText({guielement},"text") :: nil int setiguitext(lua_State* L){ const char* text = lua_tostring(L, -1); @@ -63,6 +86,10 @@ int setiguitext(lua_State* L){ return 0; } +/*** +Removes a gui element, and any child elements +@function guielement:remove() +*/ //remove({self}) int removeiguielement(lua_State* L){ lua_getfield(L,-1,"guielement"); diff --git a/src/client/lua_api/gui/iguiwindow.cpp b/src/client/lua_api/gui/iguiwindow.cpp index e5c3193..3fbd5e4 100644 --- a/src/client/lua_api/gui/iguiwindow.cpp +++ b/src/client/lua_api/gui/iguiwindow.cpp @@ -76,8 +76,10 @@ static const luaL_reg iguiwindow_m[] = { }; int iguiwindow_register(lua_State* L, IrrlichtDevice* d){ - luaL_newmetatable(L,"gui.window");//m{gui.checkbox} + luaL_newmetatable(L,"gui.window");//m{gui.window} + lua_newtable(L); luaL_register(L,NULL,iguiwindow_m); + lua_setfield(L,-2,"__index"); lua_pop(L,1);// lua_getglobal(L,"gui"); diff --git a/src/client/lua_api/load_gui.cpp b/src/client/lua_api/load_gui.cpp index 4ad5438..5b580bf 100644 --- a/src/client/lua_api/load_gui.cpp +++ b/src/client/lua_api/load_gui.cpp @@ -40,6 +40,15 @@ lua_State* tL; int screenwidth(lua_State* L); int screenheight(lua_State* L); +/*** +@function gui.scrw() +@treturn number The width of the screen +*/ + +/*** +@function gui.scrh() +@treturn number The height of the screen +*/ void load_guifuncs(lua_State* L){ printf("Started loading gui...\n"); tL = L; diff --git a/src/client/lua_api/load_video.cpp b/src/client/lua_api/load_video.cpp index bd07e97..607759c 100644 --- a/src/client/lua_api/load_video.cpp +++ b/src/client/lua_api/load_video.cpp @@ -18,6 +18,7 @@ using namespace core; extern IrrlichtDevice* device; extern IVideoDriver* driver; +//video.drawtexture //{texture},{x,y} //{texture},{x,y},{sourcerect},,{color},use_alpha int draw2dimage(lua_State* L){ diff --git a/src/client/lua_api/video/iimage.cpp b/src/client/lua_api/video/iimage.cpp index 9fb6ec2..1009ea0 100644 --- a/src/client/lua_api/video/iimage.cpp +++ b/src/client/lua_api/video/iimage.cpp @@ -35,7 +35,7 @@ int newiimagefromfile(lua_State* L){ lua_pop(L,1); int numloaders = driver->getImageLoaderCount(); bool hasloaded = false; - IImage* img; + IImage* img = NULL; for(int j = 0; j < numloaders; j++){ IImageLoader* loader = driver->getImageLoader(j); io::IReadFile* f = device->getFileSystem()->createAndOpenFile(strpath); -- cgit v1.2.3-70-g09d2