mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-21 22:58:03 +02:00
made use of tabheader and container as formspec elements
This commit is contained in:
parent
17544df2a1
commit
2071a45f3d
@ -19,12 +19,12 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields)
|
||||
local n_dialog = dialog.n_dialogs[d_id]
|
||||
local d_option = n_dialog.d_options[o_id]
|
||||
|
||||
if(fields.button_show_if_action_failed) then
|
||||
if(fields.switch_tab and fields.switch_tab == "2") then
|
||||
yl_speak_up.show_fs(player, "edit_option_dialog",
|
||||
{n_id = n_id, d_id = d_id, o_id = o_id,
|
||||
caller="show_if_action_failed"})
|
||||
return
|
||||
elseif(fields.button_show_if_action_succeeded) then
|
||||
elseif(fields.switch_tab and fields.switch_tab == "1") then
|
||||
yl_speak_up.show_fs(player, "edit_option_dialog",
|
||||
{n_id = n_id, d_id = d_id, o_id = o_id,
|
||||
caller="show_if_action_succeeded"})
|
||||
@ -277,15 +277,16 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id, calle
|
||||
local o_found = o_id
|
||||
local anz_options = 0
|
||||
for i, o in ipairs(sorted_list) do
|
||||
-- the buttons are inside a container; thus, Y is 0.0
|
||||
if(o == o_id and sorted_list[ i-1 ]) then
|
||||
button_prev = ""..
|
||||
"button[7.9,18.7;2.0,0.9;edit_option_prev;Prev]"..
|
||||
"button[7.9,0.0;2.0,0.9;edit_option_prev;Prev]"..
|
||||
"tooltip[edit_option_prev;Go to previous option/answer "..
|
||||
"(according to o_sort).]"
|
||||
end
|
||||
if(o == o_id and sorted_list[ i+1 ]) then
|
||||
button_next = ""..
|
||||
"button[12.5,18.7;2.0,0.9;edit_option_next;Next]"..
|
||||
"button[12.5,0.0;2.0,0.9;edit_option_next;Next]"..
|
||||
"tooltip[edit_option_next;Go to next option/answer "..
|
||||
"(according to o_sort).]"
|
||||
end
|
||||
@ -294,165 +295,204 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id, calle
|
||||
|
||||
-- less than yl_speak_up.max_number_of_options_per_dialog options?
|
||||
local button_add = ""..
|
||||
"button[2.4,18.7;2.0,0.9;add_option;Add]"..
|
||||
-- the buttons are inside a container; thus, Y is 0.0
|
||||
"button[2.4,0.0;2.0,0.9;add_option;Add]"..
|
||||
"tooltip[add_option;Add a new option/answer to this dialog.]"
|
||||
if(anz_options >= yl_speak_up.max_number_of_options_per_dialog) then
|
||||
button_add = ""
|
||||
end
|
||||
|
||||
local action_text = "label[0.2,12.1;"..
|
||||
"If the player completed the above action successfully, "..
|
||||
"apply the following (Ef)fects:]"..
|
||||
"button[17.0,11.7;4.0,0.7;button_show_if_action_failed;Show if it failed]"..
|
||||
"tooltip[button_show_if_action_failed;Click here to see what will happen "..
|
||||
"if the player\nfailed to execute the action successfully.]"
|
||||
if(count_actions == 0) then
|
||||
action_text = "label[0.2,12.1;"..
|
||||
"There is no (A)ction defined. Directly apply the following (Ef)fects:]"
|
||||
end
|
||||
-- make all following coordinates relative
|
||||
local action_text = "container[0.2,13.0]"..
|
||||
"box[0.25,0.0;21.0,6.7;#555555]"
|
||||
-- show what happens if the action fails
|
||||
if(caller == "show_if_action_failed") then
|
||||
action_text = "label[0.2,12.1;"..
|
||||
"If the player *failed* to complete the above action correctly,]"..
|
||||
"button[17.0,11.7;4.0,0.7;button_show_if_action_succeeded;Show if successful]"..
|
||||
"tooltip[button_show_if_action_succeeded;Click here to see what will happen "..
|
||||
"if the player\nexecuted the action successfully.]"
|
||||
action_text = action_text..
|
||||
-- allow to switch between successful and failed actions
|
||||
"tabheader[0.2,0.0;switch_tab;"..
|
||||
"If the action was successful:,"..
|
||||
"If the action failed:;2;true;true]"..
|
||||
"label[0.4,0.6;"..
|
||||
"If the player *failed* to complete the above action correctly,]"
|
||||
if(action_data and action_data.a_on_failure
|
||||
and dialog.n_dialogs and dialog.n_dialogs[ action_data.a_on_failure]) then
|
||||
action_text = action_text..
|
||||
-- ..and what the NPC will reply to that answer
|
||||
"tooltip[1.2,15.5;19.6,2.5;This is what the NPC will say next when "..
|
||||
"tooltip[1.2,3.9;19.6,2.5;This is what the NPC will say next when "..
|
||||
"the player has failed to complete the action.]"..
|
||||
"label[0.2,15.1;..the NPC will react to this failed action with the "..
|
||||
|
||||
"container[0.0,3.2]"..
|
||||
"label[0.4,0.4;..the NPC will react to this failed action with the "..
|
||||
"following dialog \""..tostring(action_data.a_on_failure)..
|
||||
"\""..
|
||||
yl_speak_up.show_colored_dialog_text(
|
||||
dialog,
|
||||
action_data,
|
||||
action_data.a_on_failure,
|
||||
"1.2,15.5;19.6,2.5;d_text_next",
|
||||
"1.2,0.7;19.6,2.5;d_text_next",
|
||||
"with the *modified* text",
|
||||
":]")
|
||||
":]")..
|
||||
"container_end[]"
|
||||
else
|
||||
action_text = action_text..
|
||||
"label[0.2,15.1;..go back to the initial dialog.]"
|
||||
"label[0.4,3.6;..go back to the initial dialog.]"
|
||||
end
|
||||
-- show what happens if the action was successful
|
||||
else
|
||||
-- no action defined
|
||||
if(count_actions == 0) then
|
||||
-- do not show tabheader
|
||||
action_text = action_text..
|
||||
"label[0.4,0.6;"..
|
||||
"There is no (A)ction defined. Directly apply the following (Ef)fects:]"
|
||||
else
|
||||
action_text = action_text..
|
||||
-- allow to switch between successful and failed actions
|
||||
"tabheader[0.2,0.0;switch_tab;"..
|
||||
"If the action was successful:,"..
|
||||
"If the action failed:;1;true;true]"..
|
||||
"label[0.4,0.6;"..
|
||||
"If the player completed the above action successfully, "..
|
||||
"apply the following (Ef)fects:]"
|
||||
end
|
||||
action_text = action_text..
|
||||
-- list of effects
|
||||
"tablecolumns[text;color,span=1;text;text]"..
|
||||
"table[1.2,12.4;19.6,2.0;table_of_effects;"..
|
||||
list_of_effects..";0]"..
|
||||
"tooltip[1.2,12.4;19.6,2.0;"..
|
||||
"*All* (Ef)fects are executed after the action (if there is\n"..
|
||||
"one defined in this option) has been completed successfully\n"..
|
||||
"by the player. If there is no action defined, then the\n"..
|
||||
"(Ef)fects will always be executed when this option here is\n"..
|
||||
"selected.\n"..
|
||||
"Please click on an (Ef)fect in order to edit or delete it!]"..
|
||||
-- allow to change the target dialog via a dropdown menu
|
||||
"dropdown[12.3,14.7;2.8,0.7;d_id_"..minetest.formspec_escape(o_id)..";"..
|
||||
dialog_list..";"..dialog_selected..",]"..
|
||||
"tooltip[12.3,14.7;2.8,0.7;Select the target dialog with which the NPC shall react "..
|
||||
"to this answer. Currently, dialog \""..minetest.formspec_escape(target_dialog)..
|
||||
"\" is beeing displayed.;#FFFFFF;#000000]"..
|
||||
-- ..and what the NPC will reply to that answer
|
||||
"tooltip[1.2,15.5;19.6,2.5;This is what the NPC will say next when the player has "..
|
||||
"selected this answer here.]"..
|
||||
"label[0.2,15.1;The NPC will react to this answer with the following dialog:]"..
|
||||
yl_speak_up.show_colored_dialog_text(
|
||||
dialog,
|
||||
-- this is either the "dialog" effect or an empty fallback
|
||||
target_effect,
|
||||
-- this is the text the NPC will say in reaction to this answer
|
||||
target_dialog,
|
||||
"1.2,15.5;19.6,2.5;d_text",
|
||||
"label[15.2,15.1;with the *modified* text:]",
|
||||
"")
|
||||
-- list of effects
|
||||
"tablecolumns[text;color,span=1;text;text]"..
|
||||
"table[1.2,0.9;19.6,2.0;table_of_effects;"..
|
||||
list_of_effects..";0]"..
|
||||
"tooltip[1.2,0.9;19.6,2.0;"..
|
||||
"*All* (Ef)fects are executed after the action (if there is\n"..
|
||||
"one defined in this option) has been completed successfully\n"..
|
||||
"by the player. If there is no action defined, then the\n"..
|
||||
"(Ef)fects will always be executed when this option here is\n"..
|
||||
"selected.\n"..
|
||||
"Please click on an (Ef)fect in order to edit or delete it!]"..
|
||||
|
||||
"container[0.0,3.2]"..
|
||||
-- allow to change the target dialog via a dropdown menu
|
||||
"dropdown[10.2,0.0;3.0,0.7;d_id_"..minetest.formspec_escape(o_id)..";"..
|
||||
dialog_list..";"..dialog_selected..",]"..
|
||||
"tooltip[10.2,0.0;3.0,0.7;Select the target dialog with which the NPC shall react "..
|
||||
"to this answer. Currently, dialog \""..
|
||||
minetest.formspec_escape(target_dialog)..
|
||||
"\" is beeing displayed.;#FFFFFF;#000000]"..
|
||||
-- ..and what the NPC will reply to that answer
|
||||
"tooltip[1.2,0.7;19.6,2.5;This is what the NPC will say next when the player has "..
|
||||
"selected this answer here.]"..
|
||||
"label[0.4,0.4;The NPC will react to this answer with dialog:]"..
|
||||
yl_speak_up.show_colored_dialog_text(
|
||||
dialog,
|
||||
-- this is either the "dialog" effect or an empty fallback
|
||||
target_effect,
|
||||
-- this is the text the NPC will say in reaction to this answer
|
||||
target_dialog,
|
||||
"1.2,0.7;19.6,2.5;d_text",
|
||||
"label[13.5,0.4;with the following *modified* text:]",
|
||||
"")..
|
||||
"container_end[]"
|
||||
end
|
||||
action_text = action_text.."container_end[]"
|
||||
|
||||
-- build up the formspec
|
||||
local formspec = ""..
|
||||
"formspec_version[3]"..
|
||||
"size[21,20]"..
|
||||
"size[22,21]"..
|
||||
"bgcolor[#00000000;false]"..
|
||||
-- button back to the current dialog (of which this is an option)
|
||||
"button[15.8,0.2;5.0,0.9;show_current_dialog;Back to dialog "..
|
||||
"button[16.4,0.2;5.0,0.9;show_current_dialog;Back to dialog "..
|
||||
minetest.formspec_escape(d_id).."]"..
|
||||
"tooltip[show_current_dialog;Go back to dialog "..
|
||||
minetest.formspec_escape(d_id).." and continue editing that dialog.]"..
|
||||
-- tell the player what this formspec is about
|
||||
"label[6.0,0.4;You are editing dialog option \""..tostring(o_id).."\":]"..
|
||||
"label[6.5,0.4;You are editing dialog option \""..tostring(o_id).."\":]"..
|
||||
|
||||
-- the text the NPC says
|
||||
"label[0.2,0.6;NPC says "..
|
||||
"container[0.0,0.9]"..
|
||||
"label[0.2,0.0;NPC says "..
|
||||
minetest.formspec_escape("[dialog \""..tostring(d_id).."\"]:").."]"..
|
||||
yl_speak_up.show_colored_dialog_text(
|
||||
dialog,
|
||||
target_effect,
|
||||
d_id,
|
||||
"1.2,1.2;19.6,2.5;d_text",
|
||||
"1.2,0.3;20.2,2.5;d_text",
|
||||
"", -- no modifications possible at this step
|
||||
"")..
|
||||
"tooltip[1.2,1.2;19.6,3.0;This is what the NPC says to the player.]"..
|
||||
"tooltip[1.2,0.3;20.2,3.0;This is what the NPC says to the player.]"..
|
||||
"container_end[]"..
|
||||
|
||||
-- list the preconditions
|
||||
"label[0.2,4.2;If all of the following pre(C)onditions are fulfilled:]"..
|
||||
"container[0.0,4.4]"..
|
||||
"label[0.2,0.0;If all of the following pre(C)onditions are fulfilled:]"..
|
||||
"tablecolumns[text;color,span=1;text;text]"..
|
||||
"table[1.2,4.5;19.6,2.0;table_of_preconditions;"..
|
||||
"table[1.2,0.3;20.2,2.0;table_of_preconditions;"..
|
||||
list_of_preconditions..";0]"..
|
||||
"tooltip[1.2,4.5;19.6,2.0;"..
|
||||
"tooltip[1.2,0.3;20.2,2.0;"..
|
||||
"*All* pre(C)onditions need to be true in order\n"..
|
||||
"for the option to be offered to the player.\n"..
|
||||
"Please click on a pre(C)ondition in order\n"..
|
||||
"to edit or delete it!]"..
|
||||
"container_end[]"..
|
||||
|
||||
-- answer of the player (the actual option)
|
||||
"label[0.2,6.9;..the player may answer with this text"..
|
||||
"container[0.0,7.3]"..
|
||||
"label[0.2,0.0;..the player may answer with this text"..
|
||||
minetest.formspec_escape(" [dialog option \""..tostring(o_id).."\"]:").."]"..
|
||||
"label[1.2,7.7;A:]"..
|
||||
"field[1.7,7.2;19.1,0.9;text_option_"..minetest.formspec_escape(o_id)..";;"..
|
||||
"label[1.2,0.8;A:]"..
|
||||
"field[1.7,0.3;19.6,0.9;text_option_"..minetest.formspec_escape(o_id)..";;"..
|
||||
minetest.formspec_escape(d_option.o_text_when_prerequisites_met).."]"..
|
||||
"tooltip[option_text_met;This is the answer the player may choose if the "..
|
||||
"preconditions are all fulfilled.]"..
|
||||
-- dropdown for selecting weather to show the alternate answer or not
|
||||
"label[0.2,8.6;..but if at least one pre(C)ondition is not fulfilled, then...]"..
|
||||
"dropdown[12.0,8.2;8.6,0.7;hide_or_grey_or_alternate_answer;"..
|
||||
"label[0.2,1.7;..but if at least one pre(C)ondition is not fulfilled, then...]"..
|
||||
"dropdown[12.0,1.3;9.3,0.7;hide_or_grey_or_alternate_answer;"..
|
||||
"..hide this answer.,"..
|
||||
"..grey out the following answer:,"..
|
||||
"..display the following alternate answer:;"..
|
||||
alternate_answer_option..";]"..
|
||||
-- alternate answer
|
||||
"label[1.2,9.4;A:]"..
|
||||
"field[1.7,8.9;19.1,0.9;option_text_not_met;;"..
|
||||
"label[1.2,2.5;A:]"..
|
||||
"field[1.7,2.0;19.6,0.9;option_text_not_met;;"..
|
||||
minetest.formspec_escape(d_option.o_text_when_prerequisites_not_met).."]"..
|
||||
"tooltip[option_text_not_met;This is the answer the player may choose if the "..
|
||||
"preconditions are NOT all fulfilled.]"..
|
||||
"container_end[]"..
|
||||
|
||||
-- list of (A)ctions (there can only be one per option; i.e. a trade)
|
||||
"label[0.2,10.6;When this answer has been selected, start the following (A)ction:]"..
|
||||
"container[0.0,11.0]"..
|
||||
"label[0.2,0.0;When this answer has been selected, start the following (A)ction:]"..
|
||||
"tablecolumns[text;color,span=1;text;text]"..
|
||||
"table[1.2,10.9;19.6,0.7;table_of_actions;"..
|
||||
"table[1.2,0.3;20.2,0.7;table_of_actions;"..
|
||||
list_of_actions..";0]"..
|
||||
"container_end[]"..
|
||||
|
||||
-- list effects and target dialog for successful - and target dialog for unsuccessful
|
||||
-- actions (including a toggle button)
|
||||
action_text..
|
||||
|
||||
-- container for the buttons/footer
|
||||
"container[0.0,19.9]"..
|
||||
-- button: delete
|
||||
"button[0.2,18.7;2.0,0.9;del_option;Delete]"..
|
||||
"button[0.2,0.0;2.0,0.9;del_option;Delete]"..
|
||||
"tooltip[del_option;Delete this option/answer.]"..
|
||||
-- button: add new
|
||||
button_add..
|
||||
-- button: save
|
||||
"button[4.6,18.7;2.0,0.9;save_option;Save]"..
|
||||
"button[4.6,0.0;2.0,0.9;save_option;Save]"..
|
||||
"tooltip[save_option;Save what you canged (or discard it).]"..
|
||||
-- button: prev/next
|
||||
button_prev..
|
||||
button_next..
|
||||
-- button: go back to dialog (repeated from top of the page)
|
||||
"button[15.8,18.7;5.0,0.9;show_current_dialog;Back to dialog "..
|
||||
"button[15.8,0.0;5.0,0.9;show_current_dialog;Back to dialog "..
|
||||
minetest.formspec_escape(d_id).."]"..
|
||||
"tooltip[show_current_dialog;Go back to dialog "..
|
||||
minetest.formspec_escape(d_id).." and continue editing that dialog.]"..
|
||||
-- allow to enter o_sort
|
||||
"label[10.1,19.2;Sort:]"..
|
||||
"field[11.1,18.7;1.0,0.9;edit_option_o_sort;;"..
|
||||
"label[10.1,0.5;Sort:]"..
|
||||
"field[11.1,0.0;1.0,0.9;edit_option_o_sort;;"..
|
||||
minetest.formspec_escape(d_option.o_sort).."]"..
|
||||
"tooltip[edit_option_o_sort;o_sort: The lower the number, the higher up in the "..
|
||||
"list this option goes\nNegative values are ignored;#FFFFFF;#000000]"
|
||||
"list this option goes\nNegative values are ignored;#FFFFFF;#000000]"..
|
||||
"container_end[]"
|
||||
return formspec
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user