diff --git a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp index 22f7c70cc5..5981973d60 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ButtonReader/ButtonReader.cpp @@ -62,21 +62,21 @@ namespace cocostudio }else if(key == "positionType"){ widget->setPositionType((Widget::PositionType)valueToInt(value)); }else if(key == "sizePercentX"){ - sizePercentX = valueToFloat(value); + _sizePercentX = valueToFloat(value); }else if(key == "sizePercentY"){ - sizePercentY = valueToFloat(value); + _sizePercentY = valueToFloat(value); }else if(key == "positionPercentX"){ - positionPercentX = valueToFloat(value); + _positionPercentX = valueToFloat(value); }else if(key == "positionPercentY"){ - positionPercentY = valueToFloat(value); + _positionPercentY = valueToFloat(value); } else if(key == "adaptScreen"){ - isAdaptScreen = valueToBool(value); + _isAdaptScreen = valueToBool(value); } else if (key == "width"){ - width = valueToFloat(value); + _width = valueToFloat(value); }else if(key == "height"){ - height = valueToFloat(value); + _height = valueToFloat(value); }else if(key == "tag"){ widget->setTag(valueToInt(value)); }else if(key == "actiontag"){ @@ -87,9 +87,9 @@ namespace cocostudio std::string widgetName = value.empty() ? "default" : value; widget->setName(widgetName); }else if(key == "x"){ - position.x = valueToFloat(value); + _position.x = valueToFloat(value); }else if(key == "y"){ - position.y = valueToFloat(value); + _position.y = valueToFloat(value); }else if(key == "scaleX"){ widget->setScaleX(valueToFloat(value)); }else if(key == "scaleY"){ @@ -148,28 +148,23 @@ namespace cocostudio } else if (key == "opacity") { - widget->setOpacity(valueToInt(value)); + _opacity = valueToInt(value); }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); + _color.r = valueToInt(value); }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); + _color.g = valueToInt(value); }else if(key == "colorB") { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); + _color.b = valueToInt(value); }else if(key == "flipX"){ widget->setFlippedX(valueToBool(value)); }else if(key == "flipY"){ widget->setFlippedY(valueToBool(value)); }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); + _originalAnchorPoint.x = valueToFloat(value); }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); + _originalAnchorPoint.y = valueToFloat(value); } - - else if (key == "scale9Enable") { button->setScale9Enabled(valueToBool(value)); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp index 089539fcb8..8f0307b233 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/CheckBoxReader/CheckBoxReader.cpp @@ -42,7 +42,7 @@ namespace cocostudio for (int i = 0; i < pCocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(pCocoLoader); std::string value = stChildArray[i].GetValue(); - CCLOG("key = %s, index : %d", key.c_str(), i); +// CCLOG("key = %s, index : %d", key.c_str(), i); if (key == "ignoreSize") { widget->ignoreContentAdaptWithSize(valueToBool(value)); }else if(key == "sizeType"){ @@ -50,21 +50,21 @@ namespace cocostudio }else if(key == "positionType"){ widget->setPositionType((Widget::PositionType)valueToInt(value)); }else if(key == "sizePercentX"){ - sizePercentX = valueToFloat(value); + _sizePercentX = valueToFloat(value); }else if(key == "sizePercentY"){ - sizePercentY = valueToFloat(value); + _sizePercentY = valueToFloat(value); }else if(key == "positionPercentX"){ - positionPercentX = valueToFloat(value); + _positionPercentX = valueToFloat(value); }else if(key == "positionPercentY"){ - positionPercentY = valueToFloat(value); + _positionPercentY = valueToFloat(value); } else if(key == "adaptScreen"){ - isAdaptScreen = valueToBool(value); + _isAdaptScreen = valueToBool(value); } else if (key == "width"){ - width = valueToFloat(value); + _width = valueToFloat(value); }else if(key == "height"){ - height = valueToFloat(value); + _height = valueToFloat(value); }else if(key == "tag"){ widget->setTag(valueToInt(value)); }else if(key == "actiontag"){ @@ -75,9 +75,9 @@ namespace cocostudio std::string widgetName = value.empty() ? "default" : value; widget->setName(widgetName); }else if(key == "x"){ - position.x = valueToFloat(value); + _position.x = valueToFloat(value); }else if(key == "y"){ - position.y = valueToFloat(value); + _position.y = valueToFloat(value); }else if(key == "scaleX"){ widget->setScaleX(valueToFloat(value)); }else if(key == "scaleY"){ @@ -136,25 +136,22 @@ namespace cocostudio } else if (key == "opacity") { - widget->setOpacity(valueToInt(value)); + _opacity = valueToInt(value); }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); + _color.r = valueToInt(value); }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); + _color.g = valueToInt(value); }else if(key == "colorB") { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); + _color.b = valueToInt(value); }else if(key == "flipX"){ widget->setFlippedX(valueToBool(value)); }else if(key == "flipY"){ widget->setFlippedY(valueToBool(value)); }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); + _originalAnchorPoint.x = valueToFloat(value); }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); + _originalAnchorPoint.y = valueToFloat(value); } else if (key == "backGroundBoxData"){ diff --git a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp index 9e8e350733..04bcc66b6c 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ImageViewReader/ImageViewReader.cpp @@ -45,7 +45,7 @@ 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); +// CCLOG("ImageView: key = %s, value = %d", key.c_str(), i); if (key == "ignoreSize") { widget->ignoreContentAdaptWithSize(valueToBool(value)); @@ -54,21 +54,21 @@ namespace cocostudio }else if(key == "positionType"){ widget->setPositionType((Widget::PositionType)valueToInt(value)); }else if(key == "sizePercentX"){ - sizePercentX = valueToFloat(value); + _sizePercentX = valueToFloat(value); }else if(key == "sizePercentY"){ - sizePercentY = valueToFloat(value); + _sizePercentY = valueToFloat(value); }else if(key == "positionPercentX"){ - positionPercentX = valueToFloat(value); + _positionPercentX = valueToFloat(value); }else if(key == "positionPercentY"){ - positionPercentY = valueToFloat(value); + _positionPercentY = valueToFloat(value); } else if(key == "adaptScreen"){ - isAdaptScreen = valueToBool(value); + _isAdaptScreen = valueToBool(value); } else if (key == "width"){ - width = valueToFloat(value); + _width = valueToFloat(value); }else if(key == "height"){ - height = valueToFloat(value); + _height = valueToFloat(value); }else if(key == "tag"){ widget->setTag(valueToInt(value)); }else if(key == "actiontag"){ @@ -79,9 +79,9 @@ namespace cocostudio std::string widgetName = value.empty() ? "default" : value; widget->setName(widgetName); }else if(key == "x"){ - position.x = valueToFloat(value); + _position.x = valueToFloat(value); }else if(key == "y"){ - position.y = valueToFloat(value); + _position.y = valueToFloat(value); }else if(key == "scaleX"){ widget->setScaleX(valueToFloat(value)); }else if(key == "scaleY"){ @@ -140,25 +140,22 @@ namespace cocostudio } else if (key == "opacity") { - widget->setOpacity(valueToInt(value)); + _opacity = valueToInt(value); }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); + _color.r = valueToInt(value); }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); + _color.g = valueToInt(value); }else if(key == "colorB") { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); + _color.b = valueToInt(value); }else if(key == "flipX"){ widget->setFlippedX(valueToBool(value)); }else if(key == "flipY"){ widget->setFlippedY(valueToBool(value)); }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); + _originalAnchorPoint.x = valueToFloat(value); }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); + _originalAnchorPoint.y = valueToFloat(value); } else if (key == "scale9Enable") { imageView->setScale9Enabled(valueToBool(value)); diff --git a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp index 25281c43e0..6fa76a2af2 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LayoutReader/LayoutReader.cpp @@ -48,8 +48,8 @@ namespace cocostudio int ecr=0, ecg=0, ecb= 0; float bgcv1 = 0.0f, bgcv2= 0.0f; float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f; - bool isAdaptScreen = false; Layout::Type layoutType; + int bgColorOpacity = panel->getBackGroundColorOpacity(); for (int i = 0; i < pCocoNode->GetChildNum(); ++i) { std::string key = stChildArray[i].GetName(pCocoLoader); @@ -62,21 +62,21 @@ namespace cocostudio }else if(key == "positionType"){ widget->setPositionType((Widget::PositionType)valueToInt(value)); }else if(key == "sizePercentX"){ - sizePercentX = valueToFloat(value); + _sizePercentX = valueToFloat(value); }else if(key == "sizePercentY"){ - sizePercentY = valueToFloat(value); + _sizePercentY = valueToFloat(value); }else if(key == "positionPercentX"){ - positionPercentX = valueToFloat(value); + _positionPercentX = valueToFloat(value); }else if(key == "positionPercentY"){ - positionPercentY = valueToFloat(value); + _positionPercentY = valueToFloat(value); } else if(key == "adaptScreen"){ - isAdaptScreen = valueToBool(value); + _isAdaptScreen = valueToBool(value); } else if (key == "width"){ - width = valueToFloat(value); + _width = valueToFloat(value); }else if(key == "height"){ - height = valueToFloat(value); + _height = valueToFloat(value); }else if(key == "tag"){ widget->setTag(valueToInt(value)); }else if(key == "actiontag"){ @@ -87,9 +87,9 @@ namespace cocostudio std::string widgetName = value.empty() ? "default" : value; widget->setName(widgetName); }else if(key == "x"){ - position.x = valueToFloat(value); + _position.x = valueToFloat(value); }else if(key == "y"){ - position.y = valueToFloat(value); + _position.y = valueToFloat(value); }else if(key == "scaleX"){ widget->setScaleX(valueToFloat(value)); }else if(key == "scaleY"){ @@ -148,28 +148,22 @@ namespace cocostudio } else if (key == "opacity") { - widget->setOpacity(valueToInt(value)); + _opacity = valueToInt(value); }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); + _color.r = valueToInt(value); }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); + _color.g = valueToInt(value); }else if(key == "colorB") { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); + _color.b = valueToInt(value); }else if(key == "flipX"){ widget->setFlippedX(valueToBool(value)); }else if(key == "flipY"){ widget->setFlippedY(valueToBool(value)); }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); + _originalAnchorPoint.x = valueToFloat(value); }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); - } - else if (key == "adaptScreen") { - isAdaptScreen = valueToBool(value); + _originalAnchorPoint.y = valueToFloat(value); } else if(key == "width"){ w = valueToFloat(value); @@ -208,7 +202,7 @@ namespace cocostudio }else if(key == "vectorY"){ bgcv2 = valueToFloat(value); }else if(key == "bgColorOpacity"){ - panel->setBackGroundColorOpacity(valueToInt(value)); + bgColorOpacity = valueToInt(value); }else if( key == "colorType"){ panel->setBackGroundColorType(Layout::BackGroundColorType(valueToInt(value))); }else if (key == "backGroundImageData"){ @@ -239,17 +233,19 @@ namespace cocostudio } - Size screenSize = Director::getInstance()->getWinSize(); - if (isAdaptScreen) { - w = screenSize.width; - h = screenSize.height; - } - panel->setSize(Size(w,h)); panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); panel->setBackGroundColor(Color3B(cr, cg, cb)); panel->setBackGroundColorVector(Vec2(bgcv1, bgcv2)); + + panel->setBackGroundColorOpacity(bgColorOpacity); + + + panel->setBackGroundImageColor(Color3B(_color.r, _color.g, _color.b)); + + panel->setBackGroundImageOpacity(_opacity); + if (panel->isBackGroundImageScale9Enabled()) { panel->setBackGroundImageCapInsets(Rect(capsx, capsy, capsWidth, capsHeight)); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp index dd15962041..ffd8d2cae5 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/LoadingBarReader/LoadingBarReader.cpp @@ -40,6 +40,7 @@ namespace cocostudio LoadingBar* loadingBar = static_cast(widget); this->beginSetBasicProperties(widget); float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f; + int percent = loadingBar->getPercent(); stExpCocoNode *stChildArray = pCocoNode->GetChildArray(); @@ -54,21 +55,21 @@ namespace cocostudio }else if(key == "positionType"){ widget->setPositionType((Widget::PositionType)valueToInt(value)); }else if(key == "sizePercentX"){ - sizePercentX = valueToFloat(value); + _sizePercentX = valueToFloat(value); }else if(key == "sizePercentY"){ - sizePercentY = valueToFloat(value); + _sizePercentY = valueToFloat(value); }else if(key == "positionPercentX"){ - positionPercentX = valueToFloat(value); + _positionPercentX = valueToFloat(value); }else if(key == "positionPercentY"){ - positionPercentY = valueToFloat(value); + _positionPercentY = valueToFloat(value); } else if(key == "adaptScreen"){ - isAdaptScreen = valueToBool(value); + _isAdaptScreen = valueToBool(value); } else if (key == "width"){ - width = valueToFloat(value); + _width = valueToFloat(value); }else if(key == "height"){ - height = valueToFloat(value); + _height = valueToFloat(value); }else if(key == "tag"){ widget->setTag(valueToInt(value)); }else if(key == "actiontag"){ @@ -79,9 +80,9 @@ namespace cocostudio std::string widgetName = value.empty() ? "default" : value; widget->setName(widgetName); }else if(key == "x"){ - position.x = valueToFloat(value); + _position.x = valueToFloat(value); }else if(key == "y"){ - position.y = valueToFloat(value); + _position.y = valueToFloat(value); }else if(key == "scaleX"){ widget->setScaleX(valueToFloat(value)); }else if(key == "scaleY"){ @@ -140,25 +141,22 @@ namespace cocostudio } else if (key == "opacity") { - widget->setOpacity(valueToInt(value)); + _opacity = valueToInt(value); }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); + _color.r = valueToInt(value); }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); + _color.g = valueToInt(value); }else if(key == "colorB") { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); + _color.b = valueToInt(value); }else if(key == "flipX"){ widget->setFlippedX(valueToBool(value)); }else if(key == "flipY"){ widget->setFlippedY(valueToBool(value)); }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); + _originalAnchorPoint.x = valueToFloat(value); }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); + _originalAnchorPoint.y = valueToFloat(value); } else if (key == "scale9Enable") { loadingBar->setScale9Enabled(valueToBool(value)); @@ -186,7 +184,7 @@ namespace cocostudio }else if(key == "direction"){ loadingBar->setDirection((LoadingBar::Direction)valueToInt(value)); }else if(key == "percent"){ - loadingBar->setPercent(valueToInt(value)); + percent = valueToInt(value); } } //end of for loop @@ -194,7 +192,7 @@ namespace cocostudio if (loadingBar->isScale9Enabled()) { loadingBar->setCapInsets(Rect(capsx, capsy, capsWidth, capsHeight)); } - + loadingBar->setPercent(percent); this->endSetBasicProperties(widget); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp index e1c67f9673..fba261d993 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ScrollViewReader/ScrollViewReader.cpp @@ -45,120 +45,7 @@ namespace cocostudio 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"){ - 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") { - widget->setOpacity(valueToInt(value)); - }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); - }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); - }else if(key == "colorB") - { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); - }else if(key == "flipX"){ - widget->setFlippedX(valueToBool(value)); - }else if(key == "flipY"){ - widget->setFlippedY(valueToBool(value)); - }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); - }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); - } - else if (key == "innerWidth") { + if (key == "innerWidth") { innerWidth = valueToFloat(value); } else if(key == "innerHeight"){ diff --git a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp index e6e2f0cffc..a47c1b4bbd 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/SliderReader/SliderReader.cpp @@ -39,6 +39,7 @@ namespace cocostudio Slider* slider = static_cast(widget); float barLength = 0.0f; + int percent = slider->getPercent(); stExpCocoNode *stChildArray = pCocoNode->GetChildArray(); for (int i = 0; i < pCocoNode->GetChildNum(); ++i) { @@ -52,21 +53,21 @@ namespace cocostudio }else if(key == "positionType"){ widget->setPositionType((Widget::PositionType)valueToInt(value)); }else if(key == "sizePercentX"){ - sizePercentX = valueToFloat(value); + _sizePercentX = valueToFloat(value); }else if(key == "sizePercentY"){ - sizePercentY = valueToFloat(value); + _sizePercentY = valueToFloat(value); }else if(key == "positionPercentX"){ - positionPercentX = valueToFloat(value); + _positionPercentX = valueToFloat(value); }else if(key == "positionPercentY"){ - positionPercentY = valueToFloat(value); + _positionPercentY = valueToFloat(value); } else if(key == "adaptScreen"){ - isAdaptScreen = valueToBool(value); + _isAdaptScreen = valueToBool(value); } else if (key == "width"){ - width = valueToFloat(value); + _width = valueToFloat(value); }else if(key == "height"){ - height = valueToFloat(value); + _height = valueToFloat(value); }else if(key == "tag"){ widget->setTag(valueToInt(value)); }else if(key == "actiontag"){ @@ -77,9 +78,9 @@ namespace cocostudio std::string widgetName = value.empty() ? "default" : value; widget->setName(widgetName); }else if(key == "x"){ - position.x = valueToFloat(value); + _position.x = valueToFloat(value); }else if(key == "y"){ - position.y = valueToFloat(value); + _position.y = valueToFloat(value); }else if(key == "scaleX"){ widget->setScaleX(valueToFloat(value)); }else if(key == "scaleY"){ @@ -138,32 +139,29 @@ namespace cocostudio } else if (key == "opacity") { - widget->setOpacity(valueToInt(value)); + _opacity = valueToInt(value); }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); + _color.r = valueToInt(value); }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); + _color.g = valueToInt(value); }else if(key == "colorB") { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); + _color.b = valueToInt(value); }else if(key == "flipX"){ widget->setFlippedX(valueToBool(value)); }else if(key == "flipY"){ widget->setFlippedY(valueToBool(value)); }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); + _originalAnchorPoint.x = valueToFloat(value); }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); + _originalAnchorPoint.y = valueToFloat(value); } //control custom properties else if (key == "scale9Enable") { slider->setScale9Enabled(valueToBool(value)); } else if(key == "percent"){ - slider->setPercent(valueToInt(value)); + percent = valueToInt(value); }else if(key == "barFileNameData"){ stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); std::string resType = backGroundChildren[2].GetValue();; @@ -223,6 +221,7 @@ namespace cocostudio if (slider->isScale9Enabled()) { slider->setSize(Size(barLength, slider->getContentSize().height)); } + slider->setPercent(percent); this->endSetBasicProperties(widget); } diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp index ead7db5f26..d2ac6f1553 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextAtlasReader/TextAtlasReader.cpp @@ -58,21 +58,21 @@ namespace cocostudio }else if(key == "positionType"){ widget->setPositionType((Widget::PositionType)valueToInt(value)); }else if(key == "sizePercentX"){ - sizePercentX = valueToFloat(value); + _sizePercentX = valueToFloat(value); }else if(key == "sizePercentY"){ - sizePercentY = valueToFloat(value); + _sizePercentY = valueToFloat(value); }else if(key == "positionPercentX"){ - positionPercentX = valueToFloat(value); + _positionPercentX = valueToFloat(value); }else if(key == "positionPercentY"){ - positionPercentY = valueToFloat(value); + _positionPercentY = valueToFloat(value); } else if(key == "adaptScreen"){ - isAdaptScreen = valueToBool(value); + _isAdaptScreen = valueToBool(value); } else if (key == "width"){ - width = valueToFloat(value); + _width = valueToFloat(value); }else if(key == "height"){ - height = valueToFloat(value); + _height = valueToFloat(value); }else if(key == "tag"){ widget->setTag(valueToInt(value)); }else if(key == "actiontag"){ @@ -83,9 +83,9 @@ namespace cocostudio std::string widgetName = value.empty() ? "default" : value; widget->setName(widgetName); }else if(key == "x"){ - position.x = valueToFloat(value); + _position.x = valueToFloat(value); }else if(key == "y"){ - position.y = valueToFloat(value); + _position.y = valueToFloat(value); }else if(key == "scaleX"){ widget->setScaleX(valueToFloat(value)); }else if(key == "scaleY"){ @@ -144,25 +144,22 @@ namespace cocostudio } else if (key == "opacity") { - widget->setOpacity(valueToInt(value)); + _opacity = valueToInt(value); }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); + _color.r = valueToInt(value); }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); + _color.g = valueToInt(value); }else if(key == "colorB") { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); + _color.b = valueToInt(value); }else if(key == "flipX"){ widget->setFlippedX(valueToBool(value)); }else if(key == "flipY"){ widget->setFlippedY(valueToBool(value)); }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); + _originalAnchorPoint.x = valueToFloat(value); }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); + _originalAnchorPoint.y = valueToFloat(value); } else if (key == "stringValue") { stringValue = value; diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp index eeefd20ec1..ad3268f195 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextBMFontReader/TextBMFontReader.cpp @@ -52,21 +52,21 @@ namespace cocostudio }else if(key == "positionType"){ widget->setPositionType((Widget::PositionType)valueToInt(value)); }else if(key == "sizePercentX"){ - sizePercentX = valueToFloat(value); + _sizePercentX = valueToFloat(value); }else if(key == "sizePercentY"){ - sizePercentY = valueToFloat(value); + _sizePercentY = valueToFloat(value); }else if(key == "positionPercentX"){ - positionPercentX = valueToFloat(value); + _positionPercentX = valueToFloat(value); }else if(key == "positionPercentY"){ - positionPercentY = valueToFloat(value); + _positionPercentY = valueToFloat(value); } else if(key == "adaptScreen"){ - isAdaptScreen = valueToBool(value); + _isAdaptScreen = valueToBool(value); } else if (key == "width"){ - width = valueToFloat(value); + _width = valueToFloat(value); }else if(key == "height"){ - height = valueToFloat(value); + _height = valueToFloat(value); }else if(key == "tag"){ widget->setTag(valueToInt(value)); }else if(key == "actiontag"){ @@ -77,9 +77,9 @@ namespace cocostudio std::string widgetName = value.empty() ? "default" : value; widget->setName(widgetName); }else if(key == "x"){ - position.x = valueToFloat(value); + _position.x = valueToFloat(value); }else if(key == "y"){ - position.y = valueToFloat(value); + _position.y = valueToFloat(value); }else if(key == "scaleX"){ widget->setScaleX(valueToFloat(value)); }else if(key == "scaleY"){ @@ -138,25 +138,22 @@ namespace cocostudio } else if (key == "opacity") { - widget->setOpacity(valueToInt(value)); + _opacity = valueToInt(value); }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); + _color.r = valueToInt(value); }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); + _color.g = valueToInt(value); }else if(key == "colorB") { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); + _color.b = valueToInt(value); }else if(key == "flipX"){ widget->setFlippedX(valueToBool(value)); }else if(key == "flipY"){ widget->setFlippedY(valueToBool(value)); }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); + _originalAnchorPoint.x = valueToFloat(value); }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); + _originalAnchorPoint.y = valueToFloat(value); } else if(key == "fileNameData"){ stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(); diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp index 3271646939..fde3284b59 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldReader.cpp @@ -51,21 +51,21 @@ namespace cocostudio }else if(key == "positionType"){ widget->setPositionType((Widget::PositionType)valueToInt(value)); }else if(key == "sizePercentX"){ - sizePercentX = valueToFloat(value); + _sizePercentX = valueToFloat(value); }else if(key == "sizePercentY"){ - sizePercentY = valueToFloat(value); + _sizePercentY = valueToFloat(value); }else if(key == "positionPercentX"){ - positionPercentX = valueToFloat(value); + _positionPercentX = valueToFloat(value); }else if(key == "positionPercentY"){ - positionPercentY = valueToFloat(value); + _positionPercentY = valueToFloat(value); } else if(key == "adaptScreen"){ - isAdaptScreen = valueToBool(value); + _isAdaptScreen = valueToBool(value); } else if (key == "width"){ - width = valueToFloat(value); + _width = valueToFloat(value); }else if(key == "height"){ - height = valueToFloat(value); + _height = valueToFloat(value); }else if(key == "tag"){ widget->setTag(valueToInt(value)); }else if(key == "actiontag"){ @@ -76,9 +76,9 @@ namespace cocostudio std::string widgetName = value.empty() ? "default" : value; widget->setName(widgetName); }else if(key == "x"){ - position.x = valueToFloat(value); + _position.x = valueToFloat(value); }else if(key == "y"){ - position.y = valueToFloat(value); + _position.y = valueToFloat(value); }else if(key == "scaleX"){ widget->setScaleX(valueToFloat(value)); }else if(key == "scaleY"){ @@ -137,25 +137,22 @@ namespace cocostudio } else if (key == "opacity") { - widget->setOpacity(valueToInt(value)); + _opacity = valueToInt(value); }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); + _color.r = valueToInt(value); }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); + _color.g = valueToInt(value); }else if(key == "colorB") { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); + _color.b = valueToInt(value); }else if(key == "flipX"){ widget->setFlippedX(valueToBool(value)); }else if(key == "flipY"){ widget->setFlippedY(valueToBool(value)); }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); + _originalAnchorPoint.x = valueToFloat(value); }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); + _originalAnchorPoint.y = valueToFloat(value); } else if(key == "placeHolder"){ textField->setPlaceHolder(value); diff --git a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp index 9979e70053..d594217963 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp @@ -53,21 +53,21 @@ namespace cocostudio }else if(key == "positionType"){ widget->setPositionType((Widget::PositionType)valueToInt(value)); }else if(key == "sizePercentX"){ - sizePercentX = valueToFloat(value); + _sizePercentX = valueToFloat(value); }else if(key == "sizePercentY"){ - sizePercentY = valueToFloat(value); + _sizePercentY = valueToFloat(value); }else if(key == "positionPercentX"){ - positionPercentX = valueToFloat(value); + _positionPercentX = valueToFloat(value); }else if(key == "positionPercentY"){ - positionPercentY = valueToFloat(value); + _positionPercentY = valueToFloat(value); } else if(key == "adaptScreen"){ - isAdaptScreen = valueToBool(value); + _isAdaptScreen = valueToBool(value); } else if (key == "width"){ - width = valueToFloat(value); + _width = valueToFloat(value); }else if(key == "height"){ - height = valueToFloat(value); + _height = valueToFloat(value); }else if(key == "tag"){ widget->setTag(valueToInt(value)); }else if(key == "actiontag"){ @@ -78,9 +78,9 @@ namespace cocostudio std::string widgetName = value.empty() ? "default" : value; widget->setName(widgetName); }else if(key == "x"){ - position.x = valueToFloat(value); + _position.x = valueToFloat(value); }else if(key == "y"){ - position.y = valueToFloat(value); + _position.y = valueToFloat(value); }else if(key == "scaleX"){ widget->setScaleX(valueToFloat(value)); }else if(key == "scaleY"){ @@ -139,25 +139,22 @@ namespace cocostudio } else if (key == "opacity") { - widget->setOpacity(valueToInt(value)); + _opacity = valueToInt(value); }else if(key == "colorR"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B(valueToInt(value), color.g, color.b)); + _color.r = valueToInt(value); }else if(key == "colorG"){ - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, valueToInt(value), color.b)); + _color.g = valueToInt(value); }else if(key == "colorB") { - Color3B color = widget->getColor(); - widget->setColor(Color3B( color.r, color.g , valueToInt(value))); + _color.b = valueToInt(value); }else if(key == "flipX"){ widget->setFlippedX(valueToBool(value)); }else if(key == "flipY"){ widget->setFlippedY(valueToBool(value)); }else if(key == "anchorPointX"){ - originalAnchorPoint.x = valueToFloat(value); + _originalAnchorPoint.x = valueToFloat(value); }else if(key == "anchorPointY"){ - originalAnchorPoint.y = valueToFloat(value); + _originalAnchorPoint.y = valueToFloat(value); } else if (key == "touchScaleEnable") { label->setTouchScaleChangeEnabled(valueToBool(value)); diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp index 24a325671b..db369da192 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.cpp @@ -14,13 +14,14 @@ namespace cocostudio IMPLEMENT_CLASS_WIDGET_READER_INFO(WidgetReader) WidgetReader::WidgetReader() - :sizePercentX(0.0f), - sizePercentY(0.0f), - isAdaptScreen(false), - width(0.0f), - height(0.0f), - positionPercentX(0.0f), - positionPercentY(0.0f) + :_sizePercentX(0.0f), + _sizePercentY(0.0f), + _isAdaptScreen(false), + _width(0.0f), + _height(0.0f), + _positionPercentX(0.0f), + _positionPercentY(0.0f), + _opacity(255) { valueToInt = [=](std::string str) -> int{ return atoi(str.c_str()); @@ -198,25 +199,29 @@ namespace cocostudio void WidgetReader::beginSetBasicProperties(cocos2d::ui::Widget *widget) { - position = widget->getPosition(); + _position = widget->getPosition(); //set default color - widget->setColor(Color3B(255,255,255)); - originalAnchorPoint = widget->getAnchorPoint(); + _color = Color3B(255,255,255); + widget->setColor(_color); + _opacity = widget->getOpacity(); + _originalAnchorPoint = widget->getAnchorPoint(); } void WidgetReader::endSetBasicProperties(Widget *widget) { Size screenSize = Director::getInstance()->getWinSize(); - widget->setPositionPercent(Vec2(positionPercentX, positionPercentY)); - widget->setSizePercent(Vec2(sizePercentX, sizePercentY)); - if (isAdaptScreen) { - width = screenSize.width; - height = screenSize.height; + widget->setPositionPercent(Vec2(_positionPercentX, _positionPercentY)); + widget->setSizePercent(Vec2(_sizePercentX, _sizePercentY)); + if (_isAdaptScreen) { + _width = screenSize.width; + _height = screenSize.height; } - widget->setSize(Size(width, height)); - widget->setPosition(position); - widget->setAnchorPoint(originalAnchorPoint); + widget->setColor(_color); + widget->setOpacity(_opacity); + widget->setSize(Size(_width, _height)); + widget->setPosition(_position); + widget->setAnchorPoint(_originalAnchorPoint); } std::string WidgetReader::getResourcePath(const rapidjson::Value &dict, diff --git a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h index 0dee7d533e..0d46881b36 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h +++ b/cocos/editor-support/cocostudio/WidgetReader/WidgetReader.h @@ -74,15 +74,17 @@ namespace cocostudio std::function valueToBool; std::function valueToFloat; - float sizePercentX; - float sizePercentY; - float positionPercentX; - float positionPercentY; - float width ; - float height; - cocos2d::Vec2 position; - bool isAdaptScreen; - cocos2d::Vec2 originalAnchorPoint; + float _sizePercentX; + float _sizePercentY; + float _positionPercentX; + float _positionPercentY; + float _width ; + float _height; + cocos2d::Color3B _color; + int _opacity; + cocos2d::Vec2 _position; + bool _isAdaptScreen; + cocos2d::Vec2 _originalAnchorPoint; }; }