From d47a79c0e49525e8557bb505d2a6a343279c2756 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Mon, 16 Nov 2015 11:08:20 +0800 Subject: [PATCH] Remove cocos studio limitation for new functions --- cocos/2d/CCCamera.cpp | 2 -- cocos/2d/CCCamera.h | 6 ++---- cocos/2d/CCCameraBackgroundBrush.cpp | 6 ------ cocos/2d/CCCameraBackgroundBrush.h | 6 ------ cocos/2d/CCClippingRectangleNode.cpp | 7 ------- cocos/2d/CCDrawNode.cpp | 10 ++-------- cocos/2d/CCDrawNode.h | 4 ---- cocos/2d/CCFontAtlasCache.cpp | 2 -- cocos/2d/CCFontAtlasCache.h | 2 -- cocos/2d/CCFontFNT.cpp | 2 -- cocos/2d/CCFontFNT.h | 2 -- cocos/2d/CCFontFreeType.cpp | 2 -- cocos/2d/CCFontFreeType.h | 2 -- cocos/2d/CCNode.h | 4 ---- cocos/2d/CCParticleSystem.cpp | 5 ++--- cocos/2d/CCParticleSystem.h | 6 +++--- cocos/2d/CCScene.h | 4 ---- cocos/2d/CCSprite.cpp | 8 +++++--- cocos/2d/CCSprite.h | 7 ++----- cocos/2d/CCSpriteFrameCache.cpp | 6 ------ cocos/2d/CCSpriteFrameCache.h | 4 ---- cocos/2d/CCTMXTiledMap.cpp | 13 ++----------- cocos/2d/CCTMXTiledMap.h | 7 ++----- cocos/2d/CCTMXXMLParser.cpp | 6 ++---- cocos/2d/CCTMXXMLParser.h | 10 ++-------- 25 files changed, 24 insertions(+), 109 deletions(-) diff --git a/cocos/2d/CCCamera.cpp b/cocos/2d/CCCamera.cpp index 5f81778007..b44c20b24b 100644 --- a/cocos/2d/CCCamera.cpp +++ b/cocos/2d/CCCamera.cpp @@ -481,11 +481,9 @@ void Camera::setBackgroundBrush(CameraBackgroundBrush* clearBrush) _clearBrush = clearBrush; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only bool Camera::isBrushValid() { return _clearBrush != nullptr && _clearBrush->isValid(); } -#endif NS_CC_END diff --git a/cocos/2d/CCCamera.h b/cocos/2d/CCCamera.h index 2a2bcf9a19..e431e30c98 100644 --- a/cocos/2d/CCCamera.h +++ b/cocos/2d/CCCamera.h @@ -58,12 +58,12 @@ enum class CameraFlag USER6 = 1 << 6, USER7 = 1 << 7, USER8 = 1 << 8, -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only + + // Use in cocos studio for edit 3d relate component SkyBox = 1 << 10, DEFAULTCAMERA = DEFAULT | SkyBox, PIXEL = 1 << 13, FRONT = 1 << 14, -#endif }; /** * Defines a camera . @@ -278,9 +278,7 @@ public: virtual void visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only bool isBrushValid(); -#endif CC_CONSTRUCTOR_ACCESS: Camera(); diff --git a/cocos/2d/CCCameraBackgroundBrush.cpp b/cocos/2d/CCCameraBackgroundBrush.cpp index b197a2e516..8f52b2ea74 100644 --- a/cocos/2d/CCCameraBackgroundBrush.cpp +++ b/cocos/2d/CCCameraBackgroundBrush.cpp @@ -232,10 +232,8 @@ CameraBackgroundSkyBoxBrush::CameraBackgroundSkyBoxBrush() , _vertexBuffer(0) , _indexBuffer(0) , _texture(nullptr) -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only , _actived(false) , _textureValid(false) -#endif { #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, @@ -300,10 +298,8 @@ CameraBackgroundSkyBoxBrush* CameraBackgroundSkyBoxBrush::create() void CameraBackgroundSkyBoxBrush::drawBackground(Camera* camera) { -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (!_actived) return; -#endif Mat4 cameraModelMat = camera->getNodeToWorldTransform(); @@ -436,7 +432,6 @@ void CameraBackgroundSkyBoxBrush::setTexture(TextureCube* texture) _glProgramState->setUniformTexture("u_Env", _texture); } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only bool CameraBackgroundSkyBoxBrush::isActived() const { return _actived; @@ -455,6 +450,5 @@ bool CameraBackgroundSkyBoxBrush::isValid() { return _actived; } -#endif NS_CC_END diff --git a/cocos/2d/CCCameraBackgroundBrush.h b/cocos/2d/CCCameraBackgroundBrush.h index 1eb361eab8..54cc98e011 100644 --- a/cocos/2d/CCCameraBackgroundBrush.h +++ b/cocos/2d/CCCameraBackgroundBrush.h @@ -104,9 +104,7 @@ public: */ virtual void drawBackground(Camera* camera) {} -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only virtual bool isValid() { return true; } -#endif CC_CONSTRUCTOR_ACCESS : CameraBackgroundBrush(); @@ -241,12 +239,10 @@ public: */ virtual void drawBackground(Camera* camera) override; -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only bool isActived() const; void setActived(bool actived); virtual void setTextureValid(bool valid); virtual bool isValid()override; -#endif CC_CONSTRUCTOR_ACCESS : CameraBackgroundSkyBoxBrush(); @@ -270,11 +266,9 @@ protected: EventListenerCustom* _backToForegroundListener; #endif -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only private: bool _actived; bool _textureValid; -#endif }; NS_CC_END diff --git a/cocos/2d/CCClippingRectangleNode.cpp b/cocos/2d/CCClippingRectangleNode.cpp index eb418db97a..eb3476858b 100644 --- a/cocos/2d/CCClippingRectangleNode.cpp +++ b/cocos/2d/CCClippingRectangleNode.cpp @@ -53,17 +53,10 @@ void ClippingRectangleNode::onBeforeVisitScissor() const Point pos = convertToWorldSpace(Point(_clippingRegion.origin.x, _clippingRegion.origin.y)); GLView* glView = Director::getInstance()->getOpenGLView(); -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only - glView->setScissorInPoints(pos.x * scaleX, - pos.y * scaleY, - _clippingRegion.size.width * scaleX, - _clippingRegion.size.height * scaleY); -#else glView->setScissorInPoints(pos.x, pos.y, _clippingRegion.size.width * scaleX, _clippingRegion.size.height * scaleY); -#endif } } diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 85f86796c5..cc323cb1a9 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -130,9 +130,7 @@ DrawNode::DrawNode() , _dirtyGLPoint(false) , _dirtyGLLine(false) , _lineWidth(DEFAULT_LINE_WIDTH) -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only , _lineSmoothEnable(false) -#endif { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; } @@ -405,13 +403,13 @@ void DrawNode::onDrawGLLine(const Mat4 &transform, uint32_t flags) // texcood glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only + if (this->_lineSmoothEnable == false) { glDisable(GL_MULTISAMPLE); glDisable(GL_LINE_SMOOTH); } -#endif + glLineWidth(_lineWidth); glDrawArrays(GL_LINES, 0, _bufferCountGLLine); @@ -423,10 +421,8 @@ void DrawNode::onDrawGLLine(const Mat4 &transform, uint32_t flags) glBindBuffer(GL_ARRAY_BUFFER, 0); CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCountGLLine); -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (this->_lineSmoothEnable == true) glEnable(GL_MULTISAMPLE); -#endif CHECK_GL_ERROR_DEBUG(); } @@ -965,7 +961,6 @@ void DrawNode::setLineWidth(int lineWidth) _lineWidth = lineWidth; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only void DrawNode::setLineSmooth(bool enable) { this->_lineSmoothEnable = enable; @@ -980,6 +975,5 @@ float DrawNode::getLineWidth() { return this->_lineWidth; } -#endif NS_CC_END diff --git a/cocos/2d/CCDrawNode.h b/cocos/2d/CCDrawNode.h index 50bbd2cbbb..92c01d3dac 100644 --- a/cocos/2d/CCDrawNode.h +++ b/cocos/2d/CCDrawNode.h @@ -313,7 +313,6 @@ public: void setLineWidth(int lineWidth); -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only // Set enable or disable multisampling effect on CocosStudio guide lines. void setLineSmooth(bool enable); @@ -322,7 +321,6 @@ public: // Get CocosStudio guide lines width. float getLineWidth(); -#endif CC_CONSTRUCTOR_ACCESS: DrawNode(); @@ -366,9 +364,7 @@ protected: int _lineWidth; -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only bool _lineSmoothEnable; -#endif private: CC_DISALLOW_COPY_AND_ASSIGN(DrawNode); diff --git a/cocos/2d/CCFontAtlasCache.cpp b/cocos/2d/CCFontAtlasCache.cpp index b181f7782f..2fdc1f98f0 100644 --- a/cocos/2d/CCFontAtlasCache.cpp +++ b/cocos/2d/CCFontAtlasCache.cpp @@ -238,7 +238,6 @@ bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas) return false; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only void FontAtlasCache::reloadFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset/* = Vec2::ZERO*/) { std::string atlasName = generateFontName(fontFileName, 0, false); @@ -276,6 +275,5 @@ void FontAtlasCache::unloadFontAtlasTTF(const std::string& fontFileName) item++; } } -#endif NS_CC_END diff --git a/cocos/2d/CCFontAtlasCache.h b/cocos/2d/CCFontAtlasCache.h index 2f61231379..fac242583f 100644 --- a/cocos/2d/CCFontAtlasCache.h +++ b/cocos/2d/CCFontAtlasCache.h @@ -54,10 +54,8 @@ public: */ static void purgeCachedData(); -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only static void reloadFontAtlasFNT(const std::string& fontFileName, const Vec2& imageOffset = Vec2::ZERO); static void unloadFontAtlasTTF(const std::string& fontFileName); -#endif private: static std::string generateFontName(const std::string& fontFileName, float size, bool useDistanceField); diff --git a/cocos/2d/CCFontFNT.cpp b/cocos/2d/CCFontFNT.cpp index ed14ea9886..83c301acbc 100644 --- a/cocos/2d/CCFontFNT.cpp +++ b/cocos/2d/CCFontFNT.cpp @@ -783,7 +783,6 @@ FontAtlas * FontFNT::createFontAtlas() return tempAtlas; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only void FontFNT::reloadBMFontResource(const std::string& fntFilePath) { if (s_configurations == nullptr) @@ -804,6 +803,5 @@ void FontFNT::reloadBMFontResource(const std::string& fntFilePath) } } -#endif NS_CC_END diff --git a/cocos/2d/CCFontFNT.h b/cocos/2d/CCFontFNT.h index f8a23978cf..0509b63a5d 100644 --- a/cocos/2d/CCFontFNT.h +++ b/cocos/2d/CCFontFNT.h @@ -47,9 +47,7 @@ public: virtual int* getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const override; virtual FontAtlas *createFontAtlas() override; -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only static void reloadBMFontResource(const std::string& fntFilePath); -#endif protected: diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index 49ff8d434e..0bc9234b4f 100644 --- a/cocos/2d/CCFontFreeType.cpp +++ b/cocos/2d/CCFontFreeType.cpp @@ -634,7 +634,6 @@ const char* FontFreeType::getGlyphCollection() const return glyphCollection; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only void FontFreeType::releaseFont(const std::string &fontName) { auto item = s_cacheFontData.begin(); @@ -646,6 +645,5 @@ void FontFreeType::releaseFont(const std::string &fontName) item++; } } -#endif NS_CC_END diff --git a/cocos/2d/CCFontFreeType.h b/cocos/2d/CCFontFreeType.h index 59f31e6cf0..51600e1b30 100644 --- a/cocos/2d/CCFontFreeType.h +++ b/cocos/2d/CCFontFreeType.h @@ -75,9 +75,7 @@ public: virtual FontAtlas* createFontAtlas() override; virtual int getFontMaxHeight() const override { return _lineHeight; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only static void releaseFont(const std::string &fontName); -#endif private: static const char* _glyphASCII; diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index bffd731c39..4a521f81c7 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -38,10 +38,6 @@ #include "2d/CCComponentContainer.h" #include "2d/CCComponent.h" -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only -#include "CocosStudioExtension.h" -#endif - NS_CC_BEGIN class GridBase; diff --git a/cocos/2d/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp index d8dbc956fa..59be604eb4 100644 --- a/cocos/2d/CCParticleSystem.cpp +++ b/cocos/2d/CCParticleSystem.cpp @@ -54,6 +54,7 @@ THE SOFTWARE. #include "renderer/CCTextureCache.h" #include "deprecated/CCString.h" #include "platform/CCFileUtils.h" +#include "2d/CocosStudioExtension.h" using namespace std; @@ -1332,14 +1333,12 @@ void ParticleSystem::setScaleY(float newScaleY) Node::setScaleY(newScaleY); } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only -ResouceData ParticleSystem::csGetRenderFile() +ResouceData ParticleSystem::getRenderFile() { ResouceData rData; rData.type = 0; rData.file = _plistFile; return rData; } -#endif NS_CC_END diff --git a/cocos/2d/CCParticleSystem.h b/cocos/2d/CCParticleSystem.h index 860cf4bbdf..d662a8da4a 100644 --- a/cocos/2d/CCParticleSystem.h +++ b/cocos/2d/CCParticleSystem.h @@ -33,6 +33,8 @@ THE SOFTWARE. NS_CC_BEGIN +struct CC_DLL ResouceData; + /** * @addtogroup _2d * @{ @@ -761,9 +763,7 @@ public: */ virtual const BlendFunc &getBlendFunc() const override; -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only - ResouceData csGetRenderFile(); -#endif + ResouceData getRenderFile(); CC_CONSTRUCTOR_ACCESS: /** diff --git a/cocos/2d/CCScene.h b/cocos/2d/CCScene.h index 82b9e9a417..fc1735c8bd 100644 --- a/cocos/2d/CCScene.h +++ b/cocos/2d/CCScene.h @@ -109,11 +109,7 @@ public: * @param renderer The renderer use to render the scene. * @js NA */ -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only virtual void render(Renderer* renderer); -#else - void render(Renderer* renderer); -#endif /** override function */ virtual void removeAllChildren() override; diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index e6e42a7bee..9f13e4978a 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -38,6 +38,7 @@ THE SOFTWARE. #include "renderer/CCRenderer.h" #include "base/CCDirector.h" #include "2d/CCCamera.h" +#include "2d/CocosStudioExtension.h" #include "deprecated/CCString.h" @@ -166,7 +167,10 @@ bool Sprite::initWithFile(const std::string& filename) { #ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (filename.empty()) + { + CCLOG("Call Sprite::initWithFile with blank resource filename."); return false; + } _fileName = filename; _fileType = 0; @@ -1163,19 +1167,17 @@ void Sprite::setPolygonInfo(const PolygonInfo& info) _polyInfo = info; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only void Sprite::setOffsetPosFromCenter(Vec2 offsetFromCenter) { _unflippedOffsetPositionFromCenter = offsetFromCenter; } -ResouceData Sprite::csGetRenderFile() +ResouceData Sprite::getRenderFile() { ResouceData rData; rData.type = (int)_fileType; rData.file = _fileName; return rData; } -#endif NS_CC_END diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 8e85e0d19d..0f67c5f6df 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -46,6 +46,7 @@ class Rect; class Size; class Texture2D; struct transformValues_; +struct CC_DLL ResouceData; #ifdef SPRITE_RENDER_IN_SUBPIXEL #undef SPRITE_RENDER_IN_SUBPIXEL @@ -461,10 +462,8 @@ public: virtual bool isOpacityModifyRGB() const override; /// @} -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only - ResouceData csGetRenderFile(); + ResouceData getRenderFile(); void setOffsetPosFromCenter(Vec2 offsetFromCenter); -#endif CC_CONSTRUCTOR_ACCESS : /** @@ -640,10 +639,8 @@ protected: bool _insideBounds; /// whether or not the sprite was inside bounds the previous frame -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only std::string _fileName; int _fileType; -#endif private: CC_DISALLOW_COPY_AND_ASSIGN(Sprite); diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp index 5da33a2590..45180379be 100644 --- a/cocos/2d/CCSpriteFrameCache.cpp +++ b/cocos/2d/CCSpriteFrameCache.cpp @@ -150,10 +150,8 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu Version 3 with TexturePacker 4.0 polygon mesh packing */ -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (dictionary["frames"].getType() != cocos2d::Value::Type::MAP) return; -#endif ValueMap& framesDict = dictionary["frames"].asValueMap(); int format = 0; @@ -497,10 +495,8 @@ void SpriteFrameCache::removeSpriteFramesFromFileContent(const std::string& plis void SpriteFrameCache::removeSpriteFramesFromDictionary(ValueMap& dictionary) { -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only if (dictionary["frames"].getType() != cocos2d::Value::Type::MAP) return; -#endif ValueMap framesDict = dictionary["frames"].asValueMap(); std::vector keysToRemove; @@ -552,7 +548,6 @@ SpriteFrame* SpriteFrameCache::getSpriteFrameByName(const std::string& name) return frame; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only void SpriteFrameCache::reloadSpriteFramesWithDictionary(ValueMap& dictionary, Texture2D *texture) { ValueMap& framesDict = dictionary["frames"].asValueMap(); @@ -725,6 +720,5 @@ bool SpriteFrameCache::reloadTexture(const std::string& plist) } return true; } -#endif NS_CC_END diff --git a/cocos/2d/CCSpriteFrameCache.h b/cocos/2d/CCSpriteFrameCache.h index e5557706b8..cb305ba20c 100644 --- a/cocos/2d/CCSpriteFrameCache.h +++ b/cocos/2d/CCSpriteFrameCache.h @@ -236,9 +236,7 @@ public: /** @deprecated use getSpriteFrameByName() instead */ CC_DEPRECATED_ATTRIBUTE SpriteFrame* spriteFrameByName(const std::string&name) { return getSpriteFrameByName(name); } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only bool reloadTexture(const std::string& plist); -#endif protected: // MARMALADE: Made this protected not private, as deriving from this class is pretty useful @@ -264,9 +262,7 @@ protected: const std::vector &triangleIndices, PolygonInfo &polygonInfo); -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only void reloadSpriteFramesWithDictionary(ValueMap& dictionary, Texture2D *texture); -#endif Map _spriteFrames; ValueMap _spriteFramesAliases; diff --git a/cocos/2d/CCTMXTiledMap.cpp b/cocos/2d/CCTMXTiledMap.cpp index 75b955e5d2..9c33e29d7e 100644 --- a/cocos/2d/CCTMXTiledMap.cpp +++ b/cocos/2d/CCTMXTiledMap.cpp @@ -29,6 +29,7 @@ THE SOFTWARE. #include "2d/CCTMXLayer.h" #include "2d/CCSprite.h" #include "deprecated/CCString.h" // For StringUtils::format +#include "2d/CocosStudioExtension.h" NS_CC_BEGIN @@ -62,9 +63,7 @@ bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile) { CCASSERT(tmxFile.size()>0, "TMXTiledMap: tmx file should not be empty"); -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only _tmxFile = tmxFile; -#endif setContentSize(Size::ZERO); @@ -82,9 +81,7 @@ bool TMXTiledMap::initWithTMXFile(const std::string& tmxFile) bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& resourcePath) { -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only _tmxFile = tmxString; -#endif setContentSize(Size::ZERO); @@ -99,10 +96,8 @@ bool TMXTiledMap::initWithXML(const std::string& tmxString, const std::string& r TMXTiledMap::TMXTiledMap() :_mapSize(Size::ZERO) ,_tileSize(Size::ZERO) -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only ,_tmxFile("") , _tmxLayerNum(0) -#endif { } @@ -208,9 +203,7 @@ void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo) idx++; } } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only _tmxLayerNum = idx; -#endif } // public @@ -286,19 +279,17 @@ std::string TMXTiledMap::getDescription() const return StringUtils::format("(_children.size())); } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only int TMXTiledMap::getLayerNum() { return _tmxLayerNum; } -ResouceData TMXTiledMap::csGetRenderFile() +ResouceData TMXTiledMap::getRenderFile() { ResouceData rData; rData.type = 0; rData.file = _tmxFile; return rData; } -#endif NS_CC_END diff --git a/cocos/2d/CCTMXTiledMap.h b/cocos/2d/CCTMXTiledMap.h index 985cd16659..5ff396f6c9 100644 --- a/cocos/2d/CCTMXTiledMap.h +++ b/cocos/2d/CCTMXTiledMap.h @@ -37,6 +37,7 @@ class TMXLayer; class TMXLayerInfo; class TMXTilesetInfo; class TMXMapInfo; +struct CC_DLL ResouceData; /** * @addtogroup _2d @@ -252,10 +253,8 @@ public: */ virtual std::string getDescription() const override; -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only - ResouceData csGetRenderFile(); + ResouceData getRenderFile(); int getLayerNum(); -#endif CC_CONSTRUCTOR_ACCESS: /** @@ -293,10 +292,8 @@ protected: //! tile properties ValueMapIntKey _tileProperties; -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only std::string _tmxFile; int _tmxLayerNum; -#endif static const int TMXLayerTag = 32768; diff --git a/cocos/2d/CCTMXXMLParser.cpp b/cocos/2d/CCTMXXMLParser.cpp index c8f0082739..ee1e557424 100644 --- a/cocos/2d/CCTMXXMLParser.cpp +++ b/cocos/2d/CCTMXXMLParser.cpp @@ -266,9 +266,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) std::string externalTilesetFilename = attributeDict["source"].asString(); if (externalTilesetFilename != "") { -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only _externalTilesetFilename = externalTilesetFilename; -#endif + // Tileset file will be relative to the map file. So we need to convert it to an absolute path if (_TMXFileName.find_last_of("/") != string::npos) { @@ -391,9 +390,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) // build full path std::string imagename = attributeDict["source"].asString(); -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only tileset->_originSourceImage = imagename; -#endif + if (_TMXFileName.find_last_of("/") != string::npos) { string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of("/") + 1); diff --git a/cocos/2d/CCTMXXMLParser.h b/cocos/2d/CCTMXXMLParser.h index 5ca6e5473d..3531852628 100644 --- a/cocos/2d/CCTMXXMLParser.h +++ b/cocos/2d/CCTMXXMLParser.h @@ -139,10 +139,8 @@ public: std::string _sourceImage; //! size in pixels of the image Size _imageSize; -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only - std::string _sourceImage; std::string _originSourceImage; -#endif + public: /** * @js ctor @@ -283,9 +281,7 @@ public: inline void setCurrentString(const std::string& currentString){ _currentString = currentString; } inline const std::string& getTMXFileName() const { return _TMXFileName; } inline void setTMXFileName(const std::string& fileName){ _TMXFileName = fileName; } -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only - inline const std::string& getExternalTilesetFileName(){ return _externalTilesetFilename; } -#endif + inline const std::string& getExternalTilesetFileName() const { return _externalTilesetFilename; } protected: void internalInit(const std::string& tmxFileName, const std::string& resourcePath); @@ -325,9 +321,7 @@ protected: ValueMapIntKey _tileProperties; int _currentFirstGID; bool _recordFirstGID; -#ifdef CC_STUDIO_ENABLED_VIEW // for cocostudio only std::string _externalTilesetFilename; -#endif }; // end of tilemap_parallax_nodes group