From 24fd2b0df58c31739bd86905bfa7cec051f96b35 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Mon, 26 Jul 2021 21:23:21 +0200 Subject: [PATCH] added a stretch parameter to make the formspec fields in the dropdown menu larger --- formspec_helpers.lua | 13 ++++++++----- fs_initial_config.lua | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/formspec_helpers.lua b/formspec_helpers.lua index 7bf9341..4d5120e 100644 --- a/formspec_helpers.lua +++ b/formspec_helpers.lua @@ -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 diff --git a/fs_initial_config.lua b/fs_initial_config.lua index 2f64e27..76e7265 100644 --- a/fs_initial_config.lua +++ b/fs_initial_config.lua @@ -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"..