mirror of https://github.com/axmolengine/axmol.git
add default value to widget reader
This commit is contained in:
parent
b9a968680f
commit
fefdc70af9
|
@ -117,19 +117,21 @@ namespace cocostudio
|
||||||
bool scale9Enable = DICTOOL->getBooleanValue_json(options, P_Scale9Enable);
|
bool scale9Enable = DICTOOL->getBooleanValue_json(options, P_Scale9Enable);
|
||||||
loadingBar->setScale9Enabled(scale9Enable);
|
loadingBar->setScale9Enabled(scale9Enable);
|
||||||
|
|
||||||
if (scale9Enable)
|
|
||||||
{
|
|
||||||
float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);
|
float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);
|
||||||
float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY);
|
float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY);
|
||||||
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1);
|
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1);
|
||||||
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1);
|
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1);
|
||||||
|
|
||||||
|
if (scale9Enable) {
|
||||||
loadingBar->setCapInsets(Rect(cx, cy, cw, ch));
|
loadingBar->setCapInsets(Rect(cx, cy, cw, ch));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
float width = DICTOOL->getFloatValue_json(options, P_Width);
|
float width = DICTOOL->getFloatValue_json(options, P_Width);
|
||||||
float height = DICTOOL->getFloatValue_json(options, P_Height);
|
float height = DICTOOL->getFloatValue_json(options, P_Height);
|
||||||
loadingBar->setSize(Size(width, height));
|
loadingBar->setSize(Size(width, height));
|
||||||
}
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
loadingBar->setDirection(LoadingBar::Direction(DICTOOL->getIntValue_json(options, P_Direction)));
|
loadingBar->setDirection(LoadingBar::Direction(DICTOOL->getIntValue_json(options, P_Direction)));
|
||||||
|
|
|
@ -145,25 +145,24 @@ namespace cocostudio
|
||||||
slider->setPercent(DICTOOL->getIntValue_json(options, P_Percent));
|
slider->setPercent(DICTOOL->getIntValue_json(options, P_Percent));
|
||||||
|
|
||||||
|
|
||||||
bool bt = DICTOOL->checkObjectExist_json(options, P_BarFileName);
|
// bool bt = DICTOOL->checkObjectExist_json(options, P_BarFileName);
|
||||||
float barLength = DICTOOL->getFloatValue_json(options, P_Length,290);
|
float barLength = DICTOOL->getFloatValue_json(options, P_Length,290);
|
||||||
if (bt)
|
|
||||||
{
|
|
||||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, P_BarFileNameData);
|
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, P_BarFileNameData);
|
||||||
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, P_ResourceType);
|
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, P_ResourceType);
|
||||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, P_Path, (Widget::TextureResType)imageFileNameType);
|
std::string imageFileName = this->getResourcePath(imageFileNameDic, P_Path, (Widget::TextureResType)imageFileNameType);
|
||||||
slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (barTextureScale9Enable)
|
if (barTextureScale9Enable)
|
||||||
{
|
{
|
||||||
slider->setContentSize(Size(barLength, slider->getContentSize().height));
|
slider->setContentSize(Size(barLength, slider->getContentSize().height));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//loading normal slider ball texture
|
//loading normal slider ball texture
|
||||||
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, P_BallNormalData);
|
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, P_BallNormalData);
|
||||||
int normalType = DICTOOL->getIntValue_json(normalDic, P_ResourceType);
|
int normalType = DICTOOL->getIntValue_json(normalDic, P_ResourceType);
|
||||||
std::string imageFileName = this->getResourcePath(normalDic, P_Path, (Widget::TextureResType)normalType);
|
imageFileName = this->getResourcePath(normalDic, P_Path, (Widget::TextureResType)normalType);
|
||||||
slider->loadSlidBallTextureNormal(imageFileName, (Widget::TextureResType)normalType);
|
slider->loadSlidBallTextureNormal(imageFileName, (Widget::TextureResType)normalType);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -101,13 +101,12 @@ namespace cocostudio
|
||||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
||||||
|
|
||||||
TextAtlas* labelAtlas = static_cast<TextAtlas*>(widget);
|
TextAtlas* labelAtlas = static_cast<TextAtlas*>(widget);
|
||||||
bool sv = DICTOOL->checkObjectExist_json(options, P_StringValue);
|
// bool sv = DICTOOL->checkObjectExist_json(options, P_StringValue);
|
||||||
bool cmf = DICTOOL->checkObjectExist_json(options, P_CharMapFile);
|
// bool cmf = DICTOOL->checkObjectExist_json(options, P_CharMapFile);
|
||||||
bool iw = DICTOOL->checkObjectExist_json(options, P_ItemWidth);
|
// bool iw = DICTOOL->checkObjectExist_json(options, P_ItemWidth);
|
||||||
bool ih = DICTOOL->checkObjectExist_json(options, P_ItemHeight);
|
// bool ih = DICTOOL->checkObjectExist_json(options, P_ItemHeight);
|
||||||
bool scm = DICTOOL->checkObjectExist_json(options, P_StartCharMap);
|
// bool scm = DICTOOL->checkObjectExist_json(options, P_StartCharMap);
|
||||||
if (sv && cmf && iw && ih && scm)
|
|
||||||
{
|
|
||||||
const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, P_CharMapFileData);
|
const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, P_CharMapFileData);
|
||||||
int cmfType = DICTOOL->getIntValue_json(cmftDic, P_ResourceType);
|
int cmfType = DICTOOL->getIntValue_json(cmftDic, P_ResourceType);
|
||||||
switch (cmfType)
|
switch (cmfType)
|
||||||
|
@ -130,7 +129,7 @@ namespace cocostudio
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
||||||
|
|
|
@ -113,11 +113,9 @@ namespace cocostudio
|
||||||
|
|
||||||
void WidgetReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
|
void WidgetReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
|
||||||
{
|
{
|
||||||
bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, P_IgnoreSize);
|
|
||||||
if (ignoreSizeExsit)
|
widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize,false));
|
||||||
{
|
|
||||||
widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, P_SizeType));
|
widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, P_SizeType));
|
||||||
widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, P_PositionType));
|
widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, P_PositionType));
|
||||||
|
@ -151,21 +149,15 @@ namespace cocostudio
|
||||||
float x = DICTOOL->getFloatValue_json(options, P_X);
|
float x = DICTOOL->getFloatValue_json(options, P_X);
|
||||||
float y = DICTOOL->getFloatValue_json(options, P_Y);
|
float y = DICTOOL->getFloatValue_json(options, P_Y);
|
||||||
widget->setPosition(Vec2(x,y));
|
widget->setPosition(Vec2(x,y));
|
||||||
bool sx = DICTOOL->checkObjectExist_json(options, P_ScaleX);
|
|
||||||
if (sx)
|
widget->setScaleX(DICTOOL->getFloatValue_json(options, P_ScaleX,1.0));
|
||||||
{
|
|
||||||
widget->setScaleX(DICTOOL->getFloatValue_json(options, P_ScaleX));
|
|
||||||
}
|
widget->setScaleY(DICTOOL->getFloatValue_json(options, P_ScaleY,1.0));
|
||||||
bool sy = DICTOOL->checkObjectExist_json(options, P_ScaleY);
|
|
||||||
if (sy)
|
|
||||||
{
|
widget->setRotation(DICTOOL->getFloatValue_json(options, P_Rotation,0));
|
||||||
widget->setScaleY(DICTOOL->getFloatValue_json(options, P_ScaleY));
|
|
||||||
}
|
|
||||||
bool rt = DICTOOL->checkObjectExist_json(options, P_Rotation);
|
|
||||||
if (rt)
|
|
||||||
{
|
|
||||||
widget->setRotation(DICTOOL->getFloatValue_json(options, P_Rotation));
|
|
||||||
}
|
|
||||||
bool vb = DICTOOL->checkObjectExist_json(options, P_Visbile);
|
bool vb = DICTOOL->checkObjectExist_json(options, P_Visbile);
|
||||||
if (vb)
|
if (vb)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue