Merge pull request #8908 from zawasp/v3-source

fix some warnings / remove TABs
This commit is contained in:
minggo 2014-11-05 13:39:20 +08:00
commit 98073632d4
2 changed files with 87 additions and 87 deletions

View File

@ -273,7 +273,7 @@ public:
CC_DEPRECATED_ATTRIBUTE virtual void setFontDefinition(const FontDefinition& textDefinition); CC_DEPRECATED_ATTRIBUTE virtual void setFontDefinition(const FontDefinition& textDefinition);
CC_DEPRECATED_ATTRIBUTE const FontDefinition& getFontDefinition() const { return _fontDefinition; } 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: CC_CONSTRUCTOR_ACCESS:
/** /**

View File

@ -42,7 +42,7 @@ SceneReader::SceneReader()
ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAttribute)); ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAttribute));
ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComRender)); ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComRender));
ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAudio)); 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() SceneReader::~SceneReader()
@ -57,13 +57,13 @@ const char* SceneReader::sceneReaderVersion()
cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, AttachComponentType attachComponent /*= AttachComponentType::EMPTY_NODE*/) cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, AttachComponentType attachComponent /*= AttachComponentType::EMPTY_NODE*/)
{ {
std::string reDir = fileName; std::string reDir = fileName;
std::string file_extension = ""; std::string file_extension = "";
size_t pos = reDir.find_last_of('.'); size_t pos = reDir.find_last_of('.');
if (pos != std::string::npos) if (pos != std::string::npos)
{ {
file_extension = reDir.substr(pos, reDir.length()); file_extension = reDir.substr(pos, reDir.length());
std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper); std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper);
} }
if (file_extension == ".JSON") if (file_extension == ".JSON")
{ {
_node = nullptr; _node = nullptr;
@ -78,7 +78,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
} }
else if(file_extension == ".CSB") else if(file_extension == ".CSB")
{ {
do { do {
std::string binaryFilePath = CCFileUtils::getInstance()->fullPathForFilename(fileName); std::string binaryFilePath = CCFileUtils::getInstance()->fullPathForFilename(fileName);
auto fileData = FileUtils::getInstance()->getDataFromFile(binaryFilePath); auto fileData = FileUtils::getInstance()->getDataFromFile(binaryFilePath);
auto fileDataBytes = fileData.getBytes(); auto fileDataBytes = fileData.getBytes();
@ -86,90 +86,90 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
CocoLoader tCocoLoader; CocoLoader tCocoLoader;
if (tCocoLoader.ReadCocoBinBuff((char*)fileDataBytes)) if (tCocoLoader.ReadCocoBinBuff((char*)fileDataBytes))
{ {
stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode(); stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode();
rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader); rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
if (rapidjson::kObjectType == tType) if (rapidjson::kObjectType == tType)
{ {
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader); stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
CC_BREAK_IF(tpRootCocoNode->GetChildNum() == 0); CC_BREAK_IF(tpRootCocoNode->GetChildNum() == 0);
_node = Node::create(); _node = Node::create();
int nCount = 0; int nCount = 0;
std::vector<Component*> _vecComs; std::vector<Component*> _vecComs;
ComRender *pRender = nullptr; ComRender *pRender = nullptr;
std::string key = tpChildArray[15].GetName(&tCocoLoader); std::string key = tpChildArray[15].GetName(&tCocoLoader);
if (key == "components") if (key == "components")
{ {
nCount = tpChildArray[15].GetChildNum(); nCount = tpChildArray[15].GetChildNum();
} }
stExpCocoNode *pComponents = tpChildArray[15].GetChildArray(&tCocoLoader); stExpCocoNode *pComponents = tpChildArray[15].GetChildArray(&tCocoLoader);
SerData *data = new (std::nothrow) SerData(); SerData *data = new (std::nothrow) SerData();
for (int i = 0; i < nCount; i++) for (int i = 0; i < nCount; i++)
{ {
stExpCocoNode *subDict = pComponents[i].GetChildArray(&tCocoLoader); stExpCocoNode *subDict = pComponents[i].GetChildArray(&tCocoLoader);
if (subDict == nullptr) if (subDict == nullptr)
{ {
continue; continue;
} }
std::string key1 = subDict[1].GetName(&tCocoLoader); std::string key1 = subDict[1].GetName(&tCocoLoader);
const char *comName = subDict[1].GetValue(&tCocoLoader); const char *comName = subDict[1].GetValue(&tCocoLoader);
Component *pCom = nullptr; Component *pCom = nullptr;
if (key1 == "classname" && comName != nullptr) if (key1 == "classname" && comName != nullptr)
{ {
pCom = createComponent(comName); pCom = createComponent(comName);
} }
CCLOG("classname = %s", comName); CCLOG("classname = %s", comName);
if (pCom != nullptr) if (pCom != nullptr)
{ {
data->_rData = nullptr; data->_rData = nullptr;
data->_cocoNode = subDict; data->_cocoNode = subDict;
data->_cocoLoader = &tCocoLoader; data->_cocoLoader = &tCocoLoader;
if (pCom->serialize(data)) if (pCom->serialize(data))
{ {
ComRender *pTRender = dynamic_cast<ComRender*>(pCom); ComRender *pTRender = dynamic_cast<ComRender*>(pCom);
if (pTRender != nullptr) if (pTRender != nullptr)
{ {
pRender = pTRender; pRender = pTRender;
} }
else else
{ {
_vecComs.push_back(pCom); _vecComs.push_back(pCom);
} }
} }
else else
{ {
CC_SAFE_RELEASE_NULL(pCom); CC_SAFE_RELEASE_NULL(pCom);
} }
} }
if(_fnSelector != nullptr) if(_fnSelector != nullptr)
{ {
_fnSelector(pCom, (void*)(data)); _fnSelector(pCom, (void*)(data));
} }
} }
setPropertyFromJsonDict(&tCocoLoader, tpRootCocoNode, _node); setPropertyFromJsonDict(&tCocoLoader, tpRootCocoNode, _node);
for (std::vector<Component*>::iterator iter = _vecComs.begin(); iter != _vecComs.end(); ++iter) for (std::vector<Component*>::iterator iter = _vecComs.begin(); iter != _vecComs.end(); ++iter)
{ {
_node->addComponent(*iter); _node->addComponent(*iter);
} }
stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray(&tCocoLoader); stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray(&tCocoLoader);
int length = tpChildArray[11].GetChildNum(); int length = tpChildArray[11].GetChildNum();
for (int i = 0; i < length; ++i) for (int i = 0; i < length; ++i)
{ {
createObject(&tCocoLoader, &pGameObjects[i], _node, attachComponent); createObject(&tCocoLoader, &pGameObjects[i], _node, attachComponent);
} }
TriggerMng::getInstance()->parse(&tCocoLoader, tpChildArray); TriggerMng::getInstance()->parse(&tCocoLoader, tpChildArray);
} }
} }
}while (0); }while (0);
return _node; return _node;
} }
else else
{ {
log("read file [%s] error!\n", fileName.c_str()); log("read file [%s] error!\n", fileName.c_str());
} }
return nullptr; return nullptr;
} }
bool SceneReader::readJson(const std::string &fileName, rapidjson::Document &doc) 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) if (com != nullptr)
{ {
data->_rData = &subDict; data->_rData = &subDict;
data->_cocoNode = nullptr; data->_cocoNode = nullptr;
data->_cocoLoader = nullptr; data->_cocoLoader = nullptr;
if (com->serialize(data)) if (com->serialize(data))
{ {
@ -531,7 +531,7 @@ void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode
} }
else if (key == "visible") else if (key == "visible")
{ {
bVisible = (bool)atoi(value.c_str()); bVisible = atoi(value.c_str()) != 0;
node->setVisible(bVisible); node->setVisible(bVisible);
} }
else if (key == "objecttag") else if (key == "objecttag")