Make it so auto4lua macros can have an IsActive function. Probably not very useful at the moment.

Originally committed to SVN as r5644.
This commit is contained in:
Thomas Goyne 2011-09-28 19:49:18 +00:00
parent 60ea67661a
commit 59d11f4cc4

View file

@ -655,7 +655,25 @@ namespace Automation4 {
bool LuaCommand::IsActive(const agi::Context *c)
{
return false;
if (!(cmd_type & cmd::COMMAND_TOGGLE)) return false;
GetFeatureFunction("isactive");
LuaAssFile *subsobj = new LuaAssFile(L, c->ass);
lua_pushinteger(L, transform_selection(L, c));
int err = lua_pcall(L, 3, 1, 0);
subsobj->ProcessingComplete();
bool result = false;
if (err)
wxLogWarning("Runtime error in Lua macro IsActive function:\n%s", get_wxstring(L, -1));
else
result = !!lua_toboolean(L, -1);
// clean up stack (result or error message)
lua_pop(L, 1);
return result;
}
// LuaFeatureFilter