mirror of https://github.com/odrling/Aegisub
Introducing fxgroup modifier
Originally committed to SVN as r1248.
This commit is contained in:
parent
0ceff61352
commit
a214b69cac
|
@ -89,9 +89,6 @@ function parse_code(meta, styles, line, templates, mods)
|
||||||
elseif m == "syl" then
|
elseif m == "syl" then
|
||||||
table.insert(templates.syl, template)
|
table.insert(templates.syl, template)
|
||||||
inserted = true
|
inserted = true
|
||||||
elseif m == "char" then
|
|
||||||
table.insert(templates.char, template)
|
|
||||||
inserted = true
|
|
||||||
elseif m == "furi" then
|
elseif m == "furi" then
|
||||||
table.insert(templates.furi, template)
|
table.insert(templates.furi, template)
|
||||||
inserted = true
|
inserted = true
|
||||||
|
@ -117,8 +114,8 @@ function parse_code(meta, styles, line, templates, mods)
|
||||||
end
|
end
|
||||||
|
|
||||||
template_modifiers = {
|
template_modifiers = {
|
||||||
"pre-line", "line", "syl", "char", "furi",
|
"pre-line", "line", "syl", "furi", "char", "all", "repeat", "loop",
|
||||||
"all", "repeat", "loop", "notext", "keeptags", "multi", "fx"
|
"notext", "keeptags", "noblank", "multi", "fx", "fxgroup"
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse_template(meta, styles, line, templates, mods)
|
function parse_template(meta, styles, line, templates, mods)
|
||||||
|
@ -130,6 +127,7 @@ function parse_template(meta, styles, line, templates, mods)
|
||||||
layer = line.layer,
|
layer = line.layer,
|
||||||
addtext = true,
|
addtext = true,
|
||||||
keeptags = false,
|
keeptags = false,
|
||||||
|
fxgroup = nil,
|
||||||
inline_fx = nil,
|
inline_fx = nil,
|
||||||
multi = false,
|
multi = false,
|
||||||
isline = false,
|
isline = false,
|
||||||
|
@ -183,7 +181,7 @@ function parse_template(meta, styles, line, templates, mods)
|
||||||
inserted = true
|
inserted = true
|
||||||
elseif (m == "pre-line" or m == "line") and inserted then
|
elseif (m == "pre-line" or m == "line") and inserted then
|
||||||
aegisub.out(2, "Unable to combine %s class templates with other template classes\n\n", m)
|
aegisub.out(2, "Unable to combine %s class templates with other template classes\n\n", m)
|
||||||
elseif (m == "syl" or m == "char" or m == "furi") and template.isline then
|
elseif (m == "syl" or m == "furi") and template.isline then
|
||||||
aegisub.out(2, "Unable to combine %s class template lines with line or pre-line classes\n\n", m)
|
aegisub.out(2, "Unable to combine %s class template lines with line or pre-line classes\n\n", m)
|
||||||
elseif m == "all" then
|
elseif m == "all" then
|
||||||
template.style = nil
|
template.style = nil
|
||||||
|
@ -215,6 +213,15 @@ function parse_template(meta, styles, line, templates, mods)
|
||||||
aegisub.out(3, "No fx name following fx modifier\nIn template line: %s\nEffect field: %s\n\n", line.text, line.effect)
|
aegisub.out(3, "No fx name following fx modifier\nIn template line: %s\nEffect field: %s\n\n", line.text, line.effect)
|
||||||
template.fx = nil
|
template.fx = nil
|
||||||
end
|
end
|
||||||
|
elseif m == "fxgroup" then
|
||||||
|
local fx, t = string.headtail(rest)
|
||||||
|
if fx ~= "" then
|
||||||
|
template.fxgroup = fx
|
||||||
|
rest = t
|
||||||
|
else
|
||||||
|
aegisub.out(3, "No fxgroup name following fxgroup modifier\nIn template linee: %s\nEffect field: %s\n\n", line.text, line.effect)
|
||||||
|
template.fxgroup = nil
|
||||||
|
end
|
||||||
else
|
else
|
||||||
aegisub.out(3, "Unknown modifier in template: %s\nIn template line: %s\nEffect field: %s\n\n", m, line.text, line.effect)
|
aegisub.out(3, "Unknown modifier in template: %s\nIn template line: %s\nEffect field: %s\n\n", m, line.text, line.effect)
|
||||||
end
|
end
|
||||||
|
@ -229,14 +236,16 @@ function parse_template(meta, styles, line, templates, mods)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Iterator function, return all templates that apply to the given line
|
-- Iterator function, return all templates that apply to the given line
|
||||||
function matching_templates(templates, line)
|
function matching_templates(templates, line, tenv)
|
||||||
local lastkey = nil
|
local lastkey = nil
|
||||||
local function test_next()
|
local function test_next()
|
||||||
local k, t = next(templates, lastkey)
|
local k, t = next(templates, lastkey)
|
||||||
lastkey = k
|
lastkey = k
|
||||||
if not t then
|
if not t then
|
||||||
return nil
|
return nil
|
||||||
elseif t.style == line.style or not t.style then
|
elseif (t.style == line.style or not t.style) and
|
||||||
|
(not t.fxgroup or
|
||||||
|
(t.fxgroup and tenv.fxgroup[t.fxgroup] ~= false)) then
|
||||||
return t
|
return t
|
||||||
else
|
else
|
||||||
return test_next()
|
return test_next()
|
||||||
|
@ -297,6 +306,7 @@ function apply_templates(meta, styles, subs, templates)
|
||||||
line.end_time = newend
|
line.end_time = newend
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
tenv.fxgroup = {}
|
||||||
|
|
||||||
-- run all run-once code snippets
|
-- run all run-once code snippets
|
||||||
for k, t in pairs(templates.once) do
|
for k, t in pairs(templates.once) do
|
||||||
|
@ -426,7 +436,7 @@ function apply_line(meta, styles, subs, line, templates, tenv)
|
||||||
|
|
||||||
-- Apply all line templates
|
-- Apply all line templates
|
||||||
aegisub.debug.out(5, "Running line templates\n")
|
aegisub.debug.out(5, "Running line templates\n")
|
||||||
for t in matching_templates(templates.line, line) do
|
for t in matching_templates(templates.line, line, tenv) do
|
||||||
if t.code then
|
if t.code then
|
||||||
aegisub.debug.out(5, "Code template, %s\n", t.code)
|
aegisub.debug.out(5, "Code template, %s\n", t.code)
|
||||||
run_code_template(t, tenv)
|
run_code_template(t, tenv)
|
||||||
|
@ -560,7 +570,7 @@ function apply_syllable_templates(syl, line, templates, tenv, varctx, subs)
|
||||||
local applied_templates = false
|
local applied_templates = false
|
||||||
|
|
||||||
-- Loop over all templates matching the line style
|
-- Loop over all templates matching the line style
|
||||||
for t in matching_templates(templates, line) do
|
for t in matching_templates(templates, line, tenv) do
|
||||||
tenv.syl = syl
|
tenv.syl = syl
|
||||||
set_ctx_syl(varctx, line, syl)
|
set_ctx_syl(varctx, line, syl)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue