mirror of https://github.com/axmolengine/axmol.git
refactor Loader
This commit is contained in:
parent
615995af54
commit
63475a6f81
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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"){
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace cocostudio
|
|||
LoadingBar* loadingBar = static_cast<LoadingBar*>(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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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"){
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace cocostudio
|
|||
Slider* slider = static_cast<Slider*>(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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -74,15 +74,17 @@ namespace cocostudio
|
|||
std::function<bool(std::string)> valueToBool;
|
||||
std::function<float(std::string)> 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;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue