2014-05-04 14:37:55 +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.
|
2022-05-13 21:06:17 +08:00
|
|
|
Copyright (c) 2021-2022 Bytedance Inc.
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-09 22:23:34 +08:00
|
|
|
https://axis-project.github.io/
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +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:
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +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/base/lua_axis_base_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"
|
2014-05-04 14:37:55 +08:00
|
|
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
2021-12-25 10:04:45 +08:00
|
|
|
# include <WS2tcpip.h>
|
2014-05-04 14:37:55 +08:00
|
|
|
#else
|
2021-12-25 10:04:45 +08:00
|
|
|
# include <sys/socket.h>
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
|
2016-04-18 15:09:21 +08:00
|
|
|
#include "2d/CCActionCamera.h"
|
|
|
|
#include "2d/CCActionCatmullRom.h"
|
|
|
|
#include "2d/CCActionGrid.h"
|
|
|
|
#include "2d/CCActionInterval.h"
|
|
|
|
#include "2d/CCAtlasNode.h"
|
|
|
|
#include "2d/CCCamera.h"
|
|
|
|
#include "2d/CCMenu.h"
|
|
|
|
#include "2d/CCMenuItem.h"
|
|
|
|
#include "2d/CCMotionStreak.h"
|
|
|
|
#include "2d/CCParticleBatchNode.h"
|
|
|
|
#include "2d/CCParticleSystem.h"
|
|
|
|
#include "2d/CCScene.h"
|
|
|
|
#include "2d/CCSpriteBatchNode.h"
|
2019-10-23 14:58:31 +08:00
|
|
|
#include "2d/CCFastTMXLayer.h"
|
|
|
|
#include "2d/CCFastTMXTiledMap.h"
|
2019-06-19 13:45:14 +08:00
|
|
|
#include "2d/CCRenderTexture.h"
|
2016-04-18 15:09:21 +08:00
|
|
|
#include "base/CCEventDispatcher.h"
|
|
|
|
#include "base/CCEventListenerKeyboard.h"
|
|
|
|
#include "base/CCEventListenerMouse.h"
|
|
|
|
#include "base/CCEventListenerTouch.h"
|
|
|
|
#include "base/CCProperties.h"
|
|
|
|
#include "base/CCScheduler.h"
|
|
|
|
#include "base/CCUserDefault.h"
|
|
|
|
#include "base/ccUtils.h"
|
|
|
|
#include "platform/CCApplication.h"
|
|
|
|
#include "platform/CCDevice.h"
|
|
|
|
#include "platform/CCFileUtils.h"
|
|
|
|
#include "platform/CCGLView.h"
|
|
|
|
#include "renderer/CCTextureCache.h"
|
2019-05-05 15:26:34 +08:00
|
|
|
#include "renderer/ccShaders.h"
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
void LuaNode::draw(axis::Renderer* renderer, const axis::Mat4& transform, uint32_t flags)
|
2019-06-27 17:44:07 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int handler =
|
|
|
|
ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::LUANODE_DRAW);
|
2019-06-27 17:44:07 +08:00
|
|
|
if (0 != handler)
|
|
|
|
{
|
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
auto* L = stack->getLuaState();
|
2019-06-27 17:44:07 +08:00
|
|
|
|
|
|
|
lua_newtable(L);
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
stack->pushFloat(transform.m[i]);
|
|
|
|
lua_rawseti(L, -2, i + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
stack->pushFloat(_globalZOrder);
|
|
|
|
stack->executeFunctionByHandler(handler, 2);
|
|
|
|
stack->clean();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tolua_reg_LuaNode_type(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_usertype(tolua_S, "ax.LuaNode");
|
2019-06-27 17:44:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_collect_LuaNode(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
LuaNode* self = (LuaNode*)tolua_tousertype(tolua_S, 1, 0);
|
|
|
|
Mtolua_delete(self);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef TOLUA_DISABLE_tolua_Cocos2d_LuaNode_create00
|
|
|
|
static int tolua_Cocos2d_LuaNode_create00(lua_State* tolua_S)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
# ifndef TOLUA_RELEASE
|
2019-06-27 17:44:07 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.LuaNode", 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err))
|
2019-06-27 17:44:07 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2019-06-27 17:44:07 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
LuaNode* luaNode = new LuaNode();
|
|
|
|
luaNode->autorelease();
|
2021-12-25 10:04:45 +08:00
|
|
|
int nID = (int)luaNode->_ID;
|
2021-12-08 00:11:53 +08:00
|
|
|
int* pLuaID = &luaNode->_luaID;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)luaNode, "ax.LuaNode");
|
2019-06-27 17:44:07 +08:00
|
|
|
}
|
|
|
|
return 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
# ifndef TOLUA_RELEASE
|
|
|
|
tolua_lerror:
|
2019-06-27 17:44:07 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'create'.", &tolua_err);
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2019-06-27 17:44:07 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int tolua_Cocos2d_LuaNode_registerScriptDrawHandler00(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
#ifndef TOLUA_RELEASE
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.LuaNode", 0, &tolua_err) ||
|
2021-12-25 10:04:45 +08:00
|
|
|
(tolua_isvaluenil(tolua_S, 2, &tolua_err) || !toluafix_isfunction(tolua_S, 2, "LUA_FUNCTION", 0, &tolua_err)) ||
|
2019-06-27 17:44:07 +08:00
|
|
|
!tolua_isnoobj(tolua_S, 3, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
LuaNode* luaNode = (LuaNode*)tolua_tousertype(tolua_S, 1, 0);
|
2019-06-27 17:44:07 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(tolua_S, 2, 0));
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)luaNode, handler,
|
|
|
|
ScriptHandlerMgr::HandlerType::LUANODE_DRAW);
|
2019-06-27 17:44:07 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#ifndef TOLUA_RELEASE
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S, "#ferror in function 'registerScriptDrawHandler'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2019-06-27 17:44:07 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_Cocos2d_LuaNode_unregisterScriptDrawHandler00(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
#ifndef TOLUA_RELEASE
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.LuaNode", 0, &tolua_err) || !tolua_isnoobj(tolua_S, 2, &tolua_err))
|
2019-06-27 17:44:07 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
LuaNode* luaNode = (LuaNode*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)luaNode,
|
|
|
|
ScriptHandlerMgr::HandlerType::LUANODE_DRAW);
|
2019-06-27 17:44:07 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#ifndef TOLUA_RELEASE
|
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S, "#ferror in function 'unregisterScriptDrawhandler'.", &tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
TOLUA_API int tolua_luanode_open(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
tolua_open(tolua_S);
|
|
|
|
tolua_reg_LuaNode_type(tolua_S);
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_module(tolua_S, "ax", 0);
|
|
|
|
tolua_beginmodule(tolua_S, "ax");
|
|
|
|
tolua_cclass(tolua_S, "LuaNode", "ax.LuaNode", "ax.Node", tolua_collect_LuaNode);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_beginmodule(tolua_S, "LuaNode");
|
|
|
|
tolua_function(tolua_S, "create", tolua_Cocos2d_LuaNode_create00);
|
|
|
|
tolua_endmodule(tolua_S);
|
2019-06-27 17:44:07 +08:00
|
|
|
tolua_endmodule(tolua_S);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int register_luanode_manual(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.LuaNode");
|
2019-06-27 17:44:07 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
|
|
|
{
|
|
|
|
lua_pushstring(tolua_S, "registerScriptDrawHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_Cocos2d_LuaNode_registerScriptDrawHandler00);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "unregisterScriptDrawHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_Cocos2d_LuaNode_unregisterScriptDrawHandler00);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S)
|
|
|
|
{
|
2014-05-15 16:54:55 +08:00
|
|
|
if (nullptr == tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.MenuItemImage", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
|
|
|
MenuItemImage* tolua_ret = (MenuItemImage*)MenuItemImage::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
// Uncheck
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.MenuItemImage");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} while (0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2014-05-15 16:54:55 +08:00
|
|
|
if (argc == 2)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err) || !tolua_isstring(tolua_S, 3, 0, &tolua_err))
|
2014-05-15 16:54:55 +08:00
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
ok = true;
|
|
|
|
break;
|
|
|
|
}
|
2022-07-09 22:23:34 +08:00
|
|
|
auto normalImage = axislua_tosv(tolua_S, 2);
|
|
|
|
auto selectedImage = axislua_tosv(tolua_S, 3);
|
2022-05-13 21:06:17 +08:00
|
|
|
MenuItemImage* tolua_ret = (MenuItemImage*)MenuItemImage::create(normalImage, selectedImage);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.MenuItemImage");
|
2014-05-15 16:54:55 +08:00
|
|
|
return 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
} while (0);
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
2014-05-15 16:54:55 +08:00
|
|
|
if (argc == 3)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err) || !tolua_isstring(tolua_S, 3, 0, &tolua_err) ||
|
|
|
|
!tolua_isstring(tolua_S, 4, 0, &tolua_err))
|
2014-05-15 16:54:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
break;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2022-07-09 22:23:34 +08:00
|
|
|
auto normalImage = axislua_tosv(tolua_S, 2);
|
|
|
|
auto selectedImage = axislua_tosv(tolua_S, 3);
|
|
|
|
auto disabledImage = axislua_tosv(tolua_S, 4);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
MenuItemImage* tolua_ret = (MenuItemImage*)MenuItemImage::create(normalImage, selectedImage, disabledImage);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.MenuItemImage");
|
2014-05-15 16:54:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
} while (0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.MenuItemImage:create", argc, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_MenuItemImage_create'.\n", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItemLabel_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.MenuItemLabel", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (1 == argc)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 2, "ax.Node", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
Node* label = ((Node*)tolua_tousertype(tolua_S, 2, 0));
|
|
|
|
MenuItemLabel* tolua_ret = (MenuItemLabel*)MenuItemLabel::create(label);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.MenuItemLabel");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.MenuItemLabel:create", argc, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_MenuItemImage_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItemFont_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.MenuItemFont", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (1 == argc)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2022-07-09 22:23:34 +08:00
|
|
|
auto value = axislua_tosv(tolua_S, 2);
|
2021-12-25 10:04:45 +08:00
|
|
|
MenuItemFont* tolua_ret = (MenuItemFont*)MenuItemFont::create(value);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.MenuItemFont");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.MenuItemFont:create", argc, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_MenuItemImage_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItemSprite_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.MenuItemSprite", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (argc >= 2 && argc <= 3)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 2, "ax.Node", 0, &tolua_err) ||
|
|
|
|
!tolua_isusertype(tolua_S, 3, "ax.Node", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
if (3 == argc && !tolua_isusertype(tolua_S, 4, "ax.Node", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
Node* normalSprite = ((Node*)tolua_tousertype(tolua_S, 2, 0));
|
|
|
|
Node* selectedSprite = ((Node*)tolua_tousertype(tolua_S, 3, 0));
|
2014-05-04 14:37:55 +08:00
|
|
|
Node* disabledSprite = NULL;
|
|
|
|
if (3 == argc)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
disabledSprite = (Node*)tolua_tousertype(tolua_S, 4, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
MenuItemSprite* tolua_ret =
|
|
|
|
(MenuItemSprite*)MenuItemSprite::create(normalSprite, selectedSprite, disabledSprite);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.MenuItemSprite");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.MenuItemSprite:create", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
3);
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_MenuItemImage_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Menu_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.Menu", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (argc > 0)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
Vector<MenuItem*> items;
|
2019-09-19 18:43:31 +08:00
|
|
|
int i = 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
while (i <= argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1 + i, "ax.MenuItem", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::MenuItem* item = static_cast<axis::MenuItem*>(tolua_tousertype(tolua_S, 1 + i, NULL));
|
2014-05-04 14:37:55 +08:00
|
|
|
if (NULL != item)
|
|
|
|
{
|
|
|
|
items.pushBack(item);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Menu* tolua_ret = axis::Menu::createWithArray(items);
|
2021-12-25 10:04:45 +08:00
|
|
|
// UnCheck
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.Menu");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
else if (argc == 0)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Menu* tolua_ret = axis::Menu::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.Menu");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-12-01 15:53:41 +08:00
|
|
|
luaL_error(tolua_S, "create wrong number of arguments: %d, was expecting %d\n", argc, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Menu_create'.\n", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_Menu_alignItemsInRows(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Menu* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Menu", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<Menu*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_Menu_alignItemsInRows'\n", nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if (argc > 0)
|
|
|
|
{
|
|
|
|
ValueVector items;
|
|
|
|
if (luavals_variadic_to_ccvaluevector(tolua_S, argc, &items))
|
|
|
|
{
|
|
|
|
self->alignItemsInRowsWithArray(items);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S,
|
2022-07-12 21:31:54 +08:00
|
|
|
"'alignItemsInRows' has wrong number of arguments in tolua_axis_Menu_alignItemsInRows: %d, was "
|
2021-12-25 10:04:45 +08:00
|
|
|
"expecting %d\n",
|
|
|
|
argc, 1);
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'alignItemsInRows'.\n", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_Menu_alignItemsInColumns(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Menu* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Menu", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<Menu*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_axis_Menu_alignItemsInColumns'\n", nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if (argc > 0)
|
|
|
|
{
|
|
|
|
ValueVector items;
|
|
|
|
if (luavals_variadic_to_ccvaluevector(tolua_S, argc, &items))
|
|
|
|
{
|
|
|
|
self->alignItemsInColumnsWithArray(items);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S,
|
2022-07-12 21:31:54 +08:00
|
|
|
"'alignItemsInColumns' has wrong number of arguments in tolua_axis_Menu_alignItemsInColumns: %d, "
|
2021-12-25 10:04:45 +08:00
|
|
|
"was expecting %d\n",
|
|
|
|
argc, 1);
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_Menu_alignItemsInColumns'.\n", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItemToggle_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.MenuItemToggle", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (argc >= 1)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
MenuItemToggle* tolua_ret = MenuItemToggle::create();
|
|
|
|
if (NULL == tolua_ret)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-09-24 11:31:35 +08:00
|
|
|
for (int i = 0; i < argc; ++i)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, i + 2, "ax.MenuItem", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
MenuItem* item = static_cast<MenuItem*>(tolua_tousertype(tolua_S, i + 2, 0));
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_ret->addSubItem(item);
|
|
|
|
}
|
|
|
|
tolua_ret->setSelectedIndex(0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.MenuItemToggle");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.MenuItemToggle:create", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
1);
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_MenuItemToggle_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItem_registerScriptTapHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
MenuItem* cobj = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.MenuItem", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = static_cast<axis::MenuItemImage*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == cobj)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'tolua_cocos2d_MenuItem_registerScriptTapHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err))
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)cobj, handler,
|
|
|
|
ScriptHandlerMgr::HandlerType::MENU_CLICKED);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.MenuItem:registerScriptTapHandler", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_MenuItem_registerScriptTapHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_MenuItem_unregisterScriptTapHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
MenuItem* cobj = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.MenuItem", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = static_cast<axis::MenuItemImage*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == cobj)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'tolua_cocos2d_MenuItem_unregisterScriptTapHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (0 == argc)
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)cobj, ScriptHandlerMgr::HandlerType::MENU_CLICKED);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.MenuItem:unregisterScriptTapHandler", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_MenuItem_unregisterScriptTapHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int executeScriptTouchHandler(Layer* layer, EventTouch::EventCode eventType, Touch* touch, Event* event)
|
|
|
|
{
|
|
|
|
TouchScriptData data(eventType, layer, touch, event);
|
|
|
|
ScriptEvent scriptEvent(kTouchEvent, &data);
|
2020-02-25 16:54:05 +08:00
|
|
|
return ScriptEngineManager::sendEventToLua(scriptEvent);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int executeScriptTouchesHandler(Layer* layer,
|
|
|
|
EventTouch::EventCode eventType,
|
|
|
|
const std::vector<Touch*>& touches,
|
|
|
|
Event* event)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
TouchesScriptData data(eventType, layer, touches, event);
|
|
|
|
ScriptEvent scriptEvent(kTouchesEvent, &data);
|
2020-02-25 16:54:05 +08:00
|
|
|
return ScriptEngineManager::sendEventToLua(scriptEvent);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void setTouchEnabledForLayer(Layer* layer, bool enabled)
|
|
|
|
{
|
|
|
|
if (nullptr == layer)
|
|
|
|
return;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
// Only for v2.x lua compatibility
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_setTouchPriority(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_setTouchEnabled(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_setTouchEnabled'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!tolua_isboolean(L, 2, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
bool enabled = tolua_toboolean(L, 2, 0);
|
|
|
|
setTouchEnabledForLayer(self, enabled);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:setTouchEnabled", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_setTouchEnabled'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_isTouchEnabled(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_isTouchEnabled'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (0 == argc)
|
|
|
|
{
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
|
|
|
tolua_pushboolean(L, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:isTouchEnabled", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_isTouchEnabled'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_setTouchMode(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_setTouchMode'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!tolua_isnumber(L, 2, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
int32_t mode = (int32_t)tolua_tonumber(L, 2, 0);
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:setTouchMode", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_setTouchMode'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_getTouchMode(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_getTouchMode'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (0 == argc)
|
|
|
|
{
|
|
|
|
int32_t ret = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushnumber(L, (lua_Number)ret); // TODO:
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:getTouchMode", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_getTouchMode'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_setSwallowsTouches(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_setSwallowsTouches'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!tolua_isboolean(L, 2, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
bool swallowsTouches = tolua_toboolean(L, 2, 0);
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:setSwallowsTouches", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_setSwallowsTouches'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_isSwallowsTouches(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_isSwallowsTouches'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (0 == argc)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushboolean(L, 0); // TODO:
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:isSwallowsTouches", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_isSwallowsTouches'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_setKeyboardEnabled(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_setKeyboardEnabled'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!tolua_isboolean(L, 2, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
bool enabled = tolua_toboolean(L, 2, 0);
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:setKeyboardEnabled", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_setKeyboardEnabled'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_isKeyboardEnabled(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_isKeyboardEnabled'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (0 == argc)
|
|
|
|
{
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:isKeyboardEnabled", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_isKeyboardEnabled'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_setAccelerometerEnabled(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_setAccelerometerEnabled'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!tolua_isboolean(L, 2, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
bool enabled = tolua_toboolean(L, 2, 0);
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:setAccelerometerEnabled", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_setAccelerometerEnabled'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_isAccelerometerEnabled(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_isAccelerometerEnabled'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (0 == argc)
|
|
|
|
{
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:isAccelerometerEnabled", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_isAccelerometerEnabled'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Layer_setAccelerometerInterval(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(L, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_axis_Layer_setAccelerometerInterval'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!tolua_isnumber(L, 2, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2019-09-19 18:43:31 +08:00
|
|
|
float interval = (float)tolua_tonumber(L, 2, 0);
|
2014-07-16 18:10:05 +08:00
|
|
|
Device::setAccelerometerInterval(interval);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Layer:setAccelerometerInterval", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Layer_setAccelerometerInterval'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Layer_registerScriptTouchHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptTouchHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (argc >= 1 && argc <= 4)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err))
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
bool isMultiTouches = false;
|
2021-12-25 10:04:45 +08:00
|
|
|
int priority = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
bool swallowTouches = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (argc >= 2)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isboolean(tolua_S, 3, 0, &tolua_err))
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
isMultiTouches = (bool)tolua_toboolean(tolua_S, 3, false);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (argc >= 3)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isnumber(tolua_S, 4, 0, &tolua_err))
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
priority = (int)tolua_tonumber(tolua_S, 4, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (argc == 4)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isboolean(tolua_S, 5, 0, &tolua_err))
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
swallowTouches = (bool)tolua_toboolean(tolua_S, 5, true);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
Touch::DispatchMode touchesMode = Touch::DispatchMode::ALL_AT_ONCE;
|
|
|
|
if (!isMultiTouches)
|
|
|
|
touchesMode = Touch::DispatchMode::ONE_BY_ONE;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
2021-12-25 10:04:45 +08:00
|
|
|
// ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler,
|
|
|
|
// ScriptHandlerMgr::HandlerType::TOUCHES);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.Layer:registerScriptTouchHandler", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Layer_registerScriptTouchHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Layer_unregisterScriptTouchHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptTouchHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (0 == argc)
|
|
|
|
{
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
|
|
|
// ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::HandlerType::TOUCHES);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.Layer:unregisterScriptTouchHandler", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Layer_unregisterScriptTouchHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Layer_registerScriptKeypadHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptKeypadHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err))
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::KEYPAD);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.Layer:registerScriptKeypadHandler", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Layer_registerScriptKeypadHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Layer_unregisterScriptKeypadHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptKeypadHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (0 == argc)
|
|
|
|
{
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
|
|
|
// ScriptHandlerMgr::getInstance()->removeObjectHandler(self, ScriptHandlerMgr::HandlerType::KEYPAD);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.Layer:unregisterScriptKeypadHandler", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Layer_unregisterScriptKeypadHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Layer_registerScriptAccelerateHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Layer_registerScriptAccelerateHandler'\n",
|
|
|
|
NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err))
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler,
|
|
|
|
ScriptHandlerMgr::HandlerType::ACCELEROMETER);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.Layer:registerScriptAccelerateHandler", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Layer_registerScriptAccelerateHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Layer_unregisterScriptAccelerateHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Layer* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Layer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Layer*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Layer_unregisterScriptAccelerateHandler'\n",
|
|
|
|
NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (0 == argc)
|
|
|
|
{
|
2020-10-18 00:27:23 +08:00
|
|
|
// TODO:
|
2021-12-25 10:04:45 +08:00
|
|
|
// ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self,
|
|
|
|
// ScriptHandlerMgr::HandlerType::ACCELEROMETER);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.Layer:unregisterScriptAccelerateHandler", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Layer_unregisterScriptAccelerateHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Scheduler_scheduleScriptFunc(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Scheduler* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Scheduler", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Scheduler*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Scheduler_scheduleScriptFunc'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (3 == argc)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
|
|
|
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isboolean(tolua_S, 4, 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
|
|
|
float interval = (float)tolua_tonumber(tolua_S, 3, 0);
|
|
|
|
bool paused = (bool)tolua_toboolean(tolua_S, 4, 0);
|
|
|
|
unsigned int tolua_ret = (unsigned int)self->scheduleScriptFunc(handler, interval, paused);
|
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)tolua_ret);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Scheduler:scheduleScriptFunc",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 3);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Scheduler_scheduleScriptFunc'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Scheduler_unscheduleScriptEntry(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Scheduler* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Scheduler", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Scheduler*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Scheduler_unscheduleScriptEntry'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
unsigned int scheduleScriptEntryID = ((unsigned int)tolua_tonumber(tolua_S, 2, 0));
|
2014-05-04 14:37:55 +08:00
|
|
|
self->unscheduleScriptEntry(scheduleScriptEntryID);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.Scheduler:unscheduleScriptEntry", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Scheduler_unscheduleScriptEntry'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-06-19 13:45:14 +08:00
|
|
|
static int tolua_cocos2d_RenderTexture_newImage(lua_State* tolua_S)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::RenderTexture* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-06-19 13:45:14 +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_isusertype(tolua_S, 1, "ax.RenderTexture", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2019-06-19 13:45:14 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::RenderTexture*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-06-19 13:45:14 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'tolua_cocos2d_RenderTexture_newImage'", nullptr);
|
2019-06-19 13:45:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2019-06-19 13:45:14 +08:00
|
|
|
if (argc == 1 || argc == 2)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-06-19 13:45:14 +08:00
|
|
|
ok &= toluafix_isfunction(tolua_S, 2, "LUA_FUNCTION", 0, &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2019-06-19 13:45:14 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'tolua_cocos2d_RenderTexture_newImage'", nullptr);
|
2019-06-19 13:45:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
2022-07-11 17:50:21 +08:00
|
|
|
auto callback = [=](RefPtr<axis::Image> image) {
|
2019-06-19 13:45:14 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
2022-07-12 21:31:54 +08:00
|
|
|
stack->pushObject(image, "ax.Image");
|
2019-06-19 13:45:14 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 1);
|
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
if (argc == 2)
|
2019-06-19 13:45:14 +08:00
|
|
|
{
|
|
|
|
bool flipImage;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_boolean(tolua_S, 3, &flipImage, "ax.RenderTexture:newImage");
|
2019-06-19 13:45:14 +08:00
|
|
|
cobj->newImage(callback, flipImage);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cobj->newImage(callback);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.RenderTexture:newImage", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
2);
|
2019-06-19 13:45:14 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-06-19 13:45:14 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_RenderTexture_newImage'.", &tolua_err);
|
2019-06-19 13:45:14 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-06-19 13:45:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int tolua_cocos2d_Sequence_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2016-04-18 15:09:21 +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.Sequence", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (argc > 0)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
Vector<FiniteTimeAction*> array;
|
|
|
|
|
|
|
|
if (1 == argc && tolua_istable(tolua_S, 2, 0, &tolua_err))
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
luaval_to_ccvector(tolua_S, 2, &array, "ax.Sequence:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-19 18:43:31 +08:00
|
|
|
int i = 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
while (i <= argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1 + i, "ax.FiniteTimeAction", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::FiniteTimeAction* item =
|
|
|
|
static_cast<axis::FiniteTimeAction*>(tolua_tousertype(tolua_S, 1 + i, nullptr));
|
2014-06-23 16:38:35 +08:00
|
|
|
if (nullptr != item)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
array.pushBack(item);
|
|
|
|
}
|
2014-06-23 16:38:35 +08:00
|
|
|
++i;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sequence* tolua_ret = axis::Sequence::create(array);
|
2021-12-25 10:04:45 +08:00
|
|
|
// issue 2433 uncheck
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-06-23 16:38:35 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.Sequence");
|
2014-05-04 14:37:55 +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.Sequence:create", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Sequence_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_CallFunc_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.CallFunc", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 1 || argc == 2)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
bool hasExtraData = false;
|
2021-12-25 10:04:45 +08:00
|
|
|
int ref = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 3, 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
lua_pushvalue(tolua_S, 3);
|
2021-12-25 10:04:45 +08:00
|
|
|
ref = luaL_ref(tolua_S, LUA_REGISTRYINDEX);
|
2014-05-04 14:37:55 +08:00
|
|
|
hasExtraData = true;
|
|
|
|
}
|
2021-12-08 00:11:53 +08:00
|
|
|
LuaCallFunc* tolua_ret = new LuaCallFunc();
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_ret->initWithFunction([=](void* self, Node* target) {
|
|
|
|
int callbackHandler = ScriptHandlerMgr::getInstance()->getObjectHandler(
|
|
|
|
(void*)tolua_ret, ScriptHandlerMgr::HandlerType::CALLFUNC);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (0 != callbackHandler)
|
|
|
|
{
|
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
int argNums = 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
if (nullptr != target)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
stack->pushObject(target, "ax.Node");
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stack->pushNil();
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (hasExtraData)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawgeti(tolua_S, LUA_REGISTRYINDEX, ref);
|
2014-05-04 14:37:55 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
|
|
|
{
|
|
|
|
argNums += 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stack->executeFunctionByHandler(callbackHandler, argNums);
|
|
|
|
if (hasExtraData)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_unref(tolua_S, LUA_REGISTRYINDEX, ref);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
stack->clean();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
tolua_ret->autorelease();
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)tolua_ret, handler,
|
|
|
|
ScriptHandlerMgr::HandlerType::CALLFUNC);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.CallFunc");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.CallFunc:create", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_CallFunc_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Node_registerScriptHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Node* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Node*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Node_registerScriptHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::NODE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Node:registerScriptHandler",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Node_registerScriptHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Node_unregisterScriptHandler(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Node* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Node*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Node_unregisterScriptHandler'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::HandlerType::NODE);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Node:unregisterScriptHandler",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Node_unregisterScriptHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Node* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Node*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
|
|
|
int priority = 0;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (luaval_to_int32(tolua_S, 3, &priority, "ax.Node:scheduleUpdateWithPriorityLua"))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
self->scheduleUpdateWithPriorityLua(handler, priority);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.Node:scheduleUpdateWithPriorityLua", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Node_unscheduleUpdate(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Node* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Node*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Node_unscheduleUpdate'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (0 == argc)
|
|
|
|
{
|
|
|
|
self->unscheduleUpdate();
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Node:unscheduleUpdate", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Node_unscheduleUpdate'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_Node_setContentSize(lua_State* tolua_S)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Node* cobj = NULL;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Node*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Node_setContentSize'", NULL);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Size size;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_size(tolua_S, 2, &size, "ax.Node:setContentSize");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
cobj->setContentSize(size);
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
else if (2 == argc)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
double width;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 2, &width, "ax.Node:setContentSize");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
double height;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 3, &height, "ax.Node:setContentSize");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
cobj->setContentSize(Size(width, height));
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.Node:setContentSize", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Node_setContentSize'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_Node_setAnchorPoint(lua_State* tolua_S)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Node* cobj = NULL;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Node*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Node_setAnchorPoint'", NULL);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2 pt;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 2, &pt, "ax.Node:setAnchorPoint");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
cobj->setAnchorPoint(pt);
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
else if (2 == argc)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
double x;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 2, &x, "ax.Node:setAnchorPoint");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
double y;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 3, &y, "ax.Node:setAnchorPoint");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj->setAnchorPoint(axis::Vec2((float)x, (float)y));
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.Node:setAnchorPoint", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Node_setAnchorPoint'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Node_getPosition(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Node* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::Node*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_Node_getPosition'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc >= 0 && argc <= 2)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isnumber(tolua_S, 2, 1, &tolua_err) || !tolua_isnumber(tolua_S, 3, 1, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
float x = (float)tolua_tonumber(tolua_S, 2, 0);
|
|
|
|
float y = (float)tolua_tonumber(tolua_S, 3, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self->getPosition(&x, &y);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)x);
|
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)y);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 2;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s function in Node has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.Node:getPosition", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Node_getPosition'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Node_enumerateChildren(lua_State* tolua_S)
|
2014-07-08 14:22:05 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Node* cobj = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-07-08 14:22:05 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-07-08 14:22:05 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Node*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-07-08 14:22:05 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Node_enumerateChildren'", nullptr);
|
2014-07-08 14:22:05 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-07-08 14:22:05 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-07-08 14:22:05 +08:00
|
|
|
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err) ||
|
2021-12-25 10:04:45 +08:00
|
|
|
!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err))
|
2014-07-08 14:22:05 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-20 18:41:33 +08:00
|
|
|
auto name = axislua_tosv(tolua_S, 2);
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0);
|
2022-07-20 18:41:33 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
cobj->enumerateChildren(name, [=](Node* node) -> bool {
|
2022-07-20 18:41:33 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int id = node ? (int)node->_ID : -1;
|
2014-07-08 14:22:05 +08:00
|
|
|
int* luaID = node ? &node->_luaID : nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(stack->getLuaState(), id, luaID, (void*)node, "ax.Node");
|
2021-11-15 19:05:08 +08:00
|
|
|
bool ret = stack->executeFunctionByHandler(handler, 1);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-08 14:22:05 +08:00
|
|
|
return ret;
|
|
|
|
});
|
2022-07-20 18:41:33 +08:00
|
|
|
stack->removeScriptHandler(handler);
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-07-08 14:22:05 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "enumerateChildren", argc, 2);
|
2014-07-08 14:22:05 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-07-08 14:22:05 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Node_enumerateChildren'.", &tolua_err);
|
2014-07-08 14:22:05 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-08 14:22:05 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Node_setAdditionalTransform(lua_State* tolua_S)
|
2014-09-28 14:31:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Node* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-28 14:31:58 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-28 14:31:58 +08:00
|
|
|
#endif
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Node*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-28 14:31:58 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Node_setAdditionalTransform'", nullptr);
|
2014-09-28 14:31:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::AffineTransform arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_affinetransform(tolua_S, 2, &arg0, "ax.Node:setAdditionalTransform");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2014-09-28 14:31:58 +08:00
|
|
|
cobj->setAdditionalTransform(arg0);
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-09-28 14:31:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
} while (0);
|
|
|
|
ok = true;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_mat4(tolua_S, 2, &arg0, "ax.Node:setAdditionalTransform");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2014-09-28 14:31:58 +08:00
|
|
|
cobj->setAdditionalTransform(&arg0);
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-09-28 14:31:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
} while (0);
|
|
|
|
ok = true;
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.Node:setAdditionalTransform",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 1);
|
2014-09-28 14:31:58 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-28 14:31:58 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Node_setAdditionalTransform'.", &tolua_err);
|
2014-09-28 14:31:58 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-28 14:31:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Node_setRotationQuat(lua_State* tolua_S)
|
2014-12-25 14:54:20 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Node* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-12-25 14:54:20 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-12-25 14:54:20 +08:00
|
|
|
#endif
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Node*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-12-25 14:54:20 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Node_setRotationQuat'", nullptr);
|
2014-12-25 14:54:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Quaternion arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_quaternion(tolua_S, 2, &arg0, "ax.Node:setRotationQuat");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2014-12-25 14:54:20 +08:00
|
|
|
cobj->setRotationQuat(arg0);
|
2015-01-13 01:02:04 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
2015-01-12 15:21:21 +08:00
|
|
|
return 1;
|
2014-12-25 14:54:20 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
} while (0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.Node:setRotationQuat", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
1);
|
2014-12-25 14:54:20 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-12-25 14:54:20 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Node_setRotationQuat'.", &tolua_err);
|
2014-12-25 14:54:20 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-12-25 14:54:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_USE_NAVMESH
|
2021-12-25 10:04:45 +08:00
|
|
|
# include "navmesh/CCNavMesh.h"
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Scene_setNavMeshDebugCamera(lua_State* tolua_S)
|
2015-06-02 18:37:57 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Scene* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-06-02 18:37:57 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Scene", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Scene*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-06-02 18:37:57 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Scene_setNavMeshDebugCamera'", nullptr);
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-06-02 18:37:57 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Camera* arg0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_object<axis::Camera>(tolua_S, 2, "ax.Camera", &arg0, "ax.Scene:setNavMeshDebugCamera");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-06-02 18:37:57 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_Scene_setNavMeshDebugCamera'", nullptr);
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
cobj->setNavMeshDebugCamera(arg0);
|
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
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.Scene:setNavMeshDebugCamera",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 1);
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-06-02 18:37:57 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Scene_setNavMeshDebugCamera'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Scene_setNavMesh(lua_State* tolua_S)
|
2015-06-02 18:37:57 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Scene* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-06-02 18:37:57 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Scene", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Scene*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-06-02 18:37:57 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Scene_setNavMesh'", nullptr);
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-06-02 18:37:57 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::NavMesh* arg0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_object<axis::NavMesh>(tolua_S, 2, "ax.NavMesh", &arg0, "ax.Scene:setNavMesh");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-06-02 18:37:57 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_Scene_setNavMesh'", nullptr);
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
cobj->setNavMesh(arg0);
|
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
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.Scene:setNavMesh", argc, 1);
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-06-02 18:37:57 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Scene_setNavMesh'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Scene_getNavMesh(lua_State* tolua_S)
|
2015-06-02 18:37:57 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Scene* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-06-02 18:37:57 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Scene", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Scene*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-06-02 18:37:57 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Scene_getNavMesh'", nullptr);
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-06-02 18:37:57 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-06-02 18:37:57 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_Scene_getNavMesh'", nullptr);
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::NavMesh* ret = cobj->getNavMesh();
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::NavMesh>(tolua_S, "ax.NavMesh", (axis::NavMesh*)ret);
|
2015-06-02 18:37:57 +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.Scene:getNavMesh", argc, 0);
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-06-02 18:37:57 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Scene_getNavMesh'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-02 18:37:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#endif //#if AX_USE_NAVMESH
|
2015-06-02 18:37:57 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
static int tolua_cocos2d_Spawn_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
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.Spawn", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc > 0)
|
|
|
|
{
|
2016-04-18 15:09:21 +08:00
|
|
|
Vector<FiniteTimeAction*> array;
|
2019-09-20 11:20:07 +08:00
|
|
|
int i = 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (1 == argc && tolua_istable(tolua_S, 2, 0, &tolua_err))
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
luaval_to_ccvector(tolua_S, 2, &array, "ax.Spawn:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (i <= argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1 + i, "ax.FiniteTimeAction", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::FiniteTimeAction* item =
|
|
|
|
static_cast<axis::FiniteTimeAction*>(tolua_tousertype(tolua_S, 1 + i, NULL));
|
2014-05-04 14:37:55 +08:00
|
|
|
if (NULL != item)
|
|
|
|
{
|
|
|
|
array.pushBack(item);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Spawn* tolua_ret = axis::Spawn::create(array);
|
2021-12-25 10:04:45 +08:00
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.Spawn");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.Spawn:create", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Spawn_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int lua_cocos2d_CardinalSplineBy_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.CardinalSplineBy", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 3)
|
|
|
|
{
|
|
|
|
double dur = 0.0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 2, &dur, "ax.CardinalSplineBy:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int num = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arr = NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_array_of_vec2(tolua_S, 3, &arr, &num, "ax.CardinalSplineBy:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
double ten = 0.0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 4, &ten, "ax.CardinalSplineBy:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (num > 0)
|
|
|
|
{
|
|
|
|
PointArray* points = PointArray::create(num);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (NULL == points)
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
for (int i = 0; i < num; i++)
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
points->addControlPoint(arr[i]);
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2019-09-20 11:20:07 +08:00
|
|
|
CardinalSplineBy* tolua_ret = CardinalSplineBy::create((float)dur, points, (float)ten);
|
2014-05-04 14:37:55 +08:00
|
|
|
if (NULL != tolua_ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.CardinalSplineBy");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.CardinalSplineBy:create", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
3);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_cocos2d_CardinalSplineBy_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_CatmullRomBy_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.CatmullRomBy", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
double dur = 0.0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 2, &dur, "ax.CatmullRomBy:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int num = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arr = NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_array_of_vec2(tolua_S, 3, &arr, &num, "ax.CatmullRomBy:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (num > 0)
|
|
|
|
{
|
|
|
|
PointArray* points = PointArray::create(num);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (NULL == points)
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
for (int i = 0; i < num; i++)
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
points->addControlPoint(arr[i]);
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2019-09-20 11:20:07 +08:00
|
|
|
CatmullRomBy* tolua_ret = CatmullRomBy::create((float)dur, points);
|
2014-05-04 14:37:55 +08:00
|
|
|
if (NULL != tolua_ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.CatmullRomBy");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.CatmullRomBy:create", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_CatmullRomBy_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_CatmullRomTo_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.CatmullRomTo", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
double dur = 0.0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 2, &dur, "ax.CatmullRomTo:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int num = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arr = NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_array_of_vec2(tolua_S, 3, &arr, &num, "ax.CatmullRomTo:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (num > 0)
|
|
|
|
{
|
|
|
|
PointArray* points = PointArray::create(num);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (NULL == points)
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
for (int i = 0; i < num; i++)
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
points->addControlPoint(arr[i]);
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2019-09-20 11:20:07 +08:00
|
|
|
CatmullRomTo* tolua_ret = CatmullRomTo::create((float)dur, points);
|
2014-05-04 14:37:55 +08:00
|
|
|
if (NULL != tolua_ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.CatmullRomTo");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.CatmullRomTo:create", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_CatmullRomTo_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_BezierBy_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.BezierBy", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
double t = 0.0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 2, &t, "ax.BezierBy:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int num = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arr = NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_array_of_vec2(tolua_S, 3, &arr, &num, "ax.BezierBy:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (num < 3)
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
ccBezierConfig config;
|
|
|
|
config.controlPoint_1 = arr[0];
|
|
|
|
config.controlPoint_2 = arr[1];
|
2021-12-25 10:04:45 +08:00
|
|
|
config.endPosition = arr[2];
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-09-20 11:20:07 +08:00
|
|
|
BezierBy* tolua_ret = BezierBy::create((float)t, config);
|
2014-05-04 14:37:55 +08:00
|
|
|
if (NULL != tolua_ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.BezierBy");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.BezierBy:create", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_BezierBy_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_BezierTo_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.BezierTo", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
double t = 0.0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 2, &t, "ax.BezierTo:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int num = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arr = NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_array_of_vec2(tolua_S, 3, &arr, &num, "ax.BezierTo:create");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (num < 3)
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
ccBezierConfig config;
|
|
|
|
config.controlPoint_1 = arr[0];
|
|
|
|
config.controlPoint_2 = arr[1];
|
2021-12-25 10:04:45 +08:00
|
|
|
config.endPosition = arr[2];
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-09-20 11:20:07 +08:00
|
|
|
BezierTo* tolua_ret = BezierTo::create((float)t, config);
|
2014-05-04 14:37:55 +08:00
|
|
|
if (NULL != tolua_ret)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.BezierTo");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.BezierTo:create", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_BezierTo_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_DrawNode_drawPolygon(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
DrawNode* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.DrawNode", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::DrawNode*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_cocos2d_DrawNode_drawPolygon'\n", NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
if (5 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
|
|
|
|
!tolua_istable(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err) ||
|
|
|
|
!tolua_istable(tolua_S, 6, 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2019-09-20 11:20:07 +08:00
|
|
|
int size = lua_tointeger(tolua_S, 3);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (size > 0)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* points = new axis::Vec2[size];
|
2014-05-04 14:37:55 +08:00
|
|
|
for (int i = 0; i < size; i++)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushnumber(tolua_S, i + 1);
|
|
|
|
lua_gettable(tolua_S, 2);
|
|
|
|
if (!tolua_istable(tolua_S, -1, 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!luaval_to_vec2(tolua_S, lua_gettop(tolua_S), &points[i], "ax.DrawNode:drawPolygon"))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
lua_pop(tolua_S, 1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
Color4F fillColor;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!luaval_to_color4f(tolua_S, 4, &fillColor, "ax.DrawNode:drawPolygon"))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
float borderWidth = (float)tolua_tonumber(tolua_S, 5, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
Color4F borderColor;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!luaval_to_color4f(tolua_S, 6, &borderColor, "ax.DrawNode:drawPolygon"))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
self->drawPolygon(points, (int)size, fillColor, borderWidth, borderColor);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.DrawNode:drawPolygon", argc, 5);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_DrawNode_drawPolygon'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int tolua_axis_DrawNode_drawSolidPoly(lua_State* tolua_S)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::DrawNode* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
tolua_Error tolua_err;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.DrawNode", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-11 15:39:56 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::DrawNode*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
if (!self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_DrawNode_drawSolidPoly'", nullptr);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-09-11 15:39:56 +08:00
|
|
|
if (argc == 3)
|
|
|
|
{
|
|
|
|
unsigned int size;
|
2022-07-12 21:31:54 +08:00
|
|
|
luaval_to_uint32(tolua_S, 3, &size, "ax.DrawNode:drawSolidPoly");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (size > 0)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* points = new axis::Vec2[size];
|
2019-09-20 11:20:07 +08:00
|
|
|
for (unsigned int i = 0; i < size; i++)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushnumber(tolua_S, i + 1);
|
|
|
|
lua_gettable(tolua_S, 2);
|
|
|
|
if (!tolua_istable(tolua_S, -1, 0, &tolua_err))
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!luaval_to_vec2(tolua_S, lua_gettop(tolua_S), &points[i], "ax.DrawNode:drawSolidPoly"))
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
|
|
|
lua_pop(tolua_S, 1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Color4F arg2;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawSolidPoly");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
self->drawSolidPoly(points, size, arg2);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawSolidPoly", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
3);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_DrawNode_drawSolidPoly'.", &tolua_err);
|
2014-09-11 15:39:56 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int tolua_axis_DrawNode_drawPoly(lua_State* tolua_S)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-09-11 15:39:56 +08:00
|
|
|
DrawNode* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
tolua_Error tolua_err;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.DrawNode", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-11 15:39:56 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = static_cast<axis::DrawNode*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
if (!self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_DrawNode_drawPoly'", NULL);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-09-11 15:39:56 +08:00
|
|
|
if (argc == 4)
|
|
|
|
{
|
|
|
|
unsigned int size;
|
2022-07-12 21:31:54 +08:00
|
|
|
luaval_to_uint32(tolua_S, 3, &size, "ax.DrawNode:drawPoly");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (size > 0)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* points = new axis::Vec2[size];
|
2019-09-20 11:20:07 +08:00
|
|
|
for (unsigned int i = 0; i < size; i++)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushnumber(tolua_S, i + 1);
|
|
|
|
lua_gettable(tolua_S, 2);
|
|
|
|
if (!tolua_istable(tolua_S, -1, 0, &tolua_err))
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!luaval_to_vec2(tolua_S, lua_gettop(tolua_S), &points[i], "ax.DrawNode:drawPoly"))
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
|
|
|
lua_pop(tolua_S, 1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool arg2;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Color4F arg3;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_boolean(tolua_S, 4, &arg2, "ax.DrawNode:drawPoly");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_color4f(tolua_S, 5, &arg3, "ax.DrawNode:drawPoly");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
self->drawPoly(points, size, arg2, arg3);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawPoly", argc, 4);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_DrawNode_drawPoly'.", &tolua_err);
|
2014-09-11 15:39:56 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int tolua_axis_DrawNode_drawCardinalSpline(lua_State* tolua_S)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::DrawNode* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2016-09-15 01:49:14 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.DrawNode", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-11 15:39:56 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::DrawNode*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
if (!self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_DrawNode_drawCardinalSpline'", nullptr);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-09-11 15:39:56 +08:00
|
|
|
if (argc == 4)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int num = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arr = NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!luaval_to_array_of_vec2(tolua_S, 2, &arr, &num, "ax.DrawNode:drawCardinalSpline"))
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
PointArray* config = PointArray::create(num);
|
|
|
|
if (NULL == config)
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
for (int i = 0; i < num; i++)
|
|
|
|
{
|
2014-09-11 15:39:56 +08:00
|
|
|
config->addControlPoint(arr[i]);
|
|
|
|
}
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
double arg1;
|
|
|
|
unsigned int arg2;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Color4F arg3;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_number(tolua_S, 3, &arg1, "ax.DrawNode:drawCardinalSpline");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_uint32(tolua_S, 4, &arg2, "ax.DrawNode:drawCardinalSpline");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_color4f(tolua_S, 5, &arg3, "ax.DrawNode:drawCardinalSpline");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
2019-09-20 11:20:07 +08:00
|
|
|
self->drawCardinalSpline(config, (float)arg1, arg2, arg3);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawCardinalSpline",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 4);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_DrawNode_drawCardinalSpline'.", &tolua_err);
|
2014-09-11 15:39:56 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int tolua_axis_DrawNode_drawCatmullRom(lua_State* tolua_S)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::DrawNode* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2016-09-15 01:49:14 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.DrawNode", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-11 15:39:56 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::DrawNode*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
if (!self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_DrawNode_drawCatmullRom'", nullptr);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-09-11 15:39:56 +08:00
|
|
|
if (argc == 3)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int num = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* arr = NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!luaval_to_array_of_vec2(tolua_S, 2, &arr, &num, "ax.DrawNode:drawCatmullRom"))
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
PointArray* config = PointArray::create(num);
|
|
|
|
if (NULL == config)
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
for (int i = 0; i < num; i++)
|
|
|
|
{
|
2014-09-11 15:39:56 +08:00
|
|
|
config->addControlPoint(arr[i]);
|
|
|
|
}
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arr);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
unsigned int arg1;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Color4F arg2;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_uint32(tolua_S, 3, &arg1, "ax.DrawNode:drawCatmullRom");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawCatmullRom");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
self->drawCatmullRom(config, arg1, arg2);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawCatmullRom", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
3);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_DrawNode_drawCatmullRom'.", &tolua_err);
|
2014-09-11 15:39:56 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int tolua_axis_DrawNode_drawPoints(lua_State* tolua_S)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::DrawNode* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
tolua_Error tolua_err;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.DrawNode", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-11 15:39:56 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::DrawNode*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
if (!self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_DrawNode_drawPoints'", nullptr);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-09-11 15:39:56 +08:00
|
|
|
if (argc == 3)
|
|
|
|
{
|
|
|
|
unsigned int size;
|
2022-07-12 21:31:54 +08:00
|
|
|
luaval_to_uint32(tolua_S, 3, &size, "ax.DrawNode:drawPoints");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (size > 0)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* points = new axis::Vec2[size];
|
2019-09-20 11:20:07 +08:00
|
|
|
for (unsigned int i = 0; i < size; i++)
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushnumber(tolua_S, i + 1);
|
|
|
|
lua_gettable(tolua_S, 2);
|
|
|
|
if (!tolua_istable(tolua_S, -1, 0, &tolua_err))
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!luaval_to_vec2(tolua_S, lua_gettop(tolua_S), &points[i], "ax.DrawNode:drawPoints"))
|
2014-09-11 15:39:56 +08:00
|
|
|
{
|
|
|
|
lua_pop(tolua_S, 1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Color4F arg2;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_color4f(tolua_S, 4, &arg2, "ax.DrawNode:drawPoints");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
self->drawPoints(points, size, arg2);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2015-04-28 18:19:57 +08:00
|
|
|
else if (argc == 4)
|
|
|
|
{
|
|
|
|
unsigned int size;
|
2022-07-12 21:31:54 +08:00
|
|
|
luaval_to_uint32(tolua_S, 3, &size, "ax.DrawNode:drawPoints");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (size > 0)
|
2015-04-28 18:19:57 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2* points = new axis::Vec2[size];
|
2019-09-20 11:20:07 +08:00
|
|
|
for (unsigned int i = 0; i < size; i++)
|
2015-04-28 18:19:57 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushnumber(tolua_S, i + 1);
|
|
|
|
lua_gettable(tolua_S, 2);
|
|
|
|
if (!tolua_istable(tolua_S, -1, 0, &tolua_err))
|
2015-04-28 18:19:57 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-04-28 18:19:57 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!luaval_to_vec2(tolua_S, lua_gettop(tolua_S), &points[i], "ax.DrawNode:drawPoints"))
|
2015-04-28 18:19:57 +08:00
|
|
|
{
|
|
|
|
lua_pop(tolua_S, 1);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(points);
|
2015-04-28 18:19:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-04-28 18:19:57 +08:00
|
|
|
float pointSize = (float)tolua_tonumber(tolua_S, 4, 0);
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Color4F color;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_color4f(tolua_S, 5, &color, "ax.DrawNode:drawPoints");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-04-28 18:19:57 +08:00
|
|
|
return 0;
|
|
|
|
self->drawPoints(points, size, pointSize, color);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.DrawNode:drawPoints", argc, 3);
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-11 15:39:56 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_DrawNode_drawPoints'.", &tolua_err);
|
2014-09-11 15:39:56 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-11 15:39:56 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_LayerMultiplex_create(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2019-02-28 11:17:05 +08:00
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-02-28 11:17:05 +08:00
|
|
|
int argc = 0;
|
2021-09-03 11:13:15 +08:00
|
|
|
Vector<Node*> arg0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-02-28 11:17:05 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.LayerMultiplex", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-02-28 11:17:05 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-02-28 11:17:05 +08:00
|
|
|
if (argc > 0)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2019-02-28 11:17:05 +08:00
|
|
|
if (luavals_variadic_to_ccvector(tolua_S, argc, &arg0))
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
LayerMultiplex* tolua_ret = LayerMultiplex::createWithArray(arg0);
|
|
|
|
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
|
|
|
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret, "ax.LayerMultiplex");
|
2019-02-28 11:17:05 +08:00
|
|
|
return 1;
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
2019-02-28 11:17:05 +08:00
|
|
|
else
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "error in tolua_axis_LayerMultiplex_create \n");
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2019-02-28 11:17:05 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.LayerMultiplex:create", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
1);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_LayerMultiplex_create'.", &tolua_err);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2019-02-28 11:17:05 +08:00
|
|
|
#endif
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_FileUtils_getStringFromFile(lua_State* tolua_S)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2019-02-28 11:17:05 +08:00
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2019-02-28 11:17:05 +08:00
|
|
|
FileUtils* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.FileUtils", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<FileUtils*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-02-28 11:17:05 +08:00
|
|
|
if (nullptr == self)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_axis_FileUtils_getStringFromFile'\n", nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-02-28 11:17:05 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-02-28 11:17:05 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
const char* arg0;
|
2021-12-25 10:04:45 +08:00
|
|
|
std::string arg0_tmp;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "ax.FileUtils:getStringFromFile");
|
2021-12-25 10:04:45 +08:00
|
|
|
arg0 = arg0_tmp.c_str();
|
2019-02-28 11:17:05 +08:00
|
|
|
if (ok)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2020-10-18 00:27:23 +08:00
|
|
|
std::string content = FileUtils::getInstance()->getStringFromFile(arg0);
|
|
|
|
lua_pushlstring(tolua_S, content.c_str(), content.size());
|
2019-02-28 11:17:05 +08:00
|
|
|
return 1;
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
|
|
|
}
|
2019-02-28 11:17:05 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.FileUtils:getStringFromFile",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 1);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_FileUtils_getStringFromFile'.", &tolua_err);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2019-02-28 11:17:05 +08:00
|
|
|
#endif
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_FileUtils_getDataFromFile(lua_State* tolua_S)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2019-02-28 11:17:05 +08:00
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2019-02-28 11:17:05 +08:00
|
|
|
FileUtils* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.FileUtils", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<FileUtils*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-02-28 11:17:05 +08:00
|
|
|
if (nullptr == self)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_axis_FileUtils_getDataFromFile'\n", nullptr);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-02-28 11:17:05 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-02-28 11:17:05 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
const char* arg0;
|
2021-12-25 10:04:45 +08:00
|
|
|
std::string arg0_tmp;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &arg0_tmp, "ax.FileUtils:getDataFromFile");
|
2021-12-25 10:04:45 +08:00
|
|
|
arg0 = arg0_tmp.c_str();
|
2019-02-28 11:17:05 +08:00
|
|
|
if (ok)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2019-02-28 11:17:05 +08:00
|
|
|
auto data = FileUtils::getInstance()->getDataFromFile(arg0);
|
|
|
|
if (!data.isNull())
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushlstring(tolua_S, reinterpret_cast<const char*>(data.getBytes()),
|
|
|
|
static_cast<size_t>(data.getSize()));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-02-28 11:17:05 +08:00
|
|
|
return 1;
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
|
|
|
}
|
2019-02-28 11:17:05 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.FileUtils:getDataFromFile",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 1);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_FileUtils_getDataFromFile'.", &tolua_err);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2019-02-28 11:17:05 +08:00
|
|
|
#endif
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_UserDefault_getInstance(lua_State* tolua_S)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2019-02-28 11:17:05 +08:00
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2014-06-13 14:10:08 +08:00
|
|
|
int argc = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.UserDefault", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-02-28 11:17:05 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (0 == argc)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
UserDefault* tolua_ret = (UserDefault*)UserDefault::getInstance();
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_pushusertype(tolua_S, (void*)tolua_ret, "ax.UserDefault");
|
2014-06-13 14:10:08 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2019-02-28 11:17:05 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.UserDefault:getInstance", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
0);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_UserDefault_getInstance'.", &tolua_err);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2019-02-28 11:17:05 +08:00
|
|
|
#endif
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_Texture2D_setTexParameters(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
Texture2D* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
backend::SamplerFilter arg1;
|
|
|
|
backend::SamplerFilter arg2;
|
2019-03-13 15:34:32 +08:00
|
|
|
backend::SamplerAddressMode arg3;
|
|
|
|
backend::SamplerAddressMode arg4;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Texture2D", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = (Texture2D*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_axis_Texture2D_setTexParameters'\n", nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (4 == argc)
|
2016-04-18 15:09:21 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
|
|
|
|
!tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnumber(tolua_S, 5, 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-06-12 15:01:15 +08:00
|
|
|
arg1 = (backend::SamplerFilter)(int)tolua_tonumber(tolua_S, 2, 0);
|
|
|
|
arg2 = (backend::SamplerFilter)(int)tolua_tonumber(tolua_S, 3, 0);
|
|
|
|
arg3 = (backend::SamplerAddressMode)(int)tolua_tonumber(tolua_S, 4, 0);
|
|
|
|
arg4 = (backend::SamplerAddressMode)(int)tolua_tonumber(tolua_S, 5, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-03-13 15:34:32 +08:00
|
|
|
Texture2D::TexParams param(arg1, arg2, arg3, arg4);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
self->setTexParameters(param);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "'setTexParameters' function of Texture2D wrong number of arguments: %d, was expecting %d\n",
|
|
|
|
argc, 4);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'setTexParameters'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_SpriteBatchNode_getDescendants(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::SpriteBatchNode* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.SpriteBatchNode", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::SpriteBatchNode*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'tolua_axis_SpriteBatchNode_getDescendants'", NULL);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
std::vector<Sprite*> ret = cobj->getDescendants();
|
|
|
|
|
|
|
|
lua_newtable(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (ret.empty())
|
|
|
|
return 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
auto iter = ret.begin();
|
|
|
|
int indexTable = 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
for (; iter != ret.end(); ++iter)
|
|
|
|
{
|
|
|
|
if (nullptr == *iter)
|
|
|
|
continue;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_pushnumber(tolua_S, (lua_Number)indexTable);
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, (*iter)->_ID, &((*iter)->_luaID), (void*)(*iter), "ax.Sprite");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
(*iter)->retain();
|
|
|
|
++indexTable;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.SpriteBatchNode:getDescendants", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_SpriteBatchNode_getDescendants'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_USE_3D_PHYSICS && AX_ENABLE_BULLET_INTEGRATION
|
2021-12-25 10:04:45 +08:00
|
|
|
# include "physics3d/CCPhysics3DWorld.h"
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Scene_getPhysics3DWorld(lua_State* tolua_S)
|
2015-05-15 09:28:03 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Scene* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Scene", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Scene*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Scene_getPhysics3DWorld'", nullptr);
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-05-15 09:28:03 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-05-15 09:28:03 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_Scene_getPhysics3DWorld'", nullptr);
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Physics3DWorld* ret = cobj->getPhysics3DWorld();
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::Physics3DWorld>(tolua_S, "ax.Physics3DWorld", (axis::Physics3DWorld*)ret);
|
2015-05-15 09:28:03 +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.Scene:getPhysics3DWorld", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
0);
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Scene_getPhysics3DWorld'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Scene_setPhysics3DDebugCamera(lua_State* tolua_S)
|
2015-05-15 09:28:03 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Scene* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Scene", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Scene*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Scene_setPhysics3DDebugCamera'", nullptr);
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-05-15 09:28:03 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 2, "ax.Camera", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
{
|
2015-05-15 09:28:03 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Camera* camera = (axis::Camera*)tolua_tousertype(tolua_S, 2, 0);
|
2015-05-15 09:28:03 +08:00
|
|
|
cobj->setPhysics3DDebugCamera(camera);
|
|
|
|
return 0;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.Scene:setPhysics3DDebugCamera",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 0);
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
# if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Scene_setPhysics3DDebugCamera'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
# endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-05 17:10:25 +08:00
|
|
|
static void extendScene(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Scene");
|
2015-01-05 17:10:25 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2015-01-05 17:10:25 +08:00
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_USE_3D_PHYSICS && AX_ENABLE_BULLET_INTEGRATION
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "getPhysics3DWorld", lua_axis_Scene_getPhysics3DWorld);
|
|
|
|
tolua_function(tolua_S, "setPhysics3DDebugCamera", lua_axis_Scene_setPhysics3DDebugCamera);
|
2015-01-05 17:10:25 +08:00
|
|
|
#endif
|
2015-06-02 18:37:57 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_USE_NAVMESH
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "setNavMeshDebugCamera", lua_axis_Scene_setNavMeshDebugCamera);
|
|
|
|
tolua_function(tolua_S, "setNavMesh", lua_axis_Scene_setNavMesh);
|
|
|
|
tolua_function(tolua_S, "getNavMesh", lua_axis_Scene_getNavMesh);
|
2015-06-02 18:37:57 +08:00
|
|
|
#endif
|
2015-01-05 17:10:25 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
static void extendTexture2D(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Texture2D");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "setTexParameters");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_Texture2D_setTexParameters);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendMenuItem(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.MenuItem");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "registerScriptTapHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_MenuItem_registerScriptTapHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_pushstring(tolua_S, "unregisterScriptTapHandler");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_MenuItem_unregisterScriptTapHandler);
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendMenuItemImage(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.MenuItemImage");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_MenuItemImage_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendMenuItemLabel(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.MenuItemLabel");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_MenuItemLabel_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendMenuItemFont(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.MenuItemFont");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_MenuItemFont_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendMenuItemSprite(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.MenuItemSprite");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_MenuItemSprite_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendMenuItemToggle(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.MenuItemToggle");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_MenuItemToggle_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendMenu(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Menu");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Menu_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "alignItemsInRows");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_Menu_alignItemsInRows);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "alignItemsInColumns");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_Menu_alignItemsInColumns);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendNode(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Node");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "registerScriptHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Node_registerScriptHandler);
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "unregisterScriptHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Node_unregisterScriptHandler);
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "scheduleUpdateWithPriorityLua");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_Cocos2d_Node_scheduleUpdateWithPriorityLua);
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "unscheduleUpdate");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Node_unscheduleUpdate);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "getPosition");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Node_getPosition);
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "setContentSize");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Node_setContentSize);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "setAnchorPoint");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Node_setAnchorPoint);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-07-08 14:22:05 +08:00
|
|
|
lua_pushstring(tolua_S, "enumerateChildren");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_Node_enumerateChildren);
|
2014-07-08 14:22:05 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-09-28 14:31:58 +08:00
|
|
|
lua_pushstring(tolua_S, "setAdditionalTransform");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_Node_setAdditionalTransform);
|
2014-09-28 14:31:58 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-12-25 14:54:20 +08:00
|
|
|
lua_pushstring(tolua_S, "setRotationQuat");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, lua_axis_Node_setRotationQuat);
|
2014-12-25 14:54:20 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendLayer(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Layer");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "registerScriptTouchHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptTouchHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_pushstring(tolua_S, "unregisterScriptTouchHandler");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptTouchHandler);
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "registerScriptKeypadHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptKeypadHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "unregisterScriptKeypadHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptKeypadHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "registerScriptAccelerateHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_registerScriptAccelerateHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
lua_pushstring(tolua_S, "unregisterScriptAccelerateHandler");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Layer_unregisterScriptAccelerateHandler);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "setTouchEnabled", lua_axis_Layer_setTouchEnabled);
|
|
|
|
tolua_function(tolua_S, "isTouchEnabled", lua_axis_Layer_isTouchEnabled);
|
|
|
|
tolua_function(tolua_S, "setTouchMode", lua_axis_Layer_setTouchMode);
|
|
|
|
tolua_function(tolua_S, "getTouchMode", lua_axis_Layer_getTouchMode);
|
|
|
|
tolua_function(tolua_S, "setSwallowsTouches", lua_axis_Layer_setSwallowsTouches);
|
|
|
|
tolua_function(tolua_S, "isSwallowsTouches", lua_axis_Layer_isSwallowsTouches);
|
|
|
|
tolua_function(tolua_S, "setKeyboardEnabled", lua_axis_Layer_setKeyboardEnabled);
|
|
|
|
tolua_function(tolua_S, "isKeyboardEnabled", lua_axis_Layer_isKeyboardEnabled);
|
|
|
|
tolua_function(tolua_S, "setAccelerometerEnabled", lua_axis_Layer_setAccelerometerEnabled);
|
|
|
|
tolua_function(tolua_S, "isAccelerometerEnabled", lua_axis_Layer_isAccelerometerEnabled);
|
|
|
|
tolua_function(tolua_S, "setAccelerometerInterval", lua_axis_Layer_setAccelerometerInterval);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendScheduler(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Scheduler");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "scheduleScriptFunc");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Scheduler_scheduleScriptFunc);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_pushstring(tolua_S, "unscheduleScriptEntry");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Scheduler_unscheduleScriptEntry);
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2019-06-19 13:45:14 +08:00
|
|
|
static void extendRenderTexture(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.RenderTexture");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2019-06-19 13:45:14 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "newImage");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_RenderTexture_newImage);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2019-06-19 13:45:14 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
static void extendSequence(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Sequence");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Sequence_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendCallFunc(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.CallFunc");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_CallFunc_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendSpawn(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Spawn");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_Spawn_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendCardinalSplineBy(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.CardinalSplineBy");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, lua_cocos2d_CardinalSplineBy_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendCatmullRomBy(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.CatmullRomBy");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_CatmullRomBy_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendCatmullRomTo(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.CatmullRomTo");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_CatmullRomTo_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendBezierBy(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.BezierBy");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_BezierBy_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendBezierTo(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.BezierTo");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
|
|
|
lua_pushcfunction(tolua_S, tolua_cocos2d_BezierTo_create);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendDrawNode(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.DrawNode");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "drawPolygon");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_DrawNode_drawPolygon);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "drawSolidPoly");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_DrawNode_drawSolidPoly);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "drawPoly");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_DrawNode_drawPoly);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "drawCardinalSpline");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_DrawNode_drawCardinalSpline);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "drawCatmullRom");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_DrawNode_drawCatmullRom);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "drawPoints");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_DrawNode_drawPoints);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Sprite_initWithPolygon(lua_State* tolua_S)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sprite* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Sprite", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Sprite*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Sprite_initWithPolygon'", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-06-11 14:38:38 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* arg0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_object<axis::PolygonInfo>(tolua_S, 2, "ax.PolygonInfo", &arg0, "ax.Sprite:initWithPolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_Sprite_initWithPolygon'", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
bool ret = cobj->initWithPolygon(*arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushboolean(tolua_S, (bool)ret);
|
2015-06-11 14:38:38 +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.Sprite:initWithPolygon", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
1);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Sprite_initWithPolygon'.", &tolua_err);
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Sprite_setPolygonInfo(lua_State* tolua_S)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sprite* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Sprite", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Sprite*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Sprite_setPolygonInfo'", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-06-11 14:38:38 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* arg0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_object<axis::PolygonInfo>(tolua_S, 2, "ax.PolygonInfo", &arg0, "ax.Sprite:setPolygonInfo");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_Sprite_setPolygonInfo'", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
cobj->setPolygonInfo(*arg0);
|
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
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.Sprite:setPolygonInfo", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
1);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Sprite_setPolygonInfo'.", &tolua_err);
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Sprite_create(lua_State* tolua_S)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +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.Sprite", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-11 14:38:38 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
std::string arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &arg0, "ax.Sprite:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sprite* ret = axis::Sprite::create(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::Sprite>(tolua_S, "ax.Sprite", (axis::Sprite*)ret);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} while (0);
|
2021-12-25 10:04:45 +08:00
|
|
|
ok = true;
|
2015-06-11 14:38:38 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sprite* ret = axis::Sprite::create();
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::Sprite>(tolua_S, "ax.Sprite", (axis::Sprite*)ret);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} while (0);
|
2021-12-25 10:04:45 +08:00
|
|
|
ok = true;
|
2015-06-11 14:38:38 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_object<axis::PolygonInfo>(tolua_S, 2, "ax.PolygonInfo", &arg0, "ax.Sprite:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sprite* ret = axis::Sprite::create(*arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::Sprite>(tolua_S, "ax.Sprite", (axis::Sprite*)ret);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} while (0);
|
2021-12-25 10:04:45 +08:00
|
|
|
ok = true;
|
2015-06-11 14:38:38 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
std::string arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &arg0, "ax.Sprite:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Rect arg1;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_rect(tolua_S, 3, &arg1, "ax.Sprite:create");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sprite* ret = axis::Sprite::create(arg0, arg1);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::Sprite>(tolua_S, "ax.Sprite", (axis::Sprite*)ret);
|
2015-06-11 14:38:38 +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.Sprite:create", argc, 2);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Sprite_create'.", &tolua_err);
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
static void extendSprite(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Sprite");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "initWithPolygon", lua_axis_Sprite_initWithPolygon);
|
|
|
|
tolua_function(tolua_S, "setPolygonInfo", lua_axis_Sprite_setPolygonInfo);
|
|
|
|
tolua_function(tolua_S, "create", lua_axis_Sprite_create);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendLayerMultiplex(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.LayerMultiplex");
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "create");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_LayerMultiplex_create);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendFileUtils(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.FileUtils");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getStringFromFile");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_FileUtils_getStringFromFile);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2017-01-13 13:39:58 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getDataFromFile");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_FileUtils_getDataFromFile);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendUserDefault(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.UserDefault");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getInstance");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_UserDefault_getInstance);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendSpriteBatchNode(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.SpriteBatchNode");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_pushstring(tolua_S, "getDescendants");
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushcfunction(tolua_S, tolua_axis_SpriteBatchNode_getDescendants);
|
2021-12-25 10:04:45 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2014-05-04 14:37:55 +08:00
|
|
|
EventListenerAcceleration* LuaEventListenerAcceleration::create()
|
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
EventListenerAcceleration* eventAcceleration = new EventListenerAcceleration();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (eventAcceleration->init([=](Acceleration* acc, Event* event) {
|
|
|
|
LuaEventAccelerationData listenerData((void*)acc, event);
|
|
|
|
BasicScriptData data(eventAcceleration, (void*)&listenerData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::EVENT_ACC, (void*)&data);
|
|
|
|
}))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
eventAcceleration->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(eventAcceleration);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
return eventAcceleration;
|
|
|
|
}
|
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
EventListenerCustom* LuaEventListenerCustom::create(std::string_view eventName)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
EventListenerCustom* eventCustom = new EventListenerCustom();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (eventCustom->init(eventName, [=](EventCustom* event) {
|
|
|
|
BasicScriptData data((void*)eventCustom, (void*)event);
|
|
|
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::EVENT_CUSTIOM, (void*)&data);
|
|
|
|
}))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
eventCustom->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(eventCustom);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
return eventCustom;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|
2014-05-04 14:37:55 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_LuaEventListenerAcceleration_create(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.EventListenerAcceleration", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err))
|
|
|
|
{
|
2014-05-04 14:37:55 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerAcceleration* tolua_ret = axis::LuaEventListenerAcceleration::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)tolua_ret, handler,
|
|
|
|
ScriptHandlerMgr::HandlerType::EVENT_ACC);
|
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret, "ax.EventListenerAcceleration");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventListenerAcceleration:create", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_LuaEventListenerAcceleration_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_LuaEventListenerCustom_create(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.EventListenerCustom", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err) ||
|
|
|
|
!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2022-07-09 22:23:34 +08:00
|
|
|
auto eventName = axislua_tosv(tolua_S, 2);
|
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
|
|
|
axis::EventListenerCustom* tolua_ret = LuaEventListenerCustom::create(eventName);
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)tolua_ret, handler,
|
|
|
|
ScriptHandlerMgr::HandlerType::EVENT_CUSTIOM);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret, "ax.EventListenerCustom");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.EventListenerCustom:create",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_LuaEventListenerCustom_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendEventListenerCustom(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.EventListenerCustom");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_function(tolua_S, "create", tolua_cocos2d_LuaEventListenerCustom_create);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendEventListenerAcceleration(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.EventListenerAcceleration");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "create", tolua_axis_LuaEventListenerAcceleration_create);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerKeyboard_create(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.EventListenerKeyboard", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerKeyboard* tolua_ret = axis::EventListenerKeyboard::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == tolua_ret)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret, "ax.EventListenerKeyboard");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.EventListenerKeyboard:create",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerKeyboard_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static void cloneKeyboardHandler(const EventListenerKeyboard* src,
|
|
|
|
EventListenerKeyboard* dst,
|
|
|
|
ScriptHandlerMgr::HandlerType type)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == src || nullptr == dst)
|
|
|
|
return;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
LUA_FUNCTION handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)src, type);
|
|
|
|
if (0 != handler)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int newscriptHandler =
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::ScriptEngineManager::getInstance()->getScriptEngine()->reallocateScriptHandler(handler);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)dst, newscriptHandler, type);
|
|
|
|
switch (type)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_PRESSED:
|
|
|
|
{
|
|
|
|
dst->onKeyPressed = [=](EventKeyboard::KeyCode keyCode, Event* event) {
|
|
|
|
LuaEventKeyboarData listenerData((int)keyCode, event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&listenerData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_RELEASED:
|
|
|
|
{
|
|
|
|
dst->onKeyReleased = [=](EventKeyboard::KeyCode keyCode, Event* event) {
|
|
|
|
LuaEventKeyboarData listenerData((int)keyCode, event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&listenerData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerKeyboard_clone(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
EventListenerKeyboard* self = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.EventListenerKeyboard", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<EventListenerKeyboard*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_axis_EventListenerKeyboard_clone'\n", nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerKeyboard* tolua_ret = axis::EventListenerKeyboard::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == tolua_ret)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
cloneKeyboardHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_PRESSED);
|
|
|
|
cloneKeyboardHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_RELEASED);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret, "ax.EventListenerKeyboard");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.EventListenerKeyboard:clone",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerKeyboard_clone'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerKeyboard_registerScriptHandler(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
EventListenerKeyboard* self = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.EventListenerKeyboard", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<EventListenerKeyboard*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S,
|
2022-07-12 21:31:54 +08:00
|
|
|
"invalid 'self' in function 'tolua_axis_EventListenerKeyboard_registerScriptHandler'\n",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
2014-05-04 14:37:55 +08:00
|
|
|
!tolua_isnumber(tolua_S, 3, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
|
|
|
ScriptHandlerMgr::HandlerType type =
|
|
|
|
static_cast<ScriptHandlerMgr::HandlerType>((int)tolua_tonumber(tolua_S, 3, 0));
|
2014-05-04 14:37:55 +08:00
|
|
|
switch (type)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_PRESSED:
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
self->onKeyPressed = [=](EventKeyboard::KeyCode keyCode, Event* event) {
|
|
|
|
LuaEventKeyboarData listenerData((int)keyCode, event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&listenerData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_RELEASED:
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
self->onKeyReleased = [=](EventKeyboard::KeyCode keyCode, Event* event) {
|
|
|
|
LuaEventKeyboarData listenerData((int)keyCode, event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&listenerData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventListenerKeyboard:registerScriptHandler", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerKeyboard_registerScriptHandler'.",
|
2021-12-25 10:04:45 +08:00
|
|
|
&tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendEventListenerKeyboard(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.EventListenerKeyboard");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "create", tolua_axis_EventListenerKeyboard_create);
|
|
|
|
tolua_function(tolua_S, "registerScriptHandler", tolua_axis_EventListenerKeyboard_registerScriptHandler);
|
|
|
|
tolua_function(tolua_S, "clone", tolua_axis_EventListenerKeyboard_clone);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerTouchOneByOne_create(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.EventListenerTouchOneByOne", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerTouchOneByOne* tolua_ret = axis::EventListenerTouchOneByOne::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == tolua_ret)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret, "ax.EventListenerTouchOneByOne");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventListenerTouchOneByOne:create", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerTouchOneByOne_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static void cloneTouchOneByOneHandler(const EventListenerTouchOneByOne* src,
|
|
|
|
EventListenerTouchOneByOne* dst,
|
|
|
|
ScriptHandlerMgr::HandlerType type)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == src || nullptr == dst)
|
|
|
|
return;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
LUA_FUNCTION handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)src, type);
|
|
|
|
if (0 != handler)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int newscriptHandler =
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::ScriptEngineManager::getInstance()->getScriptEngine()->reallocateScriptHandler(handler);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)dst, newscriptHandler, type);
|
|
|
|
switch (type)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_BEGAN:
|
|
|
|
{
|
|
|
|
dst->onTouchBegan = [=](Touch* touch, Event* event) {
|
|
|
|
LuaEventTouchData touchData(touch, event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&touchData);
|
|
|
|
return LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_MOVED:
|
|
|
|
{
|
|
|
|
dst->onTouchMoved = [=](Touch* touch, Event* event) {
|
|
|
|
LuaEventTouchData touchData(touch, event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&touchData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_ENDED:
|
|
|
|
{
|
|
|
|
dst->onTouchEnded = [=](Touch* touch, Event* event) {
|
|
|
|
LuaEventTouchData touchData(touch, event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&touchData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_CANCELLED:
|
|
|
|
{
|
|
|
|
dst->onTouchCancelled = [=](Touch* touch, Event* event) {
|
|
|
|
LuaEventTouchData touchData(touch, event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&touchData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerTouchOneByOne_clone(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
EventListenerTouchOneByOne* self = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.EventListenerTouchOneByOne", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<EventListenerTouchOneByOne*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_axis_EventListenerTouchOneByOne_clone'\n", nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerTouchOneByOne* tolua_ret = axis::EventListenerTouchOneByOne::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == tolua_ret)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
cloneTouchOneByOneHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_TOUCH_BEGAN);
|
|
|
|
cloneTouchOneByOneHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_TOUCH_MOVED);
|
|
|
|
cloneTouchOneByOneHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_TOUCH_ENDED);
|
|
|
|
cloneTouchOneByOneHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_TOUCH_CANCELLED);
|
|
|
|
tolua_ret->setSwallowTouches(self->isSwallowTouches());
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret, "ax.EventListenerTouchOneByOne");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventListenerTouchOneByOne:create", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerTouchOneByOne_clone'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerTouchOneByOne_registerScriptHandler(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
EventListenerTouchOneByOne* self = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.EventListenerTouchOneByOne", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<EventListenerTouchOneByOne*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S,
|
2022-07-12 21:31:54 +08:00
|
|
|
"invalid 'self' in function 'tolua_axis_EventListenerTouchOneByOne_registerScriptHandler'\n",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
2014-05-04 14:37:55 +08:00
|
|
|
!tolua_isnumber(tolua_S, 3, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
|
|
|
ScriptHandlerMgr::HandlerType type =
|
|
|
|
static_cast<ScriptHandlerMgr::HandlerType>((int)tolua_tonumber(tolua_S, 3, 0));
|
2014-05-04 14:37:55 +08:00
|
|
|
switch (type)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_BEGAN:
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self->onTouchBegan = [=](Touch* touch, Event* event) {
|
|
|
|
LuaEventTouchData touchData(touch, event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&touchData);
|
|
|
|
return LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_MOVED:
|
|
|
|
{
|
|
|
|
self->onTouchMoved = [=](Touch* touch, Event* event) {
|
|
|
|
LuaEventTouchData touchData(touch, event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&touchData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_ENDED:
|
|
|
|
{
|
|
|
|
self->onTouchEnded = [=](Touch* touch, Event* event) {
|
|
|
|
LuaEventTouchData touchData(touch, event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&touchData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_CANCELLED:
|
|
|
|
{
|
|
|
|
self->onTouchCancelled = [=](Touch* touch, Event* event) {
|
|
|
|
LuaEventTouchData touchData(touch, event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&touchData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventListenerTouchOneByOne:registerScriptHandler", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerTouchOneByOne_registerScriptHandler'.",
|
2021-12-25 10:04:45 +08:00
|
|
|
&tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendEventListenerTouchOneByOne(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.EventListenerTouchOneByOne");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "create", tolua_axis_EventListenerTouchOneByOne_create);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_function(tolua_S, "registerScriptHandler",
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_axis_EventListenerTouchOneByOne_registerScriptHandler);
|
|
|
|
tolua_function(tolua_S, "clone", tolua_axis_EventListenerTouchOneByOne_clone);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerTouchAllAtOnce_create(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.EventListenerTouchAllAtOnce", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerTouchAllAtOnce* tolua_ret = axis::EventListenerTouchAllAtOnce::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == tolua_ret)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret, "ax.EventListenerTouchAllAtOnce");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventListenerTouchAllAtOnce:registerScriptHandler", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerTouchAllAtOnce_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static void cloneTouchAllAtOnceHandler(const EventListenerTouchAllAtOnce* src,
|
|
|
|
EventListenerTouchAllAtOnce* dst,
|
|
|
|
ScriptHandlerMgr::HandlerType type)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == src || nullptr == dst)
|
|
|
|
return;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
LUA_FUNCTION handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)src, type);
|
|
|
|
if (0 != handler)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int newscriptHandler =
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::ScriptEngineManager::getInstance()->getScriptEngine()->reallocateScriptHandler(handler);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)dst, newscriptHandler, type);
|
|
|
|
switch (type)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_BEGAN:
|
|
|
|
{
|
|
|
|
dst->onTouchesBegan = [=](const std::vector<Touch*>& touches, Event* event) {
|
|
|
|
LuaEventTouchesData touchesData(touches, event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&touchesData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_MOVED:
|
|
|
|
{
|
|
|
|
dst->onTouchesMoved = [=](const std::vector<Touch*>& touches, Event* event) {
|
|
|
|
LuaEventTouchesData touchesData(touches, event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&touchesData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_ENDED:
|
|
|
|
{
|
|
|
|
dst->onTouchesEnded = [=](const std::vector<Touch*>& touches, Event* event) {
|
|
|
|
LuaEventTouchesData touchesData(touches, event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&touchesData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_CANCELLED:
|
|
|
|
{
|
|
|
|
dst->onTouchesCancelled = [=](const std::vector<Touch*>& touches, Event* event) {
|
|
|
|
LuaEventTouchesData touchesData(touches, event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&touchesData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerTouchAllAtOnce_clone(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
EventListenerTouchAllAtOnce* self = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.EventListenerTouchAllAtOnce", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<EventListenerTouchAllAtOnce*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_axis_EventListenerTouchAllAtOnce_clone'\n",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerTouchAllAtOnce* tolua_ret = axis::EventListenerTouchAllAtOnce::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == tolua_ret)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
cloneTouchAllAtOnceHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_BEGAN);
|
|
|
|
cloneTouchAllAtOnceHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_MOVED);
|
|
|
|
cloneTouchAllAtOnceHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_ENDED);
|
|
|
|
cloneTouchAllAtOnceHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_CANCELLED);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret, "ax.EventListenerTouchAllAtOnce");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventListenerTouchAllAtOnce:clone", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerTouchAllAtOnce_clone'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerTouchAllAtOnce_registerScriptHandler(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
EventListenerTouchAllAtOnce* self = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.EventListenerTouchAllAtOnce", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<EventListenerTouchAllAtOnce*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
|
|
|
tolua_error(tolua_S,
|
2022-07-12 21:31:54 +08:00
|
|
|
"invalid 'self' in function 'tolua_axis_EventListenerTouchAllAtOnce_registerScriptHandler'\n",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
2014-05-04 14:37:55 +08:00
|
|
|
!tolua_isnumber(tolua_S, 3, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
|
|
|
ScriptHandlerMgr::HandlerType type =
|
|
|
|
static_cast<ScriptHandlerMgr::HandlerType>((int)tolua_tonumber(tolua_S, 3, 0));
|
2014-05-04 14:37:55 +08:00
|
|
|
switch (type)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_BEGAN:
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self->onTouchesBegan = [=](const std::vector<Touch*>& touches, Event* event) {
|
|
|
|
LuaEventTouchesData touchesData(touches, event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&touchesData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_MOVED:
|
|
|
|
{
|
|
|
|
self->onTouchesMoved = [=](const std::vector<Touch*>& touches, Event* event) {
|
|
|
|
LuaEventTouchesData touchesData(touches, event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&touchesData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_ENDED:
|
|
|
|
{
|
|
|
|
self->onTouchesEnded = [=](const std::vector<Touch*>& touches, Event* event) {
|
|
|
|
LuaEventTouchesData touchesData(touches, event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&touchesData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_CANCELLED:
|
|
|
|
{
|
|
|
|
self->onTouchesCancelled = [=](const std::vector<Touch*>& touches, Event* event) {
|
|
|
|
LuaEventTouchesData touchesData(touches, event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&touchesData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventListenerTouchAllAtOnce:registerScriptHandler", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerTouchAllAtOnce_registerScriptHandler'.",
|
2021-12-25 10:04:45 +08:00
|
|
|
&tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendEventListenerTouchAllAtOnce(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.EventListenerTouchAllAtOnce");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "create", tolua_axis_EventListenerTouchAllAtOnce_create);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_function(tolua_S, "registerScriptHandler",
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_axis_EventListenerTouchAllAtOnce_registerScriptHandler);
|
|
|
|
tolua_function(tolua_S, "clone", tolua_axis_EventListenerTouchAllAtOnce_clone);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerMouse_create(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.EventListenerMouse", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-05 09:39:43 +08:00
|
|
|
if (argc == 0)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerMouse* tolua_ret = axis::EventListenerMouse::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == tolua_ret)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret, "ax.EventListenerMouse");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.EventListenerMouse:create",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerMouse_create'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static void cloneMouseHandler(const EventListenerMouse* src,
|
|
|
|
EventListenerMouse* dst,
|
|
|
|
ScriptHandlerMgr::HandlerType type)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == src || nullptr == dst)
|
|
|
|
return;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
LUA_FUNCTION handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)src, type);
|
|
|
|
if (0 != handler)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int newscriptHandler =
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::ScriptEngineManager::getInstance()->getScriptEngine()->reallocateScriptHandler(handler);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)dst, newscriptHandler, type);
|
|
|
|
switch (type)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_DOWN:
|
|
|
|
{
|
|
|
|
dst->onMouseDown = [=](Event* event) {
|
|
|
|
LuaEventMouseData mouseData(event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&mouseData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_UP:
|
|
|
|
{
|
|
|
|
dst->onMouseUp = [=](Event* event) {
|
|
|
|
LuaEventMouseData mouseData(event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&mouseData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_MOVE:
|
|
|
|
{
|
|
|
|
dst->onMouseMove = [=](Event* event) {
|
|
|
|
LuaEventMouseData mouseData(event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&mouseData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_SCROLL:
|
|
|
|
{
|
|
|
|
dst->onMouseScroll = [=](Event* event) {
|
|
|
|
LuaEventMouseData mouseData(event);
|
|
|
|
BasicScriptData data((void*)dst, (void*)&mouseData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerMouse_clone(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
EventListenerMouse* self = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.EventListenerMouse", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<EventListenerMouse*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_axis_EventListenerMouse_clone'\n", nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerMouse* tolua_ret = axis::EventListenerMouse::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == tolua_ret)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
cloneMouseHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_MOUSE_DOWN);
|
|
|
|
cloneMouseHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_MOUSE_MOVE);
|
|
|
|
cloneMouseHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_MOUSE_SCROLL);
|
|
|
|
cloneMouseHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_MOUSE_UP);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret, "ax.EventListenerMouse");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n", "ax.EventListenerMouse:clone", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerMouse_clone'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_EventListenerMouse_registerScriptHandler(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-05-04 14:37:55 +08:00
|
|
|
EventListenerMouse* self = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.EventListenerMouse", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<EventListenerMouse*>(tolua_tousertype(tolua_S, 1, 0));
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'tolua_axis_EventListenerMouse_registerScriptHandler'\n",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
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, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
2014-05-04 14:37:55 +08:00
|
|
|
!tolua_isnumber(tolua_S, 3, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
|
|
|
ScriptHandlerMgr::HandlerType type =
|
|
|
|
static_cast<ScriptHandlerMgr::HandlerType>((int)tolua_tonumber(tolua_S, 3, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
switch (type)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_DOWN:
|
|
|
|
{
|
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self->onMouseDown = [=](Event* event) {
|
|
|
|
LuaEventMouseData mouseData(event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&mouseData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_UP:
|
|
|
|
{
|
|
|
|
self->onMouseUp = [=](Event* event) {
|
|
|
|
LuaEventMouseData mouseData(event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&mouseData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_MOVE:
|
|
|
|
{
|
|
|
|
self->onMouseMove = [=](Event* event) {
|
|
|
|
LuaEventMouseData mouseData(event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&mouseData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_SCROLL:
|
|
|
|
{
|
|
|
|
self->onMouseScroll = [=](Event* event) {
|
|
|
|
LuaEventMouseData mouseData(event);
|
|
|
|
BasicScriptData data((void*)self, (void*)&mouseData);
|
|
|
|
LuaEngine::getInstance()->handleEvent(type, (void*)&data);
|
|
|
|
};
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventListenerMouse:registerScriptHandler", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_EventListenerMouse_registerScriptHandler'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendEventListenerMouse(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.EventListenerMouse");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "create", tolua_axis_EventListenerMouse_create);
|
|
|
|
tolua_function(tolua_S, "registerScriptHandler", tolua_axis_EventListenerMouse_registerScriptHandler);
|
|
|
|
tolua_function(tolua_S, "clone", tolua_axis_EventListenerMouse_clone);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_ActionCamera_reverse(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::ActionCamera* cobj = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.ActionCamera", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::ActionCamera*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'tolua_axis_ActionCamera_reverse'", NULL);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::ActionCamera* reverse = cobj->reverse();
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, reverse->_ID, &(reverse->_luaID), (void*)(reverse), "ax.ActionCamera");
|
2014-05-04 14:37:55 +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.ActionCamera:reverse", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_ActionCamera_reverse'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendActionCamera(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.ActionCamera");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "reverse", tolua_axis_ActionCamera_reverse);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int tolua_axis_GridAction_reverse(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::GridAction* cobj = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.GridAction", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::GridAction*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'tolua_axis_GridAction_reverse'", NULL);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::GridAction* reverse = cobj->reverse();
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, reverse->_ID, &(reverse->_luaID), (void*)(reverse), "ax.GridAction");
|
2014-05-04 14:37:55 +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.GridAction:reverse", argc, 0);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_axis_GridAction_reverse'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendGridAction(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.GridAction");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "reverse", tolua_axis_GridAction_reverse);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Label_createWithTTF00(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(L, 1, "ax.Label", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc >= 2 && argc <= 4)
|
|
|
|
{
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3, 0, &tolua_err) ||
|
|
|
|
!tolua_isnumber(L, 4, 1, &tolua_err) || !tolua_isnumber(L, 5, 1, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
TTFConfig ttfConfig("");
|
|
|
|
std::string text = "";
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_ttfconfig(L, 2, &ttfConfig, "ax.Label:createWithTTF");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(L, 3, &text, "ax.Label:createWithTTF");
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-09-20 11:20:07 +08:00
|
|
|
int alignment = (int)tolua_tonumber(L, 4, 1);
|
|
|
|
int lineSize = (int)tolua_tonumber(L, 5, 0);
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Label* ret =
|
|
|
|
axis::Label::createWithTTF(ttfConfig, text, static_cast<TextHAlignment>(alignment), lineSize);
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = ret ? (int)(ret->_ID) : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = ret ? &(ret->_luaID) : nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)ret, "ax.Label");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ax.Label:createWithTTF", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_axis_Label_createWithTTF'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Label_createWithTTF01(lua_State* L)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
int argc = 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(L, 1, "ax.Label", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc >= 3 && argc <= 6)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isstring(L, 2, 0, &tolua_err) || !tolua_isstring(L, 3, 0, &tolua_err) ||
|
|
|
|
!tolua_isnumber(L, 4, 0, &tolua_err) || !tolua_istable(L, 5, 1, &tolua_err) ||
|
|
|
|
!tolua_isnumber(L, 6, 1, &tolua_err) || !tolua_isnumber(L, 7, 1, &tolua_err))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
std::string text = tolua_tostring(L, 2, "");
|
|
|
|
std::string fontFile = tolua_tostring(L, 3, "");
|
|
|
|
float fontSize = (float)tolua_tonumber(L, 4, 0);
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Size dimensions = axis::Size::ZERO;
|
2014-05-04 14:37:55 +08:00
|
|
|
if (lua_istable(L, 5))
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
luaval_to_size(L, 5, &dimensions, "ax.Label:createWithTTF");
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
TextHAlignment hAlignment = static_cast<TextHAlignment>((int)tolua_tonumber(L, 6, 0));
|
|
|
|
TextVAlignment vAlignment = static_cast<TextVAlignment>((int)tolua_tonumber(L, 7, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Label* ret =
|
|
|
|
axis::Label::createWithTTF(text, fontFile, fontSize, dimensions, hAlignment, vAlignment);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = ret ? (int)(ret->_ID) : -1;
|
2014-05-04 14:37:55 +08:00
|
|
|
int* luaID = ret ? &(ret->_luaID) : nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)ret, "ax.Label");
|
2014-05-04 14:37:55 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
return lua_axis_Label_createWithTTF00(L);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void extendLabel(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Label");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "createWithTTF", lua_axis_Label_createWithTTF00);
|
|
|
|
tolua_function(tolua_S, "createWithTTF", lua_axis_Label_createWithTTF01);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_TMXTiledMap_getPropertiesForGID(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::TMXTiledMap* cobj = NULL;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.TMXTiledMap", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::TMXTiledMap*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_TMXTiledMap_getPropertiesForGID'", NULL);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
int arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_int32(tolua_S, 2, (int*)&arg0, "ax.TMXTiledMap:getPropertiesForGID");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Value ret = cobj->getPropertiesForGID(arg0);
|
2014-05-04 14:37:55 +08:00
|
|
|
ccvalue_to_luaval(tolua_S, ret);
|
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.TMXTiledMap:getPropertiesForGID", argc, 1);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_TMXTiledMap_getPropertiesForGID'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendTMXTiledMap(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.TMXTiledMap");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "getPropertiesForGID", lua_axis_TMXTiledMap_getPropertiesForGID);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Console_send(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Console* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Console", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Console*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Console_send'", NULL);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
int arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_int32(tolua_S, 2, &arg0, "ax.Console:send");
|
2014-05-04 14:37:55 +08:00
|
|
|
std::string arg1;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 3, &arg1, "ax.Console:send");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
send(arg0, arg1.c_str(), arg1.length(), 0);
|
|
|
|
return 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.Console:send", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Console_send'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Console_wait(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Console* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Console", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Console*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Console_wait'", NULL);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
int arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_int32(tolua_S, 2, &arg0, "ax.Console:wait");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
std::chrono::milliseconds dura(arg0 * 1000);
|
|
|
|
std::this_thread::sleep_for(dura);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 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.Console:wait", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Console_wait'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_Console_addCommand(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Console* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Console", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Console*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Console_addCommand'", NULL);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
if (ok && argc == 2)
|
|
|
|
{
|
|
|
|
ValueMap arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_ccvaluemap(tolua_S, 2, &arg0, "ax.Console:addCommand");
|
2014-05-04 14:37:55 +08:00
|
|
|
//
|
|
|
|
std::string name = std::string(arg0["name"].asString());
|
|
|
|
std::string help = std::string(arg0["help"].asString());
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
if (!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
LUA_FUNCTION handler = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
handler = (toluafix_ref_function(tolua_S, 3, 0));
|
2014-05-04 14:37:55 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)cobj, handler);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
Console::Command outValue = {name, help, [=](int fd, std::string_view args) {
|
2021-12-25 10:04:45 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
|
|
|
auto Ls = stack->getLuaState();
|
|
|
|
// lua-callback, the third param;
|
|
|
|
tolua_pushnumber(Ls, fd);
|
2021-12-28 11:05:34 +08:00
|
|
|
tolua_pushstring(Ls, args.data());
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 2);
|
|
|
|
}};
|
2014-05-04 14:37:55 +08:00
|
|
|
cobj->addCommand(outValue);
|
|
|
|
}
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "ax.Console:addCommand", argc, 2);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-05-04 14:37:55 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Console_addCommand'.", &tolua_err);
|
2014-05-04 14:37:55 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendConsole(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Console");
|
2014-05-04 14:37:55 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "wait", lua_axis_Console_wait);
|
|
|
|
tolua_function(tolua_S, "send", lua_axis_Console_send);
|
|
|
|
tolua_function(tolua_S, "addCommand", lua_axis_Console_addCommand);
|
2014-05-04 14:37:55 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_OrbitCamera_sphericalRadius(lua_State* tolua_S)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::OrbitCamera* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.OrbitCamera", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::OrbitCamera*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
if (!self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_OrbitCamera_sphericalRadius'", nullptr);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-06-13 14:10:08 +08:00
|
|
|
if (argc == 3)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
|
2014-06-13 14:10:08 +08:00
|
|
|
!tolua_isnumber(tolua_S, 4, 0, &tolua_err))
|
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-06-13 14:10:08 +08:00
|
|
|
float newRadius = (float)tolua_tonumber(tolua_S, 2, 0);
|
|
|
|
float zenith = (float)tolua_tonumber(tolua_S, 3, 0);
|
|
|
|
float azimuth = (float)tolua_tonumber(tolua_S, 4, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-06-13 14:10:08 +08:00
|
|
|
self->sphericalRadius(&newRadius, &zenith, &azimuth);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)newRadius);
|
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)zenith);
|
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)azimuth);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-06-13 14:10:08 +08:00
|
|
|
return 3;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.OrbitCamera:sphericalRadius",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 3);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_OrbitCamera_sphericalRadius'.", &tolua_err);
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendOrbitCamera(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.OrbitCamera");
|
2014-06-13 14:10:08 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "sphericalRadius", lua_axis_OrbitCamera_sphericalRadius);
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_TMXLayer_getTileGIDAt(lua_State* tolua_S)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::TMXLayer* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.TMXLayer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::TMXLayer*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_TMXLayer_getTileGIDAt'", nullptr);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-06-13 14:10:08 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2 arg0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.TMXLayer:getTileGIDAt");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
|
|
|
unsigned int ret = cobj->getTileGIDAt(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)ret);
|
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)0);
|
2014-07-14 18:26:39 +08:00
|
|
|
return 2;
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2 arg0;
|
2014-06-13 14:10:08 +08:00
|
|
|
int arg1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.TMXLayer:getTileGIDAt");
|
|
|
|
ok &= luaval_to_int32(tolua_S, 3, &arg1, "ax.TMXLayer:getTileGIDAt");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
unsigned int ret = cobj->getTileGIDAt(arg0, (axis::TMXTileFlags*)&arg1);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)ret);
|
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)arg1);
|
2014-07-14 18:26:39 +08:00
|
|
|
return 2;
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.TMXLayer:getTileGIDAt", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
1);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_TMXLayer_getTileGIDAt'.", &tolua_err);
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_TMXLayer_setTiles(lua_State* tolua_S)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::TMXLayer* cobj = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.TMXLayer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::TMXLayer*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_TMXLayer_setTiles'", nullptr);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-06-13 14:10:08 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
|
|
|
uint32_t* arg0 = nullptr;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
if (!tolua_istable(tolua_S, 2, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-06-13 14:10:08 +08:00
|
|
|
size_t len = lua_objlen(tolua_S, 2);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (len == 0)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2014-12-01 15:53:41 +08:00
|
|
|
luaL_error(tolua_S, "Table's len equal 0");
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-08 00:11:53 +08:00
|
|
|
arg0 = new uint32_t[len];
|
2021-12-25 10:04:45 +08:00
|
|
|
for (size_t i = 1; i <= len; i++)
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
|
|
|
arg0[i - 1] = (uint32_t)tolua_tofieldnumber(tolua_S, 2, i, 0);
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-06-13 14:10:08 +08:00
|
|
|
cobj->setTiles(arg0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE_ARRAY(arg0);
|
2015-01-12 15:12:01 +08:00
|
|
|
lua_settop(tolua_S, 1);
|
|
|
|
return 1;
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.TMXLayer:setTiles", argc, 1);
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-13 14:10:08 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_TMXLayer_setTiles'.", &tolua_err);
|
2014-06-13 14:10:08 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-06-13 14:10:08 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendTMXLayer(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.TMXLayer");
|
2014-06-13 14:10:08 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-06-13 14:10:08 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "getTileGIDAt", lua_axis_TMXLayer_getTileGIDAt);
|
|
|
|
tolua_function(tolua_S, "setTiles", lua_axis_TMXLayer_setTiles);
|
2014-06-13 14:10:08 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_FastTMXLayer_getTileGIDAt(lua_State* tolua_S)
|
2019-10-23 14:58:31 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::FastTMXLayer* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2019-10-23 14:58:31 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-10-23 14:58:31 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.FastTMXLayer", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2019-10-23 14:58:31 +08:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::FastTMXLayer*)tolua_tousertype(tolua_S, 1, 0);
|
2019-10-23 14:58:31 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-10-23 14:58:31 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_FastTMXLayer_getTileGIDAt'", nullptr);
|
2019-10-23 14:58:31 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2019-10-23 14:58:31 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2 arg0;
|
2019-10-23 14:58:31 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.FastTMXLayer:getTileGIDAt");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2019-10-23 14:58:31 +08:00
|
|
|
return 0;
|
|
|
|
int ret = cobj->getTileGIDAt(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)ret);
|
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)0);
|
2019-10-23 14:58:31 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2 arg0;
|
2019-10-23 14:58:31 +08:00
|
|
|
int arg1 = 0;
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec2(tolua_S, 2, &arg0, "ax.FastTMXLayer:getTileGIDAt");
|
|
|
|
ok &= luaval_to_int32(tolua_S, 3, &arg1, "ax.FastTMXLayer:getTileGIDAt");
|
2019-10-23 14:58:31 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2019-10-23 14:58:31 +08:00
|
|
|
return 0;
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
unsigned int ret = cobj->getTileGIDAt(arg0, (axis::TMXTileFlags*)&arg1);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)ret);
|
|
|
|
tolua_pushnumber(tolua_S, (lua_Number)arg1);
|
2019-10-23 14:58:31 +08:00
|
|
|
return 2;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ax.FastTMXLayer:getTileGIDAt",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 1);
|
2019-10-23 14:58:31 +08:00
|
|
|
return 0;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-10-23 14:58:31 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_FastTMXLayer_getTileGIDAt'.", &tolua_err);
|
2019-10-23 14:58:31 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendFastTMXLayer(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.FastTMXLayer");
|
2019-10-23 14:58:31 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2019-10-23 14:58:31 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "getTileGIDAt", lua_axis_FastTMXLayer_getTileGIDAt);
|
2019-10-23 14:58:31 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Application_isIOS64bit(lua_State* tolua_S)
|
2014-06-27 17:58:59 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Application* cobj = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-27 17:58:59 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Application", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-06-27 17:58:59 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Application*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-27 17:58:59 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Application_isIOS64bit'", nullptr);
|
2014-06-27 17:58:59 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-06-27 17:58:59 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool isIOS64bit = false;
|
2022-07-11 17:50:21 +08:00
|
|
|
Application::Platform platform = axis::Application::getInstance()->getTargetPlatform();
|
2022-06-17 22:18:26 +08:00
|
|
|
if (Application::Platform::iOS == platform)
|
2014-06-27 17:58:59 +08:00
|
|
|
{
|
|
|
|
#if defined(__LP64__)
|
|
|
|
isIOS64bit = true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
tolua_pushboolean(tolua_S, isIOS64bit);
|
|
|
|
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.Application:isIOS64bit", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
0);
|
2014-06-27 17:58:59 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-06-27 17:58:59 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Application_isIOS64bit'.", &tolua_err);
|
2014-06-27 17:58:59 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-06-27 17:58:59 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Application_is64BitMobileDevice(lua_State* tolua_S)
|
2015-04-06 22:41:34 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Application* cobj = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-04-06 22:41:34 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Application", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-04-06 22:41:34 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Application*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-04-06 22:41:34 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Application_is64BitMobileDevice'", nullptr);
|
2015-04-06 22:41:34 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-04-06 22:41:34 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2022-06-17 22:18:26 +08:00
|
|
|
bool is64BitMobileDevice = false;
|
2022-07-11 17:50:21 +08:00
|
|
|
Application::Platform platform = axis::Application::getInstance()->getTargetPlatform();
|
2022-06-17 22:50:29 +08:00
|
|
|
if (Application::Platform::iOS == platform ||
|
2022-06-17 22:18:26 +08:00
|
|
|
Application::Platform::Android == platform)
|
2015-04-06 22:41:34 +08:00
|
|
|
{
|
2016-08-15 14:57:04 +08:00
|
|
|
#if defined(__arm64__) || defined(__aarch64__)
|
2022-06-17 22:18:26 +08:00
|
|
|
is64BitMobileDevice = true;
|
2015-04-06 22:41:34 +08:00
|
|
|
#endif
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-06-17 22:18:26 +08:00
|
|
|
tolua_pushboolean(tolua_S, is64BitMobileDevice);
|
2015-04-06 22:41:34 +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.Application:is64BitMobileDevice",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 0);
|
2015-04-06 22:41:34 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-04-06 22:41:34 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Application_is64BitMobileDevice'.", &tolua_err);
|
2015-04-06 22:41:34 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-04-06 22:41:34 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-06-27 17:58:59 +08:00
|
|
|
static void extendApplication(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Application");
|
2014-06-27 17:58:59 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-06-27 17:58:59 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "isIOS64bit", lua_axis_Application_isIOS64bit);
|
|
|
|
tolua_function(tolua_S, "is64BitMobileDevice", lua_axis_Application_is64BitMobileDevice);
|
2014-06-27 17:58:59 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_TextureCache_addImageAsync(lua_State* tolua_S)
|
2014-07-14 16:05:48 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2014-07-14 16:05:48 +08:00
|
|
|
TextureCache* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-07-14 16:05:48 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.TextureCache", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-07-14 16:05:48 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = static_cast<TextureCache*>(tolua_tousertype(tolua_S, 1, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_TextureCache_addImageAsync'\n", NULL);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-07-14 16:05:48 +08:00
|
|
|
#endif
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-14 16:05:48 +08:00
|
|
|
if (2 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err) ||
|
|
|
|
!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err))
|
2014-07-14 16:05:48 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2022-07-20 18:41:33 +08:00
|
|
|
auto configFilePath = axislua_tosv(tolua_S, 2);
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(tolua_S, 3, 0));
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self->addImageAsync(configFilePath, [=](Texture2D* tex) {
|
2021-11-15 19:05:08 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (tex) ? (int)tex->_ID : -1;
|
2014-07-14 16:05:48 +08:00
|
|
|
int* luaID = (tex) ? &tex->_luaID : nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(stack->getLuaState(), ID, luaID, (void*)tex, "ax.Texture2D");
|
2021-11-15 19:05:08 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 1);
|
2022-07-20 18:41:33 +08:00
|
|
|
stack->removeScriptHandler(handler);
|
2014-07-14 16:05:48 +08:00
|
|
|
});
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-14 16:05:48 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s function of TextureCache has wrong number of arguments: %d, was expecting %d\n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.TextureCache:addImageAsync", argc, 1);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-07-14 16:05:48 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_TextureCache_addImageAsync'.", &tolua_err);
|
2014-07-14 16:05:48 +08:00
|
|
|
#endif
|
2014-07-15 17:38:56 +08:00
|
|
|
return 0;
|
2014-07-14 16:05:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void extendTextureCache(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.TextureCache");
|
2014-07-14 16:05:48 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-07-14 16:05:48 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "addImageAsync", lua_axis_TextureCache_addImageAsync);
|
2014-07-14 16:05:48 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_GLView_getAllTouches(lua_State* tolua_S)
|
2014-09-04 22:12:59 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::GLView* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-04 22:12:59 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.GLView", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-04 22:12:59 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::GLView*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-04 22:12:59 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_GLView_getAllTouches'", nullptr);
|
2014-09-04 22:12:59 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2014-09-04 22:12:59 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-09-04 22:12:59 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
std::vector<axis::Touch*> ret = cobj->getAllTouches();
|
2014-09-04 22:12:59 +08:00
|
|
|
lua_newtable(tolua_S);
|
|
|
|
if (ret.empty())
|
|
|
|
return 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-04 22:12:59 +08:00
|
|
|
int index = 1;
|
|
|
|
for (const auto& obj : ret)
|
|
|
|
{
|
|
|
|
if (nullptr == obj)
|
|
|
|
continue;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-04 22:12:59 +08:00
|
|
|
lua_pushnumber(tolua_S, (lua_Number)index);
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (obj) ? (int)obj->_ID : -1;
|
2014-09-04 22:12:59 +08:00
|
|
|
int* luaID = (obj) ? &obj->_luaID : nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)obj, "ax.Touch");
|
2014-09-04 22:12:59 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
|
|
|
|
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.GLView:getAllTouches", argc,
|
2021-12-25 10:04:45 +08:00
|
|
|
0);
|
2014-09-04 22:12:59 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-04 22:12:59 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_GLView_getAllTouches'.", &tolua_err);
|
2014-09-04 22:12:59 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-04 22:12:59 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendGLView(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.GLView");
|
2014-09-04 22:12:59 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-09-04 22:12:59 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "getAllTouches", lua_axis_GLView_getAllTouches);
|
2014-09-04 22:12:59 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Camera_unproject(lua_State* tolua_S)
|
2014-09-28 16:47:06 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Camera* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-28 16:47:06 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Camera", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-28 16:47:06 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::Camera*)tolua_tousertype(tolua_S, 1, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-28 16:47:06 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_Camera_unproject'", nullptr);
|
2014-09-28 16:47:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-02-27 10:20:32 +08:00
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec3 arg0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 2, &arg0, "ax.Camera:project");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-02-27 10:20:32 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_Camera_project'", nullptr);
|
2015-02-27 10:20:32 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
auto ret = cobj->unproject(arg0);
|
|
|
|
vec3_to_luaval(tolua_S, ret);
|
|
|
|
return 1;
|
|
|
|
}
|
2014-09-28 16:47:06 +08:00
|
|
|
if (argc == 3)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Size arg0;
|
|
|
|
axis::Vec3 arg1;
|
|
|
|
axis::Vec3 arg2;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_size(tolua_S, 2, &arg0, "ax.Camera:unproject");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 3, &arg1, "ax.Camera:unproject");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 4, &arg2, "ax.Camera:unproject");
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2014-09-28 16:47:06 +08:00
|
|
|
return 0;
|
|
|
|
cobj->unproject(arg0, &arg1, &arg2);
|
|
|
|
vec3_to_luaval(tolua_S, arg2);
|
|
|
|
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.Camera:unproject", argc, 3);
|
2014-09-28 16:47:06 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-09-28 16:47:06 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Camera_unproject'.", &tolua_err);
|
2014-09-28 16:47:06 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-09-28 16:47:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendCamera(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Camera");
|
2014-09-28 16:47:06 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2014-09-28 16:47:06 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "unproject", lua_axis_Camera_unproject);
|
2014-09-28 16:47:06 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_Properties_createNonRefCounted(lua_State* tolua_S)
|
2015-05-27 15:37:59 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-27 15:37:59 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +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.Properties", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-05-27 15:37:59 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-27 15:37:59 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-27 15:37:59 +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.Properties:createNonRefCounted");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-05-27 15:37:59 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_Properties_createNonRefCounted'",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
2015-05-27 15:37:59 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Properties* ret = axis::Properties::createNonRefCounted(arg0);
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::Properties>(tolua_S, "ax.Properties", (axis::Properties*)ret);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_register_gc(tolua_S, lua_gettop(tolua_S));
|
2015-05-27 15:37:59 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ",
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.Properties:createNonRefCounted", argc, 1);
|
2015-05-27 15:37:59 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-27 15:37:59 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_Properties_createNonRefCounted'.", &tolua_err);
|
2015-05-27 15:37:59 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int lua_collect_Properties(lua_State* tolua_S)
|
2015-05-27 15:37:59 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Properties* self = (axis::Properties*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(self);
|
2015-05-27 15:37:59 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendProperties(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.Properties");
|
2015-05-27 15:37:59 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2015-05-27 15:37:59 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "createNonRefCounted", lua_axis_Properties_createNonRefCounted);
|
2015-05-27 15:37:59 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_getmetatable(tolua_S, "ax.Properties");
|
2015-05-27 15:37:59 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
|
|
|
{
|
|
|
|
tolua_function(tolua_S, ".collector", lua_collect_Properties);
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_get_PolygonInfo_rect(lua_State* tolua_S)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* cobj = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PolygonInfo", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PolygonInfo*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
if (nullptr == cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_get_PolygonInfo_rect'\n", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-10-27 09:45:40 +08:00
|
|
|
rect_to_luaval(tolua_S, cobj->getRect());
|
2015-06-11 14:38:38 +08:00
|
|
|
return 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_get_PolygonInfo_rect'.", &tolua_err);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_set_PolygonInfo_rect(lua_State* tolua_S)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PolygonInfo", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::PolygonInfo*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_set_PolygonInfo_rect'\n", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-11 14:38:38 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-11 14:38:38 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
if (!tolua_istable(tolua_S, 2, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2016-10-27 09:45:40 +08:00
|
|
|
Rect outRect;
|
|
|
|
luaval_to_rect(tolua_S, 2, &outRect);
|
|
|
|
self->setRect(outRect);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_set_PolygonInfo_rect'.", &tolua_err);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_get_PolygonInfo_filename(lua_State* tolua_S)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* cobj = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PolygonInfo", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PolygonInfo*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
if (nullptr == cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_get_PolygonInfo_filename'\n", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-28 11:05:34 +08:00
|
|
|
tolua_pushstring(tolua_S, cobj->getFilename().data());
|
2015-06-11 14:38:38 +08:00
|
|
|
return 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_get_PolygonInfo_filename'.", &tolua_err);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_set_PolygonInfo_filename(lua_State* tolua_S)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* self = nullptr;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PolygonInfo", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::PolygonInfo*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_set_PolygonInfo_filename'\n", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-11 14:38:38 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-11 14:38:38 +08:00
|
|
|
if (1 == argc)
|
|
|
|
{
|
2016-10-27 09:45:40 +08:00
|
|
|
std::string outFilename;
|
|
|
|
luaval_to_std_string(tolua_S, 2, &outFilename);
|
|
|
|
self->setFilename(outFilename);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_set_PolygonInfo_filename'.", &tolua_err);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int lua_collect_PolygonInfo(lua_State* tolua_S)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* self = (axis::PolygonInfo*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(self);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_get_PipelineDescriptor_programState(lua_State* tolua_S)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PipelineDescriptor* cobj = nullptr;
|
2019-05-05 15:26:34 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PipelineDescriptor", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2019-05-05 15:26:34 +08:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::PipelineDescriptor*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
if (nullptr == cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_get_PipelineDescriptor_programState'\n",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
2019-05-05 15:26:34 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_pushusertype(tolua_S, cobj->programState, "axb.ProgramState");
|
2019-05-05 15:26:34 +08:00
|
|
|
return 1;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_get_PipelineDescriptor_programState'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2019-05-05 15:26:34 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_set_PipelineDescriptor_programState(lua_State* tolua_S)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PipelineDescriptor* self = nullptr;
|
2019-05-05 15:26:34 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.PipelineDescriptor", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2019-05-05 15:26:34 +08:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::PipelineDescriptor*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_set_PipelineDescriptor_programState'\n",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
2019-05-05 15:26:34 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::ProgramState* programState = nullptr;
|
2022-07-12 21:31:54 +08:00
|
|
|
luaval_to_object<axis::backend::ProgramState>(tolua_S, 2, "axb.ProgramState", &programState,
|
|
|
|
"lua_axis_set_PipelineDescriptor_programState");
|
2019-05-05 15:26:34 +08:00
|
|
|
self->programState = programState;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_set_PipelineDescriptor_programState'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2019-05-05 15:26:34 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-06-11 14:38:38 +08:00
|
|
|
static void extendPolygonInfo(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.PolygonInfo");
|
2015-06-11 14:38:38 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_variable(tolua_S, "rect", lua_axis_get_PolygonInfo_rect, lua_axis_set_PolygonInfo_rect);
|
|
|
|
tolua_variable(tolua_S, "filename", lua_axis_get_PolygonInfo_filename,
|
|
|
|
lua_axis_set_PolygonInfo_filename);
|
2015-06-11 14:38:38 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_getmetatable(tolua_S, "ax.PolygonInfo");
|
2015-06-11 14:38:38 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
|
|
|
{
|
|
|
|
tolua_function(tolua_S, ".collector", lua_collect_PolygonInfo);
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static void extendPipelineDescriptor(lua_State* tolua_S)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.PipelineDescriptor");
|
2019-05-05 15:26:34 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
if (lua_istable(tolua_S, -1))
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_variable(tolua_S, "programState", lua_axis_get_PipelineDescriptor_programState,
|
|
|
|
lua_axis_set_PipelineDescriptor_programState);
|
2019-05-05 15:26:34 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_backend_ProgramState_getUniformLocation(lua_State* tolua_S)
|
2019-08-15 16:51:49 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::ProgramState* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-08-15 16:51:49 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "axb.ProgramState", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2019-08-15 16:51:49 +08:00
|
|
|
#endif
|
2022-07-11 17:50:21 +08:00
|
|
|
cobj = (axis::backend::ProgramState*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-08-15 16:51:49 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'lua_axis_backend_ProgramState_getUniformLocation'",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
2019-08-15 16:51:49 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2019-08-15 16:51:49 +08:00
|
|
|
if (lua_isstring(tolua_S, -1))
|
|
|
|
{
|
|
|
|
std::string arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &arg0, "axb.ProgramState:getUniformLocation");
|
2019-08-15 16:51:49 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::UniformLocation ret = cobj->getUniformLocation(arg0);
|
2021-12-25 10:04:45 +08:00
|
|
|
uniformLocation_to_luaval(tolua_S, ret);
|
2019-08-15 16:51:49 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (lua_isnumber(tolua_S, -1))
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::Uniform arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_int32(tolua_S, 2, (int*)&arg0, "axb.ProgramState:getUniformLocation");
|
2019-08-15 16:51:49 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::UniformLocation ret = cobj->getUniformLocation(arg0);
|
2019-08-15 16:51:49 +08:00
|
|
|
uniformLocation_to_luaval(tolua_S, ret);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n",
|
2022-07-12 21:31:54 +08:00
|
|
|
"axb.ProgramState:getUniformLocation", argc, 1);
|
2019-08-15 16:51:49 +08:00
|
|
|
return 0;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_backend_ProgramState_getUniformLocation'.", &tolua_err);
|
2019-08-15 16:51:49 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
static int lua_axis_ProgramState_setUniform(lua_State* tolua_S)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
|
|
|
int argc = 0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::ProgramState* self = nullptr;
|
2019-05-05 15:26:34 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "axb.ProgramState", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2019-05-05 15:26:34 +08:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::backend::ProgramState*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'self' in function 'lua_axis_ProgramState_setUniform'\n", nullptr);
|
2019-05-05 15:26:34 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
|
|
|
|
|
|
|
if (2 == argc)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::UniformLocation location;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-09-17 17:15:16 +08:00
|
|
|
if (lua_isstring(tolua_S, 2))
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2019-09-17 17:15:16 +08:00
|
|
|
location = self->getUniformLocation(lua_tostring(tolua_S, 2));
|
2021-12-25 10:04:45 +08:00
|
|
|
}
|
2019-09-17 17:15:16 +08:00
|
|
|
else if (lua_istable(tolua_S, 2))
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_uniformLocation(tolua_S, 2, location, "axb.ProgramState:setUniform");
|
2019-05-05 15:26:34 +08:00
|
|
|
}
|
|
|
|
|
2019-09-17 17:15:16 +08:00
|
|
|
if (ok & lua_istable(tolua_S, 3))
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2019-09-17 17:15:16 +08:00
|
|
|
int len = lua_objlen(tolua_S, 3);
|
2019-05-05 15:26:34 +08:00
|
|
|
std::vector<uint8_t> buffer(len);
|
|
|
|
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
{
|
2019-09-17 17:15:16 +08:00
|
|
|
lua_rawgeti(tolua_S, 3, i + 1);
|
2019-05-05 15:26:34 +08:00
|
|
|
buffer[i] = lua_tointeger(tolua_S, -1);
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
self->setUniform(location, buffer.data(), buffer.size());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "`lua_axis_ProgramState_setUniform` argument invalidate");
|
2019-05-05 15:26:34 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_set_PipelineDescriptor_vertexLayout'.", &tolua_err);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2019-05-05 15:26:34 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static void extendProgramState(lua_State* tolua_S)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
// lua_pushstring(tolua_S, "axb.ProgramState");
|
2021-12-25 10:04:45 +08:00
|
|
|
// lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_beginmodule(tolua_S, "axb");
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_beginmodule(tolua_S, "ProgramState");
|
|
|
|
if (lua_istable(tolua_S, -1))
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "setUniform", lua_axis_ProgramState_setUniform);
|
|
|
|
tolua_function(tolua_S, "getUniformLocation", lua_axis_backend_ProgramState_getUniformLocation);
|
2019-05-05 15:26:34 +08:00
|
|
|
}
|
|
|
|
tolua_endmodule(tolua_S);
|
|
|
|
tolua_endmodule(tolua_S);
|
2021-12-25 10:04:45 +08:00
|
|
|
// lua_pop(tolua_S, 1);
|
2019-05-05 15:26:34 +08:00
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_AutoPolygon_generatePolygon(lua_State* tolua_S)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +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.AutoPolygon", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-11 14:38:38 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-06-11 14:38:38 +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.AutoPolygon:generatePolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_AutoPolygon_generatePolygon'", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* ret = new axis::PolygonInfo(axis::AutoPolygon::generatePolygon(arg0));
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PolygonInfo>(tolua_S, "ax.PolygonInfo", (axis::PolygonInfo*)ret);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_register_gc(tolua_S, lua_gettop(tolua_S));
|
2015-06-11 14:38:38 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
std::string arg0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Rect arg1;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &arg0, "ax.AutoPolygon:generatePolygon");
|
|
|
|
ok &= luaval_to_rect(tolua_S, 3, &arg1, "ax.AutoPolygon:generatePolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_AutoPolygon_generatePolygon'", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* ret = new axis::PolygonInfo(axis::AutoPolygon::generatePolygon(arg0, arg1));
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PolygonInfo>(tolua_S, "ax.PolygonInfo", (axis::PolygonInfo*)ret);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_register_gc(tolua_S, lua_gettop(tolua_S));
|
2015-06-11 14:38:38 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 3)
|
|
|
|
{
|
|
|
|
std::string arg0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Rect arg1;
|
2015-06-11 14:38:38 +08:00
|
|
|
double arg2;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &arg0, "ax.AutoPolygon:generatePolygon");
|
|
|
|
ok &= luaval_to_rect(tolua_S, 3, &arg1, "ax.AutoPolygon:generatePolygon");
|
|
|
|
ok &= luaval_to_number(tolua_S, 4, &arg2, "ax.AutoPolygon:generatePolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_AutoPolygon_generatePolygon'", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* ret =
|
|
|
|
new axis::PolygonInfo(axis::AutoPolygon::generatePolygon(arg0, arg1, (float)arg2));
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PolygonInfo>(tolua_S, "ax.PolygonInfo", (axis::PolygonInfo*)ret);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_register_gc(tolua_S, lua_gettop(tolua_S));
|
2015-06-11 14:38:38 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (argc == 4)
|
|
|
|
{
|
|
|
|
std::string arg0;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Rect arg1;
|
2015-06-11 14:38:38 +08:00
|
|
|
double arg2;
|
|
|
|
double arg3;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_std_string(tolua_S, 2, &arg0, "ax.AutoPolygon:generatePolygon");
|
|
|
|
ok &= luaval_to_rect(tolua_S, 3, &arg1, "ax.AutoPolygon:generatePolygon");
|
|
|
|
ok &= luaval_to_number(tolua_S, 4, &arg2, "ax.AutoPolygon:generatePolygon");
|
|
|
|
ok &= luaval_to_number(tolua_S, 5, &arg3, "ax.AutoPolygon:generatePolygon");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "invalid arguments in function 'lua_axis_AutoPolygon_generatePolygon'", nullptr);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo* ret =
|
|
|
|
new axis::PolygonInfo(axis::AutoPolygon::generatePolygon(arg0, arg1, (float)arg2, (float)arg3));
|
2022-07-12 21:31:54 +08:00
|
|
|
object_to_luaval<axis::PolygonInfo>(tolua_S, "ax.PolygonInfo", (axis::PolygonInfo*)ret);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_register_gc(tolua_S, lua_gettop(tolua_S));
|
2015-06-11 14:38:38 +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.AutoPolygon:generatePolygon",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 1);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-06-11 14:38:38 +08:00
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_AutoPolygon_generatePolygon'.", &tolua_err);
|
2015-06-11 14:38:38 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int lua_collect_AutoPolygon(lua_State* tolua_S)
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::AutoPolygon* self = (axis::AutoPolygon*)tolua_tousertype(tolua_S, 1, 0);
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_SAFE_DELETE(self);
|
2015-06-11 14:38:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendAutoPolygon(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.AutoPolygon");
|
2015-06-11 14:38:38 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2015-06-11 14:38:38 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(tolua_S, "generatePolygon", lua_axis_AutoPolygon_generatePolygon);
|
2015-06-11 14:38:38 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_getmetatable(tolua_S, "ax.AutoPolygon");
|
2015-06-11 14:38:38 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
|
|
|
{
|
|
|
|
tolua_function(tolua_S, ".collector", lua_collect_AutoPolygon);
|
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
//extern int lua_axis_Director_setStatsDisplay(lua_State* tolua_S);
|
|
|
|
//static void extendDirector(lua_State* tolua_S)
|
|
|
|
//{
|
|
|
|
// lua_pushstring(tolua_S, "ax.Director");
|
|
|
|
// lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
|
|
|
// if (lua_istable(tolua_S, -1))
|
|
|
|
// {
|
|
|
|
// lua_pushstring(tolua_S, "setDisplayStats");
|
|
|
|
// lua_pushcfunction(tolua_S, lua_axis_Director_setStatsDisplay);
|
|
|
|
// lua_rawset(tolua_S, -3);
|
|
|
|
// }
|
|
|
|
// lua_pop(tolua_S, 1);
|
|
|
|
//}
|
2022-07-11 17:50:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int register_all_axis_manual(lua_State* tolua_S)
|
2014-05-04 14:37:55 +08:00
|
|
|
{
|
|
|
|
if (NULL == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
extendNode(tolua_S);
|
2015-01-05 17:10:25 +08:00
|
|
|
extendScene(tolua_S);
|
2014-05-04 14:37:55 +08:00
|
|
|
extendLayer(tolua_S);
|
|
|
|
extendMenuItem(tolua_S);
|
|
|
|
extendMenuItemImage(tolua_S);
|
|
|
|
extendMenuItemLabel(tolua_S);
|
|
|
|
extendMenuItemFont(tolua_S);
|
|
|
|
extendMenuItemSprite(tolua_S);
|
|
|
|
extendMenuItemToggle(tolua_S);
|
|
|
|
extendMenu(tolua_S);
|
|
|
|
extendScheduler(tolua_S);
|
|
|
|
extendSequence(tolua_S);
|
|
|
|
extendCallFunc(tolua_S);
|
|
|
|
extendSpawn(tolua_S);
|
|
|
|
extendCardinalSplineBy(tolua_S);
|
|
|
|
extendCatmullRomBy(tolua_S);
|
|
|
|
extendCatmullRomTo(tolua_S);
|
|
|
|
extendBezierBy(tolua_S);
|
|
|
|
extendBezierTo(tolua_S);
|
|
|
|
extendDrawNode(tolua_S);
|
|
|
|
extendSprite(tolua_S);
|
|
|
|
extendLayerMultiplex(tolua_S);
|
|
|
|
extendFileUtils(tolua_S);
|
|
|
|
extendUserDefault(tolua_S);
|
|
|
|
extendTexture2D(tolua_S);
|
|
|
|
extendSpriteBatchNode(tolua_S);
|
|
|
|
extendEventListenerKeyboard(tolua_S);
|
|
|
|
extendEventListenerTouchOneByOne(tolua_S);
|
|
|
|
extendEventListenerTouchAllAtOnce(tolua_S);
|
|
|
|
extendEventListenerMouse(tolua_S);
|
|
|
|
extendEventListenerCustom(tolua_S);
|
|
|
|
extendEventListenerAcceleration(tolua_S);
|
|
|
|
extendActionCamera(tolua_S);
|
|
|
|
extendGridAction(tolua_S);
|
2019-05-05 15:26:34 +08:00
|
|
|
extendPipelineDescriptor(tolua_S);
|
|
|
|
extendProgramState(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-05-04 14:37:55 +08:00
|
|
|
extendLabel(tolua_S);
|
|
|
|
extendTMXTiledMap(tolua_S);
|
|
|
|
extendConsole(tolua_S);
|
2014-06-13 14:10:08 +08:00
|
|
|
extendOrbitCamera(tolua_S);
|
|
|
|
extendTMXLayer(tolua_S);
|
2019-10-23 14:58:31 +08:00
|
|
|
extendFastTMXLayer(tolua_S);
|
2014-06-27 17:58:59 +08:00
|
|
|
extendApplication(tolua_S);
|
2014-07-14 16:05:48 +08:00
|
|
|
extendTextureCache(tolua_S);
|
2014-09-04 22:12:59 +08:00
|
|
|
extendGLView(tolua_S);
|
2014-09-28 16:47:06 +08:00
|
|
|
extendCamera(tolua_S);
|
2015-05-27 15:37:59 +08:00
|
|
|
extendProperties(tolua_S);
|
2015-06-11 14:38:38 +08:00
|
|
|
extendAutoPolygon(tolua_S);
|
|
|
|
extendPolygonInfo(tolua_S);
|
2019-06-19 13:45:14 +08:00
|
|
|
extendRenderTexture(tolua_S);
|
2014-05-04 14:37:55 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-07-04 16:24:00 +08:00
|
|
|
|
|
|
|
static int tolua_cocos2d_utils_captureScreen(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-07-04 16:24:00 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !toluafix_isfunction(tolua_S, 2, "LUA_FUNCTION", 0, &tolua_err) ||
|
|
|
|
!tolua_isstring(tolua_S, 3, 0, &tolua_err))
|
2014-07-04 16:24:00 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
|
2022-07-09 22:23:34 +08:00
|
|
|
auto fileName = axislua_tosv(tolua_S, 3);
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::utils::captureScreen(
|
2021-12-26 23:26:34 +08:00
|
|
|
[=](bool succeed, std::string_view name) {
|
2021-12-25 10:04:45 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
|
|
|
auto Ls = stack->getLuaState();
|
|
|
|
tolua_pushboolean(Ls, succeed);
|
2021-12-28 11:05:34 +08:00
|
|
|
tolua_pushstring(Ls, name.data());
|
2021-12-25 10:04:45 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 2);
|
2022-07-20 18:41:33 +08:00
|
|
|
stack->removeScriptHandler(handler);
|
2021-12-25 10:04:45 +08:00
|
|
|
},
|
|
|
|
fileName);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-04 16:43:33 +08:00
|
|
|
return 0;
|
2014-07-04 16:24:00 +08:00
|
|
|
}
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-07-04 16:24:00 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_utils_captureScreen'.", &tolua_err);
|
2014-07-04 16:24:00 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_utils_findChildren(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-07-04 16:24:00 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isusertype(tolua_S, 2, "ax.Node", 0, &tolua_err) ||
|
2021-12-25 10:04:45 +08:00
|
|
|
!tolua_isstring(tolua_S, 3, 0, &tolua_err))
|
2014-07-04 16:24:00 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Node* node = static_cast<Node*>(tolua_tousertype(tolua_S, 2, nullptr));
|
2022-07-09 22:23:34 +08:00
|
|
|
auto name = axislua_tosv(tolua_S, 3);
|
2022-07-11 17:50:21 +08:00
|
|
|
std::vector<Node*> children = axis::utils::findChildren(*node, name);
|
2014-07-04 16:24:00 +08:00
|
|
|
lua_newtable(tolua_S);
|
|
|
|
int index = 1;
|
|
|
|
for (const auto& obj : children)
|
|
|
|
{
|
|
|
|
if (nullptr == obj)
|
|
|
|
continue;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-04 16:24:00 +08:00
|
|
|
lua_pushnumber(tolua_S, (lua_Number)index);
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (obj) ? (int)obj->_ID : -1;
|
2014-07-04 16:24:00 +08:00
|
|
|
int* luaID = (obj) ? &obj->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)obj, "ax.Node");
|
2014-07-04 16:24:00 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-07-04 16:24:00 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_utils_findChildren'.", &tolua_err);
|
2014-07-04 16:24:00 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-07-04 14:37:44 +08:00
|
|
|
static int tolua_cocos2d_utils_findChild(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2017-07-04 14:37:44 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.Node", 0, &tolua_err) || !tolua_isstring(tolua_S, 2, 0, &tolua_err))
|
2017-07-04 14:37:44 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Node* node = static_cast<Node*>(tolua_tousertype(tolua_S, 1, nullptr));
|
2022-07-09 22:23:34 +08:00
|
|
|
auto name = axislua_tosv(tolua_S, 2);
|
2022-07-11 17:50:21 +08:00
|
|
|
auto obj = axis::utils::findChild(node, name);
|
2021-12-25 10:04:45 +08:00
|
|
|
int ID = (obj) ? (int)obj->_ID : -1;
|
|
|
|
int* luaID = (obj) ? &obj->_luaID : NULL;
|
2022-07-12 21:31:54 +08:00
|
|
|
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)obj, "ax.Node");
|
2017-07-04 14:37:44 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_utils_findChild'.", &tolua_err);
|
|
|
|
return 0;
|
2017-07-04 14:37:44 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int register_all_axis_module_manual(lua_State* tolua_S)
|
2014-07-04 16:24:00 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-04 16:24:00 +08:00
|
|
|
tolua_open(tolua_S);
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_module(tolua_S, "ax", 0);
|
|
|
|
tolua_beginmodule(tolua_S, "ax");
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_module(tolua_S, "utils", 0);
|
|
|
|
tolua_beginmodule(tolua_S, "utils");
|
|
|
|
tolua_function(tolua_S, "captureScreen", tolua_cocos2d_utils_captureScreen);
|
|
|
|
tolua_function(tolua_S, "findChildren", tolua_cocos2d_utils_findChildren);
|
|
|
|
tolua_function(tolua_S, "findChild", tolua_cocos2d_utils_findChild);
|
|
|
|
tolua_endmodule(tolua_S);
|
2014-07-04 16:24:00 +08:00
|
|
|
tolua_endmodule(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-07-04 16:24:00 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-10-10 09:49:25 +08:00
|
|
|
|
|
|
|
static int tolua_cocos2d_Mat4_getInversed(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-10-10 09:49:25 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 mat;
|
2014-10-10 09:49:25 +08:00
|
|
|
bool ok = luaval_to_mat4(tolua_S, 1, &mat);
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
mat4_to_luaval(tolua_S, mat.getInversed());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-10-10 09:49:25 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'mat4_getInversed'.", &tolua_err);
|
2014-10-10 09:49:25 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Mat4_transformVector(lua_State* tolua_S)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2014-10-10 09:49:25 +08:00
|
|
|
int argc = lua_gettop(tolua_S);
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-10-10 09:49:25 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-10-08 14:33:50 +08:00
|
|
|
if (argc == 2 || argc == 3) /* Allow 3 arguments for compatibility with old version */
|
2014-10-10 09:49:25 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-10-10 09:49:25 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_istable(tolua_S, 2, 0, &tolua_err))
|
2014-10-10 09:49:25 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 mat;
|
|
|
|
axis::Vec4 vector;
|
|
|
|
axis::Vec4 dst;
|
2014-10-10 09:49:25 +08:00
|
|
|
ok &= luaval_to_mat4(tolua_S, 1, &mat);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
ok &= luaval_to_vec4(tolua_S, 2, &vector);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
mat.transformVector(vector, &dst);
|
|
|
|
vec4_to_luaval(tolua_S, dst);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
else if (argc == 5 || argc == 6) /* Allow 6 arguments for compatibility with old version */
|
2014-10-10 09:49:25 +08:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
float x, float y, float z, float w, Vec3* dst
|
|
|
|
*/
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) ||
|
|
|
|
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) ||
|
|
|
|
!tolua_isnumber(tolua_S, 5, 0, &tolua_err))
|
2014-10-10 09:49:25 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 mat;
|
2021-12-25 10:04:45 +08:00
|
|
|
float x, y, z, w;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec3 dst;
|
2014-10-10 09:49:25 +08:00
|
|
|
ok &= luaval_to_mat4(tolua_S, 1, &mat);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2019-09-24 11:31:35 +08:00
|
|
|
x = tolua_tonumber(tolua_S, 2, 0);
|
|
|
|
y = tolua_tonumber(tolua_S, 3, 0);
|
|
|
|
z = tolua_tonumber(tolua_S, 4, 0);
|
|
|
|
w = tolua_tonumber(tolua_S, 5, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
mat.transformVector(x, y, z, w, &dst);
|
2014-10-10 09:49:25 +08:00
|
|
|
vec3_to_luaval(tolua_S, dst);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-10-10 09:49:25 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'mat4_transformVector'.", &tolua_err);
|
2014-10-10 09:49:25 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Mat4_decompose(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-10-10 09:49:25 +08:00
|
|
|
tolua_Error tolua_err;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) ||
|
2015-01-28 09:40:20 +08:00
|
|
|
(!lua_isnil(tolua_S, 2) && !tolua_istable(tolua_S, 2, 0, &tolua_err)) ||
|
|
|
|
(!lua_isnil(tolua_S, 3) && !tolua_istable(tolua_S, 3, 0, &tolua_err)) ||
|
2021-12-25 10:04:45 +08:00
|
|
|
(!lua_isnil(tolua_S, 4) && !tolua_istable(tolua_S, 4, 0, &tolua_err)))
|
2014-10-10 09:49:25 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 mat;
|
|
|
|
axis::Vec3 scale;
|
|
|
|
axis::Quaternion rotation;
|
|
|
|
axis::Vec3 translation;
|
2014-10-10 09:49:25 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
ok &= luaval_to_mat4(tolua_S, 1, &mat);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
if (lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4))
|
|
|
|
{
|
|
|
|
ok &= luaval_to_quaternion(tolua_S, 3, &rotation);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 4, &translation);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
mat.decompose(nullptr, &rotation, &translation);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_newtable(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "scale");
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "rotation");
|
|
|
|
quaternion_to_luaval(tolua_S, rotation);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "translation");
|
|
|
|
vec3_to_luaval(tolua_S, translation);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
if (lua_isnil(tolua_S, 2) && lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4))
|
|
|
|
{
|
|
|
|
ok &= luaval_to_vec3(tolua_S, 4, &translation);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
mat.decompose(nullptr, nullptr, &translation);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_newtable(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "scale");
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "rotation");
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "translation");
|
|
|
|
vec3_to_luaval(tolua_S, translation);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
if (!lua_isnil(tolua_S, 2) && lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4))
|
|
|
|
{
|
|
|
|
ok &= luaval_to_vec3(tolua_S, 2, &scale);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 4, &translation);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
mat.decompose(&scale, nullptr, &translation);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_newtable(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "scale");
|
|
|
|
vec3_to_luaval(tolua_S, scale);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "rotation");
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "translation");
|
|
|
|
vec3_to_luaval(tolua_S, translation);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
if (!lua_isnil(tolua_S, 2) && lua_isnil(tolua_S, 3) && lua_isnil(tolua_S, 4))
|
|
|
|
{
|
|
|
|
ok &= luaval_to_vec3(tolua_S, 2, &scale);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
mat.decompose(&scale, nullptr, nullptr);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_newtable(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "scale");
|
|
|
|
vec3_to_luaval(tolua_S, scale);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "rotation");
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "translation");
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
if (!lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && lua_isnil(tolua_S, 4))
|
|
|
|
{
|
|
|
|
ok &= luaval_to_vec3(tolua_S, 2, &scale);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
ok &= luaval_to_quaternion(tolua_S, 3, &rotation);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
mat.decompose(&scale, &rotation, nullptr);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_newtable(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "scale");
|
|
|
|
vec3_to_luaval(tolua_S, scale);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "rotation");
|
|
|
|
quaternion_to_luaval(tolua_S, rotation);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "translation");
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
if (lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && lua_isnil(tolua_S, 4))
|
|
|
|
{
|
|
|
|
ok &= luaval_to_quaternion(tolua_S, 3, &rotation);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
mat.decompose(nullptr, &rotation, nullptr);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_newtable(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "scale");
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "rotation");
|
|
|
|
quaternion_to_luaval(tolua_S, rotation);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "translation");
|
|
|
|
lua_pushnil(tolua_S);
|
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
if (!lua_isnil(tolua_S, 2) && !lua_isnil(tolua_S, 3) && !lua_isnil(tolua_S, 4))
|
|
|
|
{
|
|
|
|
ok &= luaval_to_vec3(tolua_S, 2, &scale);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
ok &= luaval_to_quaternion(tolua_S, 3, &rotation);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 4, &translation);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
mat.decompose(&scale, &rotation, &translation);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_newtable(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "scale");
|
|
|
|
vec3_to_luaval(tolua_S, scale);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "rotation");
|
|
|
|
quaternion_to_luaval(tolua_S, rotation);
|
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_pushstring(tolua_S, "translation");
|
2015-01-28 11:12:12 +08:00
|
|
|
vec3_to_luaval(tolua_S, translation);
|
2015-01-28 09:40:20 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
return 0;
|
2014-10-10 09:49:25 +08:00
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-10-10 09:49:25 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'mat4_decompose'.", &tolua_err);
|
2014-10-10 09:49:25 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Vec3_cross(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
int argc = lua_gettop(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-10-10 09:49:25 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
if (2 == argc)
|
2014-10-10 09:49:25 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_istable(tolua_S, 2, 0, &tolua_err))
|
2014-10-10 09:49:25 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec3 cobj;
|
|
|
|
axis::Vec3 v;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 1, &cobj);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 2, &v);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
cobj.cross(v);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
vec3_to_luaval(tolua_S, cobj);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (3 == argc)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_istable(tolua_S, 2, 0, &tolua_err) ||
|
|
|
|
!tolua_istable(tolua_S, 3, 0, &tolua_err))
|
2014-10-10 09:49:25 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec3 v1;
|
|
|
|
axis::Vec3 v2;
|
|
|
|
axis::Vec3 dst;
|
2014-10-10 09:49:25 +08:00
|
|
|
bool ok = true;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 1, &v1);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 2, &v2);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 3, &dst);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec3::cross(v1, v2, &dst);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
vec3_to_luaval(tolua_S, dst);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2014-10-10 09:49:25 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'MathUtil_gcrossVec3'.", &tolua_err);
|
2014-10-10 09:49:25 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-01-28 09:40:20 +08:00
|
|
|
static int tolua_cocos2d_Mat4_multiply(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-01-28 09:40:20 +08:00
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_istable(tolua_S, 2, 0, &tolua_err))
|
2015-01-28 09:40:20 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 mat1;
|
2015-01-28 09:40:20 +08:00
|
|
|
bool ok = luaval_to_mat4(tolua_S, 1, &mat1);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-01-28 09:40:20 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 mat2;
|
2015-01-28 09:40:20 +08:00
|
|
|
ok = luaval_to_mat4(tolua_S, 2, &mat2);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-01-28 09:40:20 +08:00
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 ret = mat1 * mat2;
|
2015-01-28 09:40:20 +08:00
|
|
|
mat4_to_luaval(tolua_S, ret);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-01-28 09:40:20 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'mat4_multiply'.", &tolua_err);
|
2015-01-28 09:40:20 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
int tolua_cocos2d_Mat4_translate(lua_State* tolua_S)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2015-05-15 09:28:03 +08:00
|
|
|
int argc = lua_gettop(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_istable(tolua_S, 2, 0, &tolua_err))
|
2015-05-15 09:28:03 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 mat;
|
|
|
|
axis::Vec3 vec3;
|
2015-05-15 09:28:03 +08:00
|
|
|
ok &= luaval_to_mat4(tolua_S, 1, &mat);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 2, &vec3);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
mat.translate(vec3);
|
|
|
|
mat4_to_luaval(tolua_S, mat);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Mat4_translate'.", &tolua_err);
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_Mat4_createRotationZ(lua_State* tolua_S)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2015-05-15 09:28:03 +08:00
|
|
|
int argc = lua_gettop(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 2)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
2015-05-15 09:28:03 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 mat;
|
2015-05-15 09:28:03 +08:00
|
|
|
float angle;
|
|
|
|
ok &= luaval_to_mat4(tolua_S, 1, &mat);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2019-09-20 11:20:07 +08:00
|
|
|
angle = (float)lua_tonumber(tolua_S, 2);
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4::createRotationZ(angle, &mat);
|
2015-05-15 09:28:03 +08:00
|
|
|
mat4_to_luaval(tolua_S, mat);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Mat4_createRotationZ'.", &tolua_err);
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_Mat4_setIdentity(lua_State* tolua_S)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2015-05-15 09:28:03 +08:00
|
|
|
int argc = lua_gettop(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 mat;
|
2015-05-15 09:28:03 +08:00
|
|
|
ok &= luaval_to_mat4(tolua_S, 1, &mat);
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
|
|
|
mat.setIdentity();
|
|
|
|
mat4_to_luaval(tolua_S, mat);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Mat4_setIdentity'.", &tolua_err);
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_Mat4_createTranslation(lua_State* tolua_S)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2015-05-15 09:28:03 +08:00
|
|
|
int argc = lua_gettop(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-10-08 14:33:50 +08:00
|
|
|
if (argc == 3)
|
2015-05-15 09:28:03 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isnumber(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err) ||
|
|
|
|
!tolua_isnumber(tolua_S, 3, 0, &tolua_err))
|
2015-05-15 09:28:03 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 dst;
|
2015-05-15 09:28:03 +08:00
|
|
|
float xTranslation = (float)lua_tonumber(tolua_S, 1);
|
|
|
|
float yTranslation = (float)lua_tonumber(tolua_S, 2);
|
|
|
|
float zTranslation = (float)lua_tonumber(tolua_S, 3);
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4::createTranslation(xTranslation, yTranslation, zTranslation, &dst);
|
2015-05-15 09:28:03 +08:00
|
|
|
mat4_to_luaval(tolua_S, dst);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-10-08 14:33:50 +08:00
|
|
|
else if (argc == 1)
|
2015-05-15 09:28:03 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err))
|
2015-05-15 09:28:03 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec3 translation;
|
|
|
|
axis::Mat4 dst;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 1, &translation, "ax.Mat4.createTranslation");
|
2015-05-15 09:28:03 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4::createTranslation(translation, &dst);
|
2015-05-15 09:28:03 +08:00
|
|
|
mat4_to_luaval(tolua_S, dst);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Mat4_createTranslation'.", &tolua_err);
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int tolua_cocos2d_Mat4_createRotation(lua_State* tolua_S)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2015-05-15 09:28:03 +08:00
|
|
|
int argc = lua_gettop(tolua_S);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2016-10-08 14:33:50 +08:00
|
|
|
if (argc == 1)
|
2015-05-15 09:28:03 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err))
|
2015-05-15 09:28:03 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Quaternion quat;
|
|
|
|
axis::Mat4 dst;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_quaternion(tolua_S, 1, &quat, "ax.Mat4.createRotation");
|
2015-05-15 09:28:03 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4::createRotation(quat, &dst);
|
2015-05-15 09:28:03 +08:00
|
|
|
mat4_to_luaval(tolua_S, dst);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-10-08 14:33:50 +08:00
|
|
|
else if (argc == 2)
|
2015-05-15 09:28:03 +08:00
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_istable(tolua_S, 1, 0, &tolua_err) || !tolua_isnumber(tolua_S, 2, 0, &tolua_err))
|
2015-05-15 09:28:03 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec3 axis;
|
|
|
|
axis::Mat4 dst;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_vec3(tolua_S, 1, &axis, "ax.Mat4.createRotation");
|
2015-05-15 09:28:03 +08:00
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
float angle = (float)tolua_tonumber(tolua_S, 2, 0);
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4::createRotation(axis, angle, &dst);
|
2015-05-15 09:28:03 +08:00
|
|
|
mat4_to_luaval(tolua_S, dst);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2015-05-15 09:28:03 +08:00
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'tolua_cocos2d_Mat4_createRotation'.", &tolua_err);
|
2015-05-15 09:28:03 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-01-03 22:06:49 +08:00
|
|
|
static int tolua_cocos2d_Vec2_new(lua_State* L)
|
|
|
|
{
|
|
|
|
return vec2_to_luaval(L, Vec2{static_cast<float>(lua_tonumber(L, 1)), static_cast<float>(lua_tonumber(L, 2))});
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Vec3_new(lua_State* L)
|
|
|
|
{
|
|
|
|
return vec3_to_luaval(L, Vec3{static_cast<float>(lua_tonumber(L, 1)), static_cast<float>(lua_tonumber(L, 2)),
|
|
|
|
static_cast<float>(lua_tonumber(L, 3))});
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tolua_cocos2d_Vec4_new(lua_State* L)
|
|
|
|
{
|
|
|
|
return vec4_to_luaval(L, Vec4{static_cast<float>(lua_tonumber(L, 1)), static_cast<float>(lua_tonumber(L, 2)),
|
|
|
|
static_cast<float>(lua_tonumber(L, 3)), static_cast<float>(lua_tonumber(L, 4))});
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int register_all_axis_math_manual(lua_State* tolua_S)
|
2014-10-10 09:49:25 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2016-04-18 15:09:21 +08:00
|
|
|
|
2014-10-10 09:49:25 +08:00
|
|
|
tolua_module(tolua_S, nullptr, 0);
|
|
|
|
tolua_beginmodule(tolua_S, nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_function(tolua_S, "mat4_getInversed", tolua_cocos2d_Mat4_getInversed);
|
|
|
|
tolua_function(tolua_S, "mat4_transformVector", tolua_cocos2d_Mat4_transformVector);
|
|
|
|
tolua_function(tolua_S, "mat4_decompose", tolua_cocos2d_Mat4_decompose);
|
|
|
|
tolua_function(tolua_S, "mat4_multiply", tolua_cocos2d_Mat4_multiply);
|
|
|
|
tolua_function(tolua_S, "mat4_translate", tolua_cocos2d_Mat4_translate);
|
|
|
|
tolua_function(tolua_S, "mat4_createRotationZ", tolua_cocos2d_Mat4_createRotationZ);
|
|
|
|
tolua_function(tolua_S, "mat4_setIdentity", tolua_cocos2d_Mat4_setIdentity);
|
|
|
|
tolua_function(tolua_S, "mat4_createTranslation", tolua_cocos2d_Mat4_createTranslation);
|
|
|
|
tolua_function(tolua_S, "mat4_createRotation", tolua_cocos2d_Mat4_createRotation);
|
|
|
|
tolua_function(tolua_S, "vec3_cross", tolua_cocos2d_Vec3_cross);
|
2022-01-03 22:06:49 +08:00
|
|
|
tolua_function(tolua_S, "vec2_new", tolua_cocos2d_Vec2_new);
|
|
|
|
tolua_function(tolua_S, "vec3_new", tolua_cocos2d_Vec3_new);
|
|
|
|
tolua_function(tolua_S, "vec4_new", tolua_cocos2d_Vec4_new);
|
2014-10-10 09:49:25 +08:00
|
|
|
tolua_endmodule(tolua_S);
|
|
|
|
return 0;
|
|
|
|
}
|
2019-05-05 15:26:34 +08:00
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int register_all_axis_shaders_manual(lua_State* tolua_S)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
#define set_lua_field(field) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
lua_pushstring(tolua_S, #field); \
|
|
|
|
lua_pushstring(tolua_S, field); \
|
|
|
|
lua_rawset(tolua_S, -3); \
|
|
|
|
} while (false)
|
2019-05-05 15:26:34 +08:00
|
|
|
|
|
|
|
tolua_open(tolua_S);
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_module(tolua_S, "ax", 0);
|
|
|
|
tolua_beginmodule(tolua_S, "ax");
|
2021-12-25 10:04:45 +08:00
|
|
|
set_lua_field(positionColor_vert);
|
|
|
|
set_lua_field(positionColor_frag);
|
|
|
|
set_lua_field(positionTexture_vert);
|
|
|
|
set_lua_field(positionTexture_frag);
|
|
|
|
set_lua_field(positionTextureColor_vert);
|
|
|
|
set_lua_field(positionTextureColor_frag);
|
|
|
|
set_lua_field(positionTextureColorAlphaTest_frag);
|
|
|
|
set_lua_field(label_normal_frag);
|
|
|
|
set_lua_field(label_distanceNormal_frag);
|
|
|
|
set_lua_field(labelOutline_frag);
|
|
|
|
set_lua_field(labelDistanceFieldGlow_frag);
|
|
|
|
set_lua_field(lineColor3D_frag);
|
|
|
|
set_lua_field(lineColor3D_vert);
|
|
|
|
set_lua_field(positionColorLengthTexture_vert);
|
|
|
|
set_lua_field(positionColorLengthTexture_frag);
|
|
|
|
set_lua_field(positionColorTextureAsPointsize_vert);
|
|
|
|
set_lua_field(position_vert);
|
|
|
|
set_lua_field(layer_radialGradient_frag);
|
|
|
|
set_lua_field(grayScale_frag);
|
|
|
|
set_lua_field(positionUColor_vert);
|
|
|
|
set_lua_field(dualSampler_frag);
|
|
|
|
set_lua_field(dualSampler_gray_frag);
|
|
|
|
set_lua_field(cameraClear_vert);
|
|
|
|
set_lua_field(cameraClear_frag);
|
|
|
|
set_lua_field(CC3D_color_frag);
|
|
|
|
set_lua_field(CC3D_colorNormal_frag);
|
|
|
|
set_lua_field(CC3D_colorNormalTexture_frag);
|
|
|
|
set_lua_field(CC3D_colorTexture_frag);
|
|
|
|
set_lua_field(CC3D_particleTexture_frag);
|
|
|
|
set_lua_field(CC3D_particleColor_frag);
|
|
|
|
set_lua_field(CC3D_particle_vert);
|
|
|
|
set_lua_field(CC3D_positionNormalTexture_vert);
|
|
|
|
set_lua_field(CC3D_skinPositionNormalTexture_vert);
|
|
|
|
set_lua_field(CC3D_positionTexture_vert);
|
|
|
|
set_lua_field(CC3D_skinPositionTexture_vert);
|
|
|
|
set_lua_field(CC3D_skybox_frag);
|
|
|
|
set_lua_field(CC3D_skybox_vert);
|
|
|
|
set_lua_field(CC3D_terrain_frag);
|
|
|
|
set_lua_field(CC3D_terrain_vert);
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_endmodule(tolua_S);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int tolua_cocos2d_bytearray_vec2(lua_State* L)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2019-05-05 15:26:34 +08:00
|
|
|
int argc = lua_gettop(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
if (!tolua_istable(L, 1, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec2 arg;
|
2019-05-05 15:26:34 +08:00
|
|
|
ok &= luaval_to_vec2(L, 1, &arg, "tolua_cocos2d_bytearray_template");
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_newtable(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
uint8_t* bytes = (uint8_t*)&arg;
|
2019-05-05 15:26:34 +08:00
|
|
|
for (auto idx = 0; idx < sizeof(arg); idx++)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, bytes[idx]);
|
|
|
|
lua_rawseti(L, 1, idx + 1);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(L, "#ferror in function 'tolua_cocos2d_bytearray_template'.", &tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int tolua_cocos2d_bytearray_vec3(lua_State* L)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2019-05-05 15:26:34 +08:00
|
|
|
int argc = lua_gettop(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
if (!tolua_istable(L, 1, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec3 arg;
|
2019-05-05 15:26:34 +08:00
|
|
|
ok &= luaval_to_vec3(L, 1, &arg, "tolua_cocos2d_bytearray_template");
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_newtable(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
uint8_t* bytes = (uint8_t*)&arg;
|
2019-05-05 15:26:34 +08:00
|
|
|
for (auto idx = 0; idx < sizeof(arg); idx++)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, bytes[idx]);
|
|
|
|
lua_rawseti(L, 1, idx + 1);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(L, "#ferror in function 'tolua_cocos2d_bytearray_template'.", &tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int tolua_cocos2d_bytearray_vec4(lua_State* L)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2019-05-05 15:26:34 +08:00
|
|
|
int argc = lua_gettop(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
if (!tolua_istable(L, 1, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vec4 arg;
|
2019-05-05 15:26:34 +08:00
|
|
|
ok &= luaval_to_vec4(L, 1, &arg, "tolua_cocos2d_bytearray_template");
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_newtable(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
uint8_t* bytes = (uint8_t*)&arg;
|
2019-05-05 15:26:34 +08:00
|
|
|
for (auto idx = 0; idx < sizeof(arg); idx++)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, bytes[idx]);
|
|
|
|
lua_rawseti(L, 1, idx + 1);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(L, "#ferror in function 'tolua_cocos2d_bytearray_template'.", &tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int tolua_cocos2d_bytearray_mat4(lua_State* L)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2019-05-05 15:26:34 +08:00
|
|
|
int argc = lua_gettop(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
if (!tolua_istable(L, 1, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Mat4 arg;
|
2019-05-05 15:26:34 +08:00
|
|
|
ok &= luaval_to_mat4(L, 1, &arg, "tolua_cocos2d_bytearray_template");
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_newtable(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
uint8_t* bytes = (uint8_t*)&arg;
|
2019-05-05 15:26:34 +08:00
|
|
|
for (auto idx = 0; idx < sizeof(arg); idx++)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, bytes[idx]);
|
|
|
|
lua_rawseti(L, 1, idx + 1);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(L, "#ferror in function 'tolua_cocos2d_bytearray_template'.", &tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int tolua_cocos2d_bytearray_int(lua_State* L)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2019-05-05 15:26:34 +08:00
|
|
|
int argc = lua_gettop(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
if (!tolua_isnumber(L, 1, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
int arg;
|
|
|
|
ok &= luaval_to_int32(L, 1, &arg, "tolua_cocos2d_bytearray_template");
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_newtable(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
uint8_t* bytes = (uint8_t*)&arg;
|
2019-05-05 15:26:34 +08:00
|
|
|
for (auto idx = 0; idx < sizeof(arg); idx++)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, bytes[idx]);
|
|
|
|
lua_rawseti(L, 1, idx + 1);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(L, "#ferror in function 'tolua_cocos2d_bytearray_template'.", &tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int tolua_cocos2d_bytearray_float(lua_State* L)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
2019-05-05 15:26:34 +08:00
|
|
|
int argc = lua_gettop(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
if (!tolua_isnumber(L, 1, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
float arg;
|
|
|
|
ok &= luaval_to_float(L, 1, &arg, "tolua_cocos2d_bytearray_template");
|
|
|
|
if (!ok)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_newtable(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
uint8_t* bytes = (uint8_t*)&arg;
|
2019-05-05 15:26:34 +08:00
|
|
|
for (auto idx = 0; idx < sizeof(arg); idx++)
|
|
|
|
{
|
|
|
|
lua_pushnumber(L, bytes[idx]);
|
|
|
|
lua_rawseti(L, 1, idx + 1);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(L, "#ferror in function 'tolua_cocos2d_bytearray_template'.", &tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int tolua_cocos2d_bytearray_intv(lua_State* L)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
|
|
|
int argc = lua_gettop(L);
|
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
|
|
|
|
if (!tolua_istable(L, 1, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
int size = lua_objlen(L, 1);
|
|
|
|
std::vector<uint8_t> arg(size * sizeof(int));
|
|
|
|
|
|
|
|
int e;
|
2021-12-25 10:04:45 +08:00
|
|
|
int* p = (int*)arg.data();
|
2019-05-05 15:26:34 +08:00
|
|
|
|
|
|
|
for (auto idx = 0; idx < size; idx++)
|
|
|
|
{
|
|
|
|
lua_rawgeti(L, 1, idx + 1);
|
|
|
|
luaval_to_int32(L, -1, &e, "tolua_cocos2d_bytearray_elev");
|
|
|
|
p[idx] = e;
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_newtable(L);
|
2019-09-20 11:20:07 +08:00
|
|
|
for (size_t idx = 0; idx < arg.size(); idx++)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
|
|
|
lua_pushnumber(L, arg[idx]);
|
|
|
|
lua_rawseti(L, 1, idx + 1);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(L, "#ferror in function 'tolua_cocos2d_bytearray_elev'.", &tolua_err);
|
|
|
|
return 0;
|
2019-05-05 15:26:34 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
static int tolua_cocos2d_bytearray_floatv(lua_State* L)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
|
|
|
int argc = lua_gettop(L);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
|
|
|
if (argc == 1)
|
|
|
|
{
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
if (!tolua_istable(L, 1, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
int size = lua_objlen(L, 1);
|
|
|
|
std::vector<uint8_t> arg(size * sizeof(float));
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
float e;
|
2021-12-25 10:04:45 +08:00
|
|
|
float* p = (float*)arg.data();
|
|
|
|
|
2019-05-05 15:26:34 +08:00
|
|
|
for (auto idx = 0; idx < size; idx++)
|
|
|
|
{
|
|
|
|
lua_rawgeti(L, 1, idx + 1);
|
|
|
|
luaval_to_float(L, -1, &e, "tolua_cocos2d_bytearray_elev");
|
|
|
|
p[idx] = e;
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_newtable(L);
|
2019-09-24 11:31:35 +08:00
|
|
|
for (auto idx = 0; idx < arg.size(); idx++)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
|
|
|
lua_pushnumber(L, arg[idx]);
|
|
|
|
lua_rawseti(L, 1, idx + 1);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2022-07-19 15:34:26 +08:00
|
|
|
#if AXIS_DEBUG >= 1
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_lerror:
|
|
|
|
tolua_error(L, "#ferror in function 'tolua_cocos2d_bytearray_elev'.", &tolua_err);
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int register_all_axis_bytearray_manual(lua_State* tolua_S)
|
2019-05-05 15:26:34 +08:00
|
|
|
{
|
|
|
|
if (nullptr == tolua_S)
|
|
|
|
return 0;
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_module(tolua_S, "ax", 0);
|
|
|
|
tolua_beginmodule(tolua_S, "ax");
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_module(tolua_S, "bytearray", 0);
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_beginmodule(tolua_S, "bytearray");
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_function(tolua_S, "from_vec2", tolua_cocos2d_bytearray_vec2);
|
|
|
|
tolua_function(tolua_S, "from_vec3", tolua_cocos2d_bytearray_vec3);
|
|
|
|
tolua_function(tolua_S, "from_vec4", tolua_cocos2d_bytearray_vec4);
|
|
|
|
tolua_function(tolua_S, "from_mat4", tolua_cocos2d_bytearray_mat4);
|
|
|
|
tolua_function(tolua_S, "from_int", tolua_cocos2d_bytearray_int);
|
|
|
|
tolua_function(tolua_S, "from_float", tolua_cocos2d_bytearray_float);
|
|
|
|
tolua_function(tolua_S, "from_intv", tolua_cocos2d_bytearray_intv);
|
|
|
|
tolua_function(tolua_S, "from_floatv", tolua_cocos2d_bytearray_floatv);
|
2019-05-05 15:26:34 +08:00
|
|
|
tolua_endmodule(tolua_S);
|
|
|
|
tolua_endmodule(tolua_S);
|
|
|
|
return 0;
|
|
|
|
}
|