aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2025-03-11 17:08:02 +0000
committergarret <garret@airmail.cc>2025-03-11 17:08:02 +0000
commit0250b20043022429cf4c0b6d7233ee7f6eada999 (patch)
treeaa5966e2b718c82495070577b16e469ca35c179a
parent9f455636d19474b404ec89e1e17152e3c08a2430 (diff)
downloadaegisub-scripts-0250b20043022429cf4c0b6d7233ee7f6eada999.tar.gz
aegisub-scripts-0250b20043022429cf4c0b6d7233ee7f6eada999.tar.bz2
aegisub-scripts-0250b20043022429cf4c0b6d7233ee7f6eada999.zip
restyler: prompt for different style if "Default" is missing
-rw-r--r--restyler.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/restyler.lua b/restyler.lua
index d0a2082..782d7c3 100644
--- a/restyler.lua
+++ b/restyler.lua
@@ -48,11 +48,27 @@ function main(sub, sel)
local new_style_name = "Default"
local new_style = styles[new_style_name]
+ if new_style == nil then
+ local style_names = {}
+ for k, v in ipairs(styles) do
+ table.insert(style_names, v.name)
+ end
+
+ local button_ok, result = aegisub.dialog.display({
+ {x=0, y=0,class="label", label="You don't have a \""..new_style_name.."\" style. Select a style to change the selected lines to:"},
+ {x=0, y=1, class="dropdown", items=style_names, value=style_names[1], name="style"},
+ })
+ if not button_ok then aegisub.cancel() end
+
+ new_style_name = result.style
+ new_style = styles[new_style_name]
+ end
+
for h, i in ipairs(sel) do
-- TODO: automatically exclude styles (also configurable)
local line = sub[i]
- local old_style = styles[line.style] -- reinventing the wheel a bit here, since karaskel can do this with preproc_line_size (line.styleref), but it also adds loads of other crap we don't care about for the same functionality in the end, so ¯\_(ツ)_/¯
+ local old_style = styles[line.style]
local italic = get_new(old_style.italic, new_style.italic)
local align = get_new(old_style.align, new_style.align)
line.style = new_style_name