Improve delete world dialog

master
MoNTE48 2021-11-17 03:12:33 +02:00
parent 667f1f2a2e
commit 34d0166af9
1 changed files with 6 additions and 23 deletions

View File

@ -16,21 +16,20 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local b = core.formspec_escape(defaulttexturedir .. "blank.png")
local function delete_world_formspec(dialogdata)
local game_name = dialogdata.delete_game
local delete_game = (game_name and " [" .. game_name .. "]") or ""
local delete_name = dialogdata.delete_name
if game_name then
delete_name = delete_name .. " (" .. game_name .. ")"
end
local retval =
"size[12,4,false]" ..
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]" ..
"image_button[3,0.4;6,0.6;" .. b .. ";;" .. fgettext("Delete World") ..
"image_button[2,0.5;8,2;" .. core.formspec_escape(defaulttexturedir ..
"blank.png") .. ";;" .. fgettext("Delete World \"$1\"?", delete_name) ..
";true;false;]" ..
"image_button[3,1;6,0.6;" .. b .. ";;" ..
fgettext("\"$1$2", dialogdata.delete_name, delete_game) ..
"\"?;true;false;]" ..
"image_button[3,0.4;6,1.25;" .. b .. ";;;true;false;]" ..
"style[world_delete_confirm;bgcolor=red]" ..
"button[3.5,2.8;2.5,0.5;world_delete_confirm;" .. fgettext("Delete") .. "]" ..
"button[6,2.8;2.5,0.5;world_delete_cancel;" .. fgettext("Cancel") .. "]"
@ -39,12 +38,6 @@ end
local function delete_world_buttonhandler(this, fields)
if fields["world_delete_confirm"] then
if this.data.callback then
this:delete()
this.data.callback()
return true
end
if this.data.delete_index > 0 and
this.data.delete_index <= #menudata.worldlist:get_raw_list() then
core.delete_world(this.data.delete_index)
@ -77,13 +70,3 @@ function create_delete_world_dlg(name_to_del, index_to_del, game_to_del)
return retval
end
function create_custom_delete_dlg(name_to_del, callback)
assert(name_to_del ~= nil and type(name_to_del) == "string" and name_to_del ~= "")
assert(type(callback) == "function")
local retval = create_delete_world_dlg(name_to_del, -1, nil)
retval.data.callback = callback
return retval
end