From dbd58b6aa70225f366c6f128913cc15cf1466a08 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 12 Aug 2013 11:06:51 +0800 Subject: [PATCH 01/10] issue #2521: Updating comments where searchs full path. --- cocos2dx/platform/CCFileUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/CCFileUtils.cpp b/cocos2dx/platform/CCFileUtils.cpp index 7b14c6dafe..c14a759f64 100644 --- a/cocos2dx/platform/CCFileUtils.cpp +++ b/cocos2dx/platform/CCFileUtils.cpp @@ -636,7 +636,7 @@ std::string FileUtils::fullPathForFilename(const char* filename) for (auto resOrderIter = _searchResolutionsOrderArray.begin(); 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); @@ -644,7 +644,7 @@ std::string FileUtils::fullPathForFilename(const char* filename) { // Using the filename passed in as key. _fullPathCache.insert(std::pair(filename, fullpath)); -// CCLOG("Returning path: %s", fullpath.c_str()); +// CCLOG("Returning path: %s\n", fullpath.c_str()); return fullpath; } } From 331f0ef7b04d9fb4da2877c6e14d4f4ab1b43555 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 12 Aug 2013 11:18:07 +0800 Subject: [PATCH 02/10] issue #2521: Capture event of ControlButton in CCB for JSB. --- extensions/CCBReader/CCBAnimationManager.cpp | 12 +++ extensions/CCBReader/CCBAnimationManager.h | 6 ++ extensions/CCBReader/CCBReader.cpp | 92 ++++++++++++-------- extensions/CCBReader/CCBReader.h | 21 ++--- extensions/CCBReader/CCNodeLoader.cpp | 37 +++++--- 5 files changed, 112 insertions(+), 56 deletions(-) diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 7526e4d0a3..7b6172a3dd 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -42,6 +42,7 @@ bool CCBAnimationManager::init() _documentOutletNodes = new Array(); _documentCallbackNames = new Array(); _documentCallbackNodes = new Array(); + _documentCallbackControlEvents = new Array(); _keyframeCallbacks = new Array(); _keyframeCallFuncs = new Dictionary(); @@ -76,6 +77,7 @@ CCBAnimationManager::~CCBAnimationManager() CC_SAFE_RELEASE(_documentOutletNodes); CC_SAFE_RELEASE(_documentCallbackNames); CC_SAFE_RELEASE(_documentCallbackNodes); + CC_SAFE_RELEASE(_documentCallbackControlEvents); CC_SAFE_RELEASE(_keyframeCallFuncs); CC_SAFE_RELEASE(_keyframeCallbacks); @@ -130,6 +132,11 @@ void CCBAnimationManager::addDocumentCallbackName(std::string name) { _documentCallbackNames->addObject(tmpName); } +void CCBAnimationManager::addDocumentCallbackControlEvents(Control::EventType eventType) +{ + _documentCallbackControlEvents->addObject(Integer::create((int)eventType)); +} + Array* CCBAnimationManager::getDocumentCallbackNames() { return _documentCallbackNames; } @@ -138,6 +145,11 @@ Array* CCBAnimationManager::getDocumentCallbackNodes() { return _documentCallbackNodes; } +Array* CCBAnimationManager::getDocumentCallbackControlEvents() +{ + return _documentCallbackControlEvents; +} + void CCBAnimationManager::addDocumentOutletNode(Node *node) { _documentOutletNodes->addObject(node); } diff --git a/extensions/CCBReader/CCBAnimationManager.h b/extensions/CCBReader/CCBAnimationManager.h index b43276ff40..9ae3f24bbc 100644 --- a/extensions/CCBReader/CCBAnimationManager.h +++ b/extensions/CCBReader/CCBAnimationManager.h @@ -6,6 +6,7 @@ #include "CCBSequence.h" #include "CCBValue.h" #include "CCBSequenceProperty.h" +#include "GUI/CCControlExtension/CCControl.h" NS_CC_EXT_BEGIN @@ -40,6 +41,8 @@ public: void addDocumentCallbackNode(Node *node); void addDocumentCallbackName(std::string name); + void addDocumentCallbackControlEvents(Control::EventType eventType); + void addDocumentOutletNode(Node *node); void addDocumentOutletName(std::string name); @@ -48,6 +51,8 @@ public: std::string getDocumentControllerName(); Array* getDocumentCallbackNames(); Array* getDocumentCallbackNodes(); + Array* getDocumentCallbackControlEvents(); + Array* getDocumentOutletNames(); Array* getDocumentOutletNodes(); std::string getLastCompletedSequenceName(); @@ -121,6 +126,7 @@ private: Array *_documentOutletNodes; Array *_documentCallbackNames; Array *_documentCallbackNodes; + Array *_documentCallbackControlEvents; Array *_keyframeCallbacks; Dictionary *_keyframeCallFuncs; diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index 9d6df2baba..a4a6bf7811 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -65,7 +65,6 @@ CCBReader::CCBReader(NodeLoaderLibrary * pNodeLoaderLibrary, CCBMemberVariableAs , _nodesWithAnimationManagers(NULL) , _animationManagersForNodes(NULL) , _ownerCallbackNodes(NULL) -, _hasScriptingOwner(false) { this->_nodeLoaderLibrary = pNodeLoaderLibrary; this->_nodeLoaderLibrary->retain(); @@ -88,7 +87,6 @@ CCBReader::CCBReader(CCBReader * ccbReader) , _nodesWithAnimationManagers(NULL) , _animationManagersForNodes(NULL) , _ownerCallbackNodes(NULL) -, _hasScriptingOwner(false) { this->_loadedSpriteSheets = ccbReader->_loadedSpriteSheets; this->_nodeLoaderLibrary = ccbReader->_nodeLoaderLibrary; @@ -97,13 +95,6 @@ CCBReader::CCBReader(CCBReader * ccbReader) this->_CCBMemberVariableAssigner = ccbReader->_CCBMemberVariableAssigner; this->_CCBSelectorResolver = ccbReader->_CCBSelectorResolver; 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(); @@ -124,12 +115,12 @@ CCBReader::CCBReader() , _CCBSelectorResolver(NULL) , _nodesWithAnimationManagers(NULL) , _animationManagersForNodes(NULL) -, _hasScriptingOwner(false) { init(); } -CCBReader::~CCBReader() { +CCBReader::~CCBReader() +{ CC_SAFE_RELEASE_NULL(_owner); CC_SAFE_RELEASE_NULL(_data); @@ -139,9 +130,9 @@ CCBReader::~CCBReader() { _ownerOutletNames.clear(); CC_SAFE_RELEASE(_ownerCallbackNodes); _ownerCallbackNames.clear(); - + CC_SAFE_RELEASE(_ownerOwnerCallbackControlEvents); + // Clear string cache. - this->_stringCache.clear(); CC_SAFE_RELEASE(_nodesWithAnimationManagers); CC_SAFE_RELEASE(_animationManagersForNodes); @@ -162,6 +153,10 @@ const std::string& CCBReader::getCCBRootPath() const bool CCBReader::init() { + _ownerOutletNodes = new Array(); + _ownerCallbackNodes = new Array(); + _ownerOwnerCallbackControlEvents = new Array(); + // Setup action manager CCBAnimationManager *pActionManager = new CCBAnimationManager(); setAnimationManager(pActionManager); @@ -269,8 +264,6 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size & _actionManager->setRootContainerSize(parentSize); _actionManager->_owner = _owner; - _ownerOutletNodes = new Array(); - _ownerCallbackNodes = new Array(); Dictionary* animationManagers = Dictionary::create(); Node *pNodeGraph = readFileWithCleanUp(true, animationManagers); @@ -280,8 +273,10 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size & // Auto play animations _actionManager->runAnimationsForSequenceIdTweenDuration(_actionManager->getAutoPlaySequenceId(), 0); } + // Assign actionManagers to userObject - if(_jsControlled) { + if(_jsControlled) + { _nodesWithAnimationManagers = new Array(); _animationManagersForNodes = new Array(); } @@ -716,8 +711,8 @@ Node * CCBReader::readNodeGraph(Node * pParent) if(target != NULL) { CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast(target); - if(targetAsCCBMemberVariableAssigner != NULL) { - + if(targetAsCCBMemberVariableAssigner != NULL) + { Dictionary* pCustomPropeties = ccNodeLoader->getCustomProperties(); DictElement* pElement; CCDICT_FOREACH(pCustomPropeties, pElement) @@ -741,7 +736,8 @@ Node * CCBReader::readNodeGraph(Node * pParent) /* Read and add children. */ 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->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". // If it's a sub-ccb node, skip notification to NodeLoaderListener since it will be // notified at LINE #734: Node * child = this->readNodeGraph(node); - if (!isCCBFileNode) { + if (!isCCBFileNode) + { // Call onNodeLoaded NodeLoaderListener * nodeAsNodeLoaderListener = dynamic_cast(node); - if(nodeAsNodeLoaderListener != NULL) { + if(nodeAsNodeLoaderListener != NULL) + { nodeAsNodeLoaderListener->onNodeLoaded(node, ccNodeLoader); - } else if(this->_nodeLoaderListener != NULL) { + } + else if(this->_nodeLoaderListener != NULL) + { 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; } -void CCBReader::addOwnerCallbackName(std::string name) { +void CCBReader::addOwnerCallbackName(const std::string& name) +{ _ownerCallbackNames.push_back(name); } -void CCBReader::addOwnerCallbackNode(Node *node) { +void CCBReader::addOwnerCallbackNode(Node *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); } -void CCBReader::addDocumentCallbackNode(Node *node) { +void CCBReader::addDocumentCallbackNode(Node *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()); std::vector::iterator it = _ownerCallbackNames.begin(); for (; it != _ownerCallbackNames.end(); ++it) @@ -1024,11 +1038,18 @@ Array* CCBReader::getOwnerCallbackNames() { return pRet; } -Array* CCBReader::getOwnerCallbackNodes() { +Array* CCBReader::getOwnerCallbackNodes() +{ return _ownerCallbackNodes; } -Array* CCBReader::getOwnerOutletNames() { +Array* CCBReader::getOwnerCallbackControlEvents() +{ + return _ownerOwnerCallbackControlEvents; +} + +Array* CCBReader::getOwnerOutletNames() +{ Array* pRet = Array::createWithCapacity(_ownerOutletNames.size()); std::vector::iterator it = _ownerOutletNames.begin(); for (; it != _ownerOutletNames.end(); ++it) @@ -1038,23 +1059,26 @@ Array* CCBReader::getOwnerOutletNames() { return pRet; } -Array* CCBReader::getOwnerOutletNodes() { +Array* CCBReader::getOwnerOutletNodes() +{ return _ownerOutletNodes; } -Array* CCBReader::getNodesWithAnimationManagers() { +Array* CCBReader::getNodesWithAnimationManagers() +{ return _nodesWithAnimationManagers; } -Array* CCBReader::getAnimationManagersForNodes() { +Array* CCBReader::getAnimationManagersForNodes() +{ return _animationManagersForNodes; } void CCBReader::addOwnerOutletName(std::string name) { _ownerOutletNames.push_back(name); - } + void CCBReader::addOwnerOutletNode(Node *node) { if (NULL != node) diff --git a/extensions/CCBReader/CCBReader.h b/extensions/CCBReader/CCBReader.h index d30c7ecbea..ecbd7ff728 100644 --- a/extensions/CCBReader/CCBReader.h +++ b/extensions/CCBReader/CCBReader.h @@ -6,7 +6,7 @@ #include #include #include "CCBSequence.h" - +#include "GUI/CCControlExtension/CCControl.h" #define CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ T * ptr = new T(); \ @@ -187,28 +187,29 @@ public: float readFloat(); std::string readCachedString(); bool isJSControlled(); - bool readCallbackKeyframesForSeq(CCBSequence* seq); bool readSoundKeyframesForSeq(CCBSequence* seq); - - Array* getOwnerCallbackNames(); Array* getOwnerCallbackNodes(); + Array* getOwnerCallbackControlEvents(); + Array* getOwnerOutletNames(); Array* getOwnerOutletNodes(); Array* getNodesWithAnimationManagers(); Array* getAnimationManagersForNodes(); - + Dictionary* getAnimationManagers(); void setAnimationManagers(Dictionary* x); // weak reference - void addOwnerCallbackName(std::string name); + void addOwnerCallbackName(const std::string& name); 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 addDocumentCallbackControlEvents(Control::EventType eventType); static float getResolutionScale(); static void setResolutionScale(float scale); @@ -232,6 +233,8 @@ private: bool getBit(); void alignBits(); + bool init(); + friend class NodeLoader; private: @@ -262,12 +265,10 @@ private: std::vector _ownerCallbackNames; Array* _ownerCallbackNodes; + Array* _ownerOwnerCallbackControlEvents; std::string _CCBRootPath; bool _jsControlled; - - bool _hasScriptingOwner; - bool init(); }; // end of effects group diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index de877acfe2..2c6ec045f8 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -800,14 +800,22 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead } else { CCLOG("Unexpected NULL target for selector."); } - } else { - if(selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) { + } + else + { + if (selectorTarget == CCBReader::TargetType::DOCUMENT_ROOT) + { ccbReader->addDocumentCallbackNode(pNode); ccbReader->addDocumentCallbackName(selectorName); - - } else { + // Since there isn't a Control::EventType::NONE, add a TOUCH_DOWN type as a placeholder. + ccbReader->addDocumentCallbackControlEvents(Control::EventType::TOUCH_DOWN); + } + else if (selectorTarget == CCBReader::TargetType::OWNER) + { ccbReader->addOwnerCallbackNode(pNode); 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->addDocumentCallbackName(selectorName); - + ccbReader->addDocumentCallbackControlEvents((Control::EventType)controlEvents); } else { ccbReader->addOwnerCallbackNode(pNode); 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 && NULL != ownerCallbackNodes && ownerCallbackNodes->count() > 0) { - assert(ownerCallbackNames->count() == ownerCallbackNodes->count()); + CCASSERT(ownerCallbackNames->count() == ownerCallbackNodes->count(), ""); int nCount = ownerCallbackNames->count(); - for (int i = 0 ; i < nCount; i++) { + + for (int i = 0 ; i < nCount; i++) + { pCCBReader->addOwnerCallbackName((dynamic_cast(ownerCallbackNames->objectAtIndex(i)))->getCString()); - pCCBReader->addOwnerCallbackNode(dynamic_cast(ownerCallbackNames->objectAtIndex(i)) ); + pCCBReader->addOwnerCallbackNode(dynamic_cast(ownerCallbackNodes->objectAtIndex(i)) ); } } //set variables @@ -966,11 +977,13 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader if (NULL != ownerOutletNames && ownerOutletNames->count() > 0 && NULL != ownerOutletNodes && ownerOutletNodes->count() > 0) { - assert(ownerOutletNames->count() == ownerOutletNodes->count()); + CCASSERT(ownerOutletNames->count() == ownerOutletNodes->count(), ""); int nCount = ownerOutletNames->count(); - for (int i = 0 ; i < nCount; i++) { - pCCBReader->addOwnerOutletName((dynamic_cast(ownerOutletNames->objectAtIndex(i)))->getCString()); - pCCBReader->addOwnerOutletNode(dynamic_cast(ownerOutletNodes->objectAtIndex(i)) ); + + for (int i = 0 ; i < nCount; i++) + { + pCCBReader->addOwnerOutletName((static_cast(ownerOutletNames->objectAtIndex(i)))->getCString()); + pCCBReader->addOwnerOutletNode(static_cast(ownerOutletNodes->objectAtIndex(i))); } } } From a34c70d2534d3e0c0204fd4ece8a9b5180b28db7 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 12 Aug 2013 11:19:21 +0800 Subject: [PATCH 03/10] issue #2521: Fixing a logical error in CCBReader::addOwnerOutletNode. 'NULL != node' --> 'NULL == node'. --- extensions/CCBReader/CCBReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index a4a6bf7811..b0d98e1fa5 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -1081,7 +1081,7 @@ void CCBReader::addOwnerOutletName(std::string name) void CCBReader::addOwnerOutletNode(Node *node) { - if (NULL != node) + if (NULL == node) return; _ownerOutletNodes->addObject(node); From 86fef75963bc8ed78a647e161797cf2974d953d1 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 12 Aug 2013 11:20:48 +0800 Subject: [PATCH 04/10] issue #2521: Removing an unused method ControlStepper::setValue(double value, bool send); since it's not implemented and there is an similar method 'setValueWithSendingEvent' could replace it. --- extensions/GUI/CCControlExtension/CCControlStepper.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCControlStepper.h b/extensions/GUI/CCControlExtension/CCControlStepper.h index 535ee2d928..51f68165a7 100644 --- a/extensions/GUI/CCControlExtension/CCControlStepper.h +++ b/extensions/GUI/CCControlExtension/CCControlStepper.h @@ -63,6 +63,7 @@ public: virtual double getValue() const; 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 bool isContinuous() const; @@ -75,9 +76,6 @@ public: /** Update the layout of the stepper with the given touch 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. */ void startAutorepeat(); From 12ffdfc4fde5ca393b60d3af55a48e0667b154a4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 12 Aug 2013 11:21:31 +0800 Subject: [PATCH 05/10] issue #2521: TestJavascript needs ccbreader support. --- samples/Javascript/TestJavascript/Classes/AppDelegate.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index efb7ba7e43..916e9ea534 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -12,6 +12,7 @@ #include "jsb_opengl_registration.h" #include "XMLHTTPRequest.h" #include "jsb_websocket.h" +#include "js_bindings_ccbreader.h" USING_NS_CC; USING_NS_CC_EXT; @@ -50,7 +51,8 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(jsb_register_system); sc->addRegisterCallback(MinXmlHttpRequest::_js_register); sc->addRegisterCallback(register_jsb_websocket); - + sc->addRegisterCallback(register_CCBuilderReader); + sc->start(); ScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); From f0e0b7600b0f0ea72d3a61a82238afd69540110f Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 12 Aug 2013 11:22:15 +0800 Subject: [PATCH 06/10] issue #2521: Adding 'cc.convertColor3BtoHexString' in jsb_cocos2d.js. --- scripting/javascript/bindings/js/jsb_cocos2d.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripting/javascript/bindings/js/jsb_cocos2d.js b/scripting/javascript/bindings/js/jsb_cocos2d.js index 7fd6c142e7..80ddb0a066 100644 --- a/scripting/javascript/bindings/js/jsb_cocos2d.js +++ b/scripting/javascript/bindings/js/jsb_cocos2d.js @@ -133,6 +133,20 @@ cc._c4b = function( r, g, b, a ) 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 // From 7d3edde8f1b2b3e94a26412bffc1ad304f239180 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 12 Aug 2013 11:23:16 +0800 Subject: [PATCH 07/10] issue #2521: Updating tojs/cocos2dx_extension.ini, bind more CCControls. --- tools/tojs/cocos2dx_extension.ini | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/tojs/cocos2dx_extension.ini b/tools/tojs/cocos2dx_extension.ini index 6a31b61f3c..4c289463fb 100644 --- a/tools/tojs/cocos2dx_extension.ini +++ b/tools/tojs/cocos2dx_extension.ini @@ -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 # 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] # 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$], .*Delegate::[*], .*Loader.*::[*], - *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType], + *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV], EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], TableView::[create (g|s)etDataSource$ (g|s)etDelegate], - Control::[removeHandleOfControlEvent addHandleOfControlEvent] + Control::[removeHandleOfControlEvent addHandleOfControlEvent], + ControlUtils::[*], + ControlSwitchSprite::[*] rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager], CCBAnimationManager::[setCallFunc=setCallFuncForJSCallbackNamed] From 1af0db12f6a766a87ef3702ee8b7a357e293aa5f Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 12 Aug 2013 11:24:08 +0800 Subject: [PATCH 08/10] issue #2521: Reporting an error when the callback function is undefined in 'js_cocos2dx_setCallback'. --- .../javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 21918cfedd..6655e24fb3 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -a9b4d7898c51c7cc4c1e53fde4695cf85e32d796 \ No newline at end of file +d17c1939227c62cebcc30a071cf81b12bfa08db3 \ No newline at end of file From 05534e87f4861a16e93a8143d6b18e52920c0f38 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 12 Aug 2013 11:27:09 +0800 Subject: [PATCH 09/10] closed #2521: Updating jsb_cocosbuilder.js, it supports CCControl now. --- .../bindings/js/jsb_cocosbuilder.js | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/scripting/javascript/bindings/js/jsb_cocosbuilder.js b/scripting/javascript/bindings/js/jsb_cocosbuilder.js index 4dbc061c9b..f748486286 100644 --- a/scripting/javascript/bindings/js/jsb_cocosbuilder.js +++ b/scripting/javascript/bindings/js/jsb_cocosbuilder.js @@ -40,7 +40,22 @@ cc.BuilderReader.load = function(file, owner, parentSize) var callbackName = ownerCallbackNames[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 @@ -86,7 +101,22 @@ cc.BuilderReader.load = function(file, owner, parentSize) var callbackName = documentCallbackNames[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 ); return scene; -}; \ No newline at end of file +}; From 9cf3bf64d58c469d13b5360df1e82315910eaa95 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 12 Aug 2013 11:31:54 +0800 Subject: [PATCH 10/10] issue #2521: Updating JS-Test. --- samples/Javascript/Shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Javascript/Shared b/samples/Javascript/Shared index dddaff578b..4a4179ed52 160000 --- a/samples/Javascript/Shared +++ b/samples/Javascript/Shared @@ -1 +1 @@ -Subproject commit dddaff578b31436a0a18c7420428e91e7d9d2df4 +Subproject commit 4a4179ed52d2236a3c2780456b77c24a600bfe3e