From c38d5eca7091fc7f0206ed0c746622022b2ae508 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 10 Sep 2018 23:11:08 -0400 Subject: Added documentation Also added treeview guielemnt Also added ifilesystem guielement Also added io library --- src/client/lua_api/gui/iguifiledialog.cpp | 34 +++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'src/client/lua_api/gui/iguifiledialog.cpp') diff --git a/src/client/lua_api/gui/iguifiledialog.cpp b/src/client/lua_api/gui/iguifiledialog.cpp index ad95b13..6303230 100644 --- a/src/client/lua_api/gui/iguifiledialog.cpp +++ b/src/client/lua_api/gui/iguifiledialog.cpp @@ -29,11 +29,11 @@ extern IrrlichtDevice* device; /*** @function newfileopendialog() Creates a new dialog to open a file -@tparam title string The rectangle to place the button at. If the box has a parent, +@tparam ?string title The rectangle to place the button at. If the box has a parent, it is offset from the upper-left of the parent element. -@tparam path string The path to open the file dialog to -@tparam parent (iguielement | nil) parent The parent element of the button. -@tparam modal boolean If other gui elements can be interacted with before this element is closed +@tparam ?string path The path to open the file dialog to +@tparam ?iguielement parent The parent element of the button. +@tparam ?boolean modal If other gui elements can be interacted with before this element is closed @treturn iguifileopendialog The button element */ //gui.newfileopendialog(["title"][,"path"][,parent][,modal]) @@ -88,12 +88,38 @@ static int newfileopendialog(lua_State* L){ return 1; } +//{fileopendialog} -> "dir" +int getdir(lua_State *L){ + lua_getfield(L,-1,"guielement");//{fileopendialog},ud_fileopendialog + IGUIFileOpenDialog *f = (IGUIFileOpenDialog*)lua_touserdata(L,-1); + lua_pop(L,2); + const char *dname = f->getDirectoryName().c_str(); + lua_pushstring(L,dname); + return 1; +} + +//{fileopendialog} -> "name" +int getname(lua_State *L){ + lua_getfield(L, -1, "guielement");//{fileopendialog},ud_fileopendialog + IGUIFileOpenDialog *f = (IGUIFileOpenDialog*)lua_touserdata(L,-1); + lua_pop(L,2);// + const wchar_t *name_w = f->getFileName(); + size_t slen = wcslen(name_w); + char name_c[slen + 1]; // + 1 for null + wcstombs(name_c,name_w,slen); + name_c[slen] = '\0'; + lua_pushstring(L,name_c); + return 1; +} + static const luaL_reg iguifileopendialog_f[] = { {"new", newfileopendialog}, {0,0}, }; static const luaL_reg iguifileopendialog_m[] = { + {"getdir", getdir}, + {"getname", getname}, {0,0}, }; -- cgit v1.2.3-70-g09d2