aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/gui/iguifiledialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/gui/iguifiledialog.cpp')
-rw-r--r--src/client/lua_api/gui/iguifiledialog.cpp34
1 files changed, 30 insertions, 4 deletions
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},
};