From 1f389d377960111f967788f5a4aafa126dadcb38 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Fri, 8 Nov 2013 18:43:06 +0800 Subject: [PATCH 01/28] Rename event interface --- cocos/gui/UICheckBox.cpp | 22 ++++---- cocos/gui/UICheckBox.h | 6 +-- cocos/gui/UIPageView.cpp | 18 +++---- cocos/gui/UIPageView.h | 6 +-- cocos/gui/UIScrollView.cpp | 50 +++++++++---------- cocos/gui/UIScrollView.h | 6 +-- cocos/gui/UISlider.cpp | 18 +++---- cocos/gui/UISlider.h | 6 +-- cocos/gui/UITextField.cpp | 30 +++++------ cocos/gui/UITextField.h | 6 +-- .../UICheckBoxTest/UICheckBoxTest.cpp | 2 +- .../UIPageViewTest/UIPageViewTest.cpp | 2 +- .../UISliderTest/UISliderTest.cpp | 4 +- .../UITextFieldTest/UITextFieldTest.cpp | 6 +-- 14 files changed, 91 insertions(+), 91 deletions(-) diff --git a/cocos/gui/UICheckBox.cpp b/cocos/gui/UICheckBox.cpp index e79be3d5f0..511d03a7ea 100644 --- a/cocos/gui/UICheckBox.cpp +++ b/cocos/gui/UICheckBox.cpp @@ -34,8 +34,8 @@ _frontCrossRenderer(NULL), _backGroundBoxDisabledRenderer(NULL), _frontCrossDisabledRenderer(NULL), _isSelected(true), -_selectedStateEventListener(NULL), -_selectedStateEventSelector(NULL), +_checkBoxEventListener(NULL), +_checkBoxEventSelector(NULL), _backGroundTexType(UI_TEX_TYPE_LOCAL), _backGroundSelectedTexType(UI_TEX_TYPE_LOCAL), _frontCrossTexType(UI_TEX_TYPE_LOCAL), @@ -51,8 +51,8 @@ _frontCrossDisabledFileName("") UICheckBox::~UICheckBox() { - _selectedStateEventListener = NULL; - _selectedStateEventSelector = NULL; + _checkBoxEventListener = NULL; + _checkBoxEventSelector = NULL; } UICheckBox* UICheckBox::create() @@ -285,24 +285,24 @@ bool UICheckBox::getSelectedState() void UICheckBox::selectedEvent() { - if (_selectedStateEventListener && _selectedStateEventSelector) + if (_checkBoxEventListener && _checkBoxEventSelector) { - (_selectedStateEventListener->*_selectedStateEventSelector)(this,CHECKBOX_STATE_EVENT_SELECTED); + (_checkBoxEventListener->*_checkBoxEventSelector)(this,CHECKBOX_STATE_EVENT_SELECTED); } } void UICheckBox::unSelectedEvent() { - if (_selectedStateEventListener && _selectedStateEventSelector) + if (_checkBoxEventListener && _checkBoxEventSelector) { - (_selectedStateEventListener->*_selectedStateEventSelector)(this,CHECKBOX_STATE_EVENT_UNSELECTED); + (_checkBoxEventListener->*_checkBoxEventSelector)(this,CHECKBOX_STATE_EVENT_UNSELECTED); } } -void UICheckBox::addEventListener(cocos2d::Object *target, SEL_SelectedStateEvent selector) +void UICheckBox::addEventListenerCheckBox(cocos2d::Object *target, SEL_SelectedStateEvent selector) { - _selectedStateEventListener = target; - _selectedStateEventSelector = selector; + _checkBoxEventListener = target; + _checkBoxEventSelector = selector; } void UICheckBox::setFlipX(bool flipX) diff --git a/cocos/gui/UICheckBox.h b/cocos/gui/UICheckBox.h index 5e9c836617..26562d2b8f 100644 --- a/cocos/gui/UICheckBox.h +++ b/cocos/gui/UICheckBox.h @@ -138,7 +138,7 @@ public: virtual void setAnchorPoint(const cocos2d::Point &pt); //add a call back function would called when checkbox is selected or unselected. - void addEventListener(cocos2d::Object* target,SEL_SelectedStateEvent selector); + void addEventListenerCheckBox(cocos2d::Object* target,SEL_SelectedStateEvent selector); //override "setFlipX" method of widget. virtual void setFlipX(bool flipX); @@ -190,8 +190,8 @@ protected: cocos2d::Sprite* _frontCrossDisabledRenderer; bool _isSelected; - cocos2d::Object* _selectedStateEventListener; - SEL_SelectedStateEvent _selectedStateEventSelector; + cocos2d::Object* _checkBoxEventListener; + SEL_SelectedStateEvent _checkBoxEventSelector; TextureResType _backGroundTexType; TextureResType _backGroundSelectedTexType; diff --git a/cocos/gui/UIPageView.cpp b/cocos/gui/UIPageView.cpp index 54b0713b7a..2183091b6d 100644 --- a/cocos/gui/UIPageView.cpp +++ b/cocos/gui/UIPageView.cpp @@ -42,8 +42,8 @@ _autoScrollDistance(0.0f), _autoScrollSpeed(0.0f), _autoScrollDir(0), _childFocusCancelOffset(5.0f), -_eventListener(NULL), -_eventSelector(NULL) +_pageViewEventListener(NULL), +_pageViewEventSelector(NULL) { } @@ -51,8 +51,8 @@ UIPageView::~UIPageView() { _pages->removeAllObjects(); CC_SAFE_RELEASE(_pages); - _eventListener = NULL; - _eventSelector = NULL; + _pageViewEventListener = NULL; + _pageViewEventSelector = NULL; } UIPageView* UIPageView::create() @@ -565,16 +565,16 @@ void UIPageView::interceptTouchEvent(int handleState, UIWidget *sender, const co void UIPageView::pageTurningEvent() { - if (_eventListener && _eventSelector) + if (_pageViewEventListener && _pageViewEventSelector) { - (_eventListener->*_eventSelector)(this, PAGEVIEW_EVENT_TURNING); + (_pageViewEventListener->*_pageViewEventSelector)(this, PAGEVIEW_EVENT_TURNING); } } -void UIPageView::addEventListener(cocos2d::Object *target, SEL_PageViewEvent selector) +void UIPageView::addEventListenerPageView(cocos2d::Object *target, SEL_PageViewEvent selector) { - _eventListener = target; - _eventSelector = selector; + _pageViewEventListener = target; + _pageViewEventSelector = selector; } int UIPageView::getCurPageIndex() const diff --git a/cocos/gui/UIPageView.h b/cocos/gui/UIPageView.h index ec78df8bbd..ef11056e9b 100644 --- a/cocos/gui/UIPageView.h +++ b/cocos/gui/UIPageView.h @@ -118,7 +118,7 @@ public: cocos2d::Array* getPages(); // event - void addEventListener(cocos2d::Object *target, SEL_PageViewEvent selector); + void addEventListenerPageView(cocos2d::Object *target, SEL_PageViewEvent selector); //override "removeChild" method of widget. @@ -186,8 +186,8 @@ protected: float _autoScrollSpeed; int _autoScrollDir; float _childFocusCancelOffset; - cocos2d::Object* _eventListener; - SEL_PageViewEvent _eventSelector; + cocos2d::Object* _pageViewEventListener; + SEL_PageViewEvent _pageViewEventSelector; }; diff --git a/cocos/gui/UIScrollView.cpp b/cocos/gui/UIScrollView.cpp index ebf32514da..e80bd3873c 100644 --- a/cocos/gui/UIScrollView.cpp +++ b/cocos/gui/UIScrollView.cpp @@ -69,15 +69,15 @@ _bouncing(false), _bounceDir(cocos2d::Point::ZERO), _bounceOriginalSpeed(0.0f), _inertiaScrollEnabled(true), -_eventListener(NULL), -_eventSelector(NULL) +_scrollViewEventListener(NULL), +_scrollViewEventSelector(NULL) { } UIScrollView::~UIScrollView() { - _eventListener = NULL; - _eventSelector = NULL; + _scrollViewEventListener = NULL; + _scrollViewEventSelector = NULL; } UIScrollView* UIScrollView::create() @@ -1458,80 +1458,80 @@ void UIScrollView::checkChildInfo(int handleState,UIWidget* sender,const cocos2d void UIScrollView::scrollToTopEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_TOP); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_TOP); } } void UIScrollView::scrollToBottomEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM); } } void UIScrollView::scrollToLeftEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_LEFT); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_LEFT); } } void UIScrollView::scrollToRightEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT); } } void UIScrollView::scrollingEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLLING); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_SCROLLING); } } void UIScrollView::bounceTopEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_TOP); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_TOP); } } void UIScrollView::bounceBottomEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_BOTTOM); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_BOTTOM); } } void UIScrollView::bounceLeftEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_LEFT); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_LEFT); } } void UIScrollView::bounceRightEvent() { - if (_eventListener && _eventSelector) + if (_scrollViewEventListener && _scrollViewEventSelector) { - (_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_RIGHT); + (_scrollViewEventListener->*_scrollViewEventSelector)(this, SCROLLVIEW_EVENT_BOUNCE_RIGHT); } } -void UIScrollView::addEventListener(cocos2d::Object *target, SEL_ScrollViewEvent selector) +void UIScrollView::addEventListenerScrollView(cocos2d::Object *target, SEL_ScrollViewEvent selector) { - _eventListener = target; - _eventSelector = selector; + _scrollViewEventListener = target; + _scrollViewEventSelector = selector; } void UIScrollView::setDirection(SCROLLVIEW_DIR dir) diff --git a/cocos/gui/UIScrollView.h b/cocos/gui/UIScrollView.h index 4d762930f8..94a6874376 100644 --- a/cocos/gui/UIScrollView.h +++ b/cocos/gui/UIScrollView.h @@ -231,7 +231,7 @@ public: /** * Add call back function called scrollview event triggered */ - void addEventListener(cocos2d::Object* target, SEL_ScrollViewEvent selector); + void addEventListenerScrollView(cocos2d::Object* target, SEL_ScrollViewEvent selector); //override "addChild" method of widget. virtual bool addChild(UIWidget* widget); @@ -382,8 +382,8 @@ protected: - cocos2d::Object* _eventListener; - SEL_ScrollViewEvent _eventSelector; + cocos2d::Object* _scrollViewEventListener; + SEL_ScrollViewEvent _scrollViewEventSelector; }; } diff --git a/cocos/gui/UISlider.cpp b/cocos/gui/UISlider.cpp index b5c90ccfb8..d8f2f95e86 100644 --- a/cocos/gui/UISlider.cpp +++ b/cocos/gui/UISlider.cpp @@ -46,8 +46,8 @@ _slidBallPressedTextureFile(""), _slidBallDisabledTextureFile(""), _capInsetsBarRenderer(cocos2d::Rect::ZERO), _capInsetsProgressBarRenderer(cocos2d::Rect::ZERO), -_slidPercentListener(NULL), -_slidPercentSelector(NULL), +_sliderEventListener(NULL), +_sliderEventSelector(NULL), _barTexType(UI_TEX_TYPE_LOCAL), _progressBarTexType(UI_TEX_TYPE_LOCAL), _ballNTexType(UI_TEX_TYPE_LOCAL), @@ -58,8 +58,8 @@ _ballDTexType(UI_TEX_TYPE_LOCAL) UISlider::~UISlider() { - _slidPercentListener = NULL; - _slidPercentSelector = NULL; + _sliderEventListener = NULL; + _sliderEventSelector = NULL; } UISlider* UISlider::create() @@ -411,17 +411,17 @@ float UISlider::getPercentWithBallPos(float px) return (((px-(-_barLength/2.0f))/_barLength)*100.0f); } -void UISlider::addEventListener(cocos2d::Object *target, SEL_SlidPercentChangedEvent selector) +void UISlider::addEventListenerSlider(cocos2d::Object *target, SEL_SlidPercentChangedEvent selector) { - _slidPercentListener = target; - _slidPercentSelector = selector; + _sliderEventListener = target; + _sliderEventSelector = selector; } void UISlider::percentChangedEvent() { - if (_slidPercentListener && _slidPercentSelector) + if (_sliderEventListener && _sliderEventSelector) { - (_slidPercentListener->*_slidPercentSelector)(this,SLIDER_PERCENTCHANGED); + (_sliderEventListener->*_sliderEventSelector)(this,SLIDER_PERCENTCHANGED); } } diff --git a/cocos/gui/UISlider.h b/cocos/gui/UISlider.h index 186af44d45..ff08ba1524 100644 --- a/cocos/gui/UISlider.h +++ b/cocos/gui/UISlider.h @@ -162,7 +162,7 @@ public: /** * Add call back function called when slider's percent has changed to slider. */ - void addEventListener(cocos2d::Object* target,SEL_SlidPercentChangedEvent selector); + void addEventListenerSlider(cocos2d::Object* target,SEL_SlidPercentChangedEvent selector); //override "onTouchBegan" method of widget. virtual bool onTouchBegan(const cocos2d::Point &touchPoint); @@ -226,8 +226,8 @@ protected: cocos2d::Rect _capInsetsBarRenderer; cocos2d::Rect _capInsetsProgressBarRenderer; - cocos2d::Object* _slidPercentListener; - SEL_SlidPercentChangedEvent _slidPercentSelector; + cocos2d::Object* _sliderEventListener; + SEL_SlidPercentChangedEvent _sliderEventSelector; TextureResType _barTexType; TextureResType _progressBarTexType; TextureResType _ballNTexType; diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index 6a95ac8605..75010d0261 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -275,16 +275,16 @@ _textFieldRenderer(NULL), _touchWidth(0.0f), _touchHeight(0.0f), _useTouchArea(false), -_eventListener(NULL), -_eventSelector(NULL), +_textFieldEventListener(NULL), +_textFieldEventSelector(NULL), _passwordStyleText("") { } UITextField::~UITextField() { - _eventListener = NULL; - _eventSelector = NULL; + _textFieldEventListener = NULL; + _textFieldEventSelector = NULL; } UITextField* UITextField::create() @@ -472,40 +472,40 @@ void UITextField::setDeleteBackward(bool deleteBackward) void UITextField::attachWithIMEEvent() { - if (_eventListener && _eventSelector) + if (_textFieldEventListener && _textFieldEventSelector) { - (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_ATTACH_WITH_IME); + (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_ATTACH_WITH_IME); } } void UITextField::detachWithIMEEvent() { - if (_eventListener && _eventSelector) + if (_textFieldEventListener && _textFieldEventSelector) { - (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DETACH_WITH_IME); + (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_DETACH_WITH_IME); } } void UITextField::insertTextEvent() { - if (_eventListener && _eventSelector) + if (_textFieldEventListener && _textFieldEventSelector) { - (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_INSERT_TEXT); + (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_INSERT_TEXT); } } void UITextField::deleteBackwardEvent() { - if (_eventListener && _eventSelector) + if (_textFieldEventListener && _textFieldEventSelector) { - (_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DELETE_BACKWARD); + (_textFieldEventListener->*_textFieldEventSelector)(this, TEXTFIELD_EVENT_DELETE_BACKWARD); } } -void UITextField::addEventListener(cocos2d::Object *target, SEL_TextFieldEvent selecor) +void UITextField::addEventListenerTextField(cocos2d::Object *target, SEL_TextFieldEvent selecor) { - _eventListener = target; - _eventSelector = selecor; + _textFieldEventListener = target; + _textFieldEventSelector = selecor; } void UITextField::setAnchorPoint(const cocos2d::Point &pt) diff --git a/cocos/gui/UITextField.h b/cocos/gui/UITextField.h index fc90ea9466..6a61faed08 100644 --- a/cocos/gui/UITextField.h +++ b/cocos/gui/UITextField.h @@ -132,7 +132,7 @@ public: void setInsertText(bool insertText); bool getDeleteBackward(); void setDeleteBackward(bool deleteBackward); - void addEventListener(cocos2d::Object* target, SEL_TextFieldEvent selecor); + void addEventListenerTextField(cocos2d::Object* target, SEL_TextFieldEvent selecor); virtual void setAnchorPoint(const cocos2d::Point &pt); virtual void setColor(const cocos2d::Color3B &color); @@ -163,8 +163,8 @@ protected: float _touchHeight; bool _useTouchArea; - cocos2d::Object* _eventListener; - SEL_TextFieldEvent _eventSelector; + cocos2d::Object* _textFieldEventListener; + SEL_TextFieldEvent _textFieldEventSelector; std::string _passwordStyleText; }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index 66b0c64a96..d28264ab46 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -54,7 +54,7 @@ bool UICheckBoxTest::init() "cocosgui/check_box_active_disable.png"); checkBox->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - checkBox->addEventListener(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent)); + checkBox->addEventListenerCheckBox(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent)); // checkBox->addSelectEvent(this, coco_selectselector(UICheckBoxTest::selectedEvent)); m_pUiLayer->addWidget(checkBox); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index ce5028ae35..309e9c2264 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -79,7 +79,7 @@ bool UIPageViewTest::init() pageView->addPage(layout); } - pageView->addEventListener(this, pagevieweventselector(UIPageViewTest::pageViewEvent)); + pageView->addEventListenerPageView(this, pagevieweventselector(UIPageViewTest::pageViewEvent)); m_pUiLayer->addWidget(pageView); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index 2749e061ab..cae91130ea 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -52,7 +52,7 @@ bool UISliderTest::init() slider->loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", ""); slider->loadProgressBarTexture("cocosgui/sliderProgress.png"); slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - slider->addEventListener(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent)); + slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent)); m_pUiLayer->addWidget(slider); return true; @@ -116,7 +116,7 @@ bool UISliderTest_Scale9::init() slider->setCapInsets(Rect(0, 0, 0, 0)); slider->setSize(Size(250, 10)); slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - slider->addEventListener(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent)); + slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent)); m_pUiLayer->addWidget(slider); return true; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp index c486c5be3a..34534d008a 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp @@ -51,7 +51,7 @@ bool UITextFieldTest::init() textField->setFontSize(30); textField->setPlaceHolder("input words here"); textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - textField->addEventListener(this, textfieldeventselector(UITextFieldTest::textFieldEvent)); + textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest::textFieldEvent)); m_pUiLayer->addWidget(textField); return true; @@ -139,7 +139,7 @@ bool UITextFieldTest_MaxLength::init() textField->setFontSize(30); textField->setPlaceHolder("input words here"); textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); - textField->addEventListener(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent)); + textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent)); m_pUiLayer->addWidget(textField); return true; @@ -233,7 +233,7 @@ bool UITextFieldTest_Password::init() textField->setFontSize(30); textField->setPlaceHolder("input password here"); textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f)); - textField->addEventListener(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent)); + textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent)); m_pUiLayer->addWidget(textField); return true; From 8a5084effa20f70f5199514e680f7907356cde05 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Fri, 8 Nov 2013 20:29:49 +0800 Subject: [PATCH 02/28] add list view event --- cocos/gui/UIListView.cpp | 45 +++++++++++++++++++++++++++++++++++++++- cocos/gui/UIListView.h | 17 +++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index 81baaad41d..3017d1e929 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -32,7 +32,10 @@ UIListView::UIListView(): _model(NULL), _items(NULL), _gravity(LISTVIEW_GRAVITY_CENTER_HORIZONTAL), -_itemsMargin(0.0f) +_itemsMargin(0.0f), +_listViewEventListener(NULL), +_listViewEventSelector(NULL), +_curSelectedIndex(0) { } @@ -41,6 +44,8 @@ UIListView::~UIListView() { _items->removeAllObjects(); CC_SAFE_RELEASE(_items); + _listViewEventListener = NULL; + _listViewEventSelector = NULL; } UIListView* UIListView::create() @@ -378,6 +383,44 @@ void UIListView::refreshView() updateInnerContainerSize(); doLayout(); } + +void UIListView::addEventListenerListView(cocos2d::Object *target, SEL_ListViewEvent selector) +{ + _listViewEventListener = target; + _listViewEventSelector = selector; +} + +void UIListView::selectedItemEvent() +{ + if (_listViewEventListener && _listViewEventSelector) + { + (_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECEDTITEM); + } +} + +void UIListView::interceptTouchEvent(int handleState, gui::UIWidget *sender, const cocos2d::Point &touchPoint) +{ + UIScrollView::interceptTouchEvent(handleState, sender, touchPoint); + if (handleState != 1) + { + UIWidget* parent = sender; + while (parent) + { + if (parent && parent->getParent() == _innerContainer) + { + _curSelectedIndex = getIndex(parent); + break; + } + parent = parent->getParent(); + } + selectedItemEvent(); + } +} + +int UIListView::getCurSelectedIndex() const +{ + return _curSelectedIndex; +} void UIListView::onSizeChanged() { diff --git a/cocos/gui/UIListView.h b/cocos/gui/UIListView.h index c78d06ace2..42fd7f15be 100644 --- a/cocos/gui/UIListView.h +++ b/cocos/gui/UIListView.h @@ -40,6 +40,14 @@ typedef enum LISTVIEW_GRAVITY_BOTTOM, LISTVIEW_GRAVITY_CENTER_VERTICAL, }ListViewGravity; + +typedef enum +{ + LISTVIEW_ONSELECEDTITEM +}ListViewEventType; + +typedef void (cocos2d::Object::*SEL_ListViewEvent)(cocos2d::Object*,ListViewEventType); +#define listvieweventselector(_SELECTOR) (SEL_ListViewEvent)(&_SELECTOR) class UIListView : public UIScrollView { @@ -145,6 +153,10 @@ public: */ void refreshView(); + int getCurSelectedIndex() const; + + void addEventListenerListView(cocos2d::Object* target, SEL_ListViewEvent selector); + /** * Changes scroll direction of scrollview. * @@ -164,12 +176,17 @@ protected: virtual UIWidget* createCloneInstance(); virtual void copySpecialProperties(UIWidget* model); virtual void copyClonedWidgetChildren(UIWidget* model); + void selectedItemEvent(); + virtual void interceptTouchEvent(int handleState,UIWidget* sender,const cocos2d::Point &touchPoint); protected: UIWidget* _model; cocos2d::Array* _items; ListViewGravity _gravity; float _itemsMargin; + cocos2d::Object* _listViewEventListener; + SEL_ListViewEvent _listViewEventSelector; + int _curSelectedIndex; }; } From a0f794b7df92d3b17ad0bda3f572afb590882213 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Fri, 8 Nov 2013 23:26:44 +0800 Subject: [PATCH 03/28] optimize layout --- cocos/gui/UILayout.cpp | 12 +++++++++++- cocos/gui/UIListView.cpp | 1 - cocos/gui/UIWidget.h | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 70b66a0b56..84c65232d7 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -129,7 +129,17 @@ void UILayout::setClippingEnabled(bool able) void UILayout::onSizeChanged() { DYNAMIC_CAST_CLIPPINGLAYER->setClippingSize(_size); - doLayout(); + if (strcmp(getDescription(), "Layout") == 0) + { + cocos2d::ccArray* arrayChildren = _children->data; + int length = arrayChildren->num; + for (int i=0; iarr[i]; + child->updateSizeAndPosition(); + } + doLayout(); + } if (_backGroundImage) { _backGroundImage->setPosition(cocos2d::Point(_size.width/2.0f, _size.height/2.0f)); diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index 3017d1e929..c6e076821d 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -381,7 +381,6 @@ void UIListView::refreshView() remedyLayoutParameter(item); } updateInnerContainerSize(); - doLayout(); } void UIListView::addEventListenerListView(cocos2d::Object *target, SEL_ListViewEvent selector) diff --git a/cocos/gui/UIWidget.h b/cocos/gui/UIWidget.h index 02db42e731..741d580fee 100644 --- a/cocos/gui/UIWidget.h +++ b/cocos/gui/UIWidget.h @@ -881,6 +881,8 @@ public: virtual void onEnter(); virtual void onExit(); + void updateSizeAndPosition(); + virtual Object* getUserObject() { return _userObject; } /** * @js NA @@ -926,7 +928,6 @@ protected: void cancelUpEvent(); void longClickEvent(); void updateAnchorPoint(); - void updateSizeAndPosition(); void copyProperties(UIWidget* model); virtual UIWidget* createCloneInstance(); virtual void copySpecialProperties(UIWidget* model); From c4e70387f7395f7161a3f7b3293f4218787b809a Mon Sep 17 00:00:00 2001 From: psi Date: Sat, 9 Nov 2013 23:02:45 +0900 Subject: [PATCH 04/28] Close display --- cocos/2d/platform/linux/CCDevice.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/platform/linux/CCDevice.cpp b/cocos/2d/platform/linux/CCDevice.cpp index 8c4d97ecd2..3b3c962413 100644 --- a/cocos/2d/platform/linux/CCDevice.cpp +++ b/cocos/2d/platform/linux/CCDevice.cpp @@ -24,6 +24,7 @@ int Device::getDPI() ((double) DisplayWidthMM(dpy,scr))); dpi = (int) (xres + 0.5); //printf("dpi = %d\n", dpi); + XCloseDisplay (dpy); } return dpi; } From 5e36021d54ecd0d08aaae6c8d1919246e1db72e6 Mon Sep 17 00:00:00 2001 From: "Lee, Jae-Hong" Date: Sat, 9 Nov 2013 23:44:15 +0900 Subject: [PATCH 05/28] [Win32] fix argument type. - argument of interface is a long type. --- cocos/2d/platform/win32/CCFileUtilsWin32.cpp | 2 +- cocos/2d/platform/win32/CCFileUtilsWin32.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp index a5c94dac90..216797bd9e 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp @@ -121,7 +121,7 @@ bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const return false; } -unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mode, unsigned long* size) +unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mode, long* size) { unsigned char * pBuffer = NULL; CCASSERT(filename != NULL && size != NULL && mode != NULL, "Invalid parameters."); diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.h b/cocos/2d/platform/win32/CCFileUtilsWin32.h index 4f01adabeb..5c88d97cf9 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.h +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.h @@ -58,7 +58,7 @@ protected: * @return Upon success, a pointer to the data is returned, otherwise NULL. * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ - virtual unsigned char* getFileData(const char* filename, const char* mode, unsigned long * size) override; + virtual unsigned char* getFileData(const char* filename, const char* mode, long * size) override; /** * Gets full path for filename, resolution directory and search path. From 3d23ca328ee0629cd95aff366134ede33e62f92f Mon Sep 17 00:00:00 2001 From: "Lee, Jae-Hong" Date: Sat, 9 Nov 2013 23:56:24 +0900 Subject: [PATCH 06/28] [Win32] fix compile error. - fix C2552 error in VS2012. --- cocos/gui/UILayout.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 70b66a0b56..a7af98c1b8 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -953,7 +953,7 @@ bool UIRectClippingNode::init() rect[2] = cocos2d::Point(_clippingSize.width, _clippingSize.height); rect[3] = cocos2d::Point(0, _clippingSize.height); - cocos2d::Color4F green = {0, 1, 0, 1}; + cocos2d::Color4F green(0, 1, 0, 1); _innerStencil->drawPolygon(rect, 4, green, 0, green); if (cocos2d::ClippingNode::init(_innerStencil)) { @@ -971,7 +971,7 @@ void UIRectClippingNode::setClippingSize(const cocos2d::Size &size) rect[1] = cocos2d::Point(_clippingSize.width, 0); rect[2] = cocos2d::Point(_clippingSize.width, _clippingSize.height); rect[3] = cocos2d::Point(0, _clippingSize.height); - cocos2d::Color4F green = {0, 1, 0, 1}; + cocos2d::Color4F green(0, 1, 0, 1); _innerStencil->clear(); _innerStencil->drawPolygon(rect, 4, green, 0, green); } From e132142689e84e3caba7122902cdf426f0730e8e Mon Sep 17 00:00:00 2001 From: "Lee, Jae-Hong" Date: Sat, 9 Nov 2013 23:57:18 +0900 Subject: [PATCH 07/28] [Win32] Update libGUI project - Update files list. --- cocos/gui/proj.win32/libGUI.vcxproj | 10 +++---- cocos/gui/proj.win32/libGUI.vcxproj.filters | 30 +++++++++------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/cocos/gui/proj.win32/libGUI.vcxproj b/cocos/gui/proj.win32/libGUI.vcxproj index b225eaa127..2712ae3900 100644 --- a/cocos/gui/proj.win32/libGUI.vcxproj +++ b/cocos/gui/proj.win32/libGUI.vcxproj @@ -12,11 +12,8 @@ - - - @@ -24,7 +21,9 @@ + + @@ -37,11 +36,8 @@ - - - @@ -49,7 +45,9 @@ + + diff --git a/cocos/gui/proj.win32/libGUI.vcxproj.filters b/cocos/gui/proj.win32/libGUI.vcxproj.filters index 12f0d385ab..092f28f7e0 100644 --- a/cocos/gui/proj.win32/libGUI.vcxproj.filters +++ b/cocos/gui/proj.win32/libGUI.vcxproj.filters @@ -24,9 +24,6 @@ UIWidgets\ScrollWidget - - UIWidgets\ScrollWidget - UIWidgets\ScrollWidget @@ -72,12 +69,6 @@ System - - Layouts - - - Layouts - Layouts @@ -87,14 +78,17 @@ BaseClasses + + Layouts + + + Layouts + UIWidgets\ScrollWidget - - UIWidgets\ScrollWidget - UIWidgets\ScrollWidget @@ -140,12 +134,6 @@ System - - Layouts - - - Layouts - Layouts @@ -155,5 +143,11 @@ BaseClasses + + Layouts + + + Layouts + \ No newline at end of file From ef92efcd79ec1823f5264ec36486af346cf49c78 Mon Sep 17 00:00:00 2001 From: bopohaa Date: Mon, 11 Nov 2013 02:28:27 +0300 Subject: [PATCH 08/28] Update CCImageCommon_cpp.h webp don't work for me --- cocos/2d/platform/CCImageCommon_cpp.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index f2fc7a9a08..bf1f856e39 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -1737,12 +1737,12 @@ bool Image::initWithWebpData(const unsigned char * data, int dataLen) _width = config.input.width; _height = config.input.height; - int bufferSize = _width * _height * 4; - _data = new unsigned char[bufferSize]; + _dataLen = _width * _height * 4; + _data = new unsigned char[_dataLen]; config.output.u.RGBA.rgba = static_cast(_data); config.output.u.RGBA.stride = _width * 4; - config.output.u.RGBA.size = bufferSize; + config.output.u.RGBA.size = _dataLen; config.output.is_external_memory = 1; if (WebPDecode(static_cast(data), dataLen, &config) != VP8_STATUS_OK) From 0a72c3c1c2af1f3d5e9d25ff82c682b6d1ded766 Mon Sep 17 00:00:00 2001 From: 2youyou2 <501251991@qq.com> Date: Mon, 11 Nov 2013 13:33:47 +0800 Subject: [PATCH 09/28] 1.when add a skin to last index, applay it's skindata to the previous skindata 2.Do not retain target when regist frame event and movement event --- .../cocostudio/CCArmatureAnimation.cpp | 17 ++------------ .../cocostudio/CCDisplayManager.cpp | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index 49aa8e1c6f..f3e5199d6c 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -69,9 +69,6 @@ ArmatureAnimation::~ArmatureAnimation(void) { CC_SAFE_RELEASE_NULL(_tweenList); CC_SAFE_RELEASE_NULL(_animationData); - - CC_SAFE_RELEASE_NULL(_movementEventTarget); - CC_SAFE_RELEASE_NULL(_frameEventTarget); } bool ArmatureAnimation::init(Armature *armature) @@ -423,23 +420,13 @@ std::string ArmatureAnimation::getCurrentMovementID() const void ArmatureAnimation::setMovementEventCallFunc(Object *target, SEL_MovementEventCallFunc callFunc) { - if (target != _movementEventTarget) - { - CC_SAFE_RETAIN(target); - CC_SAFE_RELEASE_NULL(_movementEventTarget); - _movementEventTarget = target; - } + _movementEventTarget = target; _movementEventCallFunc = callFunc; } void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCallFunc callFunc) { - if (target != _frameEventTarget) - { - CC_SAFE_RETAIN(target); - CC_SAFE_RELEASE_NULL(_frameEventTarget); - _frameEventTarget = target; - } + _frameEventTarget = target; _frameEventCallFunc = callFunc; } diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.cpp b/cocos/editor-support/cocostudio/CCDisplayManager.cpp index a8c8f5d760..6bcf7eaff3 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayManager.cpp @@ -142,8 +142,26 @@ void DisplayManager::addDisplay(Node *display, int index) } else { - BaseData baseData; - skin->setSkinData(baseData); + bool find = false; + + for (int i = _decoDisplayList->count()-2; i>=0; i--) + { + DecorativeDisplay *dd = static_cast(_decoDisplayList->objectAtIndex(i)); + SpriteDisplayData *spriteDisplayData = static_cast(dd->getDisplayData()); + if (spriteDisplayData) + { + find = true; + skin->setSkinData(spriteDisplayData->skinData); + static_cast(displayData)->skinData = spriteDisplayData->skinData; + break; + } + } + + if (!find) + { + BaseData baseData; + skin->setSkinData(baseData); + } } } else if (dynamic_cast(display)) From 5ba1e4ce105518dea858fe3d1679050e48c6a146 Mon Sep 17 00:00:00 2001 From: yinkaile Date: Mon, 11 Nov 2013 14:50:30 +0800 Subject: [PATCH 10/28] 1.remove compiler wornings 2.change void Bone::removeFromParent(bool recursion); to void Bone::removeFromParent(); --- .../editor-support/cocostudio/CCArmature.cpp | 2 +- .../cocostudio/CCArmatureAnimation.cpp | 2 +- .../cocostudio/CCArmatureAnimation.h | 1 + cocos/editor-support/cocostudio/CCBone.cpp | 19 +++++++--------- cocos/editor-support/cocostudio/CCBone.h | 5 ++--- .../cocostudio/CCDataReaderHelper.cpp | 13 +++++------ cocos/editor-support/cocostudio/CCDatas.h | 22 ++++++------------- .../cocostudio/CCProcessBase.cpp | 2 +- .../editor-support/cocostudio/CCProcessBase.h | 3 +-- cocos/editor-support/cocostudio/CCTween.cpp | 2 +- cocos/editor-support/cocostudio/CCTween.h | 1 + 11 files changed, 30 insertions(+), 42 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index b09922ff70..0e19914954 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -289,7 +289,7 @@ void Armature::removeBone(Bone *bone, bool recursion) CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!"); bone->setArmature(nullptr); - bone->removeFromParent(recursion); + bone->removeFromParent(); if (_topBoneList->containsObject(bone)) { diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index 49aa8e1c6f..47a475d34a 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -208,7 +208,7 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura loop = (loop < 0) ? _movementData->loop : loop; - ProcessBase::play((void *)animationName, durationTo, durationTween, loop, tweenEasing); + ProcessBase::play(durationTo, durationTween, loop, tweenEasing); if (_rawDuration == 0) diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.h b/cocos/editor-support/cocostudio/CCArmatureAnimation.h index 8d306398e9..ffc9401dda 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.h +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.h @@ -100,6 +100,7 @@ public: //! The animation update speed virtual void setAnimationInternal(float animationInternal); + using ProcessBase::play; /** * Play animation by animation name. * diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index cbd4544120..17541e2e78 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -322,19 +322,16 @@ void Bone::addChildBone(Bone *child) } } -void Bone::removeChildBone(Bone *bone, bool recursion) +void Bone::removeChildBone(Bone *bone) { if (_children && _children->getIndexOfObject(bone) != UINT_MAX ) { - if(recursion) - { - Array *ccbones = bone->_children; + Array *ccbones = bone->_children; - for(auto object : *ccbones) - { - Bone *ccBone = (Bone *)object; - bone->removeChildBone(ccBone, recursion); - } + for(auto object : *ccbones) + { + Bone *ccBone = (Bone *)object; + bone->removeChildBone(ccBone); } bone->setParentBone(nullptr); @@ -345,11 +342,11 @@ void Bone::removeChildBone(Bone *bone, bool recursion) } } -void Bone::removeFromParent(bool recursion) +void Bone::removeFromParent() { if (nullptr != _parentBone) { - _parentBone->removeChildBone(this, recursion); + _parentBone->removeChildBone(this); } } diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index 4d67c41e2e..17dc334c34 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -114,15 +114,14 @@ public: /** * Remove itself from its parent. - * @param recursion whether or not to remove childBone's display */ - void removeFromParent(bool recursion); + void removeFromParent(); /** * Removes a child Bone * @param bone the bone you want to remove */ - void removeChildBone(Bone *bone, bool recursion); + void removeChildBone(Bone *bone); void update(float delta) override; diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index defb268ada..45c5d85d41 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -595,10 +595,10 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML if (parentName) { parentXML = armatureXML->FirstChildElement(BONE); - std::string name = parentName; + std::string parentNameStr = parentName; while (parentXML) { - if (name.compare(parentXML->Attribute(A_NAME)) == 0) + if (parentNameStr.compare(parentXML->Attribute(A_NAME)) == 0) { break; } @@ -823,7 +823,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov } int length = 0; - int i = 0; + int index = 0; int parentTotalDuration = 0; int currentDuration = 0; @@ -864,13 +864,12 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov /* * in this loop we get the corresponding parent frame xml */ - while(i < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true)) + while(index < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true)) { - parentFrameXML = parentXmlList[i]; + parentFrameXML = parentXmlList[index]; parentTotalDuration += currentDuration; parentFrameXML->QueryIntAttribute(A_DURATION, ¤tDuration); - i++; - + index++; } } diff --git a/cocos/editor-support/cocostudio/CCDatas.h b/cocos/editor-support/cocostudio/CCDatas.h index 4b9c2feca6..065726472e 100644 --- a/cocos/editor-support/cocostudio/CCDatas.h +++ b/cocos/editor-support/cocostudio/CCDatas.h @@ -163,10 +163,8 @@ public: */ virtual ~SpriteDisplayData(); - inline void setParam(const char *displayName) - { - this->displayName = displayName; - } + void setParam(const char *pszDisplayName) { this->displayName = pszDisplayName; } + void copy(SpriteDisplayData *displayData); public: /** @@ -197,10 +195,7 @@ public: */ virtual ~ArmatureDisplayData(); - inline void setParam(const char *displayName) - { - this->displayName = displayName; - } + void setParam(const char *pszDisplayName) { this->displayName = pszDisplayName; } void copy(ArmatureDisplayData *displayData); public: /** @@ -230,10 +225,7 @@ public: */ virtual ~ParticleDisplayData() {}; - void setParam(const char *plist) - { - this->plist = plist; - } + void setParam(const char *pszPlistName) { this->plist = pszPlistName; } void copy(ParticleDisplayData *displayData); public: @@ -478,10 +470,10 @@ public: struct ContourVertex2 : public cocos2d::Object { - ContourVertex2(float x, float y) + ContourVertex2(float xx, float yy) { - this->x = x; - this->y = y; + this->x = xx; + this->y = yy; } float x; diff --git a/cocos/editor-support/cocostudio/CCProcessBase.cpp b/cocos/editor-support/cocostudio/CCProcessBase.cpp index 62bac419b6..f13769e3f7 100644 --- a/cocos/editor-support/cocostudio/CCProcessBase.cpp +++ b/cocos/editor-support/cocostudio/CCProcessBase.cpp @@ -77,7 +77,7 @@ void ProcessBase::stop() _currentPercent = 0; } -void ProcessBase::play(void *animation, int durationTo, int durationTween, int loop, int tweenEasing) +void ProcessBase::play(int durationTo, int durationTween, int loop, int tweenEasing) { _isComplete = false; _isPause = false; diff --git a/cocos/editor-support/cocostudio/CCProcessBase.h b/cocos/editor-support/cocostudio/CCProcessBase.h index 2b3ef4ab47..e763616c38 100644 --- a/cocos/editor-support/cocostudio/CCProcessBase.h +++ b/cocos/editor-support/cocostudio/CCProcessBase.h @@ -63,7 +63,6 @@ public: /** * Play animation by animation name. * - * @param animation It will not used in the ProcessBase Class * @param durationTo The frames between two animation changing-over. * It's meaning is changing to this animation need how many frames * @@ -88,7 +87,7 @@ public: * 2 : fade in and out * */ - virtual void play(void *animation, int durationTo, int durationTween, int loop, int tweenEasing); + virtual void play(int durationTo, int durationTween, int loop, int tweenEasing); /** * Pause the Process diff --git a/cocos/editor-support/cocostudio/CCTween.cpp b/cocos/editor-support/cocostudio/CCTween.cpp index dec84bf295..953ea34583 100644 --- a/cocos/editor-support/cocostudio/CCTween.cpp +++ b/cocos/editor-support/cocostudio/CCTween.cpp @@ -98,7 +98,7 @@ bool Tween::init(Bone *bone) void Tween::play(MovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing) { - ProcessBase::play(nullptr, durationTo, durationTween, loop, tweenEasing); + ProcessBase::play(durationTo, durationTween, loop, tweenEasing); if (loop) { diff --git a/cocos/editor-support/cocostudio/CCTween.h b/cocos/editor-support/cocostudio/CCTween.h index 8b4dcba9d2..ab8bb3f7ff 100644 --- a/cocos/editor-support/cocostudio/CCTween.h +++ b/cocos/editor-support/cocostudio/CCTween.h @@ -59,6 +59,7 @@ public: */ virtual bool init(Bone *bone); + using ProcessBase::play; /** * Start the Process * From 677cf0035553e06606ad4799022cda19f92b328c Mon Sep 17 00:00:00 2001 From: yinkaile Date: Mon, 11 Nov 2013 15:29:24 +0800 Subject: [PATCH 11/28] fix compiler warning --- .../editor-support/cocostudio/CCArmature.cpp | 2 +- cocos/editor-support/cocostudio/CCBone.cpp | 19 +++++++++++-------- cocos/editor-support/cocostudio/CCBone.h | 6 ++++-- .../cocostudio/CCDisplayManager.cpp | 10 +++++----- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 0e19914954..b09922ff70 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -289,7 +289,7 @@ void Armature::removeBone(Bone *bone, bool recursion) CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!"); bone->setArmature(nullptr); - bone->removeFromParent(); + bone->removeFromParent(recursion); if (_topBoneList->containsObject(bone)) { diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index 17541e2e78..cbd4544120 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -322,16 +322,19 @@ void Bone::addChildBone(Bone *child) } } -void Bone::removeChildBone(Bone *bone) +void Bone::removeChildBone(Bone *bone, bool recursion) { if (_children && _children->getIndexOfObject(bone) != UINT_MAX ) { - Array *ccbones = bone->_children; - - for(auto object : *ccbones) + if(recursion) { - Bone *ccBone = (Bone *)object; - bone->removeChildBone(ccBone); + Array *ccbones = bone->_children; + + for(auto object : *ccbones) + { + Bone *ccBone = (Bone *)object; + bone->removeChildBone(ccBone, recursion); + } } bone->setParentBone(nullptr); @@ -342,11 +345,11 @@ void Bone::removeChildBone(Bone *bone) } } -void Bone::removeFromParent() +void Bone::removeFromParent(bool recursion) { if (nullptr != _parentBone) { - _parentBone->removeChildBone(this); + _parentBone->removeChildBone(this, recursion); } } diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index 17dc334c34..8a603c1ad3 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -112,16 +112,18 @@ public: */ Bone *getParentBone(); + using Node::removeFromParent; /** * Remove itself from its parent. + * @param recursion whether or not to remove childBone's display */ - void removeFromParent(); + void removeFromParent(bool recursion); /** * Removes a child Bone * @param bone the bone you want to remove */ - void removeChildBone(Bone *bone); + void removeChildBone(Bone *bone, bool recursion); void update(float delta) override; diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.cpp b/cocos/editor-support/cocostudio/CCDisplayManager.cpp index 6bcf7eaff3..3c502f2fe7 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayManager.cpp @@ -146,13 +146,13 @@ void DisplayManager::addDisplay(Node *display, int index) for (int i = _decoDisplayList->count()-2; i>=0; i--) { - DecorativeDisplay *dd = static_cast(_decoDisplayList->objectAtIndex(i)); - SpriteDisplayData *spriteDisplayData = static_cast(dd->getDisplayData()); - if (spriteDisplayData) + DecorativeDisplay *dd = static_cast(_decoDisplayList->getObjectAtIndex(i)); + SpriteDisplayData *sdd = static_cast(dd->getDisplayData()); + if (sdd) { find = true; - skin->setSkinData(spriteDisplayData->skinData); - static_cast(displayData)->skinData = spriteDisplayData->skinData; + skin->setSkinData(sdd->skinData); + static_cast(displayData)->skinData = sdd->skinData; break; } } From 528c257497d23a84f14858f24fde0a2bd0a4b5ca Mon Sep 17 00:00:00 2001 From: 2youyou2 <501251991@qq.com> Date: Mon, 11 Nov 2013 17:30:37 +0800 Subject: [PATCH 12/28] add setUserObject method to CCArmatureAnimation --- .../cocostudio/CCArmatureAnimation.cpp | 10 ++++++ .../cocostudio/CCArmatureAnimation.h | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index f3e5199d6c..274a68342f 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -56,6 +56,7 @@ ArmatureAnimation::ArmatureAnimation() , _toIndex(0) , _tweenList(nullptr) , _ignoreFrameEvent(false) + , _userObject(nullptr) , _movementEventCallFunc(nullptr) , _frameEventCallFunc(nullptr) @@ -69,6 +70,8 @@ ArmatureAnimation::~ArmatureAnimation(void) { CC_SAFE_RELEASE_NULL(_tweenList); CC_SAFE_RELEASE_NULL(_animationData); + + CC_SAFE_RELEASE_NULL(_userObject); } bool ArmatureAnimation::init(Armature *armature) @@ -430,6 +433,13 @@ void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCall _frameEventCallFunc = callFunc; } +void ArmatureAnimation::setUserObject(Object *pUserObject) +{ + CC_SAFE_RETAIN(pUserObject); + CC_SAFE_RELEASE(_userObject); + _userObject = pUserObject; +} + void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex) { if (_frameEventTarget && _frameEventCallFunc) diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.h b/cocos/editor-support/cocostudio/CCArmatureAnimation.h index 8d306398e9..7b9e9821ab 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.h +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.h @@ -202,6 +202,35 @@ public: } } virtual AnimationData *getAnimationData() const { return _animationData; } + + + /** + * Returns a user assigned Object + * + * Similar to userData, but instead of holding a void* it holds an object + * + * @return A user assigned Object + * @js NA + * @lua NA + */ + virtual Object* getUserObject() { return _userObject; } + /** + * @js NA + * @lua NA + */ + virtual const Object* getUserObject() const { return _userObject; } + + /** + * Returns a user assigned Object + * + * Similar to UserData, but instead of holding a void* it holds an object. + * The UserObject will be retained once in this method, + * and the previous UserObject (if existed) will be relese. + * The UserObject will be released in Node's destructure. + * + * @param userObject A user assigned Object + */ + virtual void setUserObject(Object *userObject); protected: /** @@ -242,6 +271,8 @@ protected: bool _ignoreFrameEvent; std::queue _frameEventQueue; + + cocos2d::Object *_userObject; protected: /** * MovementEvent CallFunc. From 4f76141c415cf550f51cece19de1d9fee1af1600 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Mon, 11 Nov 2013 18:22:14 +0800 Subject: [PATCH 13/28] optimize guireader --- .../cocostudio/CCSGUIReader.cpp | 2933 +++++++++-------- .../editor-support/cocostudio/CCSGUIReader.h | 103 +- .../CocoStudioGUITest/UIScene.cpp | 2 +- 3 files changed, 1692 insertions(+), 1346 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 3ad788b563..ca1067e504 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -34,36 +34,36 @@ namespace cocostudio { -static CCSGUIReader* sharedReader = NULL; +static GUIReader* sharedReader = NULL; -CCSGUIReader::CCSGUIReader(): -m_strFilePath(""), -m_bOlderVersion(false) +GUIReader::GUIReader(): +m_strFilePath("") { - _fileDesignSizes = Dictionary::create(); + _fileDesignSizes = CCDictionary::create(); CC_SAFE_RETAIN(_fileDesignSizes); } -CCSGUIReader::~CCSGUIReader() +GUIReader::~GUIReader() { + _fileDesignSizes->removeAllObjects(); CC_SAFE_RELEASE(_fileDesignSizes); } -CCSGUIReader* CCSGUIReader::shareReader() +GUIReader* GUIReader::shareReader() { if (!sharedReader) { - sharedReader = new CCSGUIReader(); + sharedReader = new GUIReader(); } return sharedReader; } -void CCSGUIReader::purgeCCSGUIReader() +void GUIReader::purgeGUIReader() { - CC_SAFE_DELETE(sharedReader); + CC_SAFE_DELETE(sharedReader); } -int CCSGUIReader::getVersionInteger(const char *str) +int GUIReader::getVersionInteger(const char *str) { /*********temp***********/ std::string strVersion = str; @@ -98,11 +98,132 @@ int CCSGUIReader::getVersionInteger(const char *str) /************************/ } -UIWidget* CCSGUIReader::widgetFromJsonDictionary(JsonDictionary* data) +void GUIReader::storeFileDesignSize(const char *fileName, const cocos2d::Size &size) { + if (!_fileDesignSizes) + { + return; + } + cocos2d::String* strSize = cocos2d::String::createWithFormat("{%f,%f}", size.width, size.height); + _fileDesignSizes->setObject(strSize, fileName); +} + +const cocos2d::Size GUIReader::getFileDesignSize(const char* fileName) const +{ + if (!_fileDesignSizes) + { + return cocos2d::Size::ZERO; + } + cocos2d::Size designSize = cocos2d::SizeFromString(((cocos2d::String*)_fileDesignSizes->objectForKey(fileName))->_string.c_str()); + return designSize; +} + + +UIWidget* GUIReader::widgetFromJsonFile(const char *fileName) +{ + DictionaryHelper* dicHelper = DICTOOL; + const char *des = NULL; + std::string jsonpath; + JsonDictionary *jsonDict = NULL; + jsonpath = CCFileUtils::getInstance()->fullPathForFilename(fileName); + int pos = jsonpath.find_last_of('/'); + m_strFilePath = jsonpath.substr(0,pos+1); + long size = 0; + des = (char*)(CCFileUtils::getInstance()->getFileData(jsonpath.c_str(),"r" , &size)); + if(NULL == des || strcmp(des, "") == 0) + { + printf("read json file[%s] error!\n", fileName); + return NULL; + } + std::string strDes(des); + jsonDict = new JsonDictionary(); + jsonDict->initWithDescription(strDes.c_str()); + UIWidget* widget = NULL; - const char* classname = DICTOOL->getStringValue_json(data, "classname"); - JsonDictionary* uiOptions = DICTOOL->getSubDictionary_json(data, "options"); + const char* fileVersion = dicHelper->getStringValue_json(jsonDict, "version"); + WidgetPropertiesReader * pReader = NULL; + if (fileVersion) + { + int versionInteger = getVersionInteger(fileVersion); + if (versionInteger < 250) + { + pReader = new WidgetPropertiesReader0250(); + widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName); + } + else + { + pReader = new WidgetPropertiesReader0300(); + widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName); + } + } + else + { + pReader = new WidgetPropertiesReader0250(); + widget = pReader->createWidget(jsonDict, m_strFilePath.c_str(), fileName); + } + + CC_SAFE_DELETE(pReader); + CC_SAFE_DELETE(jsonDict); + CC_SAFE_DELETE_ARRAY(des); + return widget; +} + + + +UIWidget* WidgetPropertiesReader0250::createWidget(JsonDictionary* data, const char* fullPath, const char* fileName) +{ + m_strFilePath = fullPath; + DictionaryHelper* dicHelper = DICTOOL; + int texturesCount = dicHelper->getArrayCount_json(data, "textures"); + + for (int i=0; igetStringValueFromArray_json(data, "textures", i); + std::string tp = fullPath; + tp.append(file); + CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(tp.c_str()); + } + float fileDesignWidth = dicHelper->getFloatValue_json(data, "designWidth"); + float fileDesignHeight = dicHelper->getFloatValue_json(data, "designHeight"); + if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { + printf("Read design size error!\n"); + Size winSize = Director::getInstance()->getWinSize(); + GUIReader::shareReader()->storeFileDesignSize(fileName, winSize); + } + else + { + GUIReader::shareReader()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight)); + } + JsonDictionary* widgetTree = dicHelper->getSubDictionary_json(data, "widgetTree"); + UIWidget* widget = widgetFromJsonDictionary(widgetTree); + + /* *********temp********* */ + if (widget->getContentSize().equals(Size::ZERO)) + { + UILayout* rootWidget = dynamic_cast(widget); + rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); + } + /* ********************** */ + + // widget->setFileDesignSize(Size(fileDesignWidth, fileDesignHeight)); + JsonDictionary* actions = dicHelper->getSubDictionary_json(data, "animation"); + /* *********temp********* */ + // ActionManager::shareManager()->releaseActions(); + /* ********************** */ + CCLOG("file name == [%s]",fileName); + Object* rootWidget = (Object*) widget; + ActionManagerEx::shareManager()->initWithDictionary(fileName,actions,rootWidget); + CC_SAFE_DELETE(widgetTree); + CC_SAFE_DELETE(actions); + return widget; +} + +UIWidget* WidgetPropertiesReader0250::widgetFromJsonDictionary(JsonDictionary *data) +{ + DictionaryHelper* dicHelper = DICTOOL; + UIWidget* widget = NULL; + const char* classname = dicHelper->getStringValue_json(data, "classname"); + JsonDictionary* uiOptions = dicHelper->getSubDictionary_json(data, "options"); if (classname && strcmp(classname, "Button") == 0) { widget = UIButton::create(); @@ -134,12 +255,12 @@ UIWidget* CCSGUIReader::widgetFromJsonDictionary(JsonDictionary* data) else if (classname && strcmp(classname, "TextArea") == 0) { widget = UILabel::create(); - setPropsForTextAreaFromJsonDictionary(widget, uiOptions); + setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextButton") == 0) { widget = UIButton::create(); - setPropsForTextButtonFromJsonDictionary(widget, uiOptions); + setPropsForButtonFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextField") == 0) { @@ -154,13 +275,742 @@ UIWidget* CCSGUIReader::widgetFromJsonDictionary(JsonDictionary* data) else if (classname && strcmp(classname, "Panel") == 0) { widget = UILayout::create(); - setPropsForPanelFromJsonDictionary(widget, uiOptions); + setPropsForLayoutFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "Slider") == 0) { widget = UISlider::create(); setPropsForSliderFromJsonDictionary(widget, uiOptions); } + else if (classname && strcmp(classname, "LabelBMFont") == 0) + { + widget = UILabelBMFont::create(); + setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "DragPanel") == 0) + { + widget = UIScrollView::create(); + setPropsForScrollViewFromJsonDictionary(widget, uiOptions); + } + + int childrenCount = dicHelper->getArrayCount_json(data, "children"); + for (int i=0;igetDictionaryFromArray_json(data, "children", i); + UIWidget* child = widgetFromJsonDictionary(subData); + if (child) + { + widget->addChild(child); + } + CC_SAFE_DELETE(subData); + } + + CC_SAFE_DELETE(uiOptions); + return widget; +} + +void WidgetPropertiesReader0250::setPropsForWidgetFromJsonDictionary(UIWidget*widget,JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + bool ignoreSizeExsit = dicHelper->checkObjectExist_json(options, "ignoreSize"); + if (ignoreSizeExsit) + { + widget->ignoreContentAdaptWithSize(dicHelper->getBooleanValue_json(options, "ignoreSize")); + } + + float w = dicHelper->getFloatValue_json(options, "width"); + float h = dicHelper->getFloatValue_json(options, "height"); + widget->setSize(Size(w, h)); + + widget->setTag(dicHelper->getIntValue_json(options, "tag")); + widget->setActionTag(dicHelper->getIntValue_json(options, "actiontag")); + widget->setTouchEnabled(dicHelper->getBooleanValue_json(options, "touchAble")); + const char* name = dicHelper->getStringValue_json(options, "name"); + const char* widgetName = name?name:"default"; + widget->setName(widgetName); + float x = dicHelper->getFloatValue_json(options, "x"); + float y = dicHelper->getFloatValue_json(options, "y"); + widget->setPosition(Point(x,y)); + bool sx = dicHelper->checkObjectExist_json(options, "scaleX"); + if (sx) + { + widget->setScaleX(dicHelper->getFloatValue_json(options, "scaleX")); + } + bool sy = dicHelper->checkObjectExist_json(options, "scaleY"); + if (sy) + { + widget->setScaleY(dicHelper->getFloatValue_json(options, "scaleY")); + } + bool rt = dicHelper->checkObjectExist_json(options, "rotation"); + if (rt) + { + widget->setRotation(dicHelper->getFloatValue_json(options, "rotation")); + } + bool vb = dicHelper->checkObjectExist_json(options, "visible"); + if (vb) + { + widget->setVisible(dicHelper->getBooleanValue_json(options, "visible")); + } + int z = dicHelper->getIntValue_json(options, "ZOrder"); + widget->setZOrder(z); +} + +void WidgetPropertiesReader0250::setColorPropsForWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + bool op = dicHelper->checkObjectExist_json(options, "opacity"); + if (op) + { + widget->setOpacity(dicHelper->getIntValue_json(options, "opacity")); + } + bool cr = dicHelper->checkObjectExist_json(options, "colorR"); + bool cg = dicHelper->checkObjectExist_json(options, "colorG"); + bool cb = dicHelper->checkObjectExist_json(options, "colorB"); + int colorR = cr ? dicHelper->getIntValue_json(options, "colorR") : 255; + int colorG = cg ? dicHelper->getIntValue_json(options, "colorG") : 255; + int colorB = cb ? dicHelper->getIntValue_json(options, "colorB") : 255; + widget->setColor(Color3B(colorR, colorG, colorB)); + bool apx = dicHelper->checkObjectExist_json(options, "anchorPointX"); + float apxf = apx ? dicHelper->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + bool apy = dicHelper->checkObjectExist_json(options, "anchorPointY"); + float apyf = apy ? dicHelper->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + widget->setAnchorPoint(Point(apxf, apyf)); + bool flipX = dicHelper->getBooleanValue_json(options, "flipX"); + bool flipY = dicHelper->getBooleanValue_json(options, "flipY"); + widget->setFlipX(flipX); + widget->setFlipY(flipY); +} + +void WidgetPropertiesReader0250::setPropsForButtonFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UIButton* button = (UIButton*)widget; + bool scale9Enable = dicHelper->getBooleanValue_json(options, "scale9Enable"); + button->setScale9Enabled(scale9Enable); + + std::string tp_n = m_strFilePath; + std::string tp_p = m_strFilePath; + std::string tp_d = m_strFilePath; + + const char* normalFileName = dicHelper->getStringValue_json(options, "normal"); + const char* pressedFileName = dicHelper->getStringValue_json(options, "pressed"); + const char* disabledFileName = dicHelper->getStringValue_json(options, "disabled"); + + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + if (scale9Enable) + { + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + + if (useMergedTexture) + { + button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); + } + else + { + button->loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); + } + button->setCapInsets(Rect(cx, cy, cw, ch)); + bool sw = dicHelper->checkObjectExist_json(options, "scale9Width"); + bool sh = dicHelper->checkObjectExist_json(options, "scale9Height"); + if (sw && sh) + { + float swf = dicHelper->getFloatValue_json(options, "scale9Width"); + float shf = dicHelper->getFloatValue_json(options, "scale9Height"); + button->setSize(Size(swf, shf)); + } + } + else + { + if (useMergedTexture) + { + button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); + } + else + { + button->loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); + } + } + bool tt = dicHelper->checkObjectExist_json(options, "text"); + if (tt) + { + const char* text = dicHelper->getStringValue_json(options, "text"); + if (text) + { + button->setTitleText(text); + } + } + bool cr = dicHelper->checkObjectExist_json(options, "textColorR"); + bool cg = dicHelper->checkObjectExist_json(options, "textColorG"); + bool cb = dicHelper->checkObjectExist_json(options, "textColorB"); + int cri = cr?dicHelper->getIntValue_json(options, "textColorR"):255; + int cgi = cg?dicHelper->getIntValue_json(options, "textColorG"):255; + int cbi = cb?dicHelper->getIntValue_json(options, "textColorB"):255; + button->setTitleColor(Color3B(cri,cgi,cbi)); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); + if (fs) + { + button->setTitleFontSize(dicHelper->getIntValue_json(options, "fontSize")); + } + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); + if (fn) + { + button->setTitleFontName(dicHelper->getStringValue_json(options, "fontName")); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForCheckBoxFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UICheckBox* checkBox = (UICheckBox*)widget; + const char* backGroundFileName = dicHelper->getStringValue_json(options, "backGroundBox"); + const char* backGroundSelectedFileName = dicHelper->getStringValue_json(options, "backGroundBoxSelected"); + const char* frontCrossFileName = dicHelper->getStringValue_json(options, "frontCross"); + const char* backGroundDisabledFileName = dicHelper->getStringValue_json(options, "backGroundBoxDisabled"); + const char* frontCrossDisabledFileName = dicHelper->getStringValue_json(options, "frontCrossDisabled"); + + + std::string tp_b = m_strFilePath; + std::string tp_bs = m_strFilePath; + std::string tp_c = m_strFilePath; + std::string tp_bd = m_strFilePath; + std::string tp_cd = m_strFilePath; + + const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL; + const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL; + const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL; + const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL; + const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL; + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + + if (useMergedTexture) + { + checkBox->loadTextures(backGroundFileName, backGroundSelectedFileName, frontCrossFileName,backGroundDisabledFileName,frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); + } + else + { + checkBox->loadTextures(backGroundFileName_tp, backGroundSelectedFileName_tp, frontCrossFileName_tp,backGroundDisabledFileName_tp,frontCrossDisabledFileName_tp); + } + + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForImageViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + + UIImageView* imageView = (UIImageView*)widget; + const char* imageFileName = dicHelper->getStringValue_json(options, "fileName"); + bool scale9EnableExist = dicHelper->checkObjectExist_json(options, "scale9Enable"); + bool scale9Enable = false; + if (scale9EnableExist) + { + scale9Enable = dicHelper->getBooleanValue_json(options, "scale9Enable"); + } + imageView->setScale9Enabled(scale9Enable); + + std::string tp_i = m_strFilePath; + const char* imageFileName_tp = NULL; + if (imageFileName && (strcmp(imageFileName, "") != 0)) + { + imageFileName_tp = tp_i.append(imageFileName).c_str(); + } + + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + if (scale9Enable) + { + if (useMergedTexture) + { + imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + imageView->loadTexture(imageFileName_tp); + } + + bool sw = dicHelper->checkObjectExist_json(options, "scale9Width"); + bool sh = dicHelper->checkObjectExist_json(options, "scale9Height"); + if (sw && sh) + { + float swf = dicHelper->getFloatValue_json(options, "scale9Width"); + float shf = dicHelper->getFloatValue_json(options, "scale9Height"); + imageView->setSize(Size(swf, shf)); + } + + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + imageView->setCapInsets(Rect(cx, cy, cw, ch)); + + } + else + { + if (useMergedTexture) + { + imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + imageView->loadTexture(imageFileName_tp); + } + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForLabelFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UILabel* label = (UILabel*)widget; + bool touchScaleChangeAble = dicHelper->getBooleanValue_json(options, "touchScaleEnable"); + label->setTouchScaleChangeEnabled(touchScaleChangeAble); + const char* text = dicHelper->getStringValue_json(options, "text"); + label->setText(text); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); + if (fs) + { + label->setFontSize(dicHelper->getIntValue_json(options, "fontSize")); + } + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); + if (fn) + { + label->setFontName(dicHelper->getStringValue_json(options, "fontName")); + } + bool aw = dicHelper->checkObjectExist_json(options, "areaWidth"); + bool ah = dicHelper->checkObjectExist_json(options, "areaHeight"); + if (aw && ah) + { + Size size = Size(dicHelper->getFloatValue_json(options, "areaWidth"),dicHelper->getFloatValue_json(options,"areaHeight")); + label->setTextAreaSize(size); + } + bool ha = dicHelper->checkObjectExist_json(options, "hAlignment"); + if (ha) + { + label->setTextHorizontalAlignment((TextHAlignment)dicHelper->getIntValue_json(options, "hAlignment")); + } + bool va = dicHelper->checkObjectExist_json(options, "vAlignment"); + if (va) + { + label->setTextVerticalAlignment((TextVAlignment)dicHelper->getIntValue_json(options, "vAlignment")); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForLabelAtlasFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UILabelAtlas* labelAtlas = (UILabelAtlas*)widget; + bool sv = dicHelper->checkObjectExist_json(options, "stringValue"); + bool cmf = dicHelper->checkObjectExist_json(options, "charMapFile"); + bool iw = dicHelper->checkObjectExist_json(options, "itemWidth"); + bool ih = dicHelper->checkObjectExist_json(options, "itemHeight"); + bool scm = dicHelper->checkObjectExist_json(options, "startCharMap"); + if (sv && cmf && iw && ih && scm && (strcmp(dicHelper->getStringValue_json(options, "charMapFile"), "") != 0)) + { + std::string tp_c = m_strFilePath; + const char* cmf_tp = NULL; + 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")); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForLayoutFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + + setPropsForWidgetFromJsonDictionary(widget, options); + UILayout* containerWidget = (UILayout*)widget; + if (!dynamic_cast(containerWidget) + && !dynamic_cast(containerWidget)) + { + containerWidget->setClippingEnabled(dicHelper->getBooleanValue_json(options, "clipAble")); + } + UILayout* panel = (UILayout*)widget; + bool backGroundScale9Enable = dicHelper->getBooleanValue_json(options, "backGroundScale9Enable"); + panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); + int cr = dicHelper->getIntValue_json(options, "bgColorR"); + int cg = dicHelper->getIntValue_json(options, "bgColorG"); + int cb = dicHelper->getIntValue_json(options, "bgColorB"); + + int scr = dicHelper->getIntValue_json(options, "bgStartColorR"); + int scg = dicHelper->getIntValue_json(options, "bgStartColorG"); + int scb = dicHelper->getIntValue_json(options, "bgStartColorB"); + + int ecr = dicHelper->getIntValue_json(options, "bgEndColorR"); + int ecg = dicHelper->getIntValue_json(options, "bgEndColorG"); + int ecb = dicHelper->getIntValue_json(options, "bgEndColorB"); + + float bgcv1 = dicHelper->getFloatValue_json(options, "vectorX"); + float bgcv2 = dicHelper->getFloatValue_json(options, "vectorY"); + panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); + + int co = dicHelper->getIntValue_json(options, "bgColorOpacity"); + + int colorType = dicHelper->getIntValue_json(options, "colorType"); + panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); + panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); + panel->setBackGroundColor(Color3B(cr, cg, cb)); + panel->setBackGroundColorOpacity(co); + + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(options, "backGroundImage"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + if (backGroundScale9Enable) + { + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + if (useMergedTexture) + { + panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + panel->setBackGroundImage(imageFileName_tp); + } + panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); + } + else + { + + if (useMergedTexture) + { + panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + panel->setBackGroundImage(imageFileName_tp); + } + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForScrollViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForLayoutFromJsonDictionary(widget, options); + UIScrollView* scrollView = (UIScrollView*)widget; + float innerWidth = dicHelper->getFloatValue_json(options, "innerWidth"); + float innerHeight = dicHelper->getFloatValue_json(options, "innerHeight"); + scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); + int direction = dicHelper->getFloatValue_json(options, "direction"); + scrollView->setDirection((SCROLLVIEW_DIR)direction); + scrollView->setBounceEnabled(dicHelper->getBooleanValue_json(options, "bounceEnable")); + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForSliderFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UISlider* slider = (UISlider*)widget; + + bool barTextureScale9Enable = dicHelper->getBooleanValue_json(options, "barTextureScale9Enable"); + slider->setScale9Enabled(barTextureScale9Enable); + bool bt = dicHelper->checkObjectExist_json(options, "barFileName"); + float barLength = dicHelper->getFloatValue_json(options, "length"); + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + if (bt) + { + if (barTextureScale9Enable) + { + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(options, "barFileName"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + if (useMergedTexture) + { + slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + slider->loadBarTexture(imageFileName_tp); + } + slider->setSize(Size(barLength, slider->getContentSize().height)); + } + else + { + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(options, "barFileName"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + if (useMergedTexture) + { + slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + slider->loadBarTexture(imageFileName_tp); + } + } + } + std::string tp_n = m_strFilePath; + std::string tp_p = m_strFilePath; + std::string tp_d = m_strFilePath; + + const char* normalFileName = dicHelper->getStringValue_json(options, "ballNormal"); + const char* pressedFileName = dicHelper->getStringValue_json(options, "ballPressed"); + const char* disabledFileName = dicHelper->getStringValue_json(options, "ballDisabled"); + + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + if (useMergedTexture) + { + slider->loadSlidBallTextures(normalFileName,pressedFileName,disabledFileName,UI_TEX_TYPE_PLIST); + } + else + { + slider->loadSlidBallTextures(normalFileName_tp,pressedFileName_tp,disabledFileName_tp); + } + slider->setPercent(dicHelper->getIntValue_json(options, "percent")); + + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(options, "progressBarFileName"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + if (useMergedTexture) + { + slider->loadProgressBarTexture(imageFileName, UI_TEX_TYPE_PLIST); + } + else + { + slider->loadProgressBarTexture(imageFileName_tp); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForTextFieldFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UITextField* textField = (UITextField*)widget; + bool ph = dicHelper->checkObjectExist_json(options, "placeHolder"); + if (ph) + { + textField->setPlaceHolder(dicHelper->getStringValue_json(options, "placeHolder")); + } + textField->setText(dicHelper->getStringValue_json(options, "text")); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); + if (fs) + { + textField->setFontSize(dicHelper->getIntValue_json(options, "fontSize")); + } + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); + if (fn) + { + textField->setFontName(dicHelper->getStringValue_json(options, "fontName")); + } + bool tsw = dicHelper->checkObjectExist_json(options, "touchSizeWidth"); + bool tsh = dicHelper->checkObjectExist_json(options, "touchSizeHeight"); + if (tsw && tsh) + { + textField->setTouchSize(Size(dicHelper->getFloatValue_json(options, "touchSizeWidth"), dicHelper->getFloatValue_json(options,"touchSizeHeight"))); + } + + float dw = dicHelper->getFloatValue_json(options, "width"); + float dh = dicHelper->getFloatValue_json(options, "height"); + if (dw > 0.0f || dh > 0.0f) + { + //textField->setSize(Size(dw, dh)); + } + bool maxLengthEnable = dicHelper->getBooleanValue_json(options, "maxLengthEnable"); + textField->setMaxLengthEnabled(maxLengthEnable); + + if (maxLengthEnable) + { + int maxLength = dicHelper->getIntValue_json(options, "maxLength"); + textField->setMaxLength(maxLength); + } + bool passwordEnable = dicHelper->getBooleanValue_json(options, "passwordEnable"); + textField->setPasswordEnabled(passwordEnable); + if (passwordEnable) + { + textField->setPasswordStyleText(dicHelper->getStringValue_json(options, "passwordStyleText")); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForLoadingBarFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UILoadingBar* loadingBar = (UILoadingBar*)widget; + bool useMergedTexture = dicHelper->getBooleanValue_json(options, "useMergedTexture"); + std::string tp_b = m_strFilePath; + const char*imageFileName = dicHelper->getStringValue_json(options, "texture"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + if (useMergedTexture) + { + loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + } + else + { + loadingBar->loadTexture(imageFileName_tp); + } + loadingBar->setDirection(LoadingBarType(dicHelper->getIntValue_json(options, "direction"))); + loadingBar->setPercent(dicHelper->getIntValue_json(options, "percent")); + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0250::setPropsForLabelBMFontFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + + setPropsForWidgetFromJsonDictionary(widget, options); + + UILabelBMFont* labelBMFont = (UILabelBMFont*)widget; + + std::string tp_c = m_strFilePath; + const char* cmf_tp = NULL; + const char* cmft = dicHelper->getStringValue_json(options, "fileName"); + cmf_tp = tp_c.append(cmft).c_str(); + + labelBMFont->setFntFile(cmf_tp); + + const char* text = dicHelper->getStringValue_json(options, "text"); + labelBMFont->setText(text); + + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + + +/*0.3.0.0~1.0.0.0*/ +UIWidget* WidgetPropertiesReader0300::createWidget(JsonDictionary* data, const char* fullPath, const char* fileName) +{ + m_strFilePath = fullPath; + DictionaryHelper* dicHelper = DICTOOL; + int texturesCount = dicHelper->getArrayCount_json(data, "textures"); + + for (int i=0; igetStringValueFromArray_json(data, "textures", i); + std::string tp = fullPath; + tp.append(file); + SpriteFrameCache::getInstance()->addSpriteFramesWithFile(tp.c_str()); + } + float fileDesignWidth = dicHelper->getFloatValue_json(data, "designWidth"); + float fileDesignHeight = dicHelper->getFloatValue_json(data, "designHeight"); + if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { + printf("Read design size error!\n"); + Size winSize = Director::getInstance()->getWinSize(); + GUIReader::shareReader()->storeFileDesignSize(fileName, winSize); + } + else + { + GUIReader::shareReader()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight)); + } + JsonDictionary* widgetTree = dicHelper->getSubDictionary_json(data, "widgetTree"); + UIWidget* widget = widgetFromJsonDictionary(widgetTree); + + /* *********temp********* */ + if (widget->getContentSize().equals(Size::ZERO)) + { + UILayout* rootWidget = dynamic_cast(widget); + rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); + } + /* ********************** */ + + // widget->setFileDesignSize(Size(fileDesignWidth, fileDesignHeight)); + JsonDictionary* actions = dicHelper->getSubDictionary_json(data, "animation"); + /* *********temp********* */ + // ActionManager::shareManager()->releaseActions(); + /* ********************** */ + CCLOG("file name == [%s]",fileName); + Object* rootWidget = (Object*) widget; + ActionManagerEx::shareManager()->initWithDictionary(fileName,actions,rootWidget); + CC_SAFE_DELETE(widgetTree); + CC_SAFE_DELETE(actions); + return widget; +} + +UIWidget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *data) +{ + DictionaryHelper* dicHelper = DICTOOL; + UIWidget* widget = NULL; + const char* classname = dicHelper->getStringValue_json(data, "classname"); + JsonDictionary* uiOptions = dicHelper->getSubDictionary_json(data, "options"); + if (classname && strcmp(classname, "Button") == 0) + { + widget = UIButton::create(); + setPropsForButtonFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "CheckBox") == 0) + { + widget = UICheckBox::create(); + setPropsForCheckBoxFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "Label") == 0) + { + widget = UILabel::create(); + setPropsForLabelFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "LabelAtlas") == 0) + { + widget = UILabelAtlas::create(); + setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "LoadingBar") == 0) + { + widget = UILoadingBar::create(); + setPropsForLoadingBarFromJsonDictionary(widget, uiOptions); + }else if (classname && strcmp(classname, "ScrollView") == 0){ + widget = UIScrollView::create(); + setPropsForScrollViewFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "TextArea") == 0) + { + widget = UILabel::create(); + setPropsForLabelFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "TextButton") == 0) + { + widget = UIButton::create(); + setPropsForButtonFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "TextField") == 0) + { + widget = UITextField::create(); + setPropsForTextFieldFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "ImageView") == 0) + { + widget = UIImageView::create(); + setPropsForImageViewFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "Panel") == 0) + { + widget = UILayout::create(); + setPropsForLayoutFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "Slider") == 0) + { + widget = UISlider::create(); + setPropsForSliderFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "LabelBMFont") == 0) + { + widget = UILabelBMFont::create(); + setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); + } + else if (classname && strcmp(classname, "DragPanel") == 0) + { + widget = UIScrollView::create(); + setPropsForScrollViewFromJsonDictionary(widget, uiOptions); + } else if (classname && strcmp(classname, "ListView") == 0) { widget = UIListView::create(); @@ -171,1389 +1021,466 @@ UIWidget* CCSGUIReader::widgetFromJsonDictionary(JsonDictionary* data) widget = UIPageView::create(); setPropsForPageViewFromJsonDictionary(widget, uiOptions); } - else if (classname && strcmp(classname, "LabelBMFont") == 0) - { - widget = UILabelBMFont::create(); - setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); - } - else if (classname && strcmp(classname, "DragPanel") == 0) - { - widget = UIScrollView::create(); - setPropsForDragPanelFromJsonDictionary(widget, uiOptions); - } - - int childrenCount = DICTOOL->getArrayCount_json(data, "children"); + + int childrenCount = dicHelper->getArrayCount_json(data, "children"); for (int i=0;igetDictionaryFromArray_json(data, "children", i); + JsonDictionary* subData = dicHelper->getDictionaryFromArray_json(data, "children", i); UIWidget* child = widgetFromJsonDictionary(subData); if (child) { widget->addChild(child); } - CC_SAFE_DELETE(subData); + CC_SAFE_DELETE(subData); } - - CC_SAFE_DELETE(uiOptions); + + CC_SAFE_DELETE(uiOptions); return widget; } -void CCSGUIReader::storeFileDesignSize(const char *fileName, const cocos2d::Size &size) +void WidgetPropertiesReader0300::setPropsForWidgetFromJsonDictionary(UIWidget*widget,JsonDictionary *options) { - if (!_fileDesignSizes) - { - _fileDesignSizes = cocos2d::Dictionary::create(); - _fileDesignSizes->retain(); - } - cocos2d::String* strSize = cocos2d::String::createWithFormat("{%f,%f}", size.width, size.height); - _fileDesignSizes->setObject(strSize, fileName); -} - -const cocos2d::Size CCSGUIReader::getFileDesignSize(const char* fileName) const -{ - if (!_fileDesignSizes) - { - return cocos2d::Size::ZERO; - } - cocos2d::Size designSize = cocos2d::SizeFromString(((cocos2d::String*)_fileDesignSizes->objectForKey(fileName))->_string.c_str()); - return designSize; -} - -UIWidget* CCSGUIReader::widgetFromJsonFile(const char *fileName) -{ - m_bOlderVersion = false; - const char *des = NULL; - std::string jsonpath; - JsonDictionary *jsonDict = NULL; - jsonpath = FileUtils::getInstance()->fullPathForFilename(fileName); - - long size = 0; - des = (char*)(FileUtils::getInstance()->getFileData(jsonpath.c_str(),"r" , &size)); - if(NULL == des || strcmp(des, "") == 0) - { - printf("read json file[%s] error!\n", fileName); - return NULL; - } - std::string strDes(des); - jsonDict = new JsonDictionary(); - jsonDict->initWithDescription(strDes.c_str()); - - const char* fileVersion = DICTOOL->getStringValue_json(jsonDict, "version"); - if (!fileVersion || getVersionInteger(fileVersion) < 250) - { - m_bOlderVersion = true; - } - - int texturesCount = DICTOOL->getArrayCount_json(jsonDict, "textures"); - long pos = jsonpath.find_last_of('/'); - m_strFilePath = jsonpath.substr(0,pos+1); - for (int i=0; igetStringValueFromArray_json(jsonDict, "textures", i); - std::string tp = m_strFilePath; - tp.append(file); - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(tp.c_str()); - } - float fileDesignWidth = DICTOOL->getFloatValue_json(jsonDict, "designWidth"); - float fileDesignHeight = DICTOOL->getFloatValue_json(jsonDict, "designHeight"); - if (fileDesignWidth <= 0 || fileDesignHeight <= 0) - { - printf("Read design size error!\n"); - Size winSize = Director::getInstance()->getWinSize(); - storeFileDesignSize(fileName, winSize); - } - else - { - storeFileDesignSize(fileName, cocos2d::Size(fileDesignWidth, fileDesignHeight)); - } - JsonDictionary* widgetTree = DICTOOL->getSubDictionary_json(jsonDict, "widgetTree"); - UIWidget* widget = widgetFromJsonDictionary(widgetTree); - - /* *********temp********* */ - if (widget->getContentSize().equals(Size::ZERO)) - { - UILayout* rootWidget = dynamic_cast(widget); - rootWidget->setSize(Size(fileDesignWidth, fileDesignHeight)); - } - /* ********************** */ - -// widget->setFileDesignSize(CCSizeMake(fileDesignWidth, fileDesignHeight)); - JsonDictionary* actions = DICTOOL->getSubDictionary_json(jsonDict, "animation"); - /* *********temp********* */ -// ActionManager::shareManager()->releaseActions(); - /* ********************** */ - CCLOG("file name == [%s]",fileName); - ActionManagerEx::shareManager()->initWithDictionary(fileName,actions,widget); - - CC_SAFE_DELETE(widgetTree); - CC_SAFE_DELETE(actions); - CC_SAFE_DELETE(jsonDict); - CC_SAFE_DELETE_ARRAY(des); - return widget; -} - -void CCSGUIReader::setPropsForWidgetFromJsonDictionary(UIWidget*widget,JsonDictionary *options) -{ - bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, "ignoreSize"); + DictionaryHelper* dicHelper = DICTOOL; + bool ignoreSizeExsit = dicHelper->checkObjectExist_json(options, "ignoreSize"); if (ignoreSizeExsit) { - widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, "ignoreSize")); + widget->ignoreContentAdaptWithSize(dicHelper->getBooleanValue_json(options, "ignoreSize")); } - float w = DICTOOL->getFloatValue_json(options, "width"); - float h = DICTOOL->getFloatValue_json(options, "height"); + float w = dicHelper->getFloatValue_json(options, "width"); + float h = dicHelper->getFloatValue_json(options, "height"); widget->setSize(Size(w, h)); - widget->setTag(DICTOOL->getIntValue_json(options, "tag")); - widget->setActionTag(DICTOOL->getIntValue_json(options, "actiontag")); - widget->setTouchEnabled(DICTOOL->getBooleanValue_json(options, "touchAble")); - const char* name = DICTOOL->getStringValue_json(options, "name"); + widget->setTag(dicHelper->getIntValue_json(options, "tag")); + widget->setActionTag(dicHelper->getIntValue_json(options, "actiontag")); + widget->setTouchEnabled(dicHelper->getBooleanValue_json(options, "touchAble")); + const char* name = dicHelper->getStringValue_json(options, "name"); const char* widgetName = name?name:"default"; widget->setName(widgetName); - float x = DICTOOL->getFloatValue_json(options, "x"); - float y = DICTOOL->getFloatValue_json(options, "y"); + float x = dicHelper->getFloatValue_json(options, "x"); + float y = dicHelper->getFloatValue_json(options, "y"); widget->setPosition(Point(x,y)); - bool sx = DICTOOL->checkObjectExist_json(options, "scaleX"); + bool sx = dicHelper->checkObjectExist_json(options, "scaleX"); if (sx) { - widget->setScaleX(DICTOOL->getFloatValue_json(options, "scaleX")); + widget->setScaleX(dicHelper->getFloatValue_json(options, "scaleX")); } - bool sy = DICTOOL->checkObjectExist_json(options, "scaleY"); + bool sy = dicHelper->checkObjectExist_json(options, "scaleY"); if (sy) { - widget->setScaleY(DICTOOL->getFloatValue_json(options, "scaleY")); + widget->setScaleY(dicHelper->getFloatValue_json(options, "scaleY")); } - bool rt = DICTOOL->checkObjectExist_json(options, "rotation"); + bool rt = dicHelper->checkObjectExist_json(options, "rotation"); if (rt) { - widget->setRotation(DICTOOL->getFloatValue_json(options, "rotation")); + widget->setRotation(dicHelper->getFloatValue_json(options, "rotation")); } - bool vb = DICTOOL->checkObjectExist_json(options, "visible"); + bool vb = dicHelper->checkObjectExist_json(options, "visible"); if (vb) { - widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible")); + widget->setVisible(dicHelper->getBooleanValue_json(options, "visible")); } -// widget->setUseMergedTexture(DICTOOL->getBooleanValue_json(options, "useMergedTexture")); - int z = DICTOOL->getIntValue_json(options, "ZOrder"); + int z = dicHelper->getIntValue_json(options, "ZOrder"); widget->setZOrder(z); } -void CCSGUIReader::setColorPropsForWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +void WidgetPropertiesReader0300::setColorPropsForWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options) { - bool op = DICTOOL->checkObjectExist_json(options, "opacity"); + DictionaryHelper* dicHelper = DICTOOL; + bool op = dicHelper->checkObjectExist_json(options, "opacity"); if (op) { - widget->setOpacity(DICTOOL->getIntValue_json(options, "opacity")); + widget->setOpacity(dicHelper->getIntValue_json(options, "opacity")); } - bool cr = DICTOOL->checkObjectExist_json(options, "colorR"); - bool cg = DICTOOL->checkObjectExist_json(options, "colorG"); - bool cb = DICTOOL->checkObjectExist_json(options, "colorB"); - int colorR = cr ? DICTOOL->getIntValue_json(options, "colorR") : 255; - int colorG = cg ? DICTOOL->getIntValue_json(options, "colorG") : 255; - int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255; + bool cr = dicHelper->checkObjectExist_json(options, "colorR"); + bool cg = dicHelper->checkObjectExist_json(options, "colorG"); + bool cb = dicHelper->checkObjectExist_json(options, "colorB"); + int colorR = cr ? dicHelper->getIntValue_json(options, "colorR") : 255; + int colorG = cg ? dicHelper->getIntValue_json(options, "colorG") : 255; + int colorB = cb ? dicHelper->getIntValue_json(options, "colorB") : 255; widget->setColor(Color3B(colorR, colorG, colorB)); - bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX"); - float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : 0.5f; - bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY"); - float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : 0.5f; + bool apx = dicHelper->checkObjectExist_json(options, "anchorPointX"); + float apxf = apx ? dicHelper->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); + bool apy = dicHelper->checkObjectExist_json(options, "anchorPointY"); + float apyf = apy ? dicHelper->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); widget->setAnchorPoint(Point(apxf, apyf)); - bool flipX = DICTOOL->getBooleanValue_json(options, "flipX"); - bool flipY = DICTOOL->getBooleanValue_json(options, "flipY"); + bool flipX = dicHelper->getBooleanValue_json(options, "flipX"); + bool flipY = dicHelper->getBooleanValue_json(options, "flipY"); widget->setFlipX(flipX); widget->setFlipY(flipY); } -void CCSGUIReader::setPropsForButtonFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - UIButton* button = (UIButton*)widget; - bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - button->setScale9Enabled(scale9Enable); - - std::string tp_n = m_strFilePath; - std::string tp_p = m_strFilePath; - std::string tp_d = m_strFilePath; - - const char* normalFileName = DICTOOL->getStringValue_json(options, "normal"); - const char* pressedFileName = DICTOOL->getStringValue_json(options, "pressed"); - const char* disabledFileName = DICTOOL->getStringValue_json(options, "disabled"); - - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - if (scale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - if (useMergedTexture) - { - button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); - } - else - { - button->loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); - } - button->setCapInsets(Rect(cx, cy, cw, ch)); - bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); - bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); - float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); - button->setSize(Size(swf, shf)); - } - } - else - { - if (useMergedTexture) - { - button->loadTextures(normalFileName, pressedFileName, disabledFileName,UI_TEX_TYPE_PLIST); - } - else - { - button->loadTextures(normalFileName_tp, pressedFileName_tp, disabledFileName_tp); - } - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - UIButton* button = (UIButton*)widget; - bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - button->setScale9Enabled(scale9Enable); - - JsonDictionary* normalDic = DICTOOL->getSubDictionary_json(options, "normalData"); - int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); - switch (normalType) - { - case 0: - { - std::string tp_n = m_strFilePath; - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; - button->loadTextureNormal(normalFileName_tp); - break; - } - case 1: - { - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - button->loadTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(normalDic); - JsonDictionary* pressedDic = DICTOOL->getSubDictionary_json(options, "pressedData"); - int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); - switch (pressedType) - { - case 0: - { - std::string tp_p = m_strFilePath; - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; - button->loadTexturePressed(pressedFileName_tp); - break; - } - case 1: - { - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - button->loadTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(pressedDic); - JsonDictionary* disabledDic = DICTOOL->getSubDictionary_json(options, "disabledData"); - int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); - switch (disabledType) - { - case 0: - { - std::string tp_d = m_strFilePath; - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; - button->loadTextureDisabled(disabledFileName_tp); - break; - } - case 1: - { - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - button->loadTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(disabledDic); - if (scale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - button->setCapInsets(Rect(cx, cy, cw, ch)); - bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); - bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); - float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); - button->setSize(Size(swf, shf)); - } - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForCheckBoxFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - UICheckBox* checkBox = (UICheckBox*)widget; - const char* backGroundFileName = DICTOOL->getStringValue_json(options, "backGroundBox"); - const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(options, "backGroundBoxSelected"); - const char* frontCrossFileName = DICTOOL->getStringValue_json(options, "frontCross"); - const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(options, "backGroundBoxDisabled"); - const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "frontCrossDisabled"); - - - std::string tp_b = m_strFilePath; - std::string tp_bs = m_strFilePath; - std::string tp_c = m_strFilePath; - std::string tp_bd = m_strFilePath; - std::string tp_cd = m_strFilePath; - - const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL; - const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL; - const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL; - const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL; - const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL; - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - - if (useMergedTexture) - { - checkBox->loadTextures(backGroundFileName, backGroundSelectedFileName, frontCrossFileName,backGroundDisabledFileName,frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); - } - else - { - checkBox->loadTextures(backGroundFileName_tp, backGroundSelectedFileName_tp, frontCrossFileName_tp,backGroundDisabledFileName_tp,frontCrossDisabledFileName_tp); - } - - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - UICheckBox* checkBox = (UICheckBox*)widget; - - JsonDictionary* backGroundDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxData"); - int backGroundType = DICTOOL->getIntValue_json(backGroundDic, "resourceType"); - switch (backGroundType) - { - case 0: - { - std::string tp_b = m_strFilePath; - const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path"); - const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL; - checkBox->loadTextureBackGround(backGroundFileName_tp); - break; - } - case 1: - { - const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path"); - checkBox->loadTextureBackGround(backGroundFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(backGroundDic); - - JsonDictionary* backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxSelectedData"); - int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, "resourceType"); - switch (backGroundSelectedType) - { - case 0: - { - std::string tp_bs = m_strFilePath; - const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path"); - const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL; - checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName_tp); - break; - } - case 1: - { - const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path"); - checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(backGroundSelectedDic); - - JsonDictionary* frontCrossDic = DICTOOL->getSubDictionary_json(options, "frontCrossData"); - int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, "resourceType"); - switch (frontCrossType) - { - case 0: - { - std::string tp_c = m_strFilePath; - const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path"); - const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL; - checkBox->loadTextureFrontCross(frontCrossFileName_tp); - break; - } - case 1: - { - const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path"); - checkBox->loadTextureFrontCross(frontCrossFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(frontCrossDic); - - JsonDictionary* backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxDisabledData"); - int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, "resourceType"); - switch (backGroundDisabledType) - { - case 0: - { - std::string tp_bd = m_strFilePath; - const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path"); - const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL; - checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName_tp); - break; - } - case 1: - { - const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path"); - checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(backGroundDisabledDic); - - JsonDictionary* frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, "frontCrossDisabledData"); - int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, "resourceType"); - switch (frontCrossDisabledType) - { - case 0: - { - std::string tp_cd = m_strFilePath; - const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path"); - const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL; - checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp); - break; - } - case 1: - { - const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path"); - checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(frontCrossDisabledDic); - - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForImageViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - - UIImageView* imageView = (UIImageView*)widget; - const char* imageFileName = DICTOOL->getStringValue_json(options, "fileName"); - bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable"); - bool scale9Enable = false; - if (scale9EnableExist) - { - scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - } - imageView->setScale9Enabled(scale9Enable); - - std::string tp_i = m_strFilePath; - const char* imageFileName_tp = NULL; - if (imageFileName && (strcmp(imageFileName, "") != 0)) - { - imageFileName_tp = tp_i.append(imageFileName).c_str(); - } - - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - if (scale9Enable) - { - if (useMergedTexture) - { - imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - imageView->loadTexture(imageFileName_tp); - } - - bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); - bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); - float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); - imageView->setSize(Size(swf, shf)); - } - - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - imageView->setCapInsets(Rect(cx, cy, cw, ch)); - - } - else - { - if (useMergedTexture) - { - imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - imageView->loadTexture(imageFileName_tp); - } - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - - UIImageView* imageView = (UIImageView*)widget; - - JsonDictionary* imageFileNameDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); - int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileNameType) - { - case 0: - { - std::string tp_i = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = NULL; - if (imageFileName && (strcmp(imageFileName, "") != 0)) - { - imageFileName_tp = tp_i.append(imageFileName).c_str(); - imageView->loadTexture(imageFileName_tp); - } - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(imageFileNameDic); - - bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable"); - bool scale9Enable = false; - if (scale9EnableExist) - { - scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - } - imageView->setScale9Enabled(scale9Enable); - - - if (scale9Enable) - { - bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); - bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); - float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); - imageView->setSize(Size(swf, shf)); - } - - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - imageView->setCapInsets(Rect(cx, cy, cw, ch)); - - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForLabelFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +void WidgetPropertiesReader0300::setPropsForButtonFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { + DictionaryHelper* dicHelper = DICTOOL; setPropsForWidgetFromJsonDictionary(widget, options); - UILabel* label = (UILabel*)widget; - bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable"); - label->setTouchScaleChangeEnabled(touchScaleChangeAble); - const char* text = DICTOOL->getStringValue_json(options, "text"); - label->setText(text); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); + UIButton* button = (UIButton*)widget; + bool scale9Enable = dicHelper->getBooleanValue_json(options, "scale9Enable"); + button->setScale9Enabled(scale9Enable); + + JsonDictionary* normalDic = dicHelper->getSubDictionary_json(options, "normalData"); + int normalType = dicHelper->getIntValue_json(normalDic, "resourceType"); + switch (normalType) + { + case 0: + { + std::string tp_n = m_strFilePath; + const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path"); + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; + button->loadTextureNormal(normalFileName_tp); + break; + } + case 1: + { + const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path"); + button->loadTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(normalDic); + JsonDictionary* pressedDic = dicHelper->getSubDictionary_json(options, "pressedData"); + int pressedType = dicHelper->getIntValue_json(pressedDic, "resourceType"); + switch (pressedType) + { + case 0: + { + std::string tp_p = m_strFilePath; + const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path"); + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; + button->loadTexturePressed(pressedFileName_tp); + break; + } + case 1: + { + const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path"); + button->loadTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(pressedDic); + JsonDictionary* disabledDic = dicHelper->getSubDictionary_json(options, "disabledData"); + int disabledType = dicHelper->getIntValue_json(disabledDic, "resourceType"); + switch (disabledType) + { + case 0: + { + std::string tp_d = m_strFilePath; + const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path"); + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + button->loadTextureDisabled(disabledFileName_tp); + break; + } + case 1: + { + const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path"); + button->loadTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(disabledDic); + if (scale9Enable) + { + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + + button->setCapInsets(Rect(cx, cy, cw, ch)); + bool sw = dicHelper->checkObjectExist_json(options, "scale9Width"); + bool sh = dicHelper->checkObjectExist_json(options, "scale9Height"); + if (sw && sh) + { + float swf = dicHelper->getFloatValue_json(options, "scale9Width"); + float shf = dicHelper->getFloatValue_json(options, "scale9Height"); + button->setSize(Size(swf, shf)); + } + } + bool tt = dicHelper->checkObjectExist_json(options, "text"); + if (tt) + { + const char* text = dicHelper->getStringValue_json(options, "text"); + if (text) + { + button->setTitleText(text); + } + } + + bool cr = dicHelper->checkObjectExist_json(options, "textColorR"); + bool cg = dicHelper->checkObjectExist_json(options, "textColorG"); + bool cb = dicHelper->checkObjectExist_json(options, "textColorB"); + int cri = cr?dicHelper->getIntValue_json(options, "textColorR"):255; + int cgi = cg?dicHelper->getIntValue_json(options, "textColorG"):255; + int cbi = cb?dicHelper->getIntValue_json(options, "textColorB"):255; + button->setTitleColor(Color3B(cri,cgi,cbi)); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); if (fs) { - label->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); + button->setTitleFontSize(dicHelper->getIntValue_json(options, "fontSize")); } - bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); if (fn) { - label->setFontName(DICTOOL->getStringValue_json(options, "fontName")); + button->setTitleFontName(dicHelper->getStringValue_json(options, "fontName")); } - bool cro = DICTOOL->checkObjectExist_json(options, "colorR"); - bool cgo = DICTOOL->checkObjectExist_json(options, "colorG"); - bool cbo = DICTOOL->checkObjectExist_json(options, "colorB"); - int cr = cro?DICTOOL->getIntValue_json(options, "colorR"):255; - int cg = cgo?DICTOOL->getIntValue_json(options, "colorG"):255; - int cb = cbo?DICTOOL->getIntValue_json(options, "colorB"):255; - Color3B tc = Color3B(cr, cg, cb); - label->setColor(tc); setColorPropsForWidgetFromJsonDictionary(widget,options); } -void CCSGUIReader::setPropsForLabelAtlasFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +void WidgetPropertiesReader0300::setPropsForCheckBoxFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { - if (m_bOlderVersion) + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UICheckBox* checkBox = (UICheckBox*)widget; + + JsonDictionary* backGroundDic = dicHelper->getSubDictionary_json(options, "backGroundBoxData"); + int backGroundType = dicHelper->getIntValue_json(backGroundDic, "resourceType"); + switch (backGroundType) { - setPropsForWidgetFromJsonDictionary(widget, options); - UILabelAtlas* labelAtlas = (UILabelAtlas*)widget; - bool sv = DICTOOL->checkObjectExist_json(options, "stringValue"); - bool cmf = DICTOOL->checkObjectExist_json(options, "charMapFile"); - bool iw = DICTOOL->checkObjectExist_json(options, "itemWidth"); - bool ih = DICTOOL->checkObjectExist_json(options, "itemHeight"); - bool scm = DICTOOL->checkObjectExist_json(options, "startCharMap"); - if (sv && cmf && iw && ih && scm && (strcmp(DICTOOL->getStringValue_json(options, "charMapFile"), "") != 0)) + case 0: + { + std::string tp_b = m_strFilePath; + const char* backGroundFileName = dicHelper->getStringValue_json(backGroundDic, "path"); + const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():NULL; + checkBox->loadTextureBackGround(backGroundFileName_tp); + break; + } + case 1: + { + const char* backGroundFileName = dicHelper->getStringValue_json(backGroundDic, "path"); + checkBox->loadTextureBackGround(backGroundFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(backGroundDic); + + JsonDictionary* backGroundSelectedDic = dicHelper->getSubDictionary_json(options, "backGroundBoxSelectedData"); + int backGroundSelectedType = dicHelper->getIntValue_json(backGroundSelectedDic, "resourceType"); + switch (backGroundSelectedType) + { + case 0: + { + std::string tp_bs = m_strFilePath; + const char* backGroundSelectedFileName = dicHelper->getStringValue_json(backGroundSelectedDic, "path"); + const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():NULL; + checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName_tp); + break; + } + case 1: + { + const char* backGroundSelectedFileName = dicHelper->getStringValue_json(backGroundSelectedDic, "path"); + checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(backGroundSelectedDic); + + JsonDictionary* frontCrossDic = dicHelper->getSubDictionary_json(options, "frontCrossData"); + int frontCrossType = dicHelper->getIntValue_json(frontCrossDic, "resourceType"); + switch (frontCrossType) + { + case 0: { std::string tp_c = m_strFilePath; - const char* cmf_tp = NULL; - const char* cmft = DICTOOL->getStringValue_json(options, "charMapFile"); - cmf_tp = tp_c.append(cmft).c_str(); - - labelAtlas->setProperty(DICTOOL->getStringValue_json(options, "stringValue"),cmf_tp,DICTOOL->getIntValue_json(options, "itemWidth"),DICTOOL->getIntValue_json(options,"itemHeight"),DICTOOL->getStringValue_json(options, "startCharMap")); + const char* frontCrossFileName = dicHelper->getStringValue_json(frontCrossDic, "path"); + const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():NULL; + checkBox->loadTextureFrontCross(frontCrossFileName_tp); + break; } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - UILabelAtlas* labelAtlas = (UILabelAtlas*)widget; - bool sv = DICTOOL->checkObjectExist_json(options, "stringValue"); - bool cmf = DICTOOL->checkObjectExist_json(options, "charMapFile"); - bool iw = DICTOOL->checkObjectExist_json(options, "itemWidth"); - bool ih = DICTOOL->checkObjectExist_json(options, "itemHeight"); - bool scm = DICTOOL->checkObjectExist_json(options, "startCharMap"); - if (sv && cmf && iw && ih && scm) + case 1: { - - JsonDictionary* cmftDic = DICTOOL->getSubDictionary_json(options, "charMapFileData"); - int cmfType = DICTOOL->getIntValue_json(cmftDic, "resourceType"); - switch (cmfType) - { - case 0: - { - std::string tp_c = m_strFilePath; - const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, "path"); - const char* cmf_tp = tp_c.append(cmfPath).c_str(); - labelAtlas->setProperty(DICTOOL->getStringValue_json(options, "stringValue"),cmf_tp,DICTOOL->getIntValue_json(options, "itemWidth"),DICTOOL->getIntValue_json(options,"itemHeight"),DICTOOL->getStringValue_json(options, "startCharMap")); - break; - } - case 1: - CCLOG("Wrong res type of LabelAtlas!"); - break; - default: - break; - } - CC_SAFE_DELETE(cmftDic); + const char* frontCrossFileName = dicHelper->getStringValue_json(frontCrossDic, "path"); + checkBox->loadTextureFrontCross(frontCrossFileName,UI_TEX_TYPE_PLIST); + break; } - setColorPropsForWidgetFromJsonDictionary(widget,options); + default: + break; } + CC_SAFE_DELETE(frontCrossDic); + + JsonDictionary* backGroundDisabledDic = dicHelper->getSubDictionary_json(options, "backGroundBoxDisabledData"); + int backGroundDisabledType = dicHelper->getIntValue_json(backGroundDisabledDic, "resourceType"); + switch (backGroundDisabledType) + { + case 0: + { + std::string tp_bd = m_strFilePath; + const char* backGroundDisabledFileName = dicHelper->getStringValue_json(backGroundDisabledDic, "path"); + const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():NULL; + checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName_tp); + break; + } + case 1: + { + const char* backGroundDisabledFileName = dicHelper->getStringValue_json(backGroundDisabledDic, "path"); + checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(backGroundDisabledDic); + + JsonDictionary* frontCrossDisabledDic = dicHelper->getSubDictionary_json(options, "frontCrossDisabledData"); + int frontCrossDisabledType = dicHelper->getIntValue_json(frontCrossDisabledDic, "resourceType"); + switch (frontCrossDisabledType) + { + case 0: + { + std::string tp_cd = m_strFilePath; + const char* frontCrossDisabledFileName = dicHelper->getStringValue_json(options, "path"); + const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():NULL; + checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp); + break; + } + case 1: + { + const char* frontCrossDisabledFileName = dicHelper->getStringValue_json(options, "path"); + checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(frontCrossDisabledDic); + + setColorPropsForWidgetFromJsonDictionary(widget,options); } -void CCSGUIReader::setPropsForContainerWidgetFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +void WidgetPropertiesReader0300::setPropsForImageViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { + DictionaryHelper* dicHelper = DICTOOL; setPropsForWidgetFromJsonDictionary(widget, options); - UILayout* containerWidget = (UILayout*)widget; - if (!dynamic_cast(containerWidget) - && !dynamic_cast(containerWidget)) + + UIImageView* imageView = (UIImageView*)widget; + + JsonDictionary* imageFileNameDic = dicHelper->getSubDictionary_json(options, "fileNameData"); + int imageFileNameType = dicHelper->getIntValue_json(imageFileNameDic, "resourceType"); + switch (imageFileNameType) { - containerWidget->setClippingEnabled(DICTOOL->getBooleanValue_json(options, "clipAble")); + case 0: + { + std::string tp_i = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + const char* imageFileName_tp = NULL; + if (imageFileName && (strcmp(imageFileName, "") != 0)) + { + imageFileName_tp = tp_i.append(imageFileName).c_str(); + imageView->loadTexture(imageFileName_tp); + } + break; + } + case 1: + { + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(imageFileNameDic); + + bool scale9EnableExist = dicHelper->checkObjectExist_json(options, "scale9Enable"); + bool scale9Enable = false; + if (scale9EnableExist) + { + scale9Enable = dicHelper->getBooleanValue_json(options, "scale9Enable"); + } + imageView->setScale9Enabled(scale9Enable); + + + if (scale9Enable) + { + bool sw = dicHelper->checkObjectExist_json(options, "scale9Width"); + bool sh = dicHelper->checkObjectExist_json(options, "scale9Height"); + if (sw && sh) + { + float swf = dicHelper->getFloatValue_json(options, "scale9Width"); + float shf = dicHelper->getFloatValue_json(options, "scale9Height"); + imageView->setSize(Size(swf, shf)); + } + + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + + imageView->setCapInsets(Rect(cx, cy, cw, ch)); + } setColorPropsForWidgetFromJsonDictionary(widget,options); } -void CCSGUIReader::setPropsForPanelFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - if (m_bOlderVersion) - { - setPropsForContainerWidgetFromJsonDictionary(widget, options); - UILayout* panel = (UILayout*)widget; - bool backGroundScale9Enable = DICTOOL->getBooleanValue_json(options, "backGroundScale9Enable"); - panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); - int cr = DICTOOL->getIntValue_json(options, "bgColorR"); - int cg = DICTOOL->getIntValue_json(options, "bgColorG"); - int cb = DICTOOL->getIntValue_json(options, "bgColorB"); - - int scr = DICTOOL->getIntValue_json(options, "bgStartColorR"); - int scg = DICTOOL->getIntValue_json(options, "bgStartColorG"); - int scb = DICTOOL->getIntValue_json(options, "bgStartColorB"); - - int ecr = DICTOOL->getIntValue_json(options, "bgEndColorR"); - int ecg = DICTOOL->getIntValue_json(options, "bgEndColorG"); - int ecb = DICTOOL->getIntValue_json(options, "bgEndColorB"); - - float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX"); - float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY"); - panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); - - int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); - - int colorType = DICTOOL->getIntValue_json(options, "colorType"); - panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); -// float w = DICTOOL->getFloatValue_json(options, "width"); -// float h = DICTOOL->getFloatValue_json(options, "height"); - panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); - panel->setBackGroundColor(Color3B(cr, cg, cb)); - panel->setBackGroundColorOpacity(co); -// panel->setSize(CCSizeMake(w, h)); - - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(options, "backGroundImage"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - if (backGroundScale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - if (useMergedTexture) - { - panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - panel->setBackGroundImage(imageFileName_tp); - } - panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); - } - else - { - - if (useMergedTexture) - { - panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - panel->setBackGroundImage(imageFileName_tp); - } - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForContainerWidgetFromJsonDictionary(widget, options); - UILayout* panel = (UILayout*)widget; - bool backGroundScale9Enable = DICTOOL->getBooleanValue_json(options, "backGroundScale9Enable"); - panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); - int cr = DICTOOL->getIntValue_json(options, "bgColorR"); - int cg = DICTOOL->getIntValue_json(options, "bgColorG"); - int cb = DICTOOL->getIntValue_json(options, "bgColorB"); - - int scr = DICTOOL->getIntValue_json(options, "bgStartColorR"); - int scg = DICTOOL->getIntValue_json(options, "bgStartColorG"); - int scb = DICTOOL->getIntValue_json(options, "bgStartColorB"); - - int ecr = DICTOOL->getIntValue_json(options, "bgEndColorR"); - int ecg = DICTOOL->getIntValue_json(options, "bgEndColorG"); - int ecb = DICTOOL->getIntValue_json(options, "bgEndColorB"); - - float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX"); - float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY"); - panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); - - int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); - - int colorType = DICTOOL->getIntValue_json(options, "colorType"); - panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); -// float w = DICTOOL->getFloatValue_json(options, "width"); -// float h = DICTOOL->getFloatValue_json(options, "height"); - panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); - panel->setBackGroundColor(Color3B(cr, cg, cb)); - panel->setBackGroundColorOpacity(co); -// panel->setSize(CCSizeMake(w, h)); - - - JsonDictionary* imageFileNameDic = DICTOOL->getSubDictionary_json(options, "backGroundImageData"); - int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileNameType) - { - case 0: - { - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - panel->setBackGroundImage(imageFileName_tp); - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(imageFileNameDic); - - if (backGroundScale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForScrollViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - setPropsForPanelFromJsonDictionary(widget, options); - UIScrollView* scrollView = (UIScrollView*)widget; - float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); - float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight"); - scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); - /* gui mark */ - int direction = DICTOOL->getFloatValue_json(options, "direction"); - scrollView->setDirection((SCROLLVIEW_DIR)direction); - /**/ - setColorPropsForWidgetFromJsonDictionary(widget,options); -} - -void CCSGUIReader::setPropsForSliderFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - UISlider* slider = (UISlider*)widget; - - bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "barTextureScale9Enable"); - slider->setScale9Enabled(barTextureScale9Enable); - bool bt = DICTOOL->checkObjectExist_json(options, "barFileName"); - float barLength = DICTOOL->getFloatValue_json(options, "length"); - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - if (bt) - { - if (barTextureScale9Enable) - { - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(options, "barFileName"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - if (useMergedTexture) - { - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - slider->loadBarTexture(imageFileName_tp); - } - slider->setSize(Size(barLength, slider->getContentSize().height)); - } - else - { - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(options, "barFileName"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - if (useMergedTexture) - { - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - slider->loadBarTexture(imageFileName_tp); - } - } - } - std::string tp_n = m_strFilePath; - std::string tp_p = m_strFilePath; - std::string tp_d = m_strFilePath; - - const char* normalFileName = DICTOOL->getStringValue_json(options, "ballNormal"); - const char* pressedFileName = DICTOOL->getStringValue_json(options, "ballPressed"); - const char* disabledFileName = DICTOOL->getStringValue_json(options, "ballDisabled"); - - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; - if (useMergedTexture) - { - slider->loadSlidBallTextures(normalFileName,pressedFileName,disabledFileName,UI_TEX_TYPE_PLIST); - } - else - { - slider->loadSlidBallTextures(normalFileName_tp,pressedFileName_tp,disabledFileName_tp); - } - slider->setPercent(DICTOOL->getIntValue_json(options, "percent")); - - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(options, "progressBarFileName"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - if (useMergedTexture) - { - slider->loadProgressBarTexture(imageFileName, UI_TEX_TYPE_PLIST); - } - else - { - slider->loadProgressBarTexture(imageFileName_tp); - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - UISlider* slider = (UISlider*)widget; - - bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "barTextureScale9Enable"); - slider->setScale9Enabled(barTextureScale9Enable); - bool bt = DICTOOL->checkObjectExist_json(options, "barFileName"); - float barLength = DICTOOL->getFloatValue_json(options, "length"); - if (bt) - { - if (barTextureScale9Enable) - { - - JsonDictionary* imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData"); - int imageFileType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileType) - { - case 0: - { - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - slider->loadBarTexture(imageFileName_tp); - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - slider->setSize(Size(barLength, slider->getContentSize().height)); - CC_SAFE_DELETE(imageFileNameDic); - } - else - { - JsonDictionary* imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData"); - int imageFileType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileType) - { - case 0: - { - std::string tp_b = m_strFilePath; - const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - slider->loadBarTexture(imageFileName_tp); - break; - } - case 1: - { - const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(imageFileNameDic); - } - } -// std::string tp_n = m_strFilePath; -// std::string tp_p = m_strFilePath; -// std::string tp_d = m_strFilePath; -// -// const char* normalFileName = DICTOOL->getStringValue_json(options, "ballNormal"); -// const char* pressedFileName = DICTOOL->getStringValue_json(options, "ballPressed"); -// const char* disabledFileName = DICTOOL->getStringValue_json(options, "ballDisabled"); -// -// const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; -// const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; -// const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; -// if (useMergedTexture) -// { -// slider->setSlidBallTextures(normalFileName,pressedFileName,disabledFileName,UI_TEX_TYPE_PLIST); -// } -// else -// { -// slider->setSlidBallTextures(normalFileName_tp,pressedFileName_tp,disabledFileName_tp); -// } - - JsonDictionary* normalDic = DICTOOL->getSubDictionary_json(options, "ballNormalData"); - int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); - switch (normalType) - { - case 0: - { - std::string tp_n = m_strFilePath; - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; - slider->loadSlidBallTextureNormal(normalFileName_tp); - break; - } - case 1: - { - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - slider->loadSlidBallTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(normalDic); - - JsonDictionary* pressedDic = DICTOOL->getSubDictionary_json(options, "ballPressedData"); - int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); - switch (pressedType) - { - case 0: - { - std::string tp_p = m_strFilePath; - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; - slider->loadSlidBallTexturePressed(pressedFileName_tp); - break; - } - case 1: - { - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - slider->loadSlidBallTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(pressedDic); - - JsonDictionary* disabledDic = DICTOOL->getSubDictionary_json(options, "ballDisabledData"); - int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); - switch (disabledType) - { - case 0: - { - std::string tp_d = m_strFilePath; - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; - slider->loadSlidBallTextureDisabled(disabledFileName_tp); - break; - } - case 1: - { - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - slider->loadSlidBallTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(disabledDic); - - slider->setPercent(DICTOOL->getIntValue_json(options, "percent")); - - JsonDictionary* progressBarDic = DICTOOL->getSubDictionary_json(options, "progressBarData"); - int progressBarType = DICTOOL->getIntValue_json(progressBarDic, "resourceType"); - switch (progressBarType) - { - case 0: - { - std::string tp_b = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - slider->loadProgressBarTexture(imageFileName_tp); - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path"); - slider->loadProgressBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForTextAreaFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +void WidgetPropertiesReader0300::setPropsForLabelFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { + DictionaryHelper* dicHelper = DICTOOL; setPropsForWidgetFromJsonDictionary(widget, options); - UILabel* textArea = (UILabel*)widget; - textArea->setText(DICTOOL->getStringValue_json(options, "text")); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); + UILabel* label = (UILabel*)widget; + bool touchScaleChangeAble = dicHelper->getBooleanValue_json(options, "touchScaleEnable"); + label->setTouchScaleChangeEnabled(touchScaleChangeAble); + const char* text = dicHelper->getStringValue_json(options, "text"); + label->setText(text); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); if (fs) { - textArea->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); + label->setFontSize(dicHelper->getIntValue_json(options, "fontSize")); } - int cr = DICTOOL->getIntValue_json(options, "colorR"); - int cg = DICTOOL->getIntValue_json(options, "colorG"); - int cb = DICTOOL->getIntValue_json(options, "colorB"); - textArea->setColor(Color3B(cr, cg, cb)); - textArea->setFontName(DICTOOL->getStringValue_json(options, "fontName")); - bool aw = DICTOOL->checkObjectExist_json(options, "areaWidth"); - bool ah = DICTOOL->checkObjectExist_json(options, "areaHeight"); + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); + if (fn) + { + label->setFontName(dicHelper->getStringValue_json(options, "fontName")); + } + bool aw = dicHelper->checkObjectExist_json(options, "areaWidth"); + bool ah = dicHelper->checkObjectExist_json(options, "areaHeight"); if (aw && ah) { - Size size = Size(DICTOOL->getFloatValue_json(options, "areaWidth"),DICTOOL->getFloatValue_json(options,"areaHeight")); - textArea->setTextAreaSize(size); + Size size = Size(dicHelper->getFloatValue_json(options, "areaWidth"),dicHelper->getFloatValue_json(options,"areaHeight")); + label->setTextAreaSize(size); } - bool ha = DICTOOL->checkObjectExist_json(options, "hAlignment"); + bool ha = dicHelper->checkObjectExist_json(options, "hAlignment"); if (ha) { - textArea->setTextHorizontalAlignment((TextHAlignment)DICTOOL->getIntValue_json(options, "hAlignment")); + label->setTextHorizontalAlignment((TextHAlignment)dicHelper->getIntValue_json(options, "hAlignment")); } - bool va = DICTOOL->checkObjectExist_json(options, "vAlignment"); + bool va = dicHelper->checkObjectExist_json(options, "vAlignment"); if (va) { - textArea->setTextVerticalAlignment((TextVAlignment)DICTOOL->getIntValue_json(options, "vAlignment")); + label->setTextVerticalAlignment((TextVAlignment)dicHelper->getIntValue_json(options, "vAlignment")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } -void CCSGUIReader::setPropsForTextButtonFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - setPropsForButtonFromJsonDictionary(widget, options); - - - UIButton* textButton = (UIButton*)widget; - textButton->setTitleText(DICTOOL->getStringValue_json(options, "text")); - bool cr = DICTOOL->checkObjectExist_json(options, "textColorR"); - bool cg = DICTOOL->checkObjectExist_json(options, "textColorG"); - bool cb = DICTOOL->checkObjectExist_json(options, "textColorB"); - int cri = cr?DICTOOL->getIntValue_json(options, "textColorR"):255; - int cgi = cg?DICTOOL->getIntValue_json(options, "textColorG"):255; - int cbi = cb?DICTOOL->getIntValue_json(options, "textColorB"):255; - textButton->setTitleColor(Color3B(cri,cgi,cbi)); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); - if (fs) - { - textButton->setTitleFontSize(DICTOOL->getIntValue_json(options, "fontSize")); - } - bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); - if (fn) - { - textButton->setTitleFontName(DICTOOL->getStringValue_json(options, "fontName")); - } - setColorPropsForWidgetFromJsonDictionary(widget,options); -} - -void CCSGUIReader::setPropsForTextFieldFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +void WidgetPropertiesReader0300::setPropsForLabelAtlasFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { + DictionaryHelper* dicHelper = DICTOOL; setPropsForWidgetFromJsonDictionary(widget, options); - UITextField* textField = (UITextField*)widget; - bool ph = DICTOOL->checkObjectExist_json(options, "placeHolder"); - if (ph) + UILabelAtlas* labelAtlas = (UILabelAtlas*)widget; + bool sv = dicHelper->checkObjectExist_json(options, "stringValue"); + bool cmf = dicHelper->checkObjectExist_json(options, "charMapFile"); + bool iw = dicHelper->checkObjectExist_json(options, "itemWidth"); + bool ih = dicHelper->checkObjectExist_json(options, "itemHeight"); + bool scm = dicHelper->checkObjectExist_json(options, "startCharMap"); + if (sv && cmf && iw && ih && scm) { - textField->setPlaceHolder(DICTOOL->getStringValue_json(options, "placeHolder")); - } - textField->setText(DICTOOL->getStringValue_json(options, "text")); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); - if (fs) - { - textField->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); - } - bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); - if (fn) - { - textField->setFontName(DICTOOL->getStringValue_json(options, "fontName")); - } - bool tsw = DICTOOL->checkObjectExist_json(options, "touchSizeWidth"); - bool tsh = DICTOOL->checkObjectExist_json(options, "touchSizeHeight"); - if (tsw && tsh) - { - textField->setTouchSize(Size(DICTOOL->getFloatValue_json(options, "touchSizeWidth"), DICTOOL->getFloatValue_json(options,"touchSizeHeight"))); - } - - float dw = DICTOOL->getFloatValue_json(options, "width"); - float dh = DICTOOL->getFloatValue_json(options, "height"); - if (dw > 0.0f || dh > 0.0f) - { - //textField->setSize(CCSizeMake(dw, dh)); - } - bool maxLengthEnable = DICTOOL->getBooleanValue_json(options, "maxLengthEnable"); - textField->setMaxLengthEnabled(maxLengthEnable); - - if (maxLengthEnable) - { - int maxLength = DICTOOL->getIntValue_json(options, "maxLength"); - textField->setMaxLength(maxLength); - } - bool passwordEnable = DICTOOL->getBooleanValue_json(options, "passwordEnable"); - textField->setPasswordEnabled(passwordEnable); - if (passwordEnable) - { - textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, "passwordStyleText")); - } - setColorPropsForWidgetFromJsonDictionary(widget,options); -} - -void CCSGUIReader::setPropsForLoadingBarFromJsonDictionary(UIWidget *widget, JsonDictionary *options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - UILoadingBar* loadingBar = (UILoadingBar*)widget; - bool useMergedTexture = DICTOOL->getBooleanValue_json(options, "useMergedTexture"); - std::string tp_b = m_strFilePath; - const char*imageFileName = DICTOOL->getStringValue_json(options, "texture"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; - if (useMergedTexture) - { - loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - } - else - { - loadingBar->loadTexture(imageFileName_tp); - } - loadingBar->setDirection(LoadingBarType(DICTOOL->getIntValue_json(options, "direction"))); - loadingBar->setPercent(DICTOOL->getIntValue_json(options, "percent")); - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - UILoadingBar* loadingBar = (UILoadingBar*)widget; - - JsonDictionary* imageFileNameDic = DICTOOL->getSubDictionary_json(options, "textureData"); - int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileNameType) - { - case 0: - { - std::string tp_i = m_strFilePath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = NULL; - if (imageFileName && (strcmp(imageFileName, "") != 0)) - { - imageFileName_tp = tp_i.append(imageFileName).c_str(); - loadingBar->loadTexture(imageFileName_tp); - } - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - CC_SAFE_DELETE(imageFileNameDic); - - /* gui mark add load bar scale9 parse */ - bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - loadingBar->setScale9Enabled(scale9Enable); - - if (scale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - loadingBar->setCapInsets(Rect(cx, cy, cw, ch)); - - float width = DICTOOL->getFloatValue_json(options, "width"); - float height = DICTOOL->getFloatValue_json(options, "height"); - loadingBar->setSize(Size(width, height)); - } - /**/ - - loadingBar->setDirection(LoadingBarType(DICTOOL->getIntValue_json(options, "direction"))); - loadingBar->setPercent(DICTOOL->getIntValue_json(options, "percent")); - setColorPropsForWidgetFromJsonDictionary(widget,options); - } -} - -void CCSGUIReader::setPropsForListViewFromJsonDictionary(UIWidget *widget, JsonDictionary *options) -{ - setPropsForScrollViewFromJsonDictionary(widget, options); -} - -void CCSGUIReader::setPropsForPageViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) -{ - setPropsForPanelFromJsonDictionary(widget, options); - setColorPropsForWidgetFromJsonDictionary(widget,options); -} - -void CCSGUIReader::setPropsForLabelBMFontFromJsonDictionary(UIWidget *widget, JsonDictionary *options) -{ - if (m_bOlderVersion) - { - setPropsForWidgetFromJsonDictionary(widget, options); - - UILabelBMFont* labelBMFont = (UILabelBMFont*)widget; - - std::string tp_c = m_strFilePath; - const char* cmf_tp = NULL; - const char* cmft = DICTOOL->getStringValue_json(options, "fileName"); - cmf_tp = tp_c.append(cmft).c_str(); - - labelBMFont->setFntFile(cmf_tp); - - const char* text = DICTOOL->getStringValue_json(options, "text"); - labelBMFont->setText(text); - - setColorPropsForWidgetFromJsonDictionary(widget,options); - } - else - { - setPropsForWidgetFromJsonDictionary(widget, options); - - UILabelBMFont* labelBMFont = (UILabelBMFont*)widget; - - JsonDictionary* cmftDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); - int cmfType = DICTOOL->getIntValue_json(cmftDic, "resourceType"); + JsonDictionary* cmftDic = dicHelper->getSubDictionary_json(options, "charMapFileData"); + int cmfType = dicHelper->getIntValue_json(cmftDic, "resourceType"); switch (cmfType) { case 0: { std::string tp_c = m_strFilePath; - const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, "path"); + const char* cmfPath = dicHelper->getStringValue_json(cmftDic, "path"); const char* cmf_tp = tp_c.append(cmfPath).c_str(); - labelBMFont->setFntFile(cmf_tp); + labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth"),dicHelper->getIntValue_json(options,"itemHeight"),dicHelper->getStringValue_json(options, "startCharMap")); break; } case 1: @@ -1563,28 +1490,406 @@ void CCSGUIReader::setPropsForLabelBMFontFromJsonDictionary(UIWidget *widget, Js break; } CC_SAFE_DELETE(cmftDic); - - const char* text = DICTOOL->getStringValue_json(options, "text"); - labelBMFont->setText(text); - - setColorPropsForWidgetFromJsonDictionary(widget,options); } + setColorPropsForWidgetFromJsonDictionary(widget,options); } -void CCSGUIReader::setPropsForDragPanelFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +void WidgetPropertiesReader0300::setPropsForLayoutFromJsonDictionary(UIWidget*widget,JsonDictionary* options) { - setPropsForPanelFromJsonDictionary(widget, options); + DictionaryHelper* dicHelper = DICTOOL; - UIScrollView* dragPanel = (UIScrollView*)widget; + setPropsForWidgetFromJsonDictionary(widget, options); + UILayout* panel = (UILayout*)widget; + if (!dynamic_cast(widget) + && !dynamic_cast(widget)) + { + panel->setClippingEnabled(dicHelper->getBooleanValue_json(options, "clipAble")); + } + bool backGroundScale9Enable = dicHelper->getBooleanValue_json(options, "backGroundScale9Enable"); + panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); + int cr = dicHelper->getIntValue_json(options, "bgColorR"); + int cg = dicHelper->getIntValue_json(options, "bgColorG"); + int cb = dicHelper->getIntValue_json(options, "bgColorB"); - bool bounceEnable = DICTOOL->getBooleanValue_json(options, "bounceEnable"); - dragPanel->setBounceEnabled(bounceEnable); + int scr = dicHelper->getIntValue_json(options, "bgStartColorR"); + int scg = dicHelper->getIntValue_json(options, "bgStartColorG"); + int scb = dicHelper->getIntValue_json(options, "bgStartColorB"); - float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); - float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight"); - dragPanel->setInnerContainerSize(Size(innerWidth, innerHeight)); + int ecr = dicHelper->getIntValue_json(options, "bgEndColorR"); + int ecg = dicHelper->getIntValue_json(options, "bgEndColorG"); + int ecb = dicHelper->getIntValue_json(options, "bgEndColorB"); - setColorPropsForWidgetFromJsonDictionary(widget, options); + float bgcv1 = dicHelper->getFloatValue_json(options, "vectorX"); + float bgcv2 = dicHelper->getFloatValue_json(options, "vectorY"); + panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); + + int co = dicHelper->getIntValue_json(options, "bgColorOpacity"); + + int colorType = dicHelper->getIntValue_json(options, "colorType"); + panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); + panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); + panel->setBackGroundColor(Color3B(cr, cg, cb)); + panel->setBackGroundColorOpacity(co); + + + JsonDictionary* imageFileNameDic = dicHelper->getSubDictionary_json(options, "backGroundImageData"); + int imageFileNameType = dicHelper->getIntValue_json(imageFileNameDic, "resourceType"); + switch (imageFileNameType) + { + case 0: + { + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + panel->setBackGroundImage(imageFileName_tp); + break; + } + case 1: + { + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(imageFileNameDic); + + if (backGroundScale9Enable) + { + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); } +void WidgetPropertiesReader0300::setPropsForScrollViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForLayoutFromJsonDictionary(widget, options); + UIScrollView* scrollView = (UIScrollView*)widget; + float innerWidth = dicHelper->getFloatValue_json(options, "innerWidth"); + float innerHeight = dicHelper->getFloatValue_json(options, "innerHeight"); + scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); + int direction = dicHelper->getFloatValue_json(options, "direction"); + scrollView->setDirection((SCROLLVIEW_DIR)direction); + scrollView->setBounceEnabled(dicHelper->getBooleanValue_json(options, "bounceEnable")); + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0300::setPropsForSliderFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UISlider* slider = (UISlider*)widget; + + bool barTextureScale9Enable = dicHelper->getBooleanValue_json(options, "barTextureScale9Enable"); + slider->setScale9Enabled(barTextureScale9Enable); + bool bt = dicHelper->checkObjectExist_json(options, "barFileName"); + float barLength = dicHelper->getFloatValue_json(options, "length"); + if (bt) + { + if (barTextureScale9Enable) + { + + JsonDictionary* imageFileNameDic = dicHelper->getSubDictionary_json(options, "barFileNameData"); + int imageFileType = dicHelper->getIntValue_json(imageFileNameDic, "resourceType"); + switch (imageFileType) + { + case 0: + { + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + slider->loadBarTexture(imageFileName_tp); + break; + } + case 1: + { + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + + slider->setSize(Size(barLength, slider->getContentSize().height)); + CC_SAFE_DELETE(imageFileNameDic); + } + else + { + JsonDictionary* imageFileNameDic = dicHelper->getSubDictionary_json(options, "barFileNameData"); + int imageFileType = dicHelper->getIntValue_json(imageFileNameDic, "resourceType"); + switch (imageFileType) + { + case 0: + { + std::string tp_b = m_strFilePath; + const char*imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + slider->loadBarTexture(imageFileName_tp); + break; + } + case 1: + { + const char*imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(imageFileNameDic); + } + } + + JsonDictionary* normalDic = dicHelper->getSubDictionary_json(options, "ballNormalData"); + int normalType = dicHelper->getIntValue_json(normalDic, "resourceType"); + switch (normalType) + { + case 0: + { + std::string tp_n = m_strFilePath; + const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path"); + const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():NULL; + slider->loadSlidBallTextureNormal(normalFileName_tp); + break; + } + case 1: + { + const char* normalFileName = dicHelper->getStringValue_json(normalDic, "path"); + slider->loadSlidBallTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(normalDic); + + JsonDictionary* pressedDic = dicHelper->getSubDictionary_json(options, "ballPressedData"); + int pressedType = dicHelper->getIntValue_json(pressedDic, "resourceType"); + switch (pressedType) + { + case 0: + { + std::string tp_p = m_strFilePath; + const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path"); + const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():NULL; + slider->loadSlidBallTexturePressed(pressedFileName_tp); + break; + } + case 1: + { + const char* pressedFileName = dicHelper->getStringValue_json(pressedDic, "path"); + slider->loadSlidBallTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(pressedDic); + + JsonDictionary* disabledDic = dicHelper->getSubDictionary_json(options, "ballDisabledData"); + int disabledType = dicHelper->getIntValue_json(disabledDic, "resourceType"); + switch (disabledType) + { + case 0: + { + std::string tp_d = m_strFilePath; + const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path"); + const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():NULL; + slider->loadSlidBallTextureDisabled(disabledFileName_tp); + break; + } + case 1: + { + const char* disabledFileName = dicHelper->getStringValue_json(disabledDic, "path"); + slider->loadSlidBallTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(disabledDic); + + slider->setPercent(dicHelper->getIntValue_json(options, "percent")); + + JsonDictionary* progressBarDic = dicHelper->getSubDictionary_json(options, "progressBarData"); + int progressBarType = dicHelper->getIntValue_json(progressBarDic, "resourceType"); + switch (progressBarType) + { + case 0: + { + std::string tp_b = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(progressBarDic, "path"); + const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():NULL; + slider->loadProgressBarTexture(imageFileName_tp); + break; + } + case 1: + { + const char* imageFileName = dicHelper->getStringValue_json(progressBarDic, "path"); + slider->loadProgressBarTexture(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0300::setPropsForTextFieldFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UITextField* textField = (UITextField*)widget; + bool ph = dicHelper->checkObjectExist_json(options, "placeHolder"); + if (ph) + { + textField->setPlaceHolder(dicHelper->getStringValue_json(options, "placeHolder")); + } + textField->setText(dicHelper->getStringValue_json(options, "text")); + bool fs = dicHelper->checkObjectExist_json(options, "fontSize"); + if (fs) + { + textField->setFontSize(dicHelper->getIntValue_json(options, "fontSize")); + } + bool fn = dicHelper->checkObjectExist_json(options, "fontName"); + if (fn) + { + textField->setFontName(dicHelper->getStringValue_json(options, "fontName")); + } + bool tsw = dicHelper->checkObjectExist_json(options, "touchSizeWidth"); + bool tsh = dicHelper->checkObjectExist_json(options, "touchSizeHeight"); + if (tsw && tsh) + { + textField->setTouchSize(Size(dicHelper->getFloatValue_json(options, "touchSizeWidth"), dicHelper->getFloatValue_json(options,"touchSizeHeight"))); + } + + float dw = dicHelper->getFloatValue_json(options, "width"); + float dh = dicHelper->getFloatValue_json(options, "height"); + if (dw > 0.0f || dh > 0.0f) + { + //textField->setSize(Size(dw, dh)); + } + bool maxLengthEnable = dicHelper->getBooleanValue_json(options, "maxLengthEnable"); + textField->setMaxLengthEnabled(maxLengthEnable); + + if (maxLengthEnable) + { + int maxLength = dicHelper->getIntValue_json(options, "maxLength"); + textField->setMaxLength(maxLength); + } + bool passwordEnable = dicHelper->getBooleanValue_json(options, "passwordEnable"); + textField->setPasswordEnabled(passwordEnable); + if (passwordEnable) + { + textField->setPasswordStyleText(dicHelper->getStringValue_json(options, "passwordStyleText")); + } + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0300::setPropsForLoadingBarFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + UILoadingBar* loadingBar = (UILoadingBar*)widget; + + JsonDictionary* imageFileNameDic = dicHelper->getSubDictionary_json(options, "textureData"); + int imageFileNameType = dicHelper->getIntValue_json(imageFileNameDic, "resourceType"); + switch (imageFileNameType) + { + case 0: + { + std::string tp_i = m_strFilePath; + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + const char* imageFileName_tp = NULL; + if (imageFileName && (strcmp(imageFileName, "") != 0)) + { + imageFileName_tp = tp_i.append(imageFileName).c_str(); + loadingBar->loadTexture(imageFileName_tp); + } + break; + } + case 1: + { + const char* imageFileName = dicHelper->getStringValue_json(imageFileNameDic, "path"); + loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); + break; + } + default: + break; + } + CC_SAFE_DELETE(imageFileNameDic); + + /* gui mark add load bar scale9 parse */ + bool scale9Enable = dicHelper->getBooleanValue_json(options, "scale9Enable"); + loadingBar->setScale9Enabled(scale9Enable); + + if (scale9Enable) + { + float cx = dicHelper->getFloatValue_json(options, "capInsetsX"); + float cy = dicHelper->getFloatValue_json(options, "capInsetsY"); + float cw = dicHelper->getFloatValue_json(options, "capInsetsWidth"); + float ch = dicHelper->getFloatValue_json(options, "capInsetsHeight"); + + loadingBar->setCapInsets(Rect(cx, cy, cw, ch)); + + float width = dicHelper->getFloatValue_json(options, "width"); + float height = dicHelper->getFloatValue_json(options, "height"); + loadingBar->setSize(Size(width, height)); + } + /**/ + + loadingBar->setDirection(LoadingBarType(dicHelper->getIntValue_json(options, "direction"))); + loadingBar->setPercent(dicHelper->getIntValue_json(options, "percent")); + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0300::setPropsForLabelBMFontFromJsonDictionary(UIWidget *widget, JsonDictionary *options) +{ + DictionaryHelper* dicHelper = DICTOOL; + setPropsForWidgetFromJsonDictionary(widget, options); + + UILabelBMFont* labelBMFont = (UILabelBMFont*)widget; + + JsonDictionary* cmftDic = dicHelper->getSubDictionary_json(options, "fileNameData"); + int cmfType = dicHelper->getIntValue_json(cmftDic, "resourceType"); + switch (cmfType) + { + case 0: + { + std::string tp_c = m_strFilePath; + const char* cmfPath = dicHelper->getStringValue_json(cmftDic, "path"); + const char* cmf_tp = tp_c.append(cmfPath).c_str(); + labelBMFont->setFntFile(cmf_tp); + break; + } + case 1: + CCLOG("Wrong res type of LabelAtlas!"); + break; + default: + break; + } + CC_SAFE_DELETE(cmftDic); + + const char* text = dicHelper->getStringValue_json(options, "text"); + labelBMFont->setText(text); + + setColorPropsForWidgetFromJsonDictionary(widget,options); +} + +void WidgetPropertiesReader0300::setPropsForPageViewFromJsonDictionary(UIWidget*widget,JsonDictionary* options) +{ + +} + +void WidgetPropertiesReader0300::setPropsForListViewFromJsonDictionary(UIWidget* widget, JsonDictionary* options) +{ + +} } \ No newline at end of file diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h index 415b7b9e81..19a37292fd 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -31,49 +31,90 @@ namespace cocostudio { #define kCCSVersion 1.0 -class CCSGUIReader : cocos2d::Object +class GUIReader : public cocos2d::Object { public: - CCSGUIReader(); - ~CCSGUIReader(); - static CCSGUIReader* shareReader(); - static void purgeCCSGUIReader(); + GUIReader(); + ~GUIReader(); + static GUIReader* shareReader(); + static void purgeGUIReader(); gui::UIWidget* widgetFromJsonFile(const char* fileName); - gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* data); - int getVersionInteger(const char* str); - - void setPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setColorPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForCheckBoxFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForImageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForLabelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForLabelAtlasFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForContainerWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForPanelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForScrollViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForSliderFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForTextAreaFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForTextButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForTextFieldFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForLoadingBarFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForImageButtonFromJsonDictionary(gui::UIWidget* widget, JsonDictionary* options); - void setPropsForListViewFromJsonDictionary(gui::UIWidget* widget, JsonDictionary* options); - void setPropsForPageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForLabelBMFontFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void setPropsForDragPanelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); - void storeFileDesignSize(const char* fileName, const cocos2d::Size &size); - const cocos2d::Size getFileDesignSize(const char* fileName) const; protected: std::string m_strFilePath; - bool m_bOlderVersion; cocos2d::Dictionary* _fileDesignSizes; }; +class WidgetPropertiesReader : public cocos2d::Object +{ +public: + virtual gui::UIWidget* createWidget(JsonDictionary* dic, const char* fullPath, const char* fileName)=0; + virtual gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* dic) = 0; +protected: + std::string m_strFilePath; +}; + + +class WidgetPropertiesReader0250 : public WidgetPropertiesReader +{ + + +public: + WidgetPropertiesReader0250(){}; + virtual ~WidgetPropertiesReader0250(){}; + + virtual gui::UIWidget* createWidget(JsonDictionary* dic, const char* fullPath, const char* fileName); + virtual gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* dic); + virtual void setPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + + virtual void setColorPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForCheckBoxFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForImageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelAtlasFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelBMFontFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLoadingBarFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForSliderFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForTextFieldFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + + virtual void setPropsForLayoutFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForScrollViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); +}; + +class WidgetPropertiesReader0300 : public WidgetPropertiesReader +{ + + +public: + WidgetPropertiesReader0300(){}; + virtual ~WidgetPropertiesReader0300(){}; + + virtual gui::UIWidget* createWidget(JsonDictionary* dic, const char* fullPath, const char* fileName); + virtual gui::UIWidget* widgetFromJsonDictionary(JsonDictionary* dic); + virtual void setPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + + virtual void setColorPropsForWidgetFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForButtonFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForCheckBoxFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForImageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelAtlasFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLabelBMFontFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForLoadingBarFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForSliderFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForTextFieldFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + + virtual void setPropsForLayoutFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForPageViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForScrollViewFromJsonDictionary(gui::UIWidget*widget,JsonDictionary* options); + virtual void setPropsForListViewFromJsonDictionary(gui::UIWidget* widget, JsonDictionary* options); +}; + + } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp index a2a3ddcf42..10b482311a 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp @@ -26,7 +26,7 @@ bool UIScene::init() m_pUiLayer = UILayer::create(); addChild(m_pUiLayer); - m_pWidget = dynamic_cast(cocostudio::CCSGUIReader::shareReader()->widgetFromJsonFile("cocosgui/UITest/UITest.json")); + m_pWidget = dynamic_cast(cocostudio::GUIReader::shareReader()->widgetFromJsonFile("cocosgui/UITest/UITest.json")); m_pUiLayer->addWidget(m_pWidget); m_pSceneTitle = dynamic_cast(m_pUiLayer->getWidgetByName("UItest")); From df214acb6f062a5f5aa0e06605de89c6b71d157b Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Nov 2013 18:42:39 +0800 Subject: [PATCH 14/28] [develop] Updating bindings-generator, fixing forward declare that generates binding glue codes which is an empty class. --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 9797d44032..cad9d9ec4a 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 9797d4403207848f431d5b6456632cc966d84b0d +Subproject commit cad9d9ec4a24bdad1de383c941afa9418501161e From 3472d7ad50be0f61135949f06714f5bc4de9afde Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 11 Nov 2013 10:57:57 +0000 Subject: [PATCH 15/28] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index 5788b25003..ce2f223cd3 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit 5788b2500339473ecc19acf1c2e43656a2537a6d +Subproject commit ce2f223cd3b4bffbd564df37c738fc5b18f8d853 From d6446e9b14951fb49764a6fed7d31cb1213f74df Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 11 Nov 2013 16:07:46 -0800 Subject: [PATCH 16/28] calls `delete[]` instead of `delete` calls `delete[]` instead of `delete` --- cocos/2d/platform/ios/CCDevice.mm | 6 ++++-- cocos/physics/CCPhysicsShape.cpp | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cocos/2d/platform/ios/CCDevice.mm b/cocos/2d/platform/ios/CCDevice.mm index 4555b14df2..e8610db653 100644 --- a/cocos/2d/platform/ios/CCDevice.mm +++ b/cocos/2d/platform/ios/CCDevice.mm @@ -37,8 +37,10 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher; - (id) init { - _acceleration = new cocos2d::Acceleration(); - _motionManager = [[CMMotionManager alloc] init]; + if( (self = [super init]) ) { + _acceleration = new cocos2d::Acceleration(); + _motionManager = [[CMMotionManager alloc] init]; + } return self; } diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index bb043b027a..91df06d1ea 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -539,7 +539,7 @@ bool PhysicsShapePolygon::init(const Point* points, int count, const PhysicsMate cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); cpShape* shape = cpPolyShapeNew(_info->getSharedBody(), count, vecs, PhysicsHelper::point2cpv(offset)); - CC_SAFE_DELETE(vecs); + CC_SAFE_DELETE_ARRAY(vecs); CC_BREAK_IF(shape == nullptr); @@ -563,7 +563,7 @@ float PhysicsShapePolygon::calculateArea(const Point* points, int count) cpVect* vecs = new cpVect[count]; PhysicsHelper::points2cpvs(points, vecs, count); float area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vecs)); - CC_SAFE_DELETE(vecs); + CC_SAFE_DELETE_ARRAY(vecs); return area; } @@ -574,7 +574,7 @@ float PhysicsShapePolygon::calculateMoment(float mass, const Point* points, int PhysicsHelper::points2cpvs(points, vecs, count); float moment = mass == PHYSICS_INFINITY ? PHYSICS_INFINITY : PhysicsHelper::cpfloat2float(cpMomentForPoly(mass, count, vecs, PhysicsHelper::point2cpv(offset))); - CC_SAFE_DELETE(vecs); + CC_SAFE_DELETE_ARRAY(vecs); return moment; } From a5eeff4f4fdaec575914470519174e6f89a6e382 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Mon, 11 Nov 2013 16:09:32 -0800 Subject: [PATCH 17/28] fixes for android create improves the message. fixes some grammar errors --- build/android-build.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build/android-build.py b/build/android-build.py index c630010ef8..4a65c9e6e2 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -15,11 +15,12 @@ ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES + JSB_SAMPLES def usage(): - print "%prog [-n ndk-build-parameter] target\n\ - valid target are [hellocpp|testcpp|simplegame|assetsmanager|hellolua|testlua|cocosdragon\ -|crystalcraze|moonwarriors|testjavascript|watermelonwithme], of course you can use 'cpp'\ -to build all cpp samples, 'lua' to build all lua samples, 'jsb' to build all javascript samples,\ - and 'all' for all samples" + print """%s [-n ndk-build-parameter] target. + +Valid targets are: [hellocpp|testcpp|simplegame|assetsmanager|hellolua|testlua|cocosdragon + |crystalcraze|moonwarriors|testjavascript|watermelonwithme] + +You can use [all|cpp|lua|jsb], to build all, or all the C++, or all the Lua, or all the JavaScript samples respectevely.""" % sys.argv[0] def check_environment_variables(): ''' Checking the environment NDK_ROOT, which will be used for building From d7a0787336adbdade7f2bb1cd9b42e6eb84dead5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Nov 2013 09:44:07 +0800 Subject: [PATCH 18/28] Up --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index d553c07d24..f8e3957968 100644 --- a/AUTHORS +++ b/AUTHORS @@ -642,6 +642,7 @@ Developers: ledyba Fixed a bug that EventListeners can't be removed sometimes. Fixed a bug that the data size has to be specified when parsing XML using TinyXML. + Closed X display after getting DPI on Linux. Luis Parravicini (luisparravicini) Fixed typos in create_project.py. From 412712c5e4737394b8f7a13452c7eec60d695f4b Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Nov 2013 09:45:07 +0800 Subject: [PATCH 19/28] Update CHANGELOG[ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index e9e1da977c..e7632e9061 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -34,6 +34,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [FIX] Can't click the area that outside of keyboard to close keyboard when using EditBox. [Linux] [NEW] Used CMake to build linux projects. + [FIX] Closed X display after getting DPI on Linux. [Desktop] [FIX] Trigger onKeyReleased only after the key has been released. [Javascript binding] From 8c42e62a3fdd6fb53f8bf3a85331b8458b2cb528 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Nov 2013 10:32:22 +0800 Subject: [PATCH 20/28] Update AUTHORS [ci skip] --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index f8e3957968..e857757e3c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -650,6 +650,9 @@ Developers: xhcnb Device::setAccelerometerEnabled needs to be invoked before adding ACC listener. + bopohaa + Fixed a bug that Webp test crashes. + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, From 0358eae8f03b9f5cf9b0dc0af9cbc0ce0b8e2b47 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Nov 2013 10:33:18 +0800 Subject: [PATCH 21/28] Update CHANGELOG [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index e7632e9061..e06e8d0e37 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ cocos2d-x-3.0alpha1 @??? 2013 [NEW] Sprite: Override setScale(float scaleX, float scaleY) [NEW] External: added | operator for Control::EventType [NEW] Android & iOS screen size change support + [FIX] Webp Test Crashes. [Android] [FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes [FIX] Fixed application will crash when pause and resume. From db07c781abdbb672b93f79b2f29e3e92906d99c7 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Nov 2013 10:35:50 +0800 Subject: [PATCH 22/28] #include for std::max, std::min on VS2013. --- cocos/2d/CCTMXTiledMap.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/CCTMXTiledMap.cpp b/cocos/2d/CCTMXTiledMap.cpp index 4205adb1fe..7ab6da363b 100644 --- a/cocos/2d/CCTMXTiledMap.cpp +++ b/cocos/2d/CCTMXTiledMap.cpp @@ -27,6 +27,7 @@ THE SOFTWARE. #include "CCTMXXMLParser.h" #include "CCTMXLayer.h" #include "CCSprite.h" +#include NS_CC_BEGIN From e2224d53160a7006136dcc66e014322a3d2019e9 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 12 Nov 2013 11:24:59 +0800 Subject: [PATCH 23/28] [ci skip] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 938f0c39fb..c5d464e62f 100644 --- a/README.md +++ b/README.md @@ -103,8 +103,8 @@ $ cmake .. $ make ``` - You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, you should make it to direct to a correct one. - `install-deps-linux.sh` only has to be run onece. + You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, + you should make it to direct to a correct one. `install-deps-linux.sh` only has to be run onece. * For Windows From e182328d5101b934ac2c227c7ac55b1c514b4ff2 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Tue, 12 Nov 2013 16:25:39 +0800 Subject: [PATCH 24/28] fix incomplete copy resource --- build/android-build.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/build/android-build.py b/build/android-build.py index 4a65c9e6e2..7670e03dd2 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -109,6 +109,7 @@ def copy_files(src, dst): if os.path.isdir(path): new_dst = os.path.join(dst, item) os.mkdir(new_dst) + print new_dst copy_files(path, new_dst) def copy_resources(target, app_android_root): @@ -133,13 +134,26 @@ def copy_resources(target, app_android_root): resources_dir = os.path.join(app_android_root, "../../Shared/games/CocosDragonJS/Published files Android") if target == "crystalcraze": resources_dir = os.path.join(app_android_root, "../../Shared/games/CrystalCraze/Published-Android") - if target == "moonwarriors": - resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/res") if target == "testjavascript": resources_dir = os.path.join(app_android_root, "../../Shared/tests/") if target == "watermelonwithme": resources_dir = os.path.join(app_android_root, "../../Shared/games/WatermelonWithMe") - copy_files(resources_dir, assets_dir) + if target != "moonwarriors": + copy_files(resources_dir, assets_dir) + else: + resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/res") + dst_dir = os.path.join(assets_dir, "res") + os.mkdir(dst_dir) + copy_files(resources_dir, dst_dir) + resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors/src") + dst_dir = os.path.join(assets_dir, "src") + os.mkdir(dst_dir) + copy_files(resources_dir, dst_dir) + resources_dir = os.path.join(app_android_root, "../../Shared/games/MoonWarriors") + for item in os.listdir(resources_dir): + path = os.path.join(resources_dir, item) + if item.endswith('.js') and os.path.isfile(path): + shutil.copy(path, assets_dir) # AssetsManager test should also copy javascript files if target == "assetsmanager": From 18bc96096c389df1946db7652d0b86c8a47ecd09 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Tue, 12 Nov 2013 17:18:51 +0800 Subject: [PATCH 25/28] Resolve some warning and modify uint32_t to long --- cocos/scripting/lua/bindings/LuaBasicConversions.cpp | 2 +- cocos/scripting/lua/bindings/LuaBasicConversions.h | 2 +- tools/bindings-generator | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index 4c91daa42b..6fe9afcd00 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp @@ -32,7 +32,7 @@ extern "C" { } #endif -std::map g_luaType; +std::map g_luaType; #if COCOS2D_DEBUG >=1 void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.h b/cocos/scripting/lua/bindings/LuaBasicConversions.h index 2e2e525993..6861d1a056 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.h +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.h @@ -10,7 +10,7 @@ extern "C" { using namespace cocos2d; -extern std::map g_luaType; +extern std::map g_luaType; #if COCOS2D_DEBUG >=1 void luaval_to_native_err(lua_State* L,const char* msg,tolua_Error* err); diff --git a/tools/bindings-generator b/tools/bindings-generator index 7ccbabbaa6..5f62d1fbcf 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 7ccbabbaa677607048c511b33cb6d83b2081220e +Subproject commit 5f62d1fbcf526dce6135e3829682b421bf794823 From cb51df7d65df708ccc63e9aec11b35a4bce8f4bb Mon Sep 17 00:00:00 2001 From: samuele3 Date: Tue, 12 Nov 2013 17:31:24 +0800 Subject: [PATCH 26/28] Update bindings-generator --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 5f62d1fbcf..2f3c19e01d 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 5f62d1fbcf526dce6135e3829682b421bf794823 +Subproject commit 2f3c19e01d5043485d0887ad69a3f02e312ad690 From 0acaa1f76e4c44477fcf88d52f18189ff9a75581 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 12 Nov 2013 09:50:13 +0000 Subject: [PATCH 27/28] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index ce2f223cd3..3fa10c3f8f 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit ce2f223cd3b4bffbd564df37c738fc5b18f8d853 +Subproject commit 3fa10c3f8f9fe083ef05cb401924d31740da9719 From d43bc3f75d92026f66c871bb47192daec9491676 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Tue, 12 Nov 2013 17:53:23 +0800 Subject: [PATCH 28/28] remove unnecessary print --- build/android-build.py | 1 - 1 file changed, 1 deletion(-) diff --git a/build/android-build.py b/build/android-build.py index 7670e03dd2..34ac6010d9 100755 --- a/build/android-build.py +++ b/build/android-build.py @@ -109,7 +109,6 @@ def copy_files(src, dst): if os.path.isdir(path): new_dst = os.path.join(dst, item) os.mkdir(new_dst) - print new_dst copy_files(path, new_dst) def copy_resources(target, app_android_root):