Add aegisub.keyframes, which returns a table with all of the frame numbers which are keyframes

Originally committed to SVN as r6129.
This commit is contained in:
Thomas Goyne 2011-12-22 21:29:56 +00:00
parent f974fdb1b2
commit 4a3f2b8412
2 changed files with 16 additions and 0 deletions

View File

@ -261,6 +261,7 @@ namespace Automation4 {
set_field(L, "frame_from_ms", LuaFrameFromMs);
set_field(L, "ms_from_frame", LuaMsFromFrame);
set_field(L, "video_size", LuaVideoSize);
set_field(L, "keyframes", LuaGetKeyframes);
set_field(L, "lua_automation_version", 4);
// store aegisub table to globals
@ -496,6 +497,20 @@ namespace Automation4 {
}
}
int LuaScript::LuaGetKeyframes(lua_State *L)
{
const agi::Context *c = get_context(L);
std::vector<int> const& kf = c->videoController->GetKeyFrames();
lua_newtable(L);
for (size_t i = 0; i < kf.size(); ++i) {
lua_pushinteger(L, kf[i]);
lua_rawseti(L, -2, i);
}
return 1;
}
static void lua_threaded_call(ProgressSink *ps, lua_State *L, int nargs, int nresults, bool can_open_config, bool *failed)
{
LuaProgressSink lps(L, ps, can_open_config);

View File

@ -309,6 +309,7 @@ namespace Automation4 {
static int LuaFrameFromMs(lua_State *L);
static int LuaMsFromFrame(lua_State *L);
static int LuaVideoSize(lua_State *L);
static int LuaGetKeyframes(lua_State *L);
public:
LuaScript(const wxString &filename);