broke long formspec strings into table.concat lists (editor/fs)

This commit is contained in:
Sokomine 2024-02-12 13:05:36 +01:00
parent 6de16720e0
commit 94a1d1092a
2 changed files with 45 additions and 24 deletions

View File

@ -98,20 +98,29 @@ yl_speak_up.get_fs_properties = function(pname, selected)
end
local dialog = yl_speak_up.speak_to[pname].dialog
local npc_name = minetest.formspec_escape(dialog.n_npc or "- nameless -")
return "size[12.5,8.5]" ..
"label[2,0;Properties of "..npc_name.." (ID: "..tostring(n_id).."):]"..
"tablecolumns[color,span=1;text;text]"..
"table[0.2,0.5;12,4.0;table_of_properties;"..s..";"..tostring(selected).."]"..
"tooltip[0.2,0.5;12,4.0;"..
"Click on \"add\" to add a new property.\n"..
"Click on the name of a property to change or delete it.]"..
return table.concat({"size[12.5,8.5]",
"label[2,0;Properties of ",
npc_name,
" (ID: ",
tostring(n_id),
"):]",
"tablecolumns[color,span=1;text;text]",
"table[0.2,0.5;12,4.0;table_of_properties;",
s,
";",
tostring(selected),
"]",
"tooltip[0.2,0.5;12,4.0;",
"Click on \"add\" to add a new property.\n",
"Click on the name of a property to change or delete it.]",
"label[2.0,4.5;"..
"Properties are important for NPC that want to make use of generic dialogs.\n"..
"Properties can be used to determine which generic dialog(s) shall apply to\n"..
"this particular NPC and how they shall be configured. You need the\n"..
"\"npc_talk_admin\" priv to edit properties starting with the text \"server\".]"..
"button[5.0,7.8;2.0,0.9;back;Back]"..
"\"npc_talk_admin\" priv to edit properties starting with the text \"server\".]",
"button[5.0,7.8;2.0,0.9;back;Back]",
add_selected
}, "")
end
yl_speak_up.get_fs_properties_wrapper = function(player, param)

View File

@ -104,22 +104,34 @@ yl_speak_up.get_fs_save_or_discard_changes = function(player, param)
text = minetest.formspec_escape(t).."\n"..text
end
-- build a formspec showing the changes to this dialog and ask for save
return "size[14,6.2]"..
"bgcolor[#00000000;false]"..
return table.concat({"size[14,6.2]",
"bgcolor[#00000000;false]",
-- TODO: make this more flexible
"label[0.2,0.2;You are about to leave dialog "..minetest.formspec_escape(d_id)..
" and "..target_name..".]"..
"label[0.2,0.65;These changes have been applied to dialog "..
minetest.formspec_escape(d_id)..":]"..
"hypertext[0.2,1;13.5,4;list_of_changes;<normal>"..
minetest.formspec_escape(text) .. "\n</normal>".."]"..
"button_exit[1.2,5.2;3,0.9;discard_dialog_changes;Discard changes]"..
"button[5.7,5.2;3,0.9;back_to_dialog_changes;Back]"..
"button_exit[10.2,5.2;3,0.9;save_dialog_changes;Save changes]"..
"tooltip[save_dialog_changes;Save all changes to this dialog and "..target_name..".]"..
"tooltip[discard_dialog_changes;Undo all changes and "..target_name..".]"..
"tooltip[back_to_dialog_changes;Go back to dialog "..
minetest.formspec_escape(d_id).." and continue editing it.]"
"label[0.2,0.2;You are about to leave dialog ",
minetest.formspec_escape(d_id),
" and ",
target_name,
".]",
"label[0.2,0.65;These changes have been applied to dialog ",
minetest.formspec_escape(d_id),
":]",
"hypertext[0.2,1;13.5,4;list_of_changes;<normal>",
minetest.formspec_escape(text),
"\n</normal>",
"]",
"button_exit[1.2,5.2;3,0.9;discard_dialog_changes;Discard changes]",
"button[5.7,5.2;3,0.9;back_to_dialog_changes;Back]",
"button_exit[10.2,5.2;3,0.9;save_dialog_changes;Save changes]",
"tooltip[save_dialog_changes;Save all changes to this dialog and ",
target_name,
".]",
"tooltip[discard_dialog_changes;Undo all changes and ",
target_name,
".]",
"tooltip[back_to_dialog_changes;Go back to dialog ",
minetest.formspec_escape(d_id),
" and continue editing it.]"
}, "")
end