Merge pull request #7290 from chengstory/v3_OpBinaryParse

V3 op binary parse
This commit is contained in:
minggo 2014-07-03 14:00:01 +08:00
commit fffdfb3711
34 changed files with 643 additions and 640 deletions

View File

@ -45,6 +45,8 @@ static const char* ClassName_Button = "Button";
static const char* ClassName_CheckBox = "CheckBox";
static const char* ClassName_ImageView = "ImageView";
static const char* ClassName_TextAtlas = "TextAtlas";
static const char* ClassName_LabelAtlas = "LabelAtlas";
static const char* ClassName_LabelBMFont= "LabelBMFont";
static const char* ClassName_TextBMFont = "TextBMFont";
static const char* ClassName_Text = "Text";
static const char* ClassName_LoadingBar = "LoadingBar";
@ -132,7 +134,8 @@ void NodeReader::init()
_funcs.insert(Pair(ClassName_SubGraph, std::bind(&NodeReader::loadSubGraph, this, _1)));
_funcs.insert(Pair(ClassName_Sprite, std::bind(&NodeReader::loadSprite, this, _1)));
_funcs.insert(Pair(ClassName_Particle, std::bind(&NodeReader::loadParticle, this, _1)));
_funcs.insert(Pair(ClassName_LabelAtlas,std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_LabelBMFont,std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_Panel, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_Button, std::bind(&NodeReader::loadWidget, this, _1)));
_funcs.insert(Pair(ClassName_CheckBox, std::bind(&NodeReader::loadWidget, this, _1)));

View File

@ -83,7 +83,7 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
CCLOG("filename == %s",fileName.c_str());
cocos2d::Vector<ActionObject*> actionList;
stExpCocoNode *stChildArray = pCocoNode->GetChildArray();
stExpCocoNode *stChildArray = pCocoNode->GetChildArray(cocoLoader);
stExpCocoNode *actionNode = nullptr;
for (int i=0; i < pCocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
@ -99,7 +99,7 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
ActionObject* action = new ActionObject();
action->autorelease();
action->initWithBinary(cocoLoader, actionNode->GetChildArray(), root);
action->initWithBinary(cocoLoader, actionNode->GetChildArray(cocoLoader), root);
actionList.pushBack(action);
}

View File

