make color of table lines configurable

This commit is contained in:
Sokomine 2023-09-23 23:36:32 +02:00
parent e2ed6263ac
commit 8d0377572d

View File

@ -257,12 +257,12 @@ end
-- small helper function for yl_speak_up.get_fs_manage_quest_steps -- small helper function for yl_speak_up.get_fs_manage_quest_steps
yl_speak_up.quest_step_show_table = function(formspec, table_specs, liste) yl_speak_up.quest_step_show_table = function(formspec, table_specs, liste, color)
table.insert(formspec, "tablecolumns[color;text]table[") table.insert(formspec, "tablecolumns[color;text]table[")
table.insert(formspec, table_specs) table.insert(formspec, table_specs)
local tmp = {} local tmp = {}
for k, v in pairs(liste) do for k, v in pairs(liste) do
table.insert(tmp, "#AAFFAA") table.insert(tmp, color or "#FFFFFF")
table.insert(tmp, minetest.formspec_escape(v)) table.insert(tmp, minetest.formspec_escape(v))
end end
table.insert(formspec, table.concat(tmp, ",")) table.insert(formspec, table.concat(tmp, ","))
@ -272,6 +272,7 @@ end
yl_speak_up.quest_step_show_table_decorated = function(formspec, yl_speak_up.quest_step_show_table_decorated = function(formspec,
label, field_name, liste, start_x, start_y, width, height, label_ident, label, field_name, liste, start_x, start_y, width, height, label_ident,
box_color, column_color,
tooltip_text, add_lines) tooltip_text, add_lines)
local dim_str = tostring(width)..","..tostring(height) local dim_str = tostring(width)..","..tostring(height)
table.insert(formspec, "container[") table.insert(formspec, "container[")
@ -280,7 +281,8 @@ yl_speak_up.quest_step_show_table_decorated = function(formspec,
table.insert(formspec, "]") table.insert(formspec, "]")
table.insert(formspec, "box[0,0;") table.insert(formspec, "box[0,0;")
table.insert(formspec, dim_str) table.insert(formspec, dim_str)
table.insert(formspec, ";#666666") table.insert(formspec, ";")
table.insert(formspec, box_color or "#666666")
table.insert(formspec, "]") table.insert(formspec, "]")
-- add buttons etc. first so that the label remains visible on top -- add buttons etc. first so that the label remains visible on top
if(add_lines) then if(add_lines) then
@ -293,7 +295,7 @@ yl_speak_up.quest_step_show_table_decorated = function(formspec,
table.insert(formspec, "]") table.insert(formspec, "]")
yl_speak_up.quest_step_show_table(formspec, yl_speak_up.quest_step_show_table(formspec,
"0.1,0.7;"..tostring(width-0.2)..","..tostring(height-0.8)..";"..tostring(field_name)..";", "0.1,0.7;"..tostring(width-0.2)..","..tostring(height-0.8)..";"..tostring(field_name)..";",
liste or {}) liste or {}, column_color)
if(tooltip_text and tooltip_text ~= "") then if(tooltip_text and tooltip_text ~= "") then
table.insert(formspec, "tooltip[") table.insert(formspec, "tooltip[")
table.insert(formspec, field_name) table.insert(formspec, field_name)
@ -355,20 +357,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) local lists = yl_speak_up.quest_step_get_start_end_unconnected_lists(step_data)
yl_speak_up.quest_step_show_table_decorated(formspec, yl_speak_up.quest_step_show_table_decorated(formspec,
"Start steps:", "TODO_select_from_start_steps", lists.start_steps, "Start steps:", "TODO_select_from_start_steps", lists.start_steps,
"0.1", "2.7", "5.6", "4.3", 0, "0.1", "2.7", "5.6", "4.3", 0, nil, "#AAFFAA",
"The quest begins with this (or one of these) steps.\n".. "The quest begins with this (or one of these) steps.\n"..
"You need at least one start step.", "You need at least one start step.",
nil) nil)
yl_speak_up.quest_step_show_table_decorated(formspec, yl_speak_up.quest_step_show_table_decorated(formspec,
"Unconnected steps:", "TODO_select_from_unconnected_steps", lists.unconnected_steps, "Unconnected steps:", "TODO_select_from_unconnected_steps", lists.unconnected_steps,
"0.1", "7.0", "5.6", "4.3", 0, "0.1", "7.0", "5.6", "4.3", 0, nil, "#FFAAAA",
"These steps are not used yet. They are not required\n".. "These steps are not used yet. They are not required\n"..
"by any other steps and do not require steps either.\n".. "by any other steps and do not require steps either.\n"..
"Please decide what to do with them!", "Please decide what to do with them!",
nil) nil)
yl_speak_up.quest_step_show_table_decorated(formspec, yl_speak_up.quest_step_show_table_decorated(formspec,
"Quest ends with steps:", "TODO_select_from_end_steps", lists.end_steps, "Quest ends with steps:", "TODO_select_from_end_steps", lists.end_steps,
"24", "2.7", "5.6", "8.5", "0.1", "24", "2.7", "5.6", "8.5", "0.1", nil, "#AAFFAA",
"This quest ends with these steps. They are not required\n".. "This quest ends with these steps. They are not required\n"..
"by any other steps and have no successor.\n".. "by any other steps and have no successor.\n"..
"Your quest needs at least one end step.", "Your quest needs at least one end step.",
@ -397,7 +399,7 @@ yl_speak_up.get_fs_manage_quest_steps = function(player, param)
yl_speak_up.quest_step_show_table_decorated(formspec, yl_speak_up.quest_step_show_table_decorated(formspec,
em("One of").." these quest steps:", "one_step_required", em("One of").." these quest steps:", "one_step_required",
step_data[selected].one_step_required, step_data[selected].one_step_required,
"0.1", "2.7", "5.6", "4.3", 0, "0.1", "2.7", "5.6", "4.3", 0, nil, "#AAFFAA",
"At least "..em("one of").." these previous quest steps listed here has to be\n".. "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".. "achieved by the player who is trying to solve this quest.\n"..
"Only then can the player try to achieve this current quest\n".. "Only then can the player try to achieve this current quest\n"..
@ -411,7 +413,7 @@ yl_speak_up.get_fs_manage_quest_steps = function(player, param)
yl_speak_up.quest_step_show_table_decorated(formspec, yl_speak_up.quest_step_show_table_decorated(formspec,
em("All of").." these quest steps:", "all_steps_required", em("All of").." these quest steps:", "all_steps_required",
step_data[selected].all_steps_required, step_data[selected].all_steps_required,
"0.1", "7.0", "5.6", "4.3", 0, "0.1", "7.0", "5.6", "4.3", 0, nil, "#AAFFAA",
"Sometimes there may not be a particular order in which\n".. "Sometimes there may not be a particular order in which\n"..
"quest steps ought to be solved. Imagine for example getting\n".. "quest steps ought to be solved. Imagine for example getting\n"..
"indigrents for a cake and delivering them to an NPC.\n".. "indigrents for a cake and delivering them to an NPC.\n"..
@ -459,7 +461,7 @@ yl_speak_up.get_fs_manage_quest_steps = function(player, param)
"get these quest step(s) "..em("next")..":", "next_steps_show", "get these quest step(s) "..em("next")..":", "next_steps_show",
required_for, required_for,
-- the label needs to be moved slightly to the right to make room for the > button -- 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", "0.4", "2.7", "5.6", "8.5", "0.1", nil, "#AAFFAA",
"Once the current quest step has been achieved by the\n".. "Once the current quest step has been achieved by the\n"..
"player, the player can strive to achieve these next\n".. "player, the player can strive to achieve these next\n"..
"quest step(s).\n".. "quest step(s).\n"..