Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable TAS Editor Lua functions on QT #758

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 60 additions & 30 deletions src/lua-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5114,17 +5114,19 @@ static int taseditor_registermanual(lua_State *L)
lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]);
#ifdef __WIN_DRIVER__
taseditor_lua.enableRunFunction(caption);
#elif defined __QT_DRIVER__
taseditor_lua->enableRunFunction(caption);
#endif
return 1;
return 1;
}

// bool taseditor.engaged()
static int taseditor_engaged(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushboolean(L, taseditor_lua.engaged());
#else
lua_pushboolean(L, false);
#elif defined __QT_DRIVER__
lua_pushboolean(L, taseditor_lua->engaged());
#endif
return 1;
}
Expand All @@ -5134,8 +5136,8 @@ static int taseditor_markedframe(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushboolean(L, taseditor_lua.markedframe(luaL_checkinteger(L, 1)));
#else
lua_pushboolean(L, false);
#elif defined __QT_DRIVER__
lua_pushboolean(L, taseditor_lua->markedframe(luaL_checkinteger(L, 1)));
#endif
return 1;
}
Expand All @@ -5145,8 +5147,8 @@ static int taseditor_getmarker(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushinteger(L, taseditor_lua.getmarker(luaL_checkinteger(L, 1)));
#else
lua_pushinteger(L, -1);
#elif defined __QT_DRIVER__
lua_pushinteger(L, taseditor_lua->getmarker(luaL_checkinteger(L, 1)));
#endif
return 1;
}
Expand All @@ -5156,8 +5158,8 @@ static int taseditor_setmarker(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushinteger(L, taseditor_lua.setmarker(luaL_checkinteger(L, 1)));
#else
lua_pushinteger(L, -1);
#elif defined __QT_DRIVER__
lua_pushinteger(L, taseditor_lua->setmarker(luaL_checkinteger(L, 1)));
#endif
return 1;
}
Expand All @@ -5167,6 +5169,8 @@ static int taseditor_removemarker(lua_State *L)
{
#ifdef __WIN_DRIVER__
taseditor_lua.removemarker(luaL_checkinteger(L, 1));
#elif defined __QT_DRIVER__
taseditor_lua->removemarker(luaL_checkinteger(L, 1));
#endif
return 0;
}
Expand All @@ -5176,8 +5180,8 @@ static int taseditor_getnote(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushstring(L, taseditor_lua.getnote(luaL_checkinteger(L, 1)));
#else
lua_pushnil(L);
#elif defined __QT_DRIVER__
lua_pushstring(L, taseditor_lua->getnote(luaL_checkinteger(L, 1)));
#endif
return 1;
}
Expand All @@ -5187,6 +5191,8 @@ static int taseditor_setnote(lua_State *L)
{
#ifdef __WIN_DRIVER__
taseditor_lua.setnote(luaL_checkinteger(L, 1), luaL_checkstring(L, 2));
#elif defined __QT_DRIVER__
taseditor_lua->setnote(luaL_checkinteger(L, 1), luaL_checkstring(L, 2));
#endif
return 0;
}
Expand All @@ -5196,8 +5202,8 @@ static int taseditor_getcurrentbranch(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushinteger(L, taseditor_lua.getcurrentbranch());
#else
lua_pushinteger(L, -1);
#elif defined __QT_DRIVER__
lua_pushinteger(L, taseditor_lua->getcurrentbranch());
#endif
return 1;
}
Expand All @@ -5207,8 +5213,8 @@ static int taseditor_getrecordermode(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushstring(L, taseditor_lua.getrecordermode());
#else
lua_pushnil(L);
#elif defined __QT_DRIVER__
lua_pushstring(L, taseditor_lua->getrecordermode());
#endif
return 1;
}
Expand All @@ -5218,8 +5224,8 @@ static int taseditor_getsuperimpose(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushinteger(L, taseditor_lua.getsuperimpose());
#else
lua_pushinteger(L, -1);
#elif defined __QT_DRIVER__
lua_pushinteger(L, taseditor_lua->getsuperimpose());
#endif
return 1;
}
Expand All @@ -5229,8 +5235,8 @@ static int taseditor_getlostplayback(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushinteger(L, taseditor_lua.getlostplayback());
#else
lua_pushinteger(L, -1);
#elif defined __QT_DRIVER__
lua_pushinteger(L, taseditor_lua->getlostplayback());
#endif
return 1;
}
Expand All @@ -5240,8 +5246,8 @@ static int taseditor_getplaybacktarget(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushinteger(L, taseditor_lua.getplaybacktarget());
#else
lua_pushinteger(L, -1);
#elif defined __QT_DRIVER__
lua_pushinteger(L, taseditor_lua->getplaybacktarget());
#endif
return 1;
}
Expand All @@ -5251,6 +5257,8 @@ static int taseditor_setplayback(lua_State *L)
{
#ifdef __WIN_DRIVER__
taseditor_lua.setplayback(luaL_checkinteger(L, 1));
#elif defined __QT_DRIVER__
taseditor_lua->setplayback(luaL_checkinteger(L, 1));
#endif
return 0;
}
Expand All @@ -5260,17 +5268,22 @@ static int taseditor_stopseeking(lua_State *L)
{
#ifdef __WIN_DRIVER__
taseditor_lua.stopseeking();
#elif defined __QT_DRIVER__
taseditor_lua->stopseeking();
#endif
return 0;
}

