mirror of
https://github.com/minetest/minetest.git
synced 2024-12-28 00:47:29 +01:00
Hide uninstall package button on unmodifiable paths (#8255)
This commit is contained in:
parent
b5defcffba
commit
5d2624ab82
@ -134,9 +134,13 @@ local function get_formspec(tabview, name, tabdata)
|
||||
end
|
||||
|
||||
retval = retval .. "textarea[5.85,2.2;6.35,2.9;;" ..
|
||||
fgettext("Information:") .. ";" .. desc .. "]" ..
|
||||
"button[5.5,4.65;3.25,1;btn_mod_mgr_delete_mod;" ..
|
||||
fgettext("Uninstall Package") .. "]"
|
||||
fgettext("Information:") .. ";" .. desc .. "]"
|
||||
|
||||
if core.may_modify_path(selected_pkg.path) then
|
||||
retval = retval ..
|
||||
"button[5.5,4.65;3.25,1;btn_mod_mgr_delete_mod;" ..
|
||||
fgettext("Uninstall Package") .. "]"
|
||||
end
|
||||
end
|
||||
return retval
|
||||
end
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user