added a stretch parameter to make the formspec fields in the dropdown menu larger

This commit is contained in:
Sokomine 2021-07-26 21:23:21 +02:00
parent f35387fcd0
commit 24fd2b0df5
2 changed files with 9 additions and 6 deletions

View File

@ -5,11 +5,12 @@
-- Note: With the what_is_the_list_about-parameter, it is possible to handle i.e. variables as well
yl_speak_up.create_dropdown_playerlist = function(player, pname,
table_of_names, index_selected,
start_x, start_y, dropdown_name, what_is_the_list_about,
start_x, start_y, stretch_x, dropdown_name, what_is_the_list_about, delete_button_text,
field_name_for_adding_player, explain_add_player,
field_name_for_deleting_player, explain_delete_player)
local text = "dropdown["..tostring(start_x)..","..tostring(start_y)..";3.8;"..
local text = "dropdown["..tostring(start_x)..","..tostring(start_y)..";"..
tostring(3.8 + stretch_x)..";"..
tostring(dropdown_name)..";Add "..tostring(what_is_the_list_about)..":"
-- table_of_names is a table with the playernames as keys
-- we want to work with indices later on; in order to be able to do that reliably, we
@ -25,14 +26,16 @@ yl_speak_up.create_dropdown_playerlist = function(player, pname,
text = text..";"..tostring(index_selected)..";]"
if(index_selected == 1) then
-- first index "Add player" selected? Then offer a field for entering the name
text = text.."field["..tostring(start_x + 4.0)..","..tostring(start_y + 0.3)..";3.5,0.9;"..
text = text.."field["..tostring(start_x + 4.0 + stretch_x)..","..tostring(start_y + 0.3)..
";"..tostring(3.5 + stretch_x)..",0.9;"..
tostring(field_name_for_adding_player)..";;]"..
"tooltip["..tostring(field_name_for_adding_player)..";"..
tostring(explain_add_player).."]"
else
text = text.."button["..tostring(start_x + 3.8)..","..tostring(start_y)..";3.5,0.9;"..
text = text.."button["..tostring(start_x + 3.8 + stretch_x)..","..tostring(start_y)..
";"..tostring(3.5 + stretch_x)..",0.9;"..
tostring(field_name_for_deleting_player)..";"..
"Remove "..tostring(what_is_the_list_about).." from list]"..
tostring(delete_button_text).."]"..
"tooltip["..tostring(field_name_for_deleting_player)..";"..
tostring(explain_delete_player).."]"
end

View File

@ -254,7 +254,7 @@ yl_speak_up.get_fs_initial_config = function(player, n_id, d_id, is_initial_conf
-- offer a dropdown list and a text input field for player names for adding
yl_speak_up.create_dropdown_playerlist(player, pname,
table_of_names, yl_speak_up.speak_to[pname].tmp_index,
2.5, 3.9, "list_may_edit", "player",
2.5, 3.9, 0.0, "list_may_edit", "player", "Remove player from list",
"add_may_edit",
"Enter the name of the player whom you\n"..
"want to grant the right to edit your NPC.\n"..