@ -195,11 +195,11 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
stExpCocoNode *stChildNode = cocoNode;
int actionNodeCount = stChildNode->GetChildNum();
stChildNode = stChildNode[0].GetChildArray();
stChildNode = stChildNode[0].GetChildArray(cocoLoader);
stExpCocoNode *frameListNode = nullptr;
for (int i = 0; i < actionNodeCount; ++i) {
std::string key = stChildNode[i].GetName(cocoLoader);
std::string value = stChildNode[i].GetValue();
std::string value = stChildNode[i].GetValue(cocoLoader);
if (key == "ActionTag") {
setActionTag(valueToInt(value));
}else if (key == "actionframelist"){
@ -208,7 +208,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
}
int actionFrameCount = frameListNode->GetChildNum();
stExpCocoNode *stFrameChildNode = frameListNode->GetChildArray();
stExpCocoNode *stFrameChildNode = frameListNode->GetChildArray(cocoLoader);
for (int i=0; i<actionFrameCount; i++) {
int frameIndex;
@ -225,10 +225,10 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
std::vector<float> frameTweenParameter;
int framesCount = stFrameChildNode[i].GetChildNum();
stExpCocoNode *innerFrameNode = stFrameChildNode[i].GetChildArray();
stExpCocoNode *innerFrameNode = stFrameChildNode[i].GetChildArray(cocoLoader);
for (int j = 0; j < framesCount; j++) {
std::string key = innerFrameNode[j].GetName(cocoLoader);
std::string value = innerFrameNode[j].GetValue();
std::string value = innerFrameNode[j].GetValue(cocoLoader);
if (key == "frameid") {
frameIndex = valueToInt(value);
@ -237,10 +237,10 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
}else if (key == "tweenParameter"){
// There are no tweenParameter args in the json file
int tweenParameterCount = innerFrameNode[j].GetChildNum();
stExpCocoNode *tweenParameterArray = innerFrameNode[j].GetChildArray();
stExpCocoNode *tweenParameterArray = innerFrameNode[j].GetChildArray(cocoLoader);
for (int k = 0; k < tweenParameterCount; ++k) {
std::string t_key = tweenParameterArray[j].GetName(cocoLoader);
std::string t_value = tweenParameterArray[j].GetValue();
std::string t_value = tweenParameterArray[j].GetValue(cocoLoader);
frameTweenParameter.push_back(valueToFloat(t_value));
}
}else if (key == "positionx"){

View File

@ -132,12 +132,12 @@ void ActionObject::initWithBinary(CocoLoader *cocoLoader,
stExpCocoNode *cocoNode,
cocos2d::Ref *root)
{
stExpCocoNode *stChildNode = cocoNode->GetChildArray();
stExpCocoNode *stChildNode = cocoNode->GetChildArray(cocoLoader);
stExpCocoNode *actionNodeList = nullptr;
int count = cocoNode->GetChildNum();
for (int i = 0; i < count; ++i) {
std::string key = stChildNode[i].GetName(cocoLoader);
std::string value = stChildNode[i].GetValue();
std::string value = stChildNode[i].GetValue(cocoLoader);
if (key == "name") {
setName(value.c_str());
}else if (key == "loop"){
@ -152,7 +152,7 @@ void ActionObject::initWithBinary(CocoLoader *cocoLoader,
if(nullptr != actionNodeList)
{
int actionNodeCount = actionNodeList->GetChildNum();
stExpCocoNode *actionNodeArray = actionNodeList->GetChildArray();
stExpCocoNode *actionNodeArray = actionNodeList->GetChildArray(cocoLoader);
int maxLength = 0;
for (int i=0; i<actionNodeCount; i++) {
ActionNode* actionNode = new ActionNode();

View File

@ -151,6 +151,7 @@ bool ComAttribute::serialize(void* r)
SerData *serData = (SerData *)(r);
const rapidjson::Value *v = serData->_rData;
stExpCocoNode *cocoNode = serData->_cocoNode;
CocoLoader *cocoLoader = serData->_cocoLoader;
const char *className = nullptr;
const char *comName = nullptr;
const char *file = nullptr;
@ -170,14 +171,14 @@ bool ComAttribute::serialize(void* r)
}
else if (cocoNode != nullptr)
{
className = cocoNode[1].GetValue();
className = cocoNode[1].GetValue(cocoLoader);
CC_BREAK_IF(className == nullptr);
comName = cocoNode[2].GetValue();
stExpCocoNode *fileData = cocoNode[3].GetChildArray();
comName = cocoNode[2].GetValue(cocoLoader);
stExpCocoNode *fileData = cocoNode[3].GetChildArray(cocoLoader);
CC_BREAK_IF(!fileData);
file = fileData[0].GetValue();
file = fileData[0].GetValue(cocoLoader);
CC_BREAK_IF(file == nullptr);
resType = atoi(fileData[2].GetValue());
resType = atoi(fileData[2].GetValue(cocoLoader));
CC_BREAK_IF(resType != 0);
}
if (comName != nullptr)

View File

@ -76,6 +76,7 @@ bool ComAudio::serialize(void* r)
SerData *serData = (SerData *)(r);
const rapidjson::Value *v = serData->_rData;
stExpCocoNode *cocoNode = serData->_cocoNode;
CocoLoader *cocoLoader = serData->_cocoLoader;
const char *className = nullptr;
const char *comName = nullptr;
const char *file = nullptr;
@ -97,16 +98,16 @@ bool ComAudio::serialize(void* r)
}
else if (cocoNode != nullptr)
{
className = cocoNode[1].GetValue();
className = cocoNode[1].GetValue(cocoLoader);
CC_BREAK_IF(className == nullptr);
comName = cocoNode[2].GetValue();
stExpCocoNode *pfileData = cocoNode[4].GetChildArray();
comName = cocoNode[2].GetValue(cocoLoader);
stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader);
CC_BREAK_IF(!pfileData);
file = pfileData[0].GetValue();
file = pfileData[0].GetValue(cocoLoader);
CC_BREAK_IF(file == nullptr);
resType = atoi(pfileData[2].GetValue());
resType = atoi(pfileData[2].GetValue(cocoLoader));
CC_BREAK_IF(resType != 0);
loop = atoi(cocoNode[5].GetValue()) != 0? true:false;
loop = atoi(cocoNode[5].GetValue(cocoLoader)) != 0? true:false;
ret = true;
}
if (comName != nullptr)

View File

@ -50,10 +50,12 @@ struct SerData
{
const rapidjson::Value *_rData;
cocostudio::stExpCocoNode *_cocoNode;
cocostudio::CocoLoader *_cocoLoader;
SerData()
{
_rData = NULL;
_cocoNode = NULL;
_cocoLoader = NULL;
}
};

View File

@ -97,6 +97,7 @@ bool ComRender::serialize(void* r)
SerData *serData = (SerData *)(r);
const rapidjson::Value *v = serData->_rData;
stExpCocoNode *cocoNode = serData->_cocoNode;
CocoLoader *cocoLoader = serData->_cocoLoader;
const char *className = nullptr;
const char *comName = nullptr;
const char *file = nullptr;
@ -118,15 +119,15 @@ bool ComRender::serialize(void* r)
}
else if(cocoNode != nullptr)
{
className = cocoNode[1].GetValue();
className = cocoNode[1].GetValue(cocoLoader);
CC_BREAK_IF(className == nullptr);
comName = cocoNode[2].GetValue();
stExpCocoNode *pfileData = cocoNode[4].GetChildArray();
comName = cocoNode[2].GetValue(cocoLoader);
stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader);
CC_BREAK_IF(!pfileData);
file = pfileData[0].GetValue();
plist = pfileData[1].GetValue();
file = pfileData[0].GetValue(cocoLoader);
plist = pfileData[1].GetValue(cocoLoader);
CC_BREAK_IF(file == nullptr && plist == nullptr);
resType = atoi(pfileData[2].GetValue());
resType = atoi(pfileData[2].GetValue(cocoLoader));
}
if (comName != nullptr)
{
@ -195,7 +196,7 @@ bool ComRender::serialize(void* r)
const char *actionName = nullptr;
if (cocoNode != nullptr)
{
actionName = cocoNode[6].GetValue();//DICTOOL->getStringValue_json(*v, "selectedactionname");
actionName = cocoNode[6].GetValue(cocoLoader);//DICTOOL->getStringValue_json(*v, "selectedactionname");
}
else
{
@ -222,25 +223,25 @@ bool ComRender::serialize(void* r)
if (rapidjson::kObjectType == tType)
{
int count = tpRootCocoNode->GetChildNum();
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray();
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
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();
stExpCocoNode *armature_dataArray = tpChildArray[i].GetChildArray();
stExpCocoNode *armature_dataArray = tpChildArray[i].GetChildArray(&tCocoLoader);
if (length < 1)
{
continue;
}
length = armature_dataArray[0].GetChildNum();
stExpCocoNode *armature_data = armature_dataArray[0].GetChildArray();
stExpCocoNode *armature_data = armature_dataArray[0].GetChildArray(&tCocoLoader);
for (int j = 0; j < length; ++j)
{
std::string key1 = armature_data[j].GetName(&tCocoLoader);
const char *str1 = armature_data[j].GetValue();
const char *str1 = armature_data[j].GetValue(&tCocoLoader);
if (key.compare("name") == 0)
{
if (str1 != nullptr)
@ -252,7 +253,7 @@ bool ComRender::serialize(void* r)
const char *actionName = nullptr;
if (cocoNode != nullptr)
{
actionName = cocoNode[6].GetValue();
actionName = cocoNode[6].GetValue(&tCocoLoader);
}
else
{

View File

@ -301,9 +301,9 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath)
// Read content from file
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filePath);
bool isbinarysrc = str==".csb";
bool isbinaryfilesrc = str==".csb";
std::string filemode("r");
if(isbinarysrc)
if(isbinaryfilesrc)
filemode += "b";
ssize_t filesize;
@ -324,7 +324,7 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath)
{
DataReaderHelper::addDataFromJsonCache(contentStr, &dataInfo);
}
else if(str == ".csb")
else if(isbinaryfilesrc)
{
DataReaderHelper::addDataFromBinaryCache(contentStr.c_str(),&dataInfo);
}
@ -438,7 +438,7 @@ void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const
{
data->configType = CocoStudio_JSON;
}
else if(str == ".csb")
else if(isbinaryfilesrc)
{
data->configType = CocoStudio_Binary;
}
@ -1750,7 +1750,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
if (rapidjson::kObjectType == tType)
{
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray();
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
int nCount = tpRootCocoNode->GetChildNum();
dataInfo->contentScale = 1.0f;
@ -1762,12 +1762,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
key = tpChildArray[i].GetName(&tCocoLoader);
if (key.compare(CONTENT_SCALE) == 0)
{
std::string value = tpChildArray[i].GetValue();
std::string value = tpChildArray[i].GetValue(&tCocoLoader);
dataInfo->contentScale = atof(value.c_str());
}
else if ( 0 == key.compare(ARMATURE_DATA))
{
pDataArray = tpChildArray[i].GetChildArray();
pDataArray = tpChildArray[i].GetChildArray(&tCocoLoader);
length = tpChildArray[i].GetChildNum();
ArmatureData * armatureData;
for (int ii = 0; ii < length; ++ii)
@ -1787,7 +1787,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
}
else if ( 0 == key.compare(ANIMATION_DATA))
{
pDataArray = tpChildArray[i].GetChildArray();
pDataArray = tpChildArray[i].GetChildArray(&tCocoLoader);
length = tpChildArray[i].GetChildNum();
AnimationData *animationData;
for (int ii = 0; ii < length; ++ii)
@ -1807,7 +1807,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
}
else if (key.compare(TEXTURE_DATA) == 0)
{
pDataArray = tpChildArray[i].GetChildArray();
pDataArray = tpChildArray[i].GetChildArray(&tCocoLoader);
length = tpChildArray[i].GetChildNum();
for (int ii = 0; ii < length; ++ii)
{
@ -1837,10 +1837,10 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
continue;
}
length = tpChildArray[i].GetChildNum();
stExpCocoNode *pConfigFilePath = tpChildArray[i].GetChildArray();
stExpCocoNode *pConfigFilePath = tpChildArray[i].GetChildArray(&tCocoLoader);
for (int ii = 0; ii < length; ii++)
{
const char *path = pConfigFilePath[ii].GetValue();
const char *path = pConfigFilePath[ii].GetValue(&tCocoLoader);
if (path == nullptr)
{
CCLOG("load CONFIG_FILE_PATH error.");
@ -1872,18 +1872,18 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
ArmatureData *armatureData = new ArmatureData();
armatureData->init();
stExpCocoNode *pAramtureDataArray = cocoNode->GetChildArray();
const char *name = pAramtureDataArray[2].GetValue(); //DICTOOL->getStringValue_json(json, A_NAME);
stExpCocoNode *pAramtureDataArray = cocoNode->GetChildArray(cocoLoader);
const char *name = pAramtureDataArray[2].GetValue(cocoLoader); //DICTOOL->getStringValue_json(json, A_NAME);
if(name != nullptr)
{
armatureData->name = name;
}
float version = atof(pAramtureDataArray[1].GetValue());
float version = atof(pAramtureDataArray[1].GetValue(cocoLoader));
dataInfo->cocoStudioVersion = armatureData->dataVersion = version; //DICTOOL->getFloatValue_json(json, VERSION, 0.1f);
int length = pAramtureDataArray[3].GetChildNum(); //DICTOOL->getArrayCount_json(json, BONE_DATA, 0);
stExpCocoNode *pBoneChildren = pAramtureDataArray[3].GetChildArray();
stExpCocoNode *pBoneChildren = pAramtureDataArray[3].GetChildArray(cocoLoader);
stExpCocoNode* child;
for (int i = 0; i < length; i++)
{
@ -1905,7 +1905,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
decodeNode(boneData, cocoLoader, cocoNode, dataInfo);
int length = cocoNode->GetChildNum();
stExpCocoNode *pBoneChildren = cocoNode->GetChildArray();
stExpCocoNode *pBoneChildren = cocoNode->GetChildArray(cocoLoader);
stExpCocoNode* child;
const char *str = nullptr;
std::string key;
@ -1913,7 +1913,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
child = &pBoneChildren[i];
key = child->GetName(cocoLoader);
str = child->GetValue();
str = child->GetValue(cocoLoader);
if (key.compare(A_NAME) == 0)
{
//DICTOOL->getStringValue_json(json, A_NAME);
@ -1933,7 +1933,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
else if (key.compare(DISPLAY_DATA) == 0)
{
int count = child->GetChildNum();
stExpCocoNode *pDisplayData = child->GetChildArray();
stExpCocoNode *pDisplayData = child->GetChildArray(cocoLoader);
for (int ii = 0; ii < count; ++ii)
{
DisplayData *displayData = decodeBoneDisplay(cocoLoader, &pDisplayData[ii], dataInfo);
@ -1950,16 +1950,16 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
DisplayData* DataReaderHelper::decodeBoneDisplay(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, DataInfo *dataInfo)
{
stExpCocoNode* children = cocoNode->GetChildArray();
stExpCocoNode* children = cocoNode->GetChildArray(cocoLoader);
stExpCocoNode* child = &children[1];
const char *str = nullptr;
std::string key = child->GetName(cocoLoader);
str = child->GetValue();
str = child->GetValue(cocoLoader);
DisplayData *displayData = nullptr;
if (key.compare(A_DISPLAY_TYPE) == 0)
{
str = child->GetValue();
str = child->GetValue(cocoLoader);
DisplayType displayType = (DisplayType)(atoi(str));
int length = 0;
@ -1969,12 +1969,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
displayData = new SpriteDisplayData();
const char *name = children[0].GetValue();
const char *name = children[0].GetValue(cocoLoader);
if(name != nullptr)
{
((SpriteDisplayData *)displayData)->displayName = name;
}
stExpCocoNode *pSkinDataArray = children[2].GetChildArray();
stExpCocoNode *pSkinDataArray = children[2].GetChildArray(cocoLoader);
if (pSkinDataArray != nullptr)
{
stExpCocoNode *pSkinData = &pSkinDataArray[0];
@ -1982,11 +1982,11 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
SpriteDisplayData *sdd = (SpriteDisplayData *)displayData;
length = pSkinData->GetChildNum();
stExpCocoNode *SkinDataValue = pSkinData->GetChildArray();
stExpCocoNode *SkinDataValue = pSkinData->GetChildArray(cocoLoader);
for (int i = 0; i < length; ++i)
{
key = SkinDataValue[i].GetName(cocoLoader);
str = SkinDataValue[i].GetValue();
str = SkinDataValue[i].GetValue(cocoLoader);
if (key.compare(A_X) == 0)
{
sdd->skinData.x = atof(str) * s_PositionReadScale;
@ -2024,7 +2024,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
displayData = new ArmatureDisplayData();
const char *name = cocoNode[0].GetValue();
const char *name = cocoNode[0].GetValue(cocoLoader);
if(name != nullptr)
{
((ArmatureDisplayData *)displayData)->displayName = name;
@ -2035,11 +2035,11 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
displayData = new ParticleDisplayData();
length = cocoNode->GetChildNum();
stExpCocoNode *pDisplayData = cocoNode->GetChildArray();
stExpCocoNode *pDisplayData = cocoNode->GetChildArray(cocoLoader);
for (int i = 0; i < length; ++i)
{
key = pDisplayData[i].GetName(cocoLoader);
str = pDisplayData[i].GetValue();
str = pDisplayData[i].GetValue(cocoLoader);
if (key.compare(A_PLIST) == 0)
{
const char *plist = str;
@ -2073,7 +2073,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
AnimationData *aniData = new AnimationData();
int length = cocoNode->GetChildNum();
stExpCocoNode *pAnimationData = cocoNode->GetChildArray();
stExpCocoNode *pAnimationData = cocoNode->GetChildArray(cocoLoader);
const char *str = nullptr;
std::string key;
stExpCocoNode* child;
@ -2082,7 +2082,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
child = &pAnimationData[i];
key = child->GetName(cocoLoader);
str = child->GetValue();
str = child->GetValue(cocoLoader);
if (key.compare(A_NAME) == 0)
{
if(str != nullptr)
@ -2093,7 +2093,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
else if (key.compare(MOVEMENT_DATA) == 0)
{
int movcount = child->GetChildNum();
stExpCocoNode* movArray = child->GetChildArray();
stExpCocoNode* movArray = child->GetChildArray(cocoLoader);
for( int movnum =0; movnum <movcount; movnum++)
{
movementData = decodeMovement(cocoLoader, &movArray[movnum], dataInfo);
@ -2111,7 +2111,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
movementData->scale = 1.0f;
int length = cocoNode->GetChildNum();
stExpCocoNode *pMoveDataArray = cocoNode->GetChildArray();
stExpCocoNode *pMoveDataArray = cocoNode->GetChildArray(cocoLoader);
const char *str = nullptr;
std::string key;
@ -2120,7 +2120,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
child = &pMoveDataArray[i];
key = child->GetName(cocoLoader);
str = child->GetValue();
str = child->GetValue(cocoLoader);
if (key.compare(A_NAME) == 0)
{
if(str != nullptr)
@ -2182,7 +2182,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
else if (key.compare(MOVEMENT_BONE_DATA) == 0)
{
int count = child->GetChildNum();
stExpCocoNode *pMoveBoneData = child->GetChildArray();
stExpCocoNode *pMoveBoneData = child->GetChildArray(cocoLoader);
MovementBoneData *movementBoneData;
for (int ii = 0; ii < count; ++ii)
{
@ -2201,14 +2201,14 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
movementBoneData->init();
int length = cocoNode->GetChildNum();
stExpCocoNode *pMovementBoneDataArray = cocoNode->GetChildArray();
stExpCocoNode *pMovementBoneDataArray = cocoNode->GetChildArray(cocoLoader);
stExpCocoNode* movebonechild;
const char *str = nullptr;
for (int i = 0; i < length; ++i)
{
movebonechild = &pMovementBoneDataArray[i];
std::string key = movebonechild->GetName(cocoLoader);
str = movebonechild->GetValue();
str = movebonechild->GetValue(cocoLoader);
if (key.compare(A_NAME) == 0)
{
if(str != nullptr)
@ -2226,7 +2226,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
else if (key.compare(FRAME_DATA) == 0)
{
int count =movebonechild->GetChildNum();
stExpCocoNode *pFrameDataArray = movebonechild->GetChildArray();
stExpCocoNode *pFrameDataArray = movebonechild->GetChildArray(cocoLoader);
for (int ii = 0; ii < count; ++ii)
{
FrameData *frameData = decodeFrame(cocoLoader, &pFrameDataArray[ii], dataInfo);
@ -2296,12 +2296,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
decodeNode(frameData, cocoLoader, cocoNode, dataInfo);
int length = cocoNode->GetChildNum();
stExpCocoNode *pFrameDataArray = cocoNode->GetChildArray();
stExpCocoNode *pFrameDataArray = cocoNode->GetChildArray(cocoLoader);
const char *str = nullptr;
for (int i = 0; i < length; ++i)
{
std::string key = pFrameDataArray[i].GetName(cocoLoader);
str = pFrameDataArray[i].GetValue();
str = pFrameDataArray[i].GetValue(cocoLoader);
if (key.compare(A_TWEEN_EASING) == 0)
{
frameData->tweenEasing = cocos2d::tweenfunc::Linear;
@ -2376,10 +2376,10 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
if (count != 0 )
{
frameData->easingParams = new float[count];
stExpCocoNode *pFrameData = pFrameDataArray[i].GetChildArray();
stExpCocoNode *pFrameData = pFrameDataArray[i].GetChildArray(cocoLoader);
for (int ii = 0; ii < count; ++ii)
{
str = pFrameData[ii].GetValue();
str = pFrameData[ii].GetValue(cocoLoader);
if (str != nullptr)
{
frameData->easingParams[ii] = atof(str);
@ -2404,12 +2404,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
}
int length = cocoNode->GetChildNum();
stExpCocoNode *pTextureDataArray = cocoNode->GetChildArray();
stExpCocoNode *pTextureDataArray = cocoNode->GetChildArray(cocoLoader);
const char *str = nullptr;
for (int i = 0; i < length; ++i)
{
std::string key = pTextureDataArray[i].GetName(cocoLoader);
str = pTextureDataArray[i].GetValue();
str = pTextureDataArray[i].GetValue(cocoLoader);
if (key.compare(A_NAME) == 0)
{
if(str != nullptr)
@ -2448,7 +2448,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
else if (key.compare(CONTOUR_DATA) == 0)
{
int count = pTextureDataArray[i].GetChildNum();
stExpCocoNode *pContourArray = pTextureDataArray[i].GetChildArray();
stExpCocoNode *pContourArray = pTextureDataArray[i].GetChildArray(cocoLoader);
for (int ii = 0; ii < count; ++ii)
{
ContourData *contourData = decodeContour(cocoLoader, &pContourArray[ii]);
@ -2466,23 +2466,23 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
contourData->init();
int length = cocoNode->GetChildNum();
stExpCocoNode *verTexPointArray = cocoNode->GetChildArray();
stExpCocoNode *verTexPointArray = cocoNode->GetChildArray(cocoLoader);
const char *str = nullptr;
for (int i = 0; i < length; ++i)
{
std::string key = verTexPointArray[i].GetName(cocoLoader);
str = verTexPointArray[i].GetValue();
str = verTexPointArray[i].GetValue(cocoLoader);
if (key.compare(VERTEX_POINT) == 0)
{
int count = verTexPointArray[i].GetChildNum();
stExpCocoNode *pVerTexPointArray = verTexPointArray[i].GetChildArray();
stExpCocoNode *pVerTexPointArray = verTexPointArray[i].GetChildArray(cocoLoader);
stExpCocoNode *pVerTexPoint;
for (int ii = count - 1; ii >= 0; --ii)
{
pVerTexPoint = pVerTexPointArray[ii].GetChildArray();
pVerTexPoint = pVerTexPointArray[ii].GetChildArray(cocoLoader);
Vec2 vertex;
vertex.x = atof(pVerTexPoint[0].GetValue());
vertex.y = atof(pVerTexPoint[1].GetValue());
vertex.x = atof(pVerTexPoint[0].GetValue(cocoLoader));
vertex.y = atof(pVerTexPoint[1].GetValue(cocoLoader));
contourData->vertexList.push_back(vertex); }
break;
}
@ -2493,7 +2493,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
void DataReaderHelper::decodeNode(BaseData *node, CocoLoader *cocoLoader, stExpCocoNode* cocoNode, DataInfo *dataInfo)
{
int length = cocoNode->GetChildNum();
stExpCocoNode *NodeArray = cocoNode->GetChildArray();
stExpCocoNode *NodeArray = cocoNode->GetChildArray(cocoLoader);
const char *str = nullptr;
bool isVersionL = dataInfo->cocoStudioVersion < VERSION_COLOR_READING;
@ -2502,7 +2502,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
child = &NodeArray[i];
std::string key = child->GetName(cocoLoader);
str = child->GetValue();
str = child->GetValue(cocoLoader);
if (key.compare(A_X) == 0)
{
node->x = atof(str) * dataInfo->contentScale;
@ -2539,12 +2539,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
if(child->GetChildNum() == 4)
{
stExpCocoNode *ChildArray = child->GetChildArray();
stExpCocoNode *ChildArray = child->GetChildArray(cocoLoader);
node->a = atoi(ChildArray[0].GetValue());
node->r = atoi(ChildArray[1].GetValue());
node->g = atoi(ChildArray[2].GetValue());
node->b = atoi(ChildArray[3].GetValue());
node->a = atoi(ChildArray[0].GetValue(cocoLoader));
node->r = atoi(ChildArray[1].GetValue(cocoLoader));
node->g = atoi(ChildArray[2].GetValue(cocoLoader));
node->b = atoi(ChildArray[3].GetValue(cocoLoader));
}
}
@ -2566,12 +2566,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
{
if(NodeArray[0].GetChildNum() == 4)
{
stExpCocoNode *ChildArray = NodeArray[0].GetChildArray();
stExpCocoNode *ChildArray = NodeArray[0].GetChildArray(cocoLoader);
node->a = atoi(ChildArray[0].GetValue());
node->r = atoi(ChildArray[1].GetValue());
node->g = atoi(ChildArray[2].GetValue());
node->b = atoi(ChildArray[3].GetValue());
node->a = atoi(ChildArray[0].GetValue(cocoLoader));
node->r = atoi(ChildArray[1].GetValue(cocoLoader));
node->g = atoi(ChildArray[2].GetValue(cocoLoader));
node->b = atoi(ChildArray[3].GetValue(cocoLoader));
}
}

View File

@ -361,13 +361,13 @@ Widget* GUIReader::widgetFromBinaryFile(const char *fileName)
rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
if (rapidjson::kObjectType == tType || rapidjson::kArrayType == tType)
{
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray();
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
for (int i = 0; i < tpRootCocoNode->GetChildNum(); ++i) {
std::string key = tpChildArray[i].GetName(&tCocoLoader);
if (key == "version") {
fileVersion = tpChildArray[i].GetValue();
fileVersion = tpChildArray[i].GetValue(&tCocoLoader);
break;
}
}
@ -1222,7 +1222,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
cocos2d::ui::Widget* WidgetPropertiesReader0300::createWidgetFromBinary(CocoLoader* cocoLoader,stExpCocoNode* cocoNode, const char* fileName)
{
stExpCocoNode *tpChildArray = cocoNode->GetChildArray();
stExpCocoNode *tpChildArray = cocoNode->GetChildArray(cocoLoader);
float fileDesignWidth;
float fileDesignHeight;
@ -1236,14 +1236,14 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
for (int j=0; j<texturesCount; j++)
{
std::string file;
stExpCocoNode *textureCountsArray = tpChildArray[i].GetChildArray();
file = textureCountsArray[j].GetValue();
stExpCocoNode *textureCountsArray = tpChildArray[i].GetChildArray(cocoLoader);
file = textureCountsArray[j].GetValue(cocoLoader);
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(file);
}
}else if (key == "designWidth"){
fileDesignWidth = atof(tpChildArray[i].GetValue());
fileDesignWidth = atof(tpChildArray[i].GetValue(cocoLoader));
}else if (key == "designHeight"){
fileDesignHeight = atof(tpChildArray[i].GetValue());
fileDesignHeight = atof(tpChildArray[i].GetValue(cocoLoader));
}else if (key == "widgetTree"){
if (fileDesignWidth <= 0 || fileDesignHeight <= 0) {
@ -1275,7 +1275,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
/* ********************** */
/* ********************** */
stExpCocoNode *optionChildNode = cocoNode->GetChildArray();
stExpCocoNode *optionChildNode = cocoNode->GetChildArray(cocoLoader);
for (int k = 0; k < cocoNode->GetChildNum(); ++k) {
std::string key = optionChildNode[k].GetName(cocoLoader);
if (key == "animation") {
@ -1291,7 +1291,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, stExpCocoNode* cocoNode)
{
Widget* widget = nullptr;
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
stExpCocoNode *optionsNode = nullptr;
stExpCocoNode *childrenNode = nullptr;
int elementCount = cocoNode->GetChildNum();
@ -1299,7 +1299,7 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st
for (int i = 0; i < elementCount; ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
if (key == "classname" )
{
@ -1341,11 +1341,11 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st
// 2nd., custom widget parse with custom reader
//2nd. parse custom property
const char* customProperty = NULL;
stExpCocoNode *optionChildNode = optionsNode->GetChildArray();
stExpCocoNode *optionChildNode = optionsNode->GetChildArray(cocoLoader);
for (int k = 0; k < optionsNode->GetChildNum(); ++k) {
std::string key = optionChildNode[k].GetName(cocoLoader);
if (key == "customProperty") {
customProperty = optionChildNode[k].GetValue();
customProperty = optionChildNode[k].GetValue(cocoLoader);
break;
}
}
@ -1369,7 +1369,7 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st
if (tType22 == rapidjson::kArrayType) {
int childrenCount = childrenNode->GetChildNum();
stExpCocoNode* innerChildArray = childrenNode->GetChildArray();
stExpCocoNode* innerChildArray = childrenNode->GetChildArray(cocoLoader);
for (int i=0; i < childrenCount; ++i) {
rapidjson::Type tType = innerChildArray[i].GetType(cocoLoader);

View File

@ -91,7 +91,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
if (rapidjson::kObjectType == tType)
{
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray();
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
CC_BREAK_IF(tpRootCocoNode->GetChildNum() == 0);
_node = Node::create();
int nCount = 0;
@ -102,17 +102,17 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
{
nCount = tpChildArray[15].GetChildNum();
}
stExpCocoNode *pComponents = tpChildArray[15].GetChildArray();
stExpCocoNode *pComponents = tpChildArray[15].GetChildArray(&tCocoLoader);
SerData *data = new SerData();
for (int i = 0; i < nCount; i++)
{
stExpCocoNode *subDict = pComponents[i].GetChildArray();
stExpCocoNode *subDict = pComponents[i].GetChildArray(&tCocoLoader);
if (subDict == nullptr)
{
continue;
}
std::string key1 = subDict[1].GetName(&tCocoLoader);
const char *comName = subDict[1].GetValue();
const char *comName = subDict[1].GetValue(&tCocoLoader);
Component *pCom = nullptr;
if (key1 == "classname" && comName != nullptr)
{
@ -123,6 +123,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
{
data->_rData = nullptr;
data->_cocoNode = subDict;
data->_cocoLoader = &tCocoLoader;
if (pCom->serialize(data))
{
ComRender *pTRender = dynamic_cast<ComRender*>(pCom);
@ -152,7 +153,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
_node->addComponent(*iter);
}
stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray();
stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray(&tCocoLoader);
int length = tpChildArray[11].GetChildNum();
for (int i = 0; i < length; ++i)
{
@ -283,6 +284,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
{
data->_rData = &subDict;
data->_cocoNode = nullptr;
data->_cocoLoader = nullptr;
if (com->serialize(data))
{
ComRender *tRender = dynamic_cast<ComRender*>(com);
@ -349,11 +351,11 @@ 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 = nullptr;
stExpCocoNode *pNodeArray = cocoNode->GetChildArray();
stExpCocoNode *pNodeArray = cocoNode->GetChildArray(cocoLoader);
std::string Key = pNodeArray[1].GetName(cocoLoader);
if (Key == "classname")
{
className = pNodeArray[1].GetValue();
className = pNodeArray[1].GetValue(cocoLoader);
}
if(strcmp(className, "CCNode") == 0)
{
@ -366,17 +368,17 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
{
count = pNodeArray[13].GetChildNum();
}
stExpCocoNode *pComponents = pNodeArray[13].GetChildArray();
stExpCocoNode *pComponents = pNodeArray[13].GetChildArray(cocoLoader);
SerData *data = new SerData();
for (int i = 0; i < count; ++i)
{
stExpCocoNode *subDict = pComponents[i].GetChildArray();
stExpCocoNode *subDict = pComponents[i].GetChildArray(cocoLoader);
if (subDict == nullptr)
{
continue;
}
std::string key1 = subDict[1].GetName(cocoLoader);
const char *comName = subDict[1].GetValue();
const char *comName = subDict[1].GetValue(cocoLoader);
Component *pCom = nullptr;
if (key1 == "classname" && comName != nullptr)
{
@ -387,6 +389,7 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
{
data->_rData = nullptr;
data->_cocoNode = subDict;
data->_cocoLoader = cocoLoader;
if (pCom->serialize(data))
{
ComRender *pTRender = dynamic_cast<ComRender*>(pCom);
@ -436,7 +439,7 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
gb->addComponent(*iter);
}
stExpCocoNode *pGameObjects = pNodeArray[12].GetChildArray();
stExpCocoNode *pGameObjects = pNodeArray[12].GetChildArray(cocoLoader);
if (pGameObjects != nullptr)
{
int length = pNodeArray[12].GetChildNum();
@ -495,7 +498,7 @@ void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d:
void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::Node *node)
{
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
float x = 0.0f, y = 0.0f, fScaleX = 1.0f, fScaleY = 1.0f, fRotationZ = 1.0f;
bool bVisible = false;
int nTag = 0, nZorder = -1;
@ -503,7 +506,7 @@ void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode
for (int i = 0; i < cocoNode->GetChildNum(); ++i)
{
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
if (key == "x")
{

View File

@ -1,5 +1,5 @@
#include "CocoLoader.h"
#include "zlib.h"
using namespace std;
using namespace rapidjson;
@ -7,24 +7,46 @@ using namespace rapidjson;
namespace cocostudio{
char cTypeName[] = {'N','F','T','O','A','S','V'};
const char* kTypeNames[] = { "Null", "False", "True", "Object", "Array", "String", "Number" };
const char* kObjKeyName[] = { "__type" , "classname" };
char g_Buff[2048];
char* stExpCocoAttribDesc::GetName(CocoLoader* pCoco)
{
return ( pCoco->GetMemoryAddr_String() + m_szName );
}
char* stExpCocoObjectDesc::GetName(CocoLoader* pCoco)
{
return ( pCoco->GetMemoryAddr_String() + m_szName );
}
int stExpCocoObjectDesc::GetAttribNum()
{
return m_cAttribNum;
}
stExpCocoAttribDesc* stExpCocoObjectDesc::GetAttribDescArray(CocoLoader* pCoco)
{
return (stExpCocoAttribDesc*)( pCoco->GetMemoryAddr_AttribDesc() + m_pAttribDescArray );
}
Type stExpCocoNode::GetType(CocoLoader* pCoco)
{
Type tType = kObjectType;
if(m_ObjIndex >= 0)
{
stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray() ;
if( m_AttribIndex >= 0 )
{
stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].m_pAttribDescArray;
tType = tpAttribDescArray[m_AttribIndex].m_Type;
stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].GetAttribDescArray(pCoco);
tType = Type(tpAttribDescArray[m_AttribIndex].m_cTypeName - 'N' + kNullType);
if(kFalseType == tType || kTrueType == tType)
if('F' == tType || 'T' == tType)
{
char* szValue = (char*)m_szValue;
char* szValue = (char*)GetValue(pCoco);
if(szValue[0] == '0')
{
return kFalseType;
@ -49,7 +71,7 @@ Type stExpCocoNode::GetType(CocoLoader* pCoco)
if(kFalseType == tType || kTrueType == tType)
{
char* szValue = (char*)m_szValue;
char* szValue = (char*)GetValue(pCoco);
if(szValue[0] == '0')
{
return kFalseType;
@ -76,19 +98,22 @@ char* stExpCocoNode::GetName(CocoLoader* pCoco)
stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray();
if( m_AttribIndex >= 0 )
{
stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].m_pAttribDescArray;
szName = (char*)tpAttribDescArray[m_AttribIndex].m_szName;
stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].GetAttribDescArray(pCoco);
szName = tpAttribDescArray[m_AttribIndex].GetName(pCoco);
}
else
{
char* szValue = (char*)m_szValue;
//»Áπ˚√˚◊÷”ο‡√˚≥∆≤ªÕ¨£¨‘Ú∞¥’Ê µ÷µ…Ë÷√
char* szValue = GetValue(pCoco);
if(szValue[0])
{
szName = (char*)m_szValue;
// ˝◊È
szName = GetValue(pCoco);
}
else
{
szName = (char*)tpCocoObjectDesc[m_ObjIndex].m_szName;
//Ω·ππ
szName = tpCocoObjectDesc[m_ObjIndex].GetName(pCoco);
}
}
}
@ -101,15 +126,16 @@ char* stExpCocoNode::GetName(CocoLoader* pCoco)
}
else
{
szName = (char*)m_szValue;
szName = (char*)GetValue(pCoco);
}
}
return szName ;
}
char* stExpCocoNode::GetValue()
char* stExpCocoNode::GetValue(CocoLoader* pCoco)
{
return (char*)m_szValue;
return ( pCoco->GetMemoryAddr_String() + m_szValue );
}
int stExpCocoNode::GetChildNum()
@ -117,68 +143,52 @@ int stExpCocoNode::GetChildNum()
return m_ChildNum;
}
stExpCocoNode* stExpCocoNode::GetChildArray()
stExpCocoNode* stExpCocoNode::GetChildArray(CocoLoader* pCoco)
{
return (stExpCocoNode*)m_ChildArray;
}
void stExpCocoNode::ReBuild(char* cocoNodeAddr,char* pStringMemoryAddr)
{
m_szValue = m_szValue + (uint64_t)pStringMemoryAddr;
if( -1 == m_AttribIndex )
{
if(m_ChildNum > 0)
{
m_ChildArray = m_ChildArray + (uint64_t)cocoNodeAddr;
stExpCocoNode* tpChildArray = (stExpCocoNode*)m_ChildArray;
for(int i = 0 ; i < m_ChildNum ; i++)
{
tpChildArray[i].ReBuild(cocoNodeAddr,pStringMemoryAddr);
}
}
}
return (stExpCocoNode*)( pCoco->GetMemoryAddr_CocoNode() + m_ChildArray );
}
CocoLoader::CocoLoader()
{
m_pRootNode = NULL;
m_pObjectDescArray = NULL;
m_pMemoryBuff = NULL;
}
CocoLoader::~CocoLoader()
{
if(m_pMemoryBuff)
{
delete[] m_pMemoryBuff;
m_pMemoryBuff = NULL;
}
}
bool CocoLoader::ReadCocoBinBuff(char* pBinBuff)
{
if(m_pMemoryBuff)return true;
char* pTempBuff = pBinBuff;
m_pFileHeader = (stCocoFileHeader*)pTempBuff;
pTempBuff += sizeof(stCocoFileHeader);
char* pStartAddr = m_pMemoryBuff = pTempBuff;
if( m_pFileHeader->m_nCompressSize > 0 )
{
char* pDestBuff = new char[m_pFileHeader->m_nDataSize];
uLongf dwSrcSize = m_pFileHeader->m_nCompressSize;
uLongf dwDestSize = m_pFileHeader->m_nDataSize;
int nRes = uncompress((Bytef*)pDestBuff,&dwDestSize,(Bytef*)m_pMemoryBuff,dwSrcSize);
pStartAddr = m_pMemoryBuff = pDestBuff;
}
char* pStartAddr = pTempBuff;
m_pObjectDescArray = (stExpCocoObjectDesc*)pStartAddr;
char* pAttrAddr = pStartAddr + m_pFileHeader->m_lAttribMemAddr ;
char* pCocoMemAddr = pStartAddr + m_pFileHeader->m_CocoNodeMemAddr;
char* pStringAddr = pStartAddr + m_pFileHeader->m_lStringMemAddr ;
m_pRootNode = (stExpCocoNode*)pCocoMemAddr;
if(1 == m_pFileHeader->m_nFirstUsed)
{
for(int i = 0 ; i < m_pFileHeader->m_ObjectCount ; i++)
{
m_pObjectDescArray[i].ReBuild(pAttrAddr,pStringAddr) ;
}
m_pRootNode->ReBuild(pCocoMemAddr,pStringAddr);
m_pFileHeader->m_nFirstUsed = 0;
}
return true;
}
@ -193,4 +203,29 @@ stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(const char* szObjDesc)
}
return NULL;
}
stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(int vIndex)
{
if(vIndex >= 0 && vIndex < m_pFileHeader->m_ObjectCount)
{
return &m_pObjectDescArray[vIndex];
}
return NULL;
}
char* CocoLoader::GetMemoryAddr_AttribDesc()
{
return m_pMemoryBuff + m_pFileHeader->m_lAttribMemAddr ;
}
char* CocoLoader::GetMemoryAddr_CocoNode()
{
return m_pMemoryBuff + m_pFileHeader->m_CocoNodeMemAddr;
}
char* CocoLoader::GetMemoryAddr_String()
{
return m_pMemoryBuff + m_pFileHeader->m_lStringMemAddr ;
}
}

View File

@ -36,101 +36,80 @@
namespace cocostudio{
class CocoLoader;
struct stExpCocoAttribDesc
{
rapidjson::Type m_Type;
uint64_t m_szName;
uint64_t m_szDefaultValue;
char m_cTypeName;
uint32_t m_szName;
public:
void ReBuild(char* pStringMemoryAddr)
{
m_szName = m_szName + (uint64_t)pStringMemoryAddr;
m_szDefaultValue = m_szDefaultValue + (uint64_t)pStringMemoryAddr;
}
char* GetName(CocoLoader* pCoco);
};
struct stExpCocoObjectDesc
{
uint32_t m_nAttribNum;
uint64_t m_szName;
uint64_t m_pAttribDescArray;
unsigned char m_cAttribNum;
uint32_t m_szName;
uint32_t m_pAttribDescArray;
public:
stExpCocoObjectDesc()
{
m_nAttribNum = 0;
m_szName = 0;
m_pAttribDescArray = 0;
}
void ReBuild(char* pAttribMemoryAddr,char* pStringMemoryAddr)
{
m_szName = m_szName + (uint64_t)pStringMemoryAddr;
m_pAttribDescArray = m_pAttribDescArray + (uint64_t)pAttribMemoryAddr;
stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*)m_pAttribDescArray;
for(uint32_t i = 0 ; i < m_nAttribNum ; i++)
{
tpAttribDescArray[i].ReBuild(pStringMemoryAddr);
}
}
char* GetName(CocoLoader* pCoco);
int GetAttribNum();
stExpCocoAttribDesc* GetAttribDescArray(CocoLoader* pCoco);
};
class CocoLoader;
struct stExpCocoNode
{
protected:
int32_t m_ObjIndex;
int32_t m_AttribIndex;
uint32_t m_ChildNum;
uint64_t m_szValue;
uint64_t m_ChildArray;
public:
int16_t m_ObjIndex;
int16_t m_AttribIndex;
unsigned char m_ChildNum;
uint32_t m_szValue;
uint32_t m_ChildArray;
public:
rapidjson::Type GetType(CocoLoader* pCoco);
char* GetName(CocoLoader* pCoco);
char* GetValue();
char* GetValue(CocoLoader* pCoco);
int GetChildNum();
stExpCocoNode* GetChildArray();
stExpCocoNode* GetChildArray(CocoLoader* pCoco);
public:
inline void ReBuild(char* cocoNodeAddr,char* pStringMemoryAddr);
void WriteJson(CocoLoader* pCoco, void* pFileName = NULL, int vLayer = 0, bool bEndNode = false, bool bParentNodeIsArray = false);
void WriteJson(CocoLoader* pCoco,void* pFileName = nullptr, int vLayer = 0, bool bEndNode = false, bool bParentNodeIsArray = false);
};
struct stCocoFileHeader
{
char m_FileDesc[32];
char m_Version[32];
uint32_t m_nFirstUsed;
uint32_t m_nDataSize;
uint32_t m_nCompressSize;
uint32_t m_ObjectCount;
uint64_t m_lAttribMemAddr;
uint64_t m_CocoNodeMemAddr;
uint64_t m_lStringMemAddr;
uint32_t m_lAttribMemAddr;
uint32_t m_CocoNodeMemAddr;
uint32_t m_lStringMemAddr;
};
class CocoLoader
{
private:
stCocoFileHeader* m_pFileHeader;
stExpCocoNode* m_pRootNode;
stExpCocoObjectDesc* m_pObjectDescArray;
char* m_pMemoryBuff;
public:
CocoLoader();
~CocoLoader();
public:
bool ReadCocoBinBuff(char* pBinBuff);
stCocoFileHeader* GetFileHeader(){return m_pFileHeader;}
stExpCocoNode* GetRootCocoNode(){return m_pRootNode;}
stExpCocoObjectDesc* GetCocoObjectDescArray(){return m_pObjectDescArray;}
stExpCocoObjectDesc* GetCocoObjectDesc(const char* szObjDesc);
stExpCocoObjectDesc* GetCocoObjectDesc(int vIndex);
char* GetMemoryAddr_AttribDesc();
char* GetMemoryAddr_CocoNode();
char* GetMemoryAddr_String();
};
}

View File

@ -111,7 +111,7 @@ void TriggerMng::parse(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCoc
CCLOG("%s", triggerMngVersion());
int count = pCocoNode[13].GetChildNum();
stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray();
stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray(pCocoLoader);
#if CC_ENABLE_SCRIPT_BINDING
ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine();
@ -200,7 +200,7 @@ bool TriggerMng::isEmpty(void) const
int extent = 0;
int border = 0;
std::string key0;
stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray();
stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray(pCocoLoader);
document.SetArray();
@ -210,28 +210,28 @@ bool TriggerMng::isEmpty(void) const
rapidjson::Value vElemItem(rapidjson::kObjectType);
border = pTriggersArray[i0].GetChildNum();
stExpCocoNode *pTriggerArray = pTriggersArray[i0].GetChildArray();
stExpCocoNode *pTriggerArray = pTriggersArray[i0].GetChildArray(pCocoLoader);
for (int i1 = 0; i1 < border; ++i1)
{
std::string key1 = pTriggerArray[i1].GetName(pCocoLoader);
const char *str1 = pTriggerArray[i1].GetValue();
const char *str1 = pTriggerArray[i1].GetValue(pCocoLoader);
if (key1.compare("actions") == 0)
{
rapidjson::Value actionsItem(rapidjson::kArrayType);
length = pTriggerArray[i1].GetChildNum();
stExpCocoNode *pActionsArray = pTriggerArray[i1].GetChildArray();
stExpCocoNode *pActionsArray = pTriggerArray[i1].GetChildArray(pCocoLoader);
for (int i2 = 0; i2 < length; ++i2)
{
rapidjson::Value action(rapidjson::kObjectType);
num = pActionsArray[i2].GetChildNum();
stExpCocoNode *pActionArray = pActionsArray[i2].GetChildArray();
stExpCocoNode *pActionArray = pActionsArray[i2].GetChildArray(pCocoLoader);
for (int i3 = 0; i3 < num; ++i3)
{
std::string key2 = pActionArray[i3].GetName(pCocoLoader);
const char *str2 = pActionArray[i3].GetValue();
const char *str2 = pActionArray[i3].GetValue(pCocoLoader);
if (key2.compare("classname") == 0)
{
if (str2 != NULL)
@ -243,16 +243,16 @@ bool TriggerMng::isEmpty(void) const
{
rapidjson::Value dataitems(rapidjson::kArrayType);
size = pActionArray[i3].GetChildNum();
stExpCocoNode *pDataItemsArray = pActionArray[i3].GetChildArray();
stExpCocoNode *pDataItemsArray = pActionArray[i3].GetChildArray(pCocoLoader);
for (int i4 = 0; i4 < size; ++i4)
{
rapidjson::Value dataitem(rapidjson::kObjectType);
extent = pDataItemsArray[i4].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i4].GetChildArray();
stExpCocoNode *pDataItemArray = pDataItemsArray[i4].GetChildArray(pCocoLoader);
for (int i5 = 0; i5 < extent; ++i5)
{
std::string key3 = pDataItemArray[i5].GetName(pCocoLoader);
const char *str3 = pDataItemArray[i5].GetValue();
const char *str3 = pDataItemArray[i5].GetValue(pCocoLoader);
if (key3.compare("key") == 0)
{
if (str3 != NULL)
@ -297,17 +297,17 @@ bool TriggerMng::isEmpty(void) const
rapidjson::Value condsItem(rapidjson::kArrayType);
length = pTriggerArray[i1].GetChildNum();
stExpCocoNode *pConditionsArray = pTriggerArray[i1].GetChildArray();
stExpCocoNode *pConditionsArray = pTriggerArray[i1].GetChildArray(pCocoLoader);
for (int i6 = 0; i6 < length; ++i6)
{
rapidjson::Value cond(rapidjson::kObjectType);
num = pConditionsArray[i6].GetChildNum();
stExpCocoNode *pConditionArray = pConditionsArray[i6].GetChildArray();
stExpCocoNode *pConditionArray = pConditionsArray[i6].GetChildArray(pCocoLoader);
for (int i7 = 0; i7 < num; ++i7)
{
std::string key4 = pConditionArray[i7].GetName(pCocoLoader);
const char *str4 = pConditionArray[i7].GetValue();
const char *str4 = pConditionArray[i7].GetValue(pCocoLoader);
if (key4.compare("classname") == 0)
{
if (str4 != NULL)
@ -319,16 +319,16 @@ bool TriggerMng::isEmpty(void) const
{
rapidjson::Value dataitems(rapidjson::kArrayType);
size = pConditionArray[i7].GetChildNum();
stExpCocoNode *pDataItemsArray = pConditionArray[i7].GetChildArray();
stExpCocoNode *pDataItemsArray = pConditionArray[i7].GetChildArray(pCocoLoader);
for (int i8 = 0; i8 < size; ++i8)
{
rapidjson::Value dataitem(rapidjson::kObjectType);
extent = pDataItemsArray[i8].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i8].GetChildArray();
stExpCocoNode *pDataItemArray = pDataItemsArray[i8].GetChildArray(pCocoLoader);
for (int i9 = 0; i9 < extent; ++i9)
{
std::string key5 = pDataItemArray[i9].GetName(pCocoLoader);
const char *str5 = pDataItemArray[i9].GetValue();
const char *str5 = pDataItemArray[i9].GetValue(pCocoLoader);
if (key5.compare("key") == 0)
{
if (str5 != NULL)
@ -373,13 +373,13 @@ bool TriggerMng::isEmpty(void) const
rapidjson::Value eventsItem(rapidjson::kArrayType);
length = pTriggerArray[i1].GetChildNum();
stExpCocoNode *pEventsArray = pTriggerArray[i1].GetChildArray();
stExpCocoNode *pEventsArray = pTriggerArray[i1].GetChildArray(pCocoLoader);
for (int i10 = 0; i10 < length; ++i10)
{
rapidjson::Value event(rapidjson::kObjectType);
stExpCocoNode *pEventArray = pEventsArray->GetChildArray();
stExpCocoNode *pEventArray = pEventsArray->GetChildArray(pCocoLoader);
std::string key6 = pEventArray[0].GetName(pCocoLoader);
const char *str6 = pEventArray[0].GetValue();
const char *str6 = pEventArray[0].GetValue(pCocoLoader);
if (key6.compare("id") == 0 && str6 != NULL)
{
event.AddMember("id", atoi(str6), allocator);

View File

@ -246,11 +246,11 @@ void TriggerObj::serialize(const rapidjson::Value &val)
int length = pCocoNode->GetChildNum();
int count = 0;
int num = 0;
stExpCocoNode *pTriggerObjArray = pCocoNode->GetChildArray();
stExpCocoNode *pTriggerObjArray = pCocoNode->GetChildArray(pCocoLoader);
for (int i0 = 0; i0 < length; ++i0)
{
std::string key = pTriggerObjArray[i0].GetName(pCocoLoader);
const char* str0 = pTriggerObjArray[i0].GetValue();
const char* str0 = pTriggerObjArray[i0].GetValue(pCocoLoader);
if (key.compare("id") == 0)
{
if (str0 != NULL)
@ -261,12 +261,12 @@ void TriggerObj::serialize(const rapidjson::Value &val)
else if (key.compare("conditions") == 0)
{
count = pTriggerObjArray[i0].GetChildNum();
stExpCocoNode *pConditionsArray = pTriggerObjArray[i0].GetChildArray();
stExpCocoNode *pConditionsArray = pTriggerObjArray[i0].GetChildArray(pCocoLoader);
for (int i1 = 0; i1 < count; ++i1)
{
num = pConditionsArray[i1].GetChildNum();
stExpCocoNode *pConditionArray = pConditionsArray[i1].GetChildArray();
const char *classname = pConditionArray[0].GetValue();
stExpCocoNode *pConditionArray = pConditionsArray[i1].GetChildArray(pCocoLoader);
const char *classname = pConditionArray[0].GetValue(pCocoLoader);
if (classname == nullptr)
{
continue;
@ -281,12 +281,12 @@ void TriggerObj::serialize(const rapidjson::Value &val)
else if (key.compare("actions") == 0)
{
count = pTriggerObjArray[i0].GetChildNum();
stExpCocoNode *pActionsArray = pTriggerObjArray[i0].GetChildArray();
stExpCocoNode *pActionsArray = pTriggerObjArray[i0].GetChildArray(pCocoLoader);
for (int i2 = 0; i2 < count; ++i2)
{
num = pActionsArray[i2].GetChildNum();
stExpCocoNode *pActionArray = pActionsArray[i2].GetChildArray();
const char *classname = pActionArray[0].GetValue();
stExpCocoNode *pActionArray = pActionsArray[i2].GetChildArray(pCocoLoader);
const char *classname = pActionArray[0].GetValue(pCocoLoader);
if (classname == nullptr)
{
continue;
@ -301,12 +301,12 @@ void TriggerObj::serialize(const rapidjson::Value &val)
else if (key.compare("events") == 0)
{
count = pTriggerObjArray[i0].GetChildNum();
stExpCocoNode *pEventsArray = pTriggerObjArray[i0].GetChildArray();
stExpCocoNode *pEventsArray = pTriggerObjArray[i0].GetChildArray(pCocoLoader);
for (int i3 = 0; i3 < count; ++i3)
{
num = pEventsArray[i3].GetChildNum();
stExpCocoNode *pEventArray = pEventsArray[i3].GetChildArray();
const char *str1 = pEventArray[0].GetValue();
stExpCocoNode *pEventArray = pEventsArray[i3].GetChildArray(pCocoLoader);
const char *str1 = pEventArray[0].GetValue(pCocoLoader);
if (str1 == nullptr)
{
continue;

View File

@ -63,7 +63,7 @@ namespace cocostudio
Button *button = static_cast<Button*>(widget);
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
this->beginSetBasicProperties(widget);
@ -72,7 +72,7 @@ namespace cocostudio
float scale9Width = 0.0f, scale9Height = 0.0f;
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
// CCLOG("Button: key = %s, value = %d", key.c_str(), i);
//read all basic properties of widget
@ -86,8 +86,8 @@ namespace cocostudio
}
else if (key == P_NormalData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -98,8 +98,8 @@ namespace cocostudio
}
else if (key == P_PressedData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -110,8 +110,8 @@ namespace cocostudio
}
else if (key == P_DisabledData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -216,23 +216,18 @@ namespace cocostudio
}
}
bool cr = DICTOOL->checkObjectExist_json(options, P_TextColorR);
bool cg = DICTOOL->checkObjectExist_json(options, P_TextColorG);
bool cb = DICTOOL->checkObjectExist_json(options, P_TextColorB);
int cri = cr?DICTOOL->getIntValue_json(options, P_TextColorR):255;
int cgi = cg?DICTOOL->getIntValue_json(options, P_TextColorG):255;
int cbi = cb?DICTOOL->getIntValue_json(options, P_TextColorB):255;
int cri = DICTOOL->getIntValue_json(options, P_TextColorR,255);
int cgi = DICTOOL->getIntValue_json(options, P_TextColorG,255);
int cbi = DICTOOL->getIntValue_json(options, P_TextColorB,255);
button->setTitleColor(Color3B(cri,cgi,cbi));
bool fs = DICTOOL->checkObjectExist_json(options, P_FontSize);
if (fs)
{
button->setTitleFontSize(DICTOOL->getIntValue_json(options, P_FontSize));
}
bool fn = DICTOOL->checkObjectExist_json(options, P_FontName);
if (fn)
{
button->setTitleFontName(DICTOOL->getStringValue_json(options, P_FontName));
}
button->setTitleFontSize(DICTOOL->getIntValue_json(options, P_FontSize,14));
button->setTitleFontName(DICTOOL->getStringValue_json(options, P_FontName,"微软雅黑"));
WidgetReader::setColorPropsFromJsonDictionary(widget, options);

View File

@ -43,11 +43,11 @@ namespace cocostudio
CheckBox *checkBox = static_cast<CheckBox*>(widget);
this->beginSetBasicProperties(widget);
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
// CCLOG("key = %s, index : %d", key.c_str(), i);
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
@ -56,8 +56,8 @@ namespace cocostudio
else if (key == P_BackGroundBoxData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -65,8 +65,8 @@ namespace cocostudio
checkBox->loadTextureBackGround(backgroundValue, imageFileNameType);
}else if(key == P_BackGroundBoxSelectedData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -74,8 +74,8 @@ namespace cocostudio
checkBox->loadTextureBackGroundSelected(backgroundValue, imageFileNameType);
}else if(key == P_FrontCrossData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -83,8 +83,8 @@ namespace cocostudio
checkBox->loadTextureFrontCross(backgroundValue, imageFileNameType);
}else if(key == P_BackGroundBoxDisabledData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -92,8 +92,8 @@ namespace cocostudio
checkBox->loadTextureBackGroundDisabled(backgroundValue, imageFileNameType);
}else if (key == P_FrontCrossDisabledData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);

View File

@ -50,11 +50,11 @@ namespace cocostudio
this->beginSetBasicProperties(widget);
float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f;
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
@ -65,8 +65,8 @@ namespace cocostudio
imageView->setScale9Enabled(valueToBool(value));
}
else if (key == P_FileNameData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -125,19 +125,16 @@ namespace cocostudio
if (scale9Enable)
{
bool sw = DICTOOL->checkObjectExist_json(options, P_Scale9Width);
bool sh = DICTOOL->checkObjectExist_json(options, P_Scale9Height);
if (sw && sh)
{
float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width);
float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height);
float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width,80.0f);
float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height,80.0f);
imageView->setSize(Size(swf, shf));
}
float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);
float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY);
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth);
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight);
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1.0f);
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1.0f);
imageView->setCapInsets(Rect(cx, cy, cw, ch));

View File

@ -61,7 +61,7 @@ namespace cocostudio
Layout* panel = static_cast<Layout*>(widget);
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
this->beginSetBasicProperties(widget);
int cr=0, cg = 0, cb = 0;
@ -74,7 +74,7 @@ namespace cocostudio
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
@ -120,9 +120,9 @@ namespace cocostudio
panel->setBackGroundColorType(Layout::BackGroundColorType(valueToInt(value)));
}else if (key == P_BackGroundImageData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
if (backGroundChildren) {
std::string resType = backGroundChildren[2].GetValue();;
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -194,25 +194,25 @@ namespace cocostudio
bool backGroundScale9Enable = DICTOOL->getBooleanValue_json(options, P_BackGroundScale9Enable);
panel->setBackGroundImageScale9Enabled(backGroundScale9Enable);
int cr = DICTOOL->getIntValue_json(options, P_BgColorR);
int cg = DICTOOL->getIntValue_json(options, P_BgColorG);
int cb = DICTOOL->getIntValue_json(options, P_BgColorB);
int cr = DICTOOL->getIntValue_json(options, P_BgColorR,150);
int cg = DICTOOL->getIntValue_json(options, P_BgColorG,150);
int cb = DICTOOL->getIntValue_json(options, P_BgColorB,100);
int scr = DICTOOL->getIntValue_json(options, P_BgStartColorR);
int scg = DICTOOL->getIntValue_json(options, P_BgStartColorG);
int scb = DICTOOL->getIntValue_json(options, P_BgStartColorB);
int scr = DICTOOL->getIntValue_json(options, P_BgStartColorR,255);
int scg = DICTOOL->getIntValue_json(options, P_BgStartColorG, 255);
int scb = DICTOOL->getIntValue_json(options, P_BgStartColorB, 255);
int ecr = DICTOOL->getIntValue_json(options, P_BgEndColorR);
int ecg = DICTOOL->getIntValue_json(options, P_BgEndColorG);
int ecb = DICTOOL->getIntValue_json(options, P_BgEndColorB);
int ecr = DICTOOL->getIntValue_json(options, P_BgEndColorR,150);
int ecg = DICTOOL->getIntValue_json(options, P_BgEndColorG,200);
int ecb = DICTOOL->getIntValue_json(options, P_BgEndColorB,255);
float bgcv1 = DICTOOL->getFloatValue_json(options, P_VectorX);
float bgcv2 = DICTOOL->getFloatValue_json(options, P_VectorY);
float bgcv2 = DICTOOL->getFloatValue_json(options, P_VectorY,-0.5);
panel->setBackGroundColorVector(Vec2(bgcv1, bgcv2));
int co = DICTOOL->getIntValue_json(options, P_BgColorOpacity);
int co = DICTOOL->getIntValue_json(options, P_BgColorOpacity,100);
int colorType = DICTOOL->getIntValue_json(options, P_ColorType);
int colorType = DICTOOL->getIntValue_json(options, P_ColorType,1);
panel->setBackGroundColorType(Layout::BackGroundColorType(colorType));
panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb));
panel->setBackGroundColor(Color3B(cr, cg, cb));
@ -229,8 +229,8 @@ namespace cocostudio
{
float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);
float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY);
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth);
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight);
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1);
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1);
panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch));
}

View File

@ -41,11 +41,11 @@ namespace cocostudio
ListView* listView = static_cast<ListView*>(widget);
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
if (key == P_Direction) {
listView->setDirection((ScrollView::Direction)valueToInt(value));
@ -66,10 +66,10 @@ namespace cocostudio
ListView* listView = static_cast<ListView*>(widget);
int direction = DICTOOL->getFloatValue_json(options, P_Direction);
int direction = DICTOOL->getFloatValue_json(options, P_Direction,2);
listView->setDirection((ScrollView::Direction)direction);
ListView::Gravity gravity = (ListView::Gravity)DICTOOL->getIntValue_json(options, P_Gravity);
ListView::Gravity gravity = (ListView::Gravity)DICTOOL->getIntValue_json(options, P_Gravity,3);
listView->setGravity(gravity);
float itemMargin = DICTOOL->getFloatValue_json(options, P_ItemMargin);

View File

@ -51,11 +51,11 @@ namespace cocostudio
float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f;
int percent = loadingBar->getPercent();
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
@ -67,8 +67,8 @@ namespace cocostudio
}
else if (key == P_TextureData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -117,23 +117,25 @@ namespace cocostudio
bool scale9Enable = DICTOOL->getBooleanValue_json(options, P_Scale9Enable);
loadingBar->setScale9Enabled(scale9Enable);
if (scale9Enable)
{
float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);
float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY);
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth);
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight);
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1);
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1);
if (scale9Enable) {
loadingBar->setCapInsets(Rect(cx, cy, cw, ch));
}
float width = DICTOOL->getFloatValue_json(options, P_Width);
float height = DICTOOL->getFloatValue_json(options, P_Height);
loadingBar->setSize(Size(width, height));
}
/**/
loadingBar->setDirection(LoadingBar::Direction(DICTOOL->getIntValue_json(options, P_Direction)));
loadingBar->setPercent(DICTOOL->getIntValue_json(options, P_Percent));
loadingBar->setPercent(DICTOOL->getIntValue_json(options, P_Percent,100));
WidgetReader::setColorPropsFromJsonDictionary(widget, options);

View File

@ -44,12 +44,12 @@ namespace cocostudio
ScrollView* scrollView = static_cast<ScrollView*>(widget);
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
float innerWidth;
float innerHeight;
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
if (key == P_InnerWidth) {
innerWidth = valueToFloat(value);
}
@ -72,10 +72,10 @@ namespace cocostudio
ScrollView* scrollView = static_cast<ScrollView*>(widget);
float innerWidth = DICTOOL->getFloatValue_json(options, P_InnerWidth);
float innerHeight = DICTOOL->getFloatValue_json(options, P_InnerHeight);
float innerWidth = DICTOOL->getFloatValue_json(options, P_InnerWidth,200);
float innerHeight = DICTOOL->getFloatValue_json(options, P_InnerHeight,200);
scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
int direction = DICTOOL->getFloatValue_json(options, P_Direction);
int direction = DICTOOL->getFloatValue_json(options, P_Direction,1);
scrollView->setDirection((ScrollView::Direction)direction);
scrollView->setBounceEnabled(DICTOOL->getBooleanValue_json(options, P_BounceEnable));

View File

@ -51,11 +51,11 @@ namespace cocostudio
float barLength = 0.0f;
int percent = slider->getPercent();
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
@ -69,8 +69,8 @@ namespace cocostudio
else if(key == P_Percent){
percent = valueToInt(value);
}else if(key == P_BarFileNameData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -81,8 +81,8 @@ namespace cocostudio
}else if(key == P_Length){
barLength = valueToFloat(value);
}else if(key == P_BallNormalData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -91,8 +91,8 @@ namespace cocostudio
slider->loadSlidBallTextureNormal(backgroundValue, imageFileNameType);
}else if(key == P_BallPressedData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -101,8 +101,8 @@ namespace cocostudio
slider->loadSlidBallTexturePressed(backgroundValue, imageFileNameType);
}else if(key == P_BallDisabledData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -111,8 +111,8 @@ namespace cocostudio
slider->loadSlidBallTextureDisabled(backgroundValue, imageFileNameType);
}else if(key == P_ProgressBarData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -145,25 +145,24 @@ namespace cocostudio
slider->setPercent(DICTOOL->getIntValue_json(options, P_Percent));
bool bt = DICTOOL->checkObjectExist_json(options, P_BarFileName);
float barLength = DICTOOL->getFloatValue_json(options, P_Length);
if (bt)
{
// bool bt = DICTOOL->checkObjectExist_json(options, P_BarFileName);
float barLength = DICTOOL->getFloatValue_json(options, P_Length,290);
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, P_BarFileNameData);
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, P_ResourceType);
std::string imageFileName = this->getResourcePath(imageFileNameDic, P_Path, (Widget::TextureResType)imageFileNameType);
slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
if (barTextureScale9Enable)
{
slider->setContentSize(Size(barLength, slider->getContentSize().height));
}
}
//loading normal slider ball texture
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, P_BallNormalData);
int normalType = DICTOOL->getIntValue_json(normalDic, P_ResourceType);
std::string imageFileName = this->getResourcePath(normalDic, P_Path, (Widget::TextureResType)normalType);
imageFileName = this->getResourcePath(normalDic, P_Path, (Widget::TextureResType)normalType);
slider->loadSlidBallTextureNormal(imageFileName, (Widget::TextureResType)normalType);

View File

@ -48,7 +48,7 @@ namespace cocostudio
TextAtlas* labelAtlas = static_cast<TextAtlas*>(widget);
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
Widget::TextureResType type;
std::string charMapFileName;
std::string stringValue;
@ -57,7 +57,7 @@ namespace cocostudio
float itemHeight;
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
@ -68,8 +68,8 @@ namespace cocostudio
stringValue = value;
}
else if(key == P_CharMapFileData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -101,13 +101,12 @@ namespace cocostudio
std::string jsonPath = GUIReader::getInstance()->getFilePath();
TextAtlas* labelAtlas = static_cast<TextAtlas*>(widget);
bool sv = DICTOOL->checkObjectExist_json(options, P_StringValue);
bool cmf = DICTOOL->checkObjectExist_json(options, P_CharMapFile);
bool iw = DICTOOL->checkObjectExist_json(options, P_ItemWidth);
bool ih = DICTOOL->checkObjectExist_json(options, P_ItemHeight);
bool scm = DICTOOL->checkObjectExist_json(options, P_StartCharMap);
if (sv && cmf && iw && ih && scm)
{
// bool sv = DICTOOL->checkObjectExist_json(options, P_StringValue);
// bool cmf = DICTOOL->checkObjectExist_json(options, P_CharMapFile);
// bool iw = DICTOOL->checkObjectExist_json(options, P_ItemWidth);
// bool ih = DICTOOL->checkObjectExist_json(options, P_ItemHeight);
// bool scm = DICTOOL->checkObjectExist_json(options, P_StartCharMap);
const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, P_CharMapFileData);
int cmfType = DICTOOL->getIntValue_json(cmftDic, P_ResourceType);
switch (cmfType)
@ -117,7 +116,11 @@ namespace cocostudio
std::string tp_c = jsonPath;
const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, P_Path);
const char* cmf_tp = tp_c.append(cmfPath).c_str();
labelAtlas->setProperty(DICTOOL->getStringValue_json(options, P_StringValue),cmf_tp,DICTOOL->getIntValue_json(options, P_ItemWidth),DICTOOL->getIntValue_json(options,P_ItemHeight), DICTOOL->getStringValue_json(options, P_StartCharMap));
labelAtlas->setProperty(DICTOOL->getStringValue_json(options, P_StringValue,"12345678"),
cmf_tp,
DICTOOL->getIntValue_json(options, P_ItemWidth,24),
DICTOOL->getIntValue_json(options,P_ItemHeight,32),
DICTOOL->getStringValue_json(options, P_StartCharMap));
break;
}
case 1:
@ -126,7 +129,7 @@ namespace cocostudio
default:
break;
}
}
WidgetReader::setColorPropsFromJsonDictionary(widget, options);

View File

@ -42,19 +42,19 @@ namespace cocostudio
TextBMFont* labelBMFont = static_cast<TextBMFont*>(widget);
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
//read all color related properties of widget
CC_COLOR_PROPERTY_BINARY_READER
else if(key == P_FileNameData){
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
std::string resType = backGroundChildren[2].GetValue();;
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
@ -98,7 +98,7 @@ namespace cocostudio
break;
}
const char* text = DICTOOL->getStringValue_json(options, P_Text);
const char* text = DICTOOL->getStringValue_json(options, P_Text,"Text Label");
labelBMFont->setString(text);

View File

@ -49,11 +49,11 @@ namespace cocostudio
TextField* textField = static_cast<TextField*>(widget);
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
@ -94,19 +94,15 @@ namespace cocostudio
bool ph = DICTOOL->checkObjectExist_json(options, P_PlaceHolder);
if (ph)
{
textField->setPlaceHolder(DICTOOL->getStringValue_json(options, P_PlaceHolder));
}
textField->setText(DICTOOL->getStringValue_json(options, P_Text));
bool fs = DICTOOL->checkObjectExist_json(options, P_FontSize);
if (fs)
{
textField->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize));
}
bool fn = DICTOOL->checkObjectExist_json(options, P_FontName);
if (fn)
{
textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName));
textField->setPlaceHolder(DICTOOL->getStringValue_json(options, P_PlaceHolder,"input words here"));
}
textField->setText(DICTOOL->getStringValue_json(options, P_Text,"text Field"));
textField->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20));
textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName,"微软雅黑"));
bool tsw = DICTOOL->checkObjectExist_json(options, P_TouchSizeWidth);
bool tsh = DICTOOL->checkObjectExist_json(options, P_TouchSizeHeight);
if (tsw && tsh)
@ -125,14 +121,14 @@ namespace cocostudio
if (maxLengthEnable)
{
int maxLength = DICTOOL->getIntValue_json(options, P_MaxLength);
int maxLength = DICTOOL->getIntValue_json(options, P_MaxLength,10);
textField->setMaxLength(maxLength);
}
bool passwordEnable = DICTOOL->getBooleanValue_json(options, P_PasswordEnable);
textField->setPasswordEnabled(passwordEnable);
if (passwordEnable)
{
textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, P_PasswordStyleText));
textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, P_PasswordStyleText,"*"));
}

View File

@ -45,7 +45,7 @@ namespace cocostudio
{
this->beginSetBasicProperties(widget);
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
Text* label = static_cast<Text*>(widget);
@ -54,7 +54,7 @@ namespace cocostudio
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
//read all color related properties of widget
@ -95,20 +95,15 @@ namespace cocostudio
Text* label = static_cast<Text*>(widget);
bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, P_TouchScaleEnable);
label->setTouchScaleChangeEnabled(touchScaleChangeAble);
const char* text = DICTOOL->getStringValue_json(options, P_Text);
const char* text = DICTOOL->getStringValue_json(options, P_Text,"Text Label");
label->setString(text);
bool fs = DICTOOL->checkObjectExist_json(options, P_FontSize);
if (fs)
{
label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize));
}
bool fn = DICTOOL->checkObjectExist_json(options, P_FontName);
if (fn)
{
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName);
label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20));
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑");
std::string fontFilePath = jsonPath.append(fontName);
label->setFontName(fontFilePath);
}
bool aw = DICTOOL->checkObjectExist_json(options, P_AreaWidth);
bool ah = DICTOOL->checkObjectExist_json(options, P_AreaHeight);
if (aw && ah)

View File

@ -113,11 +113,9 @@ namespace cocostudio
void WidgetReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
{
bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, P_IgnoreSize);
if (ignoreSizeExsit)
{
widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize));
}
widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize,false));
widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, P_SizeType));
widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, P_PositionType));
@ -151,21 +149,15 @@ namespace cocostudio
float x = DICTOOL->getFloatValue_json(options, P_X);
float y = DICTOOL->getFloatValue_json(options, P_Y);
widget->setPosition(Vec2(x,y));
bool sx = DICTOOL->checkObjectExist_json(options, P_ScaleX);
if (sx)
{
widget->setScaleX(DICTOOL->getFloatValue_json(options, P_ScaleX));
}
bool sy = DICTOOL->checkObjectExist_json(options, P_ScaleY);
if (sy)
{
widget->setScaleY(DICTOOL->getFloatValue_json(options, P_ScaleY));
}
bool rt = DICTOOL->checkObjectExist_json(options, P_Rotation);
if (rt)
{
widget->setRotation(DICTOOL->getFloatValue_json(options, P_Rotation));
}
widget->setScaleX(DICTOOL->getFloatValue_json(options, P_ScaleX,1.0));
widget->setScaleY(DICTOOL->getFloatValue_json(options, P_ScaleY,1.0));
widget->setRotation(DICTOOL->getFloatValue_json(options, P_Rotation,0));
bool vb = DICTOOL->checkObjectExist_json(options, P_Visbile);
if (vb)
{
@ -295,8 +287,8 @@ namespace cocostudio
std::string WidgetReader::getResourcePath(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::ui::Widget::TextureResType texType)
{
stExpCocoNode *backGroundChildren = cocoNode->GetChildArray();
std::string backgroundValue = backGroundChildren[0].GetValue();
stExpCocoNode *backGroundChildren = cocoNode->GetChildArray(cocoLoader);
std::string backgroundValue = backGroundChildren[0].GetValue(cocoLoader);
if (backgroundValue.size() < 3) {
return "";
@ -346,13 +338,13 @@ namespace cocostudio
void WidgetReader::setPropsFromBinary(cocos2d::ui::Widget *widget, cocostudio::CocoLoader *cocoLoader, cocostudio::stExpCocoNode *cocoNode)
{
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
this->beginSetBasicProperties(widget);
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(cocoLoader);
std::string value = stChildArray[i].GetValue();
std::string value = stChildArray[i].GetValue(cocoLoader);
CC_BASIC_PROPERTY_BINARY_READER
}

View File

@ -176,14 +176,14 @@ namespace cocostudio
}else if(key == P_ZOrder){ \
widget->setZOrder(valueToInt(value)); \
}else if(key == P_LayoutParameter){ \
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray(); \
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray(cocoLoader); \
ui::LinearLayoutParameter *linearParameter = ui::LinearLayoutParameter::create(); \
ui::RelativeLayoutParameter *relativeParameter = ui::RelativeLayoutParameter::create(); \
ui::Margin mg; \
int paramType = -1; \
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) { \
std::string innerKey = layoutCocosNode[j].GetName(cocoLoader); \
std::string innerValue = layoutCocosNode[j].GetValue(); \
std::string innerValue = layoutCocosNode[j].GetValue(cocoLoader); \
if (innerKey == P_Type) { \
paramType = valueToInt(innerValue); \
}else if(innerKey == P_Gravity){ \

View File

@ -188,7 +188,7 @@
<Optimization>Disabled</Optimization>
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot)external\win32-specific\zlib\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>

View File

@ -623,7 +623,6 @@ bool TextField::isPasswordEnabled()const
void TextField::setPasswordStyleText(const char *styleText)
{
_textFieldRenderer->setPasswordStyleText(styleText);
_passwordStyleText = styleText;
setText(getStringValue());

View File

@ -69,15 +69,15 @@ void PlayMusic::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExp
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -169,15 +169,15 @@ void TMoveTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -291,15 +291,15 @@ void TMoveBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -404,15 +404,15 @@ void TRotateTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExp
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -517,15 +517,15 @@ void TRotateBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExp
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -627,15 +627,15 @@ void TScaleTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpC
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -751,15 +751,15 @@ void TScaleBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpC
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -869,15 +869,15 @@ void TSkewTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -992,15 +992,15 @@ void TSkewBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -1106,15 +1106,15 @@ void TriggerState::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::st
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "ID")
{
if (str != NULL)
@ -1195,15 +1195,15 @@ void ArmaturePlayAction::serialize(cocostudio::CocoLoader *pCocoLoader, cocostud
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)

View File

@ -51,15 +51,15 @@ void TimeElapsed::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stE
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "TotalTime")
{
if (str != NULL)
@ -151,15 +151,15 @@ void ArmatureActionState::serialize(cocostudio::CocoLoader *pCocoLoader, cocostu
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -279,15 +279,15 @@ void NodeInRect::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stEx
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)
@ -381,15 +381,15 @@ void NodeVisible::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stE
{
int length = pCocoNode->GetChildNum();
int count = 0;
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
std::string key;
const char *str = NULL;
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
key = pDataItemArray[0].GetValue();
str = pDataItemArray[1].GetValue();
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
if (key == "Tag")
{
if (str != NULL)

@ -1 +1 @@
Subproject commit 2173b0b479e0e7be62df9ded754b20e75e74b0f2
Subproject commit 6b28e948482ca7ed44c31daf3fef2e42ad6b59fb