added Delete button to fs_talkdialog in edit mode

This commit is contained in:
Sokomine 2022-10-09 15:36:44 +02:00
parent ca0a699a3e
commit df621c7435
2 changed files with 16 additions and 1 deletions

View File

@ -156,6 +156,16 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
end
end
-- delete an option directly from the main fs_talkdialog
if(dialog.n_dialogs[d_id].d_options) then
for o_id, o_v in pairs(dialog.n_dialogs[d_id].d_options) do
if(o_id and fields["delete_option_"..o_id]) then
fields["del_option"] = true
fields.o_id = o_id
end
end
end
if(fields[ "del_option"] and fields.o_id and dialog.n_dialogs[d_id].d_options[fields.o_id]) then
local o_id = fields.o_id
-- which dialog to show instead of the deleted one?

View File

@ -539,12 +539,17 @@ yl_speak_up.get_fs_talkdialog_line_in_edit_mode = function(
-- show the actual text for the option
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
"field", tostring(9.9+offset)..","..h..";"..
tostring(field_length)..",0.9",
tostring(field_length-1.2)..",0.9",
"text_option_" .. oid,
";"..minetest.formspec_escape(sb_v.o_text_when_prerequisites_met),
"Edit the text that is displayed on button "..oid..".",
true)
end
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
"button", tostring(9.9+offset+field_length-1.1)..","..h..";1.0,0.9", "delete_option_"..oid,
"Del",
"Delete this option/answer.",
true)
return {h = h, formspec = formspec}
end