diff --git a/ua.NecrosCopy.lua b/ua.NecrosCopy.lua index 66d1169..fe0f00d 100644 --- a/ua.NecrosCopy.lua +++ b/ua.NecrosCopy.lua @@ -1,12 +1,12 @@ script_name="NecrosCopy" script_description="Copy and fax things in the shadows while lines are splitting and breaking" script_author="reanimated" -script_version="4.1" +script_version="5.0.0" script_namespace="ua.NecrosCopy" local haveDepCtrl,DependencyControl,depRec=pcall(require,"l0.DependencyControl") if haveDepCtrl then - script_version="4.1.0" + script_version="5.0.0" depRec=DependencyControl{feed="https://raw.githubusercontent.com/unanimated/luaegisub/master/DependencyControl.json"} end @@ -308,6 +308,238 @@ function necrostuff(subs,sel) trnsfrm=nil end +-- Ghegghe's stuff + +function table.shallowCopy(table) + local newTable = {} + for key, value in pairs(table) do + newTable[ key ] = value + end + return newTable +end + +-- returns an object with the "type" of the tag and his "value" +function getTypeAndValue(tag) + local tags ={ + {name="blur", tag="\\blur"}, + {name="scale_x", tag="\\fscx"}, + {name="scale_y", tag="\\fscy"}, + {name="spacing", tag="\\fsp"}, + {name="alpha", tag="\\alpha"}, + {name="move", tag="\\move"}, + {name="fade", tag="\\fade"}, + {name="clip", tag="\\clip"}, + {name="iclip", tag="\\iclip"}, + {name="outline_x", tag="\\xbord"}, + {name="outline_y", tag="\\ybord"}, + {name="outline", tag="\\bord"}, + {name="shadow_x", tag="\\xshad"}, + {name="shadow_y", tag="\\yshad"}, + {name="shadow", tag="\\shad"}, + + -- three character tags + {name="position", tag="\\pos"}, + {name="origin", tag="\\org"}, + {name="fade_simple", tag="\\fad"}, + {name="angle", tag="\\frz"}, + {name="angle_x", tag="\\frx"}, + {name="angle_y", tag="\\fry"}, + {name="shear_x", tag="\\fax"}, + {name="shear_y", tag="\\fay"}, + {name="baseline_offset", tag="\\pbo"}, + + -- two character tags + {name="fontsize", tag="\\fs"}, + {name="align", tag="\\an"}, + {name="color1", tag="\\1c"}, + {name="color2", tag="\\2c"}, + {name="color3", tag="\\3c"}, + {name="color4", tag="\\4c"}, + {name="alpha1", tag="\\1a"}, + {name="alpha2", tag="\\2a"}, + {name="alpha3", tag="\\3a"}, + {name="alpha4", tag="\\4a"}, + {name="blur_edges", tag="\\be"}, + {name="k_sweep", tag="\\kf"}, + {name="k_bord", tag="\\ko"}, + {name="fontname", tag="\\fn"}, + + -- one character tags + {name="color", tag="\\c"}, + {name="drawing", tag="\\p"}, + {name="transform", tag="\\t"}, + {name="wrapstyle", tag="\\q"}, + {name="italic", tag="\\i"}, + {name="underline", tag="\\u"}, + {name="strikeout", tag="\\s"}, + {name="bold", tag="\\b"}, + {name="k_fill", tag="\\k"}, + {name="reset", tag="\\r"}, + } + for key, value in ipairs(tags) do + if tag:match(value.tag) then + return {type=value.tag, value=tag:gsub(value.tag, "")} + end + end + return nil +end + +function getStartTags(stags) + local tagObj = {} + + local iStags = 1 + local char = stags:sub(iStags, iStags) + + if char == "{" then + -- if stag present + repeat + -- copy the single tag + local tag = "" + repeat + tag = tag .. char + iStags = iStags + 1 + char = stags:sub(iStags, iStags) + until char == "\\" or char == "}" + table.insert(tagObj, getTypeAndValue(tag)) + until char == "}" + return tagObj + else + return nil + end +end + +-- groupcopy +function groupstuff(subs, sel) + progress("GroupCopying, fetch groups...") + + -- create an array of selected lines + local lines = {} + for i = 1, #sel do + lines[ i ] = subs[ sel[ i ] ] + end + + -- get to copy lines from first group + local iLine = 1 + while iLine <= #sel and not lines[ iLine ].comment do + iLine = iLine + 1 + end + local toCopyLinesLength = iLine - 1 + + -- build GUI + local groupcopyGUI={ + {x = 0, y = 0, + class = "label", label="Ready to copy? groups detected: " .. toCopyLinesLength}, + {x = 0, y = 1, + class = "checkbox", name = "overwrite", value = true, + label = "Overwrite tags", hint = "Overwrite identical tags"}, + {x = 0, y = 2, + class = "checkbox", name = "keepInline", value = true, + label = "Keep inline", hint = "Keeps inline tags in the lines where tags will be copied"}, + {x = 0, y = 3, + class = "checkbox", name = "keep", value = true, + label = "Keep old tags", hint = "Doesn't remove the start tags which doesn't match with new tags"}, + } + if iLine > #sel then + table.insert(groupcopyGUI, + {x = 0, y = 4, + class = "label", label = "It's recommended to read the flight manual first"}) + end + local press, checkboxes = ADD( + groupcopyGUI, + {"Make me fly", "Not today"}, + {ok = 'Make me fly', close = 'Not today'}) + + if press == "Not today" then + -- exit + ak() + elseif iLine > #sel then + t_error("Incorrectly formatted lines, it's recommended to read the flight manual first", true) + else + -- groupcopy + local iToCopyLines = 1 + + -- for all lines + while iLine <= #sel and iToCopyLines <= toCopyLinesLength do + progress("Groupcopying lines " .. iToCopyLines .. " / " .. toCopyLinesLength) + + -- find next group + while iLine <= #sel and lines[ iLine ].comment do + iLine = iLine + 1 + end + + if iLine <= #sel then + -- fetch stags + -- [type, value] + local toCopyTags = getStartTags(lines[ iToCopyLines ].text) + + -- copying tags + while iLine <= #sel and not lines[ iLine ].comment do + local newTags = table.shallowCopy(toCopyTags) + local oldTags = getStartTags(lines[ iLine ].text) + + if checkboxes.keep and oldTags ~= nil then + -- join tags + for _, oldValue in ipairs(oldTags) do + local isPresent = false + for newKey, newValue in ipairs(newTags) do + -- replace tag if is the same + -- transform check + if oldValue.type == newValue.type and + (oldValue ~= "\\t" or + (oldValue.type == "\\t" and + oldValue.value == newValue.value)) then + isPresent = true + -- overwrite if selected + if checkboxes.overwrite then + newTags[ newKey ].value = oldValue.value + end + end + end + + -- add the old tag + if not isPresent then + table.insert(newTags, oldValue) + end + end + end + + -- clear the line + if checkboxes.keepInline then + lines[ iLine ].text = lines[ iLine ].text:gsub("^{.-}", "") + else + lines[ iLine ].text = lines[ iLine ].text:gsub("{.-}", "") + end + + -- copy tags + local tags = "" + for key, value in ipairs(newTags) do + tags = tags .. value.type .. value.value + end + lines[ iLine ].text = "{" .. tags .. "}" .. lines[ iLine ].text + subs[ sel[ iLine ] ] = lines[ iLine ] + + iLine = iLine + 1 + end + -- repeat with next group + iToCopyLines = iToCopyLines + 1 + end + end + + -- check if all lines were copied + if iLine < #sel then + -- more groups then copy lines + t_error("There were more groups then \"to copy\" lines.\nHowever, all the " .. toCopyLinesLength .. " \"to copy\" lines were copied in the first groups") + elseif iToCopyLines <= toCopyLinesLength then + -- more copy lines then groups + t_error("There were more \"to copy\" lines then groups.\nHowever, the first " .. iToCopyLines .. " were copied anyway") + end + + progress("Groupcopy complete.") + end +end + +-- Ghegghe's end + function copytags(subs,sel) for z,i in ipairs(sel) do progress("Copypasting tags... "..z.."/"..#sel) @@ -382,7 +614,6 @@ function copycolours(subs,sel) return sel end - -- 3D shadow -- [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] function shad3(subs,sel) for z=#sel,1,-1 do @@ -424,7 +655,6 @@ function shad3(subs,sel) return sel end - -- Split into Letters -- [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] function space(subs,sel) nsel={} for z,i in ipairs(sel) do table.insert(nsel,i) end @@ -562,7 +792,6 @@ function space(subs,sel) return nsel end - -- Split by \N -- [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] [- -] function splitbreak(subs,sel) nsel={} for z,i in ipairs(sel) do table.insert(nsel,i) end @@ -797,8 +1026,6 @@ function rotxy(rot,xpos,y) return xpos,y end - - -- reanimatools ------------------------------------------------------------------------------------------------------------------------------------ function addtag(tag,text) text=text:gsub("^({\\[^}]-)}","%1"..tag.."}") return text end @@ -1168,19 +1395,43 @@ as it will restart after \N. [Un]hide lets you hide/unhide checked tags (by making them comments). Checked tags get hidden. If you don't check anything, whatever was hidden gets unhidden. Good for clips, for example.]] +grouphelp=[[ +Groupcopy +It allows you to copy all the start tag from N to N lines. +You can also check if you want to overwrite existent tags, +keep inline and/or old start tags from lines on which tags will be copied. + +For make this script works, you must select all the lines from which tags will be copied, +and the lines on which tags will be copied, separated at least by one commented line. + +Example: +-{\b1} (copy from) +-{\fad(300,400)} (copy from) +-commented lines (separator) +-(first group of lines (1), \b will be copied here) +-(first group of lines (2), \b will be copied here) +-commented lines (separator) +-(second group of lines (1), \fad(300,400) will be copied here) +-(second group of lines (2), \fad(300,400) will be copied here) +-(second group of lines (3), \fad(300,400) will be copied here) + +Obviously, you can copy more than one tag for group. +Having said that, have fun.]] + function necrohell() nekrohelp="http://unanimated.hostfree.pw/ts/scripts-manuals.htm#necroscopy" repeat if Pr=='clip2fax/frz' then nekrohelp=faxhelp end if Pr=='necroscopy' then nekrohelp=necrohelp end + if Pr=='groupcopy' then nekrohelp=grouphelp end if Pr=='copy tags/text' then nekrohelp=tagsthelp end if Pr=='copy colours' then nekrohelp=callhelp end if Pr=='3D shadow' then nekrohelp=shadehelp end if Pr=='split letters' then nekrohelp=splathelp end if Pr=='split by \\N' then nekrohelp=breakhelp end - Pr=aegisub.dialog.display({{width=32,height=10,class="textbox",value=nekrohelp},{x=36,height=10,class="label",label="NecrosCopy\nversion "..script_version}}, - {"clip2fax/frz","necroscopy","copy tags/text","copy colours","3D shadow","split letters","split by \\N","cancel"},{close='cancel'}) + Pr=aegisub.dialog.display({{width=38,height=10,class="textbox",value=nekrohelp},{x=39,height=10,class="label",label="NecrosCopy\nversion "..script_version}}, + {"clip2fax/frz","necroscopy","groupcopy","copy tags/text","copy colours","3D shadow","split letters","split by \\N","cancel"},{close='cancel'}) until Pr=='cancel' end @@ -1216,12 +1467,13 @@ end {x=12,y=0,class="label",label=script_name.." v"..script_version}, {x=12,y=1,class="checkbox",name="help",label="necronomicon",hint="necrohelp"}, } - P,res=ADD(GUI,{"clip2fax/frz","necroscopy","copy tags","copy text","copy colours","3D shadow","split letters","split by \\N","split"},{cancel='split'}) + P,res=ADD(GUI,{"clip2fax/frz","necroscopy","groupcopy","copy tags","copy text","copy colours","3D shadow","split letters","split by \\N","split"},{cancel='split'}) if P=="split" then ak() end if res.help then P='' necrohell() end if P=="clip2fax/frz" then if res.frz then frozt(subs,sel) else fucks(subs,sel) end end if P=="necroscopy" then reversel(subs,sel) necrostuff(subs,sel) end + if P=="groupcopy" then reversel(subs,sel) groupstuff(subs,sel) end if P=="copy tags" then reversel(subs,sel) copytags(subs,sel) end if P=="copy text" then reversel(subs,sel) copytext(subs,sel) end if P=="copy clip" then reversel(subs,sel) copyclip(subs,sel) end diff --git a/ua.Recalculator.lua b/ua.Recalculator.lua index f0b3e09..76c56e3 100644 --- a/ua.Recalculator.lua +++ b/ua.Recalculator.lua @@ -92,9 +92,10 @@ STAG="^{>?\\[^}]-}" {x=6,y=3,class="checkbox",name="alpha",label="alpha"}, {x=7,y=3,class="checkbox",name="space",label="[ ]",value=true,hint="workaround for spaces with full-line GBC"}, - {x=0,y=10,width=3,class="checkbox",name="byline",label="multiply/add more with each line"}, + {x=0,y=10,width=2,class="checkbox",name="byline",label="multiply iteration"}, - {x=3,y=10,width=2,class="checkbox",name="regtag",label="regular tags",value=true}, + {x=2,y=10,class="checkbox",name="regtag",label="regular tags",value=true}, + {x=3,y=10,width=2,class="checkbox",name="shiftTimeByFrame",label="time by frame"}, {x=5,y=10,width=2,class="checkbox",name="tftag",label="tags in transforms",value=true}, {x=6,y=1,width=2,class="checkbox",name="rpt",label="repeat last"}, @@ -202,7 +203,15 @@ function multiply(subs,sel) if res.clipx or res.clipy then clip=1 else clip=0 end for z,i in ipairs(sel) do progress("Processing line: "..z.."/"..#sel) - if res.byline then count=z*c linec=z altcount=z*alt else count=c linec=1 altcount=alt end + if res.byline then + count=z*c + linec=z + altcount=z*alt + else + count=c + linec=1 + altcount=alt + end if not res.alt then altcount=count alt=res.add end line=subs[i] text=line.text @@ -331,11 +340,49 @@ function multiply(subs,sel) return "\\t("..a..","..calc2(tonumber(b)).."," end) end if res.ly then line.layer=lmcalc(line.layer) end + if res.alpha then + text=text:gsub("\\alpha&H([%x]+)&", function(a) + return "\\alpha&H" .. hexAdd(a,res.add*linec) .. "&" + end) + end + if res["1a"] then + text=text:gsub("\\1a&H([%x]+)&", function(a) + return "\\1a&H" .. hexAdd(a,res.add*linec) .. "&" + end) + end + if res["2a"] then + text=text:gsub("\\2a&H([%x]+)&", function(a) + return "\\2a&H" .. hexAdd(a,res.add*linec) .. "&" + end) + end + if res["3a"] then + text=text:gsub("\\3a&H([%x]+)&", function(a) + return "\\3a&H" .. hexAdd(a,res.add*linec) .. "&" + end) + end + if res["4a"] then + text=text:gsub("\\4a&H([%x]+)&", function(a) + return "\\4a&H" .. hexAdd(a,res.add*linec) .. "&" + end) + end if res.ml then line.margin_l=lmcalc(line.margin_l) end if res.mr then line.margin_r=lmcalc(line.margin_r) end if res.mv then line.margin_t=lmcalc(line.margin_t) end - if res.st then line.start_time=lmcalc(line.start_time) end - if res.et then line.end_time=lmcalc(line.end_time) end + if res.shiftTimeByFrame then + if res.st then + frame = aegisub.frame_from_ms(line.start_time) + frame = lmcalc(frame) + line.start_time = aegisub.ms_from_frame(frame) + end + if res.et then + frame = aegisub.frame_from_ms(line.end_time) + frame = lmcalc(frame) + line.end_time = aegisub.ms_from_frame(frame) + end + else + if res.st then line.start_time=lmcalc(line.start_time) end + if res.et then line.end_time=lmcalc(line.end_time) end + end if res.retxt then neg=1 text=retext(text) end if res.react then neg=1 line.actor=retext(line.actor) end @@ -347,6 +394,27 @@ function multiply(subs,sel) end end +function hexAdd(hexString, addValue) + if hexString == "FF" and addValue > 0 or + hexString == "00" and addValue < 0 then + return hexString + elseif #hexString < 3 then + local newValue = tonumber(hexString, 16) + addValue + if newValue < 0 then + newValue = 0 + elseif newValue > 255 then + newValue = 255 + end + newValue = string.format("%X", newValue) + if #newValue < 2 then + newValue = "0" .. newValue + end + return newValue + else + return nil + end +end + function lmcalc(num) if P=="Multiply" then num=round(num+num*count,0) end if P=="Add" then num=round(num+(res.add*linec),0)end diff --git a/ua.Relocator.lua b/ua.Relocator.lua index 2e6a95d..864a7e9 100644 --- a/ua.Relocator.lua +++ b/ua.Relocator.lua @@ -5,7 +5,7 @@ script_name="Hyperdimensional Relocator" script_description="Advanced metamorphosis of multidimensional coordinates" script_author="reanimated" script_url="http://unanimated.hostfree.pw/ts/relocator.lua" -script_version="4.5.2" +script_version="4.5.2.2" script_namespace="ua.Relocator" local haveDepCtrl,DependencyControl,depRec=pcall(require,"l0.DependencyControl") @@ -98,7 +98,7 @@ function relocator(subs,sel,act) {x=12,y=4,class="checkbox",name="tpc1",label="c1",value=true,hint="affect top left corner of rectangular clip"}, {x=12,y=5,class="checkbox",name="tpc2",label="c2",value=true,hint="affect bottom right corner of rectangular clip"}, {x=15,y=5,class="checkbox",name="tpexp",label="exp",hint="expand rectangular clip in opposite directions"}, - {x=13,y=5,width=2,class="checkbox",name="tpmask",label="mask"}, + {x=13,y=5,class="checkbox",name="tpmask",label="mask",value=false,hint="Teleport mask without rounding"}, {x=14,y=0,width=2,class="checkbox",name="warp",label="&Warp",hint="Warped Teleport"}, {x=12,y=6,width=4,class="checkbox",name="autopos",label="pos with tags missing",value=true,hint="Teleport position when \\pos tags missing"}, @@ -2537,7 +2537,7 @@ function teleport(subs,sel) if res.tpmask then draw=text:match("}m ([^{]+)") - draw2=draw:gsub("([%d.-]+) ([%d.-]+)",function(a,b) return round(a+xx+fx).." "..round(b+yy+fy) end) + draw2=draw:gsub("([%d.-]+) ([%d.-]+)",function(a,b) return a+xx+fx.." "..b+yy+fy end) draw=esc(draw) text=text:gsub("(}m )"..draw,"%1"..draw2) end diff --git a/ua.ScriptCleanup.lua b/ua.ScriptCleanup.lua index a5b5903..0f67437 100644 --- a/ua.ScriptCleanup.lua +++ b/ua.ScriptCleanup.lua @@ -3,12 +3,12 @@ script_name="Script Cleanup" script_description="Garbage disposal and elimination of incriminating evidence" script_author="unanimated" -script_version="5.0" +script_version="5.0.4" script_namespace="ua.ScriptCleanup" local haveDepCtrl,DependencyControl,depRec=pcall(require,"l0.DependencyControl") if haveDepCtrl then - script_version="5.0.0" + script_version="5.0.4" depRec=DependencyControl{feed="https://raw.githubusercontent.com/unanimated/luaegisub/master/DependencyControl.json"} end @@ -153,7 +153,27 @@ function cleanlines(subs,sel) if res.ctrans then text=text:gsub(ATAG,function(tg) return cleantr(tg) end) end if res.inline2 then repeat text,r=text:gsub("(.)"..ATAG.."(.-{%*?\\)","%1%2") until r==0 elseif res.inline then text=text:gsub("(.)"..ATAG,"%1") end - + if res.text then + local newText = '' + local i = 1 + + while i <= text:len() do + local char = text:sub(i, i) + -- start to save characters + if char == '{' then + repeat + newText = newText .. char + i = i + 1 + char = text:sub(i, i) + until char == "}" + newText = newText .. char + end + i = i + 1 + end + + text=newText + end + if res.alphacol then text=text :gsub("alpha&(%x%x)&","alpha&H%1&") @@ -310,6 +330,7 @@ function killemall(subs,sel) if res.anna then trgt=killtag("an",trgt) end if res.align then trgt=killtag("a",trgt) end if res.wrap then trgt=killtag("q",trgt) end + if res.mask then trgt=killtag("p",trgt) end if res["return"] then trgt=trgt:gsub("\\r.+([\\}])","%1") end if res.kara then trgt=trgt:gsub("\\[Kk][fo]?[%d%.]+([\\}])","%1") end if res.ital then repeat trgt,r=trgt:gsub("\\i[01]?([\\}])","%1") until r==0 end @@ -624,6 +645,99 @@ if text=="" then return orig end return text end +-- Ghegghe's stuff + +function removeTextlessLines(subs, sel, ignoreCommentedLines, keepInlineComments) + progress("Deleting textless lines...") + local newSel = {} + + for s = #sel, 1, -1 do + progress("Deleting textless lines " .. #sel - (s - 1) .. " / " .. #sel) + local hasDelete = true + local line = subs[ sel[ s ] ].text + -- ignore commented lines + if not (ignoreCommentedLines and subs[ sel[ s ] ].comment) then + local iLine = 1 + while iLine <= line:len() do + -- if "{" is opened + if line:sub(iLine, iLine) == "{" then + local hasTags = false + + repeat + if line:sub(iLine, iLine) == "\\" then + hasTags = true + break + end + iLine = iLine + 1 + until line:sub(iLine, iLine) == "}" or + iLine > line:len() + + if hasTags then + while line:sub(iLine, iLine) ~= "}" do + iLine = iLine + 1 + end + else + -- "{" not closed (text) or comment inline + if iLine > line:len() or keepInlineComments then + hasDelete = false + break + end + end + + -- jump to next + iLine = iLine + 1 + else + -- text + hasDelete = false + break + end + end + else + -- commented line + hasDelete = false + end + + if hasDelete then + for z,i in ipairs(newSel) do + newSel[z]=i-1 + end + subs.delete(sel[s]) + else + table.insert(newSel,sel[s]) + end + end + + return newSel +end + +-- ver info +verInfo = "Script Cleanup v" .. script_version .. "\n" .. [[ + + What's new: + + New functions for clean your script: + - Remove text + Removes all the text from selected lines: + {tags(not removed)}text(removed){tags(not removed)} + + - Remove textless lines + Removes the lines without text from selection: + {tags} -- removed + {tags}text -- not removed + + Other options: + - Keep inline comments + {tags}{comments} + {comments} + lines like these wont be deleted + - Keep commented lines + Commented lines will be ignored + + Tag Manipulation: + Add "q" tag in tags list +]] + +-- Ghegghe's end function cleanup(subs,sel,act) ADD=aegisub.dialog.display @@ -634,96 +748,102 @@ STAG="^{>?\\[^}]-}" if act==0 then act=sel[1] end chng=0 kleen=0 GUI={ -{x=0,y=0,class="checkbox",name="nots",label="Remove TS timecodes",hint="Removes timecodes like {TS 12:36}"}, -{x=0,y=1,class="checkbox",name="clear_a",label="Clear Actor field"}, -{x=0,y=2,class="checkbox",name="clear_e",label="Clear Effect field"}, -{x=0,y=3,class="checkbox",name="layers",label="Raise dialogue layer by 5"}, -{x=0,y=4,class="checkbox",name="cleantag",label="Clean up tags",hint="Fixes duplicates, \\\\, \\}, }{, and other garbage"}, -{x=0,y=5,class="checkbox",name="ctrans",label="Clean up transforms"}, -{x=0,y=6,class="checkbox",name="overlap",label="Fix 1-frame gaps/overlaps"}, -{x=0,y=7,class="checkbox",name="nocomline",label="Delete commented lines"}, -{x=0,y=8,class="checkbox",name="noempty",label="Delete empty lines"}, -{x=0,y=9,class="checkbox",name="alphacol",label="Try to fix alpha / colour tags"}, -{x=0,y=10,class="checkbox",name="spaces",label="Fix start/end/double spaces"}, -{x=0,y=12,class="checkbox",name="info",label="Print info"}, -{x=0,y=13,class="checkbox",name="all",label="ALL OF THE ABOVE"}, - -{x=1,y=0,class="label",label=" "}, - -{x=2,y=0,width=2,class="checkbox",name="allcol",label="Remove all colour tags"}, -{x=2,y=1,class="checkbox",name="allphas",label="Remove all alphas"}, -{x=3,y=1,class="checkbox",name="alpha14",label="Only 1a-4a"}, -{x=2,y=2,class="checkbox",name="allrot",label="Remove all rotations",hint="frx, fry, frz"}, -{x=3,y=2,class="checkbox",name="xyrot",label="Only x, y",hint="remove frx, fry"}, -{x=2,y=3,class="checkbox",name="allsize",label="Remove size/scaling",hint="fs, fscx, fscy"}, -{x=3,y=3,class="checkbox",name="scales",label="Only scaling",hint="remove fscx, fscy"}, -{x=2,y=4,class="checkbox",name="allshad",label="Remove all shadows",hint="shad, xshad, yshad"}, -{x=3,y=4,class="checkbox",name="xyshad",label="Only x, y",hint="remove xshad, yshad"}, -{x=2,y=5,class="checkbox",name="parent",label="Remove parentheses",hint="fad(e), (i)clip, pos, move, org\n(but not t)"}, -{x=3,y=5,class="checkbox",name="parent2",label="Except \\pos",hint="fad(e), (i)clip, move, org\n(but not t or pos)"}, -{x=2,y=6,width=2,class="checkbox",name="allpers",label="Remove all perspective",hint="frx, fry, frz, fax, fay, org"}, - -{x=2,y=7,width=2,class="label",label=" ~ Script Cleanup v"..script_version.." ~"}, - -{x=2,y=8,width=2,class="checkbox",name="hspace",label="Remove hard spaces - \\h"}, -{x=2,y=9,class="checkbox",name="nobreak",label="Remove line breaks"}, -{x=3,y=9,class="checkbox",name="nobreak2",label="...no space",hint="Remove line breaks, leave no spaces"}, -{x=2,y=10,class="checkbox",name="nostyle",label="Delete unused styles"}, -{x=3,y=10,class="checkbox",name="nostyle2",label="Except Def.",hint="Delete unused styles except Default"}, -{x=2,y=11,class="checkbox",name="inline",label="Remove inline tags"}, -{x=3,y=11,class="checkbox",name="inline2",label="Except last",hint="Remove inline tags except the last one"}, -{x=2,y=12,width=2,class="checkbox",name="nocom",label="Remove comments from lines",hint="Removes {comments} (not tags)"}, -{x=2,y=13,width=2,class="checkbox",name="notag",label="Remove all {\\tags} from selected lines"}, - -{x=4,y=0,height=14,class="label",label="| \n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|"}, - -{x=5,y=0,class="checkbox",name="skill",label="[start]",value=true}, -{x=6,y=0,class="checkbox",name="ikill",label="[inline]",value=true,hint="only kill, not hide"}, -{x=7,y=0,width=2,class="checkbox",name="inverse",label="[inverse/unhide]",hint="kill all except checked ones\n\n'Unhide' for 'Hide Tags'"}, -{x=7,y=1,width=2,class="checkbox",name="onlyt",label="[from \\t]",hint="remove only from transforms\n\n n/a for 'Hide Tags'"}, - -{x=5,y=1,class="checkbox",name="blur",label="blur"}, -{x=5,y=2,class="checkbox",name="border",label="bord",hint="includes xbord and ybord [not for Hide]"}, -{x=5,y=3,class="checkbox",name="shadow",label="shad",hint="includes xshad and yshad for Hide"}, -{x=5,y=4,class="checkbox",name="fsize",label="fs"}, -{x=5,y=5,class="checkbox",name="fspace",label="fsp"}, -{x=5,y=6,class="checkbox",name="scalex",label="fscx"}, -{x=5,y=7,class="checkbox",name="scaley",label="fscy"}, -{x=5,y=8,class="checkbox",name="fname",label="fn"}, -{x=5,y=9,class="checkbox",name="ital",label="i"}, -{x=5,y=10,class="checkbox",name="bold",label="b"}, -{x=5,y=11,class="checkbox",name="under",label="u"}, -{x=5,y=12,class="checkbox",name="stri",label="s"}, -{x=5,y=13,class="checkbox",name="wrap",label="q"}, - -{x=6,y=1,class="checkbox",name="bee",label="be"}, -{x=6,y=2,class="checkbox",name="color1",label="c, 1c"}, -{x=6,y=3,class="checkbox",name="color2",label="2c"}, -{x=6,y=4,class="checkbox",name="color3",label="3c"}, -{x=6,y=5,class="checkbox",name="color4",label="4c"}, -{x=6,y=6,class="checkbox",name="alpha",label="alpha"}, -{x=6,y=7,class="checkbox",name="alfa1",label="1a"}, -{x=6,y=8,class="checkbox",name="alfa2",label="2a"}, -{x=6,y=9,class="checkbox",name="alfa3",label="3a"}, -{x=6,y=10,class="checkbox",name="alfa4",label="4a"}, -{x=6,y=11,class="checkbox",name="align",label="a"}, -{x=6,y=12,class="checkbox",name="anna",label="an"}, -{x=6,y=13,class="checkbox",name="clip",label="(i)clip"}, - -{x=7,y=2,class="checkbox",name="fade",label="fad"}, -{x=7,y=3,class="checkbox",name="posi",label="pos"}, -{x=7,y=4,class="checkbox",name="move",label="move"}, -{x=7,y=5,class="checkbox",name="org",label="org"}, -{x=7,y=6,class="checkbox",name="frz",label="frz"}, -{x=7,y=7,class="checkbox",name="frx",label="frx"}, -{x=7,y=8,class="checkbox",name="fry",label="fry"}, -{x=7,y=9,class="checkbox",name="fax",label="fax"}, -{x=7,y=10,class="checkbox",name="fay",label="fay"}, -{x=7,y=11,width=2,class="checkbox",name="kara",label="k/kf/ko"}, -{x=7,y=12,class="checkbox",name="return",label="r"}, -{x=7,y=13,class="checkbox",name="trans",label="t"}, - -{x=8,y=12,height=2,class="checkbox",name="hidline",label="hide\ninline",hint='Hide ALL inline tags'}, +{x=0,y=0,width=3,class="checkbox",name="nots",label="Remove TS timecodes",hint="Removes timecodes like {TS 12:36}"}, +{x=0,y=1,width=3,class="checkbox",name="clear_a",label="Clear Actor field"}, +{x=0,y=2,width=3,class="checkbox",name="clear_e",label="Clear Effect field"}, +{x=0,y=3,width=3,class="checkbox",name="layers",label="Raise dialogue layer by 5"}, +{x=0,y=4,width=3,class="checkbox",name="cleantag",label="Clean up tags",hint="Fixes duplicates, \\\\, \\}, }{, and other garbage"}, +{x=0,y=5,width=3,class="checkbox",name="ctrans",label="Clean up transforms"}, +{x=0,y=6,width=3,class="checkbox",name="overlap",label="Fix 1-frame gaps/overlaps"}, +{x=0,y=7,width=3,class="checkbox",name="nocomline",label="Delete commented lines"}, +{x=0,y=8,width=3,class="checkbox",name="noempty",label="Delete empty lines"}, +{x=0,y=9,width=3,class="checkbox",name="alphacol",label="Try to fix alpha / colour tags"}, +{x=0,y=10,width=3,class="checkbox",name="spaces",label="Fix start/end/double spaces"}, +{x=0,y=12,width=3,class="checkbox",name="info",label="Print info"}, +{x=0,y=13,width=3,class="checkbox",name="all",label="ALL OF THE ABOVE"}, + +{x=0,y=15,width=3,class="label",label=" ~ Script Cleanup v"..script_version.." ~ "}, +{x=3,y=15,class="checkbox",name="info",label="ver. info"}, +{x=0,y=16,width=3,class="checkbox",name="text",label="Remove text"}, +{x=0,y=17,width=3,class="checkbox",name="removeTextlessLines",label="Remove textless lines",hint="Removes lines without text (tag doesn't count)"}, +{x=1,y=18,width=2,class="checkbox",name="textlessLinesKeepInlineComments",label="Keep inline comments",hint="Keeps lines with comments inside"}, +{x=1,y=19,width=2,class="checkbox",name="textlessLinesKeepCommentedLines",label="Keep commented lines",value=true,hint="Keeps commented lines"}, + +{x=3,y=0,width=2,class="checkbox",name="allcol",label="Remove all colour tags"}, +{x=3,y=1,class="checkbox",name="allphas",label="Remove all alphas"}, +{x=4,y=1,class="checkbox",name="alpha14",label="Only 1a-4a"}, +{x=3,y=2,class="checkbox",name="allrot",label="Remove all rotations",hint="frx, fry, frz"}, +{x=4,y=2,class="checkbox",name="xyrot",label="Only x, y",hint="remove frx, fry"}, +{x=3,y=3,class="checkbox",name="allsize",label="Remove size/scaling",hint="fs, fscx, fscy"}, +{x=4,y=3,class="checkbox",name="scales",label="Only scaling",hint="remove fscx, fscy"}, +{x=3,y=4,class="checkbox",name="allshad",label="Remove all shadows",hint="shad, xshad, yshad"}, +{x=4,y=4,class="checkbox",name="xyshad",label="Only x, y",hint="remove xshad, yshad"}, +{x=3,y=5,class="checkbox",name="parent",label="Remove parentheses",hint="fad(e), (i)clip, pos, move, org\n(but not t)"}, +{x=4,y=5,class="checkbox",name="parent2",label="Except \\pos",hint="fad(e), (i)clip, move, org\n(but not t or pos)"}, +{x=3,y=6,width=2,class="checkbox",name="allpers",label="Remove all perspective",hint="frx, fry, frz, fax, fay, org"}, + +{x=3,y=7,width=2,class="label",label=" ~ Script Cleanup v5.0.0 ~"}, + +{x=3,y=8,width=2,class="checkbox",name="hspace",label="Remove hard spaces - \\h"}, +{x=3,y=9,class="checkbox",name="nobreak",label="Remove line breaks"}, +{x=4,y=9,class="checkbox",name="nobreak2",label="...no space",hint="Remove line breaks, leave no spaces"}, +{x=3,y=10,class="checkbox",name="nostyle",label="Delete unused styles"}, +{x=4,y=10,class="checkbox",name="nostyle2",label="Except Def.",hint="Delete unused styles except Default"}, +{x=3,y=11,class="checkbox",name="inline",label="Remove inline tags"}, +{x=4,y=11,class="checkbox",name="inline2",label="Except last",hint="Remove inline tags except the last one"}, +{x=3,y=12,width=2,class="checkbox",name="nocom",label="Remove comments from lines",hint="Removes {comments} (not tags)"}, +{x=3,y=13,width=2,class="checkbox",name="notag",label="Remove all {\\tags} from selected lines"}, + +{x=5,y=0,height=20,class="label",label="|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|\n|"}, + +{x=6,y=0,class="checkbox",name="skill",label="[start]",value=true}, +{x=7,y=0,class="checkbox",name="ikill",label="[inline]",value=true,hint="only kill, not hide"}, +{x=8,y=0,width=2,class="checkbox",name="inverse",label="[inverse/unhide]",hint="kill all except checked ones\n\n'Unhide' for 'Hide Tags'"}, +{x=8,y=1,width=2,class="checkbox",name="onlyt",label="[from \\t]",hint="remove only from transforms\n\n n/a for 'Hide Tags'"}, + +{x=6,y=1,class="checkbox",name="blur",label="blur"}, +{x=6,y=2,class="checkbox",name="border",label="bord",hint="includes xbord and ybord [not for Hide]"}, +{x=6,y=3,class="checkbox",name="shadow",label="shad",hint="includes xshad and yshad for Hide"}, +{x=6,y=4,class="checkbox",name="fsize",label="fs"}, +{x=6,y=5,class="checkbox",name="fspace",label="fsp"}, +{x=6,y=6,class="checkbox",name="scalex",label="fscx"}, +{x=6,y=7,class="checkbox",name="scaley",label="fscy"}, +{x=6,y=8,class="checkbox",name="fname",label="fn"}, +{x=6,y=9,class="checkbox",name="ital",label="i"}, +{x=6,y=10,class="checkbox",name="bold",label="b"}, +{x=6,y=11,class="checkbox",name="under",label="u"}, +{x=6,y=12,class="checkbox",name="stri",label="s"}, +{x=6,y=13,class="checkbox",name="wrap",label="q"}, +{x=6,y=14,class="checkbox",name="mask",label="p"}, + +{x=7,y=1,class="checkbox",name="bee",label="be"}, +{x=7,y=2,class="checkbox",name="color1",label="c, 1c"}, +{x=7,y=3,class="checkbox",name="color2",label="2c"}, +{x=7,y=4,class="checkbox",name="color3",label="3c"}, +{x=7,y=5,class="checkbox",name="color4",label="4c"}, +{x=7,y=6,class="checkbox",name="alpha",label="alpha"}, +{x=7,y=7,class="checkbox",name="alfa1",label="1a"}, +{x=7,y=8,class="checkbox",name="alfa2",label="2a"}, +{x=7,y=9,class="checkbox",name="alfa3",label="3a"}, +{x=7,y=10,class="checkbox",name="alfa4",label="4a"}, +{x=7,y=11,class="checkbox",name="align",label="a"}, +{x=7,y=12,class="checkbox",name="anna",label="an"}, +{x=7,y=13,class="checkbox",name="clip",label="(i)clip"}, + +{x=8,y=2,class="checkbox",name="fade",label="fad"}, +{x=8,y=3,class="checkbox",name="posi",label="pos"}, +{x=8,y=4,class="checkbox",name="move",label="move"}, +{x=8,y=5,class="checkbox",name="org",label="org"}, +{x=8,y=6,class="checkbox",name="frz",label="frz"}, +{x=8,y=7,class="checkbox",name="frx",label="frx"}, +{x=8,y=8,class="checkbox",name="fry",label="fry"}, +{x=8,y=9,class="checkbox",name="fax",label="fax"}, +{x=8,y=10,class="checkbox",name="fay",label="fay"}, +{x=8,y=11,width=2,class="checkbox",name="kara",label="k/kf/ko"}, +{x=8,y=12,class="checkbox",name="return",label="r"}, +{x=8,y=13,class="checkbox",name="trans",label="t"}, + +{x=9,y=12,height=2,class="checkbox",name="hidline",label="hide\ninline",hint='Hide ALL inline tags'}, } P,res=ADD(GUI, {"Run selected","Comments","Tags","Dial 5","Clean Tags","^ Kill Tags","Hide Tags","Cancer"},{ok='Run selected',cancel='Cancer'}) @@ -735,21 +855,29 @@ GUI={ if P=="Dial 5" then res.layers=true cleanlines(subs,sel) end if P=="Clean Tags" then res.cleantag=true cleanlines(subs,sel) end if P=="Run selected" then - C=0 for key,v in ipairs(GUI) do if v.x<=3 and res[v.name] then C=1 end end - if C==0 then t_error("Run Selected: Error - nothing selected",1) end - if res.all then - for key,v in ipairs(GUI) do if v.x>0 and v.name then res[v.name]=false end end - cleanlines(subs,sel) - sel=noemptycom(subs,sel) - else cleanlines(subs,sel) - if res.nocomline and res.noempty then sel=noemptycom(subs,sel) + if res.info then + helpGUI=aegisub.dialog.display({{width=38,height=10,class="textbox",value=verInfo},{x=39,height=10,class="label",label="ScriptCleanup\nversion "..script_version}}, + {"Close"},{close='Close'}) else - if res.nocomline then sel=nocom_line(subs,sel) end - if res.noempty then sel=noempty(subs,sel) end + C=0 for key,v in ipairs(GUI) do if v.x<=4 and res[v.name] then C=1 end end + if C==0 then t_error("Run Selected: Error - nothing selected",1) end + if res.all then + for key,v in ipairs(GUI) do if v.x>0 and v.name and v.y<15 then res[v.name]=false end end + cleanlines(subs,sel) + sel=noemptycom(subs,sel) + else cleanlines(subs,sel) + if res.nocomline and res.noempty then sel=noemptycom(subs,sel) + else + if res.nocomline then sel=nocom_line(subs,sel) end + if res.noempty then sel=noempty(subs,sel) end + end + if res.removeTextlessLines then + sel = removeTextlessLines(subs, sel, res.textlessLinesKeepCommentedLines, res.textlessLinesKeepInlineComments) + end + table.sort(sel) + if res.nostyle or res.nostyle2 then sel=nostyle(subs,sel) end + end end - table.sort(sel) - if res.nostyle or res.nostyle2 then sel=nostyle(subs,sel) end - end end if act>#subs then act=#subs end return sel,act