From 3206727b9c9be8de0484910268c9d9c08b2d921f Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 26 Dec 2013 17:01:31 +0800 Subject: [PATCH 1/3] Modify actionnode --- cocos/editor-support/cocostudio/CCActionNode.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index 6074480b39..3b7da60ae4 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -151,10 +151,6 @@ void ActionNode::initActionNodeFromRoot(Object* root) { Node* rootNode = dynamic_cast(root); if (rootNode != NULL) - { - log("Need a definition of for gameObject"); - } - else { Widget* rootWidget = dynamic_cast(root); if (rootWidget != NULL) @@ -165,7 +161,7 @@ void ActionNode::initActionNodeFromRoot(Object* root) setObject(widget); } } - } + } } void ActionNode::setUnitTime(float fTime) From ad535e2fcbde0cbe899964fd6b4088a7affc48b0 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 26 Dec 2013 17:53:22 +0800 Subject: [PATCH 2/3] Add listview and pageview reader --- .../cocostudio/CCSGUIReader.cpp | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index bec3ea845c..091c3a674f 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -619,7 +619,7 @@ void WidgetPropertiesReader0250::setPropsForLabelAtlasFromJsonDictionary(Widget* const char* cmft = dicHelper->getStringValue_json(options, "charMapFile"); 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); } @@ -1025,7 +1025,18 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *dat Widget* child = widgetFromJsonDictionary(subData); if (child) { - widget->addChild(child); + if (dynamic_cast(widget)) + { + dynamic_cast(widget)->addPage(static_cast(child)); + } + else if (dynamic_cast(widget)) + { + dynamic_cast(widget)->pushBackCustomItem(child); + } + else + { + widget->addChild(child); + } } CC_SAFE_DELETE(subData); } @@ -1525,7 +1536,7 @@ void WidgetPropertiesReader0300::setPropsForLabelAtlasFromJsonDictionary(Widget* std::string tp_c = m_strFilePath; const char* cmfPath = dicHelper->getStringValue_json(cmftDic, "path"); 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; } case 1: @@ -1931,11 +1942,26 @@ void WidgetPropertiesReader0300::setPropsForLabelBMFontFromJsonDictionary(Widget void WidgetPropertiesReader0300::setPropsForPageViewFromJsonDictionary(Widget*widget,JsonDictionary* options) { - + setPropsForLayoutFromJsonDictionary(widget, options); } void WidgetPropertiesReader0300::setPropsForListViewFromJsonDictionary(Widget* widget, JsonDictionary* options) { + setPropsForLayoutFromJsonDictionary(widget, options); + ListView* listView = (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); } + } \ No newline at end of file From 26a7f3474c837c35d493af502b867481131a4e98 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 26 Dec 2013 21:02:47 +0800 Subject: [PATCH 3/3] Modify reader --- .../cocostudio/CCSGUIReader.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 091c3a674f..ef913c9c12 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1025,17 +1025,22 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *dat Widget* child = widgetFromJsonDictionary(subData); if (child) { - if (dynamic_cast(widget)) + PageView* pageView = dynamic_cast(widget); + if (pageView) { - dynamic_cast(widget)->addPage(static_cast(child)); - } - else if (dynamic_cast(widget)) - { - dynamic_cast(widget)->pushBackCustomItem(child); + pageView->addPage(static_cast(child)); } else { - widget->addChild(child); + ListView* listView = dynamic_cast(widget); + if (listView) + { + listView->pushBackCustomItem(child); + } + else + { + widget->addChild(child); + } } } CC_SAFE_DELETE(subData); @@ -1949,7 +1954,7 @@ void WidgetPropertiesReader0300::setPropsForListViewFromJsonDictionary(Widget* w { setPropsForLayoutFromJsonDictionary(widget, options); - ListView* listView = (ListView*)widget; + ListView* listView = static_cast(widget); float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight");