2014-11-26 21:54:18 +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
|
|
|
|
2014-11-26 21:54:18 +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
|
|
|
|
2014-11-26 21:54:18 +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
|
|
|
|
2014-11-26 21:54:18 +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_axis_csloader_manual.hpp"
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "scripting/lua-bindings/manual/tolua_fix.h"
|
|
|
|
#include "scripting/lua-bindings/manual/LuaBasicConversions.h"
|
|
|
|
#include "scripting/lua-bindings/manual/CCLuaValue.h"
|
|
|
|
#include "scripting/lua-bindings/manual/CCLuaEngine.h"
|
2020-10-21 17:57:50 +08:00
|
|
|
#include "ActionTimeline/CCActionTimeline.h"
|
|
|
|
#include "ActionTimeline/CSLoader.h"
|
|
|
|
#include "ActionTimeline/CCActionTimelineNode.h"
|
2014-11-26 21:54:18 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_csloader_CSLoader_createTimeline(lua_State* tolua_S)
|
2014-11-26 21:54:18 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-11-26 21:54:18 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.CSLoader", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-11-26 21:54:18 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
std::string arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &arg0, "ax.CSLoader:createTimeline");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
cocostudio::timeline::ActionTimeline* ret = axis::CSLoader::createTimeline(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
object_to_luaval<cocostudio::timeline::ActionTimeline>(tolua_S, "ccs.ActionTimeline",
|
|
|
|
(cocostudio::timeline::ActionTimeline*)ret);
|
2014-11-26 21:54:18 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ax.CSLoader:createTimeline", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
1);
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-11-26 21:54:18 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_CSLoader_createTimeline'.", &tolua_err);
|
2014-11-26 21:54:18 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_csloader_CSLoader_createNode(lua_State* tolua_S)
|
2015-04-13 16:29:44 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-04-13 16:29:44 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.CSLoader", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-04-13 16:29:44 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
2015-04-13 16:29:44 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
std::string filename;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &filename, "ax.CSLoader:createNode");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err))
|
2015-04-13 16:29:44 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(tolua_S, 3, 0));
|
2022-07-11 17:50:21 +08:00
|
|
|
auto callback = [handler](axis::Ref* ref) {
|
2015-04-13 16:29:44 +08:00
|
|
|
if (nullptr == ref)
|
|
|
|
return;
|
2021-11-15 19:05:08 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(stack->getLuaState(), ref->_ID, &(ref->_luaID), (void*)ref, "ax.Ref");
|
2021-11-15 19:05:08 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 1);
|
2015-04-13 16:29:44 +08:00
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Node* ret = axis::CSLoader::createNode(filename, callback);
|
2015-04-13 16:29:44 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)ret, handler);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::Node>(tolua_S, "ax.Node", (axis::Node*)ret);
|
2015-04-13 16:29:44 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} while (0);
|
2021-12-25 10:04:45 +08:00
|
|
|
ok = true;
|
2015-04-13 16:29:44 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
std::string filename;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &filename, "ax.CSLoader:createNode");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Node* ret = axis::CSLoader::createNode(filename);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::Node>(tolua_S, "ax.Node", (axis::Node*)ret);
|
2015-04-13 16:29:44 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} while (0);
|
2021-12-25 10:04:45 +08:00
|
|
|
ok = true;
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "ax.CSLoader:createNode", argc, 1);
|
2015-04-13 16:29:44 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-04-13 16:29:44 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_csloader_CSLoader_createNode'.", &tolua_err);
|
2015-04-13 16:29:44 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int register_all_axis_csloader_manual(lua_State* L)
|
2014-11-26 21:54:18 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "ax.CSLoader");
|
2014-11-26 21:54:18 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-11-26 21:54:18 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "createTimeline", lua_axis_csloader_CSLoader_createTimeline);
|
|
|
|
tolua_function(L, "createNode", lua_axis_csloader_CSLoader_createNode);
|
2014-11-26 21:54:18 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-11-26 21:54:18 +08:00
|
|
|
return 0;
|
|
|
|
}
|