aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorred-001 <red-001@outlook.ie>2017-06-11 08:43:31 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-06-11 09:43:31 +0200
commit26e2eb019afa60c66c4dc89cf24bbf5b25c6a383 (patch)
treea2ac098a32d4b7c97775c9161a29b12ec54e3fad /src/script/lua_api
parent6c5e5e202394ce8063e3c2d9b663145bc4f8efce (diff)
downloadminetest-26e2eb019afa60c66c4dc89cf24bbf5b25c6a383.tar.gz
minetest-26e2eb019afa60c66c4dc89cf24bbf5b25c6a383.tar.bz2
minetest-26e2eb019afa60c66c4dc89cf24bbf5b25c6a383.zip
Improve the path select GUI (#5852)
- Allow lua to chose whatever directories or files can be selected - Fix selecting directories - Rename dialog to `guiPathSelectMenu` from `guiFileSelectMenu` - Rename lua function for opening the menu from `show_file_open_dialog` to `show_path_select_dialog` - Remove duplicate code and fix code style. Related changes - fix `clang-format` whitelist. - Regenerate minetest.conf.example
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_mainmenu.cpp10
-rw-r--r--src/script/lua_api/l_mainmenu.h2
2 files changed, 7 insertions, 5 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 388971814..3ed2ba0e0 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiEngine.h"
#include "guiMainMenu.h"
#include "guiKeyChangeMenu.h"
-#include "guiFileSelectMenu.h"
+#include "guiPathSelectMenu.h"
#include "subgame.h"
#include "version.h"
#include "porting.h"
@@ -950,13 +950,14 @@ bool ModApiMainMenu::isMinetestPath(std::string path)
}
/******************************************************************************/
-int ModApiMainMenu::l_show_file_open_dialog(lua_State *L)
+int ModApiMainMenu::l_show_path_select_dialog(lua_State *L)
{
GUIEngine* engine = getGuiEngine(L);
sanity_check(engine != NULL);
const char *formname= luaL_checkstring(L, 1);
const char *title = luaL_checkstring(L, 2);
+ bool is_file_select = lua_toboolean(L, 3);
GUIFileSelectMenu* fileOpenMenu =
new GUIFileSelectMenu(engine->m_device->getGUIEnvironment(),
@@ -964,7 +965,8 @@ int ModApiMainMenu::l_show_file_open_dialog(lua_State *L)
-1,
engine->m_menumanager,
title,
- formname);
+ formname,
+ is_file_select);
fileOpenMenu->setTextDest(engine->m_buttonhandler);
fileOpenMenu->drop();
return 0;
@@ -1138,7 +1140,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
API_FCT(copy_dir);
API_FCT(extract_zip);
API_FCT(get_mainmenu_path);
- API_FCT(show_file_open_dialog);
+ API_FCT(show_path_select_dialog);
API_FCT(download_file);
API_FCT(get_modstore_details);
API_FCT(get_modstore_list);
diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h
index b5015add3..1d3e931e1 100644
--- a/src/script/lua_api/l_mainmenu.h
+++ b/src/script/lua_api/l_mainmenu.h
@@ -86,7 +86,7 @@ private:
static int l_show_keys_menu(lua_State *L);
- static int l_show_file_open_dialog(lua_State *L);
+ static int l_show_path_select_dialog(lua_State *L);
static int l_set_topleft_text(lua_State *L);