diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp index 04164ab28b..3eff6259f9 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.cpp @@ -181,6 +181,7 @@ CSLoader::CSLoader() , _jsonPath("") , _monoCocos2dxVersion("") , _rootNode(nullptr) +, _csBuildID("2.0.8.0") { CREATE_CLASS_NODE_READER_INFO(NodeReader); CREATE_CLASS_NODE_READER_INFO(SingleNodeReader); @@ -782,6 +783,21 @@ Node* CSLoader::nodeWithFlatBuffersFile(const std::string &fileName) Data buf = FileUtils::getInstance()->getDataFromFile(fullPath); auto csparsebinary = GetCSParseBinary(buf.getBytes()); + + auto csBuildId = csparsebinary->version(); + if (csBuildId) + { + CCASSERT(strcmp(_csBuildID.c_str(), csBuildId->c_str()) == 0, + String::createWithFormat("%s%s%s%s%s%s%s%s", + "The build id of your CocosStudio exported file(", + csBuildId->c_str(), + ") and the build id of your cocos reader(", + _csBuildID.c_str(), + ") are not match.\n", + "Please get the correct cocos reader from ", + "https://github.com/chukong/cocos-reader", + " and replace the reader in your Cocos2d-x")->getCString()); + } // decode plist auto textures = csparsebinary->textures(); @@ -791,9 +807,6 @@ Node* CSLoader::nodeWithFlatBuffersFile(const std::string &fileName) { SpriteFrameCache::getInstance()->addSpriteFramesWithFile(textures->Get(i)->c_str()); } - - auto v = csparsebinary->version(); - if (v) _csdVersion = v->c_str(); Node* node = nodeWithFlatBuffers(csparsebinary->nodeTree()); @@ -1137,9 +1150,6 @@ Node* CSLoader::createNodeWithFlatBuffersForSimulator(const std::string& filenam auto nodeTree = csparsebinary->nodeTree(); - auto v = csparsebinary->version(); - if (v) _csdVersion = v->c_str(); - Node* node = nodeWithFlatBuffersForSimulator(nodeTree); _rootNode = nullptr; diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h index 93b2e16d7a..505645e5fc 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CSLoader.h @@ -104,7 +104,6 @@ public: cocos2d::Node* createNodeWithFlatBuffersForSimulator(const std::string& filename); cocos2d::Node* nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree* nodetree); - std::string getCsdVersion() { return _csdVersion; } protected: @@ -151,8 +150,7 @@ protected: std::string _monoCocos2dxVersion; Node* _rootNode; -// std::vector _loadingNodeParentHierarchy; - std::string _csdVersion; + std::string _csBuildID; }; NS_CC_END diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index 211a0e918f..c67b8c0ac0 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -771,41 +771,11 @@ namespace cocostudio widget->setCascadeOpacityEnabled(true); widget->setAnchorPoint(Vec2::ZERO); - widget->setUnifySizeEnabled(true); - bool ignoreSize = options->ignoreSize(); - widget->ignoreContentAdaptWithSize(ignoreSize); - - std::string versionString = CSLoader::getInstance()->getCsdVersion(); - //assume versionString is like "2.0.6.0" - if (versionString.length() > 0) - { - size_t p1, p2, p3, v1, v2, v3; - p1 = p2 = p3 = v1 = v2 = v3 = 0; - p1 = versionString.find('.'); - if (p1 > 0) - { - p2 = versionString.find('.', p1 + 1); - v1 = atoi(versionString.substr(0, p1).c_str()); - } - if (p2 > p1) - { - p3 = versionString.find('.', p2 + 1); - v2 = atoi(versionString.substr(p1 + 1, p2 - p1 - 1).c_str()); - } - if (p3 > p2) - { - v3 = atoi(versionString.substr(p2 + 1, p3 - p2 - 1).c_str()); - } - - if (!(v1 <= 2 && v2 == 0 && v3 <= 6)) - { - widget->setUnifySizeEnabled(false); - widget->setLayoutComponentEnabled(true); - widget->ignoreContentAdaptWithSize(false); - Size contentSize(options->size()->width(), options->size()->height()); - widget->setContentSize(contentSize); - } - } + widget->setUnifySizeEnabled(false); + widget->setLayoutComponentEnabled(true); + widget->ignoreContentAdaptWithSize(false); + Size contentSize(options->size()->width(), options->size()->height()); + widget->setContentSize(contentSize); int tag = options->tag(); widget->setTag(tag);