cleanup reader code

This commit is contained in:
andyque 2014-06-19 15:16:56 +08:00
parent 515de9eda5
commit a26ef87783
12 changed files with 162 additions and 1145 deletions

View File

@ -55,112 +55,12 @@ namespace cocostudio
std::string value = stChildArray[i].GetValue();
// CCLOG("Button: key = %s, value = %d", key.c_str(), i);
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
_sizePercentX = valueToFloat(value);
}else if(key == "sizePercentY"){
_sizePercentY = valueToFloat(value);
}else if(key == "positionPercentX"){
_positionPercentX = valueToFloat(value);
}else if(key == "positionPercentY"){
_positionPercentY = valueToFloat(value);
}
else if(key == "adaptScreen"){
_isAdaptScreen = valueToBool(value);
}
else if (key == "width"){
_width = valueToFloat(value);
}else if(key == "height"){
_height = valueToFloat(value);
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
_position.x = valueToFloat(value);
}else if(key == "y"){
_position.y = valueToFloat(value);
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;
int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
//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 == "opacity") {
_opacity = valueToInt(value);
}else if(key == "colorR"){
_color.r = valueToInt(value);
}else if(key == "colorG"){
_color.g = valueToInt(value);
}else if(key == "colorB")
{
_color.b = valueToInt(value);
}else if(key == "flipX"){
widget->setFlippedX(valueToBool(value));
}else if(key == "flipY"){
widget->setFlippedY(valueToBool(value));
}else if(key == "anchorPointX"){
else if(key == "anchorPointX"){
_originalAnchorPoint.x = valueToFloat(value);
}else if(key == "anchorPointY"){
_originalAnchorPoint.y = valueToFloat(value);

View File

@ -43,112 +43,12 @@ namespace cocostudio
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue();
// CCLOG("key = %s, index : %d", key.c_str(), i);
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
_sizePercentX = valueToFloat(value);
}else if(key == "sizePercentY"){
_sizePercentY = valueToFloat(value);
}else if(key == "positionPercentX"){
_positionPercentX = valueToFloat(value);
}else if(key == "positionPercentY"){
_positionPercentY = valueToFloat(value);
}
else if(key == "adaptScreen"){
_isAdaptScreen = valueToBool(value);
}
else if (key == "width"){
_width = valueToFloat(value);
}else if(key == "height"){
_height = valueToFloat(value);
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
_position.x = valueToFloat(value);
}else if(key == "y"){
_position.y = valueToFloat(value);
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;
int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
//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 == "opacity") {
_opacity = valueToInt(value);
}else if(key == "colorR"){
_color.r = valueToInt(value);
}else if(key == "colorG"){
_color.g = valueToInt(value);
}else if(key == "colorB")
{
_color.b = valueToInt(value);
}else if(key == "flipX"){
widget->setFlippedX(valueToBool(value));
}else if(key == "flipY"){
widget->setFlippedY(valueToBool(value));
}else if(key == "anchorPointX"){
else if(key == "anchorPointX"){
_originalAnchorPoint.x = valueToFloat(value);
}else if(key == "anchorPointY"){
_originalAnchorPoint.y = valueToFloat(value);

View File

@ -45,114 +45,13 @@ namespace cocostudio
for (int i = 0; i < pCocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue();
// CCLOG("ImageView: key = %s, value = %d", key.c_str(), i);
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
_sizePercentX = valueToFloat(value);
}else if(key == "sizePercentY"){
_sizePercentY = valueToFloat(value);
}else if(key == "positionPercentX"){
_positionPercentX = valueToFloat(value);
}else if(key == "positionPercentY"){
_positionPercentY = valueToFloat(value);
}
else if(key == "adaptScreen"){
_isAdaptScreen = valueToBool(value);
}
else if (key == "width"){
_width = valueToFloat(value);
}else if(key == "height"){
_height = valueToFloat(value);
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
_position.x = valueToFloat(value);
}else if(key == "y"){
_position.y = valueToFloat(value);
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;
int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
//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 == "opacity") {
_opacity = valueToInt(value);
}else if(key == "colorR"){
_color.r = valueToInt(value);
}else if(key == "colorG"){
_color.g = valueToInt(value);
}else if(key == "colorB")
{
_color.b = valueToInt(value);
}else if(key == "flipX"){
widget->setFlippedX(valueToBool(value));
}else if(key == "flipY"){
widget->setFlippedY(valueToBool(value));
}else if(key == "anchorPointX"){
else if(key == "anchorPointX"){
_originalAnchorPoint.x = valueToFloat(value);
}else if(key == "anchorPointY"){
_originalAnchorPoint.y = valueToFloat(value);

View File

@ -54,113 +54,13 @@ namespace cocostudio
for (int i = 0; i < pCocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue();
// CCLOG("Layout: key = %s, value = %d", key.c_str(), i);
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
_sizePercentX = valueToFloat(value);
}else if(key == "sizePercentY"){
_sizePercentY = valueToFloat(value);
}else if(key == "positionPercentX"){
_positionPercentX = valueToFloat(value);
}else if(key == "positionPercentY"){
_positionPercentY = valueToFloat(value);
}
else if(key == "adaptScreen"){
_isAdaptScreen = valueToBool(value);
}
else if (key == "width"){
_width = valueToFloat(value);
}else if(key == "height"){
_height = valueToFloat(value);
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
_position.x = valueToFloat(value);
}else if(key == "y"){
_position.y = valueToFloat(value);
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;
int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
else if (key == "opacity") {
_opacity = valueToInt(value);
}else if(key == "colorR"){
_color.r = valueToInt(value);
}else if(key == "colorG"){
_color.g = valueToInt(value);
}else if(key == "colorB")
{
_color.b = valueToInt(value);
}else if(key == "flipX"){
widget->setFlippedX(valueToBool(value));
}else if(key == "flipY"){
widget->setFlippedY(valueToBool(value));
}else if(key == "anchorPointX"){
//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 == "anchorPointX"){
_originalAnchorPoint.x = valueToFloat(value);
}else if(key == "anchorPointY"){
_originalAnchorPoint.y = valueToFloat(value);

View File

@ -48,112 +48,12 @@ namespace cocostudio
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue();
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
_sizePercentX = valueToFloat(value);
}else if(key == "sizePercentY"){
_sizePercentY = valueToFloat(value);
}else if(key == "positionPercentX"){
_positionPercentX = valueToFloat(value);
}else if(key == "positionPercentY"){
_positionPercentY = valueToFloat(value);
}
else if(key == "adaptScreen"){
_isAdaptScreen = valueToBool(value);
}
else if (key == "width"){
_width = valueToFloat(value);
}else if(key == "height"){
_height = valueToFloat(value);
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
_position.x = valueToFloat(value);
}else if(key == "y"){
_position.y = valueToFloat(value);
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;
int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
//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 == "opacity") {
_opacity = valueToInt(value);
}else if(key == "colorR"){
_color.r = valueToInt(value);
}else if(key == "colorG"){
_color.g = valueToInt(value);
}else if(key == "colorB")
{
_color.b = valueToInt(value);
}else if(key == "flipX"){
widget->setFlippedX(valueToBool(value));
}else if(key == "flipY"){
widget->setFlippedY(valueToBool(value));
}else if(key == "anchorPointX"){
else if(key == "anchorPointX"){
_originalAnchorPoint.x = valueToFloat(value);
}else if(key == "anchorPointY"){
_originalAnchorPoint.y = valueToFloat(value);

View File

@ -46,112 +46,12 @@ namespace cocostudio
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue();
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
_sizePercentX = valueToFloat(value);
}else if(key == "sizePercentY"){
_sizePercentY = valueToFloat(value);
}else if(key == "positionPercentX"){
_positionPercentX = valueToFloat(value);
}else if(key == "positionPercentY"){
_positionPercentY = valueToFloat(value);
}
else if(key == "adaptScreen"){
_isAdaptScreen = valueToBool(value);
}
else if (key == "width"){
_width = valueToFloat(value);
}else if(key == "height"){
_height = valueToFloat(value);
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
_position.x = valueToFloat(value);
}else if(key == "y"){
_position.y = valueToFloat(value);
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;
int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
//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 == "opacity") {
_opacity = valueToInt(value);
}else if(key == "colorR"){
_color.r = valueToInt(value);
}else if(key == "colorG"){
_color.g = valueToInt(value);
}else if(key == "colorB")
{
_color.b = valueToInt(value);
}else if(key == "flipX"){
widget->setFlippedX(valueToBool(value));
}else if(key == "flipY"){
widget->setFlippedY(valueToBool(value));
}else if(key == "anchorPointX"){
else if(key == "anchorPointX"){
_originalAnchorPoint.x = valueToFloat(value);
}else if(key == "anchorPointY"){
_originalAnchorPoint.y = valueToFloat(value);

View File

@ -49,114 +49,13 @@ namespace cocostudio
for (int i = 0; i < pCocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue();
// CCLOG("LabelAtlas: key = %s, value = %s", key.c_str(), value.c_str());
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
_sizePercentX = valueToFloat(value);
}else if(key == "sizePercentY"){
_sizePercentY = valueToFloat(value);
}else if(key == "positionPercentX"){
_positionPercentX = valueToFloat(value);
}else if(key == "positionPercentY"){
_positionPercentY = valueToFloat(value);
}
else if(key == "adaptScreen"){
_isAdaptScreen = valueToBool(value);
}
else if (key == "width"){
_width = valueToFloat(value);
}else if(key == "height"){
_height = valueToFloat(value);
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
_position.x = valueToFloat(value);
}else if(key == "y"){
_position.y = valueToFloat(value);
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;
int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
else if (key == "opacity") {
_opacity = valueToInt(value);
}else if(key == "colorR"){
_color.r = valueToInt(value);
}else if(key == "colorG"){
_color.g = valueToInt(value);
}else if(key == "colorB")
{
_color.b = valueToInt(value);
}else if(key == "flipX"){
widget->setFlippedX(valueToBool(value));
}else if(key == "flipY"){
widget->setFlippedY(valueToBool(value));
}else if(key == "anchorPointX"){
//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 == "anchorPointX"){
_originalAnchorPoint.x = valueToFloat(value);
}else if(key == "anchorPointY"){
_originalAnchorPoint.y = valueToFloat(value);

View File

@ -44,113 +44,12 @@ namespace cocostudio
for (int i = 0; i < pCocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue();
//read all basic properties of widget
CC_BASIC_PROPERTY_BINARY_READER
//read all color related properties of widget
CC_COLOR_PROPERTY_BINARY_READER
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
_sizePercentX = valueToFloat(value);
}else if(key == "sizePercentY"){
_sizePercentY = valueToFloat(value);
}else if(key == "positionPercentX"){
_positionPercentX = valueToFloat(value);
}else if(key == "positionPercentY"){
_positionPercentY = valueToFloat(value);
}
else if(key == "adaptScreen"){
_isAdaptScreen = valueToBool(value);
}
else if (key == "width"){
_width = valueToFloat(value);
}else if(key == "height"){
_height = valueToFloat(value);
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
_position.x = valueToFloat(value);
}else if(key == "y"){
_position.y = valueToFloat(value);
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;
int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
else if (key == "opacity") {
_opacity = valueToInt(value);
}else if(key == "colorR"){
_color.r = valueToInt(value);
}else if(key == "colorG"){
_color.g = valueToInt(value);
}else if(key == "colorB")
{
_color.b = valueToInt(value);
}else if(key == "flipX"){
widget->setFlippedX(valueToBool(value));
}else if(key == "flipY"){
widget->setFlippedY(valueToBool(value));
}else if(key == "anchorPointX"){
else if(key == "anchorPointX"){
_originalAnchorPoint.x = valueToFloat(value);
}else if(key == "anchorPointY"){
_originalAnchorPoint.y = valueToFloat(value);

View File

@ -44,112 +44,12 @@ namespace cocostudio
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue();
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
_sizePercentX = valueToFloat(value);
}else if(key == "sizePercentY"){
_sizePercentY = valueToFloat(value);
}else if(key == "positionPercentX"){
_positionPercentX = valueToFloat(value);
}else if(key == "positionPercentY"){
_positionPercentY = valueToFloat(value);
}
else if(key == "adaptScreen"){
_isAdaptScreen = valueToBool(value);
}
else if (key == "width"){
_width = valueToFloat(value);
}else if(key == "height"){
_height = valueToFloat(value);
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
_position.x = valueToFloat(value);
}else if(key == "y"){
_position.y = valueToFloat(value);
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;
int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
//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 == "opacity") {
_opacity = valueToInt(value);
}else if(key == "colorR"){
_color.r = valueToInt(value);
}else if(key == "colorG"){
_color.g = valueToInt(value);
}else if(key == "colorB")
{
_color.b = valueToInt(value);
}else if(key == "flipX"){
widget->setFlippedX(valueToBool(value));
}else if(key == "flipY"){
widget->setFlippedY(valueToBool(value));
}else if(key == "anchorPointX"){
else if(key == "anchorPointX"){
_originalAnchorPoint.x = valueToFloat(value);
}else if(key == "anchorPointY"){
_originalAnchorPoint.y = valueToFloat(value);

View File

@ -44,114 +44,12 @@ namespace cocostudio
for (int i = 0; i < pCocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue();
// CCLOG("Text: key = %s, value = %s", key.c_str(), value.c_str());
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
_sizePercentX = valueToFloat(value);
}else if(key == "sizePercentY"){
_sizePercentY = valueToFloat(value);
}else if(key == "positionPercentX"){
_positionPercentX = valueToFloat(value);
}else if(key == "positionPercentY"){
_positionPercentY = valueToFloat(value);
}
else if(key == "adaptScreen"){
_isAdaptScreen = valueToBool(value);
}
else if (key == "width"){
_width = valueToFloat(value);
}else if(key == "height"){
_height = valueToFloat(value);
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
_position.x = valueToFloat(value);
}else if(key == "y"){
_position.y = valueToFloat(value);
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;
int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
//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 == "opacity") {
_opacity = valueToInt(value);
}else if(key == "colorR"){
_color.r = valueToInt(value);
}else if(key == "colorG"){
_color.g = valueToInt(value);
}else if(key == "colorB")
{
_color.b = valueToInt(value);
}else if(key == "flipX"){
widget->setFlippedX(valueToBool(value));
}else if(key == "flipY"){
widget->setFlippedY(valueToBool(value));
}else if(key == "anchorPointX"){
else if(key == "anchorPointX"){
_originalAnchorPoint.x = valueToFloat(value);
}else if(key == "anchorPointY"){
_originalAnchorPoint.y = valueToFloat(value);

View File

@ -341,100 +341,16 @@ namespace cocostudio
{
stExpCocoNode *stChildArray = pCocoNode->GetChildArray();
this->beginSetBasicProperties(widget);
for (int i = 0; i < pCocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue();
if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
widget->setSizeType((Widget::SizeType)valueToInt(value));
}else if(key == "positionType"){
widget->setPositionType((Widget::PositionType)valueToInt(value));
}else if(key == "sizePercentX"){
widget->setSizePercent(Vec2(valueToFloat(value), widget->getSizePercent().y));
}else if(key == "sizePercentY"){
widget->setSizePercent(Vec2(widget->getSizePercent().x, valueToFloat(value)));
}else if(key == "positionPercentX"){
widget->setPositionPercent(Vec2(valueToFloat(value), widget->getPositionPercent().y));
}else if(key == "positionPercentY"){
widget->setPositionPercent(Vec2(widget->getPositionPercent().x, valueToFloat(value)));
}else if (key == "width"){
widget->setSize(Size(valueToFloat(value), widget->getSize().height));
}else if(key == "height"){
widget->setSize(Size(widget->getSize().width, valueToFloat(value)));
}else if(key == "tag"){
widget->setTag(valueToInt(value));
}else if(key == "actiontag"){
widget->setActionTag(valueToInt(value));
}else if(key == "touchAble"){
widget->setTouchEnabled(valueToBool(value));
}else if(key == "name"){
std::string widgetName = value.empty() ? "default" : value;
widget->setName(widgetName);
}else if(key == "x"){
widget->setPosition(Vec2(valueToFloat(value), widget->getPosition().y));
}else if(key == "y"){
widget->setPosition(Vec2(widget->getPosition().x, valueToFloat(value)));
}else if(key == "scaleX"){
widget->setScaleX(valueToFloat(value));
}else if(key == "scaleY"){
widget->setScaleY(valueToFloat(value));
}else if(key == "rotation"){
widget->setRotation(valueToFloat(value));
}else if(key == "visible"){
widget->setVisible(valueToBool(value));
}else if(key == "ZOrder"){
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray();
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(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue();
if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue));
}else if(innerKey == "relativeName"){
relativeParameter->setRelativeName(innerValue);
}else if(innerKey == "relativeToName"){
relativeParameter->setRelativeToWidgetName(innerValue);
}else if(innerKey == "align"){
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue));
}else if(innerKey == "marginLeft"){
mg.left = valueToFloat(innerValue);
}else if(innerKey == "marginTop"){
mg.top = valueToFloat(innerValue);
}else if(innerKey == "marginRight"){
mg.right = valueToFloat(innerValue);
}else if(innerKey == "marginDown"){
mg.bottom = valueToFloat(innerValue);
}
}
linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);
switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
break;
case 2:
widget->setLayoutParameter(relativeParameter);
default:
break;
}
}
CC_BASIC_PROPERTY_BINARY_READER
}
this->endSetBasicProperties(widget);
}
}

View File

@ -126,6 +126,112 @@ namespace cocostudio
extern const char* P_ColorB;
extern const char* P_FlipX;
extern const char* P_FlipY;
#define CC_BASIC_PROPERTY_BINARY_READER \
if (key == P_IgnoreSize) { \
widget->ignoreContentAdaptWithSize(valueToBool(value)); \
}else if(key == P_SizeType){ \
widget->setSizeType((Widget::SizeType)valueToInt(value)); \
}else if(key == P_PositionType){ \
widget->setPositionType((Widget::PositionType)valueToInt(value)); \
}else if(key == P_SizePercentX){ \
_sizePercentX = valueToFloat(value); \
}else if(key == P_SizePercentY){ \
_sizePercentY = valueToFloat(value); \
}else if(key == P_PositionPercentX){ \
_positionPercentX = valueToFloat(value); \
}else if(key == P_PositionPercentY){ \
_positionPercentY = valueToFloat(value); \
} \
else if(key == P_AdaptScreen){ \
_isAdaptScreen = valueToBool(value); \
}else if (key == P_Width){ \
_width = valueToFloat(value); \
}else if(key == P_Height){ \
_height = valueToFloat(value); \
}else if(key == P_Tag){ \
widget->setTag(valueToInt(value)); \
}else if(key == P_ActionTag){ \
widget->setActionTag(valueToInt(value)); \
}else if(key == P_TouchAble){ \
widget->setTouchEnabled(valueToBool(value)); \
}else if(key == P_Name){ \
std::string widgetName = value.empty() ? "default" : value; \
widget->setName(widgetName); \
}else if(key == P_X){ \
_position.x = valueToFloat(value); \
}else if(key == P_Y){ \
_position.y = valueToFloat(value); \
}else if(key == P_ScaleX){ \
widget->setScaleX(valueToFloat(value)); \
}else if(key == P_ScaleY){ \
widget->setScaleY(valueToFloat(value)); \
}else if(key == P_Rotation){ \
widget->setRotation(valueToFloat(value)); \
}else if(key == P_Visbile){ \
widget->setVisible(valueToBool(value)); \
}else if(key == P_ZOrder){ \
widget->setZOrder(valueToInt(value)); \
}else if(key == P_LayoutParameter){ \
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray(); \
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(pCocoLoader); \
std::string innerValue = layoutCocosNode[j].GetValue(); \
if (innerKey == P_Type) { \
paramType = valueToInt(innerValue); \
}else if(innerKey == P_Gravity){ \
linearParameter->setGravity((cocos2d::ui::LinearLayoutParameter::LinearGravity)valueToInt(innerValue)); \
}else if(innerKey == P_RelativeName){ \
relativeParameter->setRelativeName(innerValue); \
}else if(innerKey == P_RelativeToName){ \
relativeParameter->setRelativeToWidgetName(innerValue); \
}else if(innerKey == P_Align){ \
relativeParameter->setAlign((cocos2d::ui::RelativeLayoutParameter::RelativeAlign)valueToInt(innerValue)); \
}else if(innerKey == P_MarginLeft){ \
mg.left = valueToFloat(innerValue); \
}else if(innerKey == P_MarginTop){ \
mg.top = valueToFloat(innerValue); \
}else if(innerKey == P_MarginRight){ \
mg.right = valueToFloat(innerValue); \
}else if(innerKey == P_MarginDown){ \
mg.bottom = valueToFloat(innerValue); \
} \
} \
linearParameter->setMargin(mg); \
relativeParameter->setMargin(mg); \
switch (paramType) { \
case 1: \
widget->setLayoutParameter(linearParameter); \
break; \
case 2: \
widget->setLayoutParameter(relativeParameter); \
default: \
break;\
}\
}
#define CC_COLOR_PROPERTY_BINARY_READER \
else if (key == P_Opacity) { \
_opacity = valueToInt(value); \
}else if(key == P_ColorR){ \
_color.r = valueToInt(value); \
}else if(key == P_ColorG){ \
_color.g = valueToInt(value); \
}else if(key == P_ColorB) \
{\
_color.b = valueToInt(value);\
}else if(key == P_FlipX){\
widget->setFlippedX(valueToBool(value));\
}else if(key == P_FlipY){\
widget->setFlippedY(valueToBool(value));\
}
}
#endif /* defined(__TestCpp__WidgetReader__) */