2 --Copyright (C) 2014 sapier
4 --This program is free software; you can redistribute it and/or modify
5 --it under the terms of the GNU Lesser General Public License as published by
6 --the Free Software Foundation; either version 2.1 of the License, or
7 --(at your option) any later version.
9 --This program is distributed in the hope that it will be useful,
10 --but WITHOUT ANY WARRANTY; without even the implied warranty of
11 --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 --GNU Lesser General Public License for more details.
14 --You should have received a copy of the GNU Lesser General Public License along
15 --with this program; if not, write to the Free Software Foundation, Inc.,
16 --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 --------------------------------------------------------------------------------
20 local function rename_modpack_formspec(dialogdata)
22 "size[11.5,4.5,true]" ..
23 "button[3.25,3.5;2.5,0.5;dlg_rename_modpack_confirm;"..
24 fgettext("Accept") .. "]" ..
25 "button[5.75,3.5;2.5,0.5;dlg_rename_modpack_cancel;"..
26 fgettext("Cancel") .. "]"
29 if dialogdata.mod.is_name_explicit then
30 retval = retval .. "textarea[1,0.2;10,2;;;" ..
31 fgettext("This modpack has an explicit name given in its modpack.conf " ..
32 "which will override any renaming here.") .. "]"
36 "field[2.5," .. input_y .. ";7,0.5;te_modpack_name;" ..
37 fgettext("Rename Modpack:") .. ";" .. dialogdata.mod.dir_name .. "]"
42 --------------------------------------------------------------------------------
43 local function rename_modpack_buttonhandler(this, fields)
44 if fields["dlg_rename_modpack_confirm"] ~= nil then
45 local oldpath = this.data.mod.path
46 local targetpath = this.data.mod.parent_dir .. DIR_DELIM .. fields["te_modpack_name"]
47 os.rename(oldpath, targetpath)
48 pkgmgr.refresh_globals()
49 pkgmgr.selected_mod = pkgmgr.global_mods:get_current_index(
50 pkgmgr.global_mods:raw_index_by_uid(fields["te_modpack_name"]))
56 if fields["dlg_rename_modpack_cancel"] then
64 --------------------------------------------------------------------------------
65 function create_rename_modpack_dlg(modpack)
67 local retval = dialog_create("dlg_delete_mod",
68 rename_modpack_formspec,
69 rename_modpack_buttonhandler,
71 retval.data.mod = modpack