From e2ed6263ac0add43c598e7b34b62a1a5b2c38eef Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sat, 23 Sep 2023 23:14:43 +0200 Subject: [PATCH] make more use of yl_speak_up.quest_step_show_table_decorated --- fs_manage_quest_steps.lua | 114 +++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 58 deletions(-) diff --git a/fs_manage_quest_steps.lua b/fs_manage_quest_steps.lua index 346a71f..a20bdb4 100644 --- a/fs_manage_quest_steps.lua +++ b/fs_manage_quest_steps.lua @@ -271,7 +271,8 @@ end yl_speak_up.quest_step_show_table_decorated = function(formspec, - label, field_name, liste, start_x, start_y, width, height, tooltip_text, add_lines) + label, field_name, liste, start_x, start_y, width, height, label_ident, + tooltip_text, add_lines) local dim_str = tostring(width)..","..tostring(height) table.insert(formspec, "container[") table.insert(formspec, tostring(start_x)..","..tostring(start_y)..";") @@ -281,12 +282,18 @@ yl_speak_up.quest_step_show_table_decorated = function(formspec, table.insert(formspec, dim_str) table.insert(formspec, ";#666666") table.insert(formspec, "]") - table.insert(formspec, "label[0.1,0.5;") + -- add buttons etc. first so that the label remains visible on top + if(add_lines) then + table.insert(formspec, add_lines) + end + table.insert(formspec, "label[") + table.insert(formspec, tostring(0.1 + label_ident)) + table.insert(formspec, ",0.5;") table.insert(formspec, label) table.insert(formspec, "]") yl_speak_up.quest_step_show_table(formspec, "0.1,0.7;"..tostring(width-0.2)..","..tostring(height-0.8)..";"..tostring(field_name)..";", - liste) + liste or {}) if(tooltip_text and tooltip_text ~= "") then table.insert(formspec, "tooltip[") table.insert(formspec, field_name) @@ -295,9 +302,6 @@ yl_speak_up.quest_step_show_table_decorated = function(formspec, table.insert(formspec, "\n\nClick on an element to select it.") table.insert(formspec, "]") end - if(add_lines) then - table.insert(formspec, add_lines) - end table.insert(formspec, "container_end[]") end @@ -351,20 +355,20 @@ yl_speak_up.get_fs_manage_quest_steps = function(player, param) local lists = yl_speak_up.quest_step_get_start_end_unconnected_lists(step_data) yl_speak_up.quest_step_show_table_decorated(formspec, "Start steps:", "TODO_select_from_start_steps", lists.start_steps, - "0.1", "2.7", "5.6", "3.5", + "0.1", "2.7", "5.6", "4.3", 0, "The quest begins with this (or one of these) steps.\n".. "You need at least one start step.", nil) yl_speak_up.quest_step_show_table_decorated(formspec, "Unconnected steps:", "TODO_select_from_unconnected_steps", lists.unconnected_steps, - "0.1", "6.2", "5.6", "3.5", + "0.1", "7.0", "5.6", "4.3", 0, "These steps are not used yet. They are not required\n".. "by any other steps and do not require steps either.\n".. "Please decide what to do with them!", nil) yl_speak_up.quest_step_show_table_decorated(formspec, "Quest ends with steps:", "TODO_select_from_end_steps", lists.end_steps, - "23.8", "2.7", "5.6", "7.0", + "24", "2.7", "5.6", "8.5", "0.1", "This quest ends with these steps. They are not required\n".. "by any other steps and have no successor.\n".. "Your quest needs at least one end step.", @@ -386,41 +390,37 @@ yl_speak_up.get_fs_manage_quest_steps = function(player, param) -- left side (previous quest step) table.insert(formspec, "container[0,0;5.8,13.5]".. - "label[0.2,2.0;"..em("Required previous").."]".. - "label[0.2,2.4;quest step(s):]".. - "style[insert_before_next_step,insert_after_prev_step,".. - "add_to_one_needed,add_to_all_needed;bgcolor=blue;textcolor=yellow]".. - "container[0.1,2.7;5.6,10.8]".. - "box[0,0;5.6,8.5;#666666]".. - "button[4.6,0.0;0.94,0.7;add_to_one_needed;Edit]".. - "tooltip[add_to_one_needed;Add or remove a quest step to this list.]".. - "label[0.1,0.5;"..em("One of").." these quest steps:]") - yl_speak_up.quest_step_show_table(formspec, "0.1,0.7;5.4,2.7;one_step_required;", - step_data[selected].one_step_required or {}) - table.insert(formspec, "tooltip[one_step_required;".. - "At least "..em("one of").." these previous quest steps listed ".. "here has to be\n".. - "achieved by the player who is trying to solve this quest.\n".. - "Only then can the player try to achieve this current quest\n".. - "step that you are editing here.\n".. - "If this is empty, then it's usually the/a first step of the quest.\n".. - "If there is one entry, then that entry is the previous quest step.\n".. - "If there are multiple entries, then players have alternate ways\n".. - "to achieve this current quest step here.]") - - table.insert(formspec, "label[0.1,4.0;"..em("All of").." these quest steps:]".. - "button[4.6,3.5;0.94,0.7;add_to_all_needed;Edit]".. - "tooltip[add_to_all_needed;Add or remove a quest step to this list.]") - yl_speak_up.quest_step_show_table(formspec, "0.1,4.2;5.4,4.0;all_steps_required;", - step_data[selected].all_steps_required or {}) - table.insert(formspec, "tooltip[all_steps_required;".. - "Sometimes there may not be a particular order in which\n".. - "quest steps ought to be solved. Imagine for example getting\n".. - "indigrents for a cake and delivering them to an NPC.\n".. - "The quest steps listed here can be done in "..em("any order")..".\n".. - "They have "..em("all").." to be achieved first in order for this current\n".. - "quest step to become available.\n".. - "Usually this list is empty.]".. - "container_end[]") + "label[0.2,2.0;"..em("Required previous").."]".. + "label[0.2,2.4;quest step(s):]".. + "style[insert_before_next_step,insert_after_prev_step,".. + "add_to_one_needed,add_to_all_needed;bgcolor=blue;textcolor=yellow]") + yl_speak_up.quest_step_show_table_decorated(formspec, + em("One of").." these quest steps:", "one_step_required", + step_data[selected].one_step_required, + "0.1", "2.7", "5.6", "4.3", 0, + "At least "..em("one of").." these previous quest steps listed here has to be\n".. + "achieved by the player who is trying to solve this quest.\n".. + "Only then can the player try to achieve this current quest\n".. + "step that you are editing here.\n".. + "If this is empty, then it's usually the/a first step of the quest.\n".. + "If there is one entry, then that entry is the previous quest step.\n".. + "If there are multiple entries, then players have alternate ways\n".. + "to achieve this current quest step here.", + "button[4.6,0.0;0.94,0.7;add_to_one_needed;Edit]".. + "tooltip[add_to_one_needed;Add or remove a quest step to this list.]") + yl_speak_up.quest_step_show_table_decorated(formspec, + em("All of").." these quest steps:", "all_steps_required", + step_data[selected].all_steps_required, + "0.1", "7.0", "5.6", "4.3", 0, + "Sometimes there may not be a particular order in which\n".. + "quest steps ought to be solved. Imagine for example getting\n".. + "indigrents for a cake and delivering them to an NPC.\n".. + "The quest steps listed here can be done in "..em("any order")..".\n".. + "They have "..em("all").." to be achieved first in order for this current\n".. + "quest step to become available.\n".. + "Usually this list is empty.", + "button[4.6,0.0;0.94,0.7;add_to_all_needed;Edit]".. + "tooltip[add_to_all_needed;Add or remove a quest step to this list.]") if( #step_data[selected].one_step_required > 0 or #step_data[selected].all_steps_required > 0) then if( #step_data[selected].one_step_required @@ -454,20 +454,18 @@ yl_speak_up.get_fs_manage_quest_steps = function(player, param) -- right side (next quest step) table.insert(formspec, "container[23.8,0;5.8,13.5]".. "label[0.6,2.0;Achieving this quest step]".. - "label[0.6,2.4;"..em("helps").." the quester to:]".. - "container[0.4,2.7;5.6,10.8]".. - "box[0,0;5.6,8.5;#666666]".. - "label[0.2,0.5;get these quest step(s) "..em("next")..":]") - yl_speak_up.quest_step_show_table(formspec, "0.1,0.7;5.4,7.7;next_steps_show;", - required_for or {}) - table.insert(formspec, "tooltip[next_steps_show;".. - "Once the current quest step has been achieved by the\n".. - "player, the player can strive to achieve these next\n".. - "quest step(s).\n".. - "If this is empty, then it's either the/a last step (quest\n".. - "solved!) - or the quest is not properly set up.]") - table.insert(formspec, "container_end[]") - + "label[0.6,2.4;"..em("helps").." the quester to:]") + yl_speak_up.quest_step_show_table_decorated(formspec, + "get these quest step(s) "..em("next")..":", "next_steps_show", + required_for, + -- the label needs to be moved slightly to the right to make room for the > button + "0.4", "2.7", "5.6", "8.5", "0.1", + "Once the current quest step has been achieved by the\n".. + "player, the player can strive to achieve these next\n".. + "quest step(s).\n".. + "If this is empty, then it's either the/a last step (quest\n".. + "solved!) - or the quest is not properly set up.", + nil) if(required_for and #required_for > 0) then if(#required_for > 1) then