diff options
author | rubenwardy <rw@rubenwardy.com> | 2019-03-05 07:12:58 +0000 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2019-03-05 08:12:58 +0100 |
commit | 5d2624ab8271b490ed5c5eda8ca1e3ea677eadcc (patch) | |
tree | 09436ff01196bfe767a798dcdf5b59c335667b4e /src/script/lua_api | |
parent | b5defcffba12dbbcd70676ed4626929761e25620 (diff) | |
download | minetest-5d2624ab8271b490ed5c5eda8ca1e3ea677eadcc.tar.gz minetest-5d2624ab8271b490ed5c5eda8ca1e3ea677eadcc.tar.bz2 minetest-5d2624ab8271b490ed5c5eda8ca1e3ea677eadcc.zip |
Hide uninstall package button on unmodifiable paths (#8255)
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_mainmenu.cpp | 12 | ||||
-rw-r--r-- | src/script/lua_api/l_mainmenu.h | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 2557f448a..2094da241 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -867,6 +867,16 @@ bool ModApiMainMenu::mayModifyPath(const std::string &path) return false; } + +/******************************************************************************/ +int ModApiMainMenu::l_may_modify_path(lua_State *L) +{ + const char *target = luaL_checkstring(L, 1); + std::string absolute_destination = fs::RemoveRelativePathComponents(target); + lua_pushboolean(L, ModApiMainMenu::mayModifyPath(absolute_destination)); + return 1; +} + /******************************************************************************/ int ModApiMainMenu::l_show_path_select_dialog(lua_State *L) { @@ -1057,6 +1067,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top) API_FCT(delete_dir); API_FCT(copy_dir); API_FCT(extract_zip); + API_FCT(may_modify_path); API_FCT(get_mainmenu_path); API_FCT(show_path_select_dialog); API_FCT(download_file); @@ -1086,6 +1097,7 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top) API_FCT(delete_dir); API_FCT(copy_dir); //API_FCT(extract_zip); //TODO remove dependency to GuiEngine + API_FCT(may_modify_path); API_FCT(download_file); //API_FCT(gettext); (gettext lib isn't threadsafe) } diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h index 4a664359a..9ff822960 100644 --- a/src/script/lua_api/l_mainmenu.h +++ b/src/script/lua_api/l_mainmenu.h @@ -130,6 +130,8 @@ private: static int l_extract_zip(lua_State *L); + static int l_may_modify_path(lua_State *L); + static int l_download_file(lua_State *L); static int l_get_video_drivers(lua_State *L); |