diff --git a/AUTHORS b/AUTHORS index 04d52c0ee3..c37354a317 100644 --- a/AUTHORS +++ b/AUTHORS @@ -721,6 +721,9 @@ Developers: hbbalfred Fixed a bug that crash if file doesn't exist when using FileUtils::getStringFromFile. + + liang8305 + Use multiple processes according the number of cores to build android project Retired Core Developers: WenSheng Yang diff --git a/CHANGELOG b/CHANGELOG index c4a8ea7282..d2c95e4eca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,12 +1,14 @@ -cocos2d-x-3.0final ?.? ? +cocos2d-x-3.0beta2 ?.? ? [All] [NEW] DrawNode supports to draw triangle, quad bezier, cubic bezier. [NEW] Console: added the 'textures', 'fileutils dump' and 'config' commands [NEW] GLCache: glActiveTexture() is cached with GL::activeTexture(). All code MUST call the cached version in order to work correctly [NEW] Label: Uses a struct of TTF configuration for Label::createWithTTF to reduce parameters and make this interface more easily to use. [NEW] Label: Integrates LabelAtlas into new Label. + [NEW] Node: Added `setGlobalZOrder()`. Useful to change the Node's render order. Node::setZOrder() -> Node::setLocalZOrder() [NEW] Renderer: Added BatchCommand. This command is not "batchable" with other commands, but improves performance in about 10% - + [NEW] LuaBindings: Bindings-generator supports to bind namespace for lua. + [FIX] CocoStudio: TestColliderDetector in ArmatureTest can't work. [FIX] Crash if file doesn't exist when using FileUtils::getStringFromFile. [FIX] If setting a shorter string than before while using LabelAtlas, the effect will be wrong. @@ -16,9 +18,11 @@ cocos2d-x-3.0final ?.? ? [FIX] ControlSlider doesn't support to set selected thumb sprite. [FIX] ControlButton doesn't support to set scale ratio of touchdown state. [FIX] Particles: Crash was triggered if there is not `textureFileName`section in particle plist file. - [FIX] Renderer: QuadCommand::init() does not copy the Quads, it only store a reference making the code faster - [FIX] Renderer: Performance improved in Sprite and SpriteBatchNode (and subclasses) sprites in about 20% - [FIX] Renderer: When note using VAO, call glBufferData() instead of glBufferSubData(). + [FIX] Renderer: Uses a float as key with only the depth. Viewport, opaque are not needed now + [FIX] Renderer Performance Fix: QuadCommand::init() does not copy the Quads, it only store a reference making the code faster + [FIX] Renderer Performance Fix: Sprite and SpriteBatchNode (and subclasses) has much better performance + [FIX] Renderer Performance Fix: When note using VAO, call glBufferData() instead of glBufferSubData(). + [FIX] Renderer Performance Fix: Doesn't sort z=0 elements. It also uses sort() instead of stable_sort() for z!=0. [FIX] Sprite: removed _hasChildren optimization. It uses !_children.empty() now which is super fast as well [FIX] Tests: TestCpp works with CMake on Windows. [FIX] Tests: Sprites Performance Test has 4 new tests diff --git a/build/android-build.py b/build/android-build.py index 3285c690e9..0309cf008b 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -12,6 +12,16 @@ LUA_SAMPLES = ['hellolua', 'testlua'] JSB_SAMPLES = ['cocosdragon', 'crystalcraze', 'moonwarriors', 'testjavascript', 'watermelonwithme'] ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES + JSB_SAMPLES +def get_num_of_cpu(): + ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. + ''' + try: + from numpy.distutils import cpuinfo + return cpuinfo.cpu._getNCPUs() + except Exception: + print "Can't know cpuinfo, use default 1 cpu" + return 1 + def check_environment_variables(): ''' Checking the environment NDK_ROOT, which will be used for building ''' @@ -94,10 +104,12 @@ def do_build(cocos_root, ndk_root, app_android_root, ndk_build_param,sdk_root,an else: ndk_module_path = 'NDK_MODULE_PATH=%s:%s/external:%s/cocos' % (cocos_root, cocos_root, cocos_root) + num_of_cpu = get_num_of_cpu() if ndk_build_param == None: - command = '%s -C %s %s' % (ndk_path, app_android_root, ndk_module_path) + command = '%s -j%d -C %s %s' % (ndk_path, num_of_cpu, app_android_root, ndk_module_path) else: - command = '%s -C %s %s %s' % (ndk_path, app_android_root, ndk_build_param, ndk_module_path) + command = '%s -j%d -C %s %s %s' % (ndk_path, num_of_cpu, app_android_root, ndk_build_param, ndk_module_path) + print command if os.system(command) != 0: raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!") elif android_platform is not None: diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index b052741ae6..a520602c3d 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -e1e5a1169e92834330092c45165660c6cbd03609 \ No newline at end of file +63e6598ea5798bf42bbd22c2295e65f7c739695a \ No newline at end of file diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index bb3a11cb54..eac7e38de9 100644 --- a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -1fa58d8cba77ef923c83d2860d5511d28dad6c27 \ No newline at end of file +447e7ba37294e6da0df2e02f5a62f30fb15e3272 \ No newline at end of file diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index f86c143d78..15492a651f 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -152,8 +152,8 @@ void AtlasNode::draw(void) auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); - _quadCommand.init(0, - _vertexZ, + _quadCommand.init( + _globalZOrder, _textureAtlas->getTexture()->getName(), shader, _blendFunc, diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index f5bc3bf95d..f20b4d2778 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -210,12 +210,12 @@ void ClippingNode::visit() Renderer* renderer = Director::getInstance()->getRenderer(); - _groupCommand.init(0,_vertexZ); + _groupCommand.init(_globalZOrder); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); - _beforeVisitCmd.init(0,_vertexZ); + _beforeVisitCmd.init(_globalZOrder); _beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this); renderer->addCommand(&_beforeVisitCmd); if (_alphaThreshold < 1) @@ -238,7 +238,7 @@ void ClippingNode::visit() } _stencil->visit(); - _afterDrawStencilCmd.init(0,_vertexZ); + _afterDrawStencilCmd.init(_globalZOrder); _afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this); renderer->addCommand(&_afterDrawStencilCmd); @@ -268,7 +268,7 @@ void ClippingNode::visit() this->draw(); } - _afterVisitCmd.init(0,_vertexZ); + _afterVisitCmd.init(_globalZOrder); _afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this); renderer->addCommand(&_afterVisitCmd); diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 3432ad024f..003209b6e4 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -241,7 +241,7 @@ void DrawNode::render() void DrawNode::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(DrawNode::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 52f817ef7c..0cac300283 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -666,7 +666,7 @@ void Label::onDraw() void Label::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(Label::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 1b24c97f25..54b9c48cd9 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -565,7 +565,7 @@ void LayerColor::updateColor() void LayerColor::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index fdb0b70fb8..735a8edae2 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -359,7 +359,7 @@ void MotionStreak::draw() if(_nuPoints <= 1) return; kmGLGetMatrix(KM_GL_MODELVIEW,&_cachedMV); - _customCommand.init(0,_vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(MotionStreak::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 3b7ce1c47c..e631d0f02a 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -108,7 +108,8 @@ Node::Node(void) , _inverseDirty(true) // children (lazy allocs) // lazy alloc -, _ZOrder(0) +, _localZOrder(0) +, _globalZOrder(0) , _parent(nullptr) // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true , _tag(Node::INVALID_TAG) @@ -212,29 +213,22 @@ void Node::setSkewY(float newSkewY) _transformDirty = _inverseDirty = true; } -/// zOrder getter -int Node::getZOrder() const -{ - return _ZOrder; -} /// zOrder setter : private method /// used internally to alter the zOrder variable. DON'T call this method manually -void Node::_setZOrder(int z) +void Node::_setLocalZOrder(int z) { - _ZOrder = z; + _localZOrder = z; } -void Node::setZOrder(int z) +void Node::setLocalZOrder(int z) { + _localZOrder = z; if (_parent) { _parent->reorderChild(this, z); } - // should set "_ZOrder" after reorderChild, because the implementation of reorderChild subclass of Node, such as Sprite, - // will return when _ZOrder value is not changed - _setZOrder(z); - + _eventDispatcher->setDirtyForNode(this); } @@ -246,9 +240,10 @@ float Node::getVertexZ() const /// vertexZ setter -void Node::setVertexZ(float var) +void Node::setVertexZ(float zOrder) { - _vertexZ = var; + _vertexZ = zOrder; + setGlobalZOrder(zOrder); } @@ -650,7 +645,7 @@ void Node::addChild(Node *child, int zOrder) void Node::addChild(Node *child) { CCASSERT( child != nullptr, "Argument must be non-nil"); - this->addChild(child, child->_ZOrder, child->_tag); + this->addChild(child, child->_localZOrder, child->_tag); } void Node::removeFromParent() @@ -767,7 +762,7 @@ void Node::insertChild(Node* child, int z) { _reorderChildDirty = true; _children.pushBack(child); - child->_setZOrder(z); + child->_setLocalZOrder(z); } void Node::reorderChild(Node *child, int zOrder) @@ -775,7 +770,7 @@ void Node::reorderChild(Node *child, int zOrder) CCASSERT( child != nullptr, "Child must be non-nil"); _reorderChildDirty = true; child->setOrderOfArrival(s_globalOrderOfArrival++); - child->_setZOrder(zOrder); + child->_setLocalZOrder(zOrder); } void Node::sortAllChildren() @@ -816,7 +811,7 @@ void Node::visit() { auto node = _children.at(i); - if ( node && node->_ZOrder < 0 ) + if ( node && node->_localZOrder < 0 ) node->visit(); else break; diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 3069fb0a84..0598773a7c 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -161,43 +161,72 @@ public: /// @name Setters & Getters for Graphic Peroperties /** - * Sets the Z order which stands for the drawing order, and reorder this node in its parent's children array. - * - * The Z order of node is relative to its siblings. - * It is not related to the OpenGL's z property. This one only affects the draw order of itself and its siblings. - * Lower Z order number are drawn before higher numbers. - * Please refer to `setVertexZ(float)` for the difference. - * - * @param zOrder Z order of this node. + LocalZOrder is the 'key' used to sort the node relative to its siblings. + + The Node's parent will sort all its children based ont the LocalZOrder value. + If two nodes have the same LocalZOrder, then the node that was added first to the children's array will be in front of the other node in the array. + + Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) + And Nodes that have LocalZOder values < 0 are the "left" subtree + While Nodes with LocalZOder >=0 are the "right" subtree. + + @see `setGlobalZOrder` + @see `setVertexZ` */ - virtual void setZOrder(int zOrder); - /* - * Sets the z order which stands for the drawing order - * - * This is an internal method. Don't call it outside the framework. - * The difference between setZOrder(int) and _setOrder(int) is: - * - _setZOrder(int) is a pure setter for _ZOrder memeber variable - * - setZOrder(int) firstly changes _ZOrder, then recorder this node in its parent's chilren array. + virtual void setLocalZOrder(int zOrder); + + CC_DEPRECATED_ATTRIBUTE virtual void setZOrder(int zOrder) { setLocalZOrder(zOrder); } + /* Helper function used by `setLocalZOrder`. Don't use it unless you know what you are doing. */ - virtual void _setZOrder(int z); + virtual void _setLocalZOrder(int z); /** - * Gets the Z order of this node. + * Gets the local Z order of this node. * - * @see `setZOrder(int)` + * @see `setLocalZOrder(int)` * - * @return The Z order. + * @return The local (relative to its siblings) Z order. */ - virtual int getZOrder() const; + virtual int getLocalZOrder() const { return _localZOrder; } + CC_DEPRECATED_ATTRIBUTE virtual int getZOrder() const { return getLocalZOrder(); } /** - * Sets the real OpenGL Z vertex. + Defines the oder in which the nodes are renderer. + Nodes that have a Global Z Order lower, are renderer first. + + In case two or more nodes have the same Global Z Order, the oder is not guaranteed. + The only exception if the Nodes have a Global Z Order == 0. In that case, the Scene Graph order is used. + + By default, all nodes have a Global Z Order = 0. That means that by default, the Scene Graph order is used to render the nodes. + + Global Z Order is useful when you need to render nodes in an order different than the Scene Graph order. + + Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their acenstors. + And if ClippingNode is one of the ancestors, then "global Z order" will be relative to the ClippingNode. + + @see `setLocalZOrder()` + @see `setVertexZ()` + + @since v3.0 + */ + virtual void setGlobalZOrder(float zOrder) { _globalZOrder = zOrder; } + /** + * Returns the Node's Global Z Order. * - * Differences between openGL Z vertex and cocos2d Z order: - * - OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children - * - OpenGL Z might require to set 2D projection - * - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: `vertexZ = 0` + * @see `setGlobalZOrder(int)` * - * @warning Use it at your own risk since it might break the cocos2d parent-children z order + * @return The node's global Z order + */ + virtual float getGlobalZOrder() const { return _globalZOrder; } + + /** + * Sets the 'z' value in the OpenGL Depth Buffer. + * + * The OpenGL depth buffer and depth testing are disabled by default. You need to turn them on + * in order to use this property correctly. + * + * `setVertexZ()` also sets the `setGlobalZValue()` with the vertexZ value. + * + * @see `setGlobalZValue()` * * @param vertexZ OpenGL Z vertex of this node. */ @@ -1411,7 +1440,6 @@ protected: float _scaleX; ///< scaling factor on x-axis float _scaleY; ///< scaling factor on y-axis - float _vertexZ; ///< OpenGL real Z vertex Point _position; ///< position of the node @@ -1433,8 +1461,12 @@ protected: mutable bool _transformDirty; ///< transform dirty flag mutable bool _inverseDirty; ///< inverse transform dirty flag - int _ZOrder; ///< z-order value that affects the draw order - + + int _localZOrder; ///< Local order (relative to its siblings) used to sort the node + float _globalZOrder; ///< Global order used to sort the node + float _vertexZ; ///< OpenGL real Z vertex + + Vector _children; ///< array of children nodes Node *_parent; ///< weak reference to parent node diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index 9c24500da0..f8c5d5accb 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -92,7 +92,7 @@ void NodeGrid::visit() Renderer* renderer = Director::getInstance()->getRenderer(); - _groupCommand.init(0,_vertexZ); + _groupCommand.init(_globalZOrder); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); @@ -104,7 +104,7 @@ void NodeGrid::visit() _nodeGrid->set2DProjection(); } - _gridBeginCommand.init(0,_vertexZ); + _gridBeginCommand.init(_globalZOrder); _gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this); renderer->addCommand(&_gridBeginCommand); @@ -152,7 +152,7 @@ void NodeGrid::visit() director->setProjection(beforeProjectionType); } - _gridEndCommand.init(0,_vertexZ); + _gridEndCommand.init(_globalZOrder); _gridEndCommand.func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this); renderer->addCommand(&_gridEndCommand); diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index b291910422..bca1c3eb28 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -197,7 +197,7 @@ int ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int aTag) _children.insert(pos, child); child->setTag(aTag); - child->_setZOrder(z); + child->_setLocalZOrder(z); child->setParent(this); @@ -264,7 +264,7 @@ void ParticleBatchNode::reorderChild(Node * aChild, int zOrder) } } - child->_setZOrder(zOrder); + child->_setLocalZOrder(zOrder); } void ParticleBatchNode::getCurrentIndex(int* oldIndex, int* newIndex, Node* child, int z) @@ -382,8 +382,8 @@ void ParticleBatchNode::draw(void) return; } - _batchCommand.init(0, - _vertexZ, + _batchCommand.init( + _globalZOrder, _textureAtlas->getTexture()->getName(), _shaderProgram, _blendFunc, diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 8495483116..bd4bef3599 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -439,7 +439,7 @@ void ParticleSystemQuad::draw() auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); - _quadCommand.init(0, _vertexZ, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform); + _quadCommand.init(_globalZOrder, _texture->getName(), shader, _blendFunc, _quads, _particleIdx, _modelViewTransform); Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index 37c754a0ee..112b34d85b 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -555,7 +555,7 @@ void ProgressTimer::draw() if( ! _vertexData || ! _sprite) return; - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(ProgressTimer::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index fcf00452ed..57b6a00d24 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -322,7 +322,7 @@ void RenderTexture::beginWithClear(float r, float g, float b, float a, float dep this->begin(); //clear screen - _beginWithClearCommand.init(0, _vertexZ); + _beginWithClearCommand.init(_globalZOrder); _beginWithClearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this); Director::getInstance()->getRenderer()->addCommand(&_beginWithClearCommand); } @@ -340,7 +340,7 @@ void RenderTexture::clearDepth(float depthValue) this->begin(); - _clearDepthCommand.init(0, _vertexZ); + _clearDepthCommand.init(_globalZOrder); _clearDepthCommand.func = CC_CALLBACK_0(RenderTexture::onClearDepth, this); Director::getInstance()->getRenderer()->addCommand(&_clearDepthCommand); @@ -605,7 +605,7 @@ void RenderTexture::draw() begin(); //clear screen - _clearCommand.init(0, _vertexZ); + _clearCommand.init(_globalZOrder); _clearCommand.func = CC_CALLBACK_0(RenderTexture::onClear, this); Director::getInstance()->getRenderer()->addCommand(&_clearCommand); @@ -648,13 +648,13 @@ void RenderTexture::begin() (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 ); kmGLMultMatrix(&orthoMatrix); - _groupCommand.init(0, _vertexZ); + _groupCommand.init(_globalZOrder); Renderer *renderer = Director::getInstance()->getRenderer(); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); - _beginCommand.init(0, _vertexZ); + _beginCommand.init(_globalZOrder); _beginCommand.func = CC_CALLBACK_0(RenderTexture::onBegin, this); Director::getInstance()->getRenderer()->addCommand(&_beginCommand); @@ -662,7 +662,7 @@ void RenderTexture::begin() void RenderTexture::end() { - _endCommand.init(0, _vertexZ); + _endCommand.init(_globalZOrder); _endCommand.func = CC_CALLBACK_0(RenderTexture::onEnd, this); Renderer *renderer = Director::getInstance()->getRenderer(); diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index c66c811b1b..65c7a24b50 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -670,7 +670,7 @@ void Sprite::updateTransform(void) void Sprite::draw(void) { //TODO implement z order - _quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform); + _quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, _modelViewTransform); // if(culling()) { @@ -769,13 +769,8 @@ void Sprite::addChild(Node *child, int zOrder, int tag) void Sprite::reorderChild(Node *child, int zOrder) { - CCASSERT(child != nullptr, ""); - CCASSERT(_children.contains(child), ""); - - if (zOrder == child->getZOrder()) - { - return; - } + CCASSERT(child != nullptr, "child must be non null"); + CCASSERT(_children.contains(child), "child does not belong to this"); if( _batchNode && ! _reorderChildDirty) { diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index fde85639aa..0526b6768d 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -356,8 +356,8 @@ void SpriteBatchNode::draw() for(const auto &child: _children) child->updateTransform(); - _batchCommand.init(0, - _vertexZ, + _batchCommand.init( + _globalZOrder, _textureAtlas->getTexture()->getName(), _shaderProgram, _blendFunc, diff --git a/cocos/2d/CCTMXTiledMap.cpp b/cocos/2d/CCTMXTiledMap.cpp index 33a4b77519..54fecd658b 100644 --- a/cocos/2d/CCTMXTiledMap.cpp +++ b/cocos/2d/CCTMXTiledMap.cpp @@ -174,7 +174,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo) if (layerInfo->_visible) { TMXLayer *child = parseLayer(layerInfo, mapInfo); - addChild((Node*)child, idx, idx); + addChild(child, idx, idx); // update content size with the max size const Size& childSize = child->getContentSize(); diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index 7ade9878a4..7e4102b009 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -98,23 +98,23 @@ void TransitionPageTurn::draw() if( _isInSceneOnTop ) { _outSceneProxy->visit(); - _enableOffsetCmd.init(0, _vertexZ); + _enableOffsetCmd.init(_globalZOrder); _enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd); _inSceneProxy->visit(); - _disableOffsetCmd.init(0, _vertexZ); + _disableOffsetCmd.init(_globalZOrder); _disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd); } else { _inSceneProxy->visit(); - _enableOffsetCmd.init(0, _vertexZ); + _enableOffsetCmd.init(_globalZOrder); _enableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onEnablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_enableOffsetCmd); _outSceneProxy->visit(); - _disableOffsetCmd.init(0, _vertexZ); + _disableOffsetCmd.init(_globalZOrder); _disableOffsetCmd.func = CC_CALLBACK_0(TransitionPageTurn::onDisablePolygonOffset, this); Director::getInstance()->getRenderer()->addCommand(&_disableOffsetCmd); } diff --git a/cocos/2d/renderer/CCBatchCommand.cpp b/cocos/2d/renderer/CCBatchCommand.cpp index de3fc511cd..b9b0c7fab9 100644 --- a/cocos/2d/renderer/CCBatchCommand.cpp +++ b/cocos/2d/renderer/CCBatchCommand.cpp @@ -30,9 +30,7 @@ NS_CC_BEGIN BatchCommand::BatchCommand() -: _viewport(0) -, _depth(0) -, _textureID(0) +: _textureID(0) , _blendType(BlendFunc::DISABLE) , _textureAtlas(nullptr) { @@ -40,10 +38,9 @@ BatchCommand::BatchCommand() _shader = nullptr; } -void BatchCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform) +void BatchCommand::init(float globalOrder, GLuint textureID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform) { - _viewport = viewport; - _depth = depth; + _globalOrder = globalOrder; _textureID = textureID; _blendType = blendType; _shader = shader; @@ -57,59 +54,6 @@ BatchCommand::~BatchCommand() { } -int64_t BatchCommand::generateID() -{ - _id = 0; - - //Generate Material ID - //TODO fix shader ID generation - CCASSERT(_shader->getProgram() < pow(2,10), "ShaderID is greater than 2^10"); - //TODO fix texture ID generation - CCASSERT(_textureID < pow(2,18), "TextureID is greater than 2^18"); - - //TODO fix blend id generation - int blendID = 0; - if(_blendType == BlendFunc::DISABLE) - { - blendID = 0; - } - else if(_blendType == BlendFunc::ALPHA_PREMULTIPLIED) - { - blendID = 1; - } - else if(_blendType == BlendFunc::ALPHA_NON_PREMULTIPLIED) - { - blendID = 2; - } - else if(_blendType == BlendFunc::ADDITIVE) - { - blendID = 3; - } - else - { - blendID = 4; - } - - //TODO Material ID should be part of the ID - // - // Temporal hack (later, these 32-bits should be packed in 24-bits - // - // +---------------------+-------------------+----------------------+ - // | Shader ID (10 bits) | Blend ID (4 bits) | Texture ID (18 bits) | - // +---------------------+-------------------+----------------------+ - - _materialID = (int32_t)_shader->getProgram() << 22 - | (int32_t)blendID << 18 - | (int32_t)_textureID << 0; - - //Generate RenderCommandID - _id = (int64_t)_viewport << 61 - | (int64_t)1 << 60 //translucent - | (int64_t)_depth << 36; - - return _id; -} - void BatchCommand::execute() { // Set material diff --git a/cocos/2d/renderer/CCBatchCommand.h b/cocos/2d/renderer/CCBatchCommand.h index d3b2a5245e..9ac5b346ee 100644 --- a/cocos/2d/renderer/CCBatchCommand.h +++ b/cocos/2d/renderer/CCBatchCommand.h @@ -43,26 +43,13 @@ public: BatchCommand(); ~BatchCommand(); - void init(int viewport, int32_t depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform); - - // +----------+----------+-----+-----------------------------------+ - // | | | | | | - // | ViewPort | Transluc | | Depth | Material ID | - // | 3 bits | 1 bit | | 24 bits | 24 bit2 | - // +----------+----------+-----+----------------+------------------+ - virtual int64_t generateID(); + void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, TextureAtlas *textureAtlas, const kmMat4& modelViewTransform); void execute(); protected: int32_t _materialID; - //Key Data - int _viewport; /// Which view port it belongs to - - //TODO use material to determine if it's translucent - int32_t _depth; - //Maternal GLuint _textureID; diff --git a/cocos/2d/renderer/CCCustomCommand.cpp b/cocos/2d/renderer/CCCustomCommand.cpp index 5bbf2032ea..c324032116 100644 --- a/cocos/2d/renderer/CCCustomCommand.cpp +++ b/cocos/2d/renderer/CCCustomCommand.cpp @@ -28,16 +28,13 @@ NS_CC_BEGIN CustomCommand::CustomCommand() : func(nullptr) -, _viewport(0) -, _depth(0) { _type = RenderCommand::Type::CUSTOM_COMMAND; } -void CustomCommand::init(int viewport, int32_t depth) +void CustomCommand::init(float globalOrder) { - _viewport = viewport; - _depth = depth; + _globalOrder = globalOrder; } CustomCommand::~CustomCommand() @@ -45,17 +42,6 @@ CustomCommand::~CustomCommand() } -int64_t CustomCommand::generateID() -{ - _id = 0; - - _id = (int64_t)_viewport << 61 - | (int64_t)1 << 60 // translucent - | (int64_t)_depth << 36; - - return _id; -} - void CustomCommand::execute() { if(func) diff --git a/cocos/2d/renderer/CCCustomCommand.h b/cocos/2d/renderer/CCCustomCommand.h index 7ff4c3e3ca..03fdead69a 100644 --- a/cocos/2d/renderer/CCCustomCommand.h +++ b/cocos/2d/renderer/CCCustomCommand.h @@ -39,14 +39,7 @@ public: public: - void init(int viewport, int32_t depth); - - // +----------+----------+-----+-----------------------------------+ - // | | | | | | - // | ViewPort | Transluc | | Depth | | - // | 3 bits | 1 bit | | 24 bits | | - // +----------+----------+-----+----------------+------------------+ - virtual int64_t generateID(); + void init(float depth); void execute(); @@ -54,8 +47,6 @@ public: std::function func; protected: - int _viewport; - int32_t _depth; }; NS_CC_END diff --git a/cocos/2d/renderer/CCGroupCommand.cpp b/cocos/2d/renderer/CCGroupCommand.cpp index 9c0e57eb92..95b9a5ccb5 100644 --- a/cocos/2d/renderer/CCGroupCommand.cpp +++ b/cocos/2d/renderer/CCGroupCommand.cpp @@ -86,17 +86,14 @@ void GroupCommandManager::releaseGroupID(int groupID) } GroupCommand::GroupCommand() -: _viewport(0) -, _depth(0) { _type = RenderCommand::Type::GROUP_COMMAND; _renderQueueID = GroupCommandManager::getInstance()->getGroupID(); } -void GroupCommand::init(int viewport, int32_t depth) +void GroupCommand::init(float globalOrder) { - _viewport = viewport; - _depth = depth; + _globalOrder = globalOrder; GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID); _renderQueueID = GroupCommandManager::getInstance()->getGroupID(); } @@ -106,15 +103,4 @@ GroupCommand::~GroupCommand() GroupCommandManager::getInstance()->releaseGroupID(_renderQueueID); } -int64_t GroupCommand::generateID() -{ - _id = 0; - - _id = (int64_t)_viewport << 61 - | (int64_t)1 << 60 // translucent - | (int64_t)_depth << 36; - - return _id; -} - NS_CC_END diff --git a/cocos/2d/renderer/CCGroupCommand.h b/cocos/2d/renderer/CCGroupCommand.h index 7a6b6e511c..42c23d02b9 100644 --- a/cocos/2d/renderer/CCGroupCommand.h +++ b/cocos/2d/renderer/CCGroupCommand.h @@ -56,23 +56,11 @@ public: GroupCommand(); ~GroupCommand(); -public: + void init(float depth); - void init(int viewport, int32_t depth); - - // +----------+----------+-----+-----------------------------------+ - // | | | | | | - // | ViewPort | Transluc | | Depth | | - // | 3 bits | 1 bit | | 24 bits | | - // +----------+----------+-----+----------------+------------------+ - virtual int64_t generateID() override; - - inline bool isTranslucent() {return true;} - inline int getRenderQueueID() {return _renderQueueID;} + inline int getRenderQueueID() const {return _renderQueueID;} protected: - int _viewport; - int32_t _depth; int _renderQueueID; }; diff --git a/cocos/2d/renderer/CCQuadCommand.cpp b/cocos/2d/renderer/CCQuadCommand.cpp index a19e3f7053..9cae10d701 100644 --- a/cocos/2d/renderer/CCQuadCommand.cpp +++ b/cocos/2d/renderer/CCQuadCommand.cpp @@ -29,9 +29,7 @@ NS_CC_BEGIN QuadCommand::QuadCommand() -:_viewport(0) -,_depth(0) -,_textureID(0) +:_textureID(0) ,_blendType(BlendFunc::DISABLE) ,_quadsCount(0) { @@ -40,10 +38,9 @@ QuadCommand::QuadCommand() _quads = nullptr; } -void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv) +void QuadCommand::init(float globalOrder, GLuint textureID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quad, ssize_t quadCount, const kmMat4 &mv) { - _viewport = viewport; - _depth = depth; + _globalOrder = globalOrder; _textureID = textureID; _blendType = blendType; _shader = shader; @@ -52,16 +49,16 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* _quads = quad; _mv = mv; + + generateMaterialID(); } QuadCommand::~QuadCommand() { } -int64_t QuadCommand::generateID() +void QuadCommand::generateMaterialID() { - _id = 0; - //Generate Material ID //TODO fix shader ID generation CCASSERT(_shader->getProgram() < pow(2,10), "ShaderID is greater than 2^10"); @@ -99,19 +96,12 @@ int64_t QuadCommand::generateID() // | Shader ID (10 bits) | Blend ID (4 bits) | Texture ID (18 bits) | // +---------------------+-------------------+----------------------+ - _materialID = (int32_t)_shader->getProgram() << 22 - | (int32_t)blendID << 18 - | (int32_t)_textureID << 0; - - //Generate RenderCommandID - _id = (int64_t)_viewport << 61 - | (int64_t)1 << 60 //translucent - | (int64_t)_depth << 36; - - return _id; + _materialID = (uint32_t)_shader->getProgram() << 22 + | (uint32_t)blendID << 18 + | (uint32_t)_textureID << 0; } -void QuadCommand::useMaterial() +void QuadCommand::useMaterial() const { _shader->use(); diff --git a/cocos/2d/renderer/CCQuadCommand.h b/cocos/2d/renderer/CCQuadCommand.h index 1837919c8d..42411f48e9 100644 --- a/cocos/2d/renderer/CCQuadCommand.h +++ b/cocos/2d/renderer/CCQuadCommand.h @@ -41,21 +41,15 @@ public: QuadCommand(); ~QuadCommand(); - void init(int viewport, int32_t depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount, + void init(float depth, GLuint texutreID, GLProgram* shader, BlendFunc blendType, V3F_C4B_T2F_Quad* quads, ssize_t quadCount, const kmMat4& mv); - // +----------+----------+-----+-----------------------------------+ - // | | | | | | - // | ViewPort | Transluc | | Depth | Material ID | - // | 3 bits | 1 bit | | 24 bits | 24 bit2 | - // +----------+----------+-----+----------------+------------------+ - virtual int64_t generateID(); - - void useMaterial(); + void useMaterial() const; //TODO use material to decide if it is translucent inline bool isTranslucent() const { return true; } + void generateMaterialID(); inline uint32_t getMaterialID() const { return _materialID; } inline GLuint getTextureID() const { return _textureID; } @@ -73,12 +67,6 @@ public: protected: uint32_t _materialID; - //Key Data - int _viewport; /// Which view port it belongs to - - //TODO use material to determine if it's translucent - int32_t _depth; - //Maternal GLuint _textureID; diff --git a/cocos/2d/renderer/CCRenderCommand.cpp b/cocos/2d/renderer/CCRenderCommand.cpp index 71fee4edb0..578f28d426 100644 --- a/cocos/2d/renderer/CCRenderCommand.cpp +++ b/cocos/2d/renderer/CCRenderCommand.cpp @@ -28,9 +28,9 @@ NS_CC_BEGIN RenderCommand::RenderCommand() +: _type(RenderCommand::Type::UNKNOWN_COMMAND) +, _globalOrder(0) { - _id = 0; - _type = RenderCommand::Type::UNKNOWN_COMMAND; } RenderCommand::~RenderCommand() @@ -57,9 +57,7 @@ void printBits(ssize_t const size, void const * const ptr) void RenderCommand::printID() { - printf("CommandID: "); - printBits(sizeof(_id), &_id); - printf("\n"); + printf("Command Depth: %f\n", _globalOrder); } NS_CC_END \ No newline at end of file diff --git a/cocos/2d/renderer/CCRenderCommand.h b/cocos/2d/renderer/CCRenderCommand.h index 57fa2e75ce..688f65feb7 100644 --- a/cocos/2d/renderer/CCRenderCommand.h +++ b/cocos/2d/renderer/CCRenderCommand.h @@ -33,7 +33,9 @@ NS_CC_BEGIN -//TODO make RenderCommand inherent from Object +/** Base class of the RenderCommand hierarchy. + The Renderer knows how to render RenderCommands. + */ class RenderCommand { public: @@ -47,13 +49,11 @@ public: GROUP_COMMAND, }; - virtual int64_t generateID() = 0; - /** Get Render Command Id */ - inline int64_t getID() { return _id; } + inline float getGlobalOrder() const { return _globalOrder; } /** Returns the Command type */ - inline Type getType() { return _type; } + inline Type getType() const { return _type; } protected: RenderCommand(); @@ -61,9 +61,11 @@ protected: void printID(); - //Generated IDs - int64_t _id; /// used for sorting render commands + // Type used in order to avoid dynamic cast, faster Type _type; + + // commands are sort by depth + float _globalOrder; }; NS_CC_END diff --git a/cocos/2d/renderer/CCRenderer.cpp b/cocos/2d/renderer/CCRenderer.cpp index df7d41473a..6642ddfd6c 100644 --- a/cocos/2d/renderer/CCRenderer.cpp +++ b/cocos/2d/renderer/CCRenderer.cpp @@ -34,12 +34,68 @@ #include "CCEventDispatcher.h" #include "CCEventListenerCustom.h" #include "CCEventType.h" -#include // for std::stable_sort +#include NS_CC_BEGIN -using namespace std; + +bool compareRenderCommand(RenderCommand* a, RenderCommand* b) +{ + return a->getGlobalOrder() < b->getGlobalOrder(); +} + +void RenderQueue::push_back(RenderCommand* command) +{ + float z = command->getGlobalOrder(); + if(z < 0) + _queueNegZ.push_back(command); + else if(z > 0) + _queuePosZ.push_back(command); + else + _queue0.push_back(command); +} + +ssize_t RenderQueue::size() const +{ + return _queueNegZ.size() + _queue0.size() + _queuePosZ.size(); +} + +void RenderQueue::sort() +{ + // Don't sort _queue0, it already comes sorted + std::sort(std::begin(_queueNegZ), std::end(_queueNegZ), compareRenderCommand); + std::sort(std::begin(_queuePosZ), std::end(_queuePosZ), compareRenderCommand); +} + +RenderCommand* RenderQueue::operator[](ssize_t index) const +{ + if(index < _queueNegZ.size()) + return _queueNegZ[index]; + + index -= _queueNegZ.size(); + + if(index < _queue0.size()) + return _queue0[index]; + + index -= _queue0.size(); + + if(index < _queuePosZ.size()) + return _queuePosZ[index]; + + CCASSERT(false, "invalid index"); + return nullptr; +} + +void RenderQueue::clear() +{ + _queueNegZ.clear(); + _queue0.clear(); + _queuePosZ.clear(); +} +// +// +// #define DEFAULT_RENDER_QUEUE 0 Renderer::Renderer() @@ -185,8 +241,6 @@ void Renderer::addCommand(RenderCommand* command, int renderQueue) { CCASSERT(renderQueue >=0, "Invalid render queue"); CCASSERT(command->getType() != RenderCommand::Type::UNKNOWN_COMMAND, "Invalid Command Type"); - - command->generateID(); _renderGroups[renderQueue].push_back(command); } @@ -207,11 +261,6 @@ int Renderer::createRenderQueue() return (int)_renderGroups.size() - 1; } -bool compareRenderCommand(RenderCommand* a, RenderCommand* b) -{ - return a->getID() < b->getID(); -} - void Renderer::render() { //Uncomment this once everything is rendered by new renderer @@ -223,9 +272,9 @@ void Renderer::render() { //Process render commands //1. Sort render commands based on ID - for (auto it = _renderGroups.begin(); it != _renderGroups.end(); ++it) + for (auto &renderqueue : _renderGroups) { - std::stable_sort((*it).begin(), (*it).end(), compareRenderCommand); + renderqueue.sort(); } while(!_renderStack.empty()) @@ -246,7 +295,7 @@ void Renderer::render() if(commandType == RenderCommand::Type::QUAD_COMMAND) { - QuadCommand* cmd = static_cast(command); + auto cmd = static_cast(command); ssize_t cmdQuadCount = cmd->getQuadCount(); //Batch quads @@ -268,19 +317,19 @@ void Renderer::render() else if(commandType == RenderCommand::Type::CUSTOM_COMMAND) { flush(); - CustomCommand* cmd = static_cast(command); + auto cmd = static_cast(command); cmd->execute(); } else if(commandType == RenderCommand::Type::BATCH_COMMAND) { flush(); - BatchCommand* cmd = static_cast(command); + auto cmd = static_cast(command); cmd->execute(); } else if(commandType == RenderCommand::Type::GROUP_COMMAND) { flush(); - GroupCommand* cmd = static_cast(command); + auto cmd = static_cast(command); _renderStack.top().currentIndex = i + 1; @@ -415,10 +464,10 @@ void Renderer::drawBatchedQuads() //Start drawing verties in batch for(ssize_t i = _firstCommand; i <= _lastCommand; i++) { - RenderCommand* command = _renderGroups[_renderStack.top().renderQueueID][i]; + auto command = _renderGroups[_renderStack.top().renderQueueID][i]; if (command->getType() == RenderCommand::Type::QUAD_COMMAND) { - QuadCommand* cmd = static_cast(command); + auto cmd = static_cast(command); if(_lastMaterialID != cmd->getMaterialID()) { //Draw quads diff --git a/cocos/2d/renderer/CCRenderer.h b/cocos/2d/renderer/CCRenderer.h index a856d201c3..39511a04f0 100644 --- a/cocos/2d/renderer/CCRenderer.h +++ b/cocos/2d/renderer/CCRenderer.h @@ -37,7 +37,26 @@ NS_CC_BEGIN class EventListenerCustom; -typedef std::vector RenderQueue; +/** Class that knows how to sort the Commands. + Since the commands that have z==0 are "pushed back" in + the correct order, the only Commands that need to be sorted, + are the ones that have z <0 and z >0. + And that is what this class does. +*/ +class RenderQueue { + +public: + void push_back(RenderCommand* command); + ssize_t size() const; + void sort(); + RenderCommand* operator[](ssize_t index) const; + void clear(); + +protected: + std::vector _queueNegZ; + std::vector _queue0; + std::vector _queuePosZ; +}; struct RenderStackElement { diff --git a/cocos/base/CCMap.h b/cocos/base/CCMap.h index 450b39bc2e..4b940f2a78 100644 --- a/cocos/base/CCMap.h +++ b/cocos/base/CCMap.h @@ -144,9 +144,11 @@ public: std::vector keys() const { std::vector keys; - + if (!_data.empty()) { + keys.reserve(_data.size()); + for (auto iter = _data.cbegin(); iter != _data.cend(); ++iter) { keys.push_back(iter->first); @@ -160,14 +162,21 @@ public: { std::vector keys; - for (auto iter = _data.cbegin(); iter != _data.cend(); ++iter) + if (!_data.empty()) { - if (iter->second == object) + keys.reserve(_data.size() / 10); + + for (auto iter = _data.cbegin(); iter != _data.cend(); ++iter) { - keys.push_back(iter->first); + if (iter->second == object) + { + keys.push_back(iter->first); + } } } + keys.shrink_to_fit(); + return keys; } diff --git a/cocos/editor-support/cocostudio/CCBatchNode.cpp b/cocos/editor-support/cocostudio/CCBatchNode.cpp index 634630ec64..752e4911a9 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.cpp +++ b/cocos/editor-support/cocostudio/CCBatchNode.cpp @@ -156,7 +156,7 @@ void BatchNode::draw() void BatchNode::generateGroupCommand() { Renderer* renderer = Director::getInstance()->getRenderer(); - _groupCommand->init(0,_vertexZ); + _groupCommand->init(_globalZOrder); renderer->addCommand(_groupCommand); renderer->pushGroup(_groupCommand->getRenderQueueID()); diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index 4bd7883a43..dbaa142020 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -145,7 +145,7 @@ void Bone::setBoneData(BoneData *boneData) } _name = _boneData->name; - _ZOrder = _boneData->zOrder; + _localZOrder = _boneData->zOrder; _displayManager->initDisplayList(boneData); } @@ -283,11 +283,11 @@ void Bone::updateZOrder() if (_dataVersion >= VERSION_COMBINED) { int zorder = _tweenData->zOrder + _boneData->zOrder; - setZOrder(zorder); + setLocalZOrder(zorder); } else { - setZOrder(_tweenData->zOrder); + setLocalZOrder(_tweenData->zOrder); } } @@ -374,10 +374,10 @@ Tween *Bone::getTween() return _tween; } -void Bone::setZOrder(int zOrder) +void Bone::setLocalZOrder(int zOrder) { - if (_ZOrder != zOrder) - Node::setZOrder(zOrder); + if (_localZOrder != zOrder) + Node::setLocalZOrder(zOrder); } kmMat4 Bone::getNodeToArmatureTransform() const diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index db153a1da5..c81583a8c9 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -143,7 +143,7 @@ public: //! Update zorder void updateZOrder(); - virtual void setZOrder(int zOrder) override; + virtual void setLocalZOrder(int zOrder) override; Tween *getTween(); diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index ac3dc907ab..a9dc1361a8 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -331,7 +331,7 @@ void WidgetPropertiesReader0250::setPropsForWidgetFromJsonDictionary(Widget*widg widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible")); } int z = DICTOOL->getIntValue_json(options, "ZOrder"); - widget->setZOrder(z); + widget->setLocalZOrder(z); } void WidgetPropertiesReader0250::setColorPropsForWidgetFromJsonDictionary(Widget *widget, const rapidjson::Value&options) @@ -1062,7 +1062,7 @@ void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(Widget*widg widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible")); } int z = DICTOOL->getIntValue_json(options, "ZOrder"); - widget->setZOrder(z); + widget->setLocalZOrder(z); bool layout = DICTOOL->checkObjectExist_json(options, "layoutParameter"); if (layout) diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 12b18604ff..e33c4ad86a 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -203,7 +203,7 @@ void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d: node->setTag(nTag); int nZorder = DICTOOL->getIntValue_json(root, "zorder"); - node->setZOrder(nZorder); + node->setLocalZOrder(nZorder); float fScaleX = DICTOOL->getFloatValue_json(root, "scalex", 1.0); float fScaleY = DICTOOL->getFloatValue_json(root, "scaley", 1.0); diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index da98e5a736..440ce92159 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -225,7 +225,7 @@ void Skin::draw() kmGLGetMatrix(KM_GL_MODELVIEW, &mv); //TODO implement z order - _quadCommand.init(0, _vertexZ, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv); + _quadCommand.init(_globalZOrder, _texture->getName(), _shaderProgram, _blendFunc, &_quad, 1, mv); Director::getInstance()->getRenderer()->addCommand(&_quadCommand); } diff --git a/cocos/editor-support/spine/CCSkeleton.cpp b/cocos/editor-support/spine/CCSkeleton.cpp index 9051679a98..82c0ed50cd 100644 --- a/cocos/editor-support/spine/CCSkeleton.cpp +++ b/cocos/editor-support/spine/CCSkeleton.cpp @@ -131,7 +131,7 @@ void Skeleton::draw() kmGLMatrixMode(KM_GL_MODELVIEW); kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix); - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 38c73c5a65..8a64ad7ed4 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -210,18 +210,18 @@ void Layout::stencilClippingVisit() Renderer* renderer = Director::getInstance()->getRenderer(); - _groupCommand.init(0,_vertexZ); + _groupCommand.init(_globalZOrder); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); - _beforeVisitCmdStencil.init(0,_vertexZ); + _beforeVisitCmdStencil.init(_globalZOrder); _beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this); renderer->addCommand(&_beforeVisitCmdStencil); _clippingStencil->visit(); - _afterDrawStencilCmd.init(0,_vertexZ); + _afterDrawStencilCmd.init(_globalZOrder); _afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this); renderer->addCommand(&_afterDrawStencilCmd); @@ -251,7 +251,7 @@ void Layout::stencilClippingVisit() this->draw(); } - _afterVisitCmdStencil.init(0,_vertexZ); + _afterVisitCmdStencil.init(_globalZOrder); _afterVisitCmdStencil.func = CC_CALLBACK_0(Layout::onAfterVisitStencil, this); renderer->addCommand(&_afterVisitCmdStencil); @@ -336,13 +336,13 @@ void Layout::scissorClippingVisit() { Renderer* renderer = Director::getInstance()->getRenderer(); - _beforeVisitCmdScissor.init(0, _vertexZ); + _beforeVisitCmdScissor.init(_globalZOrder); _beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this); renderer->addCommand(&_beforeVisitCmdScissor); Node::visit(); - _afterVisitCmdScissor.init(0, _vertexZ); + _afterVisitCmdScissor.init(_globalZOrder); _afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this); renderer->addCommand(&_afterVisitCmdScissor); } @@ -651,14 +651,14 @@ void Layout::addBackGroundImage() if (_backGroundScale9Enabled) { _backGroundImage = extension::Scale9Sprite::create(); - _backGroundImage->setZOrder(-1); + _backGroundImage->setLocalZOrder(-1); Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); static_cast(_backGroundImage)->setPreferredSize(_size); } else { _backGroundImage = Sprite::create(); - _backGroundImage->setZOrder(-1); + _backGroundImage->setLocalZOrder(-1); Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } _backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f)); diff --git a/cocos/gui/UILayout.h b/cocos/gui/UILayout.h index fffb6aaad1..327707d7c8 100644 --- a/cocos/gui/UILayout.h +++ b/cocos/gui/UILayout.h @@ -195,7 +195,7 @@ public: * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node - * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) + * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) */ virtual void addChild(Node * child, int zOrder) override; /** @@ -204,7 +204,7 @@ public: * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node - * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) + * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) * @param tag A interger to identify the node easily. Please refer to setTag(int) */ virtual void addChild(Node* child, int zOrder, int tag) override; diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index ba6a567aef..8c732f6e70 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -378,7 +378,7 @@ void ListView::refreshView() for (int i=0; isetZOrder(i); + item->setLocalZOrder(i); remedyLayoutParameter(item); } updateInnerContainerSize(); diff --git a/cocos/gui/UIScrollView.h b/cocos/gui/UIScrollView.h index ae49fa02ea..0b196cef55 100644 --- a/cocos/gui/UIScrollView.h +++ b/cocos/gui/UIScrollView.h @@ -242,7 +242,7 @@ public: * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node - * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) + * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) */ virtual void addChild(Node * child, int zOrder) override; /** @@ -251,7 +251,7 @@ public: * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node - * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) + * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) * @param tag A interger to identify the node easily. Please refer to setTag(int) */ virtual void addChild(Node* child, int zOrder, int tag) override; diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index c475a1c409..84d07f3411 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -1040,7 +1040,7 @@ void Widget::copyProperties(Widget *widget) setBright(widget->isBright()); setTouchEnabled(widget->isTouchEnabled()); _touchPassedEnabled = false; - setZOrder(widget->getZOrder()); + setLocalZOrder(widget->getLocalZOrder()); setTag(widget->getTag()); setName(widget->getName()); setActionTag(widget->getActionTag()); diff --git a/cocos/gui/UIWidget.h b/cocos/gui/UIWidget.h index d07bc4bee8..3827c60db2 100644 --- a/cocos/gui/UIWidget.h +++ b/cocos/gui/UIWidget.h @@ -212,7 +212,7 @@ public: * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node - * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) + * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) */ virtual void addChild(Node * child, int zOrder) override; /** @@ -221,7 +221,7 @@ public: * If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. * * @param child A child node - * @param zOrder Z order for drawing priority. Please refer to setZOrder(int) + * @param zOrder Z order for drawing priority. Please refer to setLocalZOrder(int) * @param tag A interger to identify the node easily. Please refer to setTag(int) */ virtual void addChild(Node* child, int zOrder, int tag) override; diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index f03e84b93a..de699f63ae 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit f03e84b93ae69080e369962ba2e95ea9b2fd91c7 +Subproject commit de699f63aef423c3d90725171b0f020a719ef572 diff --git a/cocos/scripting/lua/bindings/CCBProxy.cpp b/cocos/scripting/lua/bindings/CCBProxy.cpp index cab487b1d8..f0ba9f92f8 100644 --- a/cocos/scripting/lua/bindings/CCBProxy.cpp +++ b/cocos/scripting/lua/bindings/CCBProxy.cpp @@ -58,75 +58,75 @@ const char* CCBProxy::getNodeTypeName(Node* pNode) } if (NULL != dynamic_cast(pNode)) { - return "LabelTTF"; + return "cc.LabelTTF"; } if (NULL != dynamic_cast(pNode)) { - return "LabelBMFont"; + return "cc.LabelBMFont"; } if (NULL != dynamic_cast(pNode)) { - return "Sprite"; + return "cc.Sprite"; } if (NULL != dynamic_cast(pNode)) { - return "ControlButton"; + return "cc.ControlButton"; } if (NULL != dynamic_cast(pNode)) { - return "LayerGradient"; + return "cc.LayerGradient"; } if (NULL != dynamic_cast(pNode)) { - return "LayerColor"; + return "cc.LayerColor"; } if (NULL != dynamic_cast(pNode)) { - return "LayerGradient"; + return "cc.LayerGradient"; } if (NULL != dynamic_cast(pNode)) { - return "Menu"; + return "cc.Menu"; } if (NULL != dynamic_cast(pNode)) { - return "MenuItemAtlasFont"; + return "cc.MenuItemAtlasFont"; } if (NULL != dynamic_cast(pNode)) { - return "MenuItemFont"; + return "cc.MenuItemFont"; } if (NULL != dynamic_cast(pNode)) { - return "MenuItemLabel"; + return "cc.MenuItemLabel"; } if (NULL != dynamic_cast(pNode)) { - return "MenuItemImage"; + return "cc.MenuItemImage"; } if (NULL != dynamic_cast(pNode)) { - return "MenuItemToggle"; + return "cc.MenuItemToggle"; } if (NULL != dynamic_cast(pNode)) { - return "MenuItemSprite"; + return "cc.MenuItemSprite"; } if (NULL != dynamic_cast(pNode)) { - return "MenuItem"; + return "cc.MenuItem"; } if (NULL != dynamic_cast(pNode)) { - return "Layer"; + return "cc.Layer"; } if (NULL != dynamic_cast(pNode)) { - return "String"; + return "cc.String"; } if (NULL != dynamic_cast(pNode)) { - return "ParticleSystemQuad"; + return "cc.ParticleSystemQuad"; } return "No Support"; diff --git a/cocos/scripting/lua/bindings/CCLuaEngine.cpp b/cocos/scripting/lua/bindings/CCLuaEngine.cpp index a05fa8f54d..502909695d 100644 --- a/cocos/scripting/lua/bindings/CCLuaEngine.cpp +++ b/cocos/scripting/lua/bindings/CCLuaEngine.cpp @@ -167,7 +167,7 @@ int LuaEngine::executeEvent(int nHandler, const char* pEventName, Object* pEvent _stack->pushString(pEventName); if (pEventSource) { - _stack->pushObject(pEventSource, pEventSourceClassName ? pEventSourceClassName : "CCObject"); + _stack->pushObject(pEventSource, pEventSourceClassName ? pEventSourceClassName : "cc.Object"); } int ret = _stack->executeFunctionByHandler(nHandler, pEventSource ? 2 : 1); _stack->clean(); @@ -329,7 +329,7 @@ int LuaEngine::handleMenuClickedEvent(void* data) return 0; _stack->pushInt(menuItem->getTag()); - _stack->pushObject(menuItem, "MenuItem"); + _stack->pushObject(menuItem, "cc.MenuItem"); int ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); return ret; @@ -352,7 +352,7 @@ int LuaEngine::handleCallFuncActionEvent(void* data) Object* target = static_cast(basicScriptData->value); if (NULL != target) { - _stack->pushObject(target, "Node"); + _stack->pushObject(target, "cc.Node"); } int ret = _stack->executeFunctionByHandler(handler, target ? 1 : 0); _stack->clean(); @@ -447,7 +447,7 @@ int LuaEngine::handleCommonEvent(void* data) } else { - _stack->pushObject(commonInfo->eventSource, "Object"); + _stack->pushObject(commonInfo->eventSource, "cc.Object"); } } int ret = _stack->executeFunctionByHandler(commonInfo->handler, commonInfo->eventSource ? 2 : 1); @@ -585,7 +585,7 @@ int LuaEngine::handlerControlEvent(void* data) if (0 != handler) { - _stack->pushObject((Object*)basicScriptData->nativeObject, "Object"); + _stack->pushObject((Object*)basicScriptData->nativeObject, "cc.Object"); _stack->pushInt(controlEvents); ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); @@ -612,7 +612,7 @@ int LuaEngine::handleEventAcc(void* data) lua_State* L = _stack->getLuaState(); LuaEventAccelerationData* eventListennerAcc = static_cast(basicScriptData->value); - toluafix_pushusertype_ccobject(L, eventListennerAcc->event->_ID, &(eventListennerAcc->event->_luaID), (void*)(eventListennerAcc->event),"Event"); + toluafix_pushusertype_ccobject(L, eventListennerAcc->event->_ID, &(eventListennerAcc->event->_luaID), (void*)(eventListennerAcc->event),"cc.Event"); Acceleration* accleration = static_cast(eventListennerAcc->acc); lua_pushnumber(L,accleration->x); lua_pushnumber(L,accleration->y); @@ -640,7 +640,7 @@ int LuaEngine::handleEventKeyboard(ScriptHandlerMgr::HandlerType type, void* dat lua_State* L = _stack->getLuaState(); lua_pushinteger(L, keyboardData->keyCode); - toluafix_pushusertype_ccobject(L, keyboardData->event->_ID, &(keyboardData->event->_luaID), (void*)(keyboardData->event),"Event"); + toluafix_pushusertype_ccobject(L, keyboardData->event->_ID, &(keyboardData->event->_luaID), (void*)(keyboardData->event),"cc.Event"); int ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); return ret; @@ -667,8 +667,8 @@ int LuaEngine::handleEventTouch(ScriptHandlerMgr::HandlerType type, void* data) Touch* touch = touchData->touch; if (NULL != touch) { - _stack->pushObject(touchData->touch, "Touch"); - _stack->pushObject(touchData->event, "Event"); + _stack->pushObject(touchData->touch, "cc.Touch"); + _stack->pushObject(touchData->event, "cc.Event"); ret = _stack->executeFunctionByHandler(handler, 2); } _stack->clean(); @@ -702,11 +702,11 @@ int LuaEngine::handleEventTouches(ScriptHandlerMgr::HandlerType type,void* data) for (auto& touch : touchesData->touches) { _stack->pushInt(i); - _stack->pushObject(touch, "Touch"); + _stack->pushObject(touch, "cc.Touch"); lua_rawset(L, -3); ++i; } - _stack->pushObject(touchesData->event, "Event"); + _stack->pushObject(touchesData->event, "cc.Event"); ret = _stack->executeFunctionByHandler(handler, 2); _stack->clean(); @@ -731,7 +731,7 @@ int LuaEngine::handleEventMouse(ScriptHandlerMgr::HandlerType type, void* data) if (0 == handler) return 0; - _stack->pushObject(mouseData->event, "Event"); + _stack->pushObject(mouseData->event, "cc.Event"); int ret = _stack->executeFunctionByHandler(handler, 1); _stack->clean(); @@ -754,7 +754,7 @@ int LuaEngine::handleEvenCustom(void* data) return 0; lua_State* L = _stack->getLuaState(); - toluafix_pushusertype_ccobject(L, eventCustom->_ID, &(eventCustom->_luaID), (void*)(eventCustom),"EventCustom"); + toluafix_pushusertype_ccobject(L, eventCustom->_ID, &(eventCustom->_luaID), (void*)(eventCustom),"cc.EventCustom"); int ret = _stack->executeFunctionByHandler(handler, 1); _stack->clean(); @@ -859,14 +859,102 @@ int LuaEngine::handleEvent(ScriptHandlerMgr::HandlerType type, void* data, int n int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data) { - CCASSERT(0, "TableView is not bound yet"); - return 0; + if (nullptr == data) + return 0; + + BasicScriptData* eventData = static_cast(data); + if (nullptr == eventData->nativeObject || nullptr == eventData->value) + return 0; + + LuaTableViewEventData* tableViewData = static_cast(eventData->value); + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, type); + + if (0 == handler) + return 0; + + Object* obj = static_cast(eventData->nativeObject); + if (nullptr == obj) + return 0; + + int ret = 0; + switch (type) + { + case ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL: + case ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM: + { + toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.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: + { + Object* cellObject = static_cast(tableViewData->value); + if (nullptr == cellObject) { + break; + } + toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"cc.TableView"); + toluafix_pushusertype_ccobject(_stack->getLuaState(), cellObject->_ID, &(cellObject->_luaID), (void*)(cellObject),"cc.TableViewCell"); + ret = _stack->executeFunctionByHandler(handler, 2); + } + break; + default: + break; + } + + return ret; + } int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType handlerType,void* data, int numResults, const std::function& func) { - CCASSERT(0, "TableView is not bound yet"); - return 0; + if (nullptr == data || numResults <= 0) + return 0; + + BasicScriptData* eventData = static_cast(data); + if (nullptr == eventData->nativeObject || nullptr == eventData->value) + return 0; + + LuaTableViewEventData* tableViewData = static_cast(eventData->value); + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, handlerType); + + if (0 == handler) + return 0; + + Object* obj = static_cast(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),"cc.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),"cc.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),"cc.TableView"); + ret = _stack->executeFunction(handler, 1, 1, func); + } + break; + default: + break; + } + + return ret; } int LuaEngine::handleAssetsManagerEvent(ScriptHandlerMgr::HandlerType type,void* data) @@ -925,7 +1013,7 @@ int LuaEngine::handleStudioEventListener(ScriptHandlerMgr::HandlerType type,void if (0 == handler) return 0; - _stack->pushObject(listenerData->objTarget, "Object"); + _stack->pushObject(listenerData->objTarget, "cc.Object"); _stack->pushInt(listenerData->eventType); _stack->executeFunctionByHandler(handler, 2); @@ -956,7 +1044,7 @@ int LuaEngine::handleArmatureWrapper(ScriptHandlerMgr::HandlerType type,void* da { LuaArmatureMovementEventData* movementData = static_cast(wrapperData->eventData); - _stack->pushObject(movementData->objTarget, "Armature"); + _stack->pushObject(movementData->objTarget, "ccs.Armature"); _stack->pushInt(movementData->movementType); _stack->pushString(movementData->movementID.c_str()); _stack->executeFunctionByHandler(handler, 3); @@ -966,7 +1054,7 @@ int LuaEngine::handleArmatureWrapper(ScriptHandlerMgr::HandlerType type,void* da { LuaArmatureFrameEventData* frameData = static_cast(wrapperData->eventData); - _stack->pushObject(frameData->objTarget, "Bone"); + _stack->pushObject(frameData->objTarget, "ccs.Bone"); _stack->pushString(frameData->frameEventName.c_str()); _stack->pushInt(frameData->originFrameIndex); _stack->pushInt(frameData->currentFrameIndex); diff --git a/cocos/scripting/lua/bindings/CCLuaStack.cpp b/cocos/scripting/lua/bindings/CCLuaStack.cpp index 7215e6afac..9661fb1cd8 100644 --- a/cocos/scripting/lua/bindings/CCLuaStack.cpp +++ b/cocos/scripting/lua/bindings/CCLuaStack.cpp @@ -151,7 +151,6 @@ bool LuaStack::init(void) register_all_cocos2dx_extension(_state); register_all_cocos2dx_deprecated(_state); register_cocos2dx_extension_CCBProxy(_state); - register_cocos2dx_event_releated(_state); tolua_opengl_open(_state); register_all_cocos2dx_gui(_state); register_all_cocos2dx_studio(_state); diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index c04df69ce3..ed8178972e 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp @@ -33,6 +33,7 @@ extern "C" { #endif std::unordered_map g_luaType; +std::unordered_map g_typeCast; #if COCOS2D_DEBUG >=1 void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.h b/cocos/scripting/lua/bindings/LuaBasicConversions.h index 20e4f79d73..9dcc2fc6e2 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.h +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.h @@ -35,6 +35,7 @@ extern "C" { using namespace cocos2d; extern std::unordered_map g_luaType; +extern std::unordered_map g_typeCast; #if COCOS2D_DEBUG >=1 void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err); diff --git a/cocos/scripting/lua/bindings/LuaOpengl.cpp.REMOVED.git-id b/cocos/scripting/lua/bindings/LuaOpengl.cpp.REMOVED.git-id index 42910a1d92..caaa6e32e0 100644 --- a/cocos/scripting/lua/bindings/LuaOpengl.cpp.REMOVED.git-id +++ b/cocos/scripting/lua/bindings/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -bcec27eb626dbcf63b810cce7f0f48b2d02c2158 \ No newline at end of file +bc70bac577759c95fbcf25da6937dbd9109da8d5 \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/LuaOpengl.h b/cocos/scripting/lua/bindings/LuaOpengl.h index d4691677ae..9e04ea1322 100644 --- a/cocos/scripting/lua/bindings/LuaOpengl.h +++ b/cocos/scripting/lua/bindings/LuaOpengl.h @@ -36,7 +36,7 @@ extern "C" { class GLNode:public cocos2d::Node { - virtual void draw(); + virtual void draw() override; }; TOLUA_API int tolua_opengl_open(lua_State* tolua_S); diff --git a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.cpp b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.cpp index 81317d65d7..c781d5b1ec 100644 --- a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.cpp +++ b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.cpp @@ -282,7 +282,7 @@ static int tolua_Cocos2d_ScriptHandlerMgr_registerScriptHandler00(lua_State* tol #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) || - !tolua_isusertype(tolua_S, 2, "Object", 0, &tolua_err) || + !tolua_isusertype(tolua_S, 2, "cc.Object", 0, &tolua_err) || !toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 0, &tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) @@ -316,7 +316,7 @@ static int tolua_Cocos2d_ScriptHandlerMgr_unregisterScriptHandler00(lua_State* t #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) || - !tolua_isusertype(tolua_S, 2, "Object", 0, &tolua_err) || + !tolua_isusertype(tolua_S, 2, "cc.Object", 0, &tolua_err) || !tolua_isnumber(tolua_S, 3, 0, &tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; @@ -348,7 +348,7 @@ static int tolua_Cocos2d_ScriptHandlerMgr_removeObjectAllHandlers00(lua_State* t #ifndef TOLUA_RELEASE tolua_Error tolua_err; if (!tolua_isusertype(tolua_S,1,"ScriptHandlerMgr",0,&tolua_err) || - !tolua_isusertype(tolua_S, 2, "Object", 0, &tolua_err) || + !tolua_isusertype(tolua_S, 2, "cc.Object", 0, &tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else diff --git a/cocos/scripting/lua/bindings/Lua_web_socket.cpp b/cocos/scripting/lua/bindings/Lua_web_socket.cpp index 4d3b8ae715..f508e720f6 100644 --- a/cocos/scripting/lua/bindings/Lua_web_socket.cpp +++ b/cocos/scripting/lua/bindings/Lua_web_socket.cpp @@ -164,7 +164,7 @@ static int tolua_collect_WebSocket (lua_State* tolua_S) /* function to release collected object via destructor */ static void tolua_reg_Web_Socket_type(lua_State* tolua_S) { - tolua_usertype(tolua_S, "WebSocket"); + tolua_usertype(tolua_S, "cc.WebSocket"); } /* method: create of class WebSocket */ @@ -174,7 +174,7 @@ static int tolua_Cocos2d_WebSocket_create00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertable(tolua_S,1,"WebSocket",0,&tolua_err) || + !tolua_isusertable(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) @@ -185,7 +185,7 @@ static int tolua_Cocos2d_WebSocket_create00(lua_State* tolua_S) const char* urlName = ((const char*) tolua_tostring(tolua_S,2,0)); LuaWebSocket *wSocket = new LuaWebSocket(); wSocket->init(*wSocket, urlName); - tolua_pushusertype(tolua_S,(void*)wSocket,"WebSocket"); + tolua_pushusertype(tolua_S,(void*)wSocket,"cc.WebSocket"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; @@ -204,7 +204,7 @@ static int tolua_Cocos2d_WebSocket_createByAProtocol00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertable(tolua_S,1,"WebSocket",0,&tolua_err) || + !tolua_isusertable(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isstring(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) @@ -219,7 +219,7 @@ static int tolua_Cocos2d_WebSocket_createByAProtocol00(lua_State* tolua_S) protocols.push_back(protocol); LuaWebSocket *wSocket = new LuaWebSocket(); wSocket->init(*wSocket, urlName,&protocols); - tolua_pushusertype(tolua_S,(void*)wSocket,"WebSocket"); + tolua_pushusertype(tolua_S,(void*)wSocket,"cc.WebSocket"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; @@ -238,7 +238,7 @@ static int tolua_Cocos2d_WebSocket_createByProtocolArray00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertable(tolua_S,1,"WebSocket",0,&tolua_err) || + !tolua_isusertable(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isusertable(tolua_S,3,"CCArray",0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) @@ -262,7 +262,7 @@ static int tolua_Cocos2d_WebSocket_createByProtocolArray00(lua_State* tolua_S) } LuaWebSocket *wSocket = new LuaWebSocket(); wSocket->init(*wSocket, urlName,&protocols); - tolua_pushusertype(tolua_S,(void*)wSocket,"WebSocket"); + tolua_pushusertype(tolua_S,(void*)wSocket,"cc.WebSocket"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } return 1; @@ -281,7 +281,7 @@ static int tolua_Cocos2d_WebSocket_getReadyState00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; @@ -312,7 +312,7 @@ static int tolua_Cocos2d_WebSocket_close00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; @@ -340,7 +340,7 @@ static int tolua_Cocos2d_WebSocket_sendString00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S, 1, "WebSocket", 0, &tolua_err) || + !tolua_isusertype(tolua_S, 1, "cc.WebSocket", 0, &tolua_err) || !tolua_isstring(tolua_S, 2, 0, &tolua_err) || !tolua_isnoobj(tolua_S, 3, &tolua_err) ) @@ -376,12 +376,12 @@ tolua_lerror: TOLUA_API int tolua_web_socket_open(lua_State* tolua_S){ tolua_open(tolua_S); tolua_reg_Web_Socket_type(tolua_S); - tolua_module(tolua_S,NULL,0); - tolua_beginmodule(tolua_S,NULL); + tolua_module(tolua_S,"cc",0); + tolua_beginmodule(tolua_S,"cc"); #ifdef __cplusplus - tolua_cclass(tolua_S,"WebSocket","WebSocket","",tolua_collect_WebSocket); + tolua_cclass(tolua_S,"WebSocket","cc.WebSocket","",tolua_collect_WebSocket); #else - tolua_cclass(tolua_S,"WebSocket","WebSocket","",NULL); + tolua_cclass(tolua_S,"WebSocket","cc.WebSocket","",NULL); #endif tolua_beginmodule(tolua_S,"WebSocket"); tolua_function(tolua_S, "create", tolua_Cocos2d_WebSocket_create00); @@ -400,7 +400,7 @@ int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) @@ -429,7 +429,7 @@ int tolua_Cocos2d_WebSocket_unregisterScriptHandler00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"cc.WebSocket",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) @@ -457,7 +457,7 @@ TOLUA_API int register_web_socket_manual(lua_State* tolua_S) if (nullptr == tolua_S) return 0 ; - lua_pushstring(tolua_S,"WebSocket"); + lua_pushstring(tolua_S,"cc.WebSocket"); lua_rawget(tolua_S,LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { diff --git a/cocos/scripting/lua/bindings/Lua_web_socket.h b/cocos/scripting/lua/bindings/Lua_web_socket.h index 5431209d12..d2463af3c2 100644 --- a/cocos/scripting/lua/bindings/Lua_web_socket.h +++ b/cocos/scripting/lua/bindings/Lua_web_socket.h @@ -39,10 +39,10 @@ class LuaWebSocket: public cocos2d::network::WebSocket,public cocos2d::network:: { public: virtual ~LuaWebSocket(); - virtual void onOpen(WebSocket* ws); - virtual void onMessage(WebSocket* ws, const WebSocket::Data& data); - virtual void onClose(WebSocket* ws); - virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error); + virtual void onOpen(WebSocket* ws) override; + virtual void onMessage(WebSocket* ws, const WebSocket::Data& data) override; + virtual void onClose(WebSocket* ws) override; + virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error) override; enum WebSocketScriptHandlerType { diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp index 5120f1d966..581279907d 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -83,7 +83,7 @@ static int lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -153,7 +153,7 @@ static int lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccs.ArmatureAnimation",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -217,7 +217,7 @@ tolua_lerror: static void extendArmatureAnimation(lua_State* L) { - lua_pushstring(L, "ArmatureAnimation"); + lua_pushstring(L, "ccs.ArmatureAnimation"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -237,7 +237,7 @@ static int lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc(lua #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccs.ArmatureDataManager",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -309,7 +309,7 @@ tolua_lerror: static void extendArmatureDataManager(lua_State* L) { - lua_pushstring(L, "ArmatureDataManager"); + lua_pushstring(L, "ccs.ArmatureDataManager"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -328,7 +328,7 @@ static int lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"Bone",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -373,7 +373,7 @@ static int lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"Bone",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccs.Bone",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -405,7 +405,7 @@ tolua_lerror: static void extendBone(lua_State* L) { - lua_pushstring(L, "Bone"); + lua_pushstring(L, "ccs.Bone"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp index 0d6d053810..e907189be2 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp @@ -2123,6 +2123,15 @@ static int tolua_bnd_cast_deprecated00(lua_State* tolua_S) } else { + std::string castName = tolua_tostring(tolua_S,2,NULL); + auto iter = g_typeCast.find(castName); + if (iter != g_typeCast.end() ) + { + CCLOG("Cast name %s doesn't include modular name which it belongs to,please add the modular name",iter->first.c_str()); + tolua_pushstring(tolua_S, iter->second.c_str()); + lua_insert(tolua_S, 2); + lua_pop(tolua_S, 1); + } return tolua_bnd_cast(tolua_S); } } diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp index 88b4693c01..739abb548c 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp @@ -42,6 +42,203 @@ USING_NS_CC; USING_NS_CC_EXT; using namespace cocostudio; +class LuaScrollViewDelegate:public Object, public ScrollViewDelegate +{ +public: + virtual ~LuaScrollViewDelegate() + {} + + virtual void scrollViewDidScroll(ScrollView* view) override + { + if (nullptr != view) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); + if (0 != handler) + { + CommonScriptData data(handler,""); + ScriptEvent event(kCommonEvent,(void*)&data); + LuaEngine::getInstance()->sendEvent(&event); + } + + } + } + + virtual void scrollViewDidZoom(ScrollView* view) override + { + if (nullptr != view) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM); + if (0 != handler) + { + CommonScriptData data(handler,""); + ScriptEvent event(kCommonEvent,(void*)&data); + LuaEngine::getInstance()->sendEvent(&event); + } + } + } +}; + +static int tolua_cocos2dx_ScrollView_setDelegate(lua_State* tolua_S) +{ + if (nullptr == tolua_S) + return 0; + + int argc = 0; + ScrollView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (ScrollView*) tolua_tousertype(tolua_S,1,0); +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_ScrollView_setDelegate'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (0 == argc) + { + LuaScrollViewDelegate* delegate = new LuaScrollViewDelegate(); + if (nullptr == delegate) + return 0; + + self->setUserObject(delegate); + self->setDelegate(delegate); + + delegate->release(); + + return 0; + } + + CCLOG("'setDelegate' function of ScrollView wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'setDelegate'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_ScrollView_registerScriptHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + ScrollView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_ScrollView_registerScriptHandler'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(tolua_S) - 1; + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isnumber(tolua_S, 3, 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); + ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(tolua_S,3,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType); + return 0; + } + + CCLOG("'registerScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static int tolua_cocos2d_ScrollView_unregisterScriptHandler(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + ScrollView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(tolua_S,1,"cc.ScrollView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(tolua_S,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_ScrollView_unregisterScriptHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(tolua_S,2,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType); + return 0; + } + + CCLOG("'unregisterScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static void extendScrollView(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "cc.ScrollView"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"setDelegate"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_ScrollView_setDelegate ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"registerScriptHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_ScrollView_registerScriptHandler ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"unregisterScriptHandler"); + lua_pushcfunction(tolua_S,tolua_cocos2d_ScrollView_unregisterScriptHandler ); + lua_rawset(tolua_S,-3); + } + lua_pop(tolua_S, 1); +} + + static int tolua_cocos2d_Control_registerControlEventHandler(lua_State* tolua_S) { if (NULL == tolua_S) @@ -52,7 +249,7 @@ static int tolua_cocos2d_Control_registerControlEventHandler(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"Control",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -108,7 +305,7 @@ static int tolua_cocos2d_control_unregisterControlEventHandler(lua_State* tolua_ #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"Control",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.Control",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -153,7 +350,7 @@ tolua_lerror: static void extendControl(lua_State* tolua_S) { - lua_pushstring(tolua_S, "Control"); + lua_pushstring(tolua_S, "cc.Control"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -177,7 +374,7 @@ static int tolua_cocos2d_EditBox_registerScriptEditBoxHandler(lua_State* tolua_S #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"EditBox",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -226,7 +423,7 @@ static int tolua_cocos2d_EditBox_unregisterScriptEditBoxHandler(lua_State* tolua #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"EditBox",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.EditBox",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -258,7 +455,7 @@ tolua_lerror: static void extendEditBox(lua_State* tolua_S) { - lua_pushstring(tolua_S, "EditBox"); + lua_pushstring(tolua_S, "cc.EditBox"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -281,7 +478,7 @@ static int tolua_cocos2d_CCBProxy_create(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertable(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -291,7 +488,7 @@ static int tolua_cocos2d_CCBProxy_create(lua_State* tolua_S) CCBProxy* tolua_ret = (CCBProxy*)CCBProxy::create(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int *pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCBProxy"); + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.CCBProxy"); return 1; } @@ -316,7 +513,7 @@ static int tolua_cocos2d_CCBProxy_createCCBReader(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -335,7 +532,7 @@ static int tolua_cocos2d_CCBProxy_createCCBReader(lua_State* tolua_S) CCBReader* tolua_ret = (CCBReader*) self->createCCBReader(); int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"CCBReader"); + toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"cc.CCBReader"); return 1; } @@ -366,7 +563,7 @@ static int tolua_cocos2d_CCBProxy_readCCBFromFile(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -384,7 +581,7 @@ static int tolua_cocos2d_CCBProxy_readCCBFromFile(lua_State* tolua_S) { #if COCOS2D_DEBUG >= 1 if (!tolua_isstring(tolua_S, 2, 0, &tolua_err)|| - !tolua_isusertype(tolua_S,3,"CCBReader",0,&tolua_err)|| + !tolua_isusertype(tolua_S,3,"cc.CCBReader",0,&tolua_err)|| !tolua_isboolean(tolua_S,4,1,&tolua_err ) ) goto tolua_lerror; @@ -395,7 +592,7 @@ static int tolua_cocos2d_CCBProxy_readCCBFromFile(lua_State* tolua_S) tolua_ret = (Node*) self->readCCBFromFile(ccbFilePath, ccbReader, setOwner); ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node"); + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node"); return 1; } @@ -420,7 +617,7 @@ static int tolua_cocos2d_CCBProxy_getNodeTypeName(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -437,7 +634,7 @@ static int tolua_cocos2d_CCBProxy_getNodeTypeName(lua_State* tolua_S) if (1 == argc) { #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"Node",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror; #endif Node* node = static_cast(tolua_tousertype(tolua_S,2,0)); @@ -466,7 +663,7 @@ static int tolua_cocos2d_CCBProxy_setCallback(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"CCBProxy",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.CCBProxy",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -482,7 +679,7 @@ static int tolua_cocos2d_CCBProxy_setCallback(lua_State* tolua_S) if ( argc >= 2 && argc <= 3 ) { #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,2,"Node",0,&tolua_err) || + if (!tolua_isusertype(tolua_S,2,"cc.Node",0,&tolua_err) || !toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err) || !tolua_isnumber(tolua_S, 4, 1, &tolua_err) ) @@ -510,8 +707,8 @@ int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S) { tolua_module(tolua_S,"cc",0); tolua_beginmodule(tolua_S,"cc"); - tolua_usertype(tolua_S,"CCBProxy"); - tolua_cclass(tolua_S,"CCBProxy","CCBProxy","Layer",NULL); + tolua_usertype(tolua_S,"cc.CCBProxy"); + tolua_cclass(tolua_S,"CCBProxy","cc.CCBProxy","cc.Layer",NULL); tolua_beginmodule(tolua_S,"CCBProxy"); tolua_function(tolua_S, "create", tolua_cocos2d_CCBProxy_create); tolua_function(tolua_S, "createCCBReader", tolua_cocos2d_CCBProxy_createCCBReader); @@ -522,7 +719,7 @@ int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S) tolua_endmodule(tolua_S); std::string typeName = typeid(CCBProxy).name(); - g_luaType[typeName] = "CCBProxy"; + g_luaType[typeName] = "cc.CCBProxy"; return 1; } @@ -537,7 +734,7 @@ static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"CCBReader",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.CCBReader",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -564,12 +761,12 @@ static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S) Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName); int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node"); + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node"); return 1; } #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S, 3, "Object", 0, &tolua_err)) + if (!tolua_isusertype(tolua_S, 3, "cc.Object", 0, &tolua_err)) goto tolua_lerror; #endif Object* owner = static_cast(tolua_tousertype(tolua_S, 3, 0)); @@ -579,7 +776,7 @@ static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S) Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName,owner); int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node"); + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node"); return 1; } @@ -591,7 +788,7 @@ static int tolua_cocos2d_CCBReader_load(lua_State* tolua_S) Node* tolua_ret = (Node*) self->readNodeGraphFromFile(fileName,owner,size); int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"Node"); + toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.Node"); return 1; } @@ -608,7 +805,7 @@ tolua_lerror: static void extendCCBReader(lua_State* tolua_S) { - lua_pushstring(tolua_S, "CCBReader"); + lua_pushstring(tolua_S, "cc.CCBReader"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -630,7 +827,7 @@ static int tolua_cocos2d_CCBAnimationManager_setCallFuncForLuaCallbackNamed(lua_ #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.CCBAnimationManager",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(tolua_S,1,0)); @@ -647,7 +844,7 @@ static int tolua_cocos2d_CCBAnimationManager_setCallFuncForLuaCallbackNamed(lua_ { #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,2, "CallFunc", 0, &tolua_err) || + if (!tolua_isusertype(tolua_S,2, "cc.CallFunc", 0, &tolua_err) || !tolua_isstring(tolua_S, 3, 0, &tolua_err) ) goto tolua_lerror; #endif @@ -675,7 +872,7 @@ tolua_lerror: static void extendCCBAnimationManager(lua_State* tolua_S) { - lua_pushstring(tolua_S, "CCBAnimationManager"); + lua_pushstring(tolua_S, "cc.CCBAnimationManager"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -692,7 +889,7 @@ public: virtual ~LuaAssetsManagerDelegateProtocol() {} - virtual void onProgress(int percent) + virtual void onProgress(int percent) override { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS); if (0 != handler) @@ -703,7 +900,7 @@ public: } } - virtual void onSuccess() + virtual void onSuccess() override { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS); if (0 != handler) @@ -714,7 +911,7 @@ public: } } - virtual void onError(AssetsManager::ErrorCode errorCode) + virtual void onError(AssetsManager::ErrorCode errorCode) override { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR); if (0 != handler) @@ -736,7 +933,7 @@ static int lua_cocos2dx_AssetsManager_setDelegate(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"AssetsManager",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.AssetsManager",0,&tolua_err)) goto tolua_lerror; #endif self = (AssetsManager*) tolua_tousertype(L,1,0); @@ -791,7 +988,7 @@ tolua_lerror: static void extendAssetsManager(lua_State* L) { - lua_pushstring(L, "AssetsManager"); + lua_pushstring(L, "cc.AssetsManager"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -800,6 +997,473 @@ static void extendAssetsManager(lua_State* L) lua_pop(L, 1); } +#define KEY_TABLEVIEW_DATA_SOURCE "TableViewDataSource" +#define KEY_TABLEVIEW_DELEGATE "TableViewDelegate" + +class LUA_TableViewDelegate:public Object, public TableViewDelegate +{ +public: + LUA_TableViewDelegate(){} + + virtual ~LUA_TableViewDelegate(){} + + + virtual void scrollViewDidScroll(ScrollView* view) override + { + if (nullptr != view) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); + if (0 != handler) + { + LuaTableViewEventData eventData; + BasicScriptData data(view,&eventData); + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL, (void*)&data); + } + } + } + + virtual void scrollViewDidZoom(ScrollView* view) override + { + if (nullptr != view) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM); + if (0 != handler) + { + LuaTableViewEventData eventData; + BasicScriptData data(view,&eventData); + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM, (void*)&data); + } + } + } + + virtual void tableCellTouched(TableView* table, TableViewCell* cell) override + { + if (nullptr != table && nullptr != cell) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED); + if (0 != handler) + { + LuaTableViewEventData eventData(cell); + BasicScriptData data(table,&eventData); + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED,(void*)&data); + } + } + } + + virtual void tableCellHighlight(TableView* table, TableViewCell* cell) override + { + if (nullptr != table && nullptr != cell) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT); + if (0 != handler) + { + LuaTableViewEventData eventData(cell); + BasicScriptData data(table,&eventData); + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT,(void*)&data); + } + } + } + + virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) override + { + if (nullptr != table && nullptr != cell) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT); + if (0 != handler) + { + LuaTableViewEventData eventData(cell); + BasicScriptData data(table,&eventData); + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT,(void*)&data); + } + } + } + + virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) override + { + if (nullptr != table && nullptr != cell) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE); + if (0 != handler) + { + LuaTableViewEventData eventData(cell); + BasicScriptData data(table,&eventData); + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE,(void*)&data); + } + } + } +}; + +static int lua_cocos2dx_TableView_setDelegate(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + TableView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (TableView*) tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TableView_setDelegate'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (0 == argc) + { + LUA_TableViewDelegate* delegate = new LUA_TableViewDelegate(); + if (nullptr == delegate) + return 0; + + Dictionary* userDict = static_cast(self->getUserObject()); + if (nullptr == userDict) + { + userDict = new Dictionary(); + if (NULL == userDict) + return 0; + + self->setUserObject(userDict); + userDict->release(); + } + + userDict->setObject(delegate, KEY_TABLEVIEW_DELEGATE); + self->setDelegate(delegate); + delegate->release(); + + return 0; + } + + CCLOG("'setDelegate' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'setDelegate'.",&tolua_err); + return 0; +#endif +} + +class LUA_TableViewDataSource:public Object,public TableViewDataSource +{ +public: + LUA_TableViewDataSource(){} + virtual ~LUA_TableViewDataSource(){} + + virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) override + { + if (nullptr != table ) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX); + if (0 != handler) + { + LuaTableViewEventData eventData(&idx); + BasicScriptData data(table,&eventData); + float width = 0.0; + float height = 0.0; + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX, (void*)&data,2,[&](lua_State* L,int numReturn){ + CCASSERT(numReturn == 2, "tableCellSizeForIndex return count error"); + ValueVector vec; + width = (float)tolua_tonumber(L, -1, 0); + lua_pop(L, 1); + height = (float)tolua_tonumber(L, -1, 0); + lua_pop(L, 1); + }); + + return Size(width, height); + } + } + + return Size::ZERO; + } + + virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) override + { + if (nullptr != table ) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX); + if (0 != handler) + { + LuaTableViewEventData eventData(&idx); + BasicScriptData data(table,&eventData); + TableViewCell* viewCell = nullptr; + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX, (void*)&data, 1, [&](lua_State* L, int numReturn){ + CCASSERT(numReturn == 1, "tableCellAtIndex return count error"); + viewCell = static_cast(tolua_tousertype(L, -1, nullptr)); + lua_pop(L, 1); + }); + + return viewCell; + } + } + + return NULL; + } + + virtual ssize_t numberOfCellsInTableView(TableView *table) override + { + if (nullptr != table ) + { + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS); + if (0 != handler) + { + LuaTableViewEventData eventData; + BasicScriptData data(table,&eventData); + ssize_t counts = 0; + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS, (void*)&data,1, [&](lua_State* L, int numReturn){ + CCASSERT(numReturn == 1, "numberOfCellsInTableView return count error"); + counts = (ssize_t)tolua_tonumber(L, -1, 0); + lua_pop(L, 1); + }); + return counts; + } + } + return 0; + } +}; + +static int lua_cocos2dx_TableView_setDataSource(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + TableView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = (TableView*) tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) + { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TableView_setDataSource'\n", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (0 == argc) + { + LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource(); + if (nullptr == dataSource) + return 0; + + Dictionary* userDict = static_cast(self->getUserObject()); + if (nullptr == userDict) + { + userDict = new Dictionary(); + if (NULL == userDict) + return 0; + + self->setUserObject(userDict); + userDict->release(); + } + + userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE); + + self->setDataSource(dataSource); + + dataSource->release(); + + return 0; + } + + CCLOG("'setDataSource' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'setDataSource'.",&tolua_err); + return 0; +#endif +} + +static int lua_cocos2dx_TableView_create(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertable(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(L) - 1; + + if (2 == argc || 1 == argc) + { + LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource(); + Size size; + ok &= luaval_to_size(L, 2, &size); + + TableView* ret = nullptr; + + if (1 == argc) + { + ret = TableView::create(dataSource, size); + } + else + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,3,"cc.Node",0,&tolua_err)) goto tolua_lerror; +#endif + Node* node = static_cast(tolua_tousertype(L, 3, nullptr)); + ret = TableView::create(dataSource, size, node); + } + + if (nullptr == ret) + return 0; + + ret->reloadData(); + + Dictionary* userDict = new Dictionary(); + userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE); + ret->setUserObject(userDict); + userDict->release(); + + dataSource->release(); + + + int nID = (int)ret->_ID; + int* pLuaID = &ret->_luaID; + toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)ret,"cc.TableView"); + + return 1; + } + CCLOG("'create' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'create'.",&tolua_err); + return 0; +#endif +} + +static int lua_cocos2d_TableView_registerScriptHandler(lua_State* L) +{ + if (NULL == L) + return 0; + + int argc = 0; + TableView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_TableView_registerScriptHandler'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (2 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || + !tolua_isnumber(L, 3, 0, &tolua_err) ) + { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType); + return 0; + } + + CCLOG("'registerScriptHandler' function of TableView has wrong number of arguments: %d, was expecting %d\n", argc, 2); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'registerScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static int lua_cocos2d_TableView_unregisterScriptHandler(lua_State* L) +{ + if (NULL == L) + return 0; + + int argc = 0; + TableView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2d_TableView_unregisterScriptHandler'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isnumber(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,2,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); + ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType); + return 0; + } + + CCLOG("'unregisterScriptHandler' function of TableView has wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); + return 0; +#endif +} + +static void extendTableView(lua_State* L) +{ + lua_pushstring(L, "cc.TableView"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "setDelegate", lua_cocos2dx_TableView_setDelegate); + tolua_function(L, "setDataSource", lua_cocos2dx_TableView_setDataSource); + tolua_function(L, "create", lua_cocos2dx_TableView_create); + tolua_function(L, "registerScriptHandler", lua_cocos2d_TableView_registerScriptHandler); + tolua_function(L, "unregisterScriptHandler", lua_cocos2d_TableView_unregisterScriptHandler); + } + lua_pop(L, 1); +} + int register_all_cocos2dx_extension_manual(lua_State* tolua_S) { extendControl(tolua_S); @@ -807,5 +1471,7 @@ int register_all_cocos2dx_extension_manual(lua_State* tolua_S) extendCCBReader(tolua_S); extendCCBAnimationManager(tolua_S); extendAssetsManager(tolua_S); + extendScrollView(tolua_S); + extendTableView(tolua_S); return 0; } diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.h b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.h index 1a76eaf316..b150bf3cbd 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.h +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.h @@ -46,5 +46,16 @@ struct LuaAssetsManagerEventData } }; +struct LuaTableViewEventData +{ + void* value; + + // Constructor + LuaTableViewEventData(void* _value = nullptr) + :value(_value) + { + } +}; + #endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_EXTENSION_MANUAL_H diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp index ec8a23ccd8..b51979ff53 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp @@ -94,7 +94,7 @@ static int lua_cocos2dx_Widget_addTouchEventListener(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"Widget",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.Widget",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -145,7 +145,7 @@ tolua_lerror: static void extendWidget(lua_State* L) { - lua_pushstring(L, "Widget"); + lua_pushstring(L, "ccui.Widget"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -164,7 +164,7 @@ static int lua_cocos2dx_CheckBox_addEventListenerCheckBox(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"CheckBox",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.CheckBox",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -214,7 +214,7 @@ tolua_lerror: static void extendCheckBox(lua_State* L) { - lua_pushstring(L, "CheckBox"); + lua_pushstring(L, "ccui.CheckBox"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -233,7 +233,7 @@ static int lua_cocos2dx_Slider_addEventListenerSlider(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"Slider",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -283,7 +283,7 @@ tolua_lerror: static void extendSlider(lua_State* L) { - lua_pushstring(L, "Slider"); + lua_pushstring(L, "ccui.Slider"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -302,7 +302,7 @@ static int lua_cocos2dx_TextField_addEventListenerTextField(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"TextField",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.TextField",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -352,7 +352,7 @@ tolua_lerror: static void extendTextField(lua_State* L) { - lua_pushstring(L, "TextField"); + lua_pushstring(L, "ccui.TextField"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -371,7 +371,7 @@ static int lua_cocos2dx_PageView_addEventListenerPageView(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"PageView",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.PageView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -421,7 +421,7 @@ tolua_lerror: static void extendPageView(lua_State* L) { - lua_pushstring(L, "PageView"); + lua_pushstring(L, "ccui.PageView"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -440,7 +440,7 @@ static int lua_cocos2dx_ListView_addEventListenerListView(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ListView",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.ListView",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -490,7 +490,7 @@ tolua_lerror: static void extendListView(lua_State* L) { - lua_pushstring(L, "ListView"); + lua_pushstring(L, "ccui.ListView"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { @@ -509,7 +509,7 @@ static int lua_cocos2dx_LayoutParameter_setMargin(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"LayoutParameter",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -577,7 +577,7 @@ static int lua_cocos2dx_LayoutParameter_getMargin(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"LayoutParameter",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"ccui.LayoutParameter",0,&tolua_err)) goto tolua_lerror; #endif self = static_cast(tolua_tousertype(L,1,0)); @@ -628,7 +628,7 @@ tolua_lerror: static void extendLayoutParameter(lua_State* L) { - lua_pushstring(L, "LayoutParameter"); + lua_pushstring(L, "ccui.LayoutParameter"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id b/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id index e3c65441d6..e296678e5b 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id @@ -1 +1 @@ -f916840e52bdfd7e7283cb9c70ebfaf1c23b9301 \ No newline at end of file +9d9d07e19dba691a22e4d184f0ec0e6ae6207a9b \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp index 0d11f0f9b4..7da290e02a 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp @@ -29,7 +29,7 @@ int lua_cocos2dx_physics_PhysicsBody_getJoints(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); @@ -69,7 +69,7 @@ int lua_cocos2dx_physics_PhysicsBody_getJoints(lua_State* tolua_S) if(name != g_luaType.end()){ className = name->second.c_str(); } else { - className = "PhysicsJoint"; + className = "cc.PhysicsJoint"; } lua_pushnumber(tolua_S, (lua_Number)indexTable); @@ -102,7 +102,7 @@ int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); @@ -129,7 +129,7 @@ int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "Scene"; + className = "cc.Scene"; } int ID = (int)(ret._ID); @@ -162,7 +162,7 @@ int lua_cocos2dx_physics_PhysicsWorld_rayCast(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); @@ -191,7 +191,7 @@ int lua_cocos2dx_physics_PhysicsWorld_rayCast(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsWorld"; + className = "cc.PhysicsWorld"; } tolua_pushusertype(tolua_S, (void*)(&world), className.c_str()); @@ -229,7 +229,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryRect(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); @@ -257,7 +257,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryRect(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsWorld"; + className = "cc.PhysicsWorld"; } tolua_pushusertype(tolua_S, (void*)(&world), className.c_str()); @@ -268,7 +268,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryRect(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsShape"; + className = "cc.PhysicsShape"; } toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), className.c_str()); return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); @@ -305,7 +305,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); @@ -333,7 +333,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsWorld"; + className = "cc.PhysicsWorld"; } tolua_pushusertype(tolua_S, (void*)(&world), className.c_str()); @@ -344,7 +344,7 @@ int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsShape"; + className = "cc.PhysicsShape"; } toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), className.c_str()); return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); @@ -380,7 +380,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -409,7 +409,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsBody"; + className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { @@ -450,7 +450,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsBody"; + className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { @@ -493,7 +493,7 @@ int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsBody"; + className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { @@ -527,7 +527,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -556,7 +556,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsBody"; + className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { @@ -597,7 +597,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsBody"; + className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { @@ -640,7 +640,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsBody"; + className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { @@ -674,7 +674,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.PhysicsBody",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -703,7 +703,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsBody"; + className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { @@ -744,7 +744,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsBody"; + className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { @@ -787,7 +787,7 @@ int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) if(iter != g_luaType.end()){ className = iter->second.c_str(); } else { - className = "PhysicsBody"; + className = "cc.PhysicsBody"; } cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); if (NULL != dynObject) { @@ -821,7 +821,7 @@ int lua_cocos2dx_physics_PhysicsShape_recenterPoints(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"PhysicsShape",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -886,7 +886,7 @@ int lua_cocos2dx_physics_PhysicsShape_getPolyonCenter(lua_State* tolua_S) #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"PhysicsShape",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(tolua_S,1,"cc.PhysicsShape",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; @@ -924,14 +924,13 @@ int lua_cocos2dx_physics_PhysicsShapeBox_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeBox* cobj = nullptr; - bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeBox*)tolua_tousertype(tolua_S,1,0); @@ -967,14 +966,13 @@ int lua_cocos2dx_physics_PhysicsShapePolygon_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapePolygon* cobj = nullptr; - bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapePolygon*)tolua_tousertype(tolua_S,1,0); @@ -1012,14 +1010,13 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgeBox* cobj = nullptr; - bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"PhysicsShapeEdgeBox",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgeBox",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgeBox*)tolua_tousertype(tolua_S,1,0); @@ -1057,14 +1054,13 @@ int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgePolygon* cobj = nullptr; - bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"PhysicsShapeEdgePolygon",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgePolygon",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgePolygon*)tolua_tousertype(tolua_S,1,0); @@ -1102,14 +1098,13 @@ int lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints(lua_State* tolua_S) { int argc = 0; cocos2d::PhysicsShapeEdgeChain* cobj = nullptr; - bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"PhysicsShapeEdgeChain",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(tolua_S,1,"cc.PhysicsShapeEdgeChain",0,&tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::PhysicsShapeEdgeChain*)tolua_tousertype(tolua_S,1,0); @@ -1145,7 +1140,7 @@ tolua_lerror: int register_all_cocos2dx_physics_manual(lua_State* tolua_S) { - lua_pushstring(tolua_S, "PhysicsBody"); + lua_pushstring(tolua_S, "cc.PhysicsBody"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -1164,7 +1159,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S) } lua_pop(tolua_S, 1); - lua_pushstring(tolua_S, "PhysicsShape"); + lua_pushstring(tolua_S, "cc.PhysicsShape"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -1177,7 +1172,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S) } lua_pop(tolua_S, 1); - lua_pushstring(tolua_S, "PhysicsShapeBox"); + lua_pushstring(tolua_S, "cc.PhysicsShapeBox"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -1187,7 +1182,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S) } lua_pop(tolua_S, 1); - lua_pushstring(tolua_S, "PhysicsShapeEdgeBox"); + lua_pushstring(tolua_S, "cc.PhysicsShapeEdgeBox"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -1197,7 +1192,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S) } lua_pop(tolua_S, 1); - lua_pushstring(tolua_S, "PhysicsShapePolygon"); + lua_pushstring(tolua_S, "cc.PhysicsShapePolygon"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -1207,7 +1202,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S) } lua_pop(tolua_S, 1); - lua_pushstring(tolua_S, "PhysicsShapeEdgePolygon"); + lua_pushstring(tolua_S, "cc.PhysicsShapeEdgePolygon"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -1217,7 +1212,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S) } lua_pop(tolua_S, 1); - lua_pushstring(tolua_S, "PhysicsShapeEdgeChain"); + lua_pushstring(tolua_S, "cc.PhysicsShapeEdgeChain"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { @@ -1227,7 +1222,7 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S) } lua_pop(tolua_S, 1); - lua_pushstring(tolua_S, "PhysicsWorld"); + lua_pushstring(tolua_S, "cc.PhysicsWorld"); lua_rawget(tolua_S, LUA_REGISTRYINDEX); if (lua_istable(tolua_S,-1)) { diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.cpp index 593dd3f0a3..63ea2a23cd 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.cpp @@ -94,7 +94,7 @@ static int lua_cocos2dx_CCSkeletonAnimation_createWithFile(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertable(L,1,"SkeletonAnimation",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertable(L,1,"sp.SkeletonAnimation",0,&tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(L) - 1; @@ -115,7 +115,7 @@ static int lua_cocos2dx_CCSkeletonAnimation_createWithFile(lua_State* L) int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)tolua_ret,"SkeletonAnimation"); + toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)tolua_ret,"sp.SkeletonAnimation"); return 1; } else if (3 == argc) { @@ -135,7 +135,7 @@ static int lua_cocos2dx_CCSkeletonAnimation_createWithFile(lua_State* L) int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)tolua_ret,"SkeletonAnimation"); + toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)tolua_ret,"sp.SkeletonAnimation"); return 1; } @@ -153,7 +153,7 @@ int tolua_Cocos2d_CCSkeletonAnimation_registerScriptHandler00(lua_State* tolua_S #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) @@ -180,7 +180,7 @@ int tolua_Cocos2d_CCSkeletonAnimation_unregisterScriptHandler00(lua_State* tolua #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; @@ -205,7 +205,7 @@ static int tolua_Cocos2d_CCSkeletonAnimation_setTimeScale00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) @@ -232,7 +232,7 @@ static int tolua_Cocos2d_CCSkeletonAnimation_setDebugSlots00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) @@ -259,7 +259,7 @@ static int tolua_Cocos2d_CCSkeletonAnimation_setDebugBones00(lua_State* tolua_S) #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) @@ -286,7 +286,7 @@ static int tolua_Cocos2d_CCSkeletonAnimation_setPremultipliedAlpha00(lua_State* #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( - !tolua_isusertype(tolua_S,1,"SkeletonAnimation",0,&tolua_err) || + !tolua_isusertype(tolua_S,1,"sp.SkeletonAnimation",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) @@ -311,13 +311,13 @@ tolua_lerror: static int tolua_spine_SkeletoneAnimation_setBlendFunc(lua_State* tolua_S) { - return tolua_cocos2dx_setBlendFunc(tolua_S,"SkeletonAnimation"); + return tolua_cocos2dx_setBlendFunc(tolua_S,"sp.SkeletonAnimation"); } static void extendCCSkeletonAnimation(lua_State* L) { - lua_pushstring(L, "SkeletonAnimation"); + lua_pushstring(L, "sp.SkeletonAnimation"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { diff --git a/cocos/scripting/lua/bindings/lua_xml_http_request.cpp b/cocos/scripting/lua/bindings/lua_xml_http_request.cpp index 9a7b124ee9..9470afffb1 100644 --- a/cocos/scripting/lua/bindings/lua_xml_http_request.cpp +++ b/cocos/scripting/lua/bindings/lua_xml_http_request.cpp @@ -270,7 +270,7 @@ void LuaMinXmlHttpRequest::getByteData(unsigned char* byteData) /* function to regType */ static void lua_reg_xml_http_request(lua_State* L) { - tolua_usertype(L, "XMLHttpRequest"); + tolua_usertype(L, "cc.XMLHttpRequest"); } static int lua_collect_xml_http_request (lua_State* L) @@ -296,7 +296,7 @@ static int lua_cocos2dx_XMLHttpRequest_constructor(lua_State* L) self->autorelease(); int ID = self? (int)self->_ID : -1; int* luaID = self? &self->_luaID : NULL; - toluafix_pushusertype_ccobject(L, ID, luaID, (void*)self, "XMLHttpRequest"); + toluafix_pushusertype_ccobject(L, ID, luaID, (void*)self, "cc.XMLHttpRequest"); return 1; } @@ -316,7 +316,7 @@ static int lua_get_XMLHttpRequest_responseType(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -345,7 +345,7 @@ static int lua_set_XMLHttpRequest_responseType(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -388,7 +388,7 @@ static int lua_get_XMLHttpRequest_withCredentials(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -417,7 +417,7 @@ static int lua_set_XMLHttpRequest_withCredentials(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -457,7 +457,7 @@ static int lua_get_XMLHttpRequest_timeout(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -486,7 +486,7 @@ static int lua_set_XMLHttpRequest_timeout(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -526,7 +526,7 @@ static int lua_get_XMLHttpRequest_readyState(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -555,7 +555,7 @@ static int lua_get_XMLHttpRequest_status(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -584,7 +584,7 @@ static int lua_get_XMLHttpRequest_statusText(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -613,7 +613,7 @@ static int lua_get_XMLHttpRequest_responseText(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -640,7 +640,7 @@ static int lua_get_XMLHttpRequest_response(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -711,7 +711,7 @@ static int lua_cocos2dx_XMLHttpRequest_open(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -796,7 +796,7 @@ static int lua_cocos2dx_XMLHttpRequest_send(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -855,7 +855,7 @@ static int lua_cocos2dx_XMLHttpRequest_setRequestHeader(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -902,7 +902,7 @@ static int lua_cocos2dx_XMLHttpRequest_getAllResponseHeaders(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -948,7 +948,7 @@ static int lua_cocos2dx_XMLHttpRequest_getResponseHeader(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -1002,7 +1002,7 @@ static int lua_cocos2dx_XMLHttpRequest_registerScriptHandler(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -1046,7 +1046,7 @@ static int lua_cocos2dx_XMLHttpRequest_unregisterScriptHandler(lua_State* L) #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; + if (!tolua_isusertype(L,1,"cc.XMLHttpRequest",0,&tolua_err)) goto tolua_lerror; #endif self = (LuaMinXmlHttpRequest*) tolua_tousertype(L,1,0); @@ -1082,9 +1082,9 @@ TOLUA_API int register_xml_http_request(lua_State* L) { tolua_open(L); lua_reg_xml_http_request(L); - tolua_module(L,NULL,0); - tolua_beginmodule(L,NULL); - tolua_cclass(L,"XMLHttpRequest","XMLHttpRequest","Object",lua_collect_xml_http_request); + tolua_module(L,"cc",0); + tolua_beginmodule(L,"cc"); + tolua_cclass(L,"XMLHttpRequest","cc.XMLHttpRequest","cc.Object",lua_collect_xml_http_request); tolua_beginmodule(L,"XMLHttpRequest"); tolua_variable(L, "responseType", lua_get_XMLHttpRequest_responseType, lua_set_XMLHttpRequest_responseType); tolua_variable(L, "withCredentials", lua_get_XMLHttpRequest_withCredentials, lua_set_XMLHttpRequest_withCredentials); diff --git a/cocos/scripting/lua/script/CCBReaderLoad.lua b/cocos/scripting/lua/script/CCBReaderLoad.lua index 733a432317..141a4e5df5 100644 --- a/cocos/scripting/lua/script/CCBReaderLoad.lua +++ b/cocos/scripting/lua/script/CCBReaderLoad.lua @@ -17,7 +17,7 @@ function CCBReaderLoad(strFilePath,proxy,owner) local i = 1 for i = 1,table.getn(ownerCallbackNames) do local callbackName = ownerCallbackNames[i] - local callbackNode = tolua.cast(ownerCallbackNodes[i],"Node") + local callbackNode = tolua.cast(ownerCallbackNodes[i],"cc.Node") if "function" == type(owner[callbackName]) then proxy:setCallback(callbackNode, owner[callbackName], ownerCallbackControlEvents[i]) @@ -33,7 +33,7 @@ function CCBReaderLoad(strFilePath,proxy,owner) for i = 1, table.getn(ownerOutletNames) do local outletName = ownerOutletNames[i] - local outletNode = tolua.cast(ownerOutletNodes[i],"Node") + local outletNode = tolua.cast(ownerOutletNodes[i],"cc.Node") owner[outletName] = outletNode end end @@ -42,8 +42,8 @@ function CCBReaderLoad(strFilePath,proxy,owner) local animationManagersForNodes = ccbReader:getAnimationManagersForNodes() for i = 1 , table.getn(nodesWithAnimationManagers) do - local innerNode = tolua.cast(nodesWithAnimationManagers[i], "Node") - local animationManager = tolua.cast(animationManagersForNodes[i], "CCBAnimationManager") + local innerNode = tolua.cast(nodesWithAnimationManagers[i], "cc.Node") + local animationManager = tolua.cast(animationManagersForNodes[i], "cc.CCBAnimationManager") local documentControllerName = animationManager:getDocumentControllerName() if "" == documentControllerName then @@ -59,7 +59,7 @@ function CCBReaderLoad(strFilePath,proxy,owner) for i = 1,table.getn(documentCallbackNames) do local callbackName = documentCallbackNames[i] - local callbackNode = tolua.cast(documentCallbackNodes[i],"Node") + local callbackNode = tolua.cast(documentCallbackNodes[i],"cc.Node") if "" ~= documentControllerName and nil ~= ccb[documentControllerName] then if "function" == type(ccb[documentControllerName][callbackName]) then proxy:setCallback(callbackNode, ccb[documentControllerName][callbackName], documentCallbackControlEvents[i]) @@ -75,7 +75,7 @@ function CCBReaderLoad(strFilePath,proxy,owner) for i = 1, table.getn(documentOutletNames) do local outletName = documentOutletNames[i] - local outletNode = tolua.cast(documentOutletNodes[i],"Node") + local outletNode = tolua.cast(documentOutletNodes[i],"cc.Node") if nil ~= ccb[documentControllerName] then ccb[documentControllerName][outletName] = tolua.cast(outletNode, proxy:getNodeTypeName(outletNode)) diff --git a/cocos/scripting/lua/script/Deprecated.lua b/cocos/scripting/lua/script/Deprecated.lua index e48ba122e9..38ae6ff614 100644 --- a/cocos/scripting/lua/script/Deprecated.lua +++ b/cocos/scripting/lua/script/Deprecated.lua @@ -706,6 +706,21 @@ end rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView) --functions of CCFileUtils will be deprecated end +--Enums of CCTableView will be deprecated begin +rawset(CCTableView, "kTableViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL) +rawset(CCTableView,"kTableViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM) +rawset(CCTableView,"kTableCellTouched",cc.TABLECELL_TOUCHED) +rawset(CCTableView,"kTableCellSizeForIndex",cc.TABLECELL_SIZE_FOR_INDEX) +rawset(CCTableView,"kTableCellSizeAtIndex",cc.TABLECELL_SIZE_AT_INDEX) +rawset(CCTableView,"kNumberOfCellsInTableView",cc.NUMBER_OF_CELLS_IN_TABLEVIEW) +--Enums of CCTableView will be deprecated end + +--Enums of CCScrollView will be deprecated begin +rawset(CCScrollView, "kScrollViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL) +rawset(CCScrollView,"kScrollViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM) +--Enums of CCScrollView will be deprecated end + + --functions of CCApplication will be deprecated end local CCApplicationDeprecated = { } diff --git a/cocos/scripting/lua/script/DeprecatedClass.lua b/cocos/scripting/lua/script/DeprecatedClass.lua index c899d0a0dc..05e476a6fe 100644 --- a/cocos/scripting/lua/script/DeprecatedClass.lua +++ b/cocos/scripting/lua/script/DeprecatedClass.lua @@ -175,6 +175,15 @@ end _G["CCEaseElasticOut"] = DeprecatedClass.CCEaseElasticOut() --CCEaseElasticOut class will be Deprecated,end +--CCTableViewCell class will be Deprecated,begin +function DeprecatedClass.CCTableViewCell() + deprecatedTip("CCTableViewCell","cc.TableViewCell") + return cc.TableViewCell +end +_G["CCTableViewCell"] = DeprecatedClass.CCTableViewCell() +--CCTableViewCell class will be Deprecated,end + + --CCEaseBackOut class will be Deprecated,begin function DeprecatedClass.CCEaseBackOut() deprecatedTip("CCEaseBackOut","cc.EaseBackOut") @@ -719,6 +728,15 @@ end _G["CCPlace"] = DeprecatedClass.CCPlace() --CCPlace class will be Deprecated,end +--CCScrollView class will be Deprecated,begin +function DeprecatedClass.CCScrollView() + deprecatedTip("CCScrollView","cc.ScrollView") + return cc.ScrollView +end +_G["CCScrollView"] = DeprecatedClass.CCScrollView() +--CCScrollView class will be Deprecated,end + + --CCGLProgram class will be Deprecated,begin function DeprecatedClass.CCGLProgram() deprecatedTip("CCGLProgram","cc.GLProgram") @@ -799,6 +817,15 @@ end _G["CCParticleFlower"] = DeprecatedClass.CCParticleFlower() --CCParticleFlower class will be Deprecated,end +--CCTableView class will be Deprecated,begin +function DeprecatedClass.CCTableView() + deprecatedTip("CCTableView","cc.TableView") + return cc.TableView +end +_G["CCTableView"] = DeprecatedClass.CCTableView() +--CCTableView class will be Deprecated,end + + --CCParticleSmoke class will be Deprecated,begin function DeprecatedClass.CCParticleSmoke() deprecatedTip("CCParticleSmoke","cc.ParticleSmoke") @@ -2127,4 +2154,20 @@ end _G["CCBProxy"] = DeprecatedClass.CCBProxy() --CCBProxy class will be Deprecated,end +--WebSocket class will be Deprecated,begin +function DeprecatedClass.WebSocket() + deprecatedTip("WebSocket","cc.WebSocket") + return cc.WebSocket +end +_G["WebSocket"] = DeprecatedClass.WebSocket() +--WebSocket class will be Deprecated,end + +--XMLHttpRequest class will be Deprecated,begin +function DeprecatedClass.XMLHttpRequest() + deprecatedTip("XMLHttpRequest","cc.XMLHttpRequest") + return cc.XMLHttpRequest +end +_G["XMLHttpRequest"] = DeprecatedClass.XMLHttpRequest() +--XMLHttpRequest class will be Deprecated,end + diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index e1c21ce3a6..0c4fbe72a3 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -494,7 +494,7 @@ void ScrollView::addChild(Node * child, int zOrder, int tag) void ScrollView::beforeDraw() { - _beforeDrawCommand.init(0, _vertexZ); + _beforeDrawCommand.init(_globalZOrder); _beforeDrawCommand.func = CC_CALLBACK_0(ScrollView::onBeforeDraw, this); Director::getInstance()->getRenderer()->addCommand(&_beforeDrawCommand); } @@ -529,7 +529,7 @@ void ScrollView::onBeforeDraw() void ScrollView::afterDraw() { - _afterDrawCommand.init(0, _vertexZ); + _afterDrawCommand.init(_globalZOrder); _afterDrawCommand.func = CC_CALLBACK_0(ScrollView::onAfterDraw, this); Director::getInstance()->getRenderer()->addCommand(&_afterDrawCommand); } diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp index fa40b74f0a..b290364d39 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -1314,7 +1314,7 @@ void ActionFollow::onEnter() void ActionFollow::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(ActionFollow::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); @@ -1630,7 +1630,7 @@ void ActionCatmullRomStacked::draw() kmGLPopMatrix(); kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2); - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(ActionCatmullRomStacked::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -1745,7 +1745,7 @@ void ActionCardinalSplineStacked::draw() kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2); kmGLPopMatrix(); - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(ActionCardinalSplineStacked::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -2107,7 +2107,7 @@ void ActionCatmullRom::draw() kmGLPopMatrix(); kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2); - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(ActionCatmullRom::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -2207,7 +2207,7 @@ void ActionCardinalSpline::draw() kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV2); kmGLPopMatrix(); - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(ActionCardinalSpline::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp index 70e55dae5d..2dabe08a75 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp @@ -149,7 +149,7 @@ void Box2DTestLayer::draw() kmGLPushMatrix(); kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewMV); - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(Box2DTestLayer::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp index dd8d3f8693..2b05f4a60b 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp @@ -211,7 +211,7 @@ void Box2DView::draw() { Layer::draw(); - _customCmd.init(0, _vertexZ); + _customCmd.init(_globalZOrder); _customCmd.func = CC_CALLBACK_0(Box2DView::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCmd); } diff --git a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 68a584d577..829c8766dc 100644 --- a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -611,7 +611,7 @@ void RawStencilBufferTest::draw() auto iter = _renderCmds.begin(); - iter->init(0, _vertexZ); + iter->init(_globalZOrder); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onEnableStencil, this); renderer->addCommand(&(*iter)); ++iter; @@ -628,7 +628,7 @@ void RawStencilBufferTest::draw() spritePoint.y = 0; _sprites.at(i)->setPosition( spritePoint ); - iter->init(0, _vertexZ); + iter->init(_globalZOrder); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i, stencilPoint); renderer->addCommand(&(*iter)); ++iter; @@ -638,7 +638,7 @@ void RawStencilBufferTest::draw() _sprites.at(i)->visit(); kmGLPopMatrix(); - iter->init(0, _vertexZ); + iter->init(_globalZOrder); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawSprite, this, i, winPoint); renderer->addCommand(&(*iter)); ++iter; @@ -649,7 +649,7 @@ void RawStencilBufferTest::draw() kmGLPopMatrix(); } - iter->init(0, _vertexZ); + iter->init(_globalZOrder); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onDisableStencil, this); renderer->addCommand(&(*iter)); diff --git a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 61aa2aa0b2..622220f09d 100644 --- a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -116,7 +116,7 @@ DrawPrimitivesTest::DrawPrimitivesTest() void DrawPrimitivesTest::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(DrawPrimitivesTest::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index fdf76c80a0..88a63ce1f9 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -503,7 +503,7 @@ void TestChangeZorder::changeZorder(float dt) Node *node = getChildByTag(currentTag); - node->setZOrder(CCRANDOM_0_1() * 3); + node->setLocalZOrder(CCRANDOM_0_1() * 3); currentTag ++; currentTag = currentTag % 3; @@ -637,7 +637,7 @@ void TestParticleDisplay::onEnter() bone->addDisplay(p1, 0); bone->changeDisplayWithIndex(0, true); bone->setIgnoreMovementBoneData(true); - bone->setZOrder(100); + bone->setLocalZOrder(100); bone->setScale(1.2f); armature->addBone(bone, "bady-a3"); @@ -645,7 +645,7 @@ void TestParticleDisplay::onEnter() bone->addDisplay(p2, 0); bone->changeDisplayWithIndex(0, true); bone->setIgnoreMovementBoneData(true); - bone->setZOrder(100); + bone->setLocalZOrder(100); bone->setScale(1.2f); armature->addBone(bone, "bady-a30"); } @@ -1067,7 +1067,7 @@ void TestColliderDetector::update(float delta) } void TestColliderDetector::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(TestColliderDetector::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -1108,7 +1108,7 @@ std::string TestBoundingBox::title() const } void TestBoundingBox::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(TestBoundingBox::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp index a06f00d592..5253040a66 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp @@ -56,7 +56,7 @@ bool UIImageViewTest::init() _uiLayer->addChild(sprite); */ -// imageView->setZOrder(20); +// imageView->setLocalZOrder(20); return true; } diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp index d85049bc94..e09dc7f4fc 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp @@ -210,7 +210,7 @@ void Atlas1::draw() // GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY // GL_TEXTURE_2D - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(Atlas1::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); @@ -526,7 +526,7 @@ Atlas4::Atlas4() void Atlas4::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(Atlas4::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -1612,7 +1612,7 @@ std::string LabelBMFontBounds::subtitle() const void LabelBMFontBounds::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(LabelBMFontBounds::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp index 604ff0cb8b..a3dff56208 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTestNew.cpp @@ -302,7 +302,7 @@ LabelFNTSpriteActions::LabelFNTSpriteActions() void LabelFNTSpriteActions::draw() { - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(LabelFNTSpriteActions::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); @@ -912,7 +912,7 @@ std::string LabelFNTBounds::subtitle() const void LabelFNTBounds::draw() { - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(LabelFNTBounds::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); } diff --git a/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp b/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp index 0cee1ffbd1..194a7bc74c 100644 --- a/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp @@ -166,11 +166,11 @@ void TouchableSpriteTest::onEnter() target->setOpacity(255); if (target == sprite2) { - sprite1->setZOrder(100); + sprite1->setLocalZOrder(100); } else if(target == sprite1) { - sprite1->setZOrder(0); + sprite1->setLocalZOrder(0); } }; diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp index 4d69c14542..290366c94c 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp @@ -67,6 +67,7 @@ static std::function createFunctions[] = CL(ConvertToNode), CL(NodeOpaqueTest), CL(NodeNonOpaqueTest), + CL(NodeGlobalZValueTest), }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -905,6 +906,55 @@ std::string NodeNonOpaqueTest::subtitle() const return "Node rendered with GL_BLEND enabled"; } +/// NodeGlobalZValueTest + +NodeGlobalZValueTest::NodeGlobalZValueTest() +{ + Size s = Director::getInstance()->getWinSize(); + for (int i = 0; i < 9; i++) + { + Sprite *sprite; + auto parent = Node::create(); + if(i==4) { + sprite = Sprite::create("Images/grossinis_sister2.png"); + _sprite = sprite; + _sprite->setGlobalZOrder(-1); + } + else + sprite = Sprite::create("Images/grossinis_sister1.png"); + + parent->addChild(sprite); + this->addChild(parent); + + float w = sprite->getContentSize().width; + sprite->setPosition(s.width/2 - w*0.7*(i-5), s.height/2); + } + + this->scheduleUpdate(); +} + +void NodeGlobalZValueTest::update(float dt) +{ + static float accum = 0; + + accum += dt; + if( accum > 1) { + float z = _sprite->getGlobalZOrder(); + _sprite->setGlobalZOrder(-z); + accum = 0; + } +} + +std::string NodeGlobalZValueTest::title() const +{ + return "Global Z Value"; +} + +std::string NodeGlobalZValueTest::subtitle() const +{ + return "Center Sprite should change go from foreground to background"; +} + // // MySprite: Used by CameraTest1 and CameraTest2 @@ -932,7 +982,7 @@ protected: void MySprite::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h index 2207c65f7c..334e2df08a 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h @@ -249,6 +249,20 @@ protected: NodeNonOpaqueTest(); }; +class NodeGlobalZValueTest : public TestCocosNodeDemo +{ +public: + CREATE_FUNC(NodeGlobalZValueTest); + virtual std::string title() const override; + virtual std::string subtitle() const override; + + virtual void update(float dt) override; + +protected: + NodeGlobalZValueTest(); + Sprite *_sprite; +}; + class CocosNodeTestScene : public TestScene { public: diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceContainerTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceContainerTest.cpp index 75efc640e5..7754582947 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceContainerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceContainerTest.cpp @@ -35,7 +35,11 @@ static std::function createFunctions[] = { CL(TemplateVectorPerfTest), - CL(ArrayPerfTest) + CL(ArrayPerfTest), + CL(TemplateMapStringKeyPerfTest), + CL(DictionaryStringKeyPerfTest), + CL(TemplateMapIntKeyPerfTest), + CL(DictionaryIntKeyPerfTest) }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -264,27 +268,6 @@ void PerformanceContainerScene::updateProfilerName() snprintf(_profilerName, sizeof(_profilerName)-1, "%s(%d)", testName(), quantityOfNodes); } -void PerformanceContainerScene::onExitTransitionDidStart() -{ - Scene::onExitTransitionDidStart(); - - auto director = Director::getInstance(); - auto sched = director->getScheduler(); - - sched->unscheduleSelector(schedule_selector(PerformanceContainerScene::dumpProfilerInfo), this); -} - -void PerformanceContainerScene::onEnterTransitionDidFinish() -{ - Scene::onEnterTransitionDidFinish(); - - auto director = Director::getInstance(); - auto sched = director->getScheduler(); - - CC_PROFILER_PURGE_ALL(); - sched->scheduleSelector(schedule_selector(PerformanceContainerScene::dumpProfilerInfo), this, 2, false); -} - void PerformanceContainerScene::dumpProfilerInfo(float dt) { CC_PROFILER_DISPLAY_TIMERS(); @@ -507,8 +490,6 @@ void TemplateVectorPerfTest::generateTestFunctions() } } - - std::string TemplateVectorPerfTest::title() const { return "Vector Perf test"; @@ -519,8 +500,6 @@ std::string TemplateVectorPerfTest::subtitle() const return "Test 'pushBack', See console"; } - - //////////////////////////////////////////////////////// // // ArrayPerfTest @@ -701,6 +680,685 @@ void ArrayPerfTest::generateTestFunctions() } } +//////////////////////////////////////////////////////// +// +// TemplateMapStringKeyPerfTest +// +//////////////////////////////////////////////////////// + +void TemplateMapStringKeyPerfTest::generateTestFunctions() +{ + auto createMap = [this](){ + Map ret; + + for( int i=0; isetTag(i); + ret.insert(StringUtils::format("key_%d", i), node); + } + return ret; + }; + + TestFunction testFunctions[] = { + { "insert", [=](){ + Map map; + + std::string* keys = new std::string[quantityOfNodes]; + + for (int i = 0; i < quantityOfNodes; ++i) + { + keys[i] = StringUtils::format("key_%d", i); + } + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iprofilerName()); + + CC_SAFE_DELETE_ARRAY(keys); + } } , + + { "at", [=](){ + Map map = createMap(); + + std::string* keys = new std::string[quantityOfNodes]; + Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes); + for (int i = 0; i < quantityOfNodes; ++i) + { + keys[i] = StringUtils::format("key_%d", i); + } + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iprofilerName()); + + CC_SAFE_DELETE_ARRAY(keys); + + for (int i = 0; i < quantityOfNodes; ++i) + { + nodes[i]->setTag(100); + } + + CC_SAFE_FREE(nodes); + } } , + + { "erase", [=](){ + auto map = createMap(); + + std::string* keys = new std::string[quantityOfNodes]; + Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes); + for (int i = 0; i < quantityOfNodes; ++i) + { + keys[i] = StringUtils::format("key_%d", i); + } + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iprofilerName()); + + CC_SAFE_DELETE_ARRAY(keys); + + CC_SAFE_FREE(nodes); + } } , + + { "clear", [=](){ + auto map = createMap(); + + CC_PROFILER_START(this->profilerName()); + map.clear(); + CC_PROFILER_STOP(this->profilerName()); + } } , + + { "size", [=](){ + auto map = createMap(); + + ssize_t size = 0; + CC_PROFILER_START(this->profilerName()); + size = map.size(); + CC_PROFILER_STOP(this->profilerName()); + } } , + + { "keys(all)", [=](){ + auto map = createMap(); + + CC_PROFILER_START(this->profilerName()); + auto keys = map.keys(); + CC_PROFILER_STOP(this->profilerName()); + + std::string allKeysString; + for (const auto& key : keys) + { + allKeysString += "_" + key; + } + } } , + + { "keys(object)", [=](){ + Map map; + + Node** nodes = (Node**) malloc(sizeof(Node*) * quantityOfNodes); + Node* sameNode = Node::create(); + + for( int i=0; isetTag(i); + map.insert(StringUtils::format("key_%d", i), node); + } + } + + CC_PROFILER_START(this->profilerName()); + auto keys = map.keys(sameNode); + CC_PROFILER_STOP(this->profilerName()); + + std::string allKeysString; + for (const auto& key : keys) + { + allKeysString += "_" + key; + } + + CC_SAFE_FREE(nodes); + } } , + + { "c++11 range loop", [=](){ + auto map = createMap(); + + CC_PROFILER_START(this->profilerName()); + + for (const auto& e : map) + { + e.second->setTag(100); + } + + CC_PROFILER_STOP(this->profilerName()); + } } , + + }; + + for (const auto& func : testFunctions) + { + _testFunctions.push_back(func); + } +} + +std::string TemplateMapStringKeyPerfTest::title() const +{ + return "Map String Key Perf test"; +} + +std::string TemplateMapStringKeyPerfTest::subtitle() const +{ + return "Test 'insert', See console"; +} + +//////////////////////////////////////////////////////// +// +// DictionaryStringKeyPerfTest +// +//////////////////////////////////////////////////////// + +void DictionaryStringKeyPerfTest::generateTestFunctions() +{ + auto createDict = [this](){ + Dictionary* ret = Dictionary::create(); + + for( int i=0; isetTag(i); + ret->setObject(node, StringUtils::format("key_%d", i)); + } + return ret; + }; + + TestFunction testFunctions[] = { + { "setObject", [=](){ + Dictionary* dict = Dictionary::create(); + + std::string* keys = new std::string[quantityOfNodes]; + + for (int i = 0; i < quantityOfNodes; ++i) + { + keys[i] = StringUtils::format("key_%d", i); + } + + CC_PROFILER_START(this->profilerName()); + for( int i=0; isetObject(Node::create(), keys[i]); + CC_PROFILER_STOP(this->profilerName()); + + CC_SAFE_DELETE_ARRAY(keys); + } } , + + { "objectForKey", [=](){ + auto dict = createDict(); + + std::string* keys = new std::string[quantityOfNodes]; + Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes); + for (int i = 0; i < quantityOfNodes; ++i) + { + keys[i] = StringUtils::format("key_%d", i); + } + + CC_PROFILER_START(this->profilerName()); + for( int i=0; i(dict->objectForKey(keys[i])); + CC_PROFILER_STOP(this->profilerName()); + + CC_SAFE_DELETE_ARRAY(keys); + + for (int i = 0; i < quantityOfNodes; ++i) + { + nodes[i]->setTag(100); + } + + CC_SAFE_FREE(nodes); + } } , + + { "removeObjectForKey", [=](){ + auto dict = createDict(); + + std::string* keys = new std::string[quantityOfNodes]; + Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes); + for (int i = 0; i < quantityOfNodes; ++i) + { + keys[i] = StringUtils::format("key_%d", i); + } + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iremoveObjectForKey(keys[i]); + CC_PROFILER_STOP(this->profilerName()); + + CC_SAFE_DELETE_ARRAY(keys); + + CC_SAFE_FREE(nodes); + } } , + + { "removeAllObjects", [=](){ + auto dict = createDict(); + + CC_PROFILER_START(this->profilerName()); + dict->removeAllObjects(); + CC_PROFILER_STOP(this->profilerName()); + } } , + + { "count", [=](){ + auto dict = createDict(); + + ssize_t size = 0; + CC_PROFILER_START(this->profilerName()); + size = dict->count(); + CC_PROFILER_STOP(this->profilerName()); + } } , + + { "allKeys", [=](){ + auto dict = createDict(); + + CC_PROFILER_START(this->profilerName()); + auto keys = dict->allKeys(); + CC_PROFILER_STOP(this->profilerName()); + + std::string allKeysString; + Object* obj; + CCARRAY_FOREACH(keys, obj) + { + auto key = static_cast(obj); + allKeysString += (std::string("_") + key->getCString()); + } + } } , + + { "allKeysForObject", [=](){ + Dictionary* dict = Dictionary::create(); + + Node** nodes = (Node**) malloc(sizeof(Node*) * quantityOfNodes); + Node* sameNode = Node::create(); + + for( int i=0; isetObject(sameNode, StringUtils::format("key_%d", i)); + } + else + { + auto node = Node::create(); + node->setTag(i); + dict->setObject(node, StringUtils::format("key_%d", i)); + } + } + + CC_PROFILER_START(this->profilerName()); + auto keys = dict->allKeysForObject(sameNode); + CC_PROFILER_STOP(this->profilerName()); + + std::string allKeysString; + Object* obj; + CCARRAY_FOREACH(keys, obj) + { + auto key = static_cast(obj); + allKeysString += (std::string("_") + key->getCString()); + } + + CC_SAFE_FREE(nodes); + } } , + + { "CCDICT_FOREACH", [=](){ + auto dict = createDict(); + + CC_PROFILER_START(this->profilerName()); + + DictElement* e = nullptr; + CCDICT_FOREACH(dict, e) + { + static_cast(e->getObject())->setTag(100); + } + + CC_PROFILER_STOP(this->profilerName()); + } } , + }; + + for (const auto& func : testFunctions) + { + _testFunctions.push_back(func); + } +} + +std::string DictionaryStringKeyPerfTest::title() const +{ + return "Dictionary String Key Perf test"; +} + +std::string DictionaryStringKeyPerfTest::subtitle() const +{ + return "Test `setObject`, See console"; +} + + +//////////////////////////////////////////////////////// +// +// TemplateMapIntKeyPerfTest +// +//////////////////////////////////////////////////////// + +void TemplateMapIntKeyPerfTest::generateTestFunctions() +{ + auto createMap = [this](){ + Map ret; + + for( int i=0; isetTag(i); + ret.insert(100+i, node); + } + return ret; + }; + + TestFunction testFunctions[] = { + { "insert", [=](){ + Map map; + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iprofilerName()); + } } , + + { "at", [=](){ + auto map = createMap(); + Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes); + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iprofilerName()); + + for (int i = 0; i < quantityOfNodes; ++i) + { + nodes[i]->setTag(100); + } + + CC_SAFE_FREE(nodes); + } } , + + { "erase", [=](){ + auto map = createMap(); + + Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes); + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iprofilerName()); + + CC_SAFE_FREE(nodes); + } } , + + { "clear", [=](){ + auto map = createMap(); + + CC_PROFILER_START(this->profilerName()); + map.clear(); + CC_PROFILER_STOP(this->profilerName()); + } } , + + { "size", [=](){ + auto map = createMap(); + + ssize_t size = 0; + CC_PROFILER_START(this->profilerName()); + size = map.size(); + CC_PROFILER_STOP(this->profilerName()); + } } , + + { "keys(all)", [=](){ + auto map = createMap(); + + CC_PROFILER_START(this->profilerName()); + auto keys = map.keys(); + CC_PROFILER_STOP(this->profilerName()); + + int allKeysInt = 0; + for (const auto& key : keys) + { + allKeysInt += key; + } + } } , + + { "keys(object)", [=](){ + Map map; + + Node** nodes = (Node**) malloc(sizeof(Node*) * quantityOfNodes); + Node* sameNode = Node::create(); + + for( int i=0; isetTag(i); + map.insert(100 + i, node); + } + } + + CC_PROFILER_START(this->profilerName()); + auto keys = map.keys(sameNode); + CC_PROFILER_STOP(this->profilerName()); + + int allKeysInt = 0; + for (const auto& key : keys) + { + allKeysInt += key; + } + + CC_SAFE_FREE(nodes); + } } , + + { "c++11 range loop", [=](){ + auto map = createMap(); + + CC_PROFILER_START(this->profilerName()); + + for (const auto& e : map) + { + e.second->setTag(100); + } + + CC_PROFILER_STOP(this->profilerName()); + } } , + + }; + + for (const auto& func : testFunctions) + { + _testFunctions.push_back(func); + } +} + +std::string TemplateMapIntKeyPerfTest::title() const +{ + return "Map Integer Key Perf test"; +} + +std::string TemplateMapIntKeyPerfTest::subtitle() const +{ + return "Test 'insert', See console"; +} + +//////////////////////////////////////////////////////// +// +// DictionaryIntKeyPerfTest +// +//////////////////////////////////////////////////////// + +void DictionaryIntKeyPerfTest::generateTestFunctions() +{ + auto createDict = [this](){ + Dictionary* ret = Dictionary::create(); + + for( int i=0; isetTag(i); + ret->setObject(node, 100 + i); + } + return ret; + }; + + TestFunction testFunctions[] = { + { "setObject", [=](){ + Dictionary* dict = Dictionary::create(); + + CC_PROFILER_START(this->profilerName()); + for( int i=0; isetObject(Node::create(), 100 + i); + CC_PROFILER_STOP(this->profilerName()); + } } , + + { "objectForKey", [=](){ + auto dict = createDict(); + + Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes); + + CC_PROFILER_START(this->profilerName()); + for( int i=0; i(dict->objectForKey(100 + i)); + CC_PROFILER_STOP(this->profilerName()); + + for (int i = 0; i < quantityOfNodes; ++i) + { + nodes[i]->setTag(100); + } + + CC_SAFE_FREE(nodes); + } } , + + { "removeObjectForKey", [=](){ + auto dict = createDict(); + + Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes); + + CC_PROFILER_START(this->profilerName()); + for( int i=0; iremoveObjectForKey(100 + i); + CC_PROFILER_STOP(this->profilerName()); + + CC_SAFE_FREE(nodes); + } } , + + { "removeAllObjects", [=](){ + auto dict = createDict(); + + CC_PROFILER_START(this->profilerName()); + dict->removeAllObjects(); + CC_PROFILER_STOP(this->profilerName()); + } } , + + { "count", [=](){ + auto dict = createDict(); + + unsigned int size = 0; + CC_PROFILER_START(this->profilerName()); + size = dict->count(); + CC_PROFILER_STOP(this->profilerName()); + } } , + + { "allKeys", [=](){ + auto dict = createDict(); + + CC_PROFILER_START(this->profilerName()); + auto keys = dict->allKeys(); + CC_PROFILER_STOP(this->profilerName()); + + int allKeysInt = 0; + Object* obj; + CCARRAY_FOREACH(keys, obj) + { + auto key = static_cast(obj); + allKeysInt += key->getValue(); + } + } } , + + { "allKeysForObject", [=](){ + Dictionary* dict = Dictionary::create(); + + Node** nodes = (Node**) malloc(sizeof(Node*) * quantityOfNodes); + Node* sameNode = Node::create(); + + for( int i=0; isetObject(sameNode, 100 + i); + } + else + { + auto node = Node::create(); + node->setTag(i); + dict->setObject(node, 100 + i); + } + } + + CC_PROFILER_START(this->profilerName()); + auto keys = dict->allKeysForObject(sameNode); + CC_PROFILER_STOP(this->profilerName()); + + int allKeysInt = 0; + Object* obj; + CCARRAY_FOREACH(keys, obj) + { + auto key = static_cast(obj); + allKeysInt += key->getValue(); + } + + CC_SAFE_FREE(nodes); + } } , + + { "CCDICT_FOREACH", [=](){ + auto dict = createDict(); + + CC_PROFILER_START(this->profilerName()); + + DictElement* e = nullptr; + CCDICT_FOREACH(dict, e) + { + static_cast(e->getObject())->setTag(100); + } + + CC_PROFILER_STOP(this->profilerName()); + } } , + }; + + for (const auto& func : testFunctions) + { + _testFunctions.push_back(func); + } +} + +std::string DictionaryIntKeyPerfTest::title() const +{ + return "Dictionary Integer Key Perf test"; +} + +std::string DictionaryIntKeyPerfTest::subtitle() const +{ + return "Test `setObject`, See console"; +} + + ///---------------------------------------- void runContainerPerformanceTest() { diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceContainerTest.h b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceContainerTest.h index d99cac90ff..603c759f76 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceContainerTest.h +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceContainerTest.h @@ -44,8 +44,6 @@ public: void dumpProfilerInfo(float dt); // overrides - virtual void onExitTransitionDidStart() override; - virtual void onEnterTransitionDidFinish() override; virtual void update(float dt) override; protected: @@ -85,6 +83,49 @@ public: virtual std::string subtitle() const override; }; +class TemplateMapStringKeyPerfTest : public PerformanceContainerScene +{ +public: + CREATE_FUNC(TemplateMapStringKeyPerfTest); + + virtual void generateTestFunctions() override; + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class DictionaryStringKeyPerfTest : public PerformanceContainerScene +{ +public: + CREATE_FUNC(DictionaryStringKeyPerfTest); + + virtual void generateTestFunctions() override; + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class TemplateMapIntKeyPerfTest : public PerformanceContainerScene +{ +public: + CREATE_FUNC(TemplateMapIntKeyPerfTest); + + virtual void generateTestFunctions() override; + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + +class DictionaryIntKeyPerfTest : public PerformanceContainerScene +{ +public: + CREATE_FUNC(DictionaryIntKeyPerfTest); + + virtual void generateTestFunctions() override; + + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; void runContainerPerformanceTest(); diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index 9a18f256be..e893f707f7 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -470,19 +470,19 @@ RenderTextureTestDepthStencil::~RenderTextureTestDepthStencil() void RenderTextureTestDepthStencil::draw() { - _renderCmds[0].init(0, _vertexZ); + _renderCmds[0].init(_globalZOrder); _renderCmds[0].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmds[0]); _rend->beginWithClear(0, 0, 0, 0, 0, 0); - _renderCmds[1].init(0, _vertexZ); + _renderCmds[1].init(_globalZOrder); _renderCmds[1].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeStencil, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmds[1]); _spriteDS->visit(); - _renderCmds[2].init(0, _vertexZ); + _renderCmds[2].init(_globalZOrder); _renderCmds[2].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmds[2]); @@ -490,7 +490,7 @@ void RenderTextureTestDepthStencil::draw() _rend->end(); - _renderCmds[3].init(0, _vertexZ); + _renderCmds[3].init(_globalZOrder); _renderCmds[3].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onAfterDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmds[3]); @@ -638,7 +638,7 @@ SpriteRenderTextureBug::SimpleSprite* SpriteRenderTextureBug::SimpleSprite::crea void SpriteRenderTextureBug::SimpleSprite::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(SpriteRenderTextureBug::SimpleSprite::onBeforeDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp index ba6c1f01c1..443a24d681 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp @@ -193,7 +193,7 @@ void ShaderNode::setPosition(const Point &newPosition) void ShaderNode::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } @@ -526,7 +526,7 @@ void SpriteBlur::initProgram() void SpriteBlur::draw() { - _customCommand.init(0, _vertexZ); + _customCommand.init(_globalZOrder); _customCommand.func = CC_CALLBACK_0(SpriteBlur::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); } diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp index 569bef3915..e8207b4cb4 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp @@ -178,7 +178,7 @@ void ShaderSprite::initShader() void ShaderSprite::draw() { - _renderCommand.init(0, _vertexZ); + _renderCommand.init(_globalZOrder); _renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCommand); diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index a3f4a7d564..a4121f8825 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -1794,7 +1794,7 @@ void TextureDrawAtPoint::draw() { TextureDemo::draw(); - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(TextureDrawAtPoint::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); @@ -1835,7 +1835,7 @@ void TextureDrawInRect::draw() { TextureDemo::draw(); - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(TextureDrawInRect::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); diff --git a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp index 75f0fd6eee..1b45442fd5 100644 --- a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp @@ -599,7 +599,7 @@ TMXOrthoObjectsTest::TMXOrthoObjectsTest() void TMXOrthoObjectsTest::draw() { - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(TMXOrthoObjectsTest::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); } @@ -672,7 +672,7 @@ TMXIsoObjectsTest::TMXIsoObjectsTest() void TMXIsoObjectsTest::draw() { - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(TMXIsoObjectsTest::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); } @@ -1504,7 +1504,7 @@ TMXGIDObjectsTest::TMXGIDObjectsTest() void TMXGIDObjectsTest::draw() { - _renderCmd.init(0, _vertexZ); + _renderCmd.init(_globalZOrder); _renderCmd.func = CC_CALLBACK_0(TMXGIDObjectsTest::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_renderCmd); } diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua index ae0da8b3bb..7ceb78c0e7 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua @@ -425,10 +425,10 @@ local function SpeedTest() local spawn = cc.Spawn:create(seq3_1, seq3_2) SpeedTest_action1 = cc.Speed:create(cc.RepeatForever:create(spawn), 1.0) - local spawn2 = tolua.cast(spawn:clone(), "Spawn") + local spawn2 = tolua.cast(spawn:clone(), "cc.Spawn") SpeedTest_action2 = cc.Speed:create(cc.RepeatForever:create(spawn2), 1.0) - local spawn3 = tolua.cast(spawn:clone(), "Spawn") + local spawn3 = tolua.cast(spawn:clone(), "cc.Spawn") SpeedTest_action3 = cc.Speed:create(cc.RepeatForever:create(spawn3), 1.0) grossini:runAction(SpeedTest_action2) diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua index 7a26897d9b..9b70078388 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua @@ -551,7 +551,7 @@ local function ActionAnimate() local animation3 = animation2:clone() -- problem - tolua.cast(animation3,"Animation"):setLoops(4) + tolua.cast(animation3,"cc.Animation"):setLoops(4) local action3 = cc.Animate:create(animation3) kathia:runAction(action3) @@ -740,7 +740,7 @@ local function ActionRotateToRepeat() local act2 = cc.RotateTo:create(1, 0) local seq = cc.Sequence:create(act1, act2) local rep1 = cc.RepeatForever:create(seq) - local rep2 = cc.Repeat:create(tolua.cast(seq:clone(), "Sequence"), 10) + local rep2 = cc.Repeat:create(tolua.cast(seq:clone(), "cc.Sequence"), 10) tamara:runAction(rep1) kathia:runAction(rep2) @@ -931,8 +931,8 @@ local function ActionOrbit() local seq = cc.Sequence:create(move, move_back) local rfe = cc.RepeatForever:create(seq) kathia:runAction(rfe) - tamara:runAction(tolua.cast(rfe:clone(), "ActionInterval")) - grossini:runAction(tolua.cast(rfe:clone(), "ActionInterval")) + tamara:runAction(tolua.cast(rfe:clone(), "cc.ActionInterval")) + grossini:runAction(tolua.cast(rfe:clone(), "cc.ActionInterval")) Helper.subtitleLabel:setString("OrbitCamera action") diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua index d47b24034e..7c15e2900b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua @@ -428,7 +428,7 @@ end function TestPerformance:refreshTitle() local subTitleInfo = ArmatureTestLayer.subTitle(5) .. self._armatureCount - local label = tolua.cast(self:getChildByTag(10001),"LabelTTF") + local label = tolua.cast(self:getChildByTag(10001),"cc.LabelTTF") label:setString(subTitleInfo) end diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id index 8d7bc14119..0279040f69 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id @@ -1 +1 @@ -1cb290e913d84d8cd141945c8b4a78ea45481cd5 \ No newline at end of file +09ed3c488f6d182685c416c291f8f325fb5cc2d2 \ No newline at end of file diff --git a/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua b/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua index 705ef3fac0..863044cd94 100644 --- a/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua @@ -95,7 +95,7 @@ local function Effect2() local delay = cc.DelayTime:create(1) - target:runAction(cc.Sequence:create(shaky, delay ,reuse, shuffle, tolua.cast(delay:clone(), "Action"), turnoff, turnon)) + target:runAction(cc.Sequence:create(shaky, delay ,reuse, shuffle, tolua.cast(delay:clone(), "cc.Action"), turnoff, turnon)) return ret end diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua index a379690f84..590ae907b6 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua @@ -30,7 +30,7 @@ ccb["TestScrollViewsLayer"] = TestScrollViewsLayer local function onMenuItemAClicked() if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then - local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"LabelBMFont") + local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"cc.LabelBMFont") if nil ~= labelBmFt then labelBmFt:setString("Menu Item A clicked."); end @@ -39,7 +39,7 @@ end local function onMenuItemBClicked() if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then - local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"LabelBMFont") + local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"cc.LabelBMFont") if nil ~= labelBmFt then labelBmFt:setString("Menu Item B clicked."); end @@ -48,7 +48,7 @@ end local function pressedC( ... ) if nil ~= TestMenusLayer["mMenuItemStatusLabelBMFont"] then - local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"LabelBMFont") + local labelBmFt = tolua.cast(TestMenusLayer["mMenuItemStatusLabelBMFont"],"cc.LabelBMFont") if nil ~= labelBmFt then labelBmFt:setString("Menu Item C clicked."); end @@ -59,9 +59,9 @@ local function onMenuTestClicked() local scene = cc.Scene:create() local proxy = cc.CCBProxy:create() local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestMenus.ccbi",proxy,HelloCocosBuilderLayer) - local layer = tolua.cast(node,"Layer") + local layer = tolua.cast(node,"cc.Layer") if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestMenus.ccbi") end @@ -88,9 +88,9 @@ local function onSpriteTestClicked() local scene = cc.Scene:create() local proxy = cc.CCBProxy:create() local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestSprites.ccbi",proxy,HelloCocosBuilderLayer) - local layer = tolua.cast(node,"Layer") + local layer = tolua.cast(node,"cc.Layer") if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestSprites.ccbi") end @@ -107,9 +107,9 @@ local function onButtonTestClicked() local scene = cc.Scene:create() local proxy = cc.CCBProxy:create() local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestButtons.ccbi",proxy,HelloCocosBuilderLayer) - local layer = tolua.cast(node,"Layer") + local layer = tolua.cast(node,"cc.Layer") if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestButtons.ccbi") end @@ -122,7 +122,7 @@ local function onButtonTestClicked() end local function onCCControlButtonClicked(sender,controlEvent) - local labelTTF = tolua.cast(TestButtonsLayer["mCCControlEventLabel"],"LabelBMFont") + local labelTTF = tolua.cast(TestButtonsLayer["mCCControlEventLabel"],"cc.LabelBMFont") if nil == labelTTF then return @@ -158,9 +158,9 @@ local function onAnimationsTestClicked() local scene = cc.Scene:create() local proxy = cc.CCBProxy:create() local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestAnimations.ccbi",proxy,HelloCocosBuilderLayer) - local layer = tolua.cast(node,"Layer") + local layer = tolua.cast(node,"cc.Layer") if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestAnimations.ccbi") end @@ -177,9 +177,9 @@ local function onParticleSystemTestClicked() local scene = cc.Scene:create() local proxy = cc.CCBProxy:create() local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestParticleSystems.ccbi",proxy,HelloCocosBuilderLayer) - local layer = tolua.cast(node,"Layer") + local layer = tolua.cast(node,"cc.Layer") if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestParticleSystems.ccbi") end @@ -193,7 +193,7 @@ end local function onCCControlButtonIdleClicked() if nil ~= TestAnimationsLayer["mAnimationManager"] then - local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager") + local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager") if nil ~= animationMgr then animationMgr:runAnimationsForSequenceNamedTweenDuration("Idle", 0.3) end @@ -202,7 +202,7 @@ end local function onCCControlButtonWaveClicked() if nil ~= TestAnimationsLayer["mAnimationManager"] then - local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager") + local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager") if nil ~= animationMgr then animationMgr:runAnimationsForSequenceNamedTweenDuration("Wave", 0.3) end @@ -211,7 +211,7 @@ end local function onCCControlButtonJumpClicked() if nil ~= TestAnimationsLayer["mAnimationManager"] then - local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager") + local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager") if nil ~= animationMgr then animationMgr:runAnimationsForSequenceNamedTweenDuration("Jump", 0.3) end @@ -220,7 +220,7 @@ end local function onCCControlButtonFunkyClicked() if nil ~= TestAnimationsLayer["mAnimationManager"] then - local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"CCBAnimationManager") + local animationMgr = tolua.cast(TestAnimationsLayer["mAnimationManager"],"cc.CCBAnimationManager") if nil ~= animationMgr then animationMgr:runAnimationsForSequenceNamedTweenDuration("Funky", 0.3) end @@ -237,9 +237,9 @@ local function onScrollViewTestClicked() local scene = cc.Scene:create() local proxy = cc.CCBProxy:create() local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestScrollViews.ccbi",proxy,HelloCocosBuilderLayer) - local layer = tolua.cast(node,"Layer") + local layer = tolua.cast(node,"cc.Layer") if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestScrollViews.ccbi") end @@ -256,9 +256,9 @@ local function onTimelineCallbackSoundClicked() local scene = cc.Scene:create() local proxy = cc.CCBProxy:create() local node = CCBReaderLoad("cocosbuilderRes/ccb/ccb/TestTimelineCallback.ccbi",proxy,HelloCocosBuilderLayer) - local layer = tolua.cast(node,"Layer") + local layer = tolua.cast(node,"cc.Layer") if nil ~= HelloCocosBuilderLayer["mTestTitleLabelTTF"] then - local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"LabelTTF") + local ccLabelTTF = tolua.cast(HelloCocosBuilderLayer["mTestTitleLabelTTF"],"cc.LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:setString("ccb/ccb/TestTimelineCallback.ccbi") end @@ -272,7 +272,7 @@ end function onCallback1() if nil ~= TestTimelineLayer["helloLabel"] then - local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"LabelTTF") + local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"cc.LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:runAction(cc.RotateBy:create(1, 360)) ccLabelTTF:setString("Callback 1"); @@ -282,7 +282,7 @@ end function onCallback2() if nil ~= TestTimelineLayer["helloLabel"] then - local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"LabelTTF") + local ccLabelTTF = tolua.cast(TestTimelineLayer["helloLabel"],"cc.LabelTTF") if nil ~= ccLabelTTF then ccLabelTTF:runAction(cc.RotateBy:create(2, 360)) ccLabelTTF:setString("Callback 2"); @@ -306,7 +306,7 @@ local function HelloCCBTestMainLayer() print(type(cc.Scene)) local proxy = cc.CCBProxy:create() local node = CCBReaderLoad("cocosbuilderRes/ccb/HelloCocosBuilder.ccbi",proxy,HelloCocosBuilderLayer) - local layer = tolua.cast(node,"Layer") + local layer = tolua.cast(node,"cc.Layer") return layer end diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua index b831962568..361dd03615 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua @@ -11,7 +11,9 @@ local ExtensionTestEnum = TEST_COCOSBUILDER = 2, TEST_WEBSOCKET = 3, TEST_EDITBOX = 4, - TEST_MAX_COUNT = 5, + TEST_TABLEVIEW = 5, + TEST_SCROLLVIEW = 6, + TEST_MAX_COUNT = 7, } local testsName = @@ -21,6 +23,8 @@ local testsName = "CocosBuilderTest", "WebSocketTest", "EditBoxTest", + "TableViewTest", + "ScrollViewTest", } @@ -65,7 +69,7 @@ local function runNotificationCenterTest() local s = cc.Director:getInstance():getWinSize() local function toggleSwitch(tag,menuItem) - local toggleItem = tolua.cast(menuItem,"MenuItemToggle") + local toggleItem = tolua.cast(menuItem,"cc.MenuItemToggle") local nIndex = toggleItem:getSelectedIndex() local selectedItem = toggleItem:getSelectedItem() if 0 == nIndex then @@ -151,7 +155,7 @@ local function runNotificationCenterTest() connectitem:setTag(NotificationCenterParam.kTagConnect+i) local function connectToSwitch(tag,menuItem) - local connectMenuitem = tolua.cast(menuItem,"MenuItemToggle") + local connectMenuitem = tolua.cast(menuItem,"cc.MenuItemToggle") local bConnected = true if connectMenuitem:getSelectedIndex() == 0 then bConnected = false @@ -372,7 +376,7 @@ local function runCCControlTest() if nil == pSender or nil == pDisplayValueLabel then return end - local pControl = tolua.cast(pSender,"ControlSlider") + local pControl = tolua.cast(pSender,"cc.ControlSlider") local strFmt = nil if pControl:getTag() == 1 then strFmt = string.format("Upper slider value = %.02f",pControl:getValue()) @@ -430,7 +434,7 @@ local function runCCControlTest() return end - local pPicker = tolua.cast(pSender,"ControlColourPicker") + local pPicker = tolua.cast(pSender,"cc.ControlColourPicker") local strFmt = string.format("#%02X%02X%02X",pPicker:getColor().r, pPicker:getColor().g, pPicker:getColor().b) pColorLabel:setString(strFmt) end @@ -495,7 +499,7 @@ local function runCCControlTest() return end - local pControl = tolua.cast(pSender,"ControlSwitch") + local pControl = tolua.cast(pSender,"cc.ControlSwitch") if pControl:isOn() then pDisplayValueLabel:setString("On") else @@ -770,7 +774,7 @@ local function runCCControlTest() return end - local pControl = tolua.cast(pSender,"ControlPotentiometer") + local pControl = tolua.cast(pSender,"cc.ControlPotentiometer") local strFmt = string.format("%0.2f",pControl:getValue()) pDisplayValueLabel:setString(strFmt ) end @@ -827,7 +831,7 @@ local function runCCControlTest() return end - local pControl = tolua.cast(pSender,"ControlStepper") + local pControl = tolua.cast(pSender,"cc.ControlStepper") local strFmt = string.format("%0.02f",pControl:getValue() ) pDisplayValueLabel:setString(strFmt ) end @@ -913,7 +917,7 @@ local function runEditBoxTest() local EditEmail = nil local function editBoxTextEventHandle(strEventName,pSender) - local edit = tolua.cast(pSender,"EditBox") + local edit = tolua.cast(pSender,"cc.EditBox") local strFmt if strEventName == "began" then strFmt = string.format("editBox %p DidBegin !", edit) @@ -988,6 +992,192 @@ local function runEditBoxTest() return newScene end +local TableViewTestLayer = class("TableViewTestLayer") +TableViewTestLayer.__index = TableViewTestLayer + +function TableViewTestLayer.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TableViewTestLayer) + return target +end + +function TableViewTestLayer.scrollViewDidScroll(view) + print("scrollViewDidScroll") +end + +function TableViewTestLayer.scrollViewDidZoom(view) + print("scrollViewDidZoom") +end + +function TableViewTestLayer.tableCellTouched(table,cell) + print("cell touched at index: " .. cell:getIdx()) +end + +function TableViewTestLayer.cellSizeForTable(table,idx) + return 60,60 +end + +function TableViewTestLayer.tableCellAtIndex(table, idx) + local strValue = string.format("%d",idx) + local cell = table:dequeueCell() + local label = nil + if nil == cell then + cell = cc.TableViewCell:new() + local sprite = cc.Sprite:create("Images/Icon.png") + sprite:setAnchorPoint(cc.p(0,0)) + sprite:setPosition(cc.p(0, 0)) + cell:addChild(sprite) + + label = cc.LabelTTF:create(strValue, "Helvetica", 20.0) + label:setPosition(cc.p(0,0)) + label:setAnchorPoint(cc.p(0,0)) + label:setTag(123) + cell:addChild(label) + else + label = tolua.cast(cell:getChildByTag(123),"cc.LabelTTF") + if nil ~= label then + label:setString(strValue) + end + end + + return cell +end + +function TableViewTestLayer.numberOfCellsInTableView(table) + return 25 +end + +function TableViewTestLayer:init() + + local winSize = cc.Director:getInstance():getWinSize() + + local tableView = cc.TableView:create(cc.size(600,60)) + tableView:setDirection(cc.SCROLLVIEW_DIRECTION_HORIZONTAL) + tableView:setPosition(cc.p(20, winSize.height / 2 - 150)) + tableView:setDelegate() + self:addChild(tableView) + --registerScriptHandler functions must be before the reloadData funtion + tableView:registerScriptHandler(TableViewTestLayer.numberOfCellsInTableView,cc.NUMBER_OF_CELLS_IN_TABLEVIEW) + tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL) + tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM) + tableView:registerScriptHandler(TableViewTestLayer.tableCellTouched,cc.TABLECELL_TOUCHED) + tableView:registerScriptHandler(TableViewTestLayer.cellSizeForTable,cc.TABLECELL_SIZE_FOR_INDEX) + tableView:registerScriptHandler(TableViewTestLayer.tableCellAtIndex,cc.TABLECELL_SIZE_AT_INDEX) + tableView:reloadData() + + tableView = cc.TableView:create(cc.size(60, 350)) + tableView:setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL) + tableView:setPosition(cc.p(winSize.width - 150, winSize.height / 2 - 150)) + tableView:setDelegate() + tableView:setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN) + self:addChild(tableView) + tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL) + tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM) + tableView:registerScriptHandler(TableViewTestLayer.tableCellTouched,cc.TABLECELL_TOUCHED) + tableView:registerScriptHandler(TableViewTestLayer.cellSizeForTable,cc.TABLECELL_SIZE_FOR_INDEX) + tableView:registerScriptHandler(TableViewTestLayer.tableCellAtIndex,cc.TABLECELL_SIZE_AT_INDEX) + tableView:registerScriptHandler(TableViewTestLayer.numberOfCellsInTableView,cc.NUMBER_OF_CELLS_IN_TABLEVIEW) + tableView:reloadData() + + -- Back Menu + local pToMainMenu = cc.Menu:create() + CreateExtensionsBasicLayerMenu(pToMainMenu) + pToMainMenu:setPosition(cc.p(0, 0)) + self:addChild(pToMainMenu,10) + + return true +end + +function TableViewTestLayer.create() + local layer = TableViewTestLayer.extend(cc.Layer:create()) + if nil ~= layer then + layer:init() + end + + return layer +end + +local function runTableViewTest() + local newScene = cc.Scene:create() + local newLayer = TableViewTestLayer.create() + newScene:addChild(newLayer) + return newScene +end + +local function runScrollViewTest() + local newScene = cc.Scene:create() + local newLayer = cc.Layer:create() + + -- Back Menu + local pToMainMenu = cc.Menu:create() + CreateExtensionsBasicLayerMenu(pToMainMenu) + pToMainMenu:setPosition(cc.p(0, 0)) + newLayer:addChild(pToMainMenu,10) + + local layerColor = cc.LayerColor:create(cc.c4b(128,64,0,255)) + newLayer:addChild(layerColor) + + local scrollView1 = cc.ScrollView:create() + local screenSize = cc.Director:getInstance():getWinSize() + local function scrollView1DidScroll() + print("scrollView1DidScroll") + end + local function scrollView1DidZoom() + print("scrollView1DidZoom") + end + if nil ~= scrollView1 then + scrollView1:setViewSize(cc.size(screenSize.width / 2,screenSize.height)) + scrollView1:setPosition(cc.p(0,0)) + scrollView1:setScale(1.0) + scrollView1:ignoreAnchorPointForPosition(true) + local flowersprite1 = cc.Sprite:create("ccb/flower.jpg") + if nil ~= flowersprite1 then + scrollView1:setContainer(flowersprite1) + scrollView1:updateInset() + end + scrollView1:setDirection(cc.SCROLLVIEW_DIRECTION_BOTH ) + scrollView1:setClippingToBounds(true) + scrollView1:setBounceable(true) + scrollView1:setDelegate() + scrollView1:registerScriptHandler(scrollView1DidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL) + scrollView1:registerScriptHandler(scrollView1DidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM) + end + newLayer:addChild(scrollView1) + + local scrollView2 = cc.ScrollView:create() + local function scrollView2DidScroll() + print("scrollView2DidScroll") + end + local function scrollView2DidZoom() + print("scrollView2DidZoom") + end + if nil ~= scrollView2 then + scrollView2:setViewSize(cc.size(screenSize.width / 2,screenSize.height)) + scrollView2:setPosition(cc.p(screenSize.width / 2,0)) + scrollView2:setScale(1.0) + scrollView2:ignoreAnchorPointForPosition(true) + local flowersprite2 = cc.Sprite:create("ccb/flower.jpg") + if nil ~= flowersprite2 then + scrollView2:setContainer(flowersprite2) + scrollView2:updateInset() + end + scrollView2:setDirection(cc.SCROLLVIEW_DIRECTION_BOTH ) + scrollView2:setClippingToBounds(true) + scrollView2:setBounceable(true) + scrollView2:setDelegate() + scrollView2:registerScriptHandler(scrollView2DidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL) + scrollView2:registerScriptHandler(scrollView2DidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM) + end + newLayer:addChild(scrollView2) + + newScene:addChild(newLayer) + return newScene +end + local CreateExtensionsTestTable = { runNotificationCenterTest, @@ -995,6 +1185,8 @@ local CreateExtensionsTestTable = runCocosBuilder, runWebSocketTest, runEditBoxTest, + runTableViewTest, + runScrollViewTest, } diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua index e27a321cb5..9a2c203ffd 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua @@ -83,9 +83,9 @@ toMainMenu:setPosition(cc.p(0, 0)) layer:addChild(toMainMenu,10) - wsSendText = WebSocket:create("ws://echo.websocket.org") - wsSendBinary = WebSocket:create("ws://echo.websocket.org") - wsError = WebSocket:create("ws://invalid.url.com") + wsSendText = cc.WebSocket:create("ws://echo.websocket.org") + wsSendBinary = cc.WebSocket:create("ws://echo.websocket.org") + wsError = cc.WebSocket:create("ws://invalid.url.com") local function wsSendTextOpen(strData) sendTextStatus:setString("Send Text WS was opened.") diff --git a/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua b/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua index 32649cbdba..3025c2afce 100644 --- a/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua @@ -32,11 +32,11 @@ function LabelAtlasTest.step(dt) local string = string.format("%2.2f Test", m_time) local label1_origin = LabelAtlasTest.layer:getChildByTag(kTagSprite1) - local label1 = tolua.cast(label1_origin, "LabelAtlas") + local label1 = tolua.cast(label1_origin, "cc.LabelAtlas") label1:setString(string) -- local label2_origin = LabelAtlasTest.layer:getChildByTag(kTagSprite2) - local label2 = tolua.cast(label2_origin, "LabelAtlas") + local label2 = tolua.cast(label2_origin, "cc.LabelAtlas") string = string.format("%d", m_time) label2:setString(string) @@ -88,11 +88,11 @@ function LabelAtlasColorTest.step(dt) m_time = m_time + dt local string = string.format("%2.2f Test", m_time) local label1_origin = LabelAtlasColorTest.layer:getChildByTag(kTagSprite1) - local label1 = tolua.cast(label1_origin, "LabelAtlas") + local label1 = tolua.cast(label1_origin, "cc.LabelAtlas") label1:setString(string) local label2_origin = LabelAtlasColorTest.layer:getChildByTag(kTagSprite2) - local label2 = tolua.cast(label2_origin, "LabelAtlas") + local label2 = tolua.cast(label2_origin, "cc.LabelAtlas") string = string.format("%d", m_time) label2:setString(string) @@ -199,7 +199,7 @@ function Atlas3.create() label2:setColor(cc.c3b(255, 0, 0 )) layer:addChild(label2, 0, kTagBitmapAtlas2) - label2:runAction( tolua.cast(repeatAction:clone(), "Action") ) + label2:runAction( tolua.cast(repeatAction:clone(), "cc.Action") ) local label3 = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt") -- testing anchors @@ -223,13 +223,13 @@ function Atlas3.step(dt) m_time = m_time + dt local string = string.format("%2.2f Test j", m_time) - local label1 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas1), "LabelBMFont") + local label1 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas1), "cc.LabelBMFont") label1:setString(string) - local label2 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas2), "LabelBMFont") + local label2 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas2), "cc.LabelBMFont") label2:setString(string) - local label3 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas3), "LabelBMFont") + local label3 = tolua.cast(Atlas3.layer:getChildByTag(kTagBitmapAtlas3), "cc.LabelBMFont") label3:setString(string) end @@ -309,7 +309,7 @@ function Atlas4.create() label2:setPosition( cc.p(s.width/2.0, 80) ) local lastChar = label2:getChildByTag(3) - lastChar:runAction(tolua.cast( rot_4ever:clone(), "Action" )) + lastChar:runAction(tolua.cast( rot_4ever:clone(), "cc.Action" )) layer:registerScriptHandler(Atlas4.onNodeEvent) @@ -329,7 +329,7 @@ function Atlas4.step(dt) local string = string.format("%04.1f", m_time) - local label1 = tolua.cast(Atlas4.layer:getChildByTag(kTagBitmapAtlas2), "LabelBMFont") + local label1 = tolua.cast(Atlas4.layer:getChildByTag(kTagBitmapAtlas2), "cc.LabelBMFont") label1:setString(string) end @@ -592,9 +592,9 @@ function LabelsEmpty.create() end function LabelsEmpty.updateStrings(dt) - local label1 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas1), "LabelBMFont") - local label2 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas2), "LabelTTF") - local label3 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas3), "LabelAtlas") + local label1 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas1), "cc.LabelBMFont") + local label2 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas2), "cc.LabelTTF") + local label3 = tolua.cast(LabelsEmpty.layer:getChildByTag(kTagBitmapAtlas3), "cc.LabelAtlas") if( LabelsEmpty.setEmpty == false) then label1:setString("not empty") @@ -1083,7 +1083,7 @@ end function BitmapFontMultiLineAlignment.stringChanged(tag, sender) - local item = tolua.cast(sender, "MenuItemFont") + local item = tolua.cast(sender, "cc.MenuItemFont") item:setColor(cc.c3b(255, 0, 0)) BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255)) BitmapFontMultiLineAlignment._pLastAlignmentItem = item @@ -1101,7 +1101,7 @@ end function BitmapFontMultiLineAlignment.alignmentChanged(tag, sender) -- cclog("BitmapFontMultiLineAlignment.alignmentChanged, tag:"..tag) - local item = tolua.cast(sender, "MenuItemFont") + local item = tolua.cast(sender, "cc.MenuItemFont") item:setColor(cc.c3b(255, 0, 0)) BitmapFontMultiLineAlignment._pLastAlignmentItem:setColor(cc.c3b(255, 255, 255)) BitmapFontMultiLineAlignment._pLastAlignmentItem = item diff --git a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua index 991ad016fd..5a8be68410 100644 --- a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua @@ -316,7 +316,7 @@ local function LayerTest1() local newSize = cc.size( math.abs(x - s.width/2)*2, math.abs(y - s.height/2)*2) - local l = tolua.cast(ret:getChildByTag(kTagLayer), "LayerColor") + local l = tolua.cast(ret:getChildByTag(kTagLayer), "cc.LayerColor") l:setContentSize( newSize ) end @@ -389,7 +389,7 @@ local function LayerTestBlend() local blend = true local function newBlend(dt) - local layer = tolua.cast(ret:getChildByTag(kTagLayer), "LayerColor") + local layer = tolua.cast(ret:getChildByTag(kTagLayer), "cc.LayerColor") local src = 0 local dst = 0 @@ -441,7 +441,7 @@ local function LayerGradient() local function toggleItem(sender) -- cclog("toggleItem") - local gradient = tolua.cast(ret:getChildByTag(kTagLayer), "LayerGradient") + local gradient = tolua.cast(ret:getChildByTag(kTagLayer), "cc.LayerGradient") gradient:setCompressedInterpolation(not gradient:isCompressedInterpolation()) end @@ -462,7 +462,7 @@ local function LayerGradient() local diff = cc.p(movingPos.x - start.x, movingPos.y - start.y) diff = cc.pNormalize(diff) - local gradient = tolua.cast(ret:getChildByTag(1), "LayerGradient") + local gradient = tolua.cast(ret:getChildByTag(1), "cc.LayerGradient") gradient:setVector(diff) end end @@ -487,7 +487,7 @@ local function LayerIgnoreAnchorPointPos() l:setPosition(cc.p( s.width/2, s.height/2)) local move = cc.MoveBy:create(2, cc.p(100,2)) - local back = tolua.cast(move:reverse(), "MoveBy") + local back = tolua.cast(move:reverse(), "cc.MoveBy") local seq = cc.Sequence:create(move, back) l:runAction(cc.RepeatForever:create(seq)) ret:addChild(l, 0, kLayerIgnoreAnchorPoint) @@ -564,7 +564,7 @@ local function LayerIgnoreAnchorPointScale() local scale = cc.ScaleBy:create(2, 2) - local back = tolua.cast(scale:reverse(), "ScaleBy") + local back = tolua.cast(scale:reverse(), "cc.ScaleBy") local seq = cc.Sequence:create(scale, back) l:runAction(cc.RepeatForever:create(seq)) diff --git a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua index d2593602e0..7569f70cf2 100644 --- a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua @@ -34,13 +34,13 @@ local function MenuLayerMainMenu() local function menuCallback(sender) cclog("menuCallback...") - tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(1) + tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(1) end item1:registerScriptTapHandler(menuCallback) -- Image Item local function menuCallback2(sender) - tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(2) + tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(2) end local item2 = cc.MenuItemImage:create(s_SendScore, s_PressSendScore) @@ -87,7 +87,7 @@ local function MenuLayerMainMenu() cc.MenuItemFont:setFontName("Marker Felt") local function menuCallbackConfig(sender) - tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(3) + tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(3) end -- Label Item (cc.LabelBMFont) @@ -101,7 +101,7 @@ local function MenuLayerMainMenu() -- Events cc.MenuItemFont:setFontName("Marker Felt") local function menuCallbackBugsTest(pSender) - tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(4) + tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(4) end -- Bugs Item @@ -117,7 +117,7 @@ local function MenuLayerMainMenu() item7:registerScriptTapHandler(onQuit) local function menuMovingCallback(pSender) - tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(5) + tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(5) end local item8 = cc.MenuItemFont:create("Remove menu item when moving") @@ -154,7 +154,7 @@ local function MenuLayerMainMenu() if pObject == nil then break end - child = tolua.cast(pObject, "Node") + child = tolua.cast(pObject, "cc.Node") local dstPointX, dstPointY = child:getPosition() local offset = s.width/2 + 50 if i % 2 == 0 then @@ -202,7 +202,7 @@ local function MenuLayer2() local function alignMenusH() local i = 0 for i=0, 1 do - local menu = tolua.cast(ret:getChildByTag(100+i), "Menu") + local menu = tolua.cast(ret:getChildByTag(100+i), "cc.Menu") menu:setPosition( m_centeredMenu ) if i==0 then -- TIP: if no padding, padding = 5 @@ -221,7 +221,7 @@ local function MenuLayer2() local function alignMenusV() local i = 0 for i=0, 1 do - local menu = tolua.cast(ret:getChildByTag(100+i), "Menu") + local menu = tolua.cast(ret:getChildByTag(100+i), "cc.Menu") menu:setPosition( m_centeredMenu ) if i==0 then -- TIP: if no padding, padding = 5 @@ -238,11 +238,11 @@ local function MenuLayer2() end local function menuCallback(sender) - tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(0) end local function menuCallbackOpacity(tag, sender) - local menu = tolua.cast(sender:getParent(), "Menu") + local menu = tolua.cast(sender:getParent(), "cc.Menu") local opacity = menu:getOpacity() if opacity == 128 then menu:setOpacity(255) @@ -307,7 +307,7 @@ local function MenuLayer3() local m_disabledItem = nil local ret = cc.Layer:create() local function menuCallback(sender) - tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(0) end local function menuCallback2(sender) @@ -359,8 +359,8 @@ local function MenuLayer3() item2:runAction( cc.RepeatForever:create(cc.Sequence:create( jump, jump:reverse()))) local spin1 = cc.RotateBy:create(3, 360) - local spin2 = tolua.cast(spin1:clone(), "ActionInterval") - local spin3 = tolua.cast(spin1:clone(), "ActionInterval") + local spin2 = tolua.cast(spin1:clone(), "cc.ActionInterval") + local spin3 = tolua.cast(spin1:clone(), "cc.ActionInterval") item1:runAction( cc.RepeatForever:create(spin1) ) item2:runAction( cc.RepeatForever:create(spin2) ) @@ -400,11 +400,11 @@ local function MenuLayer4() local item1 = cc.MenuItemToggle:create(cc.MenuItemFont:create( "On" )) local function menuCallback(tag, sender) - cclog("selected item: tag: %d, index:%d", tag, tolua.cast(sender, "MenuItemToggle"):getSelectedIndex() ) + cclog("selected item: tag: %d, index:%d", tag, tolua.cast(sender, "cc.MenuItemToggle"):getSelectedIndex() ) end local function backCallback(tag, sender) - tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(0) end item1:registerScriptTapHandler(menuCallback) @@ -477,21 +477,21 @@ end local function BugsTest() local ret = cc.Layer:create() local function issue1410MenuCallback(tag, pSender) - local menu = tolua.cast(pSender:getParent(), "Menu") + local menu = tolua.cast(pSender:getParent(), "cc.Menu") menu:setEnabled(false) menu:setEnabled(true) cclog("NO CRASHES") end local function issue1410v2MenuCallback(tag, pSender) - local menu = tolua.cast(pSender:getParent(), "Menu") + local menu = tolua.cast(pSender:getParent(), "cc.Menu") menu:setEnabled(true) menu:setEnabled(false) cclog("NO CRASHES. AND MENU SHOULD STOP WORKING") end local function backMenuCallback(tag, pSender) - tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(0) end @@ -528,7 +528,7 @@ local function RemoveMenuItemWhenMove() local back = cc.MenuItemFont:create("go back") local function goBack(tag, pSender) - tolua.cast(ret:getParent(), "LayerMultiplex"):switchTo(0) + tolua.cast(ret:getParent(), "cc.LayerMultiplex"):switchTo(0) end back:registerScriptTapHandler(goBack) diff --git a/samples/Lua/TestLua/Resources/luaScript/NewEventDispatcherTest/NewEventDispatcherTest.lua b/samples/Lua/TestLua/Resources/luaScript/NewEventDispatcherTest/NewEventDispatcherTest.lua index e363ae3141..10be2d574c 100644 --- a/samples/Lua/TestLua/Resources/luaScript/NewEventDispatcherTest/NewEventDispatcherTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/NewEventDispatcherTest/NewEventDispatcherTest.lua @@ -184,7 +184,7 @@ function TouchableSpriteTest:onEnter() sprite2:addChild(sprite3, 1) local function onTouchBegan(touch, event) - local target = tolua.cast(event:getCurrentTarget(),"Sprite") + local target = tolua.cast(event:getCurrentTarget(),"cc.Sprite") local locationInNode = target:convertToNodeSpace(touch:getLocation()) local s = target:getContentSize() @@ -199,14 +199,14 @@ function TouchableSpriteTest:onEnter() end local function onTouchMoved(touch, event) - local target = tolua.cast(event:getCurrentTarget(), "Sprite") + local target = tolua.cast(event:getCurrentTarget(), "cc.Sprite") local posX,posY = target:getPosition() local delta = touch:getDelta() target:setPosition(cc.p(posX + delta.x, posY + delta.y)) end local function onTouchEnded(touch, event) - local target = tolua.cast(event:getCurrentTarget(), "Sprite") + local target = tolua.cast(event:getCurrentTarget(), "cc.Sprite") print("sprite onTouchesEnded..") target:setOpacity(255) if target == sprite2 then diff --git a/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua b/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua index 47e4d0103e..9ffcac5706 100644 --- a/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua @@ -261,10 +261,10 @@ local function Test6() local rot = cc.RotateBy:create(2, 360) local rot_back = rot:reverse() local forever1 = cc.RepeatForever:create(cc.Sequence:create(rot, rot_back)) - local forever11 = tolua.cast(forever1:clone(), "RepeatForever") + local forever11 = tolua.cast(forever1:clone(), "cc.RepeatForever") - local forever2 = tolua.cast(forever1:clone(), "RepeatForever") - local forever21 = tolua.cast(forever1:clone(), "RepeatForever") + local forever2 = tolua.cast(forever1:clone(), "cc.RepeatForever") + local forever21 = tolua.cast(forever1:clone(), "cc.RepeatForever") Test6_layer:addChild(sp1, 0, kTagSprite1) sp1:addChild(sp11) @@ -370,10 +370,10 @@ local function StressTest2() local fire = cc.ParticleFire:create() fire:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) - fire = tolua.cast(fire, "Node") + fire = tolua.cast(fire, "cc.Node") fire:setPosition(80, s.height / 2 - 50) - local copy_seq3 = tolua.cast(seq3:clone(), "Sequence") + local copy_seq3 = tolua.cast(seq3:clone(), "cc.Sequence") fire:runAction(cc.RepeatForever:create(copy_seq3)) sublayer:addChild(fire, 2) @@ -564,7 +564,7 @@ local function ConvertToNode() point:setPosition(sprite:getPosition()) - local copy = tolua.cast(action:clone(), "RepeatForever") + local copy = tolua.cast(action:clone(), "cc.RepeatForever") sprite:runAction(copy) ConvertToNode_layer:addChild(sprite, i) end diff --git a/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua b/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua index 91ac6844e4..e34f399e07 100644 --- a/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua @@ -147,7 +147,7 @@ local function OpenGLTestMainLayer() local i = 0 local len = table.getn(children) for i= 0 ,len - 1 do - local child = tolua.cast(children[i + 1], "Sprite") + local child = tolua.cast(children[i + 1], "cc.Sprite") local oldPosX,oldPosY = child:getPosition() child:setPosition(oldPosX,math.sin(accum * 2 + i / 2.0) * 20) local scaleY = math.sin(accum * 2 + i / 2.0 + 0.707) @@ -558,7 +558,7 @@ local function OpenGLTestMainLayer() local function getCurrentResult() local var = {} - local glProgam = tolua.cast(sprite:getShaderProgram(),"GLProgram") + local glProgam = tolua.cast(sprite:getShaderProgram(),"cc.GLProgram") if nil ~= glProgam then local p = glProgam:getProgram() local aaSize,aaType,aaName = gl.getActiveAttrib(p,0) diff --git a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua index 0267dd0eb0..71f6c569f1 100644 --- a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua @@ -147,7 +147,7 @@ local function runNodeChildrenTest() local function updateQuantityLabel() if nQuantityOfNodes ~= nLastRenderedCount then -- local pInfoLabel = pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer) - local pInfoLabel = tolua.cast(pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer), "LabelTTF") + local pInfoLabel = tolua.cast(pNewscene:getChildByTag(NodeChildrenTestParam.kTagInfoLayer), "cc.LabelTTF") local strNode = nQuantityOfNodes.." nodes" pInfoLabel:setString(strNode) nLastRenderedCount = nQuantityOfNodes @@ -166,7 +166,7 @@ local function runNodeChildrenTest() local i = 0 local len = table.getn(pChildren) for i = 0, len - 1, 1 do - local child = tolua.cast(pChildren[i + 1], "Sprite") + local child = tolua.cast(pChildren[i + 1], "cc.Sprite") child:setVisible(false) end end @@ -189,7 +189,7 @@ local function runNodeChildrenTest() end for i = 0 , nTotalToAdd - 1 do - local pChild = tolua.cast(pSprites[i + 1],"Node") + local pChild = tolua.cast(pSprites[i + 1],"cc.Node") pBatchNode:addChild(pChild, zs[i], NodeChildrenTestParam.kTagBase + i) end @@ -216,7 +216,7 @@ local function runNodeChildrenTest() end -- add them with random Z (very important!) for i=0, nTotalToAdd - 1 do - local pChild = tolua.cast(pSprites[i + 1],"Node") + local pChild = tolua.cast(pSprites[i + 1],"cc.Node") pBatchNode:addChild(pChild, math.random(-1,1) * 50, NodeChildrenTestParam.kTagBase + i) end @@ -244,7 +244,7 @@ local function runNodeChildrenTest() --dd them with random Z (very important!) for i = 0, nTotalToAdd - 1 do - local pChild = tolua.cast(pSprites[i + 1] ,"Node") + local pChild = tolua.cast(pSprites[i + 1] ,"cc.Node") pBatchNode:addChild(pChild, math.random(-1,1) * 50, NodeChildrenTestParam.kTagBase + i) end @@ -252,7 +252,7 @@ local function runNodeChildrenTest() -- reorder them for i = 0, nTotalToAdd - 1 do - local pNode = tolua.cast(pSprites[i + 1],"Node") + local pNode = tolua.cast(pSprites[i + 1],"cc.Node") pBatchNode:reorderChild(pNode, math.random(-1,1) * 50) end pBatchNode:sortAllChildren() @@ -508,7 +508,7 @@ local function runParticleTest() local function UpdateQuantityLabel() if nQuantityParticles ~= nLastRenderedCount then - local pInfoLabel = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagInfoLayer), "LabelTTF") + local pInfoLabel = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagInfoLayer), "cc.LabelTTF") local strInfo = string.format("%u particles", nQuantityParticles) pInfoLabel:setString(strInfo) @@ -518,7 +518,7 @@ local function runParticleTest() local function doTest() local s = cc.Director:getInstance():getWinSize() - local pParticleSystem = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"ParticleSystem") + local pParticleSystem = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"cc.ParticleSystem") if nil == pParticleSystem then return end @@ -763,8 +763,8 @@ local function runParticleTest() end local function step(t) - local pAtlas = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagLabelAtlas),"LabelAtlas") - local pEmitter = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"ParticleSystem") + local pAtlas = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagLabelAtlas),"cc.LabelAtlas") + local pEmitter = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"cc.ParticleSystem") local strInfo = string.format("%4d",pEmitter:getParticleCount()) pAtlas:setString(strInfo) end @@ -989,7 +989,7 @@ local function runSpriteTest() local function UpdateNodes() if nQuantityNodes ~= nLastRenderedCount then - local pInfoLabel = tolua.cast(pNewScene:getChildByTag(SpriteTestParam.kTagInfoLayer), "LabelTTF") + local pInfoLabel = tolua.cast(pNewScene:getChildByTag(SpriteTestParam.kTagInfoLayer), "cc.LabelTTF") local strInfo = string.format("%u nodes", nQuantityNodes) pInfoLabel:setString(strInfo) nLastRenderedCount = nQuantityNodes diff --git a/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua b/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua index c6e9c6dd7b..05f6ae2488 100644 --- a/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua @@ -445,7 +445,7 @@ function SpriteAnchorPoint.initLayer(layer) end point:setPosition( sprite:getPosition() ) - local copy = tolua.cast(action:clone(), "Action") + local copy = tolua.cast(action:clone(), "cc.Action") sprite:runAction(copy) layer:addChild(sprite, i) end @@ -498,7 +498,7 @@ function SpriteBatchNodeAnchorPoint.initLayer(layer) point:setPosition( cc.p(sprite:getPosition()) ) - local copy = tolua.cast(action:clone(), "Action") + local copy = tolua.cast(action:clone(), "cc.Action") sprite:runAction(copy) batch:addChild(sprite, i) end diff --git a/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua b/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua index ec191438b1..ff4ffd467e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua @@ -110,7 +110,7 @@ local function TextureMipMap() local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3) local sc_back = scale1:reverse() - local scale2 = tolua.cast(scale1:clone(), "EaseOut") + local scale2 = tolua.cast(scale1:clone(), "cc.EaseOut") local sc_back2 = scale2:reverse() img0:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back))) @@ -148,7 +148,7 @@ local function TexturePVRMipMap() local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3) local sc_back = scale1:reverse() - local scale2 = tolua.cast(scale1:clone(), "EaseOut") + local scale2 = tolua.cast(scale1:clone(), "cc.EaseOut") local sc_back2 = scale2:reverse() imgMipMap:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back))) @@ -182,7 +182,7 @@ local function TexturePVRMipMap2() local scale1 = cc.EaseOut:create(cc.ScaleBy:create(4, 0.01), 3) local sc_back = scale1:reverse() - local scale2 = tolua.cast(scale1:clone(), "EaseOut") + local scale2 = tolua.cast(scale1:clone(), "cc.EaseOut") local sc_back2 = scale2:reverse() imgMipMap:runAction(cc.RepeatForever:create(cc.Sequence:create(scale1, sc_back))) @@ -803,9 +803,9 @@ local function TextureAlias() -- scale them to show local sc = cc.ScaleBy:create(3, 8.0) - local sc_back = tolua.cast(sc:reverse(), "ScaleBy") + local sc_back = tolua.cast(sc:reverse(), "cc.ScaleBy") local scaleforever = cc.RepeatForever:create(cc.Sequence:create(sc, sc_back)) - local scaleToo = tolua.cast(scaleforever:clone(), "RepeatForever") + local scaleToo = tolua.cast(scaleforever:clone(), "cc.RepeatForever") sprite2:runAction(scaleforever) sprite:runAction(scaleToo) @@ -829,7 +829,7 @@ local function TexturePixelFormat() -- 3- 16-bit RGB5A1 -- 4- 16-bit RGB565 - local label = tolua.cast(ret:getChildByTag(kTagLabel), "LabelTTF") + local label = tolua.cast(ret:getChildByTag(kTagLabel), "cc.LabelTTF") label:setColor(cc.c3b(16,16,255)) local s = cc.Director:getInstance():getWinSize() @@ -895,10 +895,10 @@ local function TexturePixelFormat() local fadein = cc.FadeIn:create(2) local seq = cc.Sequence:create(cc.DelayTime:create(2), fadeout, fadein) local seq_4ever = cc.RepeatForever:create(seq) - local seq_4ever2 = tolua.cast(seq_4ever:clone(), "RepeatForever") - local seq_4ever3 = tolua.cast(seq_4ever:clone(), "RepeatForever") - local seq_4ever4 = tolua.cast(seq_4ever:clone(), "RepeatForever") - local seq_4ever5 = tolua.cast(seq_4ever:clone(), "RepeatForever") + local seq_4ever2 = tolua.cast(seq_4ever:clone(), "cc.RepeatForever") + local seq_4ever3 = tolua.cast(seq_4ever:clone(), "cc.RepeatForever") + local seq_4ever4 = tolua.cast(seq_4ever:clone(), "cc.RepeatForever") + local seq_4ever5 = tolua.cast(seq_4ever:clone(), "cc.RepeatForever") sprite1:runAction(seq_4ever) sprite2:runAction(seq_4ever2) @@ -964,12 +964,12 @@ local function TextureAsync() ret:addChild(label, 10) local scale = cc.ScaleBy:create(0.3, 2) - local scale_back = tolua.cast(scale:reverse(), "ScaleBy") + local scale_back = tolua.cast(scale:reverse(), "cc.ScaleBy") local seq = cc.Sequence:create(scale, scale_back) label:runAction(cc.RepeatForever:create(seq)) local function imageLoaded(pObj) - local tex = tolua.cast(pObj, "Texture2D") + local tex = tolua.cast(pObj, "cc.Texture2D") local director = cc.Director:getInstance() --cc.ASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread") @@ -1043,7 +1043,7 @@ local function TextureGlClamp() local rotate = cc.RotateBy:create(4, 360) sprite:runAction(rotate) local scale = cc.ScaleBy:create(2, 0.04) - local scaleBack = tolua.cast(scale:reverse(), "ScaleBy") + local scaleBack = tolua.cast(scale:reverse(), "cc.ScaleBy") local seq = cc.Sequence:create(scale, scaleBack) sprite:runAction(seq) local function onNodeEvent(event) @@ -1077,7 +1077,7 @@ local function TextureGlRepeat() local rotate = cc.RotateBy:create(4, 360) sprite:runAction(rotate) local scale = cc.ScaleBy:create(2, 0.04) - local scaleBack = tolua.cast(scale:reverse(), "ScaleBy") + local scaleBack = tolua.cast(scale:reverse(), "cc.ScaleBy") local seq = cc.Sequence:create(scale, scaleBack) sprite:runAction(seq) local function onNodeEvent(event) @@ -1338,7 +1338,7 @@ local function TexturePVRv3Premult() local function transformSprite(sprite) local fade = cc.FadeOut:create(2) local dl = cc.DelayTime:create(2) - local fadein = tolua.cast(fade:reverse(), "FadeOut") + local fadein = tolua.cast(fade:reverse(), "cc.FadeOut") local seq = cc.Sequence:create(fade, fadein, dl) local repeatAction = cc.RepeatForever:create(seq) sprite:runAction(repeatAction) diff --git a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua index c2326ca230..66fc8ffac1 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua @@ -90,7 +90,7 @@ local function TileMapEditTest() -- The only limitation is that you cannot change an empty, or assign an empty tile to a tile -- The value 0 not rendered so don't assign or change a tile with value 0 - local tilemap = tolua.cast(layer:getChildByTag(kTagTileMap), "TileMapAtlas") + local tilemap = tolua.cast(layer:getChildByTag(kTagTileMap), "cc.TileMapAtlas") -- -- For example you can iterate over all the tiles @@ -165,7 +165,7 @@ local function TMXOrthoTest() local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do pObject = pChildrenArray[i + 1] - child = tolua.cast(pObject, "SpriteBatchNode") + child = tolua.cast(pObject, "cc.SpriteBatchNode") if child == nil then break @@ -219,7 +219,7 @@ local function TMXOrthoTest2() local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - child = tolua.cast(pChildrenArray[i + 1], "SpriteBatchNode") + child = tolua.cast(pChildrenArray[i + 1], "cc.SpriteBatchNode") if child == nil then break @@ -251,7 +251,7 @@ local function TMXOrthoTest3() local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - child = tolua.cast(pChildrenArray[i + 1], "SpriteBatchNode") + child = tolua.cast(pChildrenArray[i + 1], "cc.SpriteBatchNode") if child == nil then break @@ -285,7 +285,7 @@ local function TMXOrthoTest4() local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - child = tolua.cast(pChildrenArray[i + 1], "SpriteBatchNode") + child = tolua.cast(pChildrenArray[i + 1], "cc.SpriteBatchNode") if child == nil then break @@ -312,7 +312,7 @@ local function TMXOrthoTest4() local function removeSprite(dt) scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "cc.TMXTiledMap") local layer0 = map:getLayer("Layer 0") local s = layer0:getLayerSize() @@ -376,7 +376,7 @@ local function TMXReadWriteTest() local function removeSprite(sender) --------cclog("removing tile: %x", sender) - local node = tolua.cast(sender, "Node") + local node = tolua.cast(sender, "cc.Node") if nil == node then print("Errro node is nil") end @@ -390,9 +390,9 @@ local function TMXReadWriteTest() local finish = cc.CallFunc:create(removeSprite) local seq0 = cc.Sequence:create(move, rotate, scale, opacity, fadein, scaleback, finish) - local seq1 = tolua.cast(seq0:clone(), "Action") - local seq2 = tolua.cast(seq0:clone(), "Action") - local seq3 = tolua.cast(seq0:clone(), "Action") + local seq1 = tolua.cast(seq0:clone(), "cc.Action") + local seq2 = tolua.cast(seq0:clone(), "cc.Action") + local seq3 = tolua.cast(seq0:clone(), "cc.Action") tile0:runAction(seq0) tile1:runAction(seq1) @@ -408,8 +408,8 @@ local function TMXReadWriteTest() local function updateCol(dt) - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") - local layer = tolua.cast(map:getChildByTag(0), "TMXLayer") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "cc.TMXTiledMap") + local layer = tolua.cast(map:getChildByTag(0), "cc.TMXLayer") --------cclog("++++atlas quantity: %d", layer:textureAtlas():getTotalQuads()) --------cclog("++++children: %d", layer:getChildren():count() ) @@ -426,8 +426,8 @@ local function TMXReadWriteTest() local function repaintWithGID(dt) -- unschedule:_cmd) - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") - local layer = tolua.cast(map:getChildByTag(0), "TMXLayer") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "cc.TMXTiledMap") + local layer = tolua.cast(map:getChildByTag(0), "cc.TMXLayer") local s = layer:getLayerSize() local x = 0 @@ -441,8 +441,8 @@ local function TMXReadWriteTest() local function removeTiles(dt) scheduler:unscheduleScriptEntry(removeTilesScheduler) removeTilesScheduler = nil - local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap") - local layer = tolua.cast(map:getChildByTag(0), "TMXLayer") + local map = tolua.cast(ret:getChildByTag(kTagTileMap), "cc.TMXTiledMap") + local layer = tolua.cast(map:getChildByTag(0), "cc.TMXLayer") local s = layer:getLayerSize() local y = 0 for y=0, s.height-1, 1 do @@ -588,7 +588,7 @@ local function TMXUncompressedTest() local i = 0 local len = table.getn(pChildrenArray) for i = 0, len-1, 1 do - layer = tolua.cast(pChildrenArray[i + 1], "TMXLayer") + layer = tolua.cast(pChildrenArray[i + 1], "cc.TMXLayer") if layer == nil then break end @@ -659,7 +659,7 @@ end local function draw() - local map = tolua.cast(getChildByTag(kTagTileMap), "TMXTiledMap") + local map = tolua.cast(getChildByTag(kTagTileMap), "cc.TMXTiledMap") local group = map:getObjectGroup("Object Group 1") local objects = group:getObjects() @@ -716,7 +716,7 @@ local function TMXIsoObjectsTest() local i = 0 local len = table.getn(objects) for i = 0, len-1, 1 do - dict = tolua.cast(objects[i + 1], "Dictionary") + dict = tolua.cast(objects[i + 1], "cc.Dictionary") if dict == nil then break @@ -728,7 +728,7 @@ end local function draw() - local map = tolua.cast(getChildByTag(kTagTileMap), "TMXTiledMap") + local map = tolua.cast(getChildByTag(kTagTileMap), "cc.TMXTiledMap") local group = map:getObjectGroup("Object Group 1") local objects = group:getObjects() @@ -736,20 +736,20 @@ local function draw() local i = 0 local len = table.getn(objects) for i = 0, len-1, 1 do - dict = tolua.cast(objects[i + 1], "Dictionary") + dict = tolua.cast(objects[i + 1], "cc.Dictionary") if dict == nil then break end local key = "x" - local x = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("x")):getNumber() + local x = (tolua.cast(dict:objectForKey(key), "cc.String")):intValue()--dynamic_cast(dict:objectForKey("x")):getNumber() key = "y" - local y = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("y")):getNumber() + local y = (tolua.cast(dict:objectForKey(key), "cc.String")):intValue()--dynamic_cast(dict:objectForKey("y")):getNumber() key = "width" - local width = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("width")):getNumber() + local width = (tolua.cast(dict:objectForKey(key), "cc.String")):intValue()--dynamic_cast(dict:objectForKey("width")):getNumber() key = "height" - local height = (tolua.cast(dict:objectForKey(key), "String")):intValue()--dynamic_cast(dict:objectForKey("height")):getNumber() + local height = (tolua.cast(dict:objectForKey(key), "cc.String")):intValue()--dynamic_cast(dict:objectForKey("height")):getNumber() glLineWidth(3) @@ -1081,7 +1081,7 @@ local function TMXOrthoFlipTest() local i = 0 for i = 0, table.getn(map:getChildren())-1, 1 do - local child = tolua.cast(map:getChildren()[i + 1], "SpriteBatchNode") + local child = tolua.cast(map:getChildren()[i + 1], "cc.SpriteBatchNode") child:getTexture():setAntiAliasTexParameters() end @@ -1106,7 +1106,7 @@ local function TMXOrthoFlipRunTimeTest() local i = 0 for i = 0, table.getn(map:getChildren())-1, 1 do - local child = tolua.cast(map:getChildren()[i + 1], "SpriteBatchNode") + local child = tolua.cast(map:getChildren()[i + 1], "cc.SpriteBatchNode") child:getTexture():setAntiAliasTexParameters() end @@ -1186,7 +1186,7 @@ local function TMXOrthoFromXMLTest() local i = 0 local len = table.getn(map:getChildren()) for i = 0, len-1, 1 do - local child = tolua.cast(map:getChildren()[i + 1], "SpriteBatchNode") + local child = tolua.cast(map:getChildren()[i + 1], "cc.SpriteBatchNode") child:getTexture():setAntiAliasTexParameters() end @@ -1214,7 +1214,7 @@ local function TMXBug987() local len = table.getn(childs) local pNode = nil for i = 0, len-1, 1 do - pNode = tolua.cast(childs[i + 1], "TMXLayer") + pNode = tolua.cast(childs[i + 1], "cc.TMXLayer") if pNode == nil then break end diff --git a/samples/Lua/TestLua/Resources/luaScript/XMLHttpRequestTest/XMLHttpRequestTest.lua b/samples/Lua/TestLua/Resources/luaScript/XMLHttpRequestTest/XMLHttpRequestTest.lua index 1cdffa035a..4bec50a734 100644 --- a/samples/Lua/TestLua/Resources/luaScript/XMLHttpRequestTest/XMLHttpRequestTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/XMLHttpRequestTest/XMLHttpRequestTest.lua @@ -22,7 +22,7 @@ local function XMLHttpRequestLayer() --Get local function onMenuGetClicked() - local xhr = XMLHttpRequest:new() + local xhr = cc.XMLHttpRequest:new() xhr.responseType = cc.XMLHTTPREQUEST_RESPONSE_STRING xhr:open("GET", "http://httpbin.org/get") @@ -46,7 +46,7 @@ local function XMLHttpRequestLayer() --Post local function onMenuPostClicked() - local xhr = XMLHttpRequest:new() + local xhr = cc.XMLHttpRequest:new() xhr.responseType = cc.XMLHTTPREQUEST_RESPONSE_STRING xhr:open("POST", "http://httpbin.org/post") local function onReadyStateChange() @@ -67,7 +67,7 @@ local function XMLHttpRequestLayer() --Post Binary local function onMenuPostBinaryClicked() - local xhr = XMLHttpRequest:new() + local xhr = cc.XMLHttpRequest:new() xhr.responseType = cc.XMLHTTPREQUEST_RESPONSE_ARRAY_BUFFER xhr:open("POST", "http://httpbin.org/post") @@ -102,7 +102,7 @@ local function XMLHttpRequestLayer() --Post Json local function onMenuPostJsonClicked() - local xhr = XMLHttpRequest:new() + local xhr = cc.XMLHttpRequest:new() xhr.responseType = cc.XMLHTTPREQUEST_RESPONSE_JSON xhr:open("POST", "http://httpbin.org/post") diff --git a/template/multi-platform-cpp/proj.android/build_native.py b/template/multi-platform-cpp/proj.android/build_native.py index 03ee8de50f..c702b81a85 100755 --- a/template/multi-platform-cpp/proj.android/build_native.py +++ b/template/multi-platform-cpp/proj.android/build_native.py @@ -8,6 +8,16 @@ import os, os.path import shutil from optparse import OptionParser +def get_num_of_cpu(): + ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. + ''' + try: + from numpy.distutils import cpuinfo + return cpuinfo.cpu._getNCPUs() + except Exception: + print "Can't know cpuinfo, use default 1 cpu" + return 1 + def check_environment_variables_sdk(): ''' Checking the environment ANDROID_SDK_ROOT, which will be used for building ''' @@ -61,11 +71,13 @@ def do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,and ndk_module_path = 'NDK_MODULE_PATH=%s;%s/external;%s/cocos' % (cocos_root, cocos_root, cocos_root) else: ndk_module_path = 'NDK_MODULE_PATH=%s:%s/external:%s/cocos' % (cocos_root, cocos_root, cocos_root) - + + num_of_cpu = get_num_of_cpu() + if ndk_build_param == None: - command = '%s -C %s %s' % (ndk_path, app_android_root, ndk_module_path) + command = '%s -j%d -C %s %s' % (ndk_path, num_of_cpu, app_android_root, ndk_module_path) else: - command = '%s -C %s %s %s' % (ndk_path, app_android_root, ''.join(str(e) for e in ndk_build_param), ndk_module_path) + command = '%s -j%d -C %s %s %s' % (ndk_path, num_of_cpu, app_android_root, ''.join(str(e) for e in ndk_build_param), ndk_module_path) if os.system(command) != 0: raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!") elif android_platform is not None: diff --git a/template/multi-platform-js/proj.android/build_native.py b/template/multi-platform-js/proj.android/build_native.py index 4b20992504..42dd3aa9b6 100755 --- a/template/multi-platform-js/proj.android/build_native.py +++ b/template/multi-platform-js/proj.android/build_native.py @@ -8,6 +8,16 @@ import os, os.path import shutil from optparse import OptionParser +def get_num_of_cpu(): + ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. + ''' + try: + from numpy.distutils import cpuinfo + return cpuinfo.cpu._getNCPUs() + except Exception: + print "Can't know cpuinfo, use default 1 cpu" + return 1 + def check_environment_variables_sdk(): ''' Checking the environment ANDROID_SDK_ROOT, which will be used for building ''' @@ -62,10 +72,12 @@ def do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,and else: ndk_module_path = 'NDK_MODULE_PATH=%s:%s/external:%s/cocos' % (cocos_root, cocos_root, cocos_root) + num_of_cpu = get_num_of_cpu() + if ndk_build_param == None: - command = '%s -C %s %s' % (ndk_path, app_android_root, ndk_module_path) + command = '%s -j%d -C %s %s' % (ndk_path, num_of_cpu, app_android_root, ndk_module_path) else: - command = '%s -C %s %s %s' % (ndk_path, app_android_root, ''.join(str(e) for e in ndk_build_param), ndk_module_path) + command = '%s -j%d -C %s %s %s' % (ndk_path, num_of_cpu, app_android_root, ''.join(str(e) for e in ndk_build_param), ndk_module_path) if os.system(command) != 0: raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!") elif android_platform is not None: diff --git a/template/multi-platform-lua/proj.android/build_native.py b/template/multi-platform-lua/proj.android/build_native.py index 7414dd23af..b6920e2bbe 100755 --- a/template/multi-platform-lua/proj.android/build_native.py +++ b/template/multi-platform-lua/proj.android/build_native.py @@ -8,6 +8,16 @@ import os, os.path import shutil from optparse import OptionParser +def get_num_of_cpu(): + ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. + ''' + try: + from numpy.distutils import cpuinfo + return cpuinfo.cpu._getNCPUs() + except Exception: + print "Can't know cpuinfo, use default 1 cpu" + return 1 + def check_environment_variables_sdk(): ''' Checking the environment ANDROID_SDK_ROOT, which will be used for building ''' @@ -62,10 +72,12 @@ def do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,and else: ndk_module_path = 'NDK_MODULE_PATH=%s:%s/external:%s/cocos' % (cocos_root, cocos_root, cocos_root) + num_of_cpu = get_num_of_cpu() + if ndk_build_param == None: - command = '%s -C %s %s' % (ndk_path, app_android_root, ndk_module_path) + command = '%s -j%d -C %s %s' % (ndk_path, num_of_cpu, app_android_root, ndk_module_path) else: - command = '%s -C %s %s %s' % (ndk_path, app_android_root, ''.join(str(e) for e in ndk_build_param), ndk_module_path) + command = '%s -j%d -C %s %s %s' % (ndk_path, num_of_cpu, app_android_root, ''.join(str(e) for e in ndk_build_param), ndk_module_path) if os.system(command) != 0: raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!") elif android_platform is not None: diff --git a/tools/bindings-generator b/tools/bindings-generator index 71a0aa4bc7..6fc3372cdf 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 71a0aa4bc70743ae2078f4a43217987751ff17ec +Subproject commit 6fc3372cdfdbf39dd20bdcf1f60eb779773d32d7 diff --git a/tools/jenkins-scripts/pull-request-builder.py b/tools/jenkins-scripts/pull-request-builder.py index 0b0733639b..91b54c7f69 100755 --- a/tools/jenkins-scripts/pull-request-builder.py +++ b/tools/jenkins-scripts/pull-request-builder.py @@ -27,6 +27,7 @@ def set_description(desc, url): def main(): #get payload from os env payload_str = os.environ['payload'] + payload_str = payload_str.decode('utf-8','ignore') #parse to json obj payload = json.loads(payload_str) diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index d75f375305..248894593e 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/extensions/cocos-ext.h %(cocosdir)s/cocos/editor-support/ # 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 = AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* EditBox$ +classes = AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* EditBox$ ScrollView$ TableView$ TableViewCell$ # 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 @@ -46,7 +46,9 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC AssetsManagerDelegateProtocol::[*], Control::[removeHandleOfControlEvent addHandleOfControlEvent], ControlUtils::[*], - ControlSwitchSprite::[*] + ControlSwitchSprite::[*], + ScrollView::[(g|s)etDelegate$], + TableView::[create (g|s)etDataSource$ (g|s)etDelegate] rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager]