mirror of
https://github.com/odrling/Aegisub
synced 2025-04-11 22:56:02 +02:00
Implement aegisub.video_size() function in Automation 4 Lua. Returns nil if no video is loaded, otherwise returns xres,yres,ar,artype.
Originally committed to SVN as r2337.
This commit is contained in:
parent
30a0b7e82b
commit
e737471043
@ -44,7 +44,9 @@
|
|||||||
#include "ass_override.h"
|
#include "ass_override.h"
|
||||||
#include "text_file_reader.h"
|
#include "text_file_reader.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
#include "vfr.h"
|
#include "vfr.h"
|
||||||
|
#include "video_context.h"
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
#include "../lua51/src/lualib.h"
|
#include "../lua51/src/lualib.h"
|
||||||
@ -177,6 +179,8 @@ namespace Automation4 {
|
|||||||
lua_setfield(L, -2, "frame_from_ms");
|
lua_setfield(L, -2, "frame_from_ms");
|
||||||
lua_pushcfunction(L, LuaMsFromFrame);
|
lua_pushcfunction(L, LuaMsFromFrame);
|
||||||
lua_setfield(L, -2, "ms_from_frame");
|
lua_setfield(L, -2, "ms_from_frame");
|
||||||
|
lua_pushcfunction(L, LuaVideoSize);
|
||||||
|
lua_setfield(L, -2, "video_size");
|
||||||
// aegisub.lua_automation_version
|
// aegisub.lua_automation_version
|
||||||
lua_pushinteger(L, 4);
|
lua_pushinteger(L, 4);
|
||||||
lua_setfield(L, -2, "lua_automation_version");
|
lua_setfield(L, -2, "lua_automation_version");
|
||||||
@ -393,6 +397,21 @@ namespace Automation4 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LuaScript::LuaVideoSize(lua_State *L)
|
||||||
|
{
|
||||||
|
VideoContext *ctx = VideoContext::Get();
|
||||||
|
if (ctx->IsLoaded()) {
|
||||||
|
lua_pushnumber(L, ctx->GetWidth());
|
||||||
|
lua_pushnumber(L, ctx->GetHeight());
|
||||||
|
lua_pushnumber(L, ctx->GetAspectRatioValue());
|
||||||
|
lua_pushnumber(L, ctx->GetAspectRatioType());
|
||||||
|
return 4;
|
||||||
|
} else {
|
||||||
|
lua_pushnil(L);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// LuaThreadedCall
|
// LuaThreadedCall
|
||||||
|
|
||||||
|
@ -194,6 +194,7 @@ namespace Automation4 {
|
|||||||
static int LuaInclude(lua_State *L);
|
static int LuaInclude(lua_State *L);
|
||||||
static int LuaFrameFromMs(lua_State *L);
|
static int LuaFrameFromMs(lua_State *L);
|
||||||
static int LuaMsFromFrame(lua_State *L);
|
static int LuaMsFromFrame(lua_State *L);
|
||||||
|
static int LuaVideoSize(lua_State *L);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LuaScript(const wxString &filename);
|
LuaScript(const wxString &filename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user