mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5862 from samuele3hu/develop_script_mgr
closed #4452: Adds `addCustomHandler` in the ScriptHandlerMgr for Console auto test.
This commit is contained in:
commit
832ab120aa
|
@ -236,6 +236,29 @@ void ScriptHandlerMgr::removeObjectAllHandlers(void* object)
|
|||
}
|
||||
}
|
||||
|
||||
ScriptHandlerMgr::HandlerType ScriptHandlerMgr::addCustomHandler(void* object, int handler)
|
||||
{
|
||||
assert(nullptr != object);
|
||||
|
||||
auto iter = _mapObjectHandlers.find(object);
|
||||
VecHandlerPairs vecHandlers;
|
||||
vecHandlers.clear();
|
||||
HandlerType handlerType = HandlerType::EVENT_CUSTOM_BEGAN;
|
||||
|
||||
if (_mapObjectHandlers.end() != iter)
|
||||
{
|
||||
vecHandlers = iter->second;
|
||||
handlerType = static_cast<HandlerType>((int)vecHandlers.back().first + 1);
|
||||
}
|
||||
assert(handlerType <= HandlerType::EVENT_CUSTOM_ENDED);
|
||||
|
||||
HandlerPair eventHanler = std::make_pair(handlerType, handler);
|
||||
vecHandlers.push_back(eventHanler);
|
||||
_mapObjectHandlers[object] = vecHandlers;
|
||||
|
||||
return handlerType;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
||||
|
|
|
@ -160,8 +160,11 @@ public:
|
|||
EVENT_PHYSICS_CONTACT_PRESOLVE,
|
||||
EVENT_PHYSICS_CONTACT_POSTSOLVE,
|
||||
EVENT_PHYSICS_CONTACT_SEPERATE,
|
||||
|
||||
EVENT_CUSTOM_BEGAN = 10000,
|
||||
EVENT_CUSTOM_ENDED = 11000,
|
||||
};
|
||||
|
||||
|
||||
typedef int Handler;
|
||||
typedef std::pair<HandlerType, Handler> HandlerPair;
|
||||
typedef std::vector<HandlerPair> VecHandlerPairs;
|
||||
|
@ -175,6 +178,7 @@ public:
|
|||
void removeObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType);
|
||||
int getObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType);
|
||||
void removeObjectAllHandlers(void* object);
|
||||
ScriptHandlerMgr::HandlerType addCustomHandler(void* object, int handler);
|
||||
|
||||
private:
|
||||
void init(void);
|
||||
|
|
Loading…
Reference in New Issue