// table taseditor.getselection()
static int taseditor_getselection(lua_State *L)
{
#ifdef __WIN_DRIVER__
// create temp vector and provide its reference to TAS Editor for filling the vector with data
std::vector<int> cur_set;
#ifdef __WIN_DRIVER__
taseditor_lua.getselection(cur_set);
#elif defined __QT_DRIVER__
taseditor_lua->getselection(cur_set);
#endif
int size = cur_set.size();
if (size)
{
Expand All @@ -5284,16 +5297,12 @@ static int taseditor_getselection(lua_State *L)
{
lua_pushnil(L);
}
#else
lua_pushnil(L);
#endif
return 1;
}

// taseditor.setselection(table new_set)
static int taseditor_setselection(lua_State *L)
{
#ifdef __WIN_DRIVER__
std::vector<int> cur_set;
// retrieve new_set data from table to vector
if (!lua_isnil(L, 1))
Expand All @@ -5310,7 +5319,10 @@ static int taseditor_setselection(lua_State *L)
}
}
// and provide its reference to TAS Editor for changing selection
#ifdef __WIN_DRIVER__
taseditor_lua.setselection(cur_set);
#elif defined __QT_DRIVER__
taseditor_lua->setselection(cur_set);
#endif
return 0;
}
Expand All @@ -5320,8 +5332,8 @@ static int taseditor_getinput(lua_State *L)
{
#ifdef __WIN_DRIVER__
lua_pushinteger(L, taseditor_lua.getinput(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)));
#else
lua_pushinteger(L, -1);
#elif defined __QT_DRIVER__
lua_pushinteger(L, taseditor_lua->getinput(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)));
#endif
return 1;
}
Expand All @@ -5331,6 +5343,8 @@ static int taseditor_submitinputchange(lua_State *L)
{
#ifdef __WIN_DRIVER__
taseditor_lua.submitinputchange(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2), luaL_checkinteger(L, 3));
#elif defined __QT_DRIVER__
taseditor_lua->submitinputchange(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2), luaL_checkinteger(L, 3));
#endif
return 0;
}
Expand All @@ -5340,6 +5354,8 @@ static int taseditor_submitinsertframes(lua_State *L)
{
#ifdef __WIN_DRIVER__
taseditor_lua.submitinsertframes(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2));
#elif defined __QT_DRIVER__
taseditor_lua->submitinsertframes(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2));
#endif
return 0;
}
Expand All @@ -5349,6 +5365,8 @@ static int taseditor_submitdeleteframes(lua_State *L)
{
#ifdef __WIN_DRIVER__
taseditor_lua.submitdeleteframes(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2));
#elif defined __QT_DRIVER__
taseditor_lua->submitdeleteframes(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2));
#endif
return 0;
}
Expand All @@ -5368,8 +5386,18 @@ static int taseditor_applyinputchanges(lua_State *L)
else
lua_pushinteger(L, taseditor_lua.applyinputchanges(""));
}
#else
lua_pushinteger(L, -1);
#elif defined __QT_DRIVER__
if (lua_isnil(L, 1))
{
lua_pushinteger(L, taseditor_lua->applyinputchanges(""));
} else
{
const char* name = lua_tostring(L, 1);
if (name)
lua_pushinteger(L, taseditor_lua->applyinputchanges(name));
else
lua_pushinteger(L, taseditor_lua->applyinputchanges(""));
}
#endif
return 1;
}
Expand All @@ -5379,6 +5407,8 @@ static int taseditor_clearinputchanges(lua_State *L)
{
#ifdef __WIN_DRIVER__
taseditor_lua.clearinputchanges();
#elif defined __QT_DRIVER__
taseditor_lua->clearinputchanges();
#endif
return 0;
}
Expand Down