ink import: sort dialogs according to order given in ink; sort existing but not imported dialogs in after that
This commit is contained in:
parent
9b2aae7fe1
commit
a85f0629c5
@ -228,6 +228,9 @@ yl_speak_up.update_dialog = function(log, dialog, dialog_name, dialog_text)
|
||||
for i, o_id in ipairs(d_data.d_tmp_sorted_option_list or {}) do
|
||||
d_data.d_options[o_id].o_tmp_needs_update = true
|
||||
end
|
||||
-- mark this dialog as having received an update (meaning we won't have to update d_sort after
|
||||
-- all dialogs have been updated)
|
||||
d_data.d_tmp_has_been_updated = true
|
||||
return d_id
|
||||
end
|
||||
|
||||
@ -302,7 +305,7 @@ end
|
||||
|
||||
|
||||
-- make sure only one dialog has d_sort set to 0 (and is thus the start dialog)
|
||||
yl_speak_up.update_start_dialog = function(log, dialog, start_dialog_name)
|
||||
yl_speak_up.update_start_dialog = function(log, dialog, start_dialog_name, start_with_d_sort)
|
||||
local start_d_id = yl_speak_up.d_name_to_d_id(dialog, start_dialog_name)
|
||||
if(not(start_d_id)) then
|
||||
return
|
||||
@ -315,10 +318,12 @@ yl_speak_up.update_start_dialog = function(log, dialog, start_dialog_name)
|
||||
d.d_sort = 0
|
||||
-- the start dialog certainly is *a* start dialog (with the buttons)
|
||||
d.is_a_start_dialog = true
|
||||
elseif(not(d.d_sort) or d.d_sort == 0) then
|
||||
-- all other dialogs are not *the* start dialog
|
||||
d.d_sort = d.d_sort or tonumber(string.sub(d_id, 3)) or 1
|
||||
elseif(not(d.d_tmp_has_been_updated)) then
|
||||
-- sort this dialog behind the others
|
||||
d.d_sort = start_with_d_sort
|
||||
start_with_d_sort = start_with_d_sort + 1
|
||||
end
|
||||
d.d_tmp_has_been_updated = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -889,12 +889,19 @@ parse_ink.import_dialogs = function(dialog, dialogs, actions, effects, start_dia
|
||||
end
|
||||
end
|
||||
-- we need to add the dialogs as such first so that target_dialog will work
|
||||
local d_sort = 1
|
||||
for i, d_name in ipairs(dialog_list) do
|
||||
local dialog_knot = dialogs[d_name]
|
||||
local dialog_name = parse_ink.strip_prefix(d_name, prefix)
|
||||
|
||||
local d_id = yl_speak_up.update_dialog(log, dialog, dialog_name, dialog_knot.text)
|
||||
dialog_knot.d_id = d_id
|
||||
|
||||
-- adjust d_sort so that it is the same order as in the import
|
||||
if(d_id and dialog.n_dialogs[d_id] and d_name ~= start_dialog) then
|
||||
dialog.n_dialogs[d_id].d_sort = d_sort
|
||||
d_sort = d_sort + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- now we can add the options
|
||||
@ -977,7 +984,7 @@ parse_ink.import_dialogs = function(dialog, dialogs, actions, effects, start_dia
|
||||
end
|
||||
|
||||
-- make sure the right start dialog is set
|
||||
yl_speak_up.update_start_dialog(log, dialog, parse_ink.strip_prefix(start_dialog, prefix))
|
||||
yl_speak_up.update_start_dialog(log, dialog, parse_ink.strip_prefix(start_dialog, prefix), d_sort)
|
||||
|
||||
return dialog
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user