mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4691 from samuele3hu/DispatcherBak1
Reconstruct the operation of handling lua script event
This commit is contained in:
commit
bf881f3ac0
|
@ -190,13 +190,7 @@ void NotificationCenter::postNotification(const std::string& name, Object *sende
|
||||||
|
|
||||||
if (observer->getName() == name && (observer->getSender() == sender || observer->getSender() == nullptr || sender == nullptr))
|
if (observer->getName() == name && (observer->getSender() == sender || observer->getSender() == nullptr || sender == nullptr))
|
||||||
{
|
{
|
||||||
if (0 != observer->getHandler())
|
if (0 == observer->getHandler())
|
||||||
{
|
|
||||||
BasicScriptData data(this, (void*)name.c_str());
|
|
||||||
ScriptEvent scriptEvent(kNotificationEvent,(void*)&data);
|
|
||||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
observer->performSelector(sender);
|
observer->performSelector(sender);
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,6 @@ enum ScriptEventType
|
||||||
{
|
{
|
||||||
kNodeEvent = 0,
|
kNodeEvent = 0,
|
||||||
kMenuClickedEvent,
|
kMenuClickedEvent,
|
||||||
kNotificationEvent,
|
|
||||||
kCallFuncEvent,
|
kCallFuncEvent,
|
||||||
kScheduleEvent,
|
kScheduleEvent,
|
||||||
kTouchEvent,
|
kTouchEvent,
|
||||||
|
@ -210,16 +209,6 @@ enum ScriptEventType
|
||||||
kAccelerometerEvent,
|
kAccelerometerEvent,
|
||||||
kControlEvent,
|
kControlEvent,
|
||||||
kCommonEvent,
|
kCommonEvent,
|
||||||
kTableViewEvent,//Now it's only used in LuaBinding
|
|
||||||
kAssetsManagerEvent,//Now it's only used in Lua Binding
|
|
||||||
kCocoStudioEventListener,//Now it's only used in Lua Binding
|
|
||||||
kArmatureWrapper,//Now it's only used in Lua Binding
|
|
||||||
kEventListenerAcc,//Now it's only used in Lua Binding
|
|
||||||
kEventListenerKeyboard,//Now it's only used in Lua Binding
|
|
||||||
kEventListenerTouch,//Now it's only used in Lua Binding
|
|
||||||
kEventListenerTouches,//Now it's only used in Lua Binding
|
|
||||||
kEventListenerMouse,//Now it's only used in Lua Binding
|
|
||||||
kEventListenerCustom,////Now it's only used in Lua Binding
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BasicScriptData
|
struct BasicScriptData
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
#include "CCArray.h"
|
#include "CCArray.h"
|
||||||
#include "CCScheduler.h"
|
#include "CCScheduler.h"
|
||||||
#include "LuaScriptHandlerMgr.h"
|
|
||||||
#include "extensions/GUI/CCControlExtension/CCControl.h"
|
#include "extensions/GUI/CCControlExtension/CCControl.h"
|
||||||
#include "LuaOpengl.h"
|
#include "LuaOpengl.h"
|
||||||
#include "lua_cocos2dx_manual.hpp"
|
#include "lua_cocos2dx_manual.hpp"
|
||||||
|
@ -204,11 +203,6 @@ int LuaEngine::sendEvent(ScriptEvent* evt)
|
||||||
return handleMenuClickedEvent(evt->data);
|
return handleMenuClickedEvent(evt->data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kNotificationEvent:
|
|
||||||
{
|
|
||||||
return handleNotificationEvent(evt->data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kCallFuncEvent:
|
case kCallFuncEvent:
|
||||||
{
|
{
|
||||||
return handleCallFuncActionEvent(evt->data);
|
return handleCallFuncActionEvent(evt->data);
|
||||||
|
@ -249,56 +243,6 @@ int LuaEngine::sendEvent(ScriptEvent* evt)
|
||||||
return handlerControlEvent(evt->data);
|
return handlerControlEvent(evt->data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kTableViewEvent:
|
|
||||||
{
|
|
||||||
return handleTableViewEvent(evt->data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kAssetsManagerEvent:
|
|
||||||
{
|
|
||||||
return handleAssetsManagerEvent(evt->data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kCocoStudioEventListener:
|
|
||||||
{
|
|
||||||
return handleCocoStudioEventListener(evt->data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kArmatureWrapper:
|
|
||||||
{
|
|
||||||
return handleArmatureWrapper(evt->data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kEventListenerAcc:
|
|
||||||
{
|
|
||||||
return handleEventListenerAcc(evt->data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kEventListenerKeyboard:
|
|
||||||
{
|
|
||||||
return handleEventListenerKeyboard(evt->data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kEventListenerTouch:
|
|
||||||
{
|
|
||||||
return handleEventListenerTouch(evt->data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kEventListenerTouches:
|
|
||||||
{
|
|
||||||
return handleEventListenerTouches(evt->data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kEventListenerMouse:
|
|
||||||
{
|
|
||||||
return handleEventListenerMouse(evt->data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kEventListenerCustom:
|
|
||||||
{
|
|
||||||
return handleEventListenerCustom(evt->data);
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -373,28 +317,6 @@ int LuaEngine::handleMenuClickedEvent(void* data)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::handleNotificationEvent(void* data)
|
|
||||||
{
|
|
||||||
if ( NULL == data)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
BasicScriptData* basicScriptData = (BasicScriptData*)(data);
|
|
||||||
if (NULL == basicScriptData->nativeObject ||NULL == basicScriptData->value)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
NotificationCenter* center = static_cast<NotificationCenter*>(basicScriptData->nativeObject);
|
|
||||||
|
|
||||||
int handler = center->getObserverHandlerByName((const char*)basicScriptData->value);
|
|
||||||
|
|
||||||
if (0 == handler)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
_stack->pushString((const char*)basicScriptData->value);
|
|
||||||
int ret = _stack->executeFunctionByHandler(handler, 1);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LuaEngine::handleCallFuncActionEvent(void* data)
|
int LuaEngine::handleCallFuncActionEvent(void* data)
|
||||||
{
|
{
|
||||||
if (NULL == data)
|
if (NULL == data)
|
||||||
|
@ -622,51 +544,6 @@ int LuaEngine::handleTouchesEvent(void* data)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::handleTableViewEvent(void* data)
|
|
||||||
{
|
|
||||||
if (nullptr == data)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
BasicScriptData* eventData = static_cast<BasicScriptData*>(data);
|
|
||||||
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
LuaTableViewEventData* tableViewEventData = static_cast<LuaTableViewEventData*>(eventData->value);
|
|
||||||
if (tableViewEventData->handlerType < ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL || tableViewEventData->handlerType > ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, tableViewEventData->handlerType);
|
|
||||||
|
|
||||||
if (0 == handler)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int ret = 0;
|
|
||||||
switch (tableViewEventData->handlerType)
|
|
||||||
{
|
|
||||||
case ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL:
|
|
||||||
case ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM:
|
|
||||||
{
|
|
||||||
_stack->pushObject(static_cast<Object*>(eventData->nativeObject), "TableView");
|
|
||||||
ret = _stack->executeFunctionByHandler(handler, 1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED:
|
|
||||||
case ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT:
|
|
||||||
case ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT:
|
|
||||||
case ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE:
|
|
||||||
{
|
|
||||||
_stack->pushObject(static_cast<Object*>(eventData->nativeObject), "TableView");
|
|
||||||
_stack->pushObject(static_cast<Object*>(tableViewEventData->value), "TableViewCell");
|
|
||||||
ret = _stack->executeFunctionByHandler(handler, 2);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LuaEngine::handlerControlEvent(void* data)
|
int LuaEngine::handlerControlEvent(void* data)
|
||||||
{
|
{
|
||||||
if ( NULL == data )
|
if ( NULL == data )
|
||||||
|
@ -701,27 +578,269 @@ int LuaEngine::handlerControlEvent(void* data)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::sendEventReturnArray(ScriptEvent* message,int numResults,Array& resultArray)
|
int LuaEngine::handleEventAcc(void* data)
|
||||||
{
|
{
|
||||||
if (nullptr == message || numResults <= 0)
|
if (nullptr == data)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (message->type)
|
BasicScriptData* basicScriptData = static_cast<BasicScriptData*>(data);
|
||||||
|
if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::HandlerType::EVENT_ACC);
|
||||||
|
if (0 == handler)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
lua_State* L = _stack->getLuaState();
|
||||||
|
|
||||||
|
LuaEventAccelerationData* eventListennerAcc = static_cast<LuaEventAccelerationData*>(basicScriptData->value);
|
||||||
|
toluafix_pushusertype_ccobject(L, eventListennerAcc->event->_ID, &(eventListennerAcc->event->_luaID), (void*)(eventListennerAcc->event),"Event");
|
||||||
|
Acceleration* accleration = static_cast<Acceleration*>(eventListennerAcc->acc);
|
||||||
|
lua_pushnumber(L,accleration->x);
|
||||||
|
lua_pushnumber(L,accleration->y);
|
||||||
|
lua_pushnumber(L,accleration->z);
|
||||||
|
lua_pushnumber(L,accleration->timestamp);
|
||||||
|
int ret = _stack->executeFunctionByHandler(handler, 5);
|
||||||
|
_stack->clean();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaEngine::handleEventKeyboard(ScriptHandlerMgr::HandlerType type, void* data)
|
||||||
{
|
{
|
||||||
case kTableViewEvent:
|
if (nullptr == data)
|
||||||
return handleTableViewEventReturnArray(message->data,numResults,resultArray);
|
return 0;
|
||||||
|
|
||||||
|
BasicScriptData* basicScriptData = static_cast<BasicScriptData*>(data);
|
||||||
|
if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
LuaEventKeyboarData* keyboardData = static_cast<LuaEventKeyboarData*>(basicScriptData->value);
|
||||||
|
|
||||||
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, type);
|
||||||
|
if (0 == handler)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
lua_State* L = _stack->getLuaState();
|
||||||
|
lua_pushinteger(L, keyboardData->keyCode);
|
||||||
|
toluafix_pushusertype_ccobject(L, keyboardData->event->_ID, &(keyboardData->event->_luaID), (void*)(keyboardData->event),"Event");
|
||||||
|
int ret = _stack->executeFunctionByHandler(handler, 2);
|
||||||
|
_stack->clean();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaEngine::handleEventTouch(ScriptHandlerMgr::HandlerType type, void* data)
|
||||||
|
{
|
||||||
|
if (nullptr == data)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
BasicScriptData* basicScriptData = static_cast<BasicScriptData*>(data);
|
||||||
|
if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
LuaEventTouchData* touchData = static_cast<LuaEventTouchData*>(basicScriptData->value);
|
||||||
|
if (nullptr == touchData->touch || nullptr == touchData->event)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, type);
|
||||||
|
if (0 == handler)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
Touch* touch = touchData->touch;
|
||||||
|
if (NULL != touch) {
|
||||||
|
_stack->pushObject(touchData->touch, "Touch");
|
||||||
|
_stack->pushObject(touchData->event, "Event");
|
||||||
|
ret = _stack->executeFunctionByHandler(handler, 2);
|
||||||
|
}
|
||||||
|
_stack->clean();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaEngine::handleEventTouches(ScriptHandlerMgr::HandlerType type,void* data)
|
||||||
|
{
|
||||||
|
if (nullptr == data)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
BasicScriptData* basicScriptData = static_cast<BasicScriptData*>(data);
|
||||||
|
if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
LuaEventTouchesData * touchesData = static_cast<LuaEventTouchesData*>(basicScriptData->value);
|
||||||
|
if (nullptr == touchesData->event || touchesData->touches.size() == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)basicScriptData->nativeObject, type);
|
||||||
|
|
||||||
|
if (0 == handler)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
lua_State *L = _stack->getLuaState();
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
lua_newtable(L);
|
||||||
|
int i = 1;
|
||||||
|
for (auto& touch : touchesData->touches)
|
||||||
|
{
|
||||||
|
_stack->pushInt(i);
|
||||||
|
_stack->pushObject(touch, "Touch");
|
||||||
|
lua_rawset(L, -3);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
_stack->pushObject(touchesData->event, "Event");
|
||||||
|
|
||||||
|
ret = _stack->executeFunctionByHandler(handler, 2);
|
||||||
|
_stack->clean();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaEngine::handleEventMouse(ScriptHandlerMgr::HandlerType type, void* data)
|
||||||
|
{
|
||||||
|
if (nullptr == data)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
BasicScriptData* basicScriptData = static_cast<BasicScriptData*>(data);
|
||||||
|
if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
LuaEventMouseData * mouseData = static_cast<LuaEventMouseData*>(basicScriptData->value);
|
||||||
|
if (nullptr == mouseData->event )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)basicScriptData->nativeObject, type);
|
||||||
|
|
||||||
|
if (0 == handler)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
_stack->pushObject(mouseData->event, "Event");
|
||||||
|
int ret = _stack->executeFunctionByHandler(handler, 1);
|
||||||
|
_stack->clean();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaEngine::handleEvenCustom(void* data)
|
||||||
|
{
|
||||||
|
if (nullptr == data)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
BasicScriptData * basicData = static_cast<BasicScriptData*>(data);
|
||||||
|
if (NULL == basicData->nativeObject || nullptr == basicData->value )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
EventCustom* eventCustom = static_cast<EventCustom*>(basicData->value);
|
||||||
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)basicData->nativeObject, ScriptHandlerMgr::HandlerType::EVENT_CUSTIOM);
|
||||||
|
|
||||||
|
if (0 == handler)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
lua_State* L = _stack->getLuaState();
|
||||||
|
toluafix_pushusertype_ccobject(L, eventCustom->_ID, &(eventCustom->_luaID), (void*)(eventCustom),"EventCustom");
|
||||||
|
int ret = _stack->executeFunctionByHandler(handler, 1);
|
||||||
|
_stack->clean();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaEngine::handleEvent(ScriptHandlerMgr::HandlerType type,void* data)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL:
|
||||||
|
case ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM:
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED:
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT:
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT:
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE:
|
||||||
|
{
|
||||||
|
return handleTableViewEvent(type, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS:
|
||||||
|
case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR:
|
||||||
|
case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS:
|
||||||
|
{
|
||||||
|
return handleAssetsManagerEvent(type, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER:
|
||||||
|
{
|
||||||
|
return handleStudioEventListener(type, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::ARMATURE_EVENT:
|
||||||
|
{
|
||||||
|
return handleArmatureWrapper(type, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_ACC:
|
||||||
|
{
|
||||||
|
return handleEventAcc(data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_PRESSED:
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_KEYBOARD_RELEASED:
|
||||||
|
{
|
||||||
|
return handleEventKeyboard(type,data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_CUSTIOM:
|
||||||
|
{
|
||||||
|
return handleEvenCustom(data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_BEGAN:
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_MOVED:
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_ENDED:
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCH_CANCELLED:
|
||||||
|
{
|
||||||
|
return handleEventTouch(type, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_BEGAN:
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_MOVED:
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_ENDED:
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_TOUCHES_CANCELLED:
|
||||||
|
{
|
||||||
|
return handleEventTouches(type, data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_DOWN:
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_UP:
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_MOVE:
|
||||||
|
case ScriptHandlerMgr::HandlerType::EVENT_MOUSE_SCROLL:
|
||||||
|
{
|
||||||
|
return handleEventMouse(type, data);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::handleTableViewEventReturnArray(void* data,int numResults,Array& resultArray)
|
int LuaEngine::handleEvent(ScriptHandlerMgr::HandlerType type, void* data, int numResults, const std::function<void(lua_State*,int)>& func)
|
||||||
{
|
{
|
||||||
if (nullptr == data || numResults <= 0)
|
switch (type)
|
||||||
return 0;
|
{
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX:
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX:
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS:
|
||||||
|
{
|
||||||
|
return handleTableViewEvent(type, data, numResults,func);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data)
|
||||||
|
{
|
||||||
if (nullptr == data)
|
if (nullptr == data)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -729,36 +848,38 @@ int LuaEngine::handleTableViewEventReturnArray(void* data,int numResults,Array&
|
||||||
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
LuaTableViewEventData* tableViewEventData = static_cast<LuaTableViewEventData*>(eventData->value);
|
LuaTableViewEventData* tableViewData = static_cast<LuaTableViewEventData*>(eventData->value);
|
||||||
if (tableViewEventData->handlerType < ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL || tableViewEventData->handlerType > ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS )
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, type);
|
||||||
return 0;
|
|
||||||
|
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, tableViewEventData->handlerType);
|
|
||||||
|
|
||||||
if (0 == handler)
|
if (0 == handler)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Object* obj = static_cast<Object*>(eventData->nativeObject);
|
||||||
|
if (nullptr == obj)
|
||||||
|
return 0;
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
switch (tableViewEventData->handlerType)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX:
|
case ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL:
|
||||||
|
case ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM:
|
||||||
{
|
{
|
||||||
_stack->pushObject(static_cast<Object*>(eventData->nativeObject), "TableView");
|
toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"TableView");
|
||||||
_stack->pushLong(*((long*)tableViewEventData->value));
|
ret = _stack->executeFunctionByHandler(handler, 1);
|
||||||
ret = _stack->executeFunctionReturnArray(handler, 2, 2, resultArray);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX:
|
case ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED:
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT:
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT:
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE:
|
||||||
{
|
{
|
||||||
_stack->pushObject(static_cast<Object*>(eventData->nativeObject), "TableView");
|
Object* cellObject = static_cast<Object*>(tableViewData->value);
|
||||||
_stack->pushLong(*((long*)tableViewEventData->value));
|
if (nullptr == cellObject) {
|
||||||
ret = _stack->executeFunctionReturnArray(handler, 2, 1, resultArray);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS:
|
}
|
||||||
{
|
toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"TableView");
|
||||||
_stack->pushObject(static_cast<Object*>(eventData->nativeObject), "TableView");
|
toluafix_pushusertype_ccobject(_stack->getLuaState(), cellObject->_ID, &(cellObject->_luaID), (void*)(cellObject),"TableViewCell");
|
||||||
ret = _stack->executeFunctionReturnArray(handler, 1, 1, resultArray);
|
ret = _stack->executeFunctionByHandler(handler, 2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -768,7 +889,56 @@ int LuaEngine::handleTableViewEventReturnArray(void* data,int numResults,Array&
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::handleAssetsManagerEvent(void* data)
|
int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType handlerType,void* data, int numResults, const std::function<void(lua_State*,int)>& func)
|
||||||
|
{
|
||||||
|
if (nullptr == data || numResults <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
BasicScriptData* eventData = static_cast<BasicScriptData*>(data);
|
||||||
|
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
LuaTableViewEventData* tableViewData = static_cast<LuaTableViewEventData*>(eventData->value);
|
||||||
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, handlerType);
|
||||||
|
|
||||||
|
if (0 == handler)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
Object* obj = static_cast<Object*>(eventData->nativeObject);
|
||||||
|
if (nullptr == obj)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
switch (handlerType)
|
||||||
|
{
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX:
|
||||||
|
{
|
||||||
|
toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"TableView");
|
||||||
|
_stack->pushLong(*((ssize_t*)tableViewData->value));
|
||||||
|
ret = _stack->executeFunction(handler, 2, 2, func);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX:
|
||||||
|
{
|
||||||
|
toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"TableView");
|
||||||
|
_stack->pushLong(*((ssize_t*)tableViewData->value));
|
||||||
|
ret = _stack->executeFunction(handler, 2, 1, func);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS:
|
||||||
|
{
|
||||||
|
toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"TableView");
|
||||||
|
ret = _stack->executeFunction(handler, 1, 1, func);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaEngine::handleAssetsManagerEvent(ScriptHandlerMgr::HandlerType type,void* data)
|
||||||
{
|
{
|
||||||
if (nullptr == data)
|
if (nullptr == data)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -777,22 +947,20 @@ int LuaEngine::handleAssetsManagerEvent(void* data)
|
||||||
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
LuaAssetsManagerEventData* assetsManagerEventData = static_cast<LuaAssetsManagerEventData*>(eventData->value);
|
LuaAssetsManagerEventData* assetsManagerData = static_cast<LuaAssetsManagerEventData*>(eventData->value);
|
||||||
if (assetsManagerEventData->handlerType < ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS || assetsManagerEventData->handlerType > ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, assetsManagerEventData->handlerType);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, type);
|
||||||
|
|
||||||
if (0 == handler)
|
if (0 == handler)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
switch (assetsManagerEventData->handlerType)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS:
|
case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS:
|
||||||
case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR:
|
case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR:
|
||||||
{
|
{
|
||||||
_stack->pushInt(assetsManagerEventData->value);
|
_stack->pushInt(assetsManagerData->value);
|
||||||
ret = _stack->executeFunctionByHandler(handler, 1);
|
ret = _stack->executeFunctionByHandler(handler, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -810,9 +978,8 @@ int LuaEngine::handleAssetsManagerEvent(void* data)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::handleCocoStudioEventListener(void* data)
|
int LuaEngine::handleStudioEventListener(ScriptHandlerMgr::HandlerType type,void* data)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (nullptr == data)
|
if (nullptr == data)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -820,9 +987,9 @@ int LuaEngine::handleCocoStudioEventListener(void* data)
|
||||||
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
if (nullptr == eventData->nativeObject || nullptr == eventData->value)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
LuaCocoStudioEventListenerData* listenerData = static_cast<LuaCocoStudioEventListenerData*>(eventData->value);
|
LuaStudioEventListenerData* listenerData = static_cast<LuaStudioEventListenerData*>(eventData->value);
|
||||||
|
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER);
|
||||||
|
|
||||||
if (0 == handler)
|
if (0 == handler)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -836,7 +1003,7 @@ int LuaEngine::handleCocoStudioEventListener(void* data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::handleArmatureWrapper(void* data)
|
int LuaEngine::handleArmatureWrapper(ScriptHandlerMgr::HandlerType type,void* data)
|
||||||
{
|
{
|
||||||
if (nullptr == data)
|
if (nullptr == data)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -890,160 +1057,4 @@ int LuaEngine::handleArmatureWrapper(void* data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LuaEngine::handleEventListenerAcc(void* data)
|
|
||||||
{
|
|
||||||
if (nullptr == data)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
BasicScriptData* basicScriptData = static_cast<BasicScriptData*>(data);
|
|
||||||
if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, ScriptHandlerMgr::HandlerType::EVENTLISTENER_ACC);
|
|
||||||
if (0 == handler)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
lua_State* L = _stack->getLuaState();
|
|
||||||
|
|
||||||
LuaEventListenerAccelerationData* eventListennerAcc = static_cast<LuaEventListenerAccelerationData*>(basicScriptData->value);
|
|
||||||
toluafix_pushusertype_ccobject(L, eventListennerAcc->event->_ID, &(eventListennerAcc->event->_luaID), (void*)(eventListennerAcc->event),"Event");
|
|
||||||
Acceleration* accleration = static_cast<Acceleration*>(eventListennerAcc->acc);
|
|
||||||
lua_pushnumber(L,accleration->x);
|
|
||||||
lua_pushnumber(L,accleration->y);
|
|
||||||
lua_pushnumber(L,accleration->z);
|
|
||||||
lua_pushnumber(L,accleration->timestamp);
|
|
||||||
int ret = _stack->executeFunctionByHandler(handler, 5);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LuaEngine::handleEventListenerKeyboard(void* data)
|
|
||||||
{
|
|
||||||
if (nullptr == data)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
BasicScriptData* basicScriptData = static_cast<BasicScriptData*>(data);
|
|
||||||
if (nullptr == basicScriptData->nativeObject || nullptr == basicScriptData->value)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
LuaEventListenerKeyboarData* keyboardData = static_cast<LuaEventListenerKeyboarData*>(basicScriptData->value);
|
|
||||||
|
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(basicScriptData->nativeObject, keyboardData->type);
|
|
||||||
if (0 == handler)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
lua_State* L = _stack->getLuaState();
|
|
||||||
lua_pushinteger(L, keyboardData->keyCode);
|
|
||||||
toluafix_pushusertype_ccobject(L, keyboardData->event->_ID, &(keyboardData->event->_luaID), (void*)(keyboardData->event),"Event");
|
|
||||||
int ret = _stack->executeFunctionByHandler(handler, 2);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LuaEngine::handleEventListenerTouch(void* data)
|
|
||||||
{
|
|
||||||
if (nullptr == data)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
LuaEventListenerTouchData* listenerData = static_cast<LuaEventListenerTouchData*>(data);
|
|
||||||
if (nullptr == listenerData->nativeObject || nullptr == listenerData->touch || nullptr == listenerData->event)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler(listenerData->nativeObject, listenerData->type);
|
|
||||||
if (0 == handler)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
Touch* touch = listenerData->touch;
|
|
||||||
if (NULL != touch) {
|
|
||||||
lua_State* L = _stack->getLuaState();
|
|
||||||
toluafix_pushusertype_ccobject(L, listenerData->touch->_ID, &(listenerData->touch->_luaID), (void*)(listenerData->touch),"Touch");
|
|
||||||
toluafix_pushusertype_ccobject(L, listenerData->event->_ID, &(listenerData->event->_luaID), (void*)(listenerData->event),"Event");
|
|
||||||
ret = _stack->executeFunctionByHandler(handler, 2);
|
|
||||||
}
|
|
||||||
_stack->clean();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LuaEngine::handleEventListenerTouches(void* data)
|
|
||||||
{
|
|
||||||
if (nullptr == data)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
LuaEventListenerTouchesData * listenerData = static_cast<LuaEventListenerTouchesData*>(data);
|
|
||||||
if (NULL == listenerData->nativeObject || nullptr == listenerData->event || listenerData->touches.size() == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)listenerData->nativeObject, listenerData->type);
|
|
||||||
|
|
||||||
if (0 == handler)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
lua_State *L = _stack->getLuaState();
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
lua_newtable(L);
|
|
||||||
int i = 1;
|
|
||||||
for (auto& touch : listenerData->touches)
|
|
||||||
{
|
|
||||||
lua_pushnumber(L, (lua_Number)i);
|
|
||||||
toluafix_pushusertype_ccobject(L, touch->_ID, &(touch->_luaID), (void*)(touch),"Touch");
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
toluafix_pushusertype_ccobject(L, listenerData->event->_ID, &(listenerData->event->_luaID), (void*)(listenerData->event),"Event");
|
|
||||||
|
|
||||||
ret = _stack->executeFunctionByHandler(handler, 2);
|
|
||||||
_stack->clean();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LuaEngine::handleEventListenerMouse(void* data)
|
|
||||||
{
|
|
||||||
if (nullptr == data)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
LuaEventListenerMouseData * listenerData = static_cast<LuaEventListenerMouseData*>(data);
|
|
||||||
if (NULL == listenerData->nativeObject || nullptr == listenerData->event )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)listenerData->nativeObject, listenerData->type);
|
|
||||||
|
|
||||||
if (0 == handler)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
lua_State* L = _stack->getLuaState();
|
|
||||||
toluafix_pushusertype_ccobject(L, listenerData->event->_ID, &(listenerData->event->_luaID), (void*)(listenerData->event),"Event");
|
|
||||||
|
|
||||||
int ret = _stack->executeFunctionByHandler(handler, 1);
|
|
||||||
_stack->clean();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LuaEngine::handleEventListenerCustom(void* data)
|
|
||||||
{
|
|
||||||
if (nullptr == data)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
BasicScriptData * listenerData = static_cast<BasicScriptData*>(data);
|
|
||||||
if (NULL == listenerData->nativeObject || nullptr == listenerData->value )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
EventCustom* eventCustom = static_cast<EventCustom*>(listenerData->value);
|
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)listenerData->nativeObject, ScriptHandlerMgr::HandlerType::EVENTLISTENER_CUSTIOM);
|
|
||||||
|
|
||||||
if (0 == handler)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
lua_State* L = _stack->getLuaState();
|
|
||||||
toluafix_pushusertype_ccobject(L, eventCustom->_ID, &(eventCustom->_luaID), (void*)(eventCustom),"EventCustom");
|
|
||||||
int ret = _stack->executeFunctionByHandler(handler, 1);
|
|
||||||
_stack->clean();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -33,6 +33,7 @@ extern "C" {
|
||||||
#include "CCScriptSupport.h"
|
#include "CCScriptSupport.h"
|
||||||
#include "CCLuaStack.h"
|
#include "CCLuaStack.h"
|
||||||
#include "CCLuaValue.h"
|
#include "CCLuaValue.h"
|
||||||
|
#include "LuaScriptHandlerMgr.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
@ -116,7 +117,8 @@ public:
|
||||||
virtual bool handleAssert(const char *msg);
|
virtual bool handleAssert(const char *msg);
|
||||||
|
|
||||||
virtual int sendEvent(ScriptEvent* message);
|
virtual int sendEvent(ScriptEvent* message);
|
||||||
virtual int sendEventReturnArray(ScriptEvent* message,int numResults,Array& resultArray);
|
virtual int handleEvent(ScriptHandlerMgr::HandlerType type,void* data);
|
||||||
|
virtual int handleEvent(ScriptHandlerMgr::HandlerType type, void* data, int numResults, const std::function<void(lua_State*,int)>& func);
|
||||||
private:
|
private:
|
||||||
LuaEngine(void)
|
LuaEngine(void)
|
||||||
: _stack(NULL)
|
: _stack(NULL)
|
||||||
|
@ -125,7 +127,6 @@ private:
|
||||||
bool init(void);
|
bool init(void);
|
||||||
int handleNodeEvent(void* data);
|
int handleNodeEvent(void* data);
|
||||||
int handleMenuClickedEvent(void* data);
|
int handleMenuClickedEvent(void* data);
|
||||||
int handleNotificationEvent(void* data);
|
|
||||||
int handleCallFuncActionEvent(void* data);
|
int handleCallFuncActionEvent(void* data);
|
||||||
int handleScheduler(void* data);
|
int handleScheduler(void* data);
|
||||||
int handleKeypadEvent(void* data);
|
int handleKeypadEvent(void* data);
|
||||||
|
@ -134,17 +135,18 @@ private:
|
||||||
int handleTouchEvent(void* data);
|
int handleTouchEvent(void* data);
|
||||||
int handleTouchesEvent(void* data);
|
int handleTouchesEvent(void* data);
|
||||||
int handlerControlEvent(void* data);
|
int handlerControlEvent(void* data);
|
||||||
int handleTableViewEvent(void* data);
|
int handleEvenCustom(void* data);
|
||||||
int handleTableViewEventReturnArray(void* data,int numResults,Array& resultArray);
|
int handleAssetsManagerEvent(ScriptHandlerMgr::HandlerType type,void* data);
|
||||||
int handleAssetsManagerEvent(void* data);
|
int handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data);
|
||||||
int handleCocoStudioEventListener(void* data);
|
int handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data, int numResults, const std::function<void(lua_State*,int)>& func);
|
||||||
int handleArmatureWrapper(void* data);
|
int handleStudioEventListener(ScriptHandlerMgr::HandlerType type,void* data);
|
||||||
int handleEventListenerAcc(void* data);
|
int handleArmatureWrapper(ScriptHandlerMgr::HandlerType type,void* data);
|
||||||
int handleEventListenerKeyboard(void* data);
|
int handleEventAcc(void* data);
|
||||||
int handleEventListenerTouch(void* data);
|
int handleEventKeyboard(ScriptHandlerMgr::HandlerType type,void* data);
|
||||||
int handleEventListenerTouches(void* data);
|
int handleEventTouch(ScriptHandlerMgr::HandlerType type, void* data);
|
||||||
int handleEventListenerMouse(void* data);
|
int handleEventTouches(ScriptHandlerMgr::HandlerType type, void* data);
|
||||||
int handleEventListenerCustom(void* data);
|
int handleEventMouse(ScriptHandlerMgr::HandlerType type, void* data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static LuaEngine* _defaultEngine;
|
static LuaEngine* _defaultEngine;
|
||||||
LuaStack *_stack;
|
LuaStack *_stack;
|
||||||
|
|
|
@ -577,4 +577,83 @@ int LuaStack::executeFunctionReturnArray(int handler,int numArgs,int numResults,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LuaStack::executeFunction(int handler, int numArgs, int numResults, const std::function<void(lua_State*,int)>& func)
|
||||||
|
{
|
||||||
|
if (pushFunctionByHandler(handler)) /* L: ... arg1 arg2 ... func */
|
||||||
|
{
|
||||||
|
if (numArgs > 0)
|
||||||
|
{
|
||||||
|
lua_insert(_state, -(numArgs + 1)); /* L: ... func arg1 arg2 ... */
|
||||||
|
}
|
||||||
|
|
||||||
|
int functionIndex = -(numArgs + 1);
|
||||||
|
|
||||||
|
if (!lua_isfunction(_state, functionIndex))
|
||||||
|
{
|
||||||
|
CCLOG("value at stack [%d] is not function", functionIndex);
|
||||||
|
lua_pop(_state, numArgs + 1); // remove function and arguments
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int traceCallback = 0;
|
||||||
|
lua_getglobal(_state, "__G__TRACKBACK__"); /* L: ... func arg1 arg2 ... G */
|
||||||
|
if (!lua_isfunction(_state, -1))
|
||||||
|
{
|
||||||
|
lua_pop(_state, 1); /* L: ... func arg1 arg2 ... */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lua_insert(_state, functionIndex - 1); /* L: ... G func arg1 arg2 ... */
|
||||||
|
traceCallback = functionIndex - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int error = 0;
|
||||||
|
++_callFromLua;
|
||||||
|
error = lua_pcall(_state, numArgs, numResults, traceCallback); /* L: ... [G] ret1 ret2 ... retResults*/
|
||||||
|
--_callFromLua;
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
if (traceCallback == 0)
|
||||||
|
{
|
||||||
|
CCLOG("[LUA ERROR] %s", lua_tostring(_state, - 1)); /* L: ... error */
|
||||||
|
lua_pop(_state, 1); // remove error message from stack
|
||||||
|
}
|
||||||
|
else /* L: ... G error */
|
||||||
|
{
|
||||||
|
lua_pop(_state, 2); // remove __G__TRACKBACK__ and error message from stack
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get return value,don't pass LUA_MULTRET to numResults,
|
||||||
|
if (numResults <= 0)
|
||||||
|
{
|
||||||
|
if (traceCallback)
|
||||||
|
lua_pop(_state, 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nullptr == func)
|
||||||
|
{
|
||||||
|
if (traceCallback)
|
||||||
|
lua_pop(_state, 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
func(_state,numResults);
|
||||||
|
|
||||||
|
if (traceCallback)
|
||||||
|
{
|
||||||
|
lua_pop(_state, 1); // remove __G__TRACKBACK__ from stack /* L: ... */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_settop(_state, 0);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -116,6 +116,7 @@ public:
|
||||||
|
|
||||||
virtual int executeFunctionByHandler(int nHandler, int numArgs);
|
virtual int executeFunctionByHandler(int nHandler, int numArgs);
|
||||||
virtual int executeFunctionReturnArray(int handler,int numArgs,int numResults,Array& resultArray);
|
virtual int executeFunctionReturnArray(int handler,int numArgs,int numResults,Array& resultArray);
|
||||||
|
virtual int executeFunction(int handler, int numArgs, int numResults, const std::function<void(lua_State*,int)>& func);
|
||||||
|
|
||||||
virtual bool handleAssert(const char *msg);
|
virtual bool handleAssert(const char *msg);
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ void ScriptHandlerMgr::removeObjectHandler(void* object,ScriptHandlerMgr::Handle
|
||||||
|
|
||||||
auto iterVec = iterMap->second.begin();
|
auto iterVec = iterMap->second.begin();
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
for (; iterVec != iterMap->second.end(); iterVec++)
|
for (; iterVec != iterMap->second.end(); ++iterVec)
|
||||||
{
|
{
|
||||||
if (iterVec->first == handlerType)
|
if (iterVec->first == handlerType)
|
||||||
{
|
{
|
||||||
|
@ -172,6 +172,7 @@ void ScriptHandlerMgr::removeObjectHandler(void* object,ScriptHandlerMgr::Handle
|
||||||
|
|
||||||
if (exist)
|
if (exist)
|
||||||
{
|
{
|
||||||
|
LuaEngine::getInstance()->removeScriptHandler(iterVec->second);
|
||||||
iterMap->second.erase(iterVec);
|
iterMap->second.erase(iterVec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +207,15 @@ void ScriptHandlerMgr::removeObjectAllHandlers(void* object)
|
||||||
|
|
||||||
if (_mapObjectHandlers.end() != iter)
|
if (_mapObjectHandlers.end() != iter)
|
||||||
{
|
{
|
||||||
|
if (!iter->second.empty())
|
||||||
|
{
|
||||||
|
auto iterVec = iter->second.begin();
|
||||||
|
for (; iterVec != iter->second.end(); ++iterVec)
|
||||||
|
{
|
||||||
|
LuaEngine::getInstance()->removeScriptHandler(iterVec->second);
|
||||||
|
}
|
||||||
(iter->second).clear();
|
(iter->second).clear();
|
||||||
|
}
|
||||||
_mapObjectHandlers.erase(iter);
|
_mapObjectHandlers.erase(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,6 @@ public:
|
||||||
{
|
{
|
||||||
NODE = 0,
|
NODE = 0,
|
||||||
MENU_CLICKED,
|
MENU_CLICKED,
|
||||||
NOTIFICATION,
|
|
||||||
CALLFUNC,
|
CALLFUNC,
|
||||||
SCHEDULE,
|
SCHEDULE,
|
||||||
TOUCHES,
|
TOUCHES,
|
||||||
|
@ -108,26 +107,31 @@ public:
|
||||||
ASSETSMANAGER_SUCCESS,
|
ASSETSMANAGER_SUCCESS,
|
||||||
ASSETSMANAGER_ERROR,
|
ASSETSMANAGER_ERROR,
|
||||||
|
|
||||||
EVENT_LISTENER,
|
STUDIO_EVENT_LISTENER,
|
||||||
ARMATURE_EVENT,
|
ARMATURE_EVENT,
|
||||||
|
|
||||||
EVENTLISTENER_ACC,
|
EVENT_ACC,
|
||||||
EVENTLISTENER_CUSTIOM,
|
EVENT_CUSTIOM,
|
||||||
|
|
||||||
EVENTLISTENER_KEYBOARD_PRESSED,
|
EVENT_KEYBOARD_PRESSED,
|
||||||
EVENTLISTENER_KEYBOARD_RELEASE,
|
EVENT_KEYBOARD_RELEASED,
|
||||||
|
|
||||||
EVENTLISTENER_TOUCH_BEGAN,
|
EVENT_TOUCH_BEGAN,
|
||||||
EVENTLISTENER_TOUCH_MOVED,
|
EVENT_TOUCH_MOVED,
|
||||||
EVENTLISTENER_TOUCH_ENDED,
|
EVENT_TOUCH_ENDED,
|
||||||
EVENTLISTENER_TOUCH_CANCELLED,
|
EVENT_TOUCH_CANCELLED,
|
||||||
|
|
||||||
EVENTLISTENER_MOUSE_DOWN,
|
EVENT_TOUCHES_BEGAN,
|
||||||
EVENTLISTENER_MOUSE_UP,
|
EVENT_TOUCHES_MOVED,
|
||||||
EVENTLISTENER_MOUSE_MOVE,
|
EVENT_TOUCHES_ENDED,
|
||||||
EVENTLISTENER_MOUSE_SCROLL,
|
EVENT_TOUCHES_CANCELLED,
|
||||||
|
|
||||||
SPINE_EVENT,
|
EVENT_MOUSE_DOWN,
|
||||||
|
EVENT_MOUSE_UP,
|
||||||
|
EVENT_MOUSE_MOVE,
|
||||||
|
EVENT_MOUSE_SCROLL,
|
||||||
|
|
||||||
|
EVENT_SPINE,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int Handler;
|
typedef int Handler;
|
||||||
|
|
|
@ -98,7 +98,7 @@ LuaSkeletonAnimation* LuaSkeletonAnimation::createWithFile (const char* skeleton
|
||||||
|
|
||||||
void LuaSkeletonAnimation::animationStateEvent (spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount)
|
void LuaSkeletonAnimation::animationStateEvent (spine::SkeletonAnimation* node, int trackIndex, spEventType type, spEvent* event, int loopCount)
|
||||||
{
|
{
|
||||||
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::SPINE_EVENT);
|
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::EVENT_SPINE);
|
||||||
if (0 != nHandler) {
|
if (0 != nHandler) {
|
||||||
SendSpineEventToLua(nHandler, node, trackIndex, type, event, loopCount);
|
SendSpineEventToLua(nHandler, node, trackIndex, type, event, loopCount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ extern "C" {
|
||||||
#include "CCLuaValue.h"
|
#include "CCLuaValue.h"
|
||||||
#include "CocosGUI.h"
|
#include "CocosGUI.h"
|
||||||
#include "CocoStudio.h"
|
#include "CocoStudio.h"
|
||||||
|
#include "CCLuaEngine.h"
|
||||||
|
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
using namespace cocostudio;
|
using namespace cocostudio;
|
||||||
|
@ -52,14 +53,13 @@ LuaCocoStudioEventListener* LuaCocoStudioEventListener::create()
|
||||||
|
|
||||||
void LuaCocoStudioEventListener::eventCallbackFunc(Object* sender,int eventType)
|
void LuaCocoStudioEventListener::eventCallbackFunc(Object* sender,int eventType)
|
||||||
{
|
{
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER);
|
||||||
|
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
LuaCocoStudioEventListenerData eventData(sender,eventType);
|
LuaStudioEventListenerData eventData(sender,eventType);
|
||||||
BasicScriptData data(this,(void*)&eventData);
|
BasicScriptData data(this,(void*)&eventData);
|
||||||
ScriptEvent scriptEvent(kCocoStudioEventListener,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER, (void*)&data);
|
||||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ static int lua_cocos2dx_Widget_addTouchEventListener(lua_State* L)
|
||||||
|
|
||||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||||
|
|
||||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER);
|
||||||
|
|
||||||
self->setUserObject(listener);
|
self->setUserObject(listener);
|
||||||
self->addTouchEventListener(listener, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
self->addTouchEventListener(listener, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||||
|
@ -172,7 +172,7 @@ static int lua_cocos2dx_CheckBox_addEventListenerCheckBox(lua_State* L)
|
||||||
|
|
||||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||||
|
|
||||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER);
|
||||||
|
|
||||||
self->setUserObject(listener);
|
self->setUserObject(listener);
|
||||||
self->addEventListenerCheckBox(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
self->addEventListenerCheckBox(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||||
|
@ -241,7 +241,7 @@ static int lua_cocos2dx_Slider_addEventListenerSlider(lua_State* L)
|
||||||
|
|
||||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||||
|
|
||||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER);
|
||||||
|
|
||||||
self->setUserObject(listener);
|
self->setUserObject(listener);
|
||||||
self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||||
|
@ -310,7 +310,7 @@ static int lua_cocos2dx_TextField_addEventListenerTextField(lua_State* L)
|
||||||
|
|
||||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||||
|
|
||||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER);
|
||||||
|
|
||||||
self->setUserObject(listener);
|
self->setUserObject(listener);
|
||||||
self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||||
|
@ -379,7 +379,7 @@ static int lua_cocos2dx_PageView_addEventListenerPageView(lua_State* L)
|
||||||
|
|
||||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||||
|
|
||||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER);
|
||||||
|
|
||||||
self->setUserObject(listener);
|
self->setUserObject(listener);
|
||||||
self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||||
|
@ -448,7 +448,7 @@ static int lua_cocos2dx_ListView_addEventListenerListView(lua_State* L)
|
||||||
|
|
||||||
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
|
||||||
|
|
||||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::EVENT_LISTENER);
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER);
|
||||||
|
|
||||||
self->setUserObject(listern);
|
self->setUserObject(listern);
|
||||||
self->addEventListenerListView(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
self->addEventListenerListView(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc));
|
||||||
|
@ -651,9 +651,7 @@ void LuaArmatureWrapper::movementEventCallback(Armature* armature, MovementEvent
|
||||||
|
|
||||||
BasicScriptData data(this,(void*)&wrapperData);
|
BasicScriptData data(this,(void*)&wrapperData);
|
||||||
|
|
||||||
ScriptEvent scriptEvent(kArmatureWrapper,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data);
|
||||||
|
|
||||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,9 +669,7 @@ void LuaArmatureWrapper::frameEventCallback(Bone* bone, const char* frameEventNa
|
||||||
|
|
||||||
BasicScriptData data(this,(void*)&wrapperData);
|
BasicScriptData data(this,(void*)&wrapperData);
|
||||||
|
|
||||||
ScriptEvent scriptEvent(kArmatureWrapper,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data);
|
||||||
|
|
||||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,9 +683,7 @@ void LuaArmatureWrapper::addArmatureFileInfoAsyncCallback(float percent)
|
||||||
|
|
||||||
BasicScriptData data(this,(void*)&wrapperData);
|
BasicScriptData data(this,(void*)&wrapperData);
|
||||||
|
|
||||||
ScriptEvent scriptEvent(kArmatureWrapper,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data);
|
||||||
|
|
||||||
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,12 @@ extern "C" {
|
||||||
|
|
||||||
TOLUA_API int register_all_cocos2dx_coco_studio_manual(lua_State* L);
|
TOLUA_API int register_all_cocos2dx_coco_studio_manual(lua_State* L);
|
||||||
|
|
||||||
struct LuaCocoStudioEventListenerData
|
struct LuaStudioEventListenerData
|
||||||
{
|
{
|
||||||
cocos2d::Object* objTarget;
|
cocos2d::Object* objTarget;
|
||||||
int eventType;
|
int eventType;
|
||||||
|
|
||||||
LuaCocoStudioEventListenerData(cocos2d::Object* _objTarget, int _eventType):objTarget(_objTarget),eventType(_eventType)
|
LuaStudioEventListenerData(cocos2d::Object* _objTarget, int _eventType):objTarget(_objTarget),eventType(_eventType)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -877,10 +877,9 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
LuaTableViewEventData eventData(ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL);
|
LuaTableViewEventData eventData;
|
||||||
BasicScriptData data(view,&eventData);
|
BasicScriptData data(view,&eventData);
|
||||||
ScriptEvent event(kTableViewEvent,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL, (void*)&data);
|
||||||
LuaEngine::getInstance()->sendEvent(&event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -892,10 +891,9 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
LuaTableViewEventData eventData(ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM);
|
LuaTableViewEventData eventData;
|
||||||
BasicScriptData data(view,&eventData);
|
BasicScriptData data(view,&eventData);
|
||||||
ScriptEvent event(kTableViewEvent,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM, (void*)&data);
|
||||||
LuaEngine::getInstance()->sendEvent(&event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -907,10 +905,9 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
LuaTableViewEventData eventData(ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED,cell);
|
LuaTableViewEventData eventData(cell);
|
||||||
BasicScriptData data(table,&eventData);
|
BasicScriptData data(table,&eventData);
|
||||||
ScriptEvent event(kTableViewEvent,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED,(void*)&data);
|
||||||
LuaEngine::getInstance()->sendEvent(&event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -922,10 +919,9 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
LuaTableViewEventData eventData(ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT,cell);
|
LuaTableViewEventData eventData(cell);
|
||||||
BasicScriptData data(table,&eventData);
|
BasicScriptData data(table,&eventData);
|
||||||
ScriptEvent event(kTableViewEvent,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT,(void*)&data);
|
||||||
LuaEngine::getInstance()->sendEvent(&event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -937,10 +933,9 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
LuaTableViewEventData eventData(ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT,cell);
|
LuaTableViewEventData eventData(cell);
|
||||||
BasicScriptData data(table,&eventData);
|
BasicScriptData data(table,&eventData);
|
||||||
ScriptEvent event(kTableViewEvent,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT,(void*)&data);
|
||||||
LuaEngine::getInstance()->sendEvent(&event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -952,10 +947,9 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
LuaTableViewEventData eventData(ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE,cell);
|
LuaTableViewEventData eventData(cell);
|
||||||
BasicScriptData data(table,&eventData);
|
BasicScriptData data(table,&eventData);
|
||||||
ScriptEvent event(kTableViewEvent,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE,(void*)&data);
|
||||||
LuaEngine::getInstance()->sendEvent(&event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1033,19 +1027,20 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
Array resultArray;
|
LuaTableViewEventData eventData(&idx);
|
||||||
resultArray.initWithCapacity(1);
|
|
||||||
LuaTableViewEventData eventData(ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX,&idx);
|
|
||||||
BasicScriptData data(table,&eventData);
|
BasicScriptData data(table,&eventData);
|
||||||
ScriptEvent event(kTableViewEvent,(void*)&data);
|
float width = 0.0;
|
||||||
LuaEngine::getInstance()->sendEventReturnArray(&event, 2, resultArray);
|
float height = 0.0;
|
||||||
CCASSERT(resultArray.count() == 2, "tableCellSizeForIndex Array count error");
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX, (void*)&data,2,[&](lua_State* L,int numReturn){
|
||||||
Double* width = dynamic_cast<Double*>(resultArray.getObjectAtIndex(0));
|
CCASSERT(numReturn == 2, "tableCellSizeForIndex return count error");
|
||||||
Double* height = dynamic_cast<Double*>(resultArray.getObjectAtIndex(1));
|
ValueVector vec;
|
||||||
if (nullptr != width && nullptr != height)
|
width = (float)tolua_tonumber(L, -1, 0);
|
||||||
{
|
lua_pop(L, 1);
|
||||||
return Size((float)width->getValue(), (float)height->getValue());
|
height = (float)tolua_tonumber(L, -1, 0);
|
||||||
}
|
lua_pop(L, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Size(width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,17 +1054,14 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
Array resultArray;
|
LuaTableViewEventData eventData(&idx);
|
||||||
resultArray.initWithCapacity(1);
|
|
||||||
LuaTableViewEventData eventData(ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX,&idx);
|
|
||||||
BasicScriptData data(table,&eventData);
|
BasicScriptData data(table,&eventData);
|
||||||
ScriptEvent event(kTableViewEvent,(void*)&data);
|
|
||||||
LuaEngine::getInstance()->sendEventReturnArray(&event, 1, resultArray);
|
|
||||||
TableViewCell* viewCell = nullptr;
|
TableViewCell* viewCell = nullptr;
|
||||||
if (resultArray.count() > 0)
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX, (void*)&data, 1, [&](lua_State* L, int numReturn){
|
||||||
{
|
CCASSERT(numReturn == 1, "tableCellAtIndex return count error");
|
||||||
viewCell = dynamic_cast<TableViewCell*>(resultArray.getObjectAtIndex(0));
|
viewCell = static_cast<TableViewCell*>(tolua_tousertype(L, -1, nullptr));
|
||||||
}
|
lua_pop(L, 1);
|
||||||
|
});
|
||||||
|
|
||||||
return viewCell;
|
return viewCell;
|
||||||
}
|
}
|
||||||
|
@ -1085,17 +1077,15 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
Array resultArray;
|
LuaTableViewEventData eventData;
|
||||||
resultArray.initWithCapacity(1);
|
|
||||||
LuaTableViewEventData eventData(ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS);
|
|
||||||
BasicScriptData data(table,&eventData);
|
BasicScriptData data(table,&eventData);
|
||||||
ScriptEvent event(kTableViewEvent,(void*)&data);
|
ssize_t counts = 0;
|
||||||
LuaEngine::getInstance()->sendEventReturnArray(&event, 1, resultArray);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS, (void*)&data,1, [&](lua_State* L, int numReturn){
|
||||||
Double* numbers = dynamic_cast<Double*>(resultArray.getObjectAtIndex(0));
|
CCASSERT(numReturn == 1, "numberOfCellsInTableView return count error");
|
||||||
if (NULL != numbers)
|
counts = (ssize_t)tolua_tonumber(L, -1, 0);
|
||||||
{
|
lua_pop(L, 1);
|
||||||
return (ssize_t)numbers->getValue();
|
});
|
||||||
}
|
return counts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1444,10 +1434,9 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
LuaAssetsManagerEventData eventData(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS,percent);
|
LuaAssetsManagerEventData eventData(percent);
|
||||||
BasicScriptData data((void*)this,&eventData);
|
BasicScriptData data((void*)this,&eventData);
|
||||||
ScriptEvent event(kAssetsManagerEvent,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS, (void*)&data);
|
||||||
LuaEngine::getInstance()->sendEvent(&event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1456,10 +1445,9 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
LuaAssetsManagerEventData eventData(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS);
|
LuaAssetsManagerEventData eventData;
|
||||||
BasicScriptData data((void*)this,&eventData);
|
BasicScriptData data((void*)this,&eventData);
|
||||||
ScriptEvent event(kAssetsManagerEvent,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS, (void*)&data);
|
||||||
LuaEngine::getInstance()->sendEvent(&event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,10 +1456,9 @@ public:
|
||||||
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR);
|
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR);
|
||||||
if (0 != handler)
|
if (0 != handler)
|
||||||
{
|
{
|
||||||
LuaAssetsManagerEventData eventData(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR, (int)errorCode);
|
LuaAssetsManagerEventData eventData((int)errorCode);
|
||||||
BasicScriptData data((void*)this,&eventData);
|
BasicScriptData data((void*)this,&eventData);
|
||||||
ScriptEvent event(kAssetsManagerEvent,(void*)&data);
|
LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR, (void*)&data);
|
||||||
LuaEngine::getInstance()->sendEvent(&event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,22 +16,20 @@ TOLUA_API int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S);
|
||||||
|
|
||||||
struct LuaTableViewEventData
|
struct LuaTableViewEventData
|
||||||
{
|
{
|
||||||
cocos2d::ScriptHandlerMgr::HandlerType handlerType;
|
|
||||||
void* value;
|
void* value;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
LuaTableViewEventData(cocos2d::ScriptHandlerMgr::HandlerType _handleType,void* _value = nullptr)
|
LuaTableViewEventData(void* _value = nullptr)
|
||||||
: handlerType(_handleType),value(_value)
|
:value(_value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LuaAssetsManagerEventData
|
struct LuaAssetsManagerEventData
|
||||||
{
|
{
|
||||||
cocos2d::ScriptHandlerMgr::HandlerType handlerType;
|
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
LuaAssetsManagerEventData(cocos2d::ScriptHandlerMgr::HandlerType _handleType, int _value = 0):handlerType(_handleType),value(_value)
|
LuaAssetsManagerEventData(int _value = 0):value(_value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
85709d90033c30cb048f5ba371a8e0028ec3f9e4
|
91928b80f0e66732d837b163cd32fd7613369715
|
|
@ -32,76 +32,58 @@ TOLUA_API int register_all_cocos2dx_manual(lua_State* tolua_S);
|
||||||
|
|
||||||
TOLUA_API int register_cocos2dx_event_releated(lua_State* tolua_S);
|
TOLUA_API int register_cocos2dx_event_releated(lua_State* tolua_S);
|
||||||
|
|
||||||
struct LuaEventListenerAccelerationData
|
struct LuaEventAccelerationData
|
||||||
{
|
{
|
||||||
void* acc;
|
void* acc;
|
||||||
Event* event;
|
Event* event;
|
||||||
|
|
||||||
LuaEventListenerAccelerationData(void* inAcc,Event* inEvent)
|
LuaEventAccelerationData(void* inAcc,Event* inEvent)
|
||||||
:acc(inAcc),event(inEvent)
|
:acc(inAcc),event(inEvent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LuaEventListenerKeyboarData
|
struct LuaEventKeyboarData
|
||||||
{
|
{
|
||||||
enum class KeyboardStatus :int
|
|
||||||
{
|
|
||||||
PRESSED = 0,
|
|
||||||
RELEASE,
|
|
||||||
};
|
|
||||||
int keyCode;
|
int keyCode;
|
||||||
Event* event;
|
Event* event;
|
||||||
ScriptHandlerMgr::HandlerType type;
|
|
||||||
|
|
||||||
LuaEventListenerKeyboarData(int inKeyCode,Event* inEvent,ScriptHandlerMgr::HandlerType inType)
|
LuaEventKeyboarData(int inKeyCode,Event* inEvent)
|
||||||
:keyCode(inKeyCode),event(inEvent),type(inType)
|
:keyCode(inKeyCode),event(inEvent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LuaEventListenerTouchData
|
struct LuaEventTouchData
|
||||||
{
|
{
|
||||||
ScriptHandlerMgr::HandlerType type;
|
|
||||||
void* nativeObject;
|
|
||||||
Touch* touch;
|
Touch* touch;
|
||||||
Event* event;
|
Event* event;
|
||||||
|
|
||||||
LuaEventListenerTouchData(ScriptHandlerMgr::HandlerType inType, void* inNativeObject, Touch* inTouch, Event* inEvent)
|
LuaEventTouchData(Touch* inTouch, Event* inEvent)
|
||||||
: type(inType),
|
:touch(inTouch),
|
||||||
nativeObject(inNativeObject),
|
|
||||||
touch(inTouch),
|
|
||||||
event(inEvent)
|
event(inEvent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LuaEventListenerTouchesData
|
struct LuaEventTouchesData
|
||||||
{
|
{
|
||||||
ScriptHandlerMgr::HandlerType type;
|
|
||||||
void* nativeObject;
|
|
||||||
std::vector<Touch*> touches;
|
std::vector<Touch*> touches;
|
||||||
Event* event;
|
Event* event;
|
||||||
|
|
||||||
LuaEventListenerTouchesData(ScriptHandlerMgr::HandlerType inType, void* inNativeObject, std::vector<Touch*> inTouches, Event* inEvent)
|
LuaEventTouchesData(std::vector<Touch*> inTouches, Event* inEvent)
|
||||||
: type(inType),
|
:touches(inTouches),
|
||||||
nativeObject(inNativeObject),
|
|
||||||
touches(inTouches),
|
|
||||||
event(inEvent)
|
event(inEvent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LuaEventListenerMouseData
|
struct LuaEventMouseData
|
||||||
{
|
{
|
||||||
ScriptHandlerMgr::HandlerType type;
|
|
||||||
void* nativeObject;
|
|
||||||
Event* event;
|
Event* event;
|
||||||
|
|
||||||
LuaEventListenerMouseData(ScriptHandlerMgr::HandlerType inType, void* inNativeObject, Event* inEvent)
|
LuaEventMouseData(Event* inEvent)
|
||||||
: type(inType),
|
:event(inEvent)
|
||||||
nativeObject(inNativeObject),
|
|
||||||
event(inEvent)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -141,7 +141,7 @@ int tolua_Cocos2d_CCSkeletonAnimation_registerScriptHandler00(lua_State* tolua_S
|
||||||
LuaSkeletonAnimation* self = (LuaSkeletonAnimation*) tolua_tousertype(tolua_S,1,0);
|
LuaSkeletonAnimation* self = (LuaSkeletonAnimation*) tolua_tousertype(tolua_S,1,0);
|
||||||
if (NULL != self ) {
|
if (NULL != self ) {
|
||||||
int handler = ( toluafix_ref_function(tolua_S,2,0));
|
int handler = ( toluafix_ref_function(tolua_S,2,0));
|
||||||
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::SPINE_EVENT);
|
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::HandlerType::EVENT_SPINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -166,7 +166,7 @@ int tolua_Cocos2d_CCSkeletonAnimation_unregisterScriptHandler00(lua_State* tolua
|
||||||
{
|
{
|
||||||
LuaSkeletonAnimation* self = (LuaSkeletonAnimation*) tolua_tousertype(tolua_S,1,0);
|
LuaSkeletonAnimation* self = (LuaSkeletonAnimation*) tolua_tousertype(tolua_S,1,0);
|
||||||
if (NULL != self ) {
|
if (NULL != self ) {
|
||||||
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::HandlerType::SPINE_EVENT);
|
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, ScriptHandlerMgr::HandlerType::EVENT_SPINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -289,78 +289,66 @@ cc.ASSETSMANAGER_PROTOCOL_PROGRESS = 0
|
||||||
cc.ASSETSMANAGER_PROTOCOL_SUCCESS = 1
|
cc.ASSETSMANAGER_PROTOCOL_SUCCESS = 1
|
||||||
cc.ASSETSMANAGER_PROTOCOL_ERROR = 2
|
cc.ASSETSMANAGER_PROTOCOL_ERROR = 2
|
||||||
|
|
||||||
cc.HANDLERTYPE_NODE = 0
|
cc.Handler = cc.Handler or {}
|
||||||
cc.HANDLERTYPE_MENU_CLICKED = 1
|
cc.Handler.NODE = 0
|
||||||
cc.HANDLERTYPE_NOTIFICATION = 2
|
cc.Handler.MENU_CLICKED = 1
|
||||||
cc.HANDLERTYPE_CALLFUNC = 3
|
cc.Handler.CALLFUNC = 2
|
||||||
cc.HANDLERTYPE_SCHEDULE = 4
|
cc.Handler.SCHEDULE = 3
|
||||||
cc.HANDLERTYPE_TOUCHES = 5
|
cc.Handler.TOUCHES = 4
|
||||||
cc.HANDLERTYPE_KEYPAD = 6
|
cc.Handler.KEYPAD = 5
|
||||||
cc.HANDLERTYPE_ACCELEROMETER = 7
|
cc.Handler.ACCELEROMETER = 6
|
||||||
cc.HANDLERTYPE_CONTROL_TOUCH_DOWN = 8
|
cc.Handler.CONTROL_TOUCH_DOWN = 7
|
||||||
cc.HANDLERTYPE_CONTROL_TOUCH_DRAG_INSIDE = 9
|
cc.Handler.CONTROL_TOUCH_DRAG_INSIDE = 8
|
||||||
cc.HANDLERTYPE_CONTROL_TOUCH_DRAG_OUTSIDE = 10
|
cc.Handler.CONTROL_TOUCH_DRAG_OUTSIDE = 9
|
||||||
cc.HANDLERTYPE_CONTROL_TOUCH_DRAG_ENTER = 11
|
cc.Handler.CONTROL_TOUCH_DRAG_ENTER = 10
|
||||||
cc.HANDLERTYPE_CONTROL_TOUCH_DRAG_EXIT = 12
|
cc.Handler.CONTROL_TOUCH_DRAG_EXIT = 11
|
||||||
cc.HANDLERTYPE_CONTROL_TOUCH_UP_INSIDE = 13
|
cc.Handler.CONTROL_TOUCH_UP_INSIDE = 12
|
||||||
cc.HANDLERTYPE_CONTROL_TOUCH_UP_OUTSIDE = 14
|
cc.Handler.CONTROL_TOUCH_UP_OUTSIDE = 13
|
||||||
cc.HANDLERTYPE_CONTROL_TOUCH_UP_CANCEL = 15
|
cc.Handler.CONTROL_TOUCH_UP_CANCEL = 14
|
||||||
cc.HANDLERTYPE_CONTROL_VALUE_CHANGED = 16
|
cc.Handler.CONTROL_VALUE_CHANGED = 15
|
||||||
cc.HANDLERTYPE_WEBSOCKET_OPEN = 17
|
cc.Handler.WEBSOCKET_OPEN = 16
|
||||||
cc.HANDLERTYPE_WEBSOCKET_MESSAGE = 18
|
cc.Handler.WEBSOCKET_MESSAGE = 17
|
||||||
cc.HANDLERTYPE_WEBSOCKET_CLOSE = 19
|
cc.Handler.WEBSOCKET_CLOSE = 18
|
||||||
cc.HANDLERTYPE_WEBSOCKET_ERROR = 20
|
cc.Handler.WEBSOCKET_ERROR = 19
|
||||||
cc.HANDLERTYPE_GL_NODE_DRAW = 21
|
cc.Handler.GL_NODE_DRAW = 20
|
||||||
cc.HANDLERTYPE_SCROLLVIEW_SCROLL = 22
|
cc.Handler.SCROLLVIEW_SCROLL = 21
|
||||||
cc.HANDLERTYPE_SCROLLVIEW_ZOOM = 23
|
cc.Handler.SCROLLVIEW_ZOOM = 22
|
||||||
cc.HANDLERTYPE_TABLECELL_TOUCHED = 24
|
cc.Handler.TABLECELL_TOUCHED = 23
|
||||||
cc.HANDLERTYPE_TABLECELL_HIGHLIGHT = 25
|
cc.Handler.TABLECELL_HIGHLIGHT = 24
|
||||||
cc.HANDLERTYPE_TABLECELL_UNHIGHLIGHT = 26
|
cc.Handler.TABLECELL_UNHIGHLIGHT = 25
|
||||||
cc.HANDLERTYPE_TABLECELL_WILL_RECYCLE = 27
|
cc.Handler.TABLECELL_WILL_RECYCLE = 26
|
||||||
cc.HANDLERTYPE_TABLECELL_SIZE_FOR_INDEX = 28
|
cc.Handler.TABLECELL_SIZE_FOR_INDEX = 27
|
||||||
cc.HANDLERTYPE_TABLECELL_AT_INDEX = 29
|
cc.Handler.TABLECELL_AT_INDEX = 28
|
||||||
cc.HANDLERTYPE_TABLEVIEW_NUMS_OF_CELLS = 30
|
cc.Handler.TABLEVIEW_NUMS_OF_CELLS = 29
|
||||||
cc.HANDLERTYPE_XMLHTTPREQUEST_READY_STATE_CHANGE = 31
|
cc.Handler.HTTPREQUEST_STATE_CHANGE = 30
|
||||||
cc.HANDLERTYPE_ASSETSMANAGER_PROGRESS = 32
|
cc.Handler.ASSETSMANAGER_PROGRESS = 31
|
||||||
cc.HANDLERTYPE_ASSETSMANAGER_SUCCESS = 33
|
cc.Handler.ASSETSMANAGER_SUCCESS = 32
|
||||||
cc.HANDLERTYPE_ASSETSMANAGER_ERROR = 34
|
cc.Handler.ASSETSMANAGER_ERROR = 33
|
||||||
cc.HANDLERTYPE_EVENT_LISTENER = 35
|
cc.Handler.STUDIO_EVENT_LISTENER = 34
|
||||||
cc.HANDLERTYPE_ARMATURE_EVENT = 36
|
cc.Handler.ARMATURE_EVENT = 35
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_ACC = 37
|
cc.Handler.EVENT_ACC = 36
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_CUSTIOM = 38
|
cc.Handler.EVENT_CUSTIOM = 37
|
||||||
|
cc.Handler.EVENT_KEYBOARD_PRESSED = 38
|
||||||
|
cc.Handler.EVENT_KEYBOARD_RELEASED = 39
|
||||||
|
cc.Handler.EVENT_TOUCH_BEGAN = 40
|
||||||
|
cc.Handler.EVENT_TOUCH_MOVED = 41
|
||||||
|
cc.Handler.EVENT_TOUCH_ENDED = 42
|
||||||
|
cc.Handler.EVENT_TOUCH_CANCELLED = 43
|
||||||
|
cc.Handler.EVENT_TOUCHES_BEGAN = 44
|
||||||
|
cc.Handler.EVENT_TOUCHES_MOVED = 45
|
||||||
|
cc.Handler.EVENT_TOUCHES_ENDED = 46
|
||||||
|
cc.Handler.EVENT_TOUCHES_CANCELLED = 47
|
||||||
|
cc.Handler.EVENT_MOUSE_DOWN = 48
|
||||||
|
cc.Handler.EVENT_MOUSE_UP = 49
|
||||||
|
cc.Handler.EVENT_MOUSE_MOVE = 50
|
||||||
|
cc.Handler.EVENT_MOUSE_SCROLL = 51
|
||||||
|
cc.Handler.EVENT_SPINE = 52
|
||||||
|
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_KEYBOARD_PRESSED = 39
|
cc.EVENT_UNKNOWN = 0
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_KEYBOARD_RELEASE = 40
|
cc.EVENT_TOUCH_ONE_BY_ONE = 1
|
||||||
|
cc.EVENT_TOUCH_ALL_AT_ONCE = 2
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_TOUCH_BEGAN = 41
|
cc.EVENT_KEYBOARD = 3
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_TOUCH_MOVED = 42
|
cc.EVENT_MOUSE = 4
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_TOUCH_ENDED = 43
|
cc.EVENT_ACCELERATION = 5
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_TOUCH_CANCELLED = 44
|
cc.EVENT_CUSTOM = 6
|
||||||
|
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_MOUSE_DOWN = 45
|
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_MOUSE_UP = 46
|
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_MOUSE_MOVE = 47
|
|
||||||
cc.HANDLERTYPE_EVENTLISTENER_MOUSE_SCROLL = 48
|
|
||||||
|
|
||||||
|
|
||||||
cc.GLYPHCOLLECTION_DYNAMIC = 0
|
|
||||||
cc.GLYPHCOLLECTION_NEHE = 1
|
|
||||||
cc.GLYPHCOLLECTION_ASCII = 2
|
|
||||||
cc.GLYPHCOLLECTION_CUSTOM = 3
|
|
||||||
|
|
||||||
cc.EVENTLISTENER_UNKNOWN = 0
|
|
||||||
cc.EVENTLISTENER_TOUCH_ONE_BY_ONE = 1
|
|
||||||
cc.EVENTLISTENER_TOUCH_ALL_AT_ONCE = 2
|
|
||||||
cc.EVENTLISTENER_KEYBOARD = 3
|
|
||||||
cc.EVENTLISTENER_MOUSE = 4
|
|
||||||
cc.EVENTLISTENER_ACCELERATION = 5
|
|
||||||
cc.EVENTLISTENER_CUSTOM = 6
|
|
||||||
|
|
||||||
cc.TOUCH_BEGAN = 0
|
|
||||||
cc.TOUCH_MOVED = 1
|
|
||||||
cc.TOUCH_ENDED = 2
|
|
||||||
cc.TOUCH_CANCELLED = 3
|
|
||||||
|
|
||||||
cc.KEYBOARD_PRESSED = 0
|
|
||||||
cc.KEYBOARD_RELEASE = 1
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ LOCAL_MODULE_FILENAME := libhellolua
|
||||||
LOCAL_SRC_FILES := hellolua/main.cpp \
|
LOCAL_SRC_FILES := hellolua/main.cpp \
|
||||||
../../Classes/AppDelegate.cpp
|
../../Classes/AppDelegate.cpp
|
||||||
|
|
||||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
|
||||||
|
$(LOCAL_PATH)/../../../../../external/lua/tolua \
|
||||||
|
|
||||||
LOCAL_WHOLE_STATIC_LIBRARIES := cocos_lua_static
|
LOCAL_WHOLE_STATIC_LIBRARIES := cocos_lua_static
|
||||||
|
|
||||||
|
|
|
@ -218,28 +218,28 @@ function TouchableSpriteTest:onEnter()
|
||||||
|
|
||||||
local listener1 = cc.EventListenerTouchOneByOne:create()
|
local listener1 = cc.EventListenerTouchOneByOne:create()
|
||||||
listener1:setSwallowTouches(true)
|
listener1:setSwallowTouches(true)
|
||||||
listener1:registerScriptHandler(onTouchBegan,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_BEGAN )
|
listener1:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
|
||||||
listener1:registerScriptHandler(onTouchMoved,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_MOVED )
|
listener1:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED )
|
||||||
listener1:registerScriptHandler(onTouchEnded,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_ENDED )
|
listener1:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED )
|
||||||
local eventDispatcher = self:getEventDispatcher()
|
local eventDispatcher = self:getEventDispatcher()
|
||||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener1, sprite1)
|
eventDispatcher:addEventListenerWithSceneGraphPriority(listener1, sprite1)
|
||||||
|
|
||||||
local listener2 = listener1:clone()
|
local listener2 = listener1:clone()
|
||||||
listener2:registerScriptHandler(onTouchBegan,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_BEGAN)
|
listener2:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN)
|
||||||
listener2:registerScriptHandler(onTouchMoved,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_MOVED)
|
listener2:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED)
|
||||||
listener2:registerScriptHandler(onTouchEnded,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_ENDED )
|
listener2:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED )
|
||||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener2, sprite2)
|
eventDispatcher:addEventListenerWithSceneGraphPriority(listener2, sprite2)
|
||||||
|
|
||||||
|
|
||||||
local listener3 = listener1:clone()
|
local listener3 = listener1:clone()
|
||||||
listener3:registerScriptHandler(onTouchBegan,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_BEGAN )
|
listener3:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
|
||||||
listener3:registerScriptHandler(onTouchMoved,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_MOVED )
|
listener3:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED )
|
||||||
listener3:registerScriptHandler(onTouchEnded,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_ENDED )
|
listener3:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED )
|
||||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener3, sprite3)
|
eventDispatcher:addEventListenerWithSceneGraphPriority(listener3, sprite3)
|
||||||
|
|
||||||
local function removeAllTouchItem(tag, sender)
|
local function removeAllTouchItem(tag, sender)
|
||||||
sender:setString("Only Next item could be clicked")
|
sender:setString("Only Next item could be clicked")
|
||||||
eventDispatcher:removeEventListeners(cc.EVENTLISTENER_TOUCH_ONE_BY_ONE)
|
eventDispatcher:removeEventListeners(cc.EVENT_TOUCH_ONE_BY_ONE)
|
||||||
|
|
||||||
local nextMenuItem = cc.MenuItemFont:create("Next")
|
local nextMenuItem = cc.MenuItemFont:create("Next")
|
||||||
nextMenuItem:setFontSizeObj(16)
|
nextMenuItem:setFontSizeObj(16)
|
||||||
|
@ -321,9 +321,9 @@ function TouchableSpriteWithFixedPriority:onEnter()
|
||||||
self._listener = listener
|
self._listener = listener
|
||||||
listener:setSwallowTouches(true)
|
listener:setSwallowTouches(true)
|
||||||
|
|
||||||
listener:registerScriptHandler(onTouchBegan,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_BEGAN )
|
listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
|
||||||
listener:registerScriptHandler(onTouchMoved,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_MOVED )
|
listener:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED )
|
||||||
listener:registerScriptHandler(onTouchEnded,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_ENDED )
|
listener:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED )
|
||||||
|
|
||||||
local eventDispatcher = self:getEventDispatcher()
|
local eventDispatcher = self:getEventDispatcher()
|
||||||
if self._useNodePriority then
|
if self._useNodePriority then
|
||||||
|
@ -457,8 +457,8 @@ function RemoveListenerWhenDispatchingTest:onEnter()
|
||||||
listener1:setSwallowTouches(true)
|
listener1:setSwallowTouches(true)
|
||||||
self:setUserObject(listener1)
|
self:setUserObject(listener1)
|
||||||
|
|
||||||
listener1:registerScriptHandler(onTouchBegan,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_BEGAN )
|
listener1:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN )
|
||||||
listener1:registerScriptHandler(onTouchEnded,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_ENDED )
|
listener1:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED )
|
||||||
|
|
||||||
local eventDispatcher = self:getEventDispatcher()
|
local eventDispatcher = self:getEventDispatcher()
|
||||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener1, sprite1)
|
eventDispatcher:addEventListenerWithSceneGraphPriority(listener1, sprite1)
|
||||||
|
@ -643,8 +643,8 @@ function LabelKeyboardEventTest:onEnter()
|
||||||
end
|
end
|
||||||
|
|
||||||
local listener = cc.EventListenerKeyboard:create()
|
local listener = cc.EventListenerKeyboard:create()
|
||||||
listener:registerScriptHandler(onKeyPressed, cc.HANDLERTYPE_EVENTLISTENER_KEYBOARD_PRESSED )
|
listener:registerScriptHandler(onKeyPressed, cc.Handler.EVENT_KEYBOARD_PRESSED )
|
||||||
listener:registerScriptHandler(onKeyReleased, cc.HANDLERTYPE_EVENTLISTENER_KEYBOARD_RELEASE )
|
listener:registerScriptHandler(onKeyReleased, cc.Handler.EVENT_KEYBOARD_RELEASED )
|
||||||
|
|
||||||
local eventDispatcher = self:getEventDispatcher()
|
local eventDispatcher = self:getEventDispatcher()
|
||||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, statusLabel)
|
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, statusLabel)
|
||||||
|
@ -795,9 +795,9 @@ function RemoveAndRetainNodeTest:onEnter()
|
||||||
|
|
||||||
local listener1 = cc.EventListenerTouchOneByOne:create()
|
local listener1 = cc.EventListenerTouchOneByOne:create()
|
||||||
listener1:setSwallowTouches(true)
|
listener1:setSwallowTouches(true)
|
||||||
listener1:registerScriptHandler(onTouchBegan,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_BEGAN)
|
listener1:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN)
|
||||||
listener1:registerScriptHandler(onTouchMoved,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_MOVED)
|
listener1:registerScriptHandler(onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED)
|
||||||
listener1:registerScriptHandler(onTouchEnded,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_ENDED)
|
listener1:registerScriptHandler(onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED)
|
||||||
self:getEventDispatcher():addEventListenerWithSceneGraphPriority(listener1, sprite)
|
self:getEventDispatcher():addEventListenerWithSceneGraphPriority(listener1, sprite)
|
||||||
|
|
||||||
local function retainSprite()
|
local function retainSprite()
|
||||||
|
@ -869,7 +869,7 @@ function RemoveListenerAfterAddingTest:onEnter()
|
||||||
end
|
end
|
||||||
|
|
||||||
local listener = cc.EventListenerTouchOneByOne:create()
|
local listener = cc.EventListenerTouchOneByOne:create()
|
||||||
listener:registerScriptHandler(onTouchBegan, cc.HANDLERTYPE_EVENTLISTENER_TOUCH_BEGAN)
|
listener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN)
|
||||||
eventDispatcher:addEventListenerWithFixedPriority(listener, -1)
|
eventDispatcher:addEventListenerWithFixedPriority(listener, -1)
|
||||||
eventDispatcher:removeEventListener(listener)
|
eventDispatcher:removeEventListener(listener)
|
||||||
end
|
end
|
||||||
|
@ -902,10 +902,10 @@ function RemoveListenerAfterAddingTest:onEnter()
|
||||||
end
|
end
|
||||||
|
|
||||||
local listener = cc.EventListenerTouchOneByOne:create()
|
local listener = cc.EventListenerTouchOneByOne:create()
|
||||||
listener:registerScriptHandler(onTouchBegan,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_BEGAN)
|
listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN)
|
||||||
|
|
||||||
eventDispatcher:addEventListenerWithFixedPriority(listener, -1)
|
eventDispatcher:addEventListenerWithFixedPriority(listener, -1)
|
||||||
eventDispatcher:removeEventListeners(cc.EVENTLISTENER_TOUCH_ONE_BY_ONE)
|
eventDispatcher:removeEventListeners(cc.EVENT_TOUCH_ONE_BY_ONE)
|
||||||
|
|
||||||
addNextButton()
|
addNextButton()
|
||||||
|
|
||||||
|
@ -923,7 +923,7 @@ function RemoveListenerAfterAddingTest:onEnter()
|
||||||
end
|
end
|
||||||
|
|
||||||
local listener = cc.EventListenerTouchOneByOne:create()
|
local listener = cc.EventListenerTouchOneByOne:create()
|
||||||
listener:registerScriptHandler(onTouchBegan,cc.HANDLERTYPE_EVENTLISTENER_TOUCH_BEGAN)
|
listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN)
|
||||||
|
|
||||||
eventDispatcher:addEventListenerWithFixedPriority(listener, -1)
|
eventDispatcher:addEventListenerWithFixedPriority(listener, -1)
|
||||||
eventDispatcher:removeAllEventListeners()
|
eventDispatcher:removeAllEventListeners()
|
||||||
|
|
Loading…
Reference in New Issue