From 26e2eb019afa60c66c4dc89cf24bbf5b25c6a383 Mon Sep 17 00:00:00 2001 From: red-001 Date: Sun, 11 Jun 2017 08:43:31 +0100 Subject: 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 --- src/script/lua_api/l_mainmenu.cpp | 10 ++++++---- src/script/lua_api/l_mainmenu.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/script') 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); -- cgit v1.2.3