mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3413 from dumganhar/iss2521-js-ccb-owner
Adding more ExtensionTest like CocosBuilderTest and ControlButtonTest and bug fix in CCBReader.
This commit is contained in:
commit
9dbd74d2a8
|
@ -636,7 +636,7 @@ std::string FileUtils::fullPathForFilename(const char* filename)
|
||||||
for (auto resOrderIter = _searchResolutionsOrderArray.begin();
|
for (auto resOrderIter = _searchResolutionsOrderArray.begin();
|
||||||
resOrderIter != _searchResolutionsOrderArray.end(); ++resOrderIter) {
|
resOrderIter != _searchResolutionsOrderArray.end(); ++resOrderIter) {
|
||||||
|
|
||||||
// CCLOG("\n\nSEARCHING: %s, %s, %s", newFilename.c_str(), resOrderIter->c_str(), searchPathsIter->c_str());
|
// CCLOG("SEARCHING: %s\n", std::string(*searchPathsIter + *resOrderIter + newFilename).c_str() );
|
||||||
|
|
||||||
fullpath = this->getPathForFilename(newFilename, *resOrderIter, *searchPathsIter);
|
fullpath = this->getPathForFilename(newFilename, *resOrderIter, *searchPathsIter);
|
||||||
|
|
||||||
|
@ -644,7 +644,7 @@ std::string FileUtils::fullPathForFilename(const char* filename)
|
||||||
{
|
{
|
||||||
// Using the filename passed in as key.
|
// Using the filename passed in as key.
|
||||||
_fullPathCache.insert(std::pair<std::string, std::string>(filename, fullpath));
|
_fullPathCache.insert(std::pair<std::string, std::string>(filename, fullpath));
|
||||||
// CCLOG("Returning path: %s", fullpath.c_str());
|
// CCLOG("Returning path: %s\n", fullpath.c_str());
|
||||||
return fullpath;
|
return fullpath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ bool CCBAnimationManager::init()
|
||||||
_documentOutletNodes = new Array();
|
_documentOutletNodes = new Array();
|
||||||
_documentCallbackNames = new Array();
|
_documentCallbackNames = new Array();
|
||||||
_documentCallbackNodes = new Array();
|
_documentCallbackNodes = new Array();
|
||||||
|
_documentCallbackControlEvents = new Array();
|
||||||
_keyframeCallbacks = new Array();
|
_keyframeCallbacks = new Array();
|
||||||
_keyframeCallFuncs = new Dictionary();
|
_keyframeCallFuncs = new Dictionary();
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ CCBAnimationManager::~CCBAnimationManager()
|
||||||
CC_SAFE_RELEASE(_documentOutletNodes);
|
CC_SAFE_RELEASE(_documentOutletNodes);
|
||||||
CC_SAFE_RELEASE(_documentCallbackNames);
|
CC_SAFE_RELEASE(_documentCallbackNames);
|
||||||
CC_SAFE_RELEASE(_documentCallbackNodes);
|
CC_SAFE_RELEASE(_documentCallbackNodes);
|
||||||
|
CC_SAFE_RELEASE(_documentCallbackControlEvents);
|
||||||
|
|
||||||
CC_SAFE_RELEASE(_keyframeCallFuncs);
|
CC_SAFE_RELEASE(_keyframeCallFuncs);
|
||||||
CC_SAFE_RELEASE(_keyframeCallbacks);
|
CC_SAFE_RELEASE(_keyframeCallbacks);
|
||||||
|
@ -130,6 +132,11 @@ void CCBAnimationManager::addDocumentCallbackName(std::string name) {
|
||||||
_documentCallbackNames->addObject(tmpName);
|
_documentCallbackNames->addObject(tmpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCBAnimationManager::addDocumentCallbackControlEvents(Control::EventType eventType)
|
||||||
|
{
|
||||||
|
_documentCallbackControlEvents->addObject(Integer::create((int)eventType));
|
||||||
|
}
|
||||||
|
|
||||||
Array* CCBAnimationManager::getDocumentCallbackNames() {
|
Array* CCBAnimationManager::getDocumentCallbackNames() {
|
||||||
return _documentCallbackNames;
|
return _documentCallbackNames;
|
||||||
}
|
}
|
||||||
|
@ -138,6 +145,11 @@ Array* CCBAnimationManager::getDocumentCallbackNodes() {
|
||||||
return _documentCallbackNodes;
|
return _documentCallbackNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Array* CCBAnimationManager::getDocumentCallbackControlEvents()
|
||||||
|
{
|
||||||
|
return _documentCallbackControlEvents;
|
||||||
|
}
|
||||||
|
|
||||||
void CCBAnimationManager::addDocumentOutletNode(Node *node) {
|
void CCBAnimationManager::addDocumentOutletNode(Node *node) {
|
||||||
_documentOutletNodes->addObject(node);
|
_documentOutletNodes->addObject(node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "CCBSequence.h"
|
#include "CCBSequence.h"
|
||||||
#include "CCBValue.h"
|
#include "CCBValue.h"
|
||||||
#include "CCBSequenceProperty.h"
|
#include "CCBSequenceProperty.h"
|
||||||
|
#include "GUI/CCControlExtension/CCControl.h"
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
|
@ -40,6 +41,8 @@ public:
|
||||||
|
|
||||||
void addDocumentCallbackNode(Node *node);
|
void addDocumentCallbackNode(Node *node);
|
||||||
void addDocumentCallbackName(std::string name);
|
void addDocumentCallbackName(std::string name);
|
||||||
|
void addDocumentCallbackControlEvents(Control::EventType eventType);
|
||||||
|
|
||||||
void addDocumentOutletNode(Node *node);
|
void addDocumentOutletNode(Node *node);
|
||||||
void addDocumentOutletName(std::string name);
|
void addDocumentOutletName(std::string name);
|
||||||
|
|
||||||
|
@ -48,6 +51,8 @@ public:
|
||||||
std::string getDocumentControllerName();
|
std::string getDocumentControllerName();
|
||||||
Array* getDocumentCallbackNames();
|
Array* getDocumentCallbackNames();
|
||||||
Array* getDocumentCallbackNodes();
|
Array* getDocumentCallbackNodes();
|
||||||
|
Array* getDocumentCallbackControlEvents();
|
||||||
|
|
||||||
Array* getDocumentOutletNames();
|
Array* getDocumentOutletNames();
|
||||||
Array* getDocumentOutletNodes();
|
Array* getDocumentOutletNodes();
|
||||||
std::string getLastCompletedSequenceName();
|
std::string getLastCompletedSequenceName();
|
||||||
|
@ -121,6 +126,7 @@ private:
|
||||||
Array *_documentOutletNodes;
|
Array *_documentOutletNodes;
|
||||||
Array *_documentCallbackNames;
|
Array *_documentCallbackNames;
|
||||||
Array *_documentCallbackNodes;
|
Array *_documentCallbackNodes;
|
||||||
|
Array *_documentCallbackControlEvents;
|
||||||
Array *_keyframeCallbacks;
|
Array *_keyframeCallbacks;
|
||||||
Dictionary *_keyframeCallFuncs;
|
Dictionary *_keyframeCallFuncs;
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,6 @@ CCBReader::CCBReader(NodeLoaderLibrary * pNodeLoaderLibrary, CCBMemberVariableAs
|
||||||
, _nodesWithAnimationManagers(NULL)
|
, _nodesWithAnimationManagers(NULL)
|
||||||
, _animationManagersForNodes(NULL)
|
, _animationManagersForNodes(NULL)
|
||||||
, _ownerCallbackNodes(NULL)
|
, _ownerCallbackNodes(NULL)
|
||||||
, _hasScriptingOwner(false)
|
|
||||||
{
|
{
|
||||||
this->_nodeLoaderLibrary = pNodeLoaderLibrary;
|
this->_nodeLoaderLibrary = pNodeLoaderLibrary;
|
||||||
this->_nodeLoaderLibrary->retain();
|
this->_nodeLoaderLibrary->retain();
|
||||||
|
@ -88,7 +87,6 @@ CCBReader::CCBReader(CCBReader * ccbReader)
|
||||||
, _nodesWithAnimationManagers(NULL)
|
, _nodesWithAnimationManagers(NULL)
|
||||||
, _animationManagersForNodes(NULL)
|
, _animationManagersForNodes(NULL)
|
||||||
, _ownerCallbackNodes(NULL)
|
, _ownerCallbackNodes(NULL)
|
||||||
, _hasScriptingOwner(false)
|
|
||||||
{
|
{
|
||||||
this->_loadedSpriteSheets = ccbReader->_loadedSpriteSheets;
|
this->_loadedSpriteSheets = ccbReader->_loadedSpriteSheets;
|
||||||
this->_nodeLoaderLibrary = ccbReader->_nodeLoaderLibrary;
|
this->_nodeLoaderLibrary = ccbReader->_nodeLoaderLibrary;
|
||||||
|
@ -97,13 +95,6 @@ CCBReader::CCBReader(CCBReader * ccbReader)
|
||||||
this->_CCBMemberVariableAssigner = ccbReader->_CCBMemberVariableAssigner;
|
this->_CCBMemberVariableAssigner = ccbReader->_CCBMemberVariableAssigner;
|
||||||
this->_CCBSelectorResolver = ccbReader->_CCBSelectorResolver;
|
this->_CCBSelectorResolver = ccbReader->_CCBSelectorResolver;
|
||||||
this->_nodeLoaderListener = ccbReader->_nodeLoaderListener;
|
this->_nodeLoaderListener = ccbReader->_nodeLoaderListener;
|
||||||
|
|
||||||
this->_ownerCallbackNames = ccbReader->_ownerCallbackNames;
|
|
||||||
this->_ownerCallbackNodes = ccbReader->_ownerCallbackNodes;
|
|
||||||
this->_ownerCallbackNodes->retain();
|
|
||||||
this->_ownerOutletNames = ccbReader->_ownerOutletNames;
|
|
||||||
this->_ownerOutletNodes = ccbReader->_ownerOutletNodes;
|
|
||||||
this->_ownerOutletNodes->retain();
|
|
||||||
|
|
||||||
this->_CCBRootPath = ccbReader->getCCBRootPath();
|
this->_CCBRootPath = ccbReader->getCCBRootPath();
|
||||||
|
|
||||||
|
@ -124,12 +115,12 @@ CCBReader::CCBReader()
|
||||||
, _CCBSelectorResolver(NULL)
|
, _CCBSelectorResolver(NULL)
|
||||||
, _nodesWithAnimationManagers(NULL)
|
, _nodesWithAnimationManagers(NULL)
|
||||||
, _animationManagersForNodes(NULL)
|
, _animationManagersForNodes(NULL)
|
||||||
, _hasScriptingOwner(false)
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCBReader::~CCBReader() {
|
CCBReader::~CCBReader()
|
||||||
|
{
|
||||||
CC_SAFE_RELEASE_NULL(_owner);
|
CC_SAFE_RELEASE_NULL(_owner);
|
||||||
CC_SAFE_RELEASE_NULL(_data);
|
CC_SAFE_RELEASE_NULL(_data);
|
||||||
|
|
||||||
|
@ -139,9 +130,9 @@ CCBReader::~CCBReader() {
|
||||||
_ownerOutletNames.clear();
|
_ownerOutletNames.clear();
|
||||||
CC_SAFE_RELEASE(_ownerCallbackNodes);
|
CC_SAFE_RELEASE(_ownerCallbackNodes);
|
||||||
_ownerCallbackNames.clear();
|
_ownerCallbackNames.clear();
|
||||||
|
CC_SAFE_RELEASE(_ownerOwnerCallbackControlEvents);
|
||||||
|
|
||||||
// Clear string cache.
|
// Clear string cache.
|
||||||
|
|
||||||
this->_stringCache.clear();
|
this->_stringCache.clear();
|
||||||
CC_SAFE_RELEASE(_nodesWithAnimationManagers);
|
CC_SAFE_RELEASE(_nodesWithAnimationManagers);
|
||||||
CC_SAFE_RELEASE(_animationManagersForNodes);
|
CC_SAFE_RELEASE(_animationManagersForNodes);
|
||||||
|
@ -162,6 +153,10 @@ const std::string& CCBReader::getCCBRootPath() const
|
||||||
|
|
||||||
bool CCBReader::init()
|
bool CCBReader::init()
|
||||||
{
|
{
|
||||||
|
_ownerOutletNodes = new Array();
|
||||||
|
_ownerCallbackNodes = new Array();
|
||||||
|
_ownerOwnerCallbackControlEvents = new Array();
|
||||||
|
|
||||||
// Setup action manager
|
// Setup action manager
|
||||||
CCBAnimationManager *pActionManager = new CCBAnimationManager();
|
CCBAnimationManager *pActionManager = new CCBAnimationManager();
|
||||||
setAnimationManager(pActionManager);
|
setAnimationManager(pActionManager);
|
||||||
|
@ -269,8 +264,6 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &
|
||||||
|
|
||||||
_actionManager->setRootContainerSize(parentSize);
|
_actionManager->setRootContainerSize(parentSize);
|
||||||
_actionManager->_owner = _owner;
|
_actionManager->_owner = _owner;
|
||||||
_ownerOutletNodes = new Array();
|
|
||||||
_ownerCallbackNodes = new Array();
|
|
||||||
|
|
||||||
Dictionary* animationManagers = Dictionary::create();
|
Dictionary* animationManagers = Dictionary::create();
|
||||||
Node *pNodeGraph = readFileWithCleanUp(true, animationManagers);
|
Node *pNodeGraph = readFileWithCleanUp(true, animationManagers);
|
||||||
|
@ -280,8 +273,10 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &
|
||||||
// Auto play animations
|
// Auto play animations
|
||||||
_actionManager->runAnimationsForSequenceIdTweenDuration(_actionManager->getAutoPlaySequenceId(), 0);
|
_actionManager->runAnimationsForSequenceIdTweenDuration(_actionManager->getAutoPlaySequenceId(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign actionManagers to userObject
|
// Assign actionManagers to userObject
|
||||||
if(_jsControlled) {
|
if(_jsControlled)
|
||||||
|
{
|
||||||
_nodesWithAnimationManagers = new Array();
|
_nodesWithAnimationManagers = new Array();
|
||||||
_animationManagersForNodes = new Array();
|
_animationManagersForNodes = new Array();
|
||||||
}
|
}
|
||||||
|
@ -716,8 +711,8 @@ Node * CCBReader::readNodeGraph(Node * pParent)
|
||||||
if(target != NULL)
|
if(target != NULL)
|
||||||
{
|
{
|
||||||
CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast<CCBMemberVariableAssigner *>(target);
|
CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast<CCBMemberVariableAssigner *>(target);
|
||||||
if(targetAsCCBMemberVariableAssigner != NULL) {
|
if(targetAsCCBMemberVariableAssigner != NULL)
|
||||||
|
{
|
||||||
Dictionary* pCustomPropeties = ccNodeLoader->getCustomProperties();
|
Dictionary* pCustomPropeties = ccNodeLoader->getCustomProperties();
|
||||||
DictElement* pElement;
|
DictElement* pElement;
|
||||||
CCDICT_FOREACH(pCustomPropeties, pElement)
|
CCDICT_FOREACH(pCustomPropeties, pElement)
|
||||||
|
@ -741,7 +736,8 @@ Node * CCBReader::readNodeGraph(Node * pParent)
|
||||||
|
|
||||||
/* Read and add children. */
|
/* Read and add children. */
|
||||||
int numChildren = this->readInt(false);
|
int numChildren = this->readInt(false);
|
||||||
for(int i = 0; i < numChildren; i++) {
|
for(int i = 0; i < numChildren; i++)
|
||||||
|
{
|
||||||
Node * child = this->readNodeGraph(node);
|
Node * child = this->readNodeGraph(node);
|
||||||
node->addChild(child);
|
node->addChild(child);
|
||||||
}
|
}
|
||||||
|
@ -749,12 +745,16 @@ Node * CCBReader::readNodeGraph(Node * pParent)
|
||||||
// FIX ISSUE #1860: "onNodeLoaded will be called twice if ccb was added as a CCBFile".
|
// FIX ISSUE #1860: "onNodeLoaded will be called twice if ccb was added as a CCBFile".
|
||||||
// If it's a sub-ccb node, skip notification to NodeLoaderListener since it will be
|
// If it's a sub-ccb node, skip notification to NodeLoaderListener since it will be
|
||||||
// notified at LINE #734: Node * child = this->readNodeGraph(node);
|
// notified at LINE #734: Node * child = this->readNodeGraph(node);
|
||||||
if (!isCCBFileNode) {
|
if (!isCCBFileNode)
|
||||||
|
{
|
||||||
// Call onNodeLoaded
|
// Call onNodeLoaded
|
||||||
NodeLoaderListener * nodeAsNodeLoaderListener = dynamic_cast<NodeLoaderListener *>(node);
|
NodeLoaderListener * nodeAsNodeLoaderListener = dynamic_cast<NodeLoaderListener *>(node);
|
||||||
if(nodeAsNodeLoaderListener != NULL) {
|
if(nodeAsNodeLoaderListener != NULL)
|
||||||
|
{
|
||||||
nodeAsNodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
|
nodeAsNodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
|
||||||
} else if(this->_nodeLoaderListener != NULL) {
|
}
|
||||||
|
else if(this->_nodeLoaderListener != NULL)
|
||||||
|
{
|
||||||
this->_nodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
|
this->_nodeLoaderListener->onNodeLoaded(node, ccNodeLoader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -991,29 +991,43 @@ bool CCBReader::endsWith(const char* pString, const char* pEnding) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCBReader::isJSControlled() {
|
bool CCBReader::isJSControlled()
|
||||||
|
{
|
||||||
return _jsControlled;
|
return _jsControlled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCBReader::addOwnerCallbackName(std::string name) {
|
void CCBReader::addOwnerCallbackName(const std::string& name)
|
||||||
|
{
|
||||||
_ownerCallbackNames.push_back(name);
|
_ownerCallbackNames.push_back(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCBReader::addOwnerCallbackNode(Node *node) {
|
void CCBReader::addOwnerCallbackNode(Node *node)
|
||||||
|
{
|
||||||
_ownerCallbackNodes->addObject(node);
|
_ownerCallbackNodes->addObject(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCBReader::addOwnerCallbackControlEvents(Control::EventType type)
|
||||||
|
{
|
||||||
|
_ownerOwnerCallbackControlEvents->addObject(Integer::create((int)type));
|
||||||
|
}
|
||||||
|
|
||||||
void CCBReader::addDocumentCallbackName(std::string name) {
|
void CCBReader::addDocumentCallbackName(const std::string& name)
|
||||||
|
{
|
||||||
_actionManager->addDocumentCallbackName(name);
|
_actionManager->addDocumentCallbackName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCBReader::addDocumentCallbackNode(Node *node) {
|
void CCBReader::addDocumentCallbackNode(Node *node)
|
||||||
|
{
|
||||||
_actionManager->addDocumentCallbackNode(node);
|
_actionManager->addDocumentCallbackNode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCBReader::addDocumentCallbackControlEvents(Control::EventType eventType)
|
||||||
|
{
|
||||||
|
_actionManager->addDocumentCallbackControlEvents(eventType);
|
||||||
|
}
|
||||||
|
|
||||||
Array* CCBReader::getOwnerCallbackNames() {
|
Array* CCBReader::getOwnerCallbackNames()
|
||||||
|
{
|
||||||
Array* pRet = Array::createWithCapacity(_ownerCallbackNames.size());
|
Array* pRet = Array::createWithCapacity(_ownerCallbackNames.size());
|
||||||
std::vector<std::string>::iterator it = _ownerCallbackNames.begin();
|
std::vector<std::string>::iterator it = _ownerCallbackNames.begin();
|
||||||
for (; it != _ownerCallbackNames.end(); ++it)
|
for (; it != _ownerCallbackNames.end(); ++it)
|
||||||
|
@ -1024,11 +1038,18 @@ Array* CCBReader::getOwnerCallbackNames() {
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array* CCBReader::getOwnerCallbackNodes() {
|
Array* CCBReader::getOwnerCallbackNodes()
|
||||||
|
{
|
||||||
return _ownerCallbackNodes;
|
return _ownerCallbackNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array* CCBReader::getOwnerOutletNames() {
|
Array* CCBReader::getOwnerCallbackControlEvents()
|
||||||
|
{
|
||||||
|
return _ownerOwnerCallbackControlEvents;
|
||||||
|
}
|
||||||
|
|
||||||
|
Array* CCBReader::getOwnerOutletNames()
|
||||||
|
{
|
||||||
Array* pRet = Array::createWithCapacity(_ownerOutletNames.size());
|
Array* pRet = Array::createWithCapacity(_ownerOutletNames.size());
|
||||||
std::vector<std::string>::iterator it = _ownerOutletNames.begin();
|
std::vector<std::string>::iterator it = _ownerOutletNames.begin();
|
||||||
for (; it != _ownerOutletNames.end(); ++it)
|
for (; it != _ownerOutletNames.end(); ++it)
|
||||||
|
@ -1038,26 +1059,29 @@ Array* CCBReader::getOwnerOutletNames() {
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array* CCBReader::getOwnerOutletNodes() {
|
Array* CCBReader::getOwnerOutletNodes()
|
||||||
|
{
|
||||||
return _ownerOutletNodes;
|
return _ownerOutletNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array* CCBReader::getNodesWithAnimationManagers() {
|
Array* CCBReader::getNodesWithAnimationManagers()
|
||||||
|
{
|
||||||
return _nodesWithAnimationManagers;
|
return _nodesWithAnimationManagers;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array* CCBReader::getAnimationManagersForNodes() {
|
Array* CCBReader::getAnimationManagersForNodes()
|
||||||
|
{
|
||||||
return _animationManagersForNodes;
|
return _animationManagersForNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCBReader::addOwnerOutletName(std::string name)
|
void CCBReader::addOwnerOutletName(std::string name)
|
||||||
{
|
{
|
||||||
_ownerOutletNames.push_back(name);
|
_ownerOutletNames.push_back(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCBReader::addOwnerOutletNode(Node *node)
|
void CCBReader::addOwnerOutletNode(Node *node)
|
||||||
{
|
{
|
||||||
if (NULL != node)
|
if (NULL == node)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_ownerOutletNodes->addObject(node);
|
_ownerOutletNodes->addObject(node);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "CCBSequence.h"
|
#include "CCBSequence.h"
|
||||||
|
#include "GUI/CCControlExtension/CCControl.h"
|
||||||
|
|
||||||
#define CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \
|
#define CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \
|
||||||
T * ptr = new T(); \
|
T * ptr = new T(); \
|
||||||
|
@ -187,28 +187,29 @@ public:
|
||||||
float readFloat();
|
float readFloat();
|
||||||
std::string readCachedString();
|
std::string readCachedString();
|
||||||
bool isJSControlled();
|
bool isJSControlled();
|
||||||
|
|
||||||
|
|
||||||
bool readCallbackKeyframesForSeq(CCBSequence* seq);
|
bool readCallbackKeyframesForSeq(CCBSequence* seq);
|
||||||
bool readSoundKeyframesForSeq(CCBSequence* seq);
|
bool readSoundKeyframesForSeq(CCBSequence* seq);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Array* getOwnerCallbackNames();
|
Array* getOwnerCallbackNames();
|
||||||
Array* getOwnerCallbackNodes();
|
Array* getOwnerCallbackNodes();
|
||||||
|
Array* getOwnerCallbackControlEvents();
|
||||||
|
|
||||||
Array* getOwnerOutletNames();
|
Array* getOwnerOutletNames();
|
||||||
Array* getOwnerOutletNodes();
|
Array* getOwnerOutletNodes();
|
||||||
Array* getNodesWithAnimationManagers();
|
Array* getNodesWithAnimationManagers();
|
||||||
Array* getAnimationManagersForNodes();
|
Array* getAnimationManagersForNodes();
|
||||||
|
|
||||||
Dictionary* getAnimationManagers();
|
Dictionary* getAnimationManagers();
|
||||||
void setAnimationManagers(Dictionary* x); // weak reference
|
void setAnimationManagers(Dictionary* x); // weak reference
|
||||||
|
|
||||||
void addOwnerCallbackName(std::string name);
|
void addOwnerCallbackName(const std::string& name);
|
||||||
void addOwnerCallbackNode(Node *node);
|
void addOwnerCallbackNode(Node *node);
|
||||||
|
void addOwnerCallbackControlEvents(Control::EventType type);
|
||||||
|
|
||||||
void addDocumentCallbackName(std::string name);
|
void addDocumentCallbackName(const std::string& name);
|
||||||
void addDocumentCallbackNode(Node *node);
|
void addDocumentCallbackNode(Node *node);
|
||||||
|
void addDocumentCallbackControlEvents(Control::EventType eventType);
|
||||||
|
|
||||||
static float getResolutionScale();
|
static float getResolutionScale();
|
||||||
static void setResolutionScale(float scale);
|
static void setResolutionScale(float scale);
|
||||||
|
@ -232,6 +233,8 @@ private:
|
||||||
bool getBit();
|
bool getBit();
|
||||||
void alignBits();
|
void alignBits();
|
||||||
|
|
||||||
|
bool init();
|
||||||
|
|
||||||
friend class NodeLoader;
|
friend class NodeLoader;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -262,12 +265,10 @@ private:
|
||||||
|
|
||||||
std::vector<std::string> _ownerCallbackNames;
|
std::vector<std::string> _ownerCallbackNames;
|
||||||
Array* _ownerCallbackNodes;
|
Array* _ownerCallbackNodes;
|
||||||
|
Array* _ownerOwnerCallbackControlEvents;
|
||||||
std::string _CCBRootPath;
|
std::string _CCBRootPath;
|
||||||
|
|
||||||
bool _jsControlled;
|
bool _jsControlled;
|
||||||
|
|
||||||
bool _hasScriptingOwner;
|
|
||||||
bool init();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of effects group
|
// end of effects group
|
||||||
|
|
|
@ -800,14 +800,22 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead
|
||||||
} else {
|
} else {
|
||||||
CCLOG("Unexpected NULL target for selector.");
|
CCLOG("Unexpected NULL target for selector.");
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) {
|
else
|
||||||
|
{
|
||||||
|
if (selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT)
|
||||||
|
{
|
||||||
ccbReader->addDocumentCallbackNode(pNode);
|
ccbReader->addDocumentCallbackNode(pNode);
|
||||||
ccbReader->addDocumentCallbackName(selectorName);
|
ccbReader->addDocumentCallbackName(selectorName);
|
||||||
|
// Since there isn't a Control::EventType::NONE, add a TOUCH_DOWN type as a placeholder.
|
||||||
} else {
|
ccbReader->addDocumentCallbackControlEvents(Control::EventType::TOUCH_DOWN);
|
||||||
|
}
|
||||||
|
else if (selectorTarget == CCBReader::TargetType::OWNER)
|
||||||
|
{
|
||||||
ccbReader->addOwnerCallbackNode(pNode);
|
ccbReader->addOwnerCallbackNode(pNode);
|
||||||
ccbReader->addOwnerCallbackName(selectorName);
|
ccbReader->addOwnerCallbackName(selectorName);
|
||||||
|
// Since there isn't a Control::EventType::NONE, add a TOUCH_DOWN type as a placeholder.
|
||||||
|
ccbReader->addOwnerCallbackControlEvents(Control::EventType::TOUCH_DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -884,12 +892,13 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP
|
||||||
{
|
{
|
||||||
ccbReader->addDocumentCallbackNode(pNode);
|
ccbReader->addDocumentCallbackNode(pNode);
|
||||||
ccbReader->addDocumentCallbackName(selectorName);
|
ccbReader->addDocumentCallbackName(selectorName);
|
||||||
|
ccbReader->addDocumentCallbackControlEvents((Control::EventType)controlEvents);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ccbReader->addOwnerCallbackNode(pNode);
|
ccbReader->addOwnerCallbackNode(pNode);
|
||||||
ccbReader->addOwnerCallbackName(selectorName);
|
ccbReader->addOwnerCallbackName(selectorName);
|
||||||
|
ccbReader->addOwnerCallbackControlEvents((Control::EventType)controlEvents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -953,11 +962,13 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader
|
||||||
if (NULL != ownerCallbackNames && ownerCallbackNames->count() > 0 &&
|
if (NULL != ownerCallbackNames && ownerCallbackNames->count() > 0 &&
|
||||||
NULL != ownerCallbackNodes && ownerCallbackNodes->count() > 0)
|
NULL != ownerCallbackNodes && ownerCallbackNodes->count() > 0)
|
||||||
{
|
{
|
||||||
assert(ownerCallbackNames->count() == ownerCallbackNodes->count());
|
CCASSERT(ownerCallbackNames->count() == ownerCallbackNodes->count(), "");
|
||||||
int nCount = ownerCallbackNames->count();
|
int nCount = ownerCallbackNames->count();
|
||||||
for (int i = 0 ; i < nCount; i++) {
|
|
||||||
|
for (int i = 0 ; i < nCount; i++)
|
||||||
|
{
|
||||||
pCCBReader->addOwnerCallbackName((dynamic_cast<String*>(ownerCallbackNames->objectAtIndex(i)))->getCString());
|
pCCBReader->addOwnerCallbackName((dynamic_cast<String*>(ownerCallbackNames->objectAtIndex(i)))->getCString());
|
||||||
pCCBReader->addOwnerCallbackNode(dynamic_cast<Node*>(ownerCallbackNames->objectAtIndex(i)) );
|
pCCBReader->addOwnerCallbackNode(dynamic_cast<Node*>(ownerCallbackNodes->objectAtIndex(i)) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//set variables
|
//set variables
|
||||||
|
@ -966,11 +977,13 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader
|
||||||
if (NULL != ownerOutletNames && ownerOutletNames->count() > 0 &&
|
if (NULL != ownerOutletNames && ownerOutletNames->count() > 0 &&
|
||||||
NULL != ownerOutletNodes && ownerOutletNodes->count() > 0)
|
NULL != ownerOutletNodes && ownerOutletNodes->count() > 0)
|
||||||
{
|
{
|
||||||
assert(ownerOutletNames->count() == ownerOutletNodes->count());
|
CCASSERT(ownerOutletNames->count() == ownerOutletNodes->count(), "");
|
||||||
int nCount = ownerOutletNames->count();
|
int nCount = ownerOutletNames->count();
|
||||||
for (int i = 0 ; i < nCount; i++) {
|
|
||||||
pCCBReader->addOwnerOutletName((dynamic_cast<String*>(ownerOutletNames->objectAtIndex(i)))->getCString());
|
for (int i = 0 ; i < nCount; i++)
|
||||||
pCCBReader->addOwnerOutletNode(dynamic_cast<Node*>(ownerOutletNodes->objectAtIndex(i)) );
|
{
|
||||||
|
pCCBReader->addOwnerOutletName((static_cast<String*>(ownerOutletNames->objectAtIndex(i)))->getCString());
|
||||||
|
pCCBReader->addOwnerOutletNode(static_cast<Node*>(ownerOutletNodes->objectAtIndex(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
|
|
||||||
virtual double getValue() const;
|
virtual double getValue() const;
|
||||||
virtual void setStepValue(double stepValue);
|
virtual void setStepValue(double stepValue);
|
||||||
|
/** Set the numeric value of the stepper. If send is true, the Control::EventType::VALUE_CHANGED is sent. */
|
||||||
virtual void setValueWithSendingEvent(double value, bool send);
|
virtual void setValueWithSendingEvent(double value, bool send);
|
||||||
virtual bool isContinuous() const;
|
virtual bool isContinuous() const;
|
||||||
|
|
||||||
|
@ -75,9 +76,6 @@ public:
|
||||||
/** Update the layout of the stepper with the given touch location. */
|
/** Update the layout of the stepper with the given touch location. */
|
||||||
void updateLayoutUsingTouchLocation(Point location);
|
void updateLayoutUsingTouchLocation(Point location);
|
||||||
|
|
||||||
/** Set the numeric value of the stepper. If send is true, the Control::EventType::VALUE_CHANGED is sent. */
|
|
||||||
void setValue(double value, bool send);
|
|
||||||
|
|
||||||
/** Start the autorepeat increment/decrement. */
|
/** Start the autorepeat increment/decrement. */
|
||||||
void startAutorepeat();
|
void startAutorepeat();
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit dddaff578b31436a0a18c7420428e91e7d9d2df4
|
Subproject commit 4a4179ed52d2236a3c2780456b77c24a600bfe3e
|
|
@ -12,6 +12,7 @@
|
||||||
#include "jsb_opengl_registration.h"
|
#include "jsb_opengl_registration.h"
|
||||||
#include "XMLHTTPRequest.h"
|
#include "XMLHTTPRequest.h"
|
||||||
#include "jsb_websocket.h"
|
#include "jsb_websocket.h"
|
||||||
|
#include "js_bindings_ccbreader.h"
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
USING_NS_CC_EXT;
|
USING_NS_CC_EXT;
|
||||||
|
@ -50,7 +51,8 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||||
sc->addRegisterCallback(jsb_register_system);
|
sc->addRegisterCallback(jsb_register_system);
|
||||||
sc->addRegisterCallback(MinXmlHttpRequest::_js_register);
|
sc->addRegisterCallback(MinXmlHttpRequest::_js_register);
|
||||||
sc->addRegisterCallback(register_jsb_websocket);
|
sc->addRegisterCallback(register_jsb_websocket);
|
||||||
|
sc->addRegisterCallback(register_CCBuilderReader);
|
||||||
|
|
||||||
sc->start();
|
sc->start();
|
||||||
|
|
||||||
ScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
|
ScriptEngineProtocol *pEngine = ScriptingCore::getInstance();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
a9b4d7898c51c7cc4c1e53fde4695cf85e32d796
|
d17c1939227c62cebcc30a071cf81b12bfa08db3
|
|
@ -133,6 +133,20 @@ cc._c4b = function( r, g, b, a )
|
||||||
cc.c4 = cc.c4b;
|
cc.c4 = cc.c4b;
|
||||||
cc._c4 = cc._c4b;
|
cc._c4 = cc._c4b;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert Color3B to a string of color for style.
|
||||||
|
* e.g. Color3B(255,6,255) to : "#ff06ff"
|
||||||
|
* @param clr
|
||||||
|
* @return {String}
|
||||||
|
*/
|
||||||
|
cc.convertColor3BtoHexString = function (clr) {
|
||||||
|
var hR = clr.r.toString(16);
|
||||||
|
var hG = clr.g.toString(16);
|
||||||
|
var hB = clr.b.toString(16);
|
||||||
|
var stClr = "#" + (clr.r < 16 ? ("0" + hR) : hR) + (clr.g < 16 ? ("0" + hG) : hG) + (clr.b < 16 ? ("0" + hB) : hB);
|
||||||
|
return stClr;
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Color 4F
|
// Color 4F
|
||||||
//
|
//
|
||||||
|
|
|
@ -40,7 +40,22 @@ cc.BuilderReader.load = function(file, owner, parentSize)
|
||||||
var callbackName = ownerCallbackNames[i];
|
var callbackName = ownerCallbackNames[i];
|
||||||
var callbackNode = ownerCallbackNodes[i];
|
var callbackNode = ownerCallbackNodes[i];
|
||||||
|
|
||||||
callbackNode.setCallback(owner[callbackName], owner);
|
if (owner[callbackName] === undefined)
|
||||||
|
{
|
||||||
|
cc.log("Warning: " + "owner." + callbackName + " is undefined.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(callbackNode instanceof cc.ControlButton)
|
||||||
|
{
|
||||||
|
var ownerCallbackControlEvents = reader.getOwnerCallbackControlEvents();
|
||||||
|
callbackNode.addTargetWithActionForControlEvents(owner, owner[callbackName], ownerCallbackControlEvents[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
callbackNode.setCallback(owner[callbackName], owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
|
@ -86,7 +101,22 @@ cc.BuilderReader.load = function(file, owner, parentSize)
|
||||||
var callbackName = documentCallbackNames[j];
|
var callbackName = documentCallbackNames[j];
|
||||||
var callbackNode = documentCallbackNodes[j];
|
var callbackNode = documentCallbackNodes[j];
|
||||||
|
|
||||||
callbackNode.setCallback(controller[callbackName], controller);
|
if (controller[callbackName] === undefined)
|
||||||
|
{
|
||||||
|
cc.log("Warning: " + documentControllerName + "." + callbackName + " is undefined.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(callbackNode instanceof cc.ControlButton)
|
||||||
|
{
|
||||||
|
var documentCallbackControlEvents = animationManager.getDocumentCallbackControlEvents();
|
||||||
|
callbackNode.addTargetWithActionForControlEvents(controller, controller[callbackName], documentCallbackControlEvents[j]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
callbackNode.setCallback(controller[callbackName], controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,4 +175,4 @@ cc.BuilderReader.loadAsScene = function(file, owner, parentSize)
|
||||||
scene.addChild( node );
|
scene.addChild( node );
|
||||||
|
|
||||||
return scene;
|
return scene;
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,7 @@ headers = %(cocosdir)s/extensions/cocos-ext.h
|
||||||
|
|
||||||
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||||
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||||
classes = CCBReader.* CCBAnimationManager.* Scale9Sprite Control$ ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$
|
classes = CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$
|
||||||
|
|
||||||
# what should we skip? in the format ClassName::[function function]
|
# what should we skip? in the format ClassName::[function function]
|
||||||
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||||
|
@ -40,10 +40,12 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC
|
||||||
ScrollView::[(g|s)etDelegate$],
|
ScrollView::[(g|s)etDelegate$],
|
||||||
.*Delegate::[*],
|
.*Delegate::[*],
|
||||||
.*Loader.*::[*],
|
.*Loader.*::[*],
|
||||||
*::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType],
|
*::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV],
|
||||||
EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler],
|
EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler],
|
||||||
TableView::[create (g|s)etDataSource$ (g|s)etDelegate],
|
TableView::[create (g|s)etDataSource$ (g|s)etDelegate],
|
||||||
Control::[removeHandleOfControlEvent addHandleOfControlEvent]
|
Control::[removeHandleOfControlEvent addHandleOfControlEvent],
|
||||||
|
ControlUtils::[*],
|
||||||
|
ControlSwitchSprite::[*]
|
||||||
|
|
||||||
rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager],
|
rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager],
|
||||||
CCBAnimationManager::[setCallFunc=setCallFuncForJSCallbackNamed]
|
CCBAnimationManager::[setCallFunc=setCallFuncForJSCallbackNamed]
|
||||||
|
|
Loading…
Reference in New Issue