mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-23 15:48:03 +02:00
added helper function yl_speak_up.handle_edit_actions_alternate_text
This commit is contained in:
parent
6e40dbc388
commit
b03ab2e6b5
@ -894,9 +894,53 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
|
||||
return
|
||||
end
|
||||
|
||||
-- handle editing and changing of alternate texts for actions
|
||||
if( fields.button_edit_action_on_failure_text_change
|
||||
or fields.button_edit_effect_on_failure_text_change
|
||||
or fields.save_dialog_modification) then
|
||||
yl_speak_up.handle_edit_actions_alternate_text(
|
||||
player, pname, n_id, d_id, o_id, x_id, id_prefix,
|
||||
formspec_input_to, data, fields, tmp_data_cache)
|
||||
if(not(fields.save_dialog_modification)) then
|
||||
return
|
||||
end
|
||||
was_changed = true
|
||||
-- we are back from that submenu
|
||||
elseif(fields.back_from_edit_dialog_modification) then
|
||||
was_changed = true
|
||||
end
|
||||
|
||||
-- the player wants to change/edit a precondition or effect
|
||||
if(not(fields.back)
|
||||
and (fields.change_element or fields.select_what or fields.select_trade
|
||||
or fields.select_inv or fields.select_block
|
||||
or fields.select_variable or fields.select_operator
|
||||
or fields.select_on_failure
|
||||
or fields.select_on_action_failure
|
||||
or fields.back_from_error_msg
|
||||
or fields.store_item_name
|
||||
or was_changed
|
||||
or fields.key_enter
|
||||
or fields.quit
|
||||
-- return was pressed
|
||||
or fields.key_enter_field)) then
|
||||
yl_speak_up.show_fs(player, formspec_input_to)
|
||||
return
|
||||
end
|
||||
|
||||
-- go back to the edit option dialog
|
||||
yl_speak_up.show_fs(player, "edit_option_dialog",
|
||||
{n_id = n_id, d_id = d_id, o_id = o_id, caller= formspec_input_to})
|
||||
end
|
||||
|
||||
|
||||
-- helper function for yl_speak_up.input_fs_edit_option_related
|
||||
-- (handle editing of alternate texts that are shown instead of the normal dialog)
|
||||
yl_speak_up.handle_edit_actions_alternate_text = function(
|
||||
player, pname, n_id, d_id, o_id, x_id, id_prefix,
|
||||
formspec_input_to, data, fields, tmp_data_cache)
|
||||
-- edit alternate text for an action
|
||||
if(fields.button_edit_action_on_failure_text_change) then
|
||||
was_changed = true
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
local sorted_dialog_list = yl_speak_up.sort_keys(dialog.n_dialogs)
|
||||
local failure_id = ""
|
||||
@ -915,7 +959,6 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
|
||||
return
|
||||
-- edit alternate text for an on_failure effect
|
||||
elseif(fields.button_edit_effect_on_failure_text_change) then
|
||||
was_changed = true
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
yl_speak_up.show_fs(player, "msg", {
|
||||
input_to = "yl_speak_up:"..formspec_input_to,
|
||||
@ -929,7 +972,6 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
|
||||
return
|
||||
-- save the changes
|
||||
elseif(fields.save_dialog_modification) then
|
||||
was_changed = true
|
||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||
local old_text = data.alternate_text
|
||||
if(data and fields.d_text_new and fields.d_text_new ~= "$TEXT$"
|
||||
@ -962,33 +1004,7 @@ yl_speak_up.input_fs_edit_option_related = function(player, formname, fields,
|
||||
"["..tostring(old_text).."] to ["..tostring(fields.d_text_new).."].")
|
||||
end
|
||||
end
|
||||
-- just back; nothing special (but definitely a legitimate button)
|
||||
elseif(fields.back_from_edit_dialog_modification) then
|
||||
was_changed = true
|
||||
end
|
||||
|
||||
|
||||
-- the player wants to change/edit a precondition or effect
|
||||
if(not(fields.back)
|
||||
and (fields.change_element or fields.select_what or fields.select_trade
|
||||
or fields.select_inv or fields.select_block
|
||||
or fields.select_variable or fields.select_operator
|
||||
or fields.select_on_failure
|
||||
or fields.select_on_action_failure
|
||||
or fields.back_from_error_msg
|
||||
or fields.store_item_name
|
||||
or was_changed
|
||||
or fields.key_enter
|
||||
or fields.quit
|
||||
-- return was pressed
|
||||
or fields.key_enter_field)) then
|
||||
yl_speak_up.show_fs(player, formspec_input_to)
|
||||
return
|
||||
end
|
||||
|
||||
-- go back to the edit option dialog
|
||||
yl_speak_up.show_fs(player, "edit_option_dialog",
|
||||
{n_id = n_id, d_id = d_id, o_id = o_id, caller= formspec_input_to})
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user