Add subtitles.script_resolution()

Returns the values from the headers if they're present, or does the
insane Gabest-logic if one or both are missing.
This commit is contained in:
Thomas Goyne 2014-12-24 13:56:23 -08:00
parent c43bf1e822
commit 1fd44ea8da
3 changed files with 13 additions and 24 deletions

View File

@ -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

View File

@ -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);

View File

@ -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)