better visualization in quest step view over where quest steps can be set

This commit is contained in:
Sokomine 2023-10-02 03:48:48 +02:00
parent 7e4bd07109
commit 53c9318cd4
2 changed files with 68 additions and 4 deletions

View File

@ -534,7 +534,7 @@ end
-- describe a location where a quest step can be set; also used by yl_speak_up.fs_manage_quest_steps
yl_speak_up.quest_step_show_where_set = function(pname, formspec, label, n_id, d_id, o_id)
yl_speak_up.quest_step_show_where_set = function(pname, formspec, label, n_id, d_id, o_id, box_color, nr)
if(not(pname)) then
return
end
@ -562,6 +562,29 @@ yl_speak_up.quest_step_show_where_set = function(pname, formspec, label, n_id, d
id_label = "NPC "
end
if(box_color) then
name_txt = name_txt.." ["..tostring(n_id).."]"
table.insert(formspec, "label[0.2,0.2;")
if(nr) then
table.insert(formspec, tostring(nr)..". ")
end
table.insert(formspec, id_label)
table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(name_txt)))
table.insert(formspec, " says in dialog ")
table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(d_id)..":]"))
table.insert(formspec, "]")
table.insert(formspec, "box[1.0,0.4;16,1.8;")
table.insert(formspec, box_color)
table.insert(formspec, "]")
table.insert(formspec, "textarea[1.0,0.4;16,1.8;;;")
table.insert(formspec, minetest.formspec_escape(dialog_txt))
table.insert(formspec, "]")
table.insert(formspec, "label[1.0,2.4;Answer ")
table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(o_id..": ")))
table.insert(formspec, minetest.colorize("#AAAAFF", minetest.formspec_escape(option_txt)))
table.insert(formspec, "]")
return
end
table.insert(formspec, "label[0.2,0;")
table.insert(formspec, label or "which will be set by ")
table.insert(formspec, id_label)
@ -711,7 +734,7 @@ yl_speak_up.get_fs_add_quest_steps = function(player, param)
local d_id = yl_speak_up.speak_to[pname].d_id
local o_id = yl_speak_up.speak_to[pname].o_id
-- describe where in the dialog of the NPC or location this quest step shall be set
yl_speak_up.quest_step_show_where_set(pname, formspec, "which will be set by ", n_id, d_id, o_id)
yl_speak_up.quest_step_show_where_set(pname, formspec, "which will be set by ", n_id, d_id, o_id, nil, nil)
table.insert(formspec, "container_end[]")
y_pos = 7.8

View File

@ -384,13 +384,54 @@ yl_speak_up.get_fs_manage_quest_steps = function(player, param)
-- middle (this quest step)
table.insert(formspec, "container[6,2.7;12,10.8]"..
"label[0.2,0.5;This quest step:]"..
"label[0.2,0.5;This quest step is named:]"..
"box[0.7,0.7;17,0.7;#000000]"..
"label[0.8,1.1;")
table.insert(formspec, minetest.colorize("#AAFFAA", minetest.formspec_escape(selected)))
table.insert(formspec, "]")
table.insert(formspec, "container_end[]")
-- show the locations where this quest step is set
local c = 0
for where_id, d in pairs(step_data[selected].where or {}) do
c = c + 1
end
if(c > 1) then
table.insert(formspec, "label[6.2,4.5;This quest step can be set in diffrent ways (")
table.insert(formspec, tostring(c))
table.insert(formspec, " ways) by:]")
table.insert(formspec, "scrollbaroptions[max=")
table.insert(formspec, tostring((c-1) * 30)) -- 10 units for default 0.1 scroll factor
table.insert(formspec, ";thumbsize=15")
table.insert(formspec, "]")
table.insert(formspec, "scrollbar[23.2,4.7;0.3,4;vertical;scrollbar_where;0.1]")
elseif(c == 1) then
table.insert(formspec, "label[6.2,4.5;This quest step can be set by:]")
else
table.insert(formspec, "label[6.2,4.5;This quest step cannot be set yet.]")
end
table.insert(formspec, "scroll_container[6.2,4.7;17,4;scrollbar_where;vertical;]")
c = 0
for where_id, d in pairs(step_data[selected].where or {}) do
table.insert(formspec, "container[0,")
table.insert(formspec, tostring(0.2 + c * 3.0))
table.insert(formspec, ";17,4]")
table.insert(formspec, "box[0,0;17,2.7;")
if(c%2 == 0) then
table.insert(formspec, "#000000]")
else
table.insert(formspec, "#222222]")
end
-- describe where in the dialog of the NPC or location this quest step shall be set
local s = "This quest step can be set by "
if(c > 0) then
s = "..alternatively, this quest step can be set by "
end
yl_speak_up.quest_step_show_where_set(res.pname, formspec, s, d.n_id, d.d_id, d.o_id,
"#444488", c + 1) --"#513F23", c + 1) --"#a37e45", c + 1)
table.insert(formspec, "container_end[]")
c = c + 1
end
table.insert(formspec, "scroll_container_end[]")
-- left side (previous quest step)
table.insert(formspec, "container[0,0;5.8,13.5]"..