2013-06-04 17:38:43 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:47:11 +08:00
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
2013-06-04 17:38:43 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "cocostudio/CCComRender.h"
|
2014-01-05 02:22:32 +08:00
|
|
|
#include "cocostudio/CocoStudio.h"
|
|
|
|
|
|
|
|
using namespace cocos2d;
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace cocostudio {
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2014-01-05 02:22:32 +08:00
|
|
|
IMPLEMENT_CLASS_COMPONENT_INFO(ComRender)
|
2015-09-18 11:48:43 +08:00
|
|
|
|
|
|
|
const std::string ComRender::COMPONENT_NAME = "CCComRender";
|
|
|
|
|
|
|
|
ComRender::ComRender()
|
2013-11-14 14:05:24 +08:00
|
|
|
: _render(nullptr)
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
2015-09-18 11:48:43 +08:00
|
|
|
_name = COMPONENT_NAME;
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
2013-09-09 19:51:26 +08:00
|
|
|
ComRender::ComRender(cocos2d::Node *node, const char *comName)
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
2014-03-26 16:39:32 +08:00
|
|
|
if (node != nullptr)
|
|
|
|
{
|
|
|
|
_render = node;
|
|
|
|
_render->retain();
|
|
|
|
}
|
2013-09-09 19:51:26 +08:00
|
|
|
_name.assign(comName);
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
2015-09-18 11:48:43 +08:00
|
|
|
ComRender::~ComRender()
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
2014-03-26 16:39:32 +08:00
|
|
|
CC_SAFE_RELEASE_NULL(_render);
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
2013-09-09 19:51:26 +08:00
|
|
|
void ComRender::onEnter()
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
2015-06-23 13:54:11 +08:00
|
|
|
if (_owner != nullptr && _render->getParent() == nullptr)
|
2013-09-09 19:51:26 +08:00
|
|
|
{
|
2015-06-23 13:54:11 +08:00
|
|
|
_owner->addChild(_render);
|
2013-09-09 19:51:26 +08:00
|
|
|
}
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
2013-09-09 19:51:26 +08:00
|
|
|
void ComRender::onExit()
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
2015-06-23 13:54:11 +08:00
|
|
|
if (_owner != nullptr && _render->getParent() == nullptr)
|
2014-03-26 16:39:32 +08:00
|
|
|
{
|
2015-06-23 13:54:11 +08:00
|
|
|
_owner->removeChild(_render, true);
|
2014-03-26 16:39:32 +08:00
|
|
|
}
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
2015-06-04 14:06:31 +08:00
|
|
|
void ComRender::onAdd()
|
|
|
|
{
|
2015-06-23 13:54:11 +08:00
|
|
|
if (_owner != nullptr && _render->getParent() == nullptr)
|
2015-06-04 14:06:31 +08:00
|
|
|
{
|
|
|
|
_owner->addChild(_render);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ComRender::onRemove()
|
|
|
|
{
|
2015-06-23 13:54:11 +08:00
|
|
|
if (_owner != nullptr && _render->getParent() == nullptr)
|
2015-06-04 14:06:31 +08:00
|
|
|
{
|
|
|
|
_owner->removeChild(_render, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-09 19:51:26 +08:00
|
|
|
cocos2d::Node* ComRender::getNode()
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
2013-09-09 19:51:26 +08:00
|
|
|
return _render;
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
2014-01-03 01:42:14 +08:00
|
|
|
void ComRender::setNode(cocos2d::Node *node)
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
2014-03-26 16:39:32 +08:00
|
|
|
if (_render != nullptr)
|
|
|
|
{
|
|
|
|
_render->release();
|
|
|
|
_render = nullptr;
|
|
|
|
}
|
|
|
|
if (node != nullptr)
|
|
|
|
{
|
|
|
|
_render = node;
|
|
|
|
_render->retain();
|
|
|
|
}
|
2014-01-03 01:42:14 +08:00
|
|
|
}
|
|
|
|
|
2014-01-05 02:22:32 +08:00
|
|
|
|
2015-06-23 13:54:11 +08:00
|
|
|
// TODO: This method is soooo big!! We should refactor it!
|
2014-01-05 02:22:32 +08:00
|
|
|
bool ComRender::serialize(void* r)
|
2014-01-03 01:42:14 +08:00
|
|
|
{
|
2015-06-23 13:54:11 +08:00
|
|
|
bool ret = false;
|
2014-06-25 11:58:36 +08:00
|
|
|
do
|
|
|
|
{
|
2014-06-30 17:15:55 +08:00
|
|
|
CC_BREAK_IF(r == nullptr);
|
2015-06-23 13:54:11 +08:00
|
|
|
SerData *serData = (SerData *)(r);
|
2014-06-25 18:10:06 +08:00
|
|
|
const rapidjson::Value *v = serData->_rData;
|
2015-06-23 13:54:11 +08:00
|
|
|
stExpCocoNode *cocoNode = serData->_cocoNode;
|
2014-07-01 16:31:17 +08:00
|
|
|
CocoLoader *cocoLoader = serData->_cocoLoader;
|
2015-06-23 13:54:11 +08:00
|
|
|
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 != nullptr)
|
|
|
|
{
|
|
|
|
className = DICTOOL->getStringValue_json(*v, "classname");
|
|
|
|
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 == nullptr && plist == nullptr);
|
|
|
|
resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
|
|
|
|
}
|
|
|
|
else if(cocoNode != nullptr)
|
|
|
|
{
|
|
|
|
className = cocoNode[1].GetValue(cocoLoader);
|
|
|
|
CC_BREAK_IF(className == nullptr);
|
|
|
|
comName = cocoNode[2].GetValue(cocoLoader);
|
|
|
|
stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader);
|
|
|
|
CC_BREAK_IF(!pfileData);
|
|
|
|
file = pfileData[0].GetValue(cocoLoader);
|
|
|
|
plist = pfileData[1].GetValue(cocoLoader);
|
|
|
|
CC_BREAK_IF(file == nullptr && plist == nullptr);
|
|
|
|
resType = atoi(pfileData[2].GetValue(cocoLoader));
|
|
|
|
}
|
|
|
|
if (comName != nullptr)
|
|
|
|
{
|
|
|
|
setName(comName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setName(className);
|
|
|
|
}
|
2014-06-25 11:58:36 +08:00
|
|
|
|
2015-06-23 13:54:11 +08:00
|
|
|
if (file != nullptr)
|
|
|
|
{
|
|
|
|
filePath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(file));
|
|
|
|
}
|
|
|
|
if (plist != nullptr)
|
|
|
|
{
|
|
|
|
plistPath.assign(cocos2d::FileUtils::getInstance()->fullPathForFilename(plist));
|
|
|
|
}
|
|
|
|
if (resType == 0)
|
|
|
|
{
|
|
|
|
if (strcmp(className, "CCSprite") == 0 && (filePath.find(".png") != filePath.npos || filePath.find(".pvr.ccz") != filePath.npos))
|
|
|
|
{
|
2016-02-03 23:12:37 +08:00
|
|
|
_render = Sprite::create(filePath);
|
2015-06-23 13:54:11 +08:00
|
|
|
_render->retain();
|
2014-06-25 11:58:36 +08:00
|
|
|
|
2014-06-30 17:15:55 +08:00
|
|
|
ret = true;
|
2015-06-23 13:54:11 +08:00
|
|
|
}
|
|
|
|
else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != filePath.npos)
|
|
|
|
{
|
2016-02-03 23:12:37 +08:00
|
|
|
_render = TMXTiledMap::create(filePath);
|
2015-06-23 13:54:11 +08:00
|
|
|
_render->retain();
|
2014-06-25 11:58:36 +08:00
|
|
|
|
2014-06-30 17:15:55 +08:00
|
|
|
ret = true;
|
2015-06-23 13:54:11 +08:00
|
|
|
}
|
|
|
|
else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != filePath.npos)
|
|
|
|
{
|
2016-02-03 23:12:37 +08:00
|
|
|
_render = ParticleSystemQuad::create(filePath);
|
2015-06-23 13:54:11 +08:00
|
|
|
_render->setPosition(0.0f, 0.0f);
|
|
|
|
_render->retain();
|
2014-06-25 11:58:36 +08:00
|
|
|
|
2014-06-30 17:15:55 +08:00
|
|
|
ret = true;
|
2015-06-23 13:54:11 +08:00
|
|
|
}
|
|
|
|
else if(strcmp(className, "CCArmature") == 0)
|
|
|
|
{
|
2015-08-06 03:21:16 +08:00
|
|
|
std::string fileExtension = FileUtils::getInstance()->getFileExtension(filePath);
|
|
|
|
if (fileExtension == ".json" || fileExtension == ".exportjson")
|
2015-06-23 13:54:11 +08:00
|
|
|
{
|
|
|
|
rapidjson::Document doc;
|
2016-02-03 23:12:37 +08:00
|
|
|
if(!readJson(filePath, doc))
|
2015-06-23 13:54:11 +08:00
|
|
|
{
|
|
|
|
log("read json file[%s] error!\n", filePath.c_str());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0);
|
|
|
|
const char *name = DICTOOL->getStringValue_json(subData, "name");
|
2016-02-03 23:12:37 +08:00
|
|
|
ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath);
|
2015-06-23 13:54:11 +08:00
|
|
|
Armature *pAr = Armature::create(name);
|
|
|
|
_render = pAr;
|
|
|
|
_render->retain();
|
|
|
|
const char *actionName = nullptr;
|
|
|
|
if (cocoNode != nullptr)
|
|
|
|
{
|
|
|
|
actionName = cocoNode[6].GetValue(cocoLoader);//DICTOOL->getStringValue_json(*v, "selectedactionname");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
actionName = DICTOOL->getStringValue_json(*v, "selectedactionname");
|
|
|
|
}
|
|
|
|
if (actionName != nullptr && pAr->getAnimation() != nullptr)
|
|
|
|
{
|
|
|
|
pAr->getAnimation()->play(actionName);
|
|
|
|
}
|
2014-06-30 17:15:55 +08:00
|
|
|
ret = true;
|
2015-06-23 13:54:11 +08:00
|
|
|
}
|
2015-08-06 03:21:16 +08:00
|
|
|
else if (fileExtension == ".csb")
|
2015-06-23 13:54:11 +08:00
|
|
|
{
|
2016-02-03 23:12:37 +08:00
|
|
|
std::string binaryFilePath = FileUtils::getInstance()->fullPathForFilename(filePath);
|
2014-10-09 17:19:43 +08:00
|
|
|
auto fileData = FileUtils::getInstance()->getDataFromFile(binaryFilePath);
|
|
|
|
auto fileDataBytes = fileData.getBytes();
|
|
|
|
CC_BREAK_IF(fileData.isNull());
|
|
|
|
CocoLoader tCocoLoader;
|
|
|
|
if (tCocoLoader.ReadCocoBinBuff((char*)fileDataBytes))
|
|
|
|
{
|
2015-06-23 13:54:11 +08:00
|
|
|
stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode();
|
|
|
|
rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
|
|
|
|
if (rapidjson::kObjectType == tType)
|
|
|
|
{
|
2014-06-25 11:58:36 +08:00
|
|
|
int count = tpRootCocoNode->GetChildNum();
|
2014-07-01 16:31:17 +08:00
|
|
|
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
|
2014-06-25 11:58:36 +08:00
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
std::string key = tpChildArray[i].GetName(&tCocoLoader);
|
|
|
|
if (key.compare("armature_data") == 0)
|
|
|
|
{
|
|
|
|
int length = tpChildArray[i].GetChildNum();
|
2014-07-01 16:31:17 +08:00
|
|
|
stExpCocoNode *armature_dataArray = tpChildArray[i].GetChildArray(&tCocoLoader);
|
2014-06-25 11:58:36 +08:00
|
|
|
if (length < 1)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
length = armature_dataArray[0].GetChildNum();
|
2014-07-01 16:31:17 +08:00
|
|
|
stExpCocoNode *armature_data = armature_dataArray[0].GetChildArray(&tCocoLoader);
|
2014-06-25 11:58:36 +08:00
|
|
|
for (int j = 0; j < length; ++j)
|
|
|
|
{
|
|
|
|
std::string key1 = armature_data[j].GetName(&tCocoLoader);
|
2014-07-01 16:31:17 +08:00
|
|
|
const char *str1 = armature_data[j].GetValue(&tCocoLoader);
|
2014-06-25 11:58:36 +08:00
|
|
|
if (key.compare("name") == 0)
|
|
|
|
{
|
2014-06-30 17:15:55 +08:00
|
|
|
if (str1 != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
2016-02-03 23:12:37 +08:00
|
|
|
ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath);
|
2015-06-23 13:54:11 +08:00
|
|
|
Armature *pAr = Armature::create(str1);
|
2014-06-25 11:58:36 +08:00
|
|
|
_render = pAr;
|
|
|
|
_render->retain();
|
2014-06-30 17:15:55 +08:00
|
|
|
const char *actionName = nullptr;
|
|
|
|
if (cocoNode != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
2014-07-01 16:31:17 +08:00
|
|
|
actionName = cocoNode[6].GetValue(&tCocoLoader);
|
2014-06-25 11:58:36 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
actionName = DICTOOL->getStringValue_json(*v, "selectedactionname");
|
|
|
|
}
|
2014-06-30 17:15:55 +08:00
|
|
|
if (actionName != nullptr && pAr->getAnimation() != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
pAr->getAnimation()->play(actionName);
|
|
|
|
}
|
2014-06-30 17:15:55 +08:00
|
|
|
ret = true;
|
2014-06-25 11:58:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-23 13:54:11 +08:00
|
|
|
}
|
|
|
|
}
|
2014-06-25 11:58:36 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2015-06-23 13:54:11 +08:00
|
|
|
}
|
2014-06-25 11:58:36 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2015-06-23 13:54:11 +08:00
|
|
|
}
|
|
|
|
else if(strcmp(className, "GUIComponent") == 0)
|
|
|
|
{
|
2015-08-06 03:21:16 +08:00
|
|
|
std::string fileExtension = FileUtils::getInstance()->getFileExtension(filePath);
|
|
|
|
if (fileExtension == ".json" || fileExtension == ".exportjson")
|
2015-06-23 13:54:11 +08:00
|
|
|
{
|
2014-06-25 18:10:06 +08:00
|
|
|
cocos2d::ui::Widget* widget = GUIReader::getInstance()->widgetFromJsonFile(filePath.c_str());
|
2014-06-25 11:58:36 +08:00
|
|
|
_render = widget;
|
|
|
|
_render->retain();
|
|
|
|
|
2014-06-30 17:15:55 +08:00
|
|
|
ret = true;
|
2015-06-23 13:54:11 +08:00
|
|
|
}
|
2015-08-06 03:21:16 +08:00
|
|
|
else if (fileExtension == ".csb")
|
2015-06-23 13:54:11 +08:00
|
|
|
{
|
2014-06-25 18:10:06 +08:00
|
|
|
cocos2d::ui::Widget* widget = GUIReader::getInstance()->widgetFromBinaryFile(filePath.c_str());
|
2014-06-25 11:58:36 +08:00
|
|
|
_render = widget;
|
|
|
|
_render->retain();
|
|
|
|
|
2014-06-30 17:15:55 +08:00
|
|
|
ret = true;
|
2015-06-23 13:54:11 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_BREAK_IF(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (resType == 1)
|
|
|
|
{
|
|
|
|
if (strcmp(className, "CCSprite") == 0)
|
|
|
|
{
|
|
|
|
std::string strPngFile = plistPath;
|
|
|
|
std::string::size_type pos = strPngFile.find(".plist");
|
|
|
|
if (pos == strPngFile.npos)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
strPngFile.replace(pos, strPngFile.length(), ".png");
|
2016-02-03 23:12:37 +08:00
|
|
|
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath, strPngFile);
|
|
|
|
_render = Sprite::createWithSpriteFrameName(filePath);
|
2015-06-23 13:54:11 +08:00
|
|
|
_render->retain();
|
2014-06-25 11:58:36 +08:00
|
|
|
|
2014-06-30 17:15:55 +08:00
|
|
|
ret = true;
|
2015-06-23 13:54:11 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_BREAK_IF(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_BREAK_IF(true);
|
|
|
|
}
|
2014-06-25 11:58:36 +08:00
|
|
|
} while (0);
|
|
|
|
|
2014-06-30 17:15:55 +08:00
|
|
|
return ret;
|
2014-01-05 02:22:32 +08:00
|
|
|
}
|
|
|
|
|
2015-09-18 11:48:43 +08:00
|
|
|
ComRender* ComRender::create()
|
2014-01-05 02:22:32 +08:00
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
ComRender * ret = new (std::nothrow) ComRender();
|
2014-01-03 19:30:47 +08:00
|
|
|
if (ret != nullptr && ret->init())
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
ret->autorelease();
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
CC_SAFE_DELETE(ret);
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
2014-01-03 01:42:14 +08:00
|
|
|
return ret;
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
2014-01-05 03:11:32 +08:00
|
|
|
ComRender* ComRender::create(cocos2d::Node *node, const char *comName)
|
|
|
|
{
|
2014-08-28 07:31:57 +08:00
|
|
|
ComRender * ret = new (std::nothrow) ComRender(node, comName);
|
2014-01-05 03:11:32 +08:00
|
|
|
if (ret != nullptr && ret->init())
|
|
|
|
{
|
|
|
|
ret->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(ret);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-01-05 02:22:32 +08:00
|
|
|
bool ComRender::readJson(const std::string &fileName, rapidjson::Document &doc)
|
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
do {
|
|
|
|
std::string contentStr = FileUtils::getInstance()->getStringFromFile(fileName);
|
|
|
|
doc.Parse<0>(contentStr.c_str());
|
|
|
|
CC_BREAK_IF(doc.HasParseError());
|
|
|
|
ret = true;
|
|
|
|
} while (0);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
}
|