Merge pull request #9748 from doomsdayer/v3_version1

V3 version1
This commit is contained in:
minggo 2014-12-31 16:10:36 +08:00
commit 0b0ca17031
3 changed files with 23 additions and 40 deletions

View File

@ -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);
@ -783,6 +784,22 @@ Node* CSLoader::nodeWithFlatBuffersFile(const std::string &fileName)
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 reader build id of your CocosStudio exported file(",
csBuildId->c_str(),
") and the reader build id of your Cocos2d-x(",
_csBuildID.c_str(),
") are not match.\n",
"Please get the correct Cocos2d-x from ",
"https://github.com/chukong/cocos-reader",
" and replace your Cocos2d-x")->getCString());
}
// decode plist
auto textures = csparsebinary->textures();
int textureSize = csparsebinary->textures()->size();
@ -791,9 +808,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 +1151,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;

View File

@ -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<Node*> _loadingNodeParentHierarchy;
std::string _csdVersion;
std::string _csBuildID;
};
NS_CC_END

View File

@ -775,37 +775,11 @@ namespace cocostudio
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);