2015-01-21 10:06:48 +08:00
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-09 22:23:34 +08:00
|
|
|
https://axis-project.github.io/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
#include "scripting/lua-bindings/manual/cocostudio/lua-cocostudio-conversions.h"
|
2020-10-21 17:57:50 +08:00
|
|
|
#include "ActionTimeline/CCActionTimeline.h"
|
2015-01-21 10:06:48 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
extern void luaval_to_native_err(lua_State* L, const char* msg, tolua_Error* err, const char* funcName);
|
2015-01-21 10:06:48 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool luaval_to_animationInfo(lua_State* L, int lo, cocostudio::timeline::AnimationInfo* outValue, const char* funcName)
|
2015-01-21 10:06:48 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L || nullptr == outValue)
|
|
|
|
return false;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(L, lo, 0, &tolua_err))
|
2015-01-21 10:06:48 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
luaval_to_native_err(L, "#ferror:", &tolua_err, funcName);
|
2015-01-21 10:06:48 +08:00
|
|
|
#endif
|
|
|
|
ok = false;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
if (ok)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(L, "name"); /* L: paramStack key */
|
|
|
|
lua_gettable(L, lo); /* L: paramStack paramStack[lo][key] */
|
|
|
|
outValue->name = lua_isstring(L, -1) ? lua_tostring(L, -1) : "";
|
|
|
|
lua_pop(L, 1); /* L: paramStack*/
|
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
lua_pushstring(L, "startIndex");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_gettable(L, lo);
|
|
|
|
outValue->startIndex = lua_isnumber(L, -1) ? (int)lua_tonumber(L, -1) : 0;
|
|
|
|
lua_pop(L, 1);
|
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
lua_pushstring(L, "endIndex");
|
|
|
|
lua_gettable(L, lo);
|
2021-12-25 10:04:45 +08:00
|
|
|
outValue->endIndex = lua_isnumber(L, -1) ? (int)lua_tonumber(L, -1) : 0;
|
2015-01-21 10:06:48 +08:00
|
|
|
lua_pop(L, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
return true;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void animationInfo_to_luaval(lua_State* L, const cocostudio::timeline::AnimationInfo& inValue)
|
2015-01-21 10:06:48 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
lua_newtable(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
lua_pushstring(L, "name");
|
|
|
|
lua_pushstring(L, inValue.name.c_str());
|
|
|
|
lua_rawset(L, -3);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
lua_pushstring(L, "startIndex");
|
|
|
|
lua_pushnumber(L, (lua_Number)inValue.startIndex);
|
|
|
|
lua_rawset(L, -3);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-01-21 10:06:48 +08:00
|
|
|
lua_pushstring(L, "endIndex");
|
|
|
|
lua_pushnumber(L, (lua_Number)inValue.endIndex);
|
|
|
|
lua_rawset(L, -3);
|
|
|
|
}
|