diff --git a/automation/include/karaskel-auto4.lua b/automation/include/karaskel-auto4.lua index 275cb56aa..3edd88152 100644 --- a/automation/include/karaskel-auto4.lua +++ b/automation/include/karaskel-auto4.lua @@ -96,30 +96,7 @@ function karaskel.collect_head(subs, generate_furigana) end -- Fix resolution data - if meta.playresx then - meta.res_x = math.floor(meta.playresx) - end - if meta.playresy then - meta.res_y = math.floor(meta.playresy) - end - if meta.res_x == 0 and meta_res_y == 0 then - meta.res_x = 384 - meta.res_y = 288 - elseif meta.res_x == 0 then - -- This is braindead, but it's how TextSub does things... - if meta.res_y == 1024 then - meta.res_x = 1280 - else - meta.res_x = meta.res_y / 3 * 4 - end - elseif meta.res_y == 0 then - -- As if 1280x960 didn't exist - if meta.res_x == 1280 then - meta.res_y = 1024 - else - meta.res_y = meta.res_x * 3 / 4 - end - end + meta.res_x, meta.res_y = subs.script_resolution() local video_x, video_y = aegisub.video_size() if video_y then diff --git a/src/auto4_lua.h b/src/auto4_lua.h index a3d284558..46068173e 100644 --- a/src/auto4_lua.h +++ b/src/auto4_lua.h @@ -104,6 +104,7 @@ namespace Automation4 { int IterNext(lua_State *L); int LuaParseKaraokeData(lua_State *L); + int LuaGetScriptResolution(lua_State *L); void LuaSetUndoPoint(lua_State *L); diff --git a/src/auto4_lua_assfile.cpp b/src/auto4_lua_assfile.cpp index e4856016e..9a73aee2b 100644 --- a/src/auto4_lua_assfile.cpp +++ b/src/auto4_lua_assfile.cpp @@ -352,6 +352,8 @@ namespace Automation4 { lua_pushcclosure(L, closure_wrapper_v<&LuaAssFile::ObjectInsert, false>, 1); else if (strcmp(idx, "append") == 0) lua_pushcclosure(L, closure_wrapper_v<&LuaAssFile::ObjectAppend, false>, 1); + else if (strcmp(idx, "script_resolution") == 0) + lua_pushcclosure(L, closure_wrapper<&LuaAssFile::LuaGetScriptResolution>, 1); else { // idiot lua_pop(L, 1); @@ -648,6 +650,15 @@ namespace Automation4 { return 1; } + int LuaAssFile::LuaGetScriptResolution(lua_State *L) + { + int w, h; + ass->GetResolution(w, h); + push_value(L, w); + push_value(L, h); + return 2; + } + void LuaAssFile::LuaSetUndoPoint(lua_State *L) { if (!can_set_undo)