From 3d276db6d2e00187c20da19278b7964b08e5fdb8 Mon Sep 17 00:00:00 2001 From: Mircea Rila Date: Thu, 23 Oct 2014 12:54:15 +0300 Subject: [PATCH] fix some warnings / remove TABs --- cocos/2d/CCLabel.h | 2 +- .../cocostudio/CCSSceneReader.cpp | 172 +++++++++--------- 2 files changed, 87 insertions(+), 87 deletions(-) diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 2b3efbb34a..02844fa5f4 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -273,7 +273,7 @@ public: CC_DEPRECATED_ATTRIBUTE virtual void setFontDefinition(const FontDefinition& textDefinition); CC_DEPRECATED_ATTRIBUTE const FontDefinition& getFontDefinition() const { return _fontDefinition; } - CC_DEPRECATED_ATTRIBUTE int getCommonLineHeight() const { return getLineHeight();} + CC_DEPRECATED_ATTRIBUTE int getCommonLineHeight() const { return (int)getLineHeight();} CC_CONSTRUCTOR_ACCESS: /** diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 52a9e50e5e..0e29de8d2f 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -42,7 +42,7 @@ SceneReader::SceneReader() ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAttribute)); ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComRender)); ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAudio)); - ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComController)); + ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComController)); } SceneReader::~SceneReader() @@ -57,13 +57,13 @@ const char* SceneReader::sceneReaderVersion() cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, AttachComponentType attachComponent /*= AttachComponentType::EMPTY_NODE*/) { std::string reDir = fileName; - std::string file_extension = ""; - size_t pos = reDir.find_last_of('.'); - if (pos != std::string::npos) - { - file_extension = reDir.substr(pos, reDir.length()); - std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper); - } + std::string file_extension = ""; + size_t pos = reDir.find_last_of('.'); + if (pos != std::string::npos) + { + file_extension = reDir.substr(pos, reDir.length()); + std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper); + } if (file_extension == ".JSON") { _node = nullptr; @@ -78,7 +78,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, } else if(file_extension == ".CSB") { - do { + do { std::string binaryFilePath = CCFileUtils::getInstance()->fullPathForFilename(fileName); auto fileData = FileUtils::getInstance()->getDataFromFile(binaryFilePath); auto fileDataBytes = fileData.getBytes(); @@ -86,90 +86,90 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, CocoLoader tCocoLoader; if (tCocoLoader.ReadCocoBinBuff((char*)fileDataBytes)) { - stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode(); - rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader); - if (rapidjson::kObjectType == tType) - { - stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader); - CC_BREAK_IF(tpRootCocoNode->GetChildNum() == 0); - _node = Node::create(); - int nCount = 0; - std::vector _vecComs; - ComRender *pRender = nullptr; - std::string key = tpChildArray[15].GetName(&tCocoLoader); - if (key == "components") - { - nCount = tpChildArray[15].GetChildNum(); - } - stExpCocoNode *pComponents = tpChildArray[15].GetChildArray(&tCocoLoader); - SerData *data = new (std::nothrow) SerData(); - for (int i = 0; i < nCount; i++) - { - stExpCocoNode *subDict = pComponents[i].GetChildArray(&tCocoLoader); - if (subDict == nullptr) - { - continue; - } - std::string key1 = subDict[1].GetName(&tCocoLoader); - const char *comName = subDict[1].GetValue(&tCocoLoader); - Component *pCom = nullptr; - if (key1 == "classname" && comName != nullptr) - { - pCom = createComponent(comName); - } - CCLOG("classname = %s", comName); - if (pCom != nullptr) - { - data->_rData = nullptr; - data->_cocoNode = subDict; + stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode(); + rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader); + if (rapidjson::kObjectType == tType) + { + stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader); + CC_BREAK_IF(tpRootCocoNode->GetChildNum() == 0); + _node = Node::create(); + int nCount = 0; + std::vector _vecComs; + ComRender *pRender = nullptr; + std::string key = tpChildArray[15].GetName(&tCocoLoader); + if (key == "components") + { + nCount = tpChildArray[15].GetChildNum(); + } + stExpCocoNode *pComponents = tpChildArray[15].GetChildArray(&tCocoLoader); + SerData *data = new (std::nothrow) SerData(); + for (int i = 0; i < nCount; i++) + { + stExpCocoNode *subDict = pComponents[i].GetChildArray(&tCocoLoader); + if (subDict == nullptr) + { + continue; + } + std::string key1 = subDict[1].GetName(&tCocoLoader); + const char *comName = subDict[1].GetValue(&tCocoLoader); + Component *pCom = nullptr; + if (key1 == "classname" && comName != nullptr) + { + pCom = createComponent(comName); + } + CCLOG("classname = %s", comName); + if (pCom != nullptr) + { + data->_rData = nullptr; + data->_cocoNode = subDict; data->_cocoLoader = &tCocoLoader; - if (pCom->serialize(data)) - { - ComRender *pTRender = dynamic_cast(pCom); - if (pTRender != nullptr) - { - pRender = pTRender; - } - else - { - _vecComs.push_back(pCom); - } - } - else - { - CC_SAFE_RELEASE_NULL(pCom); - } - } + if (pCom->serialize(data)) + { + ComRender *pTRender = dynamic_cast(pCom); + if (pTRender != nullptr) + { + pRender = pTRender; + } + else + { + _vecComs.push_back(pCom); + } + } + else + { + CC_SAFE_RELEASE_NULL(pCom); + } + } if(_fnSelector != nullptr) { _fnSelector(pCom, (void*)(data)); } - } + } - setPropertyFromJsonDict(&tCocoLoader, tpRootCocoNode, _node); - for (std::vector::iterator iter = _vecComs.begin(); iter != _vecComs.end(); ++iter) - { - _node->addComponent(*iter); - } + setPropertyFromJsonDict(&tCocoLoader, tpRootCocoNode, _node); + for (std::vector::iterator iter = _vecComs.begin(); iter != _vecComs.end(); ++iter) + { + _node->addComponent(*iter); + } - stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray(&tCocoLoader); - int length = tpChildArray[11].GetChildNum(); - for (int i = 0; i < length; ++i) - { - createObject(&tCocoLoader, &pGameObjects[i], _node, attachComponent); - } - TriggerMng::getInstance()->parse(&tCocoLoader, tpChildArray); - } - - } - }while (0); - return _node; + stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray(&tCocoLoader); + int length = tpChildArray[11].GetChildNum(); + for (int i = 0; i < length; ++i) + { + createObject(&tCocoLoader, &pGameObjects[i], _node, attachComponent); + } + TriggerMng::getInstance()->parse(&tCocoLoader, tpChildArray); + } + + } + }while (0); + return _node; } else - { - log("read file [%s] error!\n", fileName.c_str()); - } - return nullptr; + { + log("read file [%s] error!\n", fileName.c_str()); + } + return nullptr; } bool SceneReader::readJson(const std::string &fileName, rapidjson::Document &doc) @@ -282,7 +282,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par if (com != nullptr) { data->_rData = &subDict; - data->_cocoNode = nullptr; + data->_cocoNode = nullptr; data->_cocoLoader = nullptr; if (com->serialize(data)) { @@ -531,7 +531,7 @@ void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode } else if (key == "visible") { - bVisible = (bool)atoi(value.c_str()); + bVisible = atoi(value.c_str()) != 0; node->setVisible(bVisible); } else if (key == "objecttag")