mirror of https://github.com/axmolengine/axmol.git
parent
a6d6287b29
commit
a3fcddde39
|
@ -144,43 +144,43 @@ ComAttribute* ComAttribute::create(void)
|
|||
|
||||
bool ComAttribute::serialize(void* r)
|
||||
{
|
||||
bool bRet = false;
|
||||
bool ret = false;
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(r == NULL);
|
||||
CC_BREAK_IF(r == nullptr);
|
||||
SerData *serData = (SerData *)(r);
|
||||
const rapidjson::Value *v = serData->_rData;
|
||||
stExpCocoNode *cocoNode = serData->_cocoNode;
|
||||
const char *className = NULL;
|
||||
const char *comName = NULL;
|
||||
const char *file = NULL;
|
||||
const char *className = nullptr;
|
||||
const char *comName = nullptr;
|
||||
const char *file = nullptr;
|
||||
std::string filePath;
|
||||
int resType = 0;
|
||||
if (v != NULL)
|
||||
if (v != nullptr)
|
||||
{
|
||||
className = DICTOOL->getStringValue_json(*v, "classname");
|
||||
CC_BREAK_IF(className == NULL);
|
||||
CC_BREAK_IF(className == nullptr);
|
||||
comName = DICTOOL->getStringValue_json(*v, "name");
|
||||
const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData");
|
||||
CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData));
|
||||
file = DICTOOL->getStringValue_json(fileData, "path");
|
||||
CC_BREAK_IF(file == NULL);
|
||||
CC_BREAK_IF(file == nullptr);
|
||||
resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
|
||||
CC_BREAK_IF(resType != 0);
|
||||
}
|
||||
else if (cocoNode != NULL)
|
||||
else if (cocoNode != nullptr)
|
||||
{
|
||||
className = cocoNode[1].GetValue();
|
||||
CC_BREAK_IF(className == NULL);
|
||||
CC_BREAK_IF(className == nullptr);
|
||||
comName = cocoNode[2].GetValue();
|
||||
stExpCocoNode *fileData = cocoNode[3].GetChildArray();
|
||||
CC_BREAK_IF(!fileData);
|
||||
file = fileData[0].GetValue();
|
||||
CC_BREAK_IF(file == NULL);
|
||||
CC_BREAK_IF(file == nullptr);
|
||||
resType = atoi(fileData[2].GetValue());
|
||||
CC_BREAK_IF(resType != 0);
|
||||
}
|
||||
if (comName != NULL)
|
||||
if (comName != nullptr)
|
||||
{
|
||||
setName(comName);
|
||||
}
|
||||
|
@ -188,17 +188,17 @@ bool ComAttribute::serialize(void* r)
|
|||
{
|
||||
setName(className);
|
||||
}
|
||||
if (file != NULL)
|
||||
if (file != nullptr)
|
||||
{
|
||||
filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file));
|
||||
}
|
||||
if (parse(filePath.c_str()))
|
||||
{
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
}while (0);
|
||||
return bRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ComAttribute::parse(const std::string &jsonFile)
|
||||
|
|
|
@ -69,47 +69,47 @@ void ComAudio::setEnabled(bool b)
|
|||
|
||||
bool ComAudio::serialize(void* r)
|
||||
{
|
||||
bool bRet = false;
|
||||
bool ret = false;
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(r == NULL);
|
||||
CC_BREAK_IF(r == nullptr);
|
||||
SerData *serData = (SerData *)(r);
|
||||
const rapidjson::Value *v = serData->_rData;
|
||||
stExpCocoNode *cocoNode = serData->_cocoNode;
|
||||
const char *className = NULL;
|
||||
const char *comName = NULL;
|
||||
const char *file = NULL;
|
||||
const char *className = nullptr;
|
||||
const char *comName = nullptr;
|
||||
const char *file = nullptr;
|
||||
std::string filePath;
|
||||
int resType = 0;
|
||||
bool loop = false;
|
||||
if (v != NULL)
|
||||
if (v != nullptr)
|
||||
{
|
||||
className = DICTOOL->getStringValue_json(*v, "classname");
|
||||
CC_BREAK_IF(className == NULL);
|
||||
CC_BREAK_IF(className == nullptr);
|
||||
comName = DICTOOL->getStringValue_json(*v, "name");
|
||||
const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData");
|
||||
CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData));
|
||||
file = DICTOOL->getStringValue_json(fileData, "path");
|
||||
CC_BREAK_IF(file == NULL);
|
||||
CC_BREAK_IF(file == nullptr);
|
||||
resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
|
||||
CC_BREAK_IF(resType != 0);
|
||||
loop = DICTOOL->getIntValue_json(*v, "loop") != 0? true:false;
|
||||
}
|
||||
else if (cocoNode != NULL)
|
||||
else if (cocoNode != nullptr)
|
||||
{
|
||||
className = cocoNode[1].GetValue();
|
||||
CC_BREAK_IF(className == NULL);
|
||||
CC_BREAK_IF(className == nullptr);
|
||||
comName = cocoNode[2].GetValue();
|
||||
stExpCocoNode *pfileData = cocoNode[4].GetChildArray();
|
||||
CC_BREAK_IF(!pfileData);
|
||||
file = pfileData[0].GetValue();
|
||||
CC_BREAK_IF(file == NULL);
|
||||
CC_BREAK_IF(file == nullptr);
|
||||
resType = atoi(pfileData[2].GetValue());
|
||||
CC_BREAK_IF(resType != 0);
|
||||
loop = atoi(cocoNode[5].GetValue()) != 0? true:false;
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
if (comName != NULL)
|
||||
if (comName != nullptr)
|
||||
{
|
||||
setName(comName);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ bool ComAudio::serialize(void* r)
|
|||
{
|
||||
setName(className);
|
||||
}
|
||||
if (file != NULL)
|
||||
if (file != nullptr)
|
||||
{
|
||||
if (strcmp(file, "") == 0)
|
||||
{
|
||||
|
@ -148,9 +148,9 @@ bool ComAudio::serialize(void* r)
|
|||
{
|
||||
CC_BREAK_IF(true);
|
||||
}
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}while (0);
|
||||
return bRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ComAudio* ComAudio::create(void)
|
||||
|
|
|
@ -90,45 +90,45 @@ void ComRender::setNode(cocos2d::Node *node)
|
|||
|
||||
bool ComRender::serialize(void* r)
|
||||
{
|
||||
bool bRet = false;
|
||||
bool ret = false;
|
||||
do
|
||||
{
|
||||
CC_BREAK_IF(r == NULL);
|
||||
CC_BREAK_IF(r == nullptr);
|
||||
SerData *serData = (SerData *)(r);
|
||||
const rapidjson::Value *v = serData->_rData;
|
||||
stExpCocoNode *cocoNode = serData->_cocoNode;
|
||||
const char *className = NULL;
|
||||
const char *comName = NULL;
|
||||
const char *file = NULL;
|
||||
const char *plist = NULL;
|
||||
const char *className = nullptr;
|
||||
const char *comName = nullptr;
|
||||
const char *file = nullptr;
|
||||
const char *plist = nullptr;
|
||||
std::string filePath;
|
||||
std::string plistPath;
|
||||
int resType = 0;
|
||||
if (v != NULL)
|
||||
if (v != nullptr)
|
||||
{
|
||||
className = DICTOOL->getStringValue_json(*v, "classname");
|
||||
CC_BREAK_IF(className == NULL);
|
||||
CC_BREAK_IF(className == nullptr);
|
||||
comName = DICTOOL->getStringValue_json(*v, "name");
|
||||
const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData");
|
||||
CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData));
|
||||
file = DICTOOL->getStringValue_json(fileData, "path");
|
||||
plist = DICTOOL->getStringValue_json(fileData, "plistFile");
|
||||
CC_BREAK_IF(file == NULL && plist == NULL);
|
||||
CC_BREAK_IF(file == nullptr && plist == nullptr);
|
||||
resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
|
||||
}
|
||||
else if(cocoNode != NULL)
|
||||
else if(cocoNode != nullptr)
|
||||
{
|
||||
className = cocoNode[1].GetValue();
|
||||
CC_BREAK_IF(className == NULL);
|
||||
CC_BREAK_IF(className == nullptr);
|
||||
comName = cocoNode[2].GetValue();
|
||||
stExpCocoNode *pfileData = cocoNode[4].GetChildArray();
|
||||
CC_BREAK_IF(!pfileData);
|
||||
file = pfileData[0].GetValue();
|
||||
plist = pfileData[1].GetValue();
|
||||
CC_BREAK_IF(file == NULL && plist == NULL);
|
||||
CC_BREAK_IF(file == nullptr && plist == nullptr);
|
||||
resType = atoi(pfileData[2].GetValue());
|
||||
}
|
||||
if (comName != NULL)
|
||||
if (comName != nullptr)
|
||||
{
|
||||
setName(comName);
|
||||
}
|
||||
|
@ -137,11 +137,11 @@ bool ComRender::serialize(void* r)
|
|||
setName(className);
|
||||
}
|
||||
|
||||
if (file != NULL)
|
||||
if (file != nullptr)
|
||||
{
|
||||
filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file));
|
||||
}
|
||||
if (plist != NULL)
|
||||
if (plist != nullptr)
|
||||
{
|
||||
plistPath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(plist));
|
||||
}
|
||||
|
@ -152,14 +152,14 @@ bool ComRender::serialize(void* r)
|
|||
_render = CCSprite::create(filePath.c_str());
|
||||
_render->retain();
|
||||
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != filePath.npos)
|
||||
{
|
||||
_render = CCTMXTiledMap::create(filePath.c_str());
|
||||
_render->retain();
|
||||
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != filePath.npos)
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ bool ComRender::serialize(void* r)
|
|||
_render->setPosition(Point(0.0f, 0.0f));
|
||||
_render->retain();
|
||||
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
else if(strcmp(className, "CCArmature") == 0)
|
||||
{
|
||||
|
@ -192,8 +192,8 @@ bool ComRender::serialize(void* r)
|
|||
Armature *pAr = Armature::create(name);
|
||||
_render = pAr;
|
||||
_render->retain();
|
||||
const char *actionName = NULL;
|
||||
if (cocoNode != NULL)
|
||||
const char *actionName = nullptr;
|
||||
if (cocoNode != nullptr)
|
||||
{
|
||||
actionName = cocoNode[6].GetValue();//DICTOOL->getStringValue_json(*v, "selectedactionname");
|
||||
}
|
||||
|
@ -201,19 +201,19 @@ bool ComRender::serialize(void* r)
|
|||
{
|
||||
actionName = DICTOOL->getStringValue_json(*v, "selectedactionname");
|
||||
}
|
||||
if (actionName != NULL && pAr->getAnimation() != NULL)
|
||||
if (actionName != nullptr && pAr->getAnimation() != nullptr)
|
||||
{
|
||||
pAr->getAnimation()->play(actionName);
|
||||
}
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
else if (file_extension == ".CSB")
|
||||
{
|
||||
ssize_t size = 0;
|
||||
unsigned char *pBytes = NULL;
|
||||
unsigned char *pBytes = nullptr;
|
||||
std::string binaryFilePath = FileUtils::getInstance()->fullPathForFilename(filePath.c_str());
|
||||
pBytes = cocos2d::FileUtils::getInstance()->getFileData(binaryFilePath.c_str(), "rb", &size);
|
||||
CC_BREAK_IF(pBytes == NULL || strcmp((char*)pBytes, "") == 0);
|
||||
CC_BREAK_IF(pBytes == nullptr || strcmp((char*)pBytes, "") == 0);
|
||||
CocoLoader tCocoLoader;
|
||||
if (tCocoLoader.ReadCocoBinBuff((char*)pBytes))
|
||||
{
|
||||
|
@ -243,14 +243,14 @@ bool ComRender::serialize(void* r)
|
|||
const char *str1 = armature_data[j].GetValue();
|
||||
if (key.compare("name") == 0)
|
||||
{
|
||||
if (str1 != NULL)
|
||||
if (str1 != nullptr)
|
||||
{
|
||||
ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str());
|
||||
Armature *pAr = CCArmature::create(str1);
|
||||
_render = pAr;
|
||||
_render->retain();
|
||||
const char *actionName = NULL;
|
||||
if (cocoNode != NULL)
|
||||
const char *actionName = nullptr;
|
||||
if (cocoNode != nullptr)
|
||||
{
|
||||
actionName = cocoNode[6].GetValue();
|
||||
}
|
||||
|
@ -258,11 +258,11 @@ bool ComRender::serialize(void* r)
|
|||
{
|
||||
actionName = DICTOOL->getStringValue_json(*v, "selectedactionname");
|
||||
}
|
||||
if (actionName != NULL && pAr->getAnimation() != NULL)
|
||||
if (actionName != nullptr && pAr->getAnimation() != nullptr)
|
||||
{
|
||||
pAr->getAnimation()->play(actionName);
|
||||
}
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ bool ComRender::serialize(void* r)
|
|||
_render = widget;
|
||||
_render->retain();
|
||||
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
else if (file_extension == ".CSB")
|
||||
{
|
||||
|
@ -303,7 +303,7 @@ bool ComRender::serialize(void* r)
|
|||
_render = widget;
|
||||
_render->retain();
|
||||
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -326,7 +326,7 @@ bool ComRender::serialize(void* r)
|
|||
_render = CCSprite::createWithSpriteFrameName(filePath.c_str());
|
||||
_render->retain();
|
||||
|
||||
bRet = true;
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ bool ComRender::serialize(void* r)
|
|||
}
|
||||
} while (0);
|
||||
|
||||
return bRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ComRender* ComRender::create(void)
|
||||
|
|
|
@ -79,11 +79,11 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
|
|||
else if(file_extension == ".CSB")
|
||||
{
|
||||
ssize_t size = 0;
|
||||
unsigned char *pBytes = NULL;
|
||||
unsigned char *pBytes = nullptr;
|
||||
do {
|
||||
std::string binaryFilePath = CCFileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
pBytes = cocos2d::FileUtils::getInstance()->getFileData(binaryFilePath.c_str(), "rb", &size);
|
||||
CC_BREAK_IF(pBytes == NULL || strcmp((char*)pBytes, "") == 0);
|
||||
CC_BREAK_IF(pBytes == nullptr || strcmp((char*)pBytes, "") == 0);
|
||||
CocoLoader tCocoLoader;
|
||||
if (tCocoLoader.ReadCocoBinBuff((char*)pBytes))
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
|
|||
_node = Node::create();
|
||||
int nCount = 0;
|
||||
std::vector<Component*> _vecComs;
|
||||
ComRender *pRender = NULL;
|
||||
ComRender *pRender = nullptr;
|
||||
std::string key = tpChildArray[15].GetName(&tCocoLoader);
|
||||
if (key == "components")
|
||||
{
|
||||
|
@ -107,26 +107,26 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
|
|||
for (int i = 0; i < nCount; i++)
|
||||
{
|
||||
stExpCocoNode *subDict = pComponents[i].GetChildArray();
|
||||
if (subDict == NULL)
|
||||
if (subDict == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
std::string key = subDict[1].GetName(&tCocoLoader);
|
||||
const char *comName = subDict[1].GetValue();
|
||||
Component *pCom = NULL;
|
||||
if (key == "classname" && comName != NULL)
|
||||
Component *pCom = nullptr;
|
||||
if (key == "classname" && comName != nullptr)
|
||||
{
|
||||
pCom = createComponent(comName);
|
||||
}
|
||||
CCLOG("classname = %s", comName);
|
||||
if (pCom != NULL)
|
||||
if (pCom != nullptr)
|
||||
{
|
||||
data->_rData = NULL;
|
||||
data->_rData = nullptr;
|
||||
data->_cocoNode = subDict;
|
||||
if (pCom->serialize(data))
|
||||
{
|
||||
ComRender *pTRender = dynamic_cast<ComRender*>(pCom);
|
||||
if (pTRender != NULL)
|
||||
if (pTRender != nullptr)
|
||||
{
|
||||
pRender = pTRender;
|
||||
}
|
||||
|
@ -174,15 +174,15 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
|
|||
|
||||
bool SceneReader::readJson(const std::string &fileName, rapidjson::Document &doc)
|
||||
{
|
||||
bool bRet = false;
|
||||
bool ret = false;
|
||||
do {
|
||||
std::string jsonpath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
std::string contentStr = FileUtils::getInstance()->getStringFromFile(jsonpath);
|
||||
doc.Parse<0>(contentStr.c_str());
|
||||
CC_BREAK_IF(doc.HasParseError());
|
||||
bRet = true;
|
||||
ret = true;
|
||||
} while (0);
|
||||
return bRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Node* SceneReader::nodeByTag(Node *parent, int tag)
|
||||
|
@ -348,7 +348,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
|
|||
|
||||
cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::Node* parent, AttachComponentType attachComponent)
|
||||
{
|
||||
const char *className = NULL;
|
||||
const char *className = nullptr;
|
||||
stExpCocoNode *pNodeArray = cocoNode->GetChildArray();
|
||||
std::string Key = pNodeArray[1].GetName(cocoLoader);
|
||||
if (Key == "classname")
|
||||
|
@ -357,9 +357,9 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
|
|||
}
|
||||
if(strcmp(className, "CCNode") == 0)
|
||||
{
|
||||
Node* gb = NULL;
|
||||
Node* gb = nullptr;
|
||||
std::vector<Component*> _vecComs;
|
||||
ComRender *pRender = NULL;
|
||||
ComRender *pRender = nullptr;
|
||||
int count = 0;
|
||||
std::string key = pNodeArray[13].GetName(cocoLoader);
|
||||
if (key == "components")
|
||||
|
@ -371,7 +371,7 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
|
|||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
stExpCocoNode *subDict = pComponents[i].GetChildArray();
|
||||
if (subDict == NULL)
|
||||
if (subDict == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -383,14 +383,14 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
|
|||
pCom = createComponent(comName);
|
||||
}
|
||||
CCLOG("classname = %s", comName);
|
||||
if (pCom != NULL)
|
||||
if (pCom != nullptr)
|
||||
{
|
||||
data->_rData = NULL;
|
||||
data->_rData = nullptr;
|
||||
data->_cocoNode = subDict;
|
||||
if (pCom->serialize(data))
|
||||
{
|
||||
ComRender *pTRender = dynamic_cast<ComRender*>(pCom);
|
||||
if (pTRender != NULL)
|
||||
if (pTRender != nullptr)
|
||||
{
|
||||
pRender = pTRender;
|
||||
}
|
||||
|
@ -425,7 +425,7 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
|
|||
{
|
||||
gb = pRender->getNode();
|
||||
gb->retain();
|
||||
pRender->setNode(NULL);
|
||||
pRender->setNode(nullptr);
|
||||
CC_SAFE_RELEASE_NULL(pRender);
|
||||
}
|
||||
parent->addChild(gb);
|
||||
|
@ -437,7 +437,7 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
|
|||
}
|
||||
|
||||
stExpCocoNode *pGameObjects = pNodeArray[12].GetChildArray();
|
||||
if (pGameObjects != NULL)
|
||||
if (pGameObjects != nullptr)
|
||||
{
|
||||
int length = pNodeArray[12].GetChildNum();
|
||||
for (int i = 0; i < length; ++i)
|
||||
|
|
Loading…
Reference in New Issue