Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script_name = "Sor duplikálás képkockánként"
- script_description = "Képkockánként duplikál egy sort és az előző sor hosszával lépteti előre."
- script_author = "Hughes - isshotosho.info"
- function table.shallow_copy(t)
- local t2 = {}
- for k,v in pairs(t) do
- t2[k] = v
- end
- return t2
- end
- function dup(subtitles, selected_lines, active_line)
- local result, line, duration = nil
- -- lemasoljuk a kivalasztottak tablajat
- -- mert minden table ertek adas referencia alapu
- result = table.shallow_copy(selected_lines)
- -- i -> kivalasztott sor index
- -- v -> kivalasztott sor szama
- for i,v in pairs(selected_lines) do
- local tempStart, tempEnd = 0
- line = subtitles[v] -- line -> table object
- tempStart = aegisub.frame_from_ms(line.start_time)
- tempEnd = aegisub.frame_from_ms(line.end_time)
- line.start_time = aegisub.ms_from_frame(tempStart + 1)
- line.tempEnd = aegisub.ms_from_frame(tempEnd + 1)
- -- duration = line.end_time - line.start_time
- -- line.start_time = duration + line.start_time
- -- line.end_time = duration + line.end_time
- result[i] = line
- end
- return result
- end
- function duplicate_macro(subs, selected_lines, active_line)
- -- i -> kivalasztott sor index
- -- line -> table object
- aegisub.set_undo_point("duplicateAndShift")
- aegisub.progress.task('Sorok duplikálása...')
- for i,line in pairs(dup(subs, selected_lines, active_line)) do
- subs.insert(selected_lines[i] + i, line)
- end
- -- allitsuk be a kivalasztott sorokat
- local result = {}
- for k,v in pairs(selected_lines) do
- result[#result+1] = k+v
- end
- aegisub.progress.task('kész...')
- aegisub.progress.set(100)
- return result
- end
- function duplicate_group_macro(subs, selected_lines, active_line)
- aegisub.set_undo_point("duplicateAndShift")
- -- duplikáljuk
- subs.insert(selected_lines[#selected_lines] + 1, unpack(dup(subs, selected_lines, active_line)))
- local result = {}
- -- csoportosítsunk
- for i = 1, #selected_lines do
- result[#result + 1] = selected_lines[#selected_lines] + i
- end
- return result
- end
- function validate(subtitles, selected_lines)
- if #selected_lines > 0 and aegisub.video_size() then
- return true
- end
- return false
- end
- aegisub.register_macro(script_name, script_description, duplicate_macro, validate)
- aegisub.register_macro(script_name .. " és csoportosítás", script_description, duplicate_group_macro, validate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement