2014-03-10 14:04:58 +08:00
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-10-01 16:24:52 +08:00
|
|
|
https://axmolengine.github.io/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2022-08-08 18:02:17 +08:00
|
|
|
#include "scripting/lua-bindings/manual/extension/axlua_extension_manual.h"
|
|
|
|
#include "scripting/lua-bindings/auto/axlua_extension_auto.hpp"
|
2016-04-18 15:09:21 +08:00
|
|
|
|
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"
|
2014-03-10 14:04:58 +08:00
|
|
|
#include "cocos-ext.h"
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "scripting/lua-bindings/manual/CCLuaEngine.h"
|
2022-07-12 21:31:54 +08:00
|
|
|
#include "scripting/lua-bindings/manual/base/LuaScriptHandlerMgr.h"
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
USING_NS_AX;
|
|
|
|
USING_NS_AX_EXT;
|
2014-03-10 14:04:58 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
class LuaAssetsManagerDelegateProtocol : public Ref, public AssetsManagerDelegateProtocol
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
public:
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual ~LuaAssetsManagerDelegateProtocol() {}
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
virtual void onProgress(int percent) override
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(
|
|
|
|
(void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS);
|
2014-10-16 10:28:52 +08:00
|
|
|
if (0 != handler)
|
|
|
|
{
|
|
|
|
LuaAssetsManagerEventData eventData(percent);
|
2021-12-25 10:04:45 +08:00
|
|
|
BasicScriptData data((void*)this, &eventData);
|
2014-10-16 10:28:52 +08:00
|
|
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS, (void*)&data);
|
|
|
|
}
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
virtual void onSuccess() override
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(
|
|
|
|
(void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS);
|
2014-10-16 10:28:52 +08:00
|
|
|
if (0 != handler)
|
|
|
|
{
|
|
|
|
LuaAssetsManagerEventData eventData;
|
2021-12-25 10:04:45 +08:00
|
|
|
BasicScriptData data((void*)this, &eventData);
|
2014-10-16 10:28:52 +08:00
|
|
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS, (void*)&data);
|
|
|
|
}
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
virtual void onError(AssetsManager::ErrorCode errorCode) override
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(
|
|
|
|
(void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR);
|
2014-10-16 10:28:52 +08:00
|
|
|
if (0 != handler)
|
|
|
|
{
|
|
|
|
LuaAssetsManagerEventData eventData((int)errorCode);
|
2021-12-25 10:04:45 +08:00
|
|
|
BasicScriptData data((void*)this, &eventData);
|
2014-10-16 10:28:52 +08:00
|
|
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR, (void*)&data);
|
|
|
|
}
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
static int axlua_AssetsManager_setDelegate(lua_State* L)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int argc = 0;
|
2014-03-10 14:04:58 +08:00
|
|
|
AssetsManager* self = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.AssetsManager", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-10 14:04:58 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
self = (AssetsManager*)tolua_tousertype(L, 1, 0);
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'axlua_AssetsManager_setDelegate'\n", nullptr);
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
argc = lua_gettop(L) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
if (2 == argc)
|
2021-12-25 10:04:45 +08:00
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(L, 2, "LUA_FUNCTION", 0, &tolua_err) || !tolua_isnumber(L, 3, 0, &tolua_err))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
LuaAssetsManagerDelegateProtocol* delegate =
|
|
|
|
dynamic_cast<LuaAssetsManagerDelegateProtocol*>(self->getDelegate());
|
2014-03-10 14:04:58 +08:00
|
|
|
if (nullptr == delegate)
|
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
delegate = new LuaAssetsManagerDelegateProtocol();
|
2014-03-10 14:04:58 +08:00
|
|
|
self->setUserObject(delegate);
|
|
|
|
self->setDelegate(delegate);
|
|
|
|
delegate->release();
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(L, 2, 0);
|
|
|
|
ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType)(
|
|
|
|
(int)tolua_tonumber(L, 3, 0) + (int)ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS);
|
|
|
|
|
2014-03-10 14:04:58 +08:00
|
|
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)delegate, handler, handlerType);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +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.AssetsManager:setDelegate", argc, 2);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2014-03-10 14:04:58 +08:00
|
|
|
tolua_lerror:
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_error(L, "#ferror in function 'axlua_AssetsManager_setDelegate'.", &tolua_err);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendAssetsManager(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "ax.AssetsManager");
|
2014-03-10 14:04:58 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_function(L, "setDelegate", axlua_AssetsManager_setDelegate);
|
2014-03-10 14:04:58 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2014-10-09 18:30:39 +08:00
|
|
|
static void extendManifest(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "ax.Manifest");
|
2014-10-09 18:30:39 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
static int axlua_Extension_EventListenerAssetsManagerEx_create(lua_State* L)
|
2014-10-09 18:30:39 +08:00
|
|
|
{
|
|
|
|
if (nullptr == L)
|
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-10-09 18:30:39 +08:00
|
|
|
int argc = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2014-10-09 18:30:39 +08:00
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(L, 1, "ax.EventListenerAssetsManagerEx", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-10-09 18:30:39 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
|
2014-10-09 18:30:39 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 2, "ax.AssetsManagerEx", 0, &tolua_err) ||
|
2021-12-25 10:04:45 +08:00
|
|
|
!toluafix_isfunction(L, 3, "LUA_FUNCTION", 0, &tolua_err))
|
2014-10-09 18:30:39 +08:00
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
2022-08-08 18:02:17 +08:00
|
|
|
ax::extension::AssetsManagerEx* assetManager =
|
|
|
|
static_cast<ax::extension::AssetsManagerEx*>(tolua_tousertype(L, 2, nullptr));
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
LUA_FUNCTION handler = toluafix_ref_function(L, 3, 0);
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
ax::extension::EventListenerAssetsManagerEx* ret =
|
|
|
|
ax::extension::EventListenerAssetsManagerEx::create(assetManager, [=](EventAssetsManagerEx* event) {
|
2021-12-25 10:04:45 +08:00
|
|
|
auto stack = LuaEngine::getInstance()->getLuaStack();
|
|
|
|
int id = event ? (int)event->_ID : -1;
|
|
|
|
int* luaID = event ? &event->_luaID : nullptr;
|
|
|
|
toluafix_pushusertype_ccobject(stack->getLuaState(), id, luaID, (void*)event,
|
2022-07-12 21:31:54 +08:00
|
|
|
"ax.EventAssetsManagerEx");
|
2021-12-25 10:04:45 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
int id = (ret) ? (int)ret->_ID : -1;
|
2014-10-09 18:30:39 +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.EventListenerAssetsManagerEx");
|
2014-10-09 18:30:39 +08:00
|
|
|
return 1;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d \n", "create", argc, 2);
|
2014-10-09 18:30:39 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2014-10-09 18:30:39 +08:00
|
|
|
tolua_lerror:
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_error(L, "#ferror in function 'axlua_Extension_EventListenerAssetsManagerEx_create'.", &tolua_err);
|
2014-10-09 18:30:39 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendEventListenerAssetsManagerEx(lua_State* L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "ax.EventListenerAssetsManagerEx");
|
2014-10-09 18:30:39 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-10-09 18:30:39 +08:00
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_function(L, "create", axlua_Extension_EventListenerAssetsManagerEx_create);
|
2014-10-09 18:30:39 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
int axlua_extension_ParticleSystem3D_getParticlePool(lua_State* tolua_S)
|
2015-02-15 15:56:20 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-08-08 18:02:17 +08:00
|
|
|
ax::ParticleSystem3D* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2015-02-15 15:56:20 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.ParticleSystem3D", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-02-15 15:56:20 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
cobj = (ax::ParticleSystem3D*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2015-02-15 15:56:20 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'axlua_extension_ParticleSystem3D_getParticlePool'",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
2015-02-15 15:56:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-02-15 15:56:20 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-02-15 15:56:20 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S,
|
2022-08-08 18:02:17 +08:00
|
|
|
"invalid arguments in function 'axlua_extension_ParticleSystem3D_getParticlePool'",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
2015-02-15 15:56:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-08-08 18:02:17 +08:00
|
|
|
const ax::ParticlePool& ret = cobj->getParticlePool();
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_pushusertype(tolua_S, (void*)&ret, "ax.ParticlePool");
|
2015-02-15 15:56:20 +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.ParticleSystem3D:getParticlePool", argc, 0);
|
2015-02-15 15:56:20 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2015-02-15 15:56:20 +08:00
|
|
|
tolua_lerror:
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'axlua_extension_ParticleSystem3D_getParticlePool'.", &tolua_err);
|
2015-02-15 15:56:20 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-02-15 15:56:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendParticleSystem3D(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.ParticleSystem3D");
|
2015-02-15 15:56:20 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2015-02-15 15:56:20 +08:00
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_function(tolua_S, "getParticlePool", axlua_extension_ParticleSystem3D_getParticlePool);
|
2015-02-15 15:56:20 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
int axlua_extension_ParticlePool_getActiveDataList(lua_State* tolua_S)
|
2015-02-15 15:56:20 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2022-08-08 18:02:17 +08:00
|
|
|
ax::ParticlePool* cobj = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
bool ok = true;
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2015-02-15 15:56:20 +08:00
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(tolua_S, 1, "ax.ParticlePool", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2015-02-15 15:56:20 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
cobj = (ax::ParticlePool*)tolua_tousertype(tolua_S, 1, 0);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2015-02-15 15:56:20 +08:00
|
|
|
if (!cobj)
|
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_error(tolua_S, "invalid 'cobj' in function 'axlua_extension_ParticlePool_getActiveDataList'",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
2015-02-15 15:56:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2015-02-15 15:56:20 +08:00
|
|
|
if (argc == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!ok)
|
2015-02-15 15:56:20 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S,
|
2022-08-08 18:02:17 +08:00
|
|
|
"invalid arguments in function 'axlua_extension_ParticlePool_getActiveDataList'",
|
2021-12-25 10:04:45 +08:00
|
|
|
nullptr);
|
2015-02-15 15:56:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2015-03-04 10:42:08 +08:00
|
|
|
const ParticlePool::PoolList& ret = cobj->getActiveDataList();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-02-15 15:56:20 +08:00
|
|
|
lua_newtable(tolua_S);
|
|
|
|
if (ret.empty())
|
|
|
|
return 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-02-15 15:56:20 +08:00
|
|
|
int index = 1;
|
|
|
|
for (const auto& obj : ret)
|
|
|
|
{
|
|
|
|
if (nullptr == obj)
|
|
|
|
continue;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-02-15 15:56:20 +08:00
|
|
|
lua_pushnumber(tolua_S, (lua_Number)index);
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_pushusertype(tolua_S, (void*)&ret, "ax.ParticlePool");
|
2015-02-15 15:56:20 +08:00
|
|
|
lua_rawset(tolua_S, -3);
|
|
|
|
++index;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-02-15 15:56:20 +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.ParticlePool:getActiveParticleList", argc, 0);
|
2015-02-15 15:56:20 +08:00
|
|
|
return 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
#if _AX_DEBUG >= 1
|
2015-02-15 15:56:20 +08:00
|
|
|
tolua_lerror:
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'axlua_extension_ParticlePool_getActiveParticleList'.",
|
2021-12-25 10:04:45 +08:00
|
|
|
&tolua_err);
|
2015-02-15 15:56:20 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-02-15 15:56:20 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void extendParticlePool(lua_State* tolua_S)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(tolua_S, "ax.ParticlePool");
|
2015-02-15 15:56:20 +08:00
|
|
|
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1))
|
2015-02-15 15:56:20 +08:00
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
tolua_function(tolua_S, "getActiveDataList", axlua_extension_ParticlePool_getActiveDataList);
|
2015-02-15 15:56:20 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
|
|
|
}
|
|
|
|
|
2022-08-29 20:51:22 +08:00
|
|
|
int register_all_ax_extension_manual(lua_State* tolua_S)
|
2014-03-10 14:04:58 +08:00
|
|
|
{
|
|
|
|
extendAssetsManager(tolua_S);
|
2014-10-09 18:30:39 +08:00
|
|
|
extendManifest(tolua_S);
|
|
|
|
extendEventListenerAssetsManagerEx(tolua_S);
|
2015-02-15 15:56:20 +08:00
|
|
|
extendParticleSystem3D(tolua_S);
|
|
|
|
extendParticlePool(tolua_S);
|
2014-03-10 14:04:58 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2014-08-04 09:39:42 +08:00
|
|
|
|
|
|
|
int register_extension_module(lua_State* tolua_S)
|
|
|
|
{
|
2014-08-04 17:11:57 +08:00
|
|
|
lua_getglobal(tolua_S, "_G");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(tolua_S, -1)) // stack:...,_G,
|
2014-08-04 17:11:57 +08:00
|
|
|
{
|
2022-08-29 20:51:22 +08:00
|
|
|
register_all_ax_extension(tolua_S);
|
|
|
|
register_all_ax_extension_manual(tolua_S);
|
2014-08-04 17:11:57 +08:00
|
|
|
}
|
|
|
|
lua_pop(tolua_S, 1);
|
2014-08-04 09:39:42 +08:00
|
|
|
return 1;
|
|
|
|
}
|