axmol/extensions/scripting/lua-bindings/manual/cocostudio/axlua_cocostudio_manual.cpp

649 lines
20 KiB
C++
Raw Normal View History

2014-03-10 14:04:58 +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-08-08 18:02:17 +08:00
https://axys1.github.io/
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +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-03-10 14:04:58 +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-03-10 14:04:58 +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-08-08 18:02:17 +08:00
#include "scripting/lua-bindings/manual/cocostudio/axlua_cocostudio_manual.hpp"
#include "scripting/lua-bindings/auto/axlua_studio_auto.hpp"
#include "scripting/lua-bindings/auto/axlua_csloader_auto.hpp"
#include "scripting/lua-bindings/manual/cocostudio/axlua_csloader_manual.hpp"
2016-04-18 15:09:21 +08:00
#include "scripting/lua-bindings/manual/tolua_fix.h"
#include "scripting/lua-bindings/manual/LuaBasicConversions.h"
2022-07-12 21:31:54 +08:00
#include "scripting/lua-bindings/manual/base/LuaScriptHandlerMgr.h"
#include "scripting/lua-bindings/manual/CCLuaValue.h"
2020-10-21 17:57:50 +08:00
#include "CocoStudio.h"
#include "ActionTimeline/CCActionTimelineCache.h"
#include "scripting/lua-bindings/manual/CCLuaEngine.h"
#include "scripting/lua-bindings/manual/cocostudio/CustomGUIReader.h"
2014-03-10 14:04:58 +08:00
using namespace cocostudio;
2021-12-25 10:04:45 +08:00
class LuaArmatureWrapper : public Ref
2014-03-10 14:04:58 +08:00
{
public:
LuaArmatureWrapper();
virtual ~LuaArmatureWrapper();
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
virtual void addArmatureFileInfoAsyncCallback(float percent);
};
2021-12-25 10:04:45 +08:00
LuaArmatureWrapper::LuaArmatureWrapper() {}
2014-03-10 14:04:58 +08:00
2021-12-25 10:04:45 +08:00
LuaArmatureWrapper::~LuaArmatureWrapper() {}
2014-03-10 14:04:58 +08:00
void LuaArmatureWrapper::addArmatureFileInfoAsyncCallback(float percent)
{
2021-12-25 10:04:45 +08:00
int handler =
ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
2014-03-10 14:04:58 +08:00
if (0 != handler)
{
2021-12-25 10:04:45 +08:00
LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FILE_ASYNC,
(void*)&percent);
BasicScriptData data(this, (void*)&wrapperData);
2014-03-10 14:04:58 +08:00
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data);
}
}
2022-08-08 18:02:17 +08:00
static int axlua_ArmatureAnimation_setMovementEventCallFunc(lua_State* L)
2014-03-10 14:04:58 +08:00
{
if (nullptr == L)
return 0;
2021-12-25 10:04:45 +08:00
int argc = 0;
2014-03-10 14:04:58 +08:00
ArmatureAnimation* self = nullptr;
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
tolua_Error tolua_err;
2021-12-25 10:04:45 +08:00
if (!tolua_isusertype(L, 1, "ccs.ArmatureAnimation", 0, &tolua_err))
goto tolua_lerror;
2014-03-10 14:04:58 +08:00
#endif
2021-12-25 10:04:45 +08:00
self = static_cast<ArmatureAnimation*>(tolua_tousertype(L, 1, 0));
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (nullptr == self)
{
2022-08-08 18:02:17 +08:00
tolua_error(L, "invalid 'self' in function 'axlua_ArmatureAnimation_setMovementEventCallFunc'\n", NULL);
2021-12-25 10:04:45 +08:00
return 0;
}
2014-03-10 14:04:58 +08:00
#endif
argc = lua_gettop(L) - 1;
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
if (1 == argc)
{
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
2014-03-10 14:04:58 +08:00
{
goto tolua_lerror;
}
#endif
2021-12-25 10:04:45 +08:00
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
2021-12-08 00:11:53 +08:00
LuaArmatureWrapper* wrapper = new LuaArmatureWrapper();
2014-03-10 14:04:58 +08:00
wrapper->autorelease();
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
Vector<LuaArmatureWrapper*> vec;
vec.pushBack(wrapper);
2021-12-25 10:04:45 +08:00
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler,
ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
self->setMovementEventCallFunc(
2021-12-26 23:26:34 +08:00
[=](Armature* armature, MovementEventType movementType, std::string_view movementID) {
2021-12-25 10:04:45 +08:00
if (0 != handler)
{
2021-12-28 11:05:34 +08:00
LuaArmatureMovementEventData movementData(armature, (int)movementType, movementID);
2021-12-25 10:04:45 +08:00
LuaArmatureWrapperEventData wrapperData(
LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT, (void*)&movementData);
BasicScriptData data((void*)vec.at(0), (void*)&wrapperData);
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data);
}
});
2014-03-10 14:04:58 +08:00
return 0;
}
2021-12-25 10:04:45 +08:00
luaL_error(L,
"'setMovementEventCallFunc' function of ArmatureAnimation has wrong number of arguments: %d, was "
"expecting %d\n",
argc, 1);
2014-03-10 14:04:58 +08:00
return 0;
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
tolua_lerror:
2021-12-25 10:04:45 +08:00
tolua_error(L, "#ferror in function 'setMovementEventCallFunc'.", &tolua_err);
2014-03-10 14:04:58 +08:00
return 0;
#endif
}
2022-08-08 18:02:17 +08:00
static int axlua_ArmatureAnimation_setFrameEventCallFunc(lua_State* L)
2014-03-10 14:04:58 +08:00
{
if (nullptr == L)
return 0;
2021-12-25 10:04:45 +08:00
int argc = 0;
2014-03-10 14:04:58 +08:00
ArmatureAnimation* self = nullptr;
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
tolua_Error tolua_err;
2021-12-25 10:04:45 +08:00
if (!tolua_isusertype(L, 1, "ccs.ArmatureAnimation", 0, &tolua_err))
goto tolua_lerror;
2014-03-10 14:04:58 +08:00
#endif
2021-12-25 10:04:45 +08:00
self = static_cast<ArmatureAnimation*>(tolua_tousertype(L, 1, 0));
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (nullptr == self)
{
2022-08-08 18:02:17 +08:00
tolua_error(L, "invalid 'self' in function 'axlua_ArmatureAnimation_setFrameEventCallFunc'\n", NULL);
2021-12-25 10:04:45 +08:00
return 0;
}
2014-03-10 14:04:58 +08:00
#endif
argc = lua_gettop(L) - 1;
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
if (1 == argc)
{
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
2014-03-10 14:04:58 +08:00
{
goto tolua_lerror;
}
#endif
2021-12-25 10:04:45 +08:00
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
2021-12-08 00:11:53 +08:00
LuaArmatureWrapper* wrapper = new LuaArmatureWrapper();
2014-03-10 14:04:58 +08:00
wrapper->autorelease();
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
Vector<LuaArmatureWrapper*> vec;
vec.pushBack(wrapper);
2021-12-25 10:04:45 +08:00
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler,
ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
2021-12-28 11:00:34 +08:00
self->setFrameEventCallFunc(
[=](cocostudio::Bone* bone, std::string_view frameEventName, int originFrameIndex, int currentFrameIndex) {
if (0 != handler)
{
std::string strFrameEventName(frameEventName);
2021-12-25 10:04:45 +08:00
2021-12-28 11:00:34 +08:00
LuaArmatureFrameEventData frameData(bone, frameEventName, originFrameIndex, currentFrameIndex);
2021-12-25 10:04:45 +08:00
2021-12-28 11:00:34 +08:00
LuaArmatureWrapperEventData wrapperData(
LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT, (void*)&frameData);
2021-12-25 10:04:45 +08:00
2021-12-28 11:00:34 +08:00
BasicScriptData data((void*)vec.at(0), (void*)&wrapperData);
2021-12-25 10:04:45 +08:00
2021-12-28 11:00:34 +08:00
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data);
}
});
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
return 0;
}
2021-12-25 10:04:45 +08:00
luaL_error(
L,
"'setFrameEventCallFunc' function of ArmatureAnimation has wrong number of arguments: %d, was expecting %d\n",
argc, 1);
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
tolua_lerror:
2021-12-25 10:04:45 +08:00
tolua_error(L, "#ferror in function 'setFrameEventCallFunc'.", &tolua_err);
2014-03-10 14:04:58 +08:00
#endif
return 0;
2014-03-10 14:04:58 +08:00
}
static void extendArmatureAnimation(lua_State* L)
{
lua_pushstring(L, "ccs.ArmatureAnimation");
lua_rawget(L, LUA_REGISTRYINDEX);
2021-12-25 10:04:45 +08:00
if (lua_istable(L, -1))
2014-03-10 14:04:58 +08:00
{
2022-08-08 18:02:17 +08:00
tolua_function(L, "setMovementEventCallFunc", axlua_ArmatureAnimation_setMovementEventCallFunc);
tolua_function(L, "setFrameEventCallFunc", axlua_ArmatureAnimation_setFrameEventCallFunc);
2014-03-10 14:04:58 +08:00
}
lua_pop(L, 1);
}
2022-08-08 18:02:17 +08:00
static int axlua_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc(lua_State* L)
2014-03-10 14:04:58 +08:00
{
if (nullptr == L)
2021-12-25 10:04:45 +08:00
return 0;
int argc = 0;
2014-03-10 14:04:58 +08:00
ArmatureDataManager* self = nullptr;
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
tolua_Error tolua_err;
2021-12-25 10:04:45 +08:00
if (!tolua_isusertype(L, 1, "ccs.ArmatureDataManager", 0, &tolua_err))
goto tolua_lerror;
2014-03-10 14:04:58 +08:00
#endif
2021-12-25 10:04:45 +08:00
self = static_cast<ArmatureDataManager*>(tolua_tousertype(L, 1, 0));
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (nullptr == self)
{
tolua_error(L,
2022-08-08 18:02:17 +08:00
"invalid 'self' in function 'axlua_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc'\n",
2021-12-25 10:04:45 +08:00
NULL);
return 0;
}
2014-03-10 14:04:58 +08:00
#endif
argc = lua_gettop(L) - 1;
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
if (2 == argc)
{
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (!tolua_isstring(L, 2, 0, &tolua_err) || !toluafix_isfunction(L, 3, "LUA_FUNCTION", 0, &tolua_err))
2014-03-10 14:04:58 +08:00
{
goto tolua_lerror;
}
#endif
const char* configFilePath = tolua_tostring(L, 2, "");
2021-12-25 10:04:45 +08:00
LUA_FUNCTION handler = (toluafix_ref_function(L, 3, 0));
2021-12-08 00:11:53 +08:00
LuaArmatureWrapper* wrapper = new LuaArmatureWrapper();
2014-03-10 14:04:58 +08:00
wrapper->autorelease();
2021-12-25 10:04:45 +08:00
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler,
ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
self->addArmatureFileInfoAsync(configFilePath, wrapper,
2022-07-15 19:17:01 +08:00
AX_SCHEDULE_SELECTOR(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback));
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
return 0;
}
else if (4 == argc)
{
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (!tolua_isstring(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3, 0, &tolua_err) ||
!tolua_isstring(L, 4, 0, &tolua_err) || !toluafix_isfunction(L, 5, "LUA_FUNCTION", 0, &tolua_err))
2014-03-10 14:04:58 +08:00
{
goto tolua_lerror;
}
2021-12-25 10:04:45 +08:00
#endif
const char* imagePath = tolua_tostring(L, 2, "");
const char* plistPath = tolua_tostring(L, 3, "");
2014-03-10 14:04:58 +08:00
const char* configFilePath = tolua_tostring(L, 4, "");
2021-12-25 10:04:45 +08:00
LUA_FUNCTION handler = (toluafix_ref_function(L, 5, 0));
2021-12-08 00:11:53 +08:00
LuaArmatureWrapper* wrapper = new LuaArmatureWrapper();
2014-03-10 14:04:58 +08:00
wrapper->autorelease();
2021-12-25 10:04:45 +08:00
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler,
ScriptHandlerMgr::HandlerType::ARMATURE_EVENT);
self->addArmatureFileInfoAsync(imagePath, plistPath, configFilePath, wrapper,
2022-07-15 19:17:01 +08:00
AX_SCHEDULE_SELECTOR(LuaArmatureWrapper::addArmatureFileInfoAsyncCallback));
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
return 0;
}
2021-12-25 10:04:45 +08:00
luaL_error(L,
"'addArmatureFileInfoAsync' function of ArmatureDataManager has wrong number of arguments: %d, was "
"expecting %d\n",
argc, 1);
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
tolua_lerror:
2021-12-25 10:04:45 +08:00
tolua_error(L, "#ferror in function 'addArmatureFileInfoAsync'.", &tolua_err);
2014-03-10 14:04:58 +08:00
#endif
return 0;
2014-03-10 14:04:58 +08:00
}
static void extendArmatureDataManager(lua_State* L)
{
lua_pushstring(L, "ccs.ArmatureDataManager");
lua_rawget(L, LUA_REGISTRYINDEX);
2021-12-25 10:04:45 +08:00
if (lua_istable(L, -1))
2014-03-10 14:04:58 +08:00
{
2021-12-25 10:04:45 +08:00
tolua_function(L, "addArmatureFileInfoAsync",
2022-08-08 18:02:17 +08:00
axlua_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc);
2014-03-10 14:04:58 +08:00
}
lua_pop(L, 1);
}
2022-08-08 18:02:17 +08:00
static int axlua_extension_Bone_setIgnoreMovementBoneData(lua_State* L)
2014-03-10 14:04:58 +08:00
{
if (nullptr == L)
return 0;
2021-12-25 10:04:45 +08:00
int argc = 0;
2014-03-10 14:04:58 +08:00
cocostudio::Bone* self = nullptr;
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
tolua_Error tolua_err;
2021-12-25 10:04:45 +08:00
if (!tolua_isusertype(L, 1, "ccs.Bone", 0, &tolua_err))
goto tolua_lerror;
2014-03-10 14:04:58 +08:00
#endif
2021-12-25 10:04:45 +08:00
self = static_cast<cocostudio::Bone*>(tolua_tousertype(L, 1, 0));
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (nullptr == self)
{
2022-08-08 18:02:17 +08:00
tolua_error(L, "invalid 'self' in function 'axlua_extension_Bone_setIgnoreMovementBoneData'\n", NULL);
2021-12-25 10:04:45 +08:00
return 0;
}
2014-03-10 14:04:58 +08:00
#endif
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
argc = lua_gettop(L) - 1;
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
if (1 == argc)
{
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
if (!tolua_isboolean(L, 2, 0, &tolua_err))
goto tolua_lerror;
#endif
bool ignore = (bool)tolua_toboolean(L, 2, 0);
self->setIgnoreMovementBoneData(ignore);
return 0;
}
2021-12-25 10:04:45 +08:00
luaL_error(L, "'setIgnoreMovementBoneData' function of Bone has wrong number of arguments: %d, was expecting %d\n",
argc, 0);
2014-03-10 14:04:58 +08:00
return 0;
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
tolua_lerror:
2021-12-25 10:04:45 +08:00
tolua_error(L, "#ferror in function 'setIgnoreMovementBoneData'.", &tolua_err);
2014-03-10 14:04:58 +08:00
return 0;
#endif
}
2022-08-08 18:02:17 +08:00
static int axlua_extension_Bone_getIgnoreMovementBoneData(lua_State* L)
2014-03-10 14:04:58 +08:00
{
if (nullptr == L)
return 0;
2021-12-25 10:04:45 +08:00
int argc = 0;
2014-03-10 14:04:58 +08:00
cocostudio::Bone* self = nullptr;
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
tolua_Error tolua_err;
2021-12-25 10:04:45 +08:00
if (!tolua_isusertype(L, 1, "ccs.Bone", 0, &tolua_err))
goto tolua_lerror;
2014-03-10 14:04:58 +08:00
#endif
2021-12-25 10:04:45 +08:00
self = static_cast<cocostudio::Bone*>(tolua_tousertype(L, 1, 0));
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (nullptr == self)
{
2022-08-08 18:02:17 +08:00
tolua_error(L, "invalid 'self' in function 'axlua_extension_Bone_getIgnoreMovementBoneData'\n", NULL);
2021-12-25 10:04:45 +08:00
return 0;
}
2014-03-10 14:04:58 +08:00
#endif
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
argc = lua_gettop(L) - 1;
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
if (0 == argc)
{
tolua_pushboolean(L, self->getIgnoreMovementBoneData());
return 1;
}
2021-12-25 10:04:45 +08:00
luaL_error(L, "'getIgnoreMovementBoneData' function of Bone has wrong number of arguments: %d, was expecting %d\n",
argc, 0);
2014-03-10 14:04:58 +08:00
return 0;
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-03-10 14:04:58 +08:00
tolua_lerror:
2021-12-25 10:04:45 +08:00
tolua_error(L, "#ferror in function 'getIgnoreMovementBoneData'.", &tolua_err);
2014-03-10 14:04:58 +08:00
return 0;
#endif
}
static void extendBone(lua_State* L)
{
lua_pushstring(L, "ccs.Bone");
lua_rawget(L, LUA_REGISTRYINDEX);
2021-12-25 10:04:45 +08:00
if (lua_istable(L, -1))
2014-03-10 14:04:58 +08:00
{
2022-08-08 18:02:17 +08:00
tolua_function(L, "setIgnoreMovementBoneData", axlua_extension_Bone_setIgnoreMovementBoneData);
tolua_function(L, "getIgnoreMovementBoneData", axlua_extension_Bone_getIgnoreMovementBoneData);
2014-03-10 14:04:58 +08:00
}
lua_pop(L, 1);
}
2022-08-08 18:02:17 +08:00
int axlua_studio_ActionTimelineCache_getInstance(lua_State* L)
{
int argc = 0;
bool ok = true;
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
tolua_Error tolua_err;
#endif
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (!tolua_isusertable(L, 1, "ccs.ActionTimelineCache", 0, &tolua_err))
goto tolua_lerror;
#endif
2021-12-25 10:04:45 +08:00
argc = lua_gettop(L) - 1;
2021-12-25 10:04:45 +08:00
if (argc == 0)
{
2021-12-25 10:04:45 +08:00
if (!ok)
return 0;
cocostudio::timeline::ActionTimelineCache* ret = cocostudio::timeline::ActionTimelineCache::getInstance();
2021-12-25 10:04:45 +08:00
tolua_pushusertype(L, (void*)ret, "ccs.ActionTimelineCache");
return 1;
}
2021-12-25 10:04:45 +08:00
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccs.ActionTimelineCache:getInstance",
argc, 0);
return 0;
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
tolua_lerror:
2022-08-08 18:02:17 +08:00
tolua_error(L, "#ferror in function 'axlua_studio_ActionTimelineCache_getInstance'.", &tolua_err);
#endif
return 0;
}
static void extendActionTimelineCache(lua_State* L)
{
lua_pushstring(L, "ccs.ActionTimelineCache");
lua_rawget(L, LUA_REGISTRYINDEX);
2021-12-25 10:04:45 +08:00
if (lua_istable(L, -1))
{
2022-08-08 18:02:17 +08:00
tolua_function(L, "getInstance", axlua_studio_ActionTimelineCache_getInstance);
}
lua_pop(L, 1);
}
2022-08-08 18:02:17 +08:00
static int axlua_ActionTimeline_setFrameEventCallFunc(lua_State* L)
{
if (nullptr == L)
return 0;
2021-12-25 10:04:45 +08:00
int argc = 0;
cocostudio::timeline::ActionTimeline* self = nullptr;
2021-12-25 10:04:45 +08:00
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
tolua_Error tolua_err;
2021-12-25 10:04:45 +08:00
if (!tolua_isusertype(L, 1, "ccs.ActionTimeline", 0, &tolua_err))
goto tolua_lerror;
#endif
2021-12-25 10:04:45 +08:00
self = static_cast<cocostudio::timeline::ActionTimeline*>(tolua_tousertype(L, 1, 0));
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (nullptr == self)
{
2022-08-08 18:02:17 +08:00
tolua_error(L, "invalid 'self' in function 'axlua_ActionTimeline_setFrameEventCallFunc'\n", NULL);
2021-12-25 10:04:45 +08:00
return 0;
}
#endif
argc = lua_gettop(L) - 1;
2021-12-25 10:04:45 +08:00
if (1 == argc)
{
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err))
{
goto tolua_lerror;
}
#endif
2021-12-25 10:04:45 +08:00
LUA_FUNCTION handler = (toluafix_ref_function(L, 2, 0));
self->setFrameEventCallFunc([=](cocostudio::timeline::Frame* frame) {
2021-11-15 19:05:08 +08:00
auto stack = LuaEngine::getInstance()->getLuaStack();
toluafix_pushusertype_ccobject(stack->getLuaState(), frame->_ID, &frame->_luaID, (void*)frame,
getLuaTypeName(frame, "ccs.Frame"));
stack->executeFunctionByHandler(handler, 1);
});
2021-12-25 10:04:45 +08:00
return 0;
}
2021-12-25 10:04:45 +08:00
luaL_error(
L, "'setFrameEventCallFunc' function of ActionTimeline has wrong number of arguments: %d, was expecting %d\n",
argc, 1);
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
tolua_lerror:
2021-12-25 10:04:45 +08:00
tolua_error(L, "#ferror in function 'setFrameEventCallFunc'.", &tolua_err);
#endif
return 0;
}
static void extendActionTimeline(lua_State* L)
{
lua_pushstring(L, "ccs.ActionTimeline");
lua_rawget(L, LUA_REGISTRYINDEX);
2021-12-25 10:04:45 +08:00
if (lua_istable(L, -1))
{
2022-08-08 18:02:17 +08:00
tolua_function(L, "setFrameEventCallFunc", axlua_ActionTimeline_setFrameEventCallFunc);
}
lua_pop(L, 1);
}
2022-08-08 18:02:17 +08:00
int axlua_CustomGUIReader_create(lua_State* L)
2014-08-29 18:50:21 +08:00
{
int argc = 0;
bool ok = true;
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-08-29 18:50:21 +08:00
tolua_Error tolua_err;
#endif
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (!tolua_isusertable(L, 1, "ccs.CustomGUIReader", 0, &tolua_err))
goto tolua_lerror;
2014-08-29 18:50:21 +08:00
#endif
2021-12-25 10:04:45 +08:00
argc = lua_gettop(L) - 1;
2014-08-29 18:50:21 +08:00
2021-12-25 10:04:45 +08:00
do
2014-08-29 18:50:21 +08:00
{
if (argc == 3)
{
std::string arg0;
2021-12-25 10:04:45 +08:00
ok &= luaval_to_std_string(L, 2, &arg0, "ccs.CustomGUIReader:create");
if (!ok)
{
break;
}
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (!toluafix_isfunction(L, 3, "LUA_FUNCTION", 0, &tolua_err))
{
2014-08-29 18:50:21 +08:00
goto tolua_lerror;
}
#endif
2021-12-25 10:04:45 +08:00
LUA_FUNCTION arg1 = toluafix_ref_function(L, 3, 0);
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2021-12-25 10:04:45 +08:00
if (!toluafix_isfunction(L, 4, "LUA_FUNCTION", 0, &tolua_err))
{
2014-08-29 18:50:21 +08:00
goto tolua_lerror;
}
#endif
2021-12-25 10:04:45 +08:00
LUA_FUNCTION arg2 = toluafix_ref_function(L, 4, 0);
2014-08-29 18:50:21 +08:00
cocostudio::CustomGUIReader* ret = cocostudio::CustomGUIReader::create(arg0, arg1, arg2);
2021-12-25 10:04:45 +08:00
object_to_luaval<cocostudio::CustomGUIReader>(L, "ccs.CustomGUIReader", (cocostudio::CustomGUIReader*)ret);
2014-08-29 18:50:21 +08:00
return 1;
}
} while (0);
2021-12-25 10:04:45 +08:00
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d", "ccs.CustomGUIReader:create", argc, 1);
2014-08-29 18:50:21 +08:00
return 0;
2022-08-08 18:02:17 +08:00
#if _AX_DEBUG >= 1
2014-08-29 18:50:21 +08:00
tolua_lerror:
2022-08-08 18:02:17 +08:00
tolua_error(L, "#ferror in function 'axlua_CustomGUIReader_create'.", &tolua_err);
2014-08-29 18:50:21 +08:00
#endif
return 0;
}
int register_all_ax_coco_studio_manual(lua_State* L)
2014-03-10 14:04:58 +08:00
{
if (nullptr == L)
return 0;
extendArmatureAnimation(L);
extendArmatureDataManager(L);
extendBone(L);
extendActionTimelineCache(L);
extendActionTimeline(L);
2021-12-25 10:04:45 +08:00
2014-03-10 14:04:58 +08:00
return 0;
}
2022-07-12 21:31:54 +08:00
int lua_register_axis_coco_studio_CustomGUIReader(lua_State* L)
2014-08-29 18:50:21 +08:00
{
2021-12-25 10:04:45 +08:00
tolua_module(L, "ccs", 0);
tolua_beginmodule(L, "ccs");
2021-12-25 10:04:45 +08:00
tolua_usertype(L, "ccs.CustomGUIReader");
2022-07-12 21:31:54 +08:00
tolua_cclass(L, "CustomGUIReader", "ccs.CustomGUIReader", "ax.Ref", nullptr);
2014-08-29 18:50:21 +08:00
2021-12-25 10:04:45 +08:00
tolua_beginmodule(L, "CustomGUIReader");
2022-08-08 18:02:17 +08:00
tolua_function(L, "create", axlua_CustomGUIReader_create);
tolua_endmodule(L);
2021-12-25 10:04:45 +08:00
auto typeName = typeid(cocostudio::CustomGUIReader).name();
g_luaType[reinterpret_cast<uintptr_t>(typeName)] = "ccs.CustomGUIReader";
2021-12-25 10:04:45 +08:00
g_typeCast[typeName] = "ccs.CustomGUIReader";
tolua_endmodule(L);
2014-08-29 18:50:21 +08:00
return 1;
}
int register_cocostudio_module(lua_State* L)
{
lua_getglobal(L, "_G");
2021-12-25 10:04:45 +08:00
if (lua_istable(L, -1)) // stack:...,_G,
{
register_all_ax_studio(L);
register_all_ax_csloader(L);
register_all_ax_coco_studio_manual(L);
register_all_ax_csloader_manual(L);
2022-07-12 21:31:54 +08:00
lua_register_axis_coco_studio_CustomGUIReader(L);
}
lua_pop(L, 1);
return 1;
}