Merge pull request #4684 from nutty898/develop_nutty_modify_framework_addnewreader

Develop nutty modify framework addnewreader
This commit is contained in:
James Chen 2013-12-26 05:30:22 -08:00
commit fbdcefadfa
2 changed files with 36 additions and 9 deletions

View File

@ -151,10 +151,6 @@ void ActionNode::initActionNodeFromRoot(Object* root)
{ {
Node* rootNode = dynamic_cast<Node*>(root); Node* rootNode = dynamic_cast<Node*>(root);
if (rootNode != NULL) if (rootNode != NULL)
{
log("Need a definition of <initActionNodeFromRoot> for gameObject");
}
else
{ {
Widget* rootWidget = dynamic_cast<Widget*>(root); Widget* rootWidget = dynamic_cast<Widget*>(root);
if (rootWidget != NULL) if (rootWidget != NULL)

View File

@ -619,7 +619,7 @@ void WidgetPropertiesReader0250::setPropsForLabelAtlasFromJsonDictionary(Widget*
const char* cmft = dicHelper->getStringValue_json(options, "charMapFile"); const char* cmft = dicHelper->getStringValue_json(options, "charMapFile");
cmf_tp = tp_c.append(cmft).c_str(); cmf_tp = tp_c.append(cmft).c_str();
labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth"),dicHelper->getIntValue_json(options,"itemHeight"),dicHelper->getStringValue_json(options, "startCharMap")); labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth") / CC_CONTENT_SCALE_FACTOR() ,dicHelper->getIntValue_json(options,"itemHeight") / CC_CONTENT_SCALE_FACTOR(), dicHelper->getStringValue_json(options, "startCharMap"));
} }
setColorPropsForWidgetFromJsonDictionary(widget,options); setColorPropsForWidgetFromJsonDictionary(widget,options);
} }
@ -1024,9 +1024,25 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *dat
JsonDictionary* subData = dicHelper->getDictionaryFromArray_json(data, "children", i); JsonDictionary* subData = dicHelper->getDictionaryFromArray_json(data, "children", i);
Widget* child = widgetFromJsonDictionary(subData); Widget* child = widgetFromJsonDictionary(subData);
if (child) if (child)
{
PageView* pageView = dynamic_cast<PageView*>(widget);
if (pageView)
{
pageView->addPage(static_cast<Layout*>(child));
}
else
{
ListView* listView = dynamic_cast<ListView*>(widget);
if (listView)
{
listView->pushBackCustomItem(child);
}
else
{ {
widget->addChild(child); widget->addChild(child);
} }
}
}
CC_SAFE_DELETE(subData); CC_SAFE_DELETE(subData);
} }
@ -1525,7 +1541,7 @@ void WidgetPropertiesReader0300::setPropsForLabelAtlasFromJsonDictionary(Widget*
std::string tp_c = m_strFilePath; std::string tp_c = m_strFilePath;
const char* cmfPath = dicHelper->getStringValue_json(cmftDic, "path"); const char* cmfPath = dicHelper->getStringValue_json(cmftDic, "path");
const char* cmf_tp = tp_c.append(cmfPath).c_str(); const char* cmf_tp = tp_c.append(cmfPath).c_str();
labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth"),dicHelper->getIntValue_json(options,"itemHeight"),dicHelper->getStringValue_json(options, "startCharMap")); labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth") / CC_CONTENT_SCALE_FACTOR(),dicHelper->getIntValue_json(options,"itemHeight") / CC_CONTENT_SCALE_FACTOR(), dicHelper->getStringValue_json(options, "startCharMap"));
break; break;
} }
case 1: case 1:
@ -1931,11 +1947,26 @@ void WidgetPropertiesReader0300::setPropsForLabelBMFontFromJsonDictionary(Widget
void WidgetPropertiesReader0300::setPropsForPageViewFromJsonDictionary(Widget*widget,JsonDictionary* options) void WidgetPropertiesReader0300::setPropsForPageViewFromJsonDictionary(Widget*widget,JsonDictionary* options)
{ {
setPropsForLayoutFromJsonDictionary(widget, options);
} }
void WidgetPropertiesReader0300::setPropsForListViewFromJsonDictionary(Widget* widget, JsonDictionary* options) void WidgetPropertiesReader0300::setPropsForListViewFromJsonDictionary(Widget* widget, JsonDictionary* options)
{ {
setPropsForLayoutFromJsonDictionary(widget, options);
ListView* listView = static_cast<ListView*>(widget);
float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth");
float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight");
listView->setInnerContainerSize(Size(innerWidth, innerHeight));
int direction = DICTOOL->getFloatValue_json(options, "direction");
listView->setDirection((SCROLLVIEW_DIR)direction);
ListViewGravity gravity = (ListViewGravity)DICTOOL->getIntValue_json(options, "gravity");
listView->setGravity(gravity);
float itemMargin = DICTOOL->getFloatValue_json(options, "itemMargin");
listView->setItemsMargin(itemMargin);
}
} }
}