diff --git a/cocos/2d/CCAction.h b/cocos/2d/CCAction.h index 8b9d5d4d2c..1d76c43b17 100644 --- a/cocos/2d/CCAction.h +++ b/cocos/2d/CCAction.h @@ -50,7 +50,7 @@ public: * @js NA * @lua NA */ - std::string description() const; + virtual std::string description() const; /** returns a clone of action */ virtual Action* clone() const = 0; diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index 0ea40af3df..9da9cb7d49 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -44,7 +44,7 @@ Camera::~Camera(void) { } -const char* Camera::description(void) const +std::string Camera::getDescription() const { return String::createWithFormat("", _centerX, _centerY, _centerZ)->getCString(); } diff --git a/cocos/2d/CCCamera.h b/cocos/2d/CCCamera.h index b569a8f415..916ddaebae 100644 --- a/cocos/2d/CCCamera.h +++ b/cocos/2d/CCCamera.h @@ -83,7 +83,7 @@ public: * @js NA * @lua NA */ - const char* description() const; + virtual std::string getDescription() const; /** sets the dirty value */ inline void setDirty(bool value) { _dirty = value; } diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 404fb30312..936aeed1c8 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -154,7 +154,7 @@ bool GLProgram::initWithVertexShaderFilename(const char* vShaderFilename, const return initWithVertexShaderByteArray(vertexSource, fragmentSource); } -const char* GLProgram::description() const +std::string GLProgram::getDescription() const { return String::createWithFormat("", _tag, cc_utf16_to_utf8(_currentUTF16String,-1,NULL,NULL)); +} + NS_CC_END \ No newline at end of file diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index d781196777..9e3facffa4 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -116,6 +116,8 @@ public: virtual const std::string& getString() const override { static std::string _ret("not implemented"); return _ret; } void addChild(Node * child, int zOrder=0, int tag=0) override; + virtual std::string getDescription() const override; + private: /** * @js NA diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index 7230eae21a..ca673e1fea 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -225,4 +225,9 @@ void LabelAtlas::draw() } #endif +std::string LabelAtlas::getDescription() const +{ + return StringUtils::format("", _tag, _string.c_str()); +} + NS_CC_END diff --git a/cocos/2d/CCLabelAtlas.h b/cocos/2d/CCLabelAtlas.h index 47adb534a1..743100cdbe 100644 --- a/cocos/2d/CCLabelAtlas.h +++ b/cocos/2d/CCLabelAtlas.h @@ -90,7 +90,8 @@ public: virtual void setString(const std::string &label) override; virtual const std::string& getString(void) const override; - + virtual std::string getDescription() const override; + #if CC_LABELATLAS_DEBUG_DRAW virtual void draw() override; #endif diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index 8a1b424153..23877d3adb 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -1204,6 +1204,10 @@ const std::string& LabelBMFont::getFntFile() const return _fntFile; } +std::string LabelBMFont::getDescription() const +{ + return StringUtils::format("", _tag, _initialStringUTF8.c_str()); +} //LabelBMFont - Debug draw #if CC_LABELBMFONT_DEBUG_DRAW diff --git a/cocos/2d/CCLabelBMFont.h b/cocos/2d/CCLabelBMFont.h index 5970fa88b0..2d4a1ccc15 100644 --- a/cocos/2d/CCLabelBMFont.h +++ b/cocos/2d/CCLabelBMFont.h @@ -260,16 +260,18 @@ public: void setFntFile(const std::string& fntFile); const std::string& getFntFile() const; + + virtual std::string getDescription() const override; + #if CC_LABELBMFONT_DEBUG_DRAW virtual void draw(); #endif // CC_LABELBMFONT_DEBUG_DRAW -private: +protected: char * atlasNameFromFntFile(const std::string& fntFile); int kerningAmountForFirst(unsigned short first, unsigned short second); float getLetterPosXLeft( Sprite* characterSprite ); float getLetterPosXRight( Sprite* characterSprite ); -protected: virtual void setString(unsigned short *newString, bool needUpdateLabel); // string to render unsigned short* _string; diff --git a/cocos/2d/CCLabelTTF.cpp b/cocos/2d/CCLabelTTF.cpp index 012d79747b..53eee3196f 100644 --- a/cocos/2d/CCLabelTTF.cpp +++ b/cocos/2d/CCLabelTTF.cpp @@ -185,9 +185,9 @@ const std::string& LabelTTF::getString() const return _string; } -std::string LabelTTF::description() const +std::string LabelTTF::getDescription() const { - return StringUtils::format("", _fontName.c_str(), _fontSize); + return StringUtils::format("", _fontName.c_str(), _fontSize, _string.c_str()); } TextHAlignment LabelTTF::getHorizontalAlignment() const diff --git a/cocos/2d/CCLabelTTF.h b/cocos/2d/CCLabelTTF.h index 9dc30c1b4a..34ba14d1d4 100644 --- a/cocos/2d/CCLabelTTF.h +++ b/cocos/2d/CCLabelTTF.h @@ -66,12 +66,7 @@ public: * @lua NA */ virtual ~LabelTTF(); - /** - * @js NA - * @lua NA - */ - std::string description() const; - + /** creates a LabelTTF with a font name and font size in points @since v2.0.1 */ @@ -161,11 +156,16 @@ public: const std::string& getFontName() const; void setFontName(const std::string& fontName); - -private: - bool updateTexture(); + + /** + * @js NA + * @lua NA + */ + virtual std::string getDescription() const override; + protected: - + bool updateTexture(); + /** set the text definition for this label */ void _updateWithTextDefinition(const FontDefinition& textDefinition, bool mustUpdateTexture = true); FontDefinition _prepareTextDefinition(bool adjustForResolution = false); @@ -197,8 +197,6 @@ protected: /** font tint */ Color3B _textFillColor; - - }; diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 8dc43ab651..a82722e6fd 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -407,6 +407,12 @@ void Layer::onTouchesCancelled(const std::vector& touches, Event *unused CC_UNUSED_PARAM(unused_event); } +std::string Layer::getDescription() const +{ + return StringUtils::format("", _tag); +} + + #if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) #pragma GCC diagnostic warning "-Wdeprecated-declarations" #elif _MSC_VER >= 1400 //vs 2005 or higher @@ -549,6 +555,11 @@ void LayerRGBA::setCascadeColorEnabled(bool cascadeColorEnabled) _cascadeColorEnabled = cascadeColorEnabled; } +std::string LayerRGBA::getDescription() const +{ + return StringUtils::format("", _tag); +} + /// LayerColor LayerColor::LayerColor() @@ -735,6 +746,11 @@ void LayerColor::setOpacity(GLubyte opacity) updateColor(); } +std::string LayerColor::getDescription() const +{ + return StringUtils::format("", _tag); +} + // // LayerGradient // @@ -922,6 +938,11 @@ void LayerGradient::setCompressedInterpolation(bool compress) updateColor(); } +std::string LayerGradient::getDescription() const +{ + return StringUtils::format("", _tag); +} + /// MultiplexLayer LayerMultiplex::LayerMultiplex() @@ -1060,4 +1081,9 @@ void LayerMultiplex::switchToAndReleaseMe(int n) this->addChild(_layers.at(n)); } +std::string LayerMultiplex::getDescription() const +{ + return StringUtils::format(" #include @@ -567,4 +568,9 @@ MenuItem* Menu::getItemForTouch(Touch *touch) return NULL; } +std::string Menu::getDescription() const +{ + return StringUtils::format("", _tag); +} + NS_CC_END diff --git a/cocos/2d/CCMenu.h b/cocos/2d/CCMenu.h index 47e1f4eafe..bd0d6b351a 100644 --- a/cocos/2d/CCMenu.h +++ b/cocos/2d/CCMenu.h @@ -119,6 +119,8 @@ public: virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);} virtual bool isOpacityModifyRGB(void) const override { return false;} + virtual std::string getDescription() const override; + protected: /** * @js ctor diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp index f4709c5156..09cb00ee99 100644 --- a/cocos/2d/CCMenuItem.cpp +++ b/cocos/2d/CCMenuItem.cpp @@ -163,6 +163,10 @@ void MenuItem::setCallback(const ccMenuCallback& callback) _callback = callback; } +std::string MenuItem::getDescription() const +{ + return StringUtils::format("", _tag); +} // //CCMenuItemLabel diff --git a/cocos/2d/CCMenuItem.h b/cocos/2d/CCMenuItem.h index 57ce4dad9e..e35bdcbbd0 100644 --- a/cocos/2d/CCMenuItem.h +++ b/cocos/2d/CCMenuItem.h @@ -94,6 +94,9 @@ public: */ CC_DEPRECATED_ATTRIBUTE void setTarget(Object *rec, SEL_MenuHandler selector); + + virtual std::string getDescription() const override; + protected: /** * @js ctor diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 31d265d660..0c022abac2 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -582,7 +582,7 @@ void Node::cleanup() } -std::string Node::description() const +std::string Node::getDescription() const { return StringUtils::format("", _tag, _totalParticles); +} + NS_CC_END diff --git a/cocos/2d/CCParticleSystemQuad.h b/cocos/2d/CCParticleSystemQuad.h index 89b551a501..07f8f6bffc 100644 --- a/cocos/2d/CCParticleSystemQuad.h +++ b/cocos/2d/CCParticleSystemQuad.h @@ -120,6 +120,8 @@ public: */ virtual void setTotalParticles(int tp) override; + virtual std::string getDescription() const override; + protected: /** * @js ctor diff --git a/cocos/2d/CCProfiling.cpp b/cocos/2d/CCProfiling.cpp index a39f0167de..38d4bdd16f 100644 --- a/cocos/2d/CCProfiling.cpp +++ b/cocos/2d/CCProfiling.cpp @@ -90,7 +90,7 @@ void Profiler::displayTimers() for (auto iter = _activeTimers.begin(); iter != _activeTimers.end(); ++iter) { ProfilingTimer* timer = iter->second; - log("%s", timer->description()); + log("%s", timer->getDescription().c_str()); } } @@ -117,7 +117,7 @@ ProfilingTimer::~ProfilingTimer(void) } -const char* ProfilingTimer::description() const +std::string ProfilingTimer::getDescription() const { static char s_desciption[512] = {0}; diff --git a/cocos/2d/CCProfiling.h b/cocos/2d/CCProfiling.h index 68c7a3f079..8c122c8679 100644 --- a/cocos/2d/CCProfiling.h +++ b/cocos/2d/CCProfiling.h @@ -119,7 +119,7 @@ public: * @js NA * @lua NA */ - const char* description(void) const; + virtual std::string getDescription() const; /** * @js NA * @lua NA diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 86e8def996..e37f52d0ef 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -78,6 +78,11 @@ Scene *Scene::create() } } +std::string Scene::getDescription() const +{ + return StringUtils::format("", _tag); +} + #ifdef CC_USE_PHYSICS Scene *Scene::createWithPhysics() { diff --git a/cocos/2d/CCScene.h b/cocos/2d/CCScene.h index 5355541096..7f8462ccb5 100644 --- a/cocos/2d/CCScene.h +++ b/cocos/2d/CCScene.h @@ -66,6 +66,7 @@ public: virtual void addChild(Node* child, int zOrder) override; virtual void addChild(Node* child, int zOrder, int tag) override; virtual void update(float delta) override; + virtual std::string getDescription() const override; protected: bool initWithPhysics(); diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 10a2be7fd5..2b89a137b2 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -1234,4 +1234,14 @@ void Sprite::updateBlendFunc(void) } } +std::string Sprite::getDescription() const +{ + int texture_id = -1; + if( _batchNode ) + texture_id = _batchNode->getTextureAtlas()->getTexture()->getName(); + else + texture_id = _texture->getName(); + return StringUtils::format("", _tag, texture_id ); +} + NS_CC_END diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 1b53acc3db..6be0619d13 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -392,6 +392,8 @@ public: inline const BlendFunc& getBlendFunc() const override { return _blendFunc; } /// @} + virtual std::string getDescription() const override; + /// @{ /// @name Functions inherited from Node virtual void setScaleX(float scaleX) override; diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 748a248f58..7d40fd6cc6 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -701,4 +701,9 @@ SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, int z, int return this; } +std::string SpriteBatchNode::getDescription() const +{ + return StringUtils::format("", _tag); +} + NS_CC_END diff --git a/cocos/2d/CCSpriteBatchNode.h b/cocos/2d/CCSpriteBatchNode.h index 6ba402fe57..842ac7e71d 100644 --- a/cocos/2d/CCSpriteBatchNode.h +++ b/cocos/2d/CCSpriteBatchNode.h @@ -163,6 +163,7 @@ public: virtual void removeAllChildrenWithCleanup(bool cleanup) override; virtual void sortAllChildren() override; virtual void draw(void) override; + virtual std::string getDescription() const override; protected: /** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array. diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index 8515989a6f..479388040a 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -704,5 +704,11 @@ int TMXLayer::getVertexZForPos(const Point& pos) return ret; } +std::string TMXLayer::getDescription() const +{ + return StringUtils::format("", (int)_tag,_mapTileSize.width, (int)_mapTileSize.height); +} + + NS_CC_END diff --git a/cocos/2d/CCTMXLayer.h b/cocos/2d/CCTMXLayer.h index 2667739599..3ccdbd72fb 100644 --- a/cocos/2d/CCTMXLayer.h +++ b/cocos/2d/CCTMXLayer.h @@ -188,7 +188,7 @@ public: virtual void addChild(Node * child, int zOrder, int tag) override; // super method void removeChild(Node* child, bool cleanup) override; - + virtual std::string getDescription() const override; private: Point getPositionForIsoAt(const Point& pos); diff --git a/cocos/2d/CCTMXTiledMap.cpp b/cocos/2d/CCTMXTiledMap.cpp index 5df77a56e7..d5e30f54c4 100644 --- a/cocos/2d/CCTMXTiledMap.cpp +++ b/cocos/2d/CCTMXTiledMap.cpp @@ -243,7 +243,12 @@ Value TMXTiledMap::getPropertiesForGID(int GID) const return Value(); } - + +std::string TMXTiledMap::getDescription() const +{ + return StringUtils::format("", _name, (long)_pixelsWide, (long)_pixelsHigh, _maxS, _maxT)->getCString(); } diff --git a/cocos/2d/CCTexture2D.h b/cocos/2d/CCTexture2D.h index 03b91e49b9..efd9b99abc 100644 --- a/cocos/2d/CCTexture2D.h +++ b/cocos/2d/CCTexture2D.h @@ -200,7 +200,7 @@ public: * @js NA * @lua NA */ - const char* description(void) const; + virtual std::string getDescription() const; /** These functions are needed to create mutable textures * @js NA diff --git a/cocos/2d/CCTextureAtlas.cpp b/cocos/2d/CCTextureAtlas.cpp index 1a325d248b..95775573bc 100644 --- a/cocos/2d/CCTextureAtlas.cpp +++ b/cocos/2d/CCTextureAtlas.cpp @@ -222,7 +222,7 @@ void TextureAtlas::listenBackToForeground(Object *obj) _dirty = true; } -const char* TextureAtlas::description() const +std::string TextureAtlas::getDescription() const { return String::createWithFormat("", _totalQuads)->getCString(); } diff --git a/cocos/2d/CCTextureAtlas.h b/cocos/2d/CCTextureAtlas.h index 441a3f9038..019f6fddd1 100644 --- a/cocos/2d/CCTextureAtlas.h +++ b/cocos/2d/CCTextureAtlas.h @@ -194,7 +194,7 @@ public: * @js NA * @lua NA */ - const char* description() const; + virtual std::string getDescription() const; /** Gets the quantity of quads that are going to be drawn */ int getTotalQuads() const; diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index 55afd2588d..0557ee9057 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -87,7 +87,7 @@ void TextureCache::purgeSharedTextureCache() { } -const char* TextureCache::description() const +std::string TextureCache::getDescription() const { return String::createWithFormat("", _textures.size() )->getCString(); } diff --git a/cocos/2d/CCTextureCache.h b/cocos/2d/CCTextureCache.h index eb6ca47a22..3e63a9f8c3 100644 --- a/cocos/2d/CCTextureCache.h +++ b/cocos/2d/CCTextureCache.h @@ -96,7 +96,7 @@ public: * @js NA * @lua NA */ - const char* description(void) const; + virtual std::string getDescription() const; // Dictionary* snapshotTextures(); diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index 36aa67d13e..e2440a49f7 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -69,23 +69,26 @@ static ssize_t mydprintf(int sock, const char *format, ...) return write(sock, buf, strlen(buf)); } -static void printSceneGraph(int fd, Node* node, int level) +static int printSceneGraph(int fd, Node* node, int level) { + int total = 1; for(int i=0; idescription().c_str(), node->getZOrder(), node->getTag()); + mydprintf(fd, " %s\n", node->getDescription().c_str()); for(const auto& child: node->getChildren()) - printSceneGraph(fd, child, level+1); + total += printSceneGraph(fd, child, level+1); + + return total; } static void printSceneGraphBoot(int fd) { write(fd,"\n",1); auto scene = Director::getInstance()->getRunningScene(); - printSceneGraph(fd, scene, 0); - write(fd,"\n",1); + int total = printSceneGraph(fd, scene, 0); + mydprintf(fd, "Total Nodes: %d\n", total); }