From 6054dc0197fb1b6cd8e35de40d91f7b60af8c331 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 30 Nov 2015 16:17:13 +0800 Subject: [PATCH 01/66] update for ui test --- .../UIButtonTest/UIButtonTest.cpp | 18 +++++++++++ .../UIButtonTest/UIButtonTest.h | 2 ++ .../UICheckBoxTest/UICheckBoxTest.cpp | 30 ++++++++++++++++--- .../UICheckBoxTest/UICheckBoxTest.h | 2 ++ .../UIImageViewTest/UIImageViewTest.cpp | 15 +++++++++- .../UIImageViewTest/UIImageViewTest.h | 4 +++ .../UILayoutTest/UILayoutTest.cpp | 16 ++++++++++ .../UILayoutTest/UILayoutTest.h | 4 +++ .../UILoadingBarTest/UILoadingBarTest.cpp | 16 ++++++++++ .../UILoadingBarTest/UILoadingBarTest.h | 2 ++ .../UISliderTest/UISliderTest.cpp | 22 ++++++++++++++ .../UISliderTest/UISliderTest.h | 2 ++ .../UITextAtlasTest/UITextAtlasTest.cpp | 14 +++++++++ .../UITextAtlasTest/UITextAtlasTest.h | 3 ++ .../UITextBMFontTest/UITextBMFontTest.cpp | 15 ++++++++++ .../UITextBMFontTest/UITextBMFontTest.h | 3 ++ 16 files changed, 163 insertions(+), 5 deletions(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 09531e8cd0..12384146ca 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -75,7 +75,15 @@ bool UIButtonTest::init() _uiLayer->addChild(imageView); + _button = button; + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIButtonTest::printCheckBoxResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } @@ -117,6 +125,16 @@ void UIButtonTest::touchEvent(Ref *pSender, Widget::TouchEventType type) } } +void UIButtonTest::printCheckBoxResources(cocos2d::Ref* sender) +{ + cocos2d::ResouceData normalFileName = _button->getNormalFile(); + CCLOG("normalFileName Name : %s, Type: %d", normalFileName.file.c_str(), normalFileName.type); + cocos2d::ResouceData clickedFileName = _button->getPressedFile(); + CCLOG("clickedFileName Name : %s, Type: %d", clickedFileName.file.c_str(), clickedFileName.type); + cocos2d::ResouceData disabledFileName = _button->getDisabledFile(); + CCLOG("disabledFileName Name : %s, Type: %d", disabledFileName.file.c_str(), disabledFileName.type); +} + // UIButtonTest_Scale9 UIButtonTest_Scale9::UIButtonTest_Scale9() diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h index c52d86f2f2..24153971ae 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h @@ -40,8 +40,10 @@ public: virtual bool init() override; void touchEvent(cocos2d::Ref* sender, cocos2d::ui::Widget::TouchEventType type); + void printCheckBoxResources(cocos2d::Ref* sender); protected: cocos2d::ui::Text* _displayValueLabel; + cocos2d::ui::Button* _button; }; class UIButtonTest_Scale9 : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index 746705dc41..8513aee0ef 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -40,15 +40,23 @@ bool UICheckBoxTest::init() _uiLayer->addChild(alert); // Create the checkbox - CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png", + _checkBox = CheckBox::create("cocosui/check_box_normal.png", "cocosui/check_box_normal_press.png", "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png", "cocosui/check_box_active_disable.png"); - checkBox->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + _checkBox->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this)); - _uiLayer->addChild(checkBox); + _checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this)); + _uiLayer->addChild(_checkBox); + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UICheckBoxTest::printCheckBoxResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } @@ -73,6 +81,20 @@ void UICheckBoxTest::selectedEvent(Ref* pSender,CheckBox::EventType type) } +void UICheckBoxTest::printCheckBoxResources(cocos2d::Ref* sender) +{ + cocos2d::ResouceData backGroundFileName = _checkBox->getBackNormalFile(); + CCLOG("backGroundFile Name : %s, Type: %d", backGroundFileName.file.c_str(),backGroundFileName.type); + cocos2d::ResouceData backGroundSelectedFileName = _checkBox->getBackPressedFile(); + CCLOG("backGroundSelectedFile Name : %s, Type: %d", backGroundSelectedFileName.file.c_str(), backGroundSelectedFileName.type); + cocos2d::ResouceData backGroundDisabledFileName = _checkBox->getBackDisabledFile(); + CCLOG("backGroundDisabledFile Name : %s, Type: %d", backGroundDisabledFileName.file.c_str(), backGroundDisabledFileName.type); + cocos2d::ResouceData frontCrossFileName = _checkBox->getCrossNormalFile(); + CCLOG("frontCrossFile Name : %s, Type: %d", frontCrossFileName.file.c_str(), frontCrossFileName.type); + cocos2d::ResouceData frontCrossDisabledFileName = _checkBox->getCrossDisabeldFile(); + CCLOG("frontCrossDisabledFile Name : %s, Type: %d", frontCrossDisabledFileName.file.c_str(), frontCrossDisabledFileName.type); +} + // UICheckBoxDefaultBehaviorTest UICheckBoxDefaultBehaviorTest::UICheckBoxDefaultBehaviorTest() diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h index 061f277c5b..3aaf6404f2 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h @@ -40,8 +40,10 @@ public: virtual bool init() override; void selectedEvent(cocos2d::Ref* sender,cocos2d::ui::CheckBox::EventType type); + void printCheckBoxResources(cocos2d::Ref* sender); protected: cocos2d::ui::Text* _displayValueLabel; + cocos2d::ui::CheckBox* _checkBox; }; class UICheckBoxDefaultBehaviorTest : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp index c96140ee0d..38e8f8f6ac 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp @@ -34,13 +34,26 @@ bool UIImageViewTest::init() _uiLayer->addChild(imageView); - + _image = imageView; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIImageViewTest::printCheckBoxResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } return false; } +void UIImageViewTest::printCheckBoxResources(cocos2d::Ref* sender) +{ + cocos2d::ResouceData textureFile = _image->getRenderFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); +} // UIImageViewTest_Scale9 diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h index e98c498d24..d751d86517 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h @@ -35,6 +35,10 @@ public: CREATE_FUNC(UIImageViewTest); virtual bool init() override; + + void printCheckBoxResources(cocos2d::Ref* sender); +protected: + cocos2d::ui::ImageView* _image; }; class UIImageViewTest_Scale9 : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp index 02cdb5d4d5..c13b250ad8 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp @@ -264,12 +264,28 @@ bool UILayoutTest_BackGroundImage::init() button_scale9->getContentSize().height / 2.0f)); layout->addChild(button_scale9); + + _layout = layout; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILayoutTest_BackGroundImage::printCheckBoxResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } return false; } +void UILayoutTest_BackGroundImage::printCheckBoxResources(cocos2d::Ref* sender) +{ + cocos2d::ResouceData textureFile = _layout->getRenderFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); +} + // UILayoutTest_BackGroundImage_Scale9 UILayoutTest_BackGroundImage_Scale9::UILayoutTest_BackGroundImage_Scale9() diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h index 65336919c9..d634abf583 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h @@ -67,6 +67,10 @@ public: virtual bool init() override; CREATE_FUNC(UILayoutTest_BackGroundImage); + + void printCheckBoxResources(cocos2d::Ref* sender); +protected: + cocos2d::ui::Layout* _layout; }; class UILayoutTest_BackGroundImage_Scale9 : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index 20e93d970e..5fc1341a21 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -78,6 +78,16 @@ bool UILoadingBarTest_Left::init() _uiLayer->addChild(loadingBar,1); _uiLayer->addChild(loadingBarCopy,2); _uiLayer->addChild(button); + + _loadingBar = loadingBar; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILoadingBarTest_Left::printCheckBoxResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } @@ -97,6 +107,12 @@ void UILoadingBarTest_Left::update(float delta) loadingBarCopy->setPercent(_count); } +void UILoadingBarTest_Left::printCheckBoxResources(cocos2d::Ref* sender) +{ + cocos2d::ResouceData textureFile = _loadingBar->getRenderFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); +} + // UILoadingBarTest_Right UILoadingBarTest_Right::UILoadingBarTest_Right() diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h index d70d73c8d4..cb97117d99 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h @@ -38,9 +38,11 @@ public: ~UILoadingBarTest_Left(); virtual bool init() override; void update(float delta)override; + void printCheckBoxResources(cocos2d::Ref* sender); protected: int _count; + cocos2d::ui::LoadingBar* _loadingBar; }; class UILoadingBarTest_Right : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index 6083704502..34ab64ea9c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -53,6 +53,15 @@ bool UISliderTest::init() slider->addEventListener(CC_CALLBACK_2(UISliderTest::sliderEvent, this)); _uiLayer->addChild(slider); + _slider = slider; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UISliderTest::printCheckBoxResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } @@ -69,6 +78,19 @@ void UISliderTest::sliderEvent(Ref *pSender, Slider::EventType type) _displayValueLabel->setString(StringUtils::format("Percent %f", 10000.0 * percent / maxPercent)); } } +void UISliderTest::printCheckBoxResources(cocos2d::Ref* sender) +{ + cocos2d::ResouceData textureFile = _slider->getBackFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); + cocos2d::ResouceData progressBarTextureFile = _slider->getProgressBarFile(); + CCLOG("progressBarTextureFile Name : %s, Type: %d", progressBarTextureFile.file.c_str(), progressBarTextureFile.type); + cocos2d::ResouceData slidBallNormalTextureFile = _slider->getBallNormalFile(); + CCLOG("slidBallNormalTextureFile Name : %s, Type: %d", slidBallNormalTextureFile.file.c_str(), slidBallNormalTextureFile.type); + cocos2d::ResouceData slidBallPressedTextureFile = _slider->getBallPressedFile(); + CCLOG("slidBallPressedTextureFile Name : %s, Type: %d", slidBallPressedTextureFile.file.c_str(), slidBallPressedTextureFile.type); + cocos2d::ResouceData slidBallDisabledTextureFile = _slider->getBallDisabeldFile(); + CCLOG("slidBallDisabledTextureFile Name : %s, Type: %d", slidBallDisabledTextureFile.file.c_str(), slidBallDisabledTextureFile.type); +} // UISliderTest_Scale9 diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h index 4dfcbed501..d289da83e7 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h @@ -38,9 +38,11 @@ public: ~UISliderTest(); virtual bool init() override; void sliderEvent(cocos2d::Ref* sender, cocos2d::ui::Slider::EventType type); + void printCheckBoxResources(cocos2d::Ref* sender); protected: cocos2d::ui::TextBMFont* _displayValueLabel; + cocos2d::ui::Slider* _slider; }; class UISliderTest_Scale9 : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp index 6a09be81f8..857808c7ef 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp @@ -34,7 +34,21 @@ bool UITextAtlasTest::init() textAtlas->setPosition(Vec2((widgetSize.width) / 2, widgetSize.height / 2.0f)); _uiLayer->addChild(textAtlas); + _textAtlas = textAtlas; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextAtlasTest::printCheckBoxResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } return false; } +void UITextAtlasTest::printCheckBoxResources(cocos2d::Ref* sender) +{ + cocos2d::ResouceData textureFile = _textAtlas->getRenderFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); +} diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h index 2eef8b80c0..29154d3195 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h @@ -13,6 +13,9 @@ public: CREATE_FUNC(UITextAtlasTest); virtual bool init() override; + void printCheckBoxResources(cocos2d::Ref* sender); +protected: + cocos2d::ui::TextAtlas* _textAtlas; }; #endif /* defined(__TestCpp__UITextAtlasTest__) */ diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp index 211132dc02..58d9051ea9 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp @@ -25,7 +25,22 @@ bool UITextBMFontTest::init() textBMFont->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getContentSize().height / 8.0f)); _uiLayer->addChild(textBMFont); + _textBMFont = textBMFont; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextBMFontTest::printCheckBoxResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); + return true; } return false; } +void UITextBMFontTest::printCheckBoxResources(cocos2d::Ref* sender) +{ + cocos2d::ResouceData textureFile = _textBMFont->getRenderFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); +} diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h index c3a228a695..b0be8f01f9 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h @@ -35,6 +35,9 @@ public: CREATE_FUNC(UITextBMFontTest) virtual bool init() override; + void printCheckBoxResources(cocos2d::Ref* sender); +protected: + cocos2d::ui::TextBMFont* _textBMFont; }; #endif /* defined(__TestCpp__UITextBMFontTest__) */ From 096efe874454b08c75fafd4145959463102223e2 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 1 Dec 2015 11:07:02 +0800 Subject: [PATCH 02/66] rename print interface --- .../UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp | 4 ++-- .../UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h | 2 +- .../CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp | 4 ++-- .../UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h | 2 +- .../CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp | 4 ++-- .../CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h | 2 +- .../UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp | 4 ++-- .../UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h | 2 +- .../CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp | 4 ++-- .../CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h | 2 +- .../UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp | 4 ++-- .../UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h | 2 +- .../CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp | 4 ++-- .../CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h | 2 +- .../CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp | 4 ++-- .../CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h | 2 +- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 12384146ca..4d402efd30 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -79,7 +79,7 @@ bool UIButtonTest::init() TTFConfig ttfConfig("fonts/arial.ttf", 15); auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIButtonTest::printCheckBoxResources, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIButtonTest::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); pMenu1->setPosition(Vec2(0, 0)); @@ -125,7 +125,7 @@ void UIButtonTest::touchEvent(Ref *pSender, Widget::TouchEventType type) } } -void UIButtonTest::printCheckBoxResources(cocos2d::Ref* sender) +void UIButtonTest::printWidgetResources(cocos2d::Ref* sender) { cocos2d::ResouceData normalFileName = _button->getNormalFile(); CCLOG("normalFileName Name : %s, Type: %d", normalFileName.file.c_str(), normalFileName.type); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h index 24153971ae..8a34c6493d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h @@ -40,7 +40,7 @@ public: virtual bool init() override; void touchEvent(cocos2d::Ref* sender, cocos2d::ui::Widget::TouchEventType type); - void printCheckBoxResources(cocos2d::Ref* sender); + void printWidgetResources(cocos2d::Ref* sender); protected: cocos2d::ui::Text* _displayValueLabel; cocos2d::ui::Button* _button; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index 8513aee0ef..bc689e080f 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -52,7 +52,7 @@ bool UICheckBoxTest::init() TTFConfig ttfConfig("fonts/arial.ttf", 15); auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UICheckBoxTest::printCheckBoxResources, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UICheckBoxTest::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); pMenu1->setPosition(Vec2(0, 0)); @@ -81,7 +81,7 @@ void UICheckBoxTest::selectedEvent(Ref* pSender,CheckBox::EventType type) } -void UICheckBoxTest::printCheckBoxResources(cocos2d::Ref* sender) +void UICheckBoxTest::printWidgetResources(cocos2d::Ref* sender) { cocos2d::ResouceData backGroundFileName = _checkBox->getBackNormalFile(); CCLOG("backGroundFile Name : %s, Type: %d", backGroundFileName.file.c_str(),backGroundFileName.type); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h index 3aaf6404f2..d79722f22c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h @@ -40,7 +40,7 @@ public: virtual bool init() override; void selectedEvent(cocos2d::Ref* sender,cocos2d::ui::CheckBox::EventType type); - void printCheckBoxResources(cocos2d::Ref* sender); + void printWidgetResources(cocos2d::Ref* sender); protected: cocos2d::ui::Text* _displayValueLabel; cocos2d::ui::CheckBox* _checkBox; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp index 38e8f8f6ac..8744d5f749 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp @@ -38,7 +38,7 @@ bool UIImageViewTest::init() TTFConfig ttfConfig("fonts/arial.ttf", 15); auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIImageViewTest::printCheckBoxResources, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIImageViewTest::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); pMenu1->setPosition(Vec2(0, 0)); @@ -49,7 +49,7 @@ bool UIImageViewTest::init() return false; } -void UIImageViewTest::printCheckBoxResources(cocos2d::Ref* sender) +void UIImageViewTest::printWidgetResources(cocos2d::Ref* sender) { cocos2d::ResouceData textureFile = _image->getRenderFile(); CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h index d751d86517..fd9e4d2f19 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h @@ -36,7 +36,7 @@ public: virtual bool init() override; - void printCheckBoxResources(cocos2d::Ref* sender); + void printWidgetResources(cocos2d::Ref* sender); protected: cocos2d::ui::ImageView* _image; }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp index c13b250ad8..3559b9ffc5 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp @@ -269,7 +269,7 @@ bool UILayoutTest_BackGroundImage::init() TTFConfig ttfConfig("fonts/arial.ttf", 15); auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILayoutTest_BackGroundImage::printCheckBoxResources, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILayoutTest_BackGroundImage::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); pMenu1->setPosition(Vec2(0, 0)); @@ -280,7 +280,7 @@ bool UILayoutTest_BackGroundImage::init() return false; } -void UILayoutTest_BackGroundImage::printCheckBoxResources(cocos2d::Ref* sender) +void UILayoutTest_BackGroundImage::printWidgetResources(cocos2d::Ref* sender) { cocos2d::ResouceData textureFile = _layout->getRenderFile(); CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h index d634abf583..c5d8a77319 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h @@ -68,7 +68,7 @@ public: CREATE_FUNC(UILayoutTest_BackGroundImage); - void printCheckBoxResources(cocos2d::Ref* sender); + void printWidgetResources(cocos2d::Ref* sender); protected: cocos2d::ui::Layout* _layout; }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index 5fc1341a21..b85703ba49 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -83,7 +83,7 @@ bool UILoadingBarTest_Left::init() TTFConfig ttfConfig("fonts/arial.ttf", 15); auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILoadingBarTest_Left::printCheckBoxResources, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILoadingBarTest_Left::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); pMenu1->setPosition(Vec2(0, 0)); @@ -107,7 +107,7 @@ void UILoadingBarTest_Left::update(float delta) loadingBarCopy->setPercent(_count); } -void UILoadingBarTest_Left::printCheckBoxResources(cocos2d::Ref* sender) +void UILoadingBarTest_Left::printWidgetResources(cocos2d::Ref* sender) { cocos2d::ResouceData textureFile = _loadingBar->getRenderFile(); CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h index cb97117d99..8e8a89666b 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h @@ -38,7 +38,7 @@ public: ~UILoadingBarTest_Left(); virtual bool init() override; void update(float delta)override; - void printCheckBoxResources(cocos2d::Ref* sender); + void printWidgetResources(cocos2d::Ref* sender); protected: int _count; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index 34ab64ea9c..420658ddc0 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -57,7 +57,7 @@ bool UISliderTest::init() TTFConfig ttfConfig("fonts/arial.ttf", 15); auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UISliderTest::printCheckBoxResources, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UISliderTest::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); pMenu1->setPosition(Vec2(0, 0)); @@ -78,7 +78,7 @@ void UISliderTest::sliderEvent(Ref *pSender, Slider::EventType type) _displayValueLabel->setString(StringUtils::format("Percent %f", 10000.0 * percent / maxPercent)); } } -void UISliderTest::printCheckBoxResources(cocos2d::Ref* sender) +void UISliderTest::printWidgetResources(cocos2d::Ref* sender) { cocos2d::ResouceData textureFile = _slider->getBackFile(); CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h index d289da83e7..ab07565296 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h @@ -38,7 +38,7 @@ public: ~UISliderTest(); virtual bool init() override; void sliderEvent(cocos2d::Ref* sender, cocos2d::ui::Slider::EventType type); - void printCheckBoxResources(cocos2d::Ref* sender); + void printWidgetResources(cocos2d::Ref* sender); protected: cocos2d::ui::TextBMFont* _displayValueLabel; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp index 857808c7ef..5f28afb8c3 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp @@ -38,7 +38,7 @@ bool UITextAtlasTest::init() TTFConfig ttfConfig("fonts/arial.ttf", 15); auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextAtlasTest::printCheckBoxResources, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextAtlasTest::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); pMenu1->setPosition(Vec2(0, 0)); @@ -47,7 +47,7 @@ bool UITextAtlasTest::init() } return false; } -void UITextAtlasTest::printCheckBoxResources(cocos2d::Ref* sender) +void UITextAtlasTest::printWidgetResources(cocos2d::Ref* sender) { cocos2d::ResouceData textureFile = _textAtlas->getRenderFile(); CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h index 29154d3195..bc7c03aa53 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h @@ -13,7 +13,7 @@ public: CREATE_FUNC(UITextAtlasTest); virtual bool init() override; - void printCheckBoxResources(cocos2d::Ref* sender); + void printWidgetResources(cocos2d::Ref* sender); protected: cocos2d::ui::TextAtlas* _textAtlas; }; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp index 58d9051ea9..1cc5e0559c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp @@ -29,7 +29,7 @@ bool UITextBMFontTest::init() TTFConfig ttfConfig("fonts/arial.ttf", 15); auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); - auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextBMFontTest::printCheckBoxResources, this)); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextBMFontTest::printWidgetResources, this)); item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); auto pMenu1 = Menu::create(item1, nullptr); pMenu1->setPosition(Vec2(0, 0)); @@ -39,7 +39,7 @@ bool UITextBMFontTest::init() } return false; } -void UITextBMFontTest::printCheckBoxResources(cocos2d::Ref* sender) +void UITextBMFontTest::printWidgetResources(cocos2d::Ref* sender) { cocos2d::ResouceData textureFile = _textBMFont->getRenderFile(); CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h index b0be8f01f9..795e7bd60b 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h @@ -35,7 +35,7 @@ public: CREATE_FUNC(UITextBMFontTest) virtual bool init() override; - void printCheckBoxResources(cocos2d::Ref* sender); + void printWidgetResources(cocos2d::Ref* sender); protected: cocos2d::ui::TextBMFont* _textBMFont; }; From c823821a08810da1494da57b7853203bb946c8f1 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 10 Dec 2015 10:36:00 +0800 Subject: [PATCH 03/66] fix controlButton test error --- .../CCControlButtonTest/CCControlButtonTest.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index 9c8ccae21e..dbe92feb24 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -277,15 +277,16 @@ ControlButton *ControlButtonTest_Styling::standardButtonWithTitle(const char *ti { /** Creates and return a button with a default background and title color. */ auto backgroundButton = ui::Scale9Sprite::create("extensions/button.png"); - backgroundButton->setPreferredSize(Size(45, 45)); // Set the prefered size auto backgroundHighlightedButton = ui::Scale9Sprite::create("extensions/buttonHighlighted.png"); - backgroundHighlightedButton->setPreferredSize(Size(45, 45)); // Set the prefered size auto titleButton = Label::createWithTTF(title, "fonts/Marker Felt.ttf", 30); titleButton->setColor(Color3B(159, 168, 176)); ControlButton *button = ControlButton::create(titleButton, backgroundButton); + backgroundButton->setPreferredSize(Size(45, 45)); // Set the prefered size + backgroundHighlightedButton->setPreferredSize(Size(45, 45)); // Set the prefered size + button->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED); button->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED); From e92db43e140b935abb4af4dbe3fca40c568edfe5 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 10 Dec 2015 13:17:31 +0800 Subject: [PATCH 04/66] update for text clone --- cocos/2d/CCLabel.cpp | 2 +- cocos/2d/CCLabel.h | 9 ++++ cocos/ui/UIText.cpp | 46 +++++++++++++++++++ cocos/ui/UIText.h | 9 ++++ .../UITextTest/UITextTest.cpp | 31 +++++++++++++ .../CocoStudioGUITest/UITextTest/UITextTest.h | 8 ++++ 6 files changed, 104 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 53d290441a..ccf3e09c54 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -1022,10 +1022,10 @@ void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = -1 */ _effectColorF.g = outlineColor.g / 255.f; _effectColorF.b = outlineColor.b / 255.f; _effectColorF.a = outlineColor.a / 255.f; - _outlineSize = outlineSize; _currLabelEffect = LabelEffect::OUTLINE; _contentDirty = true; } + _outlineSize = outlineSize; } } diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 0b58ecf1c0..c40632d62e 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -349,6 +349,15 @@ public: */ virtual void disableEffect(LabelEffect effect); + bool isShadowEnabled() const { return _shadowEnabled; } + Size getShadowOffset() const { return _shadowOffset; } + float getShadowBlurRadius() const { return _shadowBlurRadius; } + Color4F getShadowColor() const { return _shadowColor4F; } + + int getOutlineSize() const { return _outlineSize; } + LabelEffect getLabelEffectType() const { return _currLabelEffect; } + Color4F getEffectColor() const { return _effectColorF; } + /** Sets the Label's text horizontal alignment.*/ void setAlignment(TextHAlignment hAlignment) { setAlignment(hAlignment,_vAlignment);} diff --git a/cocos/ui/UIText.cpp b/cocos/ui/UIText.cpp index 99ee47e029..3fae6d0c4e 100644 --- a/cocos/ui/UIText.cpp +++ b/cocos/ui/UIText.cpp @@ -372,6 +372,38 @@ void Text::disableEffect(LabelEffect effect) } } +bool Text::isShadowEnabled() const +{ + return _labelRenderer->isShadowEnabled(); +} +Size Text::getShadowOffset() const +{ + return _labelRenderer->getShadowOffset(); +} +float Text::getShadowBlurRadius() const +{ + return _labelRenderer->getShadowBlurRadius(); +} +Color4B Text::getShadowColor() const +{ + Color4F effect = _labelRenderer->getShadowColor(); + return Color4B(effect.r * 255, effect.g * 255, effect.b * 255, effect.a * 255); +} + +int Text::getOutlineSize() const +{ + return _labelRenderer->getOutlineSize(); +} +LabelEffect Text::getLabelEffectType() const +{ + return _labelRenderer->getLabelEffectType(); +} +Color4B Text::getEffectColor() const +{ + Color4F effect = _labelRenderer->getEffectColor(); + return Color4B(effect.r * 255, effect.g * 255, effect.b * 255, effect.a * 255); +} + Widget* Text::createCloneInstance() { return Text::create(); @@ -391,6 +423,20 @@ void Text::copySpecialProperties(Widget *widget) setTextVerticalAlignment(label->_labelRenderer->getVerticalAlignment()); setTextAreaSize(label->_labelRenderer->getDimensions()); setContentSize(label->getContentSize()); + + LabelEffect effectType = label->getLabelEffectType(); + if (effectType == LabelEffect::GLOW) + { + enableGlow(label->getEffectColor()); + } + else if (effectType == LabelEffect::OUTLINE) + { + enableOutline(label->getEffectColor(),label->getOutlineSize()); + } + if (label->isShadowEnabled()) + { + enableShadow(label->getShadowColor(),label->getShadowOffset(),label->getShadowBlurRadius()); + } } } diff --git a/cocos/ui/UIText.h b/cocos/ui/UIText.h index 6b960d619e..d9f14dc952 100644 --- a/cocos/ui/UIText.h +++ b/cocos/ui/UIText.h @@ -294,6 +294,15 @@ public: */ void disableEffect(LabelEffect effect); + bool isShadowEnabled() const; + Size getShadowOffset() const; + float getShadowBlurRadius() const; + Color4B getShadowColor() const; + + int getOutlineSize() const; + LabelEffect getLabelEffectType() const; + Color4B getEffectColor() const; + CC_CONSTRUCTOR_ACCESS: virtual bool init() override; virtual bool init(const std::string& textContent, diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp index 603121c565..97dc2f06c1 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.cpp @@ -11,6 +11,7 @@ UITextTests::UITextTests() ADD_TEST_CASE(UILabelTest_Effect); ADD_TEST_CASE(UITextTest_TTF); ADD_TEST_CASE(UITextTest_IgnoreConentSize); + ADD_TEST_CASE(UITextTest_Clone); } // UITextTest @@ -263,3 +264,33 @@ bool UITextTest_IgnoreConentSize::init() } return false; } + +// UITextTest_IgnoreConentSize + +bool UITextTest_Clone::init() +{ + if (UIScene::init()) + { + Size widgetSize = _widget->getContentSize(); + + Text* singleText = Text::create("ignore conent", + "fonts/Marker Felt.ttf", 30); + singleText->setPosition(Vec2(widgetSize.width / 2.0f - 80, + widgetSize.height / 2.0f)); + singleText->setString("CHUKONG"); + singleText->setTouchScaleChangeEnabled(true); + singleText->setTouchEnabled(true); + singleText->enableOutline(Color4B(255,0,0,100), 10); + singleText->enableShadow(Color4B::YELLOW, Size(2,-2), 0); + _uiLayer->addChild(singleText); + + auto cloneText = singleText->clone(); + cloneText->setPosition(Vec2(widgetSize.width / 2.0f + 80, + widgetSize.height / 2.0f)); + _uiLayer->addChild(cloneText); + + return true; + } + return false; +} + diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.h index 081b4ab94e..e0a8947ab9 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextTest/UITextTest.h @@ -71,4 +71,12 @@ public: virtual bool init() override; }; +class UITextTest_Clone : public UIScene +{ +public: + CREATE_FUNC(UITextTest_Clone); + + virtual bool init() override; +}; + #endif /* defined(__TestCpp__UITextTest__) */ From 8c2b4c78dbae7d9263f55f22d650d4818a91ea4e Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 10 Dec 2015 13:37:07 +0800 Subject: [PATCH 05/66] fix scrollview render error --- cocos/ui/UIScrollView.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 81ae8b64a6..e4e5f0cf02 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -178,19 +178,11 @@ void ScrollView::setInnerContainerSize(const Size &size) // Calculate and set the position of the inner container. Vec2 pos = _innerContainer->getPosition(); - if (_innerContainer->getLeftBoundary() > 0.0f) + if (_innerContainer->getLeftBoundary() != 0.0f) { pos.x = _innerContainer->getAnchorPoint().x * _innerContainer->getContentSize().width; } - if (_innerContainer->getRightBoundary() < _contentSize.width) - { - pos.x = _contentSize.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getContentSize().width); - } - if (_innerContainer->getPosition().y > 0.0f) - { - pos.y = _innerContainer->getAnchorPoint().y * _innerContainer->getContentSize().height; - } - if (_innerContainer->getTopBoundary() < _contentSize.height) + if (_innerContainer->getTopBoundary() != _contentSize.height) { pos.y = _contentSize.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getContentSize().height; } From 1a17e94e1c7573ddbab62ece1d3163f572ac7b41 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 10 Dec 2015 15:25:27 +0800 Subject: [PATCH 06/66] update for scrollview test --- .../UIScrollViewTest/UIScrollViewTest.cpp | 63 +++++++++++++++++++ .../UIScrollViewTest/UIScrollViewTest.h | 14 +++++ 2 files changed, 77 insertions(+) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp index 4dbc7c2879..9f695b896c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp @@ -13,6 +13,7 @@ UIScrollViewTests::UIScrollViewTests() ADD_TEST_CASE(UIScrollViewNestTest); ADD_TEST_CASE(UIScrollViewRotated); ADD_TEST_CASE(UIScrollViewDisableTest); + ADD_TEST_CASE(UIScrollViewInnerSize); } // UIScrollViewTest_Vertical @@ -618,3 +619,65 @@ bool UIScrollViewDisableTest::init() return false; } + +// UIScrollViewInnerSize + +UIScrollViewInnerSize::UIScrollViewInnerSize() + : _displayValueLabel(nullptr) +{ +} + +UIScrollViewInnerSize::~UIScrollViewInnerSize() +{ +} + +bool UIScrollViewInnerSize::init() +{ + if (UIScene::init()) + { + Size widgetSize = _widget->getContentSize(); + + // Add a label in which the scrollview alert will be displayed + _displayValueLabel = Text::create("ScrollView InnerSize Test", "fonts/Marker Felt.ttf", 32); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f)); + _uiLayer->addChild(_displayValueLabel); + + // Add the alert + Text* alert = Text::create("ScrollView & InnerContainer should be align to the left and top point", "fonts/Marker Felt.ttf", 10); + alert->setColor(Color3B(159, 168, 176)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); + _uiLayer->addChild(alert); + + Layout* root = static_cast(_uiLayer->getChildByTag(81)); + + Layout* background = dynamic_cast(root->getChildByName("background_Panel")); + + // Create the scrollview by vertical + ui::ScrollView* scrollView = ui::ScrollView::create(); + scrollView->setContentSize(Size(200.0f, 50.0f)); + Size backgroundSize = background->getContentSize(); + scrollView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f + + (backgroundSize.width - scrollView->getContentSize().width) / 2.0f, + (widgetSize.height - backgroundSize.height) / 2.0f + + (backgroundSize.height - scrollView->getContentSize().height) / 2.0f)); + scrollView->setScrollBarWidth(4); + scrollView->setTouchEnabled(false); + scrollView->setScrollBarPositionFromCorner(Vec2(2, 2)); + scrollView->setScrollBarColor(Color3B::WHITE); + scrollView->setBackGroundColorType(Layout::BackGroundColorType::SOLID); + scrollView->setBackGroundColor(ccc3(150, 150, 100)); + scrollView->getInnerContainer()->setBackGroundColorType(Layout::BackGroundColorType::SOLID); + scrollView->getInnerContainer()->setBackGroundColor(ccc3(50, 100, 50)); + scrollView->getInnerContainer()->setBackGroundColorOpacity(100); + scrollView->setClippingEnabled(false); + _uiLayer->addChild(scrollView); + + scrollView->setInnerContainerSize(Size(250.f, 100.f)); + + return true; + } + + return false; +} \ No newline at end of file diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.h index 25b3fcdf11..35f5bfe79e 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.h @@ -136,6 +136,20 @@ public: ~UIScrollViewDisableTest(); virtual bool init() override; +protected: + + cocos2d::ui::Text* _displayValueLabel; +}; + +class UIScrollViewInnerSize : public UIScene +{ +public: + CREATE_FUNC(UIScrollViewInnerSize); + + UIScrollViewInnerSize(); + ~UIScrollViewInnerSize(); + virtual bool init() override; + protected: cocos2d::ui::Text* _displayValueLabel; From 5872745593cb8b379b923c2d3cdb01e286f0fbbf Mon Sep 17 00:00:00 2001 From: GuoLunHao Date: Thu, 10 Dec 2015 16:43:01 +0800 Subject: [PATCH 07/66] fix compile error and link error on ios/Mac platform --- .../cocos2d_js_bindings.xcodeproj/project.pbxproj | 13 +++++++++++++ .../cocos2d_lua_bindings.xcodeproj/project.pbxproj | 13 +++++++++++++ .../libsimulator.xcodeproj/project.pbxproj | 4 ++++ 3 files changed, 30 insertions(+) diff --git a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj index ab0bc1f418..a79e70371b 100644 --- a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj @@ -164,6 +164,9 @@ 83A5661A18DA878400FC31A0 /* jsb_socketio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83A5661718DA878400FC31A0 /* jsb_socketio.cpp */; }; 83A5661B18DA878400FC31A0 /* jsb_socketio.h in Headers */ = {isa = PBXBuildFile; fileRef = 83A5661818DA878400FC31A0 /* jsb_socketio.h */; }; 83A5661C18DA878400FC31A0 /* jsb_socketio.h in Headers */ = {isa = PBXBuildFile; fileRef = 83A5661818DA878400FC31A0 /* jsb_socketio.h */; }; + ADD1C0DC1C196BDF00733781 /* js_module_register.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADD1C0D91C196BDF00733781 /* js_module_register.cpp */; }; + ADD1C0DD1C196BDF00733781 /* js_module_register.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD1C0DA1C196BDF00733781 /* js_module_register.h */; }; + ADD1C0DE1C196BDF00733781 /* js-BindingsExport.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD1C0DB1C196BDF00733781 /* js-BindingsExport.h */; }; B38AD56A1B1D384A0057DD7F /* jsb_cocos2dx_experimental_video_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B38AD5681B1D384A0057DD7F /* jsb_cocos2dx_experimental_video_manual.cpp */; }; B38AD56B1B1D384A0057DD7F /* jsb_cocos2dx_experimental_video_manual.h in Headers */ = {isa = PBXBuildFile; fileRef = B38AD5691B1D384A0057DD7F /* jsb_cocos2dx_experimental_video_manual.h */; }; B38AD56E1B1D38700057DD7F /* jsb_cocos2dx_experimental_video_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B38AD56C1B1D38700057DD7F /* jsb_cocos2dx_experimental_video_auto.cpp */; }; @@ -287,6 +290,9 @@ 4BE089EA1ADF967400D65D4B /* jsb_cocos2dx_experimental_webView_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_cocos2dx_experimental_webView_manual.h; sourceTree = ""; }; 83A5661718DA878400FC31A0 /* jsb_socketio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_socketio.cpp; sourceTree = ""; }; 83A5661818DA878400FC31A0 /* jsb_socketio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_socketio.h; sourceTree = ""; }; + ADD1C0D91C196BDF00733781 /* js_module_register.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_module_register.cpp; sourceTree = ""; }; + ADD1C0DA1C196BDF00733781 /* js_module_register.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_module_register.h; sourceTree = ""; }; + ADD1C0DB1C196BDF00733781 /* js-BindingsExport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "js-BindingsExport.h"; sourceTree = ""; }; B38AD5681B1D384A0057DD7F /* jsb_cocos2dx_experimental_video_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = jsb_cocos2dx_experimental_video_manual.cpp; path = experimental/jsb_cocos2dx_experimental_video_manual.cpp; sourceTree = ""; }; B38AD5691B1D384A0057DD7F /* jsb_cocos2dx_experimental_video_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = jsb_cocos2dx_experimental_video_manual.h; path = experimental/jsb_cocos2dx_experimental_video_manual.h; sourceTree = ""; }; B38AD56C1B1D38700057DD7F /* jsb_cocos2dx_experimental_video_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_experimental_video_auto.cpp; sourceTree = ""; }; @@ -397,6 +403,9 @@ 1A119E5018BDF19200352BAA /* cocosbuilder */, 1A119E5518BDF19200352BAA /* cocostudio */, 1A119E5918BDF19200352BAA /* extension */, + ADD1C0D91C196BDF00733781 /* js_module_register.cpp */, + ADD1C0DA1C196BDF00733781 /* js_module_register.h */, + ADD1C0DB1C196BDF00733781 /* js-BindingsExport.h */, 1A119E6118BDF19200352BAA /* js_bindings_config.h */, 1A119E6218BDF19200352BAA /* js_bindings_core.cpp */, 1A119E6318BDF19200352BAA /* js_bindings_core.h */, @@ -629,6 +638,7 @@ 1A119F0318BDF19200352BAA /* spidermonkey_specifics.h in Headers */, 1A119EE718BDF19200352BAA /* jsb_opengl_manual.h in Headers */, 1A119ED518BDF19200352BAA /* js_bindings_core.h in Headers */, + ADD1C0DE1C196BDF00733781 /* js-BindingsExport.h in Headers */, 1A119EC318BDF19200352BAA /* js_bindings_ccbreader.h in Headers */, 1A119EDF18BDF19200352BAA /* jsb_helper.h in Headers */, 1A119ECB18BDF19200352BAA /* jsb_cocos2dx_extension_manual.h in Headers */, @@ -642,6 +652,7 @@ 42638FFF1B0EC1B7004C53A2 /* jsb_cocos2dx_physics3d_auto.hpp in Headers */, 0541A74F1973876100E45470 /* JavaScriptObjCBridge.h in Headers */, 426390061B0EC1C6004C53A2 /* jsb_cocos2dx_physics3d_manual.h in Headers */, + ADD1C0DD1C196BDF00733781 /* js_module_register.h in Headers */, 1AB5E62D18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.hpp in Headers */, 420BBCF91AA48EE900493976 /* jsb_cocos2dx_3d_manual.h in Headers */, 1A119ED918BDF19200352BAA /* js_bindings_opengl.h in Headers */, @@ -803,6 +814,7 @@ BAEE4D711AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp in Sources */, 1A119EC518BDF19200352BAA /* jsb_cocos2dx_studio_manual.cpp in Sources */, 1A119E8F18BDF19200352BAA /* jsb_cocos2dx_extension_auto.cpp in Sources */, + ADD1C0DC1C196BDF00733781 /* js_module_register.cpp in Sources */, 1A119ED718BDF19200352BAA /* js_bindings_opengl.cpp in Sources */, 1AB5E62B18D05BC80088DAA4 /* jsb_cocos2dx_ui_auto.cpp in Sources */, 1A119E9B18BDF19200352BAA /* jsb_cocos2dx_spine_auto.cpp in Sources */, @@ -836,6 +848,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + ADD1C0DF1C196BFC00733781 /* js_module_register.cpp in Sources */, 0541A75B19738AD200E45470 /* JavaScriptObjCBridge.mm in Sources */, 420BBCF81AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp in Sources */, 1A119E8A18BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp in Sources */, diff --git a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj index 6ad467fe05..9320ffdca5 100644 --- a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj @@ -287,6 +287,9 @@ BA0CBB5F1BB0756F00003364 /* CCComponentLua.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA0CBB5C1BB0756F00003364 /* CCComponentLua.cpp */; settings = {ASSET_TAGS = (); }; }; BA0CBB601BB0756F00003364 /* CCComponentLua.h in Headers */ = {isa = PBXBuildFile; fileRef = BA0CBB5D1BB0756F00003364 /* CCComponentLua.h */; settings = {ASSET_TAGS = (); }; }; BA0CBB611BB0756F00003364 /* CCComponentLua.h in Headers */ = {isa = PBXBuildFile; fileRef = BA0CBB5D1BB0756F00003364 /* CCComponentLua.h */; settings = {ASSET_TAGS = (); }; }; + ADD1C0D51C196B9500733781 /* lua_module_register.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADD1C0D21C196B9500733781 /* lua_module_register.cpp */; }; + ADD1C0D61C196B9500733781 /* lua_module_register.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD1C0D31C196B9500733781 /* lua_module_register.h */; }; + ADD1C0D71C196B9500733781 /* Lua-BindingsExport.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD1C0D41C196B9500733781 /* Lua-BindingsExport.h */; }; F4FE0D5719ECD00100B8B12B /* luasocket_scripts.c in Sources */ = {isa = PBXBuildFile; fileRef = F4FE0D5519ECD00100B8B12B /* luasocket_scripts.c */; }; F4FE0D5819ECD00100B8B12B /* luasocket_scripts.c in Sources */ = {isa = PBXBuildFile; fileRef = F4FE0D5519ECD00100B8B12B /* luasocket_scripts.c */; }; F4FE0D5919ECD00100B8B12B /* luasocket_scripts.h in Headers */ = {isa = PBXBuildFile; fileRef = F4FE0D5619ECD00100B8B12B /* luasocket_scripts.h */; }; @@ -445,6 +448,9 @@ 3E2BDB0919C5E6100055CDCD /* lua_cocos2dx_audioengine_manual.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_cocos2dx_audioengine_manual.h; sourceTree = ""; }; 566F015D19B5EB0F00FCA620 /* CustomGUIReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomGUIReader.cpp; sourceTree = ""; }; 566F015E19B5EB0F00FCA620 /* CustomGUIReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomGUIReader.h; sourceTree = ""; }; + ADD1C0D21C196B9500733781 /* lua_module_register.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_module_register.cpp; sourceTree = ""; }; + ADD1C0D31C196B9500733781 /* lua_module_register.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_module_register.h; sourceTree = ""; }; + ADD1C0D41C196B9500733781 /* Lua-BindingsExport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Lua-BindingsExport.h"; sourceTree = ""; }; BA0CBB5C1BB0756F00003364 /* CCComponentLua.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComponentLua.cpp; sourceTree = ""; }; BA0CBB5D1BB0756F00003364 /* CCComponentLua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComponentLua.h; sourceTree = ""; }; C0D9BAFA1974D30000EC35BB /* liblua.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua.a; path = ../../../../external/lua/lua/prebuilt/ios/liblua.a; sourceTree = ""; }; @@ -680,6 +686,9 @@ 15C1BD141986526C00A46ACC /* spine */, 15C1BD191986526C00A46ACC /* ui */, 15C1BCD21986525900A46ACC /* cocos2d */, + ADD1C0D21C196B9500733781 /* lua_module_register.cpp */, + ADD1C0D31C196B9500733781 /* lua_module_register.h */, + ADD1C0D41C196B9500733781 /* Lua-BindingsExport.h */, 1AACE76018BC45C200215002 /* CCLuaBridge.cpp */, 1AACE76118BC45C200215002 /* CCLuaBridge.h */, 1AACE76218BC45C200215002 /* CCLuaEngine.cpp */, @@ -857,6 +866,7 @@ 15415AAB19A71A53004F1E71 /* buffer.h in Headers */, 15AC69DE1987711400D17520 /* lauxlib.h in Headers */, 155C7E1419A71CA800F08B25 /* Lua_web_socket.h in Headers */, + ADD1C0D61C196B9500733781 /* lua_module_register.h in Headers */, 15AC69DF1987711400D17520 /* lua.h in Headers */, 15AC69E01987711400D17520 /* luaconf.h in Headers */, 155C7DF819A71C4400F08B25 /* lua_cocos2dx_cocosdenshion_manual.h in Headers */, @@ -888,6 +898,7 @@ 15415AD319A71A53004F1E71 /* timeout.h in Headers */, 15C1C2D5198749BC00A46ACC /* LuaOpengl.h in Headers */, 15A561EE1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.h in Headers */, + ADD1C0D71C196B9500733781 /* Lua-BindingsExport.h in Headers */, 155C7E2819A71CE600F08B25 /* lua_cocos2dx_ui_manual.hpp in Headers */, 15C1C2D6198749BC00A46ACC /* lua_cocos2dx_deprecated.h in Headers */, 15C1C2D7198749BC00A46ACC /* lua_cocos2dx_experimental_manual.hpp in Headers */, @@ -1068,6 +1079,7 @@ 15AC69DA1987710400D17520 /* tolua_is.c in Sources */, 15415ACD19A71A53004F1E71 /* tcp.c in Sources */, 15AC69DB1987710400D17520 /* tolua_map.c in Sources */, + ADD1C0D51C196B9500733781 /* lua_module_register.cpp in Sources */, 15415AD519A71A53004F1E71 /* udp.c in Sources */, 150983D01B1C0554007F3818 /* lua_cocos2dx_navmesh_auto.cpp in Sources */, 15415ADD19A71A53004F1E71 /* usocket.c in Sources */, @@ -1133,6 +1145,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + ADD1C0D81C196BBF00733781 /* lua_module_register.cpp in Sources */, 15415AC619A71A53004F1E71 /* select.c in Sources */, 15A561ED1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.cpp in Sources */, 15EFA646198B3311000C57D3 /* tolua_event.c in Sources */, diff --git a/tools/simulator/libsimulator/proj.ios_mac/libsimulator.xcodeproj/project.pbxproj b/tools/simulator/libsimulator/proj.ios_mac/libsimulator.xcodeproj/project.pbxproj index d92ef78d6d..dc5d90a573 100644 --- a/tools/simulator/libsimulator/proj.ios_mac/libsimulator.xcodeproj/project.pbxproj +++ b/tools/simulator/libsimulator/proj.ios_mac/libsimulator.xcodeproj/project.pbxproj @@ -147,6 +147,7 @@ 9FF504BF1A5EA75D00AFDA55 /* PlayerTaskServiceProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 9FF504AA1A5EA75D00AFDA55 /* PlayerTaskServiceProtocol.h */; }; 9FF504C01A5EA75D00AFDA55 /* PlayerUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9FF504AB1A5EA75D00AFDA55 /* PlayerUtils.cpp */; }; 9FF504C11A5EA75D00AFDA55 /* PlayerUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 9FF504AC1A5EA75D00AFDA55 /* PlayerUtils.h */; }; + ADD1C0E11C196C2500733781 /* SimulatorExport.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD1C0E01C196C2500733781 /* SimulatorExport.h */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -274,6 +275,7 @@ 9FF504AA1A5EA75D00AFDA55 /* PlayerTaskServiceProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayerTaskServiceProtocol.h; sourceTree = ""; }; 9FF504AB1A5EA75D00AFDA55 /* PlayerUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlayerUtils.cpp; sourceTree = ""; }; 9FF504AC1A5EA75D00AFDA55 /* PlayerUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayerUtils.h; sourceTree = ""; }; + ADD1C0E01C196C2500733781 /* SimulatorExport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatorExport.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -449,6 +451,7 @@ 9FF504AB1A5EA75D00AFDA55 /* PlayerUtils.cpp */, 9FF504AC1A5EA75D00AFDA55 /* PlayerUtils.h */, 9FD6FC0E1A5D281D0028EDC6 /* cocos2dx_extra.h */, + ADD1C0E01C196C2500733781 /* SimulatorExport.h */, 9FD6FC0F1A5D281D0028EDC6 /* network */, 9FD6FC131A5D281D0028EDC6 /* platform */, 9FD6FC161A5D281D0028EDC6 /* ProjectConfig */, @@ -565,6 +568,7 @@ 9FB638931A635BA300AAEC43 /* stringprintf.h in Headers */, 9FB6388E1A635BA300AAEC43 /* once.h in Headers */, 9FD6FC671A5D2A380028EDC6 /* PlayerMac.h in Headers */, + ADD1C0E11C196C2500733781 /* SimulatorExport.h in Headers */, 9FB6386E1A635BA300AAEC43 /* coded_stream_inl.h in Headers */, 9F2F21BF1A635F1C006B8BF1 /* RuntimeCCSImpl.h in Headers */, 9FD6FC311A5D281D0028EDC6 /* cocos2dx_extra.h in Headers */, From fe5314d92747cc271d932b3aa48aee76c6d9275d Mon Sep 17 00:00:00 2001 From: "lunhao.guo" Date: Thu, 10 Dec 2015 17:20:43 +0800 Subject: [PATCH 08/66] add quiet option for Cocos Toolkit --- setup.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 019fd87a63..91ee4c8760 100755 --- a/setup.py +++ b/setup.py @@ -676,7 +676,7 @@ class SetEnvVar(object): else: return SetEnvVar.RESULT_DO_NOTHING - def set_environment_variables(self, ndk_root, android_sdk_root, ant_root): + def set_environment_variables(self, ndk_root, android_sdk_root, ant_root, quiet): print('\nSetting up cocos2d-x...') @@ -692,10 +692,10 @@ class SetEnvVar(object): else: print('->Configuration for Android platform only, you can also skip and manually edit "%s"\n' % self.file_used_for_setup) - - ndk_ret = self.set_variable(NDK_ROOT, ndk_root) - sdk_ret = self.set_variable(ANDROID_SDK_ROOT, android_sdk_root) - ant_ret = self.set_variable(ANT_ROOT, ant_root) + if(quiet) : + ndk_ret = self.set_variable(NDK_ROOT, ndk_root) + sdk_ret = self.set_variable(ANDROID_SDK_ROOT, android_sdk_root) + ant_ret = self.set_variable(ANT_ROOT, ant_root) # tip the backup file if (self.backup_file is not None) and (os.path.exists(self.backup_file)): @@ -720,12 +720,15 @@ if __name__ == '__main__': dest='android_sdk_root', help='directory of android sdk root') parser.add_option( '-t', '--antroot', dest='ant_root', help='directory that contains ant/ant.bat') + + parser.add_option( + '-q', '--quiet', dest='quiet',action="store_false", default = True, help='setup without setting NDK,SDK,ANT') opts, args = parser.parse_args() # set environment variables env = SetEnvVar() env.set_environment_variables( - opts.ndk_root, opts.android_sdk_root, opts.ant_root) + opts.ndk_root, opts.android_sdk_root, opts.ant_root, opts.quiet) if env._isWindows(): import ctypes From f877f26bd22abeb131c7949e26cbf03656e102e9 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 11 Dec 2015 11:56:58 +0800 Subject: [PATCH 09/66] update for controlButton --- .../CCControlExtension/CCControlButton.cpp | 22 +++++++++---------- .../GUI/CCControlExtension/CCControlButton.h | 8 +++---- .../CCControlButtonTest.cpp | 9 ++++---- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index 9a69de517e..94035a91a4 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -63,10 +63,10 @@ ControlButton::~ControlButton() bool ControlButton::init() { - return this->initWithLabelAndBackgroundSprite(Label::createWithSystemFont("", "Helvetica", 12), cocos2d::ui::Scale9Sprite::create()); + return this->initWithLabelAndBackgroundSprite(Label::createWithSystemFont("", "Helvetica", 12), cocos2d::ui::Scale9Sprite::create(),true); } -bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, ui::Scale9Sprite* backgroundSprite) +bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize) { if (Control::init()) { @@ -79,9 +79,9 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, ui::Scale9Sprit _isPushed = false; - // Adjust the background image by default - setAdjustBackgroundImage(true); + // Adjust the background image by adjustBackGroundSize setPreferredSize(Size::ZERO); + setAdjustBackgroundImage(adjustBackGroundSize); // Zooming button by default _zoomOnTouchDown = true; _scaleRatio = 1.1f; @@ -120,17 +120,17 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, ui::Scale9Sprit } } -ControlButton* ControlButton::create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite) +ControlButton* ControlButton::create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize) { ControlButton *pRet = new (std::nothrow) ControlButton(); - pRet->initWithLabelAndBackgroundSprite(label, backgroundSprite); + pRet->initWithLabelAndBackgroundSprite(label, backgroundSprite, adjustBackGroundSize); pRet->autorelease(); return pRet; } bool ControlButton::initWithTitleAndFontNameAndFontSize(const std::string& title, const std::string& fontName, float fontSize) { - return initWithLabelAndBackgroundSprite(Label::createWithSystemFont(title, fontName, fontSize), cocos2d::ui::Scale9Sprite::create()); + return initWithLabelAndBackgroundSprite(Label::createWithSystemFont(title, fontName, fontSize), cocos2d::ui::Scale9Sprite::create(),true); } ControlButton* ControlButton::create(const std::string& title, const std::string& fontName, float fontSize) @@ -141,16 +141,16 @@ ControlButton* ControlButton::create(const std::string& title, const std::string return pRet; } -bool ControlButton::initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite) +bool ControlButton::initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite, bool adjustBackGroundSize) { Label *label = Label::createWithSystemFont("", "Arial", 30);// - return initWithLabelAndBackgroundSprite(label, sprite); + return initWithLabelAndBackgroundSprite(label, sprite,adjustBackGroundSize); } -ControlButton* ControlButton::create(cocos2d::ui::Scale9Sprite* sprite) +ControlButton* ControlButton::create(cocos2d::ui::Scale9Sprite* sprite, bool adjustBackGroundSize) { ControlButton *pRet = new (std::nothrow) ControlButton(); - pRet->initWithBackgroundSprite(sprite); + pRet->initWithBackgroundSprite(sprite,adjustBackGroundSize); pRet->autorelease(); return pRet; } diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index 302b8c8ec9..279ccce292 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -55,8 +55,8 @@ class CC_EX_DLL ControlButton : public Control { public: static ControlButton* create(); - static ControlButton* create(cocos2d::ui::Scale9Sprite* sprite); - static ControlButton* create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite); + static ControlButton* create(cocos2d::ui::Scale9Sprite* sprite, bool adjustBackGroundSize = true); + static ControlButton* create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize = true); static ControlButton* create(const std::string& title, const std::string& fontName, float fontSize); virtual void needsLayout(void) override; @@ -202,8 +202,8 @@ CC_CONSTRUCTOR_ACCESS: virtual ~ControlButton(); virtual bool init() override; - virtual bool initWithLabelAndBackgroundSprite(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite); - virtual bool initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite); + virtual bool initWithLabelAndBackgroundSprite(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize); + virtual bool initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite, bool adjustBackGroundSize); virtual bool initWithTitleAndFontNameAndFontSize(const std::string& title, const std::string& fontName, float fontSize); protected: diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index dbe92feb24..e5b50557dd 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -277,16 +277,15 @@ ControlButton *ControlButtonTest_Styling::standardButtonWithTitle(const char *ti { /** Creates and return a button with a default background and title color. */ auto backgroundButton = ui::Scale9Sprite::create("extensions/button.png"); + backgroundButton->setPreferredSize(Size(45, 45)); // Set the prefered size auto backgroundHighlightedButton = ui::Scale9Sprite::create("extensions/buttonHighlighted.png"); - + backgroundHighlightedButton->setPreferredSize(Size(45, 45)); // Set the prefered size + auto titleButton = Label::createWithTTF(title, "fonts/Marker Felt.ttf", 30); titleButton->setColor(Color3B(159, 168, 176)); - ControlButton *button = ControlButton::create(titleButton, backgroundButton); - backgroundButton->setPreferredSize(Size(45, 45)); // Set the prefered size - backgroundHighlightedButton->setPreferredSize(Size(45, 45)); // Set the prefered size - + ControlButton *button = ControlButton::create(titleButton, backgroundButton,false); button->setBackgroundSpriteForState(backgroundHighlightedButton, Control::State::HIGH_LIGHTED); button->setTitleColorForState(Color3B::WHITE, Control::State::HIGH_LIGHTED); From 4c5c6e6d9bfbe9301bd18e12c5133468a74d9fa6 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 11 Dec 2015 12:04:54 +0800 Subject: [PATCH 10/66] update for code format --- cocos/2d/CCLabel.h | 26 ++++++++++++++++++++++++++ cocos/ui/UIText.h | 22 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index c40632d62e..b2a9f7d1f4 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -349,13 +349,39 @@ public: */ virtual void disableEffect(LabelEffect effect); + /** + * Return whether the shadow effect is enabled. + */ bool isShadowEnabled() const { return _shadowEnabled; } + + /** + * Return shadow effect offset value. + */ Size getShadowOffset() const { return _shadowOffset; } + + /** + * Return the shadow effect blur radius. + */ float getShadowBlurRadius() const { return _shadowBlurRadius; } + + /** + * Return the shadow effect color value. + */ Color4F getShadowColor() const { return _shadowColor4F; } + /** + * Return the outline effect size value. + */ int getOutlineSize() const { return _outlineSize; } + + /** + * Return current effect type. + */ LabelEffect getLabelEffectType() const { return _currLabelEffect; } + + /** + * Return current effect color vlaue. + */ Color4F getEffectColor() const { return _effectColorF; } /** Sets the Label's text horizontal alignment.*/ diff --git a/cocos/ui/UIText.h b/cocos/ui/UIText.h index d9f14dc952..df06d62ebc 100644 --- a/cocos/ui/UIText.h +++ b/cocos/ui/UIText.h @@ -294,13 +294,33 @@ public: */ void disableEffect(LabelEffect effect); + /** + * Return whether the shadow effect is enabled. + */ bool isShadowEnabled() const; + /** + * Return shadow effect offset value. + */ Size getShadowOffset() const; + /** + * Return the shadow effect blur radius. + */ float getShadowBlurRadius() const; + /** + * Return the shadow effect color value. + */ Color4B getShadowColor() const; - + /** + * Return the outline effect size value. + */ int getOutlineSize() const; + /** + * Return current effect type. + */ LabelEffect getLabelEffectType() const; + /** + * Return current effect color vlaue. + */ Color4B getEffectColor() const; CC_CONSTRUCTOR_ACCESS: From 49d03d9de170f544e978f40d81834264b5c18886 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 11 Dec 2015 18:22:02 +0800 Subject: [PATCH 11/66] Synchronize js parsers modification from html5 version --- .../js-bindings/script/studio/parsers/timelineParser-1.x.js | 2 +- .../js-bindings/script/studio/parsers/timelineParser-2.x.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-1.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-1.x.js index c9c3efbab5..2aa5de29b6 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-1.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-1.x.js @@ -287,6 +287,6 @@ }); }); - load.registerParser("timeline", "*", parser); + load.registerParser("timeline", "1.*", parser); })(ccs._load, ccs._parser); diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index 0a023cbdf0..eb868281b5 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -1777,7 +1777,7 @@ }); - load.registerParser("timeline", "2.*", parser); + load.registerParser("timeline", "*", parser); })(ccs._load, ccs._parser); From 47911e0c249ae366a6dae63ea3aede56e44d480e Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 11 Dec 2015 15:18:09 -0800 Subject: [PATCH 12/66] more js fixes fixes in how ref count is measured opengl bindings converted to new API --- cocos/base/CCRef.cpp | 9 +- cocos/base/CCRef.h | 1 + .../js-bindings/manual/ScriptingCore.cpp | 37 +++---- .../js-bindings/manual/ScriptingCore.h | 2 +- .../js-bindings/manual/cocos2d_specifics.cpp | 23 +--- .../js-bindings/manual/js_bindings_opengl.cpp | 101 ++++++++---------- .../manual/js_manual_conversions.h | 2 +- .../src/MemoryModelTest/MemoryModelTest.js | 7 ++ 8 files changed, 78 insertions(+), 104 deletions(-) diff --git a/cocos/base/CCRef.cpp b/cocos/base/CCRef.cpp index 59215c5738..4c4ce17674 100644 --- a/cocos/base/CCRef.cpp +++ b/cocos/base/CCRef.cpp @@ -50,6 +50,7 @@ Ref::Ref() , _scriptObject(nullptr) , _rooted(false) , _scriptOwned(false) +,_referenceCountAtRootTime(0) #endif { #if CC_ENABLE_SCRIPT_BINDING @@ -93,11 +94,15 @@ void Ref::retain() ++_referenceCount; #if CC_ENABLE_SCRIPT_BINDING && CC_ENABLE_GC_FOR_NATIVE_OBJECTS - if (!_rooted && _scriptOwned) + if (_scriptOwned && !_rooted) { auto scriptMgr = ScriptEngineManager::getInstance()->getScriptEngine(); if (scriptMgr && scriptMgr->getScriptType() == kScriptTypeJavascript) { + _referenceCountAtRootTime = _referenceCount-1; + + CCLOG("retain + root: %p (%s) rc=%d rcrt=%d", this, typeid(*this).name(), _referenceCount, _referenceCountAtRootTime); + scriptMgr->rootObject(this); _rooted = true; } @@ -111,7 +116,7 @@ void Ref::release() --_referenceCount; #if CC_ENABLE_SCRIPT_BINDING && CC_ENABLE_GC_FOR_NATIVE_OBJECTS - if (_scriptOwned && _referenceCount==1 && _rooted) + if (_scriptOwned && _rooted && _referenceCount==_referenceCountAtRootTime) { auto scriptMgr = ScriptEngineManager::getInstance()->getScriptEngine(); if (scriptMgr && scriptMgr->getScriptType() == kScriptTypeJavascript) diff --git a/cocos/base/CCRef.h b/cocos/base/CCRef.h index 5ca40a0c9e..4451243ae1 100644 --- a/cocos/base/CCRef.h +++ b/cocos/base/CCRef.h @@ -161,6 +161,7 @@ public: When true, it means that the object was already rooted. */ bool _rooted; + unsigned int _referenceCountAtRootTime; /** * The life of the object is scrolled by the scripting engine. diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 19354fa161..91ff3b53e9 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -1563,14 +1563,12 @@ void ScriptingCore::rootObject(Ref* ref) nproxy = jsb_get_native_proxy(ptr); if (nproxy) { JSContext *cx = getGlobalContext(); - // FIXME: Creating a RootedObject here is not needed. - // it is being created only because jsb_get_js_proxy() requires one - // but only the raw pointer is used in jsb_get_js_proxy() - JS::RootedObject handle(cx, nproxy->obj.get()); - jsproxy = jsb_get_js_proxy(handle); - AddObjectRoot(cx, &jsproxy->obj); - - CCLOG("Rooting %p - %p: %s", ref, &jsproxy->obj, typeid(*ref).name()); + jsproxy = jsb_get_js_proxy(nproxy->obj); + JS::AddNamedObjectRoot(cx, &jsproxy->obj, typeid(*ref).name()); + } + else + { + CCLOG("BUG in rootObject"); } } @@ -1583,14 +1581,12 @@ void ScriptingCore::unrootObject(Ref* ref) nproxy = jsb_get_native_proxy(ptr); if (nproxy) { JSContext *cx = getGlobalContext(); - // FIXME: Creating a RootedObject here is not needed. - // it is being created only because jsb_get_js_proxy() requires one - // but only the raw pointer is used in jsb_get_js_proxy() - JS::RootedObject handle(cx, nproxy->obj.get()); - jsproxy = jsb_get_js_proxy(handle); - RemoveObjectRoot(cx, &jsproxy->obj); - - CCLOG("Unrooting #2 %p - %p: %s", ref, &jsproxy->obj, typeid(*ref).name()); + jsproxy = jsb_get_js_proxy(nproxy->obj); + JS::RemoveObjectRoot(cx, &jsproxy->obj); + } + else + { + CCLOG("BUG in unrootObject"); } } @@ -1949,11 +1945,10 @@ js_proxy_t* jsb_get_native_proxy(void* nativeObj) return p; } -js_proxy_t* jsb_get_js_proxy(JS::HandleObject jsObj) +js_proxy_t* jsb_get_js_proxy(JSObject* jsObj) { js_proxy_t* p = nullptr; - JSObject* ptr = jsObj.get(); - JS_GET_NATIVE_PROXY(p, ptr); + JS_GET_NATIVE_PROXY(p, jsObj); return p; } @@ -2059,8 +2054,6 @@ void jsb_ref_finalize(JSFreeOp* fop, JSObject* obj) js_proxy_t* nproxy; js_proxy_t* jsproxy; - CCLOG("jsb_ref_finalize #1: JSObject address = %p", obj); - JS::RootedObject jsobj(fop->runtime(), obj); jsproxy = jsb_get_js_proxy(jsobj); if (jsproxy) @@ -2070,8 +2063,6 @@ void jsb_ref_finalize(JSFreeOp* fop, JSObject* obj) if (ref) { - CCLOG("jsb_ref_finalize #2: JSObject address = %p (%s)", obj, typeid(*ref).name()); - jsb_remove_proxy(nproxy, jsproxy); ref->release(); } diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index b9ac8b295c..820553bfc3 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -549,7 +549,7 @@ js_type_class_t *jsb_register_class(JSContext *cx, JSClass *jsClass, JS::HandleO js_proxy_t* jsb_new_proxy(void* nativeObj, JS::HandleObject jsObj); js_proxy_t* jsb_get_native_proxy(void* nativeObj); -js_proxy_t* jsb_get_js_proxy(JS::HandleObject jsObj); +js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy); /** diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 0f4c728ab2..99a761f32c 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -5142,25 +5142,10 @@ bool js_cocos2dx_EventKeyboard_constructor(JSContext *cx, uint32_t argc, jsval * JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_EventKeyboard_constructor : Error processing arguments"); cocos2d::EventKeyboard* cobj = new (std::nothrow) cocos2d::EventKeyboard(arg0, arg1); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.ref()); - JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); - JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); - JS::RootedValue objVal(cx, OBJECT_TO_JSVAL(obj)); - args.rval().set(objVal); - // link the native object with the javascript object - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS::AddNamedObjectRoot(cx, &p->obj, "cocos2d::EventKeyboard"); + js_type_class_t *typeClass = js_get_type_from_native(cobj); + auto jsobj = jsb_ref_create_jsobject(cx, cobj, typeClass, "cocos2d::EventKeyboard"); + + args.rval().set(OBJECT_TO_JSVAL(jsobj)); return true; } diff --git a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp index 605bc616fd..bb69e13000 100644 --- a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp +++ b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp @@ -32,31 +32,31 @@ void GLNode::draw(Renderer *renderer, const Mat4& transform, uint32_t flags) { void GLNode::onDraw(Mat4 &transform, uint32_t flags) { - js_proxy_t* proxy = NULL; JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - proxy = js_get_or_create_proxy(cx, this); - if( proxy ) { -// JSObject *jsObj = proxy->obj; - JS::RootedObject jsObj(cx, proxy->obj.get()); - if (jsObj) { - bool found = false; - JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + js_type_class_t *typeClass = js_get_type_from_native(this); + auto j = jsb_ref_get_or_create_jsobject(cx, this, typeClass, "cocos2d::GLNode"); - JS_HasProperty(cx, jsObj, "draw", &found); - if (found == true) { - auto director = Director::getInstance(); - director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform); + if (j) + { + JS::RootedObject jsObj(cx, j); - JS::RootedValue rval(cx); - JS::RootedValue fval(cx); - JS_GetProperty(cx, jsObj, "draw", &fval); + bool found = false; + JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET - JS_CallFunctionValue(cx, jsObj, fval, JS::HandleValueArray::empty(), &rval); + JS_HasProperty(cx, jsObj, "draw", &found); + if (found) { + auto director = Director::getInstance(); + director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); + director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform); - director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - } + JS::RootedValue rval(cx); + JS::RootedValue fval(cx); + JS_GetProperty(cx, jsObj, "draw", &fval); + + JS_CallFunctionValue(cx, jsObj, fval, JS::HandleValueArray::empty(), &rval); + + director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } } } @@ -68,32 +68,18 @@ JSObject *js_cocos2dx_GLNode_prototype; bool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 0) { - cocos2d::GLNode* cobj = new cocos2d::GLNode(); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } + cocos2d::GLNode* cobj = new (std::nothrow) cocos2d::GLNode; - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); + js_type_class_t *typeClass = js_get_type_from_native(cobj); + JS::RootedObject jsobj(cx, jsb_ref_create_jsobject(cx, cobj, typeClass, "cocos2d::GLNode")); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - - JS::RootedObject proto(cx, typeClass->proto.ref()); - JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); - JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - args.rval().set(OBJECT_TO_JSVAL(obj)); - // link the native object with the javascript object - js_proxy_t *p = jsb_new_proxy(cobj, obj); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); - JS::AddNamedObjectRoot(cx, &p->obj, "cocos2d::GLNode"); + bool ok=false; + if (JS_HasProperty(cx, jsobj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(jsobj), "_ctor", args); return true; } @@ -101,17 +87,16 @@ bool js_cocos2dx_GLNode_constructor(JSContext *cx, uint32_t argc, jsval *vp) return false; } -void js_cocos2dx_GLNode_finalize(JSFreeOp *fop, JSObject *obj) { -} - static bool js_cocos2dx_GLNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - cocos2d::GLNode *nobj = new cocos2d::GLNode(); - js_proxy_t* p = jsb_new_proxy(nobj, obj); - nobj->autorelease(); - JS::AddNamedObjectRoot(cx, &p->obj, "GLNode"); + cocos2d::GLNode *nobj = new (std::nothrow) cocos2d::GLNode; + auto newproxy = jsb_new_proxy(nobj, obj); + jsb_ref_init(cx, &newproxy->obj, nobj, "cocos2d::GLNode"); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); args.rval().setUndefined(); return true; } @@ -119,16 +104,16 @@ static bool js_cocos2dx_GLNode_ctor(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_GLNode_create(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - cocos2d::GLNode* ret = new cocos2d::GLNode(); - jsval jsret; - do { - if (ret) { - js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); - jsret = OBJECT_TO_JSVAL(proxy->obj); - } else { - jsret = JSVAL_NULL; - } - } while (0); + cocos2d::GLNode* ret = new (std::nothrow) cocos2d::GLNode; + jsval jsret = JSVAL_NULL; + + if (ret) { + js_type_class_t *typeClass = js_get_type_from_native(ret); + + auto jsobj = jsb_ref_create_jsobject(cx, ret, typeClass, "cocos2d::GLNode"); + jsret = OBJECT_TO_JSVAL(jsobj); + } + args.rval().set(jsret); return true; } @@ -145,7 +130,7 @@ void js_register_cocos2dx_GLNode(JSContext *cx, JS::HandleObject global) { js_cocos2dx_GLNode_class->enumerate = JS_EnumerateStub; js_cocos2dx_GLNode_class->resolve = JS_ResolveStub; js_cocos2dx_GLNode_class->convert = JS_ConvertStub; - js_cocos2dx_GLNode_class->finalize = js_cocos2dx_GLNode_finalize; + js_cocos2dx_GLNode_class->finalize = jsb_ref_finalize; js_cocos2dx_GLNode_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index ce64a45310..e2d2f538f0 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -119,7 +119,7 @@ bool jsval_to_ray(JSContext *cx, JS::HandleValue vp, cocos2d::Ray* ret); bool jsval_to_resourcedata(JSContext *cx, JS::HandleValue v, cocos2d::ResourceData* ret); // forward declaration -CC_JS_DLL js_proxy_t* jsb_get_js_proxy(JS::HandleObject jsObj); +CC_JS_DLL js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); template bool jsvals_variadic_to_ccvector( JSContext *cx, /*jsval *vp, int argc,*/const JS::CallArgs& args, cocos2d::Vector* ret) diff --git a/tests/js-tests/src/MemoryModelTest/MemoryModelTest.js b/tests/js-tests/src/MemoryModelTest/MemoryModelTest.js index a38d14f122..ea0e8a245d 100644 --- a/tests/js-tests/src/MemoryModelTest/MemoryModelTest.js +++ b/tests/js-tests/src/MemoryModelTest/MemoryModelTest.js @@ -70,6 +70,7 @@ var SetPropertyMemoryModelTest = MemoryModelTestBase.extend({ _subtitle:"See console for possible errors", ctor:function () { + cc.sys.garbageCollect(); this._super(); var sprite = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121)); var tag = 10; @@ -157,6 +158,12 @@ var LocalVarMemoryModelTest = MemoryModelTestBase.extend({ var sprite2 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121)); var sprite3 = new cc.Sprite(s_grossini_dance_atlas, cc.rect(0, 0, 85, 121)); var a = 10; + this.addChild(sprite1); + this.removeChild(sprite1); +// this.addChild(sprite2); +// this.removeChild(sprite2); + this.addChild(sprite3); + this.removeChild(sprite3); //cc.sys.dumpRoot(); cc.sys.garbageCollect(); cc.log(sprite1); From c5058aa2f963ce41a6317781dfcc2709806c99eb Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 11 Dec 2015 17:18:20 -0800 Subject: [PATCH 13/66] more conversions --- .../chipmunk/js_bindings_chipmunk_manual.cpp | 81 +++++-------------- .../js-bindings/manual/cocos2d_specifics.cpp | 6 +- .../js-bindings/manual/cocos2d_specifics.hpp | 7 +- .../project.pbxproj | 12 +-- .../Classes/js_DrawNode3D_bindings.cpp | 33 ++------ 5 files changed, 33 insertions(+), 106 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp index 936430eff6..34e4d42722 100644 --- a/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp +++ b/cocos/scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp @@ -70,12 +70,6 @@ JSClass* JSPROXY_CCPhysicsSprite_class = NULL; JSObject* JSPROXY_CCPhysicsSprite_object = NULL; // Constructor -// Destructor -void JSPROXY_CCPhysicsSprite_finalize(JSFreeOp *fop, JSObject *obj) -{ - CCLOGINFO("jsbindings: finalizing JS object %p (PhysicsSprite)", obj); -} - // Arguments: // Ret value: BOOL (b) bool JSPROXY_CCPhysicsSprite_isDirty(JSContext *cx, uint32_t argc, jsval *vp) { @@ -173,12 +167,6 @@ extern JSObject *js_cocos2dx_CCDrawNode_prototype; // Constructor -// Destructor -void JSB_CCPhysicsDebugNode_finalize(JSFreeOp *fop, JSObject *obj) -{ - CCLOGINFO("jsbindings: finalizing JS object %p (PhysicsDebugNode)", obj); -} - // Arguments: cpSpace* // Ret value: PhysicsDebugNode* (o) bool JSB_CCPhysicsDebugNode_debugNodeForCPSpace__static(JSContext *cx, uint32_t argc, jsval *vp) { @@ -295,7 +283,7 @@ void JSB_CCPhysicsDebugNode_createClass(JSContext *cx, JS::HandleObject globalOb JSB_CCPhysicsDebugNode_class->enumerate = JS_EnumerateStub; JSB_CCPhysicsDebugNode_class->resolve = JS_ResolveStub; JSB_CCPhysicsDebugNode_class->convert = JS_ConvertStub; - JSB_CCPhysicsDebugNode_class->finalize = JSB_CCPhysicsDebugNode_finalize; + JSB_CCPhysicsDebugNode_class->finalize = jsb_ref_finalize; JSB_CCPhysicsDebugNode_class->flags = 0; static JSPropertySpec properties[] = { @@ -442,7 +430,8 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint32 // Arguments: NSString* // Ret value: PhysicsSprite* (o) -bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, uint32_t argc, jsval *vp) { +bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, uint32_t argc, jsval *vp) +{ JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; const char* arg0 = nullptr; @@ -452,27 +441,9 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, ui PhysicsSprite* ret = PhysicsSprite::createWithSpriteFrameName(arg0); - jsval jsret; - do { - if (ret) { - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.ref()); - JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); - JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); - jsret = OBJECT_TO_JSVAL(obj); - js_proxy_t *p = jsb_new_proxy(ret, obj); - JS::AddNamedObjectRoot(cx, &p->obj, "CCPhysicsSprite"); - } else { - jsret = JSVAL_NULL; - } - } while (0); - args.rval().set(jsret); + js_type_class_t *typeClass = js_get_type_from_native(ret); + JS::RootedObject jsret(cx, jsb_ref_autoreleased_create_jsobject(cx, ret, typeClass, "cocos2d::extension::PhysicsSprite")); + args.rval().set(OBJECT_TO_JSVAL(jsret)); return true; } @@ -483,27 +454,14 @@ bool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, ui bool JSPROXY_CCPhysicsSprite_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - PhysicsSprite* cobj = new PhysicsSprite(); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - JS::RootedObject proto(cx, typeClass->proto.ref()); - JS::RootedObject parentProto(cx, typeClass->parentProto.ref()); - JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parentProto)); - args.rval().set(OBJECT_TO_JSVAL(obj)); + auto cobj = new (std::nothrow) cocos2d::extension::PhysicsSprite; + js_type_class_t *typeClass = js_get_type_from_native(cobj); + // link the native object with the javascript object - js_proxy_t* p = jsb_new_proxy(cobj, obj); - JS::AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::PhysicsSprite"); - if (JS_HasProperty(cx, obj, "_ctor", &ok)) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + JS::RootedObject jsobj(cx, jsb_ref_create_jsobject(cx, cobj, typeClass, "cocos2d::extension::PhysicsSprite")); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + if (JS_HasProperty(cx, jsobj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(jsobj), "_ctor", args); return true; } @@ -511,14 +469,11 @@ static bool JSPROXY_CCPhysicsSprite_ctor(JSContext *cx, uint32_t argc, jsval *vp { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - PhysicsSprite *nobj = new PhysicsSprite(); - if (nobj) { - nobj->autorelease(); - } - js_proxy_t* p = jsb_new_proxy(nobj, obj); - JS::AddNamedObjectRoot(cx, &p->obj, "cocos2d::extension::SpriteFrame"); + auto nobj = new (std::nothrow) cocos2d::extension::PhysicsSprite; + auto newproxy = jsb_new_proxy(nobj, obj); + jsb_ref_init(cx, &newproxy->obj, nobj, "cocos2d::extension::PhysicsSprite"); bool isFound = false; - if (JS_HasProperty(cx, obj, "_ctor", &isFound)) + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); args.rval().setUndefined(); return true; @@ -535,7 +490,7 @@ void JSPROXY_CCPhysicsSprite_createClass(JSContext *cx, JS::HandleObject globalO JSPROXY_CCPhysicsSprite_class->enumerate = JS_EnumerateStub; JSPROXY_CCPhysicsSprite_class->resolve = JS_ResolveStub; JSPROXY_CCPhysicsSprite_class->convert = JS_ConvertStub; - JSPROXY_CCPhysicsSprite_class->finalize = JSPROXY_CCPhysicsSprite_finalize; + JSPROXY_CCPhysicsSprite_class->finalize = jsb_ref_finalize; JSPROXY_CCPhysicsSprite_class->flags = 0; static JSPropertySpec properties[] = { diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 99a761f32c..025b0ed24f 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -5152,10 +5152,6 @@ bool js_cocos2dx_EventKeyboard_constructor(JSContext *cx, uint32_t argc, jsval * extern JSObject *jsb_cocos2d_Event_prototype; -void js_cocos2d_EventKeyboard_finalize(JSFreeOp *fop, JSObject *obj) { - CCLOGINFO("jsbindings: finalizing JS object %p (EventKeyboard)", obj); -} - static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -5173,7 +5169,7 @@ void js_register_cocos2dx_EventKeyboard(JSContext *cx, JS::HandleObject global) jsb_cocos2d_EventKeyboard_class->enumerate = JS_EnumerateStub; jsb_cocos2d_EventKeyboard_class->resolve = JS_ResolveStub; jsb_cocos2d_EventKeyboard_class->convert = JS_ConvertStub; - jsb_cocos2d_EventKeyboard_class->finalize = js_cocos2d_EventKeyboard_finalize; + jsb_cocos2d_EventKeyboard_class->finalize = jsb_ref_finalize; jsb_cocos2d_EventKeyboard_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp index 1c6dc8ff2c..30a096d314 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp @@ -133,11 +133,8 @@ JSObject* js_get_or_create_jsobject(JSContext *cx, typename std::enable_ifparentProto.ref().get()); JS::RootedObject js_obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); proxy = jsb_new_proxy(native_obj, js_obj); -#ifdef DEBUG - AddNamedObjectRoot(cx, &proxy->obj, typeid(*native_obj).name()); -#else - AddObjectRoot(cx, &proxy->obj); -#endif + + JS::AddNamedObjectRoot(cx, &proxy->obj, typeid(*native_obj).name()); } return proxy->obj; } diff --git a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj index ab0bc1f418..9e61293b30 100644 --- a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj @@ -172,10 +172,10 @@ BA4095C31A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA4095C01A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.cpp */; }; BA4095C41A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = BA4095C11A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h */; }; BA4095C51A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = BA4095C11A6F730A005E53F6 /* jsb_cocos2dx_studio_conversions.h */; }; - BA9FD5D21BAC0A7600996C85 /* CCComponentJS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA9FD5D01BAC0A7600996C85 /* CCComponentJS.cpp */; settings = {ASSET_TAGS = (); }; }; - BA9FD5D31BAC0A7600996C85 /* CCComponentJS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA9FD5D01BAC0A7600996C85 /* CCComponentJS.cpp */; settings = {ASSET_TAGS = (); }; }; - BA9FD5D41BAC0A7600996C85 /* CCComponentJS.h in Headers */ = {isa = PBXBuildFile; fileRef = BA9FD5D11BAC0A7600996C85 /* CCComponentJS.h */; settings = {ASSET_TAGS = (); }; }; - BA9FD5D51BAC0A7600996C85 /* CCComponentJS.h in Headers */ = {isa = PBXBuildFile; fileRef = BA9FD5D11BAC0A7600996C85 /* CCComponentJS.h */; settings = {ASSET_TAGS = (); }; }; + BA9FD5D21BAC0A7600996C85 /* CCComponentJS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA9FD5D01BAC0A7600996C85 /* CCComponentJS.cpp */; }; + BA9FD5D31BAC0A7600996C85 /* CCComponentJS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA9FD5D01BAC0A7600996C85 /* CCComponentJS.cpp */; }; + BA9FD5D41BAC0A7600996C85 /* CCComponentJS.h in Headers */ = {isa = PBXBuildFile; fileRef = BA9FD5D11BAC0A7600996C85 /* CCComponentJS.h */; }; + BA9FD5D51BAC0A7600996C85 /* CCComponentJS.h in Headers */ = {isa = PBXBuildFile; fileRef = BA9FD5D11BAC0A7600996C85 /* CCComponentJS.h */; }; BAEE4D711AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BAEE4D6F1AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp */; }; BAEE4D721AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BAEE4D6F1AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.cpp */; }; BAEE4D731AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BAEE4D701AC3FFAD003BEB0F /* jsb_cocos2dx_3d_extension_auto.hpp */; }; @@ -211,7 +211,6 @@ 1A119E3C18BDF19200352BAA /* jsb_cocos2dx_spine_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_spine_auto.hpp; sourceTree = ""; }; 1A119E3E18BDF19200352BAA /* jsb_cocos2dx_studio_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_studio_auto.cpp; sourceTree = ""; }; 1A119E3F18BDF19200352BAA /* jsb_cocos2dx_studio_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_studio_auto.hpp; sourceTree = ""; }; - 1A119E4318BDF19200352BAA /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; 1A119E4418BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_chipmunk_auto_classes.cpp; sourceTree = ""; }; 1A119E4518BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_auto_classes.h; sourceTree = ""; }; 1A119E4618BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_auto_classes_registration.h; sourceTree = ""; }; @@ -224,7 +223,6 @@ 1A119E4D18BDF19200352BAA /* js_bindings_chipmunk_registration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_chipmunk_registration.h; sourceTree = ""; }; 1A119E4E18BDF19200352BAA /* cocos2d_specifics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d_specifics.cpp; sourceTree = ""; }; 1A119E4F18BDF19200352BAA /* cocos2d_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2d_specifics.hpp; sourceTree = ""; }; - 1A119E5118BDF19200352BAA /* Android.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Android.mk; sourceTree = ""; }; 1A119E5218BDF19200352BAA /* cocosbuilder_specifics.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocosbuilder_specifics.hpp; sourceTree = ""; }; 1A119E5318BDF19200352BAA /* js_bindings_ccbreader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = js_bindings_ccbreader.cpp; sourceTree = ""; }; 1A119E5418BDF19200352BAA /* js_bindings_ccbreader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = js_bindings_ccbreader.h; sourceTree = ""; }; @@ -428,7 +426,6 @@ 1A119E4218BDF19200352BAA /* chipmunk */ = { isa = PBXGroup; children = ( - 1A119E4318BDF19200352BAA /* Android.mk */, 1A119E4418BDF19200352BAA /* js_bindings_chipmunk_auto_classes.cpp */, 1A119E4518BDF19200352BAA /* js_bindings_chipmunk_auto_classes.h */, 1A119E4618BDF19200352BAA /* js_bindings_chipmunk_auto_classes_registration.h */, @@ -446,7 +443,6 @@ 1A119E5018BDF19200352BAA /* cocosbuilder */ = { isa = PBXGroup; children = ( - 1A119E5118BDF19200352BAA /* Android.mk */, 1A119E5218BDF19200352BAA /* cocosbuilder_specifics.hpp */, 1A119E5318BDF19200352BAA /* js_bindings_ccbreader.cpp */, 1A119E5418BDF19200352BAA /* js_bindings_ccbreader.h */, diff --git a/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp b/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp index cc1bb7a1f0..e3d0dc14fb 100644 --- a/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp +++ b/tests/js-tests/project/Classes/js_DrawNode3D_bindings.cpp @@ -485,29 +485,15 @@ bool js_cocos2dx_DrawNode3D_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); bool ok = true; - cocos2d::DrawNode3D* cobj = new (std::nothrow) cocos2d::DrawNode3D(); + cocos2d::DrawNode3D* cobj = new (std::nothrow) cocos2d::DrawNode3D; cobj->init(); - cocos2d::Ref *_ccobj = dynamic_cast(cobj); - if (_ccobj) { - _ccobj->autorelease(); - } - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - CCASSERT(typeClass, "The value is null."); - // JSObject *obj = JS_NewObject(cx, typeClass->jsclass, typeClass->proto, typeClass->parentProto); - JS::RootedObject proto(cx, typeClass->proto.ref()); - JS::RootedObject parent(cx, typeClass->parentProto.ref()); - JS::RootedObject obj(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); - args.rval().set(OBJECT_TO_JSVAL(obj)); + js_type_class_t *typeClass = js_get_type_from_native(cobj); + // link the native object with the javascript object - js_proxy_t* p = jsb_new_proxy(cobj, obj); - AddNamedObjectRoot(cx, &p->obj, "cocos2d::DrawNode3D"); - if (JS_HasProperty(cx, obj, "_ctor", &ok) && ok) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + JS::RootedObject jsobj(cx, jsb_ref_create_jsobject(cx, cobj, typeClass, "cocos2d::DrawNode3D")); + args.rval().set(OBJECT_TO_JSVAL(jsobj)); + if (JS_HasProperty(cx, jsobj, "_ctor", &ok) && ok) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(jsobj), "_ctor", args); return true; } @@ -520,9 +506,6 @@ static bool js_is_native_obj(JSContext *cx, uint32_t argc, jsval *vp) extern JSObject *jsb_cocos2d_Node_prototype; -void js_cocos2d_DrawNode3D_finalize(JSFreeOp *fop, JSObject *obj) { - CCLOGINFO("jsbindings: finalizing JS object %p (DrawNode3D)", obj); -} void js_register_cocos2dx_DrawNode3D(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_DrawNode3D_class = (JSClass *)calloc(1, sizeof(JSClass)); @@ -534,7 +517,7 @@ void js_register_cocos2dx_DrawNode3D(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_DrawNode3D_class->enumerate = JS_EnumerateStub; jsb_cocos2d_DrawNode3D_class->resolve = JS_ResolveStub; jsb_cocos2d_DrawNode3D_class->convert = JS_ConvertStub; - jsb_cocos2d_DrawNode3D_class->finalize = js_cocos2d_DrawNode3D_finalize; + jsb_cocos2d_DrawNode3D_class->finalize = jsb_ref_finalize; jsb_cocos2d_DrawNode3D_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); static JSPropertySpec properties[] = { From b1d700ad33f882a7b99e8e5a00160fab47a36d22 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Sun, 13 Dec 2015 13:59:42 +0800 Subject: [PATCH 14/66] fix bmfont size error --- cocos/2d/CCLabel.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index ccf3e09c54..cfcbd019dc 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -591,9 +591,7 @@ bool Label::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2& ima FontFNT *bmFont = (FontFNT*)newAtlas->getFont(); if (bmFont) { float originalFontSize = bmFont->getOriginalFontSize(); - if(fabs(_bmFontSize+1) < FLT_EPSILON){ - _bmFontSize = originalFontSize / CC_CONTENT_SCALE_FACTOR(); - } + _bmFontSize = originalFontSize / CC_CONTENT_SCALE_FACTOR(); } } From 8c9b03112e5880723797d5a0d10fd2abe6ce10b6 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 14 Dec 2015 10:09:06 +0800 Subject: [PATCH 15/66] fix scale9sprite global zorder issue. 1. it also fix the positiong issue when call setScale9Enabled(false) --- cocos/ui/UIScale9Sprite.cpp | 20 ++++- cocos/ui/UIScale9Sprite.h | 5 +- .../CocoStudioGUITest/UIScale9SpriteTest.cpp | 82 +++++++++++++++++++ .../CocoStudioGUITest/UIScale9SpriteTest.h | 16 ++++ 4 files changed, 121 insertions(+), 2 deletions(-) diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index 91454b8058..aef00adf7a 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -670,7 +670,7 @@ namespace ui { void Scale9Sprite::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { - if (_scale9Image) { + if (_scale9Image && _scale9Enabled) { #if CC_USE_CULLING // Don't do calculate the culling if the transform was not updated auto visitingCamera = Camera::getVisitingCamera(); @@ -757,12 +757,21 @@ namespace ui { else break; } + + if (!_scale9Enabled && _scale9Image && _scale9Image->getLocalZOrder() < 0 ) + { + _scale9Image->visit(renderer, _modelViewTransform, flags); + } // draw self // if (isVisitableByVisitingCamera()) this->draw(renderer, _modelViewTransform, flags); + if (!_scale9Enabled && _scale9Image && _scale9Image->getLocalZOrder() >= 0 ) + { + _scale9Image->visit(renderer, _modelViewTransform, flags); + } for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) (*it)->visit(renderer, _modelViewTransform, flags); @@ -1336,5 +1345,14 @@ namespace ui { CC_SAFE_RELEASE_NULL(this->_scale9Image); } + + void Scale9Sprite::setGlobalZOrder(float globalZOrder) + { + Node::setGlobalZOrder(globalZOrder); + if (_scale9Image) + { + _scale9Image->setGlobalZOrder(globalZOrder); + } + } }} diff --git a/cocos/ui/UIScale9Sprite.h b/cocos/ui/UIScale9Sprite.h index 7a36a5f1de..0908c5f93f 100644 --- a/cocos/ui/UIScale9Sprite.h +++ b/cocos/ui/UIScale9Sprite.h @@ -577,6 +577,8 @@ namespace ui { /** * @brief Toggle 9-slice feature. * If Scale9Sprite is 9-slice disabled, the Scale9Sprite will rendered as a normal sprite. + * @waring: Don't use setScale9Enabled(false), use setRenderingType(RenderingType::SIMPLE) instead. + * The setScale9Enabled(false) is kept only for back back compatibility. * @param enabled True to enable 9-slice, false otherwise. * @js NA */ @@ -657,7 +659,8 @@ namespace ui { virtual float getScale() const override; using Node::getScaleZ; virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override; - + virtual void setGlobalZOrder(float globalZOrder) override; + /** * Set the slice sprite rendering type. * When setting to SIMPLE, only 4 vertexes is used to rendering. diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index 408c61f91b..4357efc8ef 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -55,6 +55,8 @@ UIScale9SpriteTests::UIScale9SpriteTests() ADD_TEST_CASE(UIS9NinePatchTest); ADD_TEST_CASE(UIS9BatchTest); ADD_TEST_CASE(UIS9ToggleRenderingTypeTest); + ADD_TEST_CASE(UIS9GlobalZOrderTest); + ADD_TEST_CASE(UIS9EnableScale9FalseTest); } // UIScale9SpriteTest @@ -92,6 +94,7 @@ bool UIScale9SpriteTest::init() normalSprite2->setPosition(120, 270); normalSprite2->setScale9Enabled(false); normalSprite2->setOpacity(100); + normalSprite2->setContentSize(normalSprite2->getContentSize() * 2); this->addChild(normalSprite2); normalSprite2->setColor(Color3B::GREEN); normalSprite2->runAction(action); @@ -994,3 +997,82 @@ bool UIS9ToggleRenderingTypeTest::init() return false; } + +bool UIS9GlobalZOrderTest::init() +{ + if (UIScene::init()) { + + auto winSize = Director::getInstance()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2 - 20); + + auto label = Label::createWithSystemFont("The green scale9sprite is in the back.", "Arial", 15); + label->setPosition(Vec2(winSize.width/2, winSize.height - 60)); + this->addChild(label); + + auto blocks = ui::Scale9Sprite::create("Images/blocks9.png"); + + blocks->setPosition(Vec2(x, y)); + blocks->setPreferredSize(Size(96*2, 96*1.5)); + blocks->setColor(Color3B::RED); + blocks->setGlobalZOrder(1); + this->addChild(blocks); + + + auto blocks2 = ui::Scale9Sprite::create("Images/blocks9.png"); + blocks2->setPosition(Vec2(x, y)); + blocks2->setPreferredSize(Size(96*3, 96)); + blocks2->setGlobalZOrder(0); + blocks2->setColor(Color3B::GREEN); + this->addChild(blocks2); + + + return true; + } + return false; +} + + +bool UIS9EnableScale9FalseTest::init() +{ + if (UIScene::init()) { + + auto winSize = Director::getInstance()->getWinSize(); + float x = winSize.width / 2 + 50; + float y = 0 + (winSize.height / 2 + 10); + + auto label = Label::createWithSystemFont("Only the yellow block intersect with the green one.", "Arial", 15); + label->setPosition(Vec2(winSize.width/2, winSize.height - 60)); + this->addChild(label); + + auto blocks = ui::Scale9Sprite::create("Images/blocks9.png"); + blocks->setScale9Enabled(false); + blocks->setPosition(Vec2(x, y)); + blocks->setPreferredSize(Size(96*2, 96)); + blocks->setColor(Color3B::RED); + blocks->setGlobalZOrder(1); + this->addChild(blocks); + + + auto blocks2 = ui::Scale9Sprite::create("Images/blocks9.png"); + blocks2->setScale9Enabled(false); + blocks2->setPosition(Vec2(0, 0)); + blocks2->setPreferredSize(Size(96*1.5, 96)); + blocks2->setGlobalZOrder(0); + blocks2->setColor(Color3B::GREEN); + blocks->addChild(blocks2); + + auto blocks3 = ui::Scale9Sprite::create("Images/blocks9.png"); + blocks3->setScale9Enabled(false); + blocks3->setPosition(Vec2(0, 0)); + blocks3->setPreferredSize(Size(96, 96)); + blocks3->setGlobalZOrder(2); + blocks3->setColor(Color3B::YELLOW); + blocks2->addChild(blocks3); + + + return true; + } + return false; +} + diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h index 87b328bf9c..66e6d238df 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h @@ -274,4 +274,20 @@ public: virtual bool init() override; }; +class UIS9GlobalZOrderTest: public UIScene +{ +public: + CREATE_FUNC(UIS9GlobalZOrderTest); + + virtual bool init() override; +}; + +class UIS9EnableScale9FalseTest: public UIScene +{ +public: + CREATE_FUNC(UIS9EnableScale9FalseTest); + + virtual bool init() override; +}; + #endif /* defined(__cocos2d_tests__UIScale9SpriteTest__) */ From 0f5aac57549209012b3cf71ca4ec2e1346934f67 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 14 Dec 2015 10:14:39 +0800 Subject: [PATCH 16/66] fix typo --- cocos/ui/UIScale9Sprite.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/ui/UIScale9Sprite.h b/cocos/ui/UIScale9Sprite.h index 0908c5f93f..4404ac9a64 100644 --- a/cocos/ui/UIScale9Sprite.h +++ b/cocos/ui/UIScale9Sprite.h @@ -577,7 +577,7 @@ namespace ui { /** * @brief Toggle 9-slice feature. * If Scale9Sprite is 9-slice disabled, the Scale9Sprite will rendered as a normal sprite. - * @waring: Don't use setScale9Enabled(false), use setRenderingType(RenderingType::SIMPLE) instead. + * @warning: Don't use setScale9Enabled(false), use setRenderingType(RenderingType::SIMPLE) instead. * The setScale9Enabled(false) is kept only for back back compatibility. * @param enabled True to enable 9-slice, false otherwise. * @js NA From 445442c964297a9970e268b06b7ecf25e5c93610 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 14 Dec 2015 10:27:11 +0800 Subject: [PATCH 17/66] Upgrade spider monkey to solve win32 js project crash issue --- cocos/scripting/js-bindings/manual/ScriptingCore.cpp | 6 +++--- cocos/scripting/js-bindings/manual/ScriptingCore.h | 2 +- external/config.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 19354fa161..ae2481d067 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -1869,14 +1869,14 @@ void ScriptingCore::enableDebugger(unsigned int port) } } -JS::HandleObject NewGlobalObject(JSContext* cx, bool debug) +JSObject* NewGlobalObject(JSContext* cx, bool debug) { JS::CompartmentOptions options; options.setVersion(JSVERSION_LATEST); JS::RootedObject glob(cx, JS_NewGlobalObject(cx, &global_class, &shellTrustedPrincipals, JS::DontFireOnNewGlobalHook, options)); if (!glob) { - return JS::NullPtr(); + return nullptr; } JSAutoCompartment ac(cx, glob); bool ok = true; @@ -1886,7 +1886,7 @@ JS::HandleObject NewGlobalObject(JSContext* cx, bool debug) if (ok && debug) ok = JS_DefineDebuggerObject(cx, glob); if (!ok) - return JS::NullPtr(); + return nullptr; JS_FireOnNewGlobalObject(cx, glob); diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index b9ac8b295c..336909455c 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -517,7 +517,7 @@ public: void restartVM(); }; -JS::HandleObject NewGlobalObject(JSContext* cx, bool debug = false); +JSObject* NewGlobalObject(JSContext* cx, bool debug = false); bool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value); bool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret); diff --git a/external/config.json b/external/config.json index 4c7cebe515..0739cd1c10 100644 --- a/external/config.json +++ b/external/config.json @@ -1,6 +1,6 @@ { - "version":"v3-deps-78", - "zip_file_size":"119277304", + "version":"v3-deps-79", + "zip_file_size":"124402591", "repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_parent":"https://github.com/cocos2d/", "move_dirs":{ From 4815ec8b9a14416db648f5f11d3ff3aeef28c21d Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Mon, 14 Dec 2015 10:18:00 +0800 Subject: [PATCH 18/66] Update version number to v3.10 --- CMakeLists.txt | 2 +- cocos/cocos2d.h | 2 +- cocos/scripting/js-bindings/manual/ScriptingCore.h | 2 +- cocos/scripting/js-bindings/script/jsb_cocos2d.js | 2 +- docs/doxygen.config | 2 +- .../frameworks/runtime-src/proj.ios_mac/mac/Info.plist | 2 +- tools/simulator/frameworks/runtime-src/proj.win32/game.rc | 4 ++-- web | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d4e896e89..ac89a870bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ endif() project (Cocos2d-X) # The version number -set(COCOS2D_X_VERSION 3.9) +set(COCOS2D_X_VERSION 3.10) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/") include(CocosBuildHelpers) diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index 1f3a539d2c..d9e52296a0 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -30,7 +30,7 @@ THE SOFTWARE. // 0x00 HI ME LO // 00 03 08 00 -#define COCOS2D_VERSION 0x00030900 +#define COCOS2D_VERSION 0x00031000 // // all cocos2d include files diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index e5f8587ad6..80f7028f7d 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -40,7 +40,7 @@ #include #include -#define ENGINE_VERSION "Cocos2d-JS v3.9" +#define ENGINE_VERSION "Cocos2d-JS v3.10" void js_log(const char *format, ...); diff --git a/cocos/scripting/js-bindings/script/jsb_cocos2d.js b/cocos/scripting/js-bindings/script/jsb_cocos2d.js index 6c0cb46b1f..fc976b8abc 100644 --- a/cocos/scripting/js-bindings/script/jsb_cocos2d.js +++ b/cocos/scripting/js-bindings/script/jsb_cocos2d.js @@ -26,7 +26,7 @@ // CCConfig.js // -cc.ENGINE_VERSION = "Cocos2d-JS v3.9"; +cc.ENGINE_VERSION = "Cocos2d-JS v3.10"; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; cc.DIRECTOR_STATS_POSITION = {x: 0, y: 0}; diff --git a/docs/doxygen.config b/docs/doxygen.config index 8f6c30aa0c..9df6c39a70 100644 --- a/docs/doxygen.config +++ b/docs/doxygen.config @@ -38,7 +38,7 @@ PROJECT_NAME = Cocos2d-x # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = v3.9 +PROJECT_NUMBER = v3.10 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist index 3a52f89600..70c8595a30 100644 --- a/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist +++ b/tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist @@ -41,7 +41,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.9 + 3.10 CFBundleSignature ???? CFBundleVersion diff --git a/tools/simulator/frameworks/runtime-src/proj.win32/game.rc b/tools/simulator/frameworks/runtime-src/proj.win32/game.rc index 35e7e472f4..65a3d825ec 100755 --- a/tools/simulator/frameworks/runtime-src/proj.win32/game.rc +++ b/tools/simulator/frameworks/runtime-src/proj.win32/game.rc @@ -64,7 +64,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM CAPTION "About Simulator" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CTEXT "Version 3.9 (20151106)",IDC_ABOUT_VERSION,35,70,173,17 + CTEXT "Version 3.10 (20151222)",IDC_ABOUT_VERSION,35,70,173,17 CTEXT "Cocos Simulator",IDC_ABOUT_TITLE,35,49,173,17 CTEXT "Copyright (C) 2015. All rights reserved.",IDC_STATIC,35,94,173,17 ICON "GLFW_ICON",IDC_STATIC,111,15,20,20 @@ -167,7 +167,7 @@ VS_VERSION_INFO VERSIONINFO BEGIN BLOCK "StringFileInfo" BEGIN - BLOCK "040904B0" + BLOCK "040904b0" BEGIN VALUE "FileDescription", "game Module" VALUE "FileVersion", "1, 0, 0, 1" diff --git a/web b/web index 116c3c9ac1..5ff018e81b 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 116c3c9ac13354cd62e65dc4ef48738fa9872340 +Subproject commit 5ff018e81bad24816373362146f2589e17706dfa From 3e64e09e6934a35f5559c44c1edd73879cd5271d Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 14 Dec 2015 10:40:09 +0800 Subject: [PATCH 19/66] fix memory leaks of stencileStateManager --- cocos/2d/CCClippingNode.cpp | 1 + cocos/ui/UILayout.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 8557203765..2f7db66030 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -67,6 +67,7 @@ ClippingNode::~ClippingNode() _stencil->stopAllActions(); _stencil->release(); } + CC_SAFE_DELETE(_stencilStateManager); } ClippingNode* ClippingNode::create() diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index b1643eff7e..81ae344ed5 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -87,6 +87,7 @@ _isFocusPassing(false) Layout::~Layout() { CC_SAFE_RELEASE(_clippingStencil); + CC_SAFE_DELETE(_stencileStateManager); } void Layout::onEnter() From 436db6e9325541b6cc9cb6d8dc074e0f3e111d74 Mon Sep 17 00:00:00 2001 From: zhangcheng Date: Mon, 14 Dec 2015 11:20:26 +0800 Subject: [PATCH 20/66] Fix #24347 JSTest(web)-->UI Test-->UIFocus-->UIFocusTestVertical displays focus first. --- tests/js-tests/src/GUITest/UIFocusTest/UIFocusTest.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/js-tests/src/GUITest/UIFocusTest/UIFocusTest.js b/tests/js-tests/src/GUITest/UIFocusTest/UIFocusTest.js index 5b172dae05..27ea0e2164 100644 --- a/tests/js-tests/src/GUITest/UIFocusTest/UIFocusTest.js +++ b/tests/js-tests/src/GUITest/UIFocusTest/UIFocusTest.js @@ -188,8 +188,6 @@ var UIFocusTestVertical = UIFocusTestBase.extend({ w.setTag(i); w.addTouchEventListener(this.onImageViewClicked, this); this._verticalLayout.addChild(w); - if (i == 2) - w.requestFocus(); } this._loopText = new ccui.Text("loop enabled", "Arial", 20); From 838bd242ce54595461e3480a8f451e276de5798b Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 14 Dec 2015 11:53:09 +0800 Subject: [PATCH 21/66] fix #12249 --- cocos/ui/UIButton.cpp | 2 +- cocos/ui/UIImageView.cpp | 2 +- cocos/ui/UILoadingBar.cpp | 2 +- cocos/ui/UISlider.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/ui/UIButton.cpp b/cocos/ui/UIButton.cpp index c877a70eac..ab034d18b4 100644 --- a/cocos/ui/UIButton.cpp +++ b/cocos/ui/UIButton.cpp @@ -256,7 +256,7 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType) } } //FIXME: https://github.com/cocos2d/cocos2d-x/issues/12249 - if (!_ignoreSize) { + if (!_ignoreSize && _customSize.equals(Size::ZERO)) { _customSize = _buttonNormalRenderer->getContentSize(); } this->setupNormalTexture(textureLoaded); diff --git a/cocos/ui/UIImageView.cpp b/cocos/ui/UIImageView.cpp index 79c12adf36..d9af32b8a9 100644 --- a/cocos/ui/UIImageView.cpp +++ b/cocos/ui/UIImageView.cpp @@ -137,7 +137,7 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType) break; } //FIXME: https://github.com/cocos2d/cocos2d-x/issues/12249 - if (!_ignoreSize) { + if (!_ignoreSize && _customSize.equals(Size::ZERO)) { _customSize = _imageRenderer->getContentSize(); } this->setupTexture(); diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index dd1d040947..d96f141369 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -163,7 +163,7 @@ void LoadingBar::loadTexture(const std::string& texture,TextureResType texType) } //FIXME: https://github.com/cocos2d/cocos2d-x/issues/12249 - if (!_ignoreSize) { + if (!_ignoreSize && _customSize.equals(Size::ZERO)) { _customSize = _barRenderer->getContentSize(); } this->setupTexture(); diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index 20909e73ca..07ca7c3077 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -172,7 +172,7 @@ void Slider::loadBarTexture(const std::string& fileName, TextureResType texType) } } //FIXME: https://github.com/cocos2d/cocos2d-x/issues/12249 - if (!_ignoreSize) { + if (!_ignoreSize && _customSize.equals(Size::ZERO)) { _customSize = _barRenderer->getContentSize(); } this->setupBarTexture(); From 330b588215da65b04ee430528151bc212d5fc877 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 14 Dec 2015 13:13:54 +0800 Subject: [PATCH 22/66] Fix evalString doesn't return result issue --- cocos/scripting/js-bindings/manual/ScriptingCore.cpp | 10 ++-------- cocos/scripting/js-bindings/manual/ScriptingCore.h | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index ae2481d067..85fb7e0c9d 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -500,16 +500,10 @@ void ScriptingCore::string_report(JS::HandleValue val) { } } -bool ScriptingCore::evalString(const char *string, jsval *outVal, const char *filename, JSContext* cx, JSObject* global) +bool ScriptingCore::evalString(const char *string, JS::MutableHandleValue outVal, JSContext* cx, JS::HandleObject global, const char *filename) { - if (cx == NULL) - cx = _cx; - if (global == NULL) - global = _global.ref().get(); - JSAutoCompartment ac(cx, global); - JS::RootedObject jsglobal(cx, global); - return JS_EvaluateScript(cx, jsglobal, string, (unsigned)strlen(string), "ScriptingCore::evalString", 1); + return JS_EvaluateScript(cx, global, string, (unsigned)strlen(string), "ScriptingCore::evalString", 1, outVal); } void ScriptingCore::start() diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 336909455c..e167569cb8 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -234,7 +234,7 @@ public: * @param global @~english The js global object * @return @~english Return true if successfully invoked, otherwise return false. */ - bool evalString(const char *string, jsval *outVal, const char *filename = NULL, JSContext* cx = NULL, JSObject* global = NULL); + bool evalString(const char *string, JS::MutableHandleValue outVal, JSContext* cx, JS::HandleObject global, const char *filename = NULL); /** @brief @~english Get script object for the given path From 662c7fbec50e7a6802cb6febe8db5cc05a255ca2 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 14 Dec 2015 13:55:17 +0800 Subject: [PATCH 23/66] Made API consistent with old version --- .../js-bindings/manual/ScriptingCore.cpp | 13 ++++++++++++- .../js-bindings/manual/ScriptingCore.h | 17 ++++++++++++++++- .../platform/android/CCJavascriptJavaBridge.cpp | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 85fb7e0c9d..aab6456212 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -500,12 +500,23 @@ void ScriptingCore::string_report(JS::HandleValue val) { } } -bool ScriptingCore::evalString(const char *string, JS::MutableHandleValue outVal, JSContext* cx, JS::HandleObject global, const char *filename) +bool ScriptingCore::evalString(const char *string, JS::MutableHandleValue outVal, const char *filename, JSContext* cx, JS::HandleObject global) { JSAutoCompartment ac(cx, global); return JS_EvaluateScript(cx, global, string, (unsigned)strlen(string), "ScriptingCore::evalString", 1, outVal); } +bool ScriptingCore::evalString(const char *string, JS::MutableHandleValue outVal) +{ + return evalString(string, outVal, nullptr, _cx, _global.ref()); +} + +bool ScriptingCore::evalString(const char *string) +{ + JS::RootedValue retVal(_cx); + return evalString(string, &retVal); +} + void ScriptingCore::start() { // for now just this diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index e167569cb8..748694e518 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -234,7 +234,22 @@ public: * @param global @~english The js global object * @return @~english Return true if successfully invoked, otherwise return false. */ - bool evalString(const char *string, JS::MutableHandleValue outVal, JSContext* cx, JS::HandleObject global, const char *filename = NULL); + bool evalString(const char *string, JS::MutableHandleValue outVal, const char *filename, JSContext* cx, JS::HandleObject global); + + /**@~english + * Evaluate the specified js code string + * @param string @~english The string with the javascript code to be evaluated + * @param outVal @~english The jsval that will hold the return value of the evaluation. + * @return @~english Return true if successfully invoked, otherwise return false. + */ + bool evalString(const char *string, JS::MutableHandleValue outVal); + + /**@~english + * Evaluate the specified js code string + * @param string @~english The string with the javascript code to be evaluated + * @return @~english Return true if successfully invoked, otherwise return false. + */ + bool evalString(const char *string); /** @brief @~english Get script object for the given path diff --git a/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp b/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp index 8b65563ebf..419dc4b603 100644 --- a/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp +++ b/cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.cpp @@ -46,7 +46,7 @@ JNIEXPORT jint JNICALL Java_org_cocos2dx_lib_Cocos2dxJavascriptJavaBridge_evalSt CCLOG("Cocos2dxJavascriptJavaBridge_evalString error, invalid string code"); return 0; } - ScriptingCore::getInstance()->evalString(strValue.c_str(), nullptr); + ScriptingCore::getInstance()->evalString(strValue.c_str()); return 1; } From 23bf815cfab7cf5274ab87fdc7146be5b060bfc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E5=B3=B0?= Date: Mon, 14 Dec 2015 14:26:52 +0800 Subject: [PATCH 24/66] Fix 3d touch compile error in lower version Xcode --- cocos/platform/ios/CCEAGLView-ios.mm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos/platform/ios/CCEAGLView-ios.mm b/cocos/platform/ios/CCEAGLView-ios.mm index eb4947bd5f..89894b21c9 100644 --- a/cocos/platform/ios/CCEAGLView-ios.mm +++ b/cocos/platform/ios/CCEAGLView-ios.mm @@ -427,8 +427,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved. ids[i] = touch; xs[i] = [touch locationInView: [touch view]].x * self.contentScaleFactor;; ys[i] = [touch locationInView: [touch view]].y * self.contentScaleFactor;; - -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0 // Use 9.0 or higher SDK to compile +#ifdef __IPHONE_9_0 && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0 // running on iOS 9.0 or higher version if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0f) { fs[i] = touch.force; From 508d54ec3c2c8e12a23ad8dc600508d70f72840d Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 14 Dec 2015 15:29:02 +0800 Subject: [PATCH 25/66] fix pageview child size --- cocos/ui/UIListView.h | 2 +- cocos/ui/UIPageView.cpp | 5 ++ cocos/ui/UIPageView.h | 1 + .../UIPageViewTest/UIPageViewTest.cpp | 86 +++++++++++++++++++ .../UIPageViewTest/UIPageViewTest.h | 16 ++++ 5 files changed, 109 insertions(+), 1 deletion(-) diff --git a/cocos/ui/UIListView.h b/cocos/ui/UIListView.h index 0112cf585a..66e48efcf1 100644 --- a/cocos/ui/UIListView.h +++ b/cocos/ui/UIListView.h @@ -390,8 +390,8 @@ protected: virtual void onItemListChanged(); + virtual void remedyLayoutParameter(Widget* item); void updateInnerContainerSize(); - void remedyLayoutParameter(Widget* item); void remedyVerticalLayoutParameter(LinearLayoutParameter* layoutParameter, ssize_t itemIndex); void remedyHorizontalLayoutParameter(LinearLayoutParameter* layoutParameter,ssize_t itemIndex); diff --git a/cocos/ui/UIPageView.cpp b/cocos/ui/UIPageView.cpp index 17904d2c38..3fb95e8093 100644 --- a/cocos/ui/UIPageView.cpp +++ b/cocos/ui/UIPageView.cpp @@ -427,6 +427,11 @@ const Color3B& PageView::getIndicatorSelectedIndexColor() const return _indicator->getSelectedIndexColor(); } +void PageView::remedyLayoutParameter(Widget *item) +{ + item->setContentSize(this->getContentSize()); + ListView::remedyLayoutParameter(item); +} } diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index c2129ccdda..926eb936c4 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -350,6 +350,7 @@ CC_CONSTRUCTOR_ACCESS: protected: void pageTurningEvent(); + virtual void remedyLayoutParameter(Widget* item)override; virtual void moveInnerContainer(const Vec2& deltaMove, bool canStartBounceBack) override; virtual void onItemListChanged() override; virtual void onSizeChanged() override; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index 20040dfdb2..7306c0d9a8 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -13,6 +13,7 @@ UIPageViewTests::UIPageViewTests() ADD_TEST_CASE(UIPageViewJumpToPageTest); ADD_TEST_CASE(UIPageViewVerticalTest); ADD_TEST_CASE(UIPageViewDisableTouchTest); + ADD_TEST_CASE(UIPageViewChildSizeTest); } // UIPageViewTest @@ -876,3 +877,88 @@ bool UIPageViewDisableTouchTest::init() return false; } +// UIPageViewTest +UIPageViewChildSizeTest::UIPageViewChildSizeTest() + : _displayValueLabel(nullptr) +{ + +} + +UIPageViewChildSizeTest::~UIPageViewChildSizeTest() +{ +} + +bool UIPageViewChildSizeTest::init() +{ + if (UIScene::init()) + { + Size widgetSize = _widget->getContentSize(); + + // Add a label in which the dragpanel events will be displayed + _displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32); + _displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f)); + _displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f + + _displayValueLabel->getContentSize().height * 1.5)); + _uiLayer->addChild(_displayValueLabel); + + // Add the black background + Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30); + alert->setColor(Color3B(159, 168, 176)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f)); + _uiLayer->addChild(alert); + + Layout* root = static_cast(_uiLayer->getChildByTag(81)); + + Layout* background = dynamic_cast(root->getChildByName("background_Panel")); + + // Create the page view + Size size(240, 130); + PageView* pageView = PageView::create(); + pageView->setDirection(PageView::Direction::HORIZONTAL); + pageView->setContentSize(size); + Size backgroundSize = background->getContentSize(); + pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f); + pageView->removeAllItems(); + pageView->setIndicatorEnabled(true); + + int pageCount = 4; + for (int i = 0; i < pageCount; ++i) + { + ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png"); + imageView->setScale9Enabled(true); + + Text* label = Text::create(StringUtils::format("page %d", (i + 1)), "fonts/Marker Felt.ttf", 30); + label->setColor(Color3B(192, 192, 192)); + label->setAnchorPoint(Vec2::ZERO); + imageView->addChild(label); + + pageView->insertCustomItem(imageView, i); + } + + pageView->addEventListener(CC_CALLBACK_2(UIPageViewChildSizeTest::pageViewEvent, this)); + + _uiLayer->addChild(pageView); + + return true; + } + return false; +} + +void UIPageViewChildSizeTest::pageViewEvent(Ref *pSender, PageView::EventType type) +{ + switch (type) + { + case PageView::EventType::TURNING: + { + PageView* pageView = dynamic_cast(pSender); + + _displayValueLabel->setString(StringUtils::format("page = %ld", pageView->getCurrentPageIndex() + 1)); + } + break; + + default: + break; + } +} + diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h index 466b95673a..bc17231970 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h @@ -139,4 +139,20 @@ protected: cocos2d::ui::Text* _displayValueLabel; }; +class UIPageViewChildSizeTest : public UIScene +{ +public: + CREATE_FUNC(UIPageViewChildSizeTest); + + UIPageViewChildSizeTest(); + ~UIPageViewChildSizeTest(); + virtual bool init() override; + + void pageViewEvent(cocos2d::Ref* sender, cocos2d::ui::PageView::EventType type); + +protected: + + cocos2d::ui::Text* _displayValueLabel; +}; + #endif /* defined(__TestCpp__UIPageViewTest__) */ From 4d89508377d5c412e0e0a692dd35b119cc7f5921 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 14 Dec 2015 17:38:52 +0800 Subject: [PATCH 26/66] update for controlButton size --- .../GUI/CCControlExtension/CCControlButton.cpp | 16 ++++++++++++---- .../GUI/CCControlExtension/CCControlButton.h | 7 ++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index 94035a91a4..99e371183a 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -120,6 +120,14 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, ui::Scale9Sprit } } +ControlButton* ControlButton::create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite) +{ + ControlButton *pRet = new (std::nothrow) ControlButton(); + pRet->initWithLabelAndBackgroundSprite(label, backgroundSprite, true); + pRet->autorelease(); + return pRet; +} + ControlButton* ControlButton::create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize) { ControlButton *pRet = new (std::nothrow) ControlButton(); @@ -141,16 +149,16 @@ ControlButton* ControlButton::create(const std::string& title, const std::string return pRet; } -bool ControlButton::initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite, bool adjustBackGroundSize) +bool ControlButton::initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite) { Label *label = Label::createWithSystemFont("", "Arial", 30);// - return initWithLabelAndBackgroundSprite(label, sprite,adjustBackGroundSize); + return initWithLabelAndBackgroundSprite(label, sprite,false); } -ControlButton* ControlButton::create(cocos2d::ui::Scale9Sprite* sprite, bool adjustBackGroundSize) +ControlButton* ControlButton::create(cocos2d::ui::Scale9Sprite* sprite) { ControlButton *pRet = new (std::nothrow) ControlButton(); - pRet->initWithBackgroundSprite(sprite,adjustBackGroundSize); + pRet->initWithBackgroundSprite(sprite); pRet->autorelease(); return pRet; } diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index 279ccce292..4f0abd14e6 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -55,9 +55,10 @@ class CC_EX_DLL ControlButton : public Control { public: static ControlButton* create(); - static ControlButton* create(cocos2d::ui::Scale9Sprite* sprite, bool adjustBackGroundSize = true); - static ControlButton* create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize = true); + static ControlButton* create(cocos2d::ui::Scale9Sprite* sprite); + static ControlButton* create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite); static ControlButton* create(const std::string& title, const std::string& fontName, float fontSize); + static ControlButton* create(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize); virtual void needsLayout(void) override; @@ -203,7 +204,7 @@ CC_CONSTRUCTOR_ACCESS: virtual bool init() override; virtual bool initWithLabelAndBackgroundSprite(Node* label, cocos2d::ui::Scale9Sprite* backgroundSprite, bool adjustBackGroundSize); - virtual bool initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite, bool adjustBackGroundSize); + virtual bool initWithBackgroundSprite(cocos2d::ui::Scale9Sprite* sprite); virtual bool initWithTitleAndFontNameAndFontSize(const std::string& title, const std::string& fontName, float fontSize); protected: From 46b926a18ea6bf0240c3ff08831d1ce07eeeb9a1 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Mon, 14 Dec 2015 14:55:33 -0800 Subject: [PATCH 27/66] added missing _USRJSSTATIC preprocessor define for ARM builds --- .../libjscocos2d.Windows/libjscocos2d.Windows.vcxproj | 6 +++--- .../libjscocos2d.WindowsPhone.vcxproj | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj index b5980b36de..df4c4ab6dc 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.Windows/libjscocos2d.Windows.vcxproj @@ -129,7 +129,7 @@ $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\navmesh;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;_USRJSSTATIC;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_USRJSSTATIC;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true ProgramDatabase @@ -172,7 +172,7 @@ $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\navmesh;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_USRJSSTATIC;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true ProgramDatabase @@ -193,7 +193,7 @@ $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manua\navmesh;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_USRJSSTATIC;%(PreprocessorDefinitions) false ProgramDatabase diff --git a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj index ec659e8365..9449b37008 100644 --- a/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj +++ b/cocos/scripting/js-bindings/proj.win8.1-universal/libjscocos2d/libjscocos2d.WindowsPhone/libjscocos2d.WindowsPhone.vcxproj @@ -94,7 +94,7 @@ $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(ProjectDir)..\..\..\manual\navmesh;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;_USRJSSTATIC;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_USRJSSTATIC;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true ProgramDatabase @@ -137,7 +137,7 @@ $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\spine;$(ProjectDir)..\..\..\manual\navmesh;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_USRJSSTATIC;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true ProgramDatabase @@ -158,7 +158,7 @@ $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support;$(EngineRoot)extensions;$(EngineRoot)external\spidermonkey\include\winrt_8.1;$(ProjectDir)..\..\..\auto;$(ProjectDir)..\..\..\manual;$(ProjectDir)..\..\..\manual\cocostudio;$(ProjectDir)..\..\..\manual\navmesh;$(ProjectDir)..\..\..\manual\spine;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4800;4703;4101;4083;4700;4068;4996;%(DisableSpecificWarnings) Level3 - CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + CC_ENABLE_CHIPMUNK_INTEGRATION=1;_USRJSSTATIC;%(PreprocessorDefinitions) false ProgramDatabase From f417f2ac2dcfb6c2bea24feaf6d50de2e104f0c3 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 15 Dec 2015 10:44:18 +0800 Subject: [PATCH 28/66] Auto generate bindings for v3.10 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1bccfbf9d6..c83427e85b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,4 +37,4 @@ before_install: # whitelist branches: only: - - v3 + - v3.10 From 64276bd664d43197b870307c71160aded55b5524 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 15 Dec 2015 11:48:44 +0800 Subject: [PATCH 29/66] Fix ComponentJS proxy management issue in JSB --- .../js-bindings/manual/cocos2d_specifics.cpp | 39 +++++++++++++++++++ .../manual/component/CCComponentJS.cpp | 32 +++++++++------ .../js-bindings/script/jsb_cocos2d.js | 9 +++-- tools/tojs/cocos2dx.ini | 6 +-- 4 files changed, 67 insertions(+), 19 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 025b0ed24f..4b46a0f9e5 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -5770,6 +5770,41 @@ void js_register_cocos2dx_AutoPolygon(JSContext *cx, JS::HandleObject global) { jsb_register_class(cx, jsb_cocos2d_AutoPolygon_class, proto, JS::NullPtr()); } +// ComponentJS controls the native js proxy itself, must be bound manually +bool js_cocos2dx_ComponentJS_create(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentJS_create : Error processing arguments"); + + auto ret = cocos2d::ComponentJS::create(arg0); + JS::RootedObject jsret(cx, static_cast(ret->getScriptObject())); + args.rval().set(OBJECT_TO_JSVAL(jsret)); + return true; + } + JS_ReportError(cx, "js_cocos2dx_ComponentJS_create : wrong number of arguments"); + return false; +} +static bool js_cocos2dx_ComponentJS_ctor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + bool ok = true; + std::string arg0; + ok &= jsval_to_std_string(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2d_ComponentJS_ctor : Error processing arguments"); + cocos2d::ComponentJS *nobj = new (std::nothrow) cocos2d::ComponentJS(arg0); + // autorelease it + nobj->autorelease(); + bool isFound = false; + if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) + ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); + args.rval().setUndefined(); + return true; +} bool js_cocos2dx_ComponentJS_getScriptObject(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -6034,8 +6069,12 @@ void register_cocos2dx_js_core(JSContext* cx, JS::HandleObject global) tmpObj.set(jsb_cocos2d_ClippingNode_prototype); JS_DefineFunction(cx, tmpObj, "init", js_cocos2dx_ClippingNode_init, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_GetProperty(cx, ccObj, "ComponentJS", &tmpVal); + tmpObj = tmpVal.toObjectOrNull(); + JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_ComponentJS_create, 1, JSPROP_READONLY | JSPROP_PERMANENT); tmpObj.set(jsb_cocos2d_ComponentJS_prototype); JS_DefineFunction(cx, tmpObj, "getScriptObject", js_cocos2dx_ComponentJS_getScriptObject, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, tmpObj, "ctor", js_cocos2dx_ComponentJS_ctor, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, ccObj, "glEnableVertexAttribs", js_cocos2dx_ccGLEnableVertexAttribs, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, ccObj, "pAdd", js_cocos2dx_ccpAdd, 1, JSPROP_READONLY | JSPROP_PERMANENT); diff --git a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp index 3e76c6d114..1f3ef212ad 100644 --- a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp +++ b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp @@ -66,25 +66,15 @@ ComponentJS::ComponentJS(const std::string& scriptFileName) JS::RootedValue protoValue(cx); JS_GetProperty(cx, classObj, "prototype", &protoValue); - TypeTest t; - js_type_class_t *typeClass = nullptr; - std::string typeName = t.s_name(); - auto typeMapIter = _js_global_type_map.find(typeName); - CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); - typeClass = typeMapIter->second; - mozilla::Maybe *jsObj = new mozilla::Maybe(); + js_type_class_t *typeClass = js_get_type_from_native(this); JS::RootedObject proto(cx, protoValue.toObjectOrNull()); JS::RootedObject parent(cx, typeClass->proto.ref()); jsObj->construct(cx); JS::RootedObject obj(cx, JS_NewObject(cx, theClass, proto, parent)); jsObj->ref() = obj; - // Unbind current proxy binding - js_proxy_t* jsproxy = js_get_or_create_proxy(cx, this); - JS::RemoveObjectRoot(cx, &jsproxy->obj); - jsb_remove_proxy(jsb_get_native_proxy(this), jsproxy); // link the native object with the javascript object jsb_new_proxy(this, jsObj->ref()); @@ -95,6 +85,17 @@ ComponentJS::ComponentJS(const std::string& scriptFileName) ComponentJS::~ComponentJS() { mozilla::Maybe* jsObj = static_cast*>(_jsObj); + if (jsObj && !jsObj->empty()) + { + // Remove proxy + js_proxy_t* jsproxy = jsb_get_js_proxy(jsObj->ref()); + if (jsproxy) + { + js_proxy_t* nproxy = jsb_get_native_proxy(jsproxy->ptr); + jsb_remove_proxy(nproxy, jsproxy); + } + } + // Delete rooted object if (jsObj != nullptr) { delete jsObj; @@ -104,7 +105,14 @@ ComponentJS::~ComponentJS() void* ComponentJS::getScriptObject() const { mozilla::Maybe* jsObj = static_cast*>(_jsObj); - return jsObj->ref().get(); + if (jsObj && !jsObj->empty()) + { + return jsObj->ref().get(); + } + else + { + return nullptr; + } } void ComponentJS::update(float delta) diff --git a/cocos/scripting/js-bindings/script/jsb_cocos2d.js b/cocos/scripting/js-bindings/script/jsb_cocos2d.js index 6c0cb46b1f..7ff747fd61 100644 --- a/cocos/scripting/js-bindings/script/jsb_cocos2d.js +++ b/cocos/scripting/js-bindings/script/jsb_cocos2d.js @@ -2771,29 +2771,30 @@ cc.GLProgram.prototype.setUniformLocationWithMatrix2fv = function(){ var tempArray = Array.prototype.slice.call(arguments); tempArray = Array.prototype.concat.call(tempArray, 2); this.setUniformLocationWithMatrixfvUnion.apply(this, tempArray); -} +}; cc.GLProgram.prototype.setUniformLocationWithMatrix3fv = function(){ var tempArray = Array.prototype.slice.call(arguments); tempArray = Array.prototype.concat.call(tempArray, 3); this.setUniformLocationWithMatrixfvUnion.apply(this, tempArray); -} +}; cc.GLProgram.prototype.setUniformLocationWithMatrix4fv = function(){ var tempArray = Array.prototype.slice.call(arguments); tempArray = Array.prototype.concat.call(tempArray, 4); this.setUniformLocationWithMatrixfvUnion.apply(this, tempArray); -} +}; // // Script Component // cc._ComponentJS = cc.ComponentJS; +cc._ComponentJS.extend = cc.Class.extend; cc.ComponentJS = function (filename) { var comp = cc._ComponentJS.create(filename); var res = comp.getScriptObject(); return res; -} +}; cc.ComponentJS.extend = function (prop) { return cc._ComponentJS.extend(prop); }; diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 411003cd71..05a6f77104 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -31,7 +31,7 @@ replace_headers = CCComponentJS.h::component/CCComponentJS.h classes = New.* Sprite SpriteBatchNode SpriteFrame SpriteFrameCache Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc CallFuncN RenderTexture GridAction Grid3DAction Grid3D TiledGrid3D GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Lens3D Ripple3D PageTurn3D ShakyTiles3D ShatteredTiles3D WavesTiles3D JumpTiles3D Speed ActionManager Set SimpleAudioEngine Scheduler Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram GLProgramCache Application ClippingNode MotionStreak TextFieldTTF GLViewProtocol GLView Component ComponentContainer __NodeRGBA __LayerRGBA SAXParser Event(?!.*(Physics).*).* Device Configuration ProtectedNode GLProgramState Image .*Light$ AsyncTaskPool Properties Material Technique RenderState Pass ComponentJS -classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame Menu MenuItem.* Scene DrawNode Component .*Action.* GridBase Grid3D TiledGrid3D MotionStreak ParticleBatchNode ParticleSystem TextFieldTTF RenderTexture TileMapAtlas TMXLayer TMXTiledMap TMXMapInfo TransitionScene ProgressTimer ParallaxNode Label.* GLProgram Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* Orbit.* Follow.* Bezier.* Hide CallFunc CallFuncN ComponentJS +classes_need_extend = Node __NodeRGBA Layer.* Sprite SpriteBatchNode SpriteFrame Menu MenuItem.* Scene DrawNode Component .*Action.* GridBase Grid3D TiledGrid3D MotionStreak ParticleBatchNode ParticleSystem TextFieldTTF RenderTexture TileMapAtlas TMXLayer TMXTiledMap TMXMapInfo TransitionScene ProgressTimer ParallaxNode Label.* GLProgram Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn ReverseTime Animate AnimationFrame Animation AnimationCache Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* Orbit.* Follow.* Bezier.* Hide CallFunc CallFuncN # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -140,7 +140,7 @@ skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserDat Camera::[unproject isVisibleInFrustum], ClippingNode::[init], RenderState::[setStateBlock], - ComponentJS::[getScriptObject update] + ComponentJS::[create getScriptObject update] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], @@ -186,7 +186,7 @@ base_classes_to_skip = Ref Clonable # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application GLViewProtocol GLView ComponentContainer SAXParser Configuration EventListener BaseLight AsyncTaskPool +abstract_classes = Action FiniteTimeAction ActionInterval ActionEase EaseRateAction EaseElastic EaseBounce ActionInstant GridAction Grid3DAction TiledGrid3DAction Director SpriteFrameCache TransitionEaseScene Set SimpleAudioEngine FileUtils Application GLViewProtocol GLView ComponentContainer SAXParser Configuration EventListener BaseLight AsyncTaskPool ComponentJS # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = no From 6d58fc05d972ea72a76273bfc42f2b4a0efea4f6 Mon Sep 17 00:00:00 2001 From: Ce Zheng Date: Tue, 15 Dec 2015 13:16:24 +0900 Subject: [PATCH 30/66] Fix Downloader callback bug on iOS9 On iOS 9 when server returns a response with HTTP status 403 caused the downloader to callback successfully and saving the error message to the storage path. This commit adds a check on the HTTP status code and do failure callback if status code is 4xx or 5xx. --- cocos/network/CCDownloader-apple.mm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cocos/network/CCDownloader-apple.mm b/cocos/network/CCDownloader-apple.mm index 40aa2b06aa..04676f9de4 100644 --- a/cocos/network/CCDownloader-apple.mm +++ b/cocos/network/CCDownloader-apple.mm @@ -515,7 +515,18 @@ namespace cocos2d { namespace network { NSString *destPath = [NSString stringWithUTF8String:storagePath]; NSFileManager *fileManager = [NSFileManager defaultManager]; NSURL *destURL = nil; - + + // On iOS 9 a response with status code 4xx(Client Error) or 5xx(Server Error) + // might end up calling this delegate method, saving the error message to the storage path + // and treating this download task as a successful one, so we need to check the status code here + NSInteger statusCode = ((NSHTTPURLResponse*)downloadTask.response).statusCode; + if (statusCode >= 400) { + std::vector buf; // just a placeholder + std::string response = [[NSString stringWithContentsOfURL:location] UTF8String] ?: ""; + _outer->onTaskFinish(*[wrapper get], cocos2d::network::DownloadTask::ERROR_IMPL_INTERNAL, noErr, response, buf); + return; + } + do { if ([destPath hasPrefix:@"file://"]) From 8cb2ec6187d8159c7147c0559fc95c69cc455205 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 15 Dec 2015 04:31:50 +0000 Subject: [PATCH 31/66] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_auto_api.js | 105 +++-- .../api/jsb_cocos2dx_extension_auto_api.js | 18 +- .../auto/api/jsb_cocos2dx_ui_auto_api.js | 70 ++++ .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 220 +++++++---- .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 13 +- .../auto/jsb_cocos2dx_extension_auto.cpp | 49 ++- .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 133 +++++++ .../js-bindings/auto/jsb_cocos2dx_ui_auto.hpp | 7 + .../lua-bindings/auto/api/ControlButton.lua | 8 +- .../scripting/lua-bindings/auto/api/Label.lua | 56 ++- .../lua-bindings/auto/api/Scale9Sprite.lua | 9 + .../scripting/lua-bindings/auto/api/Text.lua | 42 ++ .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 366 +++++++++++++++++- .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 7 + .../auto/lua_cocos2dx_extension_auto.cpp | 28 +- .../auto/lua_cocos2dx_ui_auto.cpp | 336 ++++++++++++++++ .../auto/lua_cocos2dx_ui_auto.hpp | 7 + 17 files changed, 1327 insertions(+), 147 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 626f1990b7..6714bd3924 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -12011,6 +12011,16 @@ float { }, +/** + * @method getWidth + * @return {float} + */ +getWidth : function ( +) +{ + return 0; +}, + /** * @method getString * @return {String} @@ -12081,6 +12091,16 @@ float { }, +/** + * @method getAdditionalKerning + * @return {float} + */ +getAdditionalKerning : function ( +) +{ + return 0; +}, + /** * @method getBMFontSize * @return {float} @@ -12111,6 +12131,16 @@ getHorizontalAlignment : function ( return 0; }, +/** + * @method getShadowOffset + * @return {size_object} + */ +getShadowOffset : function ( +) +{ + return cc.Size; +}, + /** * @method setClipMarginEnabled * @param {bool} arg0 @@ -12141,6 +12171,16 @@ str { }, +/** + * @method getOutlineSize + * @return {int} + */ +getOutlineSize : function ( +) +{ + return 0; +}, + /** * @method setBMFontFilePath * @param {String} arg0 @@ -12270,15 +12310,25 @@ int }, /** - * @method getAdditionalKerning + * @method getShadowBlurRadius * @return {float} */ -getAdditionalKerning : function ( +getShadowBlurRadius : function ( ) { return 0; }, +/** + * @method getEffectColor + * @return {color4f_object} + */ +getEffectColor : function ( +) +{ + return cc.Color4F; +}, + /** * @method removeAllChildrenWithCleanup * @param {bool} arg0 @@ -12367,6 +12417,16 @@ getLineHeight : function ( return 0; }, +/** + * @method getShadowColor + * @return {color4f_object} + */ +getShadowColor : function ( +) +{ + return cc.Color4F; +}, + /** * @method getTTFConfig * @return {cc._ttfConfig} @@ -12420,13 +12480,13 @@ float }, /** - * @method getWidth - * @return {float} + * @method isShadowEnabled + * @return {bool} */ -getWidth : function ( +isShadowEnabled : function ( ) { - return 0; + return false; }, /** @@ -12519,6 +12579,16 @@ isWrapEnabled : function ( return false; }, +/** + * @method getLabelEffectType + * @return {cc.LabelEffect} + */ +getLabelEffectType : function ( +) +{ + return 0; +}, + /** * @method setAlignment * @param {cc.TextHAlignment|cc.TextHAlignment} texthalignment @@ -23463,27 +23533,4 @@ getInstance : function ( */ cc.ComponentJS = { -/** - * @method create - * @param {String} arg0 - * @return {cc.ComponentJS} - */ -create : function ( -str -) -{ - return cc.ComponentJS; -}, - -/** - * @method ComponentJS - * @constructor - * @param {String} arg0 - */ -ComponentJS : function ( -str -) -{ -}, - }; diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_extension_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_extension_auto_api.js index 89a1e3796d..1f7b45a4a4 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_extension_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_extension_auto_api.js @@ -548,11 +548,13 @@ getCurrentTitle : function( * @method initWithLabelAndBackgroundSprite * @param {cc.Node} arg0 * @param {ccui.Scale9Sprite} arg1 + * @param {bool} arg2 * @return {bool} */ initWithLabelAndBackgroundSprite : function ( node, -scale9sprite +scale9sprite, +bool ) { return false; @@ -582,15 +584,15 @@ state /** * @method create -* @param {ccui.Scale9Sprite|cc.Node|String} scale9sprite -* @param {ccui.Scale9Sprite|String} scale9sprite -* @param {float} float -* @return {cc.ControlButton|cc.ControlButton|cc.ControlButton|cc.ControlButton} +* @param {ccui.Scale9Sprite|cc.Node|String|cc.Node} scale9sprite +* @param {ccui.Scale9Sprite|String|ccui.Scale9Sprite} scale9sprite +* @param {float|bool} float +* @return {cc.ControlButton|cc.ControlButton|cc.ControlButton|cc.ControlButton|cc.ControlButton} */ create : function( -str, -str, -float +node, +scale9sprite, +bool ) { return cc.ControlButton; diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js index 52354effc2..bdbe144255 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -2383,6 +2383,16 @@ labeleffect { }, +/** + * @method getLabelEffectType + * @return {cc.LabelEffect} + */ +getLabelEffectType : function ( +) +{ + return 0; +}, + /** * @method getTextColor * @return {color4b_object} @@ -2423,6 +2433,16 @@ bool { }, +/** + * @method getShadowOffset + * @return {size_object} + */ +getShadowOffset : function ( +) +{ + return cc.Size; +}, + /** * @method setString * @param {String} arg0 @@ -2433,6 +2453,16 @@ str { }, +/** + * @method getOutlineSize + * @return {int} + */ +getOutlineSize : function ( +) +{ + return 0; +}, + /** * @method init * @param {String} arg0 @@ -2449,6 +2479,16 @@ float return false; }, +/** + * @method getShadowBlurRadius + * @return {float} + */ +getShadowBlurRadius : function ( +) +{ + return 0; +}, + /** * @method isTouchScaleChangeEnabled * @return {bool} @@ -2511,6 +2551,16 @@ int { }, +/** + * @method getEffectColor + * @return {color4b_object} + */ +getEffectColor : function ( +) +{ + return cc.Color4B; +}, + /** * @method getType * @return {ccui.Text::Type} @@ -2531,6 +2581,16 @@ getTextHorizontalAlignment : function ( return 0; }, +/** + * @method isShadowEnabled + * @return {bool} + */ +isShadowEnabled : function ( +) +{ + return false; +}, + /** * @method setFontSize * @param {float} arg0 @@ -2541,6 +2601,16 @@ float { }, +/** + * @method getShadowColor + * @return {color4b_object} + */ +getShadowColor : function ( +) +{ + return cc.Color4B; +}, + /** * @method setTextColor * @param {color4b_object} arg0 diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 12771ed9b7..b05b3690ec 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -32872,6 +32872,24 @@ bool js_cocos2dx_Label_setDimensions(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_setDimensions : wrong number of arguments: %d, was expecting %d", argc, 2); return false; } +bool js_cocos2dx_Label_getWidth(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getWidth : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getWidth(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getWidth : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Label_getString(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -33017,6 +33035,24 @@ bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_setWidth : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Label_getAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getAdditionalKerning : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getAdditionalKerning(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getAdditionalKerning : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Label_getBMFontSize(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -33071,6 +33107,24 @@ bool js_cocos2dx_Label_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsva JS_ReportError(cx, "js_cocos2dx_Label_getHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Label_getShadowOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getShadowOffset : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getShadowOffset(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getShadowOffset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Label_setClipMarginEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -33131,6 +33185,24 @@ bool js_cocos2dx_Label_setSystemFontName(JSContext *cx, uint32_t argc, jsval *vp JS_ReportError(cx, "js_cocos2dx_Label_setSystemFontName : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_Label_getOutlineSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getOutlineSize : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getOutlineSize(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getOutlineSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Label_setBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -33527,22 +33599,40 @@ bool js_cocos2dx_Label_enableOutline(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_enableOutline : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Label_getAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Label_getShadowBlurRadius(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getAdditionalKerning : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getShadowBlurRadius : Invalid Native Object"); if (argc == 0) { - double ret = cobj->getAdditionalKerning(); + double ret = cobj->getShadowBlurRadius(); jsval jsret = JSVAL_NULL; jsret = DOUBLE_TO_JSVAL(ret); args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_Label_getAdditionalKerning : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_Label_getShadowBlurRadius : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} +bool js_cocos2dx_Label_getEffectColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getEffectColor : Invalid Native Object"); + if (argc == 0) { + cocos2d::Color4F ret = cobj->getEffectColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4f_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getEffectColor : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_Label_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp) @@ -33758,6 +33848,24 @@ bool js_cocos2dx_Label_getLineHeight(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_getLineHeight : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Label_getShadowColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getShadowColor : Invalid Native Object"); + if (argc == 0) { + cocos2d::Color4F ret = cobj->getShadowColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4f_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getShadowColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Label_getTTFConfig(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -33860,22 +33968,22 @@ bool js_cocos2dx_Label_setHeight(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_setHeight : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_Label_getWidth(JSContext *cx, uint32_t argc, jsval *vp) +bool js_cocos2dx_Label_isShadowEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getWidth : Invalid Native Object"); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_isShadowEnabled : Invalid Native Object"); if (argc == 0) { - double ret = cobj->getWidth(); + bool ret = cobj->isShadowEnabled(); jsval jsret = JSVAL_NULL; - jsret = DOUBLE_TO_JSVAL(ret); + jsret = BOOLEAN_TO_JSVAL(ret); args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_Label_getWidth : wrong number of arguments: %d, was expecting %d", argc, 0); + JS_ReportError(cx, "js_cocos2dx_Label_isShadowEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } bool js_cocos2dx_Label_enableGlow(JSContext *cx, uint32_t argc, jsval *vp) @@ -34048,6 +34156,24 @@ bool js_cocos2dx_Label_isWrapEnabled(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_Label_isWrapEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_Label_getLabelEffectType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::Label* cobj = (cocos2d::Label *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Label_getLabelEffectType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getLabelEffectType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_Label_getLabelEffectType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp) { bool ok = true; @@ -34429,6 +34555,7 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("isClipMarginEnabled", js_cocos2dx_Label_isClipMarginEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("enableShadow", js_cocos2dx_Label_enableShadow, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setDimensions", js_cocos2dx_Label_setDimensions, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getWidth", js_cocos2dx_Label_getWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getString", js_cocos2dx_Label_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getHeight", js_cocos2dx_Label_getHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("disableEffect", js_cocos2dx_Label_disableEffect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -34436,12 +34563,15 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("getBlendFunc", js_cocos2dx_Label_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("enableWrap", js_cocos2dx_Label_enableWrap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setWidth", js_cocos2dx_Label_setWidth, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAdditionalKerning", js_cocos2dx_Label_getAdditionalKerning, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBMFontSize", js_cocos2dx_Label_getBMFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaxLineWidth", js_cocos2dx_Label_getMaxLineWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getHorizontalAlignment", js_cocos2dx_Label_getHorizontalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getShadowOffset", js_cocos2dx_Label_getShadowOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setClipMarginEnabled", js_cocos2dx_Label_setClipMarginEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setString", js_cocos2dx_Label_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSystemFontName", js_cocos2dx_Label_setSystemFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOutlineSize", js_cocos2dx_Label_getOutlineSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBMFontFilePath", js_cocos2dx_Label_setBMFontFilePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithTTF", js_cocos2dx_Label_initWithTTF, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLineHeight", js_cocos2dx_Label_setLineHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -34453,7 +34583,8 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("setLineBreakWithoutSpace", js_cocos2dx_Label_setLineBreakWithoutSpace, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringNumLines", js_cocos2dx_Label_getStringNumLines, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("enableOutline", js_cocos2dx_Label_enableOutline, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getAdditionalKerning", js_cocos2dx_Label_getAdditionalKerning, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getShadowBlurRadius", js_cocos2dx_Label_getShadowBlurRadius, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEffectColor", js_cocos2dx_Label_getEffectColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeAllChildrenWithCleanup", js_cocos2dx_Label_removeAllChildrenWithCleanup, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCharMap", js_cocos2dx_Label_setCharMap, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getDimensions", js_cocos2dx_Label_getDimensions, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -34462,12 +34593,13 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("setVerticalAlignment", js_cocos2dx_Label_setVerticalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setLineSpacing", js_cocos2dx_Label_setLineSpacing, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLineHeight", js_cocos2dx_Label_getLineHeight, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getShadowColor", js_cocos2dx_Label_getShadowColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTTFConfig", js_cocos2dx_Label_getTTFConfig, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVerticalAlignment", js_cocos2dx_Label_getVerticalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextColor", js_cocos2dx_Label_setTextColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getLetter", js_cocos2dx_Label_getLetter, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHeight", js_cocos2dx_Label_setHeight, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getWidth", js_cocos2dx_Label_getWidth, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isShadowEnabled", js_cocos2dx_Label_isShadowEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("enableGlow", js_cocos2dx_Label_enableGlow, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getOverflow", js_cocos2dx_Label_getOverflow, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAdditionalKerning", js_cocos2dx_Label_setAdditionalKerning, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -34477,6 +34609,7 @@ void js_register_cocos2dx_Label(JSContext *cx, JS::HandleObject global) { JS_FN("getBMFontFilePath", js_cocos2dx_Label_getBMFontFilePath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setHorizontalAlignment", js_cocos2dx_Label_setHorizontalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isWrapEnabled", js_cocos2dx_Label_isWrapEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLabelEffectType", js_cocos2dx_Label_getLabelEffectType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAlignment", js_cocos2dx_Label_setAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("requestSystemFontRefresh", js_cocos2dx_Label_requestSystemFontRefresh, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setBMFontSize", js_cocos2dx_Label_setBMFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -63472,65 +63605,9 @@ void js_register_cocos2dx_SimpleAudioEngine(JSContext *cx, JS::HandleObject glob JSClass *jsb_cocos2d_ComponentJS_class; JSObject *jsb_cocos2d_ComponentJS_prototype; -bool js_cocos2dx_ComponentJS_create(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentJS_create : Error processing arguments"); - - auto ret = cocos2d::ComponentJS::create(arg0); - js_type_class_t *typeClass = js_get_type_from_native(ret); - JS::RootedObject jsret(cx, jsb_ref_autoreleased_create_jsobject(cx, ret, typeClass, "cocos2d::ComponentJS")); - args.rval().set(OBJECT_TO_JSVAL(jsret)); - return true; - } - JS_ReportError(cx, "js_cocos2dx_ComponentJS_create : wrong number of arguments"); - return false; -} - -bool js_cocos2dx_ComponentJS_constructor(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ComponentJS_constructor : Error processing arguments"); - cocos2d::ComponentJS* cobj = new (std::nothrow) cocos2d::ComponentJS(arg0); - - js_type_class_t *typeClass = js_get_type_from_native(cobj); - - // link the native object with the javascript object - JS::RootedObject jsobj(cx, jsb_ref_create_jsobject(cx, cobj, typeClass, "cocos2d::ComponentJS")); - args.rval().set(OBJECT_TO_JSVAL(jsobj)); - if (JS_HasProperty(cx, jsobj, "_ctor", &ok) && ok) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(jsobj), "_ctor", args); - return true; -} -static bool js_cocos2dx_ComponentJS_ctor(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - bool ok = true; - std::string arg0; - ok &= jsval_to_std_string(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2d_ComponentJS_ctor : Error processing arguments"); - cocos2d::ComponentJS *nobj = new (std::nothrow) cocos2d::ComponentJS(arg0); - auto newproxy = jsb_new_proxy(nobj, obj); - jsb_ref_init(cx, &newproxy->obj, nobj, "cocos2d::ComponentJS"); - bool isFound = false; - if (JS_HasProperty(cx, obj, "_ctor", &isFound) && isFound) - ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), "_ctor", args); - args.rval().setUndefined(); - return true; -} - extern JSObject *jsb_cocos2d_Component_prototype; - void js_register_cocos2dx_ComponentJS(JSContext *cx, JS::HandleObject global) { jsb_cocos2d_ComponentJS_class = (JSClass *)calloc(1, sizeof(JSClass)); jsb_cocos2d_ComponentJS_class->name = "ComponentJS"; @@ -63550,21 +63627,17 @@ void js_register_cocos2dx_ComponentJS(JSContext *cx, JS::HandleObject global) { }; static JSFunctionSpec funcs[] = { - JS_FN("ctor", js_cocos2dx_ComponentJS_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; - static JSFunctionSpec st_funcs[] = { - JS_FN("create", js_cocos2dx_ComponentJS_create, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FS_END - }; + JSFunctionSpec *st_funcs = NULL; JS::RootedObject parent_proto(cx, jsb_cocos2d_Component_prototype); jsb_cocos2d_ComponentJS_prototype = JS_InitClass( cx, global, parent_proto, jsb_cocos2d_ComponentJS_class, - js_cocos2dx_ComponentJS_constructor, 0, // constructor + empty_constructor, 0, properties, funcs, NULL, // no static properties @@ -63573,7 +63646,6 @@ void js_register_cocos2dx_ComponentJS(JSContext *cx, JS::HandleObject global) { // add the proto and JSClass to the type->js info hash table JS::RootedObject proto(cx, jsb_cocos2d_ComponentJS_prototype); jsb_register_class(cx, jsb_cocos2d_ComponentJS_class, proto, parent_proto); - anonEvaluate(cx, global, "(function () { cc.ComponentJS.extend = cc.Class.extend; })()"); } void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj) { diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index fb22303582..974408bf64 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -2225,6 +2225,7 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); bool js_cocos2dx_Label_isClipMarginEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_enableShadow(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setDimensions(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getWidth(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getString(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getHeight(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_disableEffect(JSContext *cx, uint32_t argc, jsval *vp); @@ -2232,12 +2233,15 @@ bool js_cocos2dx_Label_getTextColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_enableWrap(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getBMFontSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getMaxLineWidth(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getShadowOffset(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setClipMarginEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setString(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setSystemFontName(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getOutlineSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_initWithTTF(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setLineHeight(JSContext *cx, uint32_t argc, jsval *vp); @@ -2249,7 +2253,8 @@ bool js_cocos2dx_Label_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setLineBreakWithoutSpace(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getStringNumLines(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_enableOutline(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Label_getAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getShadowBlurRadius(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getEffectColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setCharMap(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getDimensions(JSContext *cx, uint32_t argc, jsval *vp); @@ -2258,12 +2263,13 @@ bool js_cocos2dx_Label_getSystemFontName(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_Label_setVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setLineSpacing(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getLineHeight(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getShadowColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getTTFConfig(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setTextColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getLetter(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setHeight(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Label_getWidth(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_isShadowEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_enableGlow(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_getOverflow(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setAdditionalKerning(JSContext *cx, uint32_t argc, jsval *vp); @@ -2273,6 +2279,7 @@ bool js_cocos2dx_Label_getTextAlignment(JSContext *cx, uint32_t argc, jsval *vp) bool js_cocos2dx_Label_getBMFontFilePath(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_isWrapEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_Label_getLabelEffectType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_requestSystemFontRefresh(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Label_setBMFontSize(JSContext *cx, uint32_t argc, jsval *vp); @@ -4100,7 +4107,5 @@ bool js_cocos2dx_ComponentJS_constructor(JSContext *cx, uint32_t argc, jsval *vp void js_cocos2dx_ComponentJS_finalize(JSContext *cx, JSObject *obj); void js_register_cocos2dx_ComponentJS(JSContext *cx, JS::HandleObject global); void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj); -bool js_cocos2dx_ComponentJS_create(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ComponentJS_ComponentJS(JSContext *cx, uint32_t argc, jsval *vp); #endif // __cocos2dx_h__ diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp index 33d47b4825..4ebbd486b9 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp @@ -1164,9 +1164,10 @@ bool js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite(JSCont js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::extension::ControlButton* cobj = (cocos2d::extension::ControlButton *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite : Invalid Native Object"); - if (argc == 2) { + if (argc == 3) { cocos2d::Node* arg0 = nullptr; cocos2d::ui::Scale9Sprite* arg1 = nullptr; + bool arg2; do { if (args.get(0).isNull()) { arg0 = nullptr; break; } if (!args.get(0).isObject()) { ok = false; break; } @@ -1185,15 +1186,16 @@ bool js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite(JSCont arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); } while (0); + arg2 = JS::ToBoolean(args.get(2)); JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite : Error processing arguments"); - bool ret = cobj->initWithLabelAndBackgroundSprite(arg0, arg1); + bool ret = cobj->initWithLabelAndBackgroundSprite(arg0, arg1, arg2); jsval jsret = JSVAL_NULL; jsret = BOOLEAN_TO_JSVAL(ret); args.rval().set(jsret); return true; } - JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 2); + JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite : wrong number of arguments: %d, was expecting %d", argc, 3); return false; } bool js_cocos2dx_extension_ControlButton_getZoomOnTouchDown(JSContext *cx, uint32_t argc, jsval *vp) @@ -1338,6 +1340,45 @@ bool js_cocos2dx_extension_ControlButton_create(JSContext *cx, uint32_t argc, js return true; } } while (0); + + do { + if (argc == 3) { + cocos2d::Node* arg0 = nullptr; + do { + if (args.get(0).isNull()) { arg0 = nullptr; break; } + if (!args.get(0).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JS::RootedObject tmpObj(cx, args.get(0).toObjectOrNull()); + jsProxy = jsb_get_js_proxy(tmpObj); + arg0 = (cocos2d::Node*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + cocos2d::ui::Scale9Sprite* arg1 = nullptr; + do { + if (args.get(1).isNull()) { arg1 = nullptr; break; } + if (!args.get(1).isObject()) { ok = false; break; } + js_proxy_t *jsProxy; + JS::RootedObject tmpObj(cx, args.get(1).toObjectOrNull()); + jsProxy = jsb_get_js_proxy(tmpObj); + arg1 = (cocos2d::ui::Scale9Sprite*)(jsProxy ? jsProxy->ptr : NULL); + JSB_PRECONDITION2( arg1, cx, false, "Invalid Native Object"); + } while (0); + if (!ok) { ok = true; break; } + bool arg2; + arg2 = JS::ToBoolean(args.get(2)); + if (!ok) { ok = true; break; } + cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0, arg1, arg2); + jsval jsret = JSVAL_NULL; + if (ret) { + jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject(cx, (cocos2d::extension::ControlButton*)ret)); + } else { + jsret = JSVAL_NULL; + }; + args.rval().set(jsret); + return true; + } + } while (0); JS_ReportError(cx, "js_cocos2dx_extension_ControlButton_create : wrong number of arguments"); return false; } @@ -1428,7 +1469,7 @@ void js_register_cocos2dx_extension_ControlButton(JSContext *cx, JS::HandleObjec JS_FN("getTitleLabelForState", js_cocos2dx_extension_ControlButton_getTitleLabelForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMargins", js_cocos2dx_extension_ControlButton_setMargins, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCurrentTitle", js_cocos2dx_extension_ControlButton_getCurrentTitle, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("initWithLabelAndBackgroundSprite", js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("initWithLabelAndBackgroundSprite", js_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZoomOnTouchDown", js_cocos2dx_extension_ControlButton_getZoomOnTouchDown, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTitleForState", js_cocos2dx_extension_ControlButton_getTitleForState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("ctor", js_cocos2dx_extension_ControlButton_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index 66846bc243..9e37503e96 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -6045,6 +6045,24 @@ bool js_cocos2dx_ui_Text_disableEffect(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Text_disableEffect : wrong number of arguments"); return false; } +bool js_cocos2dx_ui_Text_getLabelEffectType(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getLabelEffectType : Invalid Native Object"); + if (argc == 0) { + int ret = (int)cobj->getLabelEffectType(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getLabelEffectType : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Text_getTextColor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -6123,6 +6141,24 @@ bool js_cocos2dx_ui_Text_setTouchScaleChangeEnabled(JSContext *cx, uint32_t argc JS_ReportError(cx, "js_cocos2dx_ui_Text_setTouchScaleChangeEnabled : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Text_getShadowOffset(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getShadowOffset : Invalid Native Object"); + if (argc == 0) { + cocos2d::Size ret = cobj->getShadowOffset(); + jsval jsret = JSVAL_NULL; + jsret = ccsize_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getShadowOffset : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Text_setString(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -6143,6 +6179,24 @@ bool js_cocos2dx_ui_Text_setString(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Text_setString : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Text_getOutlineSize(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getOutlineSize : Invalid Native Object"); + if (argc == 0) { + int ret = cobj->getOutlineSize(); + jsval jsret = JSVAL_NULL; + jsret = int32_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getOutlineSize : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Text_init(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -6169,6 +6223,24 @@ bool js_cocos2dx_ui_Text_init(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Text_init : wrong number of arguments: %d, was expecting %d", argc, 3); return false; } +bool js_cocos2dx_ui_Text_getShadowBlurRadius(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getShadowBlurRadius : Invalid Native Object"); + if (argc == 0) { + double ret = cobj->getShadowBlurRadius(); + jsval jsret = JSVAL_NULL; + jsret = DOUBLE_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getShadowBlurRadius : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Text_isTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -6291,6 +6363,24 @@ bool js_cocos2dx_ui_Text_enableOutline(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Text_enableOutline : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Text_getEffectColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getEffectColor : Invalid Native Object"); + if (argc == 0) { + cocos2d::Color4B ret = cobj->getEffectColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getEffectColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Text_getType(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -6327,6 +6417,24 @@ bool js_cocos2dx_ui_Text_getTextHorizontalAlignment(JSContext *cx, uint32_t argc JS_ReportError(cx, "js_cocos2dx_ui_Text_getTextHorizontalAlignment : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Text_isShadowEnabled(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_isShadowEnabled : Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isShadowEnabled(); + jsval jsret = JSVAL_NULL; + jsret = BOOLEAN_TO_JSVAL(ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_isShadowEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Text_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -6347,6 +6455,24 @@ bool js_cocos2dx_ui_Text_setFontSize(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Text_setFontSize : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } +bool js_cocos2dx_ui_Text_getShadowColor(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Text* cobj = (cocos2d::ui::Text *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Text_getShadowColor : Invalid Native Object"); + if (argc == 0) { + cocos2d::Color4B ret = cobj->getShadowColor(); + jsval jsret = JSVAL_NULL; + jsret = cccolor4b_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Text_getShadowColor : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Text_setTextColor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -6543,21 +6669,28 @@ void js_register_cocos2dx_ui_Text(JSContext *cx, JS::HandleObject global) { JS_FN("getFontSize", js_cocos2dx_ui_Text_getFontSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getString", js_cocos2dx_ui_Text_getString, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("disableEffect", js_cocos2dx_ui_Text_disableEffect, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getLabelEffectType", js_cocos2dx_ui_Text_getLabelEffectType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextColor", js_cocos2dx_ui_Text_getTextColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextVerticalAlignment", js_cocos2dx_ui_Text_setTextVerticalAlignment, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontName", js_cocos2dx_ui_Text_setFontName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTouchScaleChangeEnabled", js_cocos2dx_ui_Text_setTouchScaleChangeEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getShadowOffset", js_cocos2dx_ui_Text_getShadowOffset, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setString", js_cocos2dx_ui_Text_setString, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getOutlineSize", js_cocos2dx_ui_Text_getOutlineSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("init", js_cocos2dx_ui_Text_init, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getShadowBlurRadius", js_cocos2dx_ui_Text_getShadowBlurRadius, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isTouchScaleChangeEnabled", js_cocos2dx_ui_Text_isTouchScaleChangeEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getFontName", js_cocos2dx_ui_Text_getFontName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextAreaSize", js_cocos2dx_ui_Text_setTextAreaSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getStringLength", js_cocos2dx_ui_Text_getStringLength, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getAutoRenderSize", js_cocos2dx_ui_Text_getAutoRenderSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("enableOutline", js_cocos2dx_ui_Text_enableOutline, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getEffectColor", js_cocos2dx_ui_Text_getEffectColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getType", js_cocos2dx_ui_Text_getType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextHorizontalAlignment", js_cocos2dx_ui_Text_getTextHorizontalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("isShadowEnabled", js_cocos2dx_ui_Text_isShadowEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setFontSize", js_cocos2dx_ui_Text_setFontSize, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getShadowColor", js_cocos2dx_ui_Text_getShadowColor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setTextColor", js_cocos2dx_ui_Text_setTextColor, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("enableGlow", js_cocos2dx_ui_Text_enableGlow, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextVerticalAlignment", js_cocos2dx_ui_Text_getTextVerticalAlignment, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp index 1b9400398c..a2c3cbc627 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -320,21 +320,28 @@ bool js_cocos2dx_ui_Text_enableShadow(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_getFontSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_getString(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_disableEffect(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getLabelEffectType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_getTextColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_setTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_setFontName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_setTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getShadowOffset(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_setString(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getOutlineSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_init(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getShadowBlurRadius(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_isTouchScaleChangeEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_getFontName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_setTextAreaSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_getStringLength(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_getAutoRenderSize(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_enableOutline(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getEffectColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_getType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_getTextHorizontalAlignment(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_isShadowEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_setFontSize(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Text_getShadowColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_setTextColor(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_enableGlow(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Text_getTextVerticalAlignment(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/ControlButton.lua b/cocos/scripting/lua-bindings/auto/api/ControlButton.lua index 9da8d10e83..ae6d5f4d21 100644 --- a/cocos/scripting/lua-bindings/auto/api/ControlButton.lua +++ b/cocos/scripting/lua-bindings/auto/api/ControlButton.lua @@ -286,6 +286,7 @@ -- @param self -- @param #cc.Node label -- @param #ccui.Scale9Sprite backgroundSprite +-- @param #bool adjustBackGroundSize -- @return bool#bool ret (return value: bool) -------------------------------- @@ -309,11 +310,12 @@ -- @overload self -- @overload self, cc.Node, ccui.Scale9Sprite -- @overload self, string, string, float +-- @overload self, cc.Node, ccui.Scale9Sprite, bool -- @function [parent=#ControlButton] create -- @param self --- @param #string title --- @param #string fontName --- @param #float fontSize +-- @param #cc.Node label +-- @param #ccui.Scale9Sprite backgroundSprite +-- @param #bool adjustBackGroundSize -- @return ControlButton#ControlButton ret (return value: cc.ControlButton) -------------------------------- diff --git a/cocos/scripting/lua-bindings/auto/api/Label.lua b/cocos/scripting/lua-bindings/auto/api/Label.lua index 80f5b69439..ce836e927c 100644 --- a/cocos/scripting/lua-bindings/auto/api/Label.lua +++ b/cocos/scripting/lua-bindings/auto/api/Label.lua @@ -25,6 +25,12 @@ -- @param #float height -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- +-- @function [parent=#Label] getWidth +-- @param self +-- @return float#float ret (return value: float) + -------------------------------- -- Return the text the Label is displaying. -- @function [parent=#Label] getString @@ -82,6 +88,14 @@ -- @param #float width -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Returns the additional kerning of the Label.
+-- warning Not support system font.
+-- since v3.2.0 +-- @function [parent=#Label] getAdditionalKerning +-- @param self +-- @return float#float ret (return value: float) + -------------------------------- -- Return the user define BMFont size.
-- return The BMFont size in float value. @@ -101,6 +115,12 @@ -- @param self -- @return int#int ret (return value: int) +-------------------------------- +-- Return shadow effect offset value. +-- @function [parent=#Label] getShadowOffset +-- @param self +-- @return size_table#size_table ret (return value: size_table) + -------------------------------- -- Makes the Label to clip upper and lower margin for reduce height of Label. -- @function [parent=#Label] setClipMarginEnabled @@ -124,6 +144,12 @@ -- @param #string font -- @return Label#Label self (return value: cc.Label) +-------------------------------- +-- Return the outline effect size value. +-- @function [parent=#Label] getOutlineSize +-- @param self +-- @return int#int ret (return value: int) + -------------------------------- -- Sets a new bitmap font to Label -- @function [parent=#Label] setBMFontFilePath @@ -220,13 +246,17 @@ -- @return Label#Label self (return value: cc.Label) -------------------------------- --- Returns the additional kerning of the Label.
--- warning Not support system font.
--- since v3.2.0 --- @function [parent=#Label] getAdditionalKerning +-- Return the shadow effect blur radius. +-- @function [parent=#Label] getShadowBlurRadius -- @param self -- @return float#float ret (return value: float) +-------------------------------- +-- Return current effect color vlaue. +-- @function [parent=#Label] getEffectColor +-- @param self +-- @return color4f_table#color4f_table ret (return value: color4f_table) + -------------------------------- -- -- @function [parent=#Label] removeAllChildrenWithCleanup @@ -288,6 +318,12 @@ -- @param self -- @return float#float ret (return value: float) +-------------------------------- +-- Return the shadow effect color value. +-- @function [parent=#Label] getShadowColor +-- @param self +-- @return color4f_table#color4f_table ret (return value: color4f_table) + -------------------------------- -- Returns the TTF configuration object used by the Label.
-- see `TTFConfig` @@ -328,10 +364,10 @@ -- @return Label#Label self (return value: cc.Label) -------------------------------- --- --- @function [parent=#Label] getWidth +-- Return whether the shadow effect is enabled. +-- @function [parent=#Label] isShadowEnabled -- @param self --- @return float#float ret (return value: float) +-- @return bool#bool ret (return value: bool) -------------------------------- -- Enable glow effect to Label.
@@ -396,6 +432,12 @@ -- @param self -- @return bool#bool ret (return value: bool) +-------------------------------- +-- Return current effect type. +-- @function [parent=#Label] getLabelEffectType +-- @param self +-- @return int#int ret (return value: int) + -------------------------------- -- @overload self, int, int -- @overload self, int diff --git a/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua b/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua index ae4daa569b..7b625dc3a8 100644 --- a/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua +++ b/cocos/scripting/lua-bindings/auto/api/Scale9Sprite.lua @@ -37,6 +37,8 @@ -------------------------------- -- brief Toggle 9-slice feature.
-- If Scale9Sprite is 9-slice disabled, the Scale9Sprite will rendered as a normal sprite.
+-- warning: Don't use setScale9Enabled(false), use setRenderingType(RenderingType::SIMPLE) instead.
+-- The setScale9Enabled(false) is kept only for back back compatibility.
-- param enabled True to enable 9-slice, false otherwise.
-- js NA -- @function [parent=#Scale9Sprite] setScale9Enabled @@ -388,6 +390,13 @@ -- @param self -- @return float#float ret (return value: float) +-------------------------------- +-- +-- @function [parent=#Scale9Sprite] setGlobalZOrder +-- @param self +-- @param #float globalZOrder +-- @return Scale9Sprite#Scale9Sprite self (return value: ccui.Scale9Sprite) + -------------------------------- -- -- @function [parent=#Scale9Sprite] setScaleY diff --git a/cocos/scripting/lua-bindings/auto/api/Text.lua b/cocos/scripting/lua-bindings/auto/api/Text.lua index a2f468df33..7eadb87592 100644 --- a/cocos/scripting/lua-bindings/auto/api/Text.lua +++ b/cocos/scripting/lua-bindings/auto/api/Text.lua @@ -35,6 +35,12 @@ -- @param #int effect -- @return Text#Text self (return value: ccui.Text) +-------------------------------- +-- Return current effect type. +-- @function [parent=#Text] getLabelEffectType +-- @param self +-- @return int#int ret (return value: int) + -------------------------------- -- Gets text color.
-- return Text color. @@ -77,6 +83,12 @@ -- @param #bool enabled -- @return Text#Text self (return value: ccui.Text) +-------------------------------- +-- Return shadow effect offset value. +-- @function [parent=#Text] getShadowOffset +-- @param self +-- @return size_table#size_table ret (return value: size_table) + -------------------------------- -- -- @function [parent=#Text] setString @@ -84,6 +96,12 @@ -- @param #string text -- @return Text#Text self (return value: ccui.Text) +-------------------------------- +-- Return the outline effect size value. +-- @function [parent=#Text] getOutlineSize +-- @param self +-- @return int#int ret (return value: int) + -------------------------------- -- -- @function [parent=#Text] init @@ -93,6 +111,12 @@ -- @param #float fontSize -- @return bool#bool ret (return value: bool) +-------------------------------- +-- Return the shadow effect blur radius. +-- @function [parent=#Text] getShadowBlurRadius +-- @param self +-- @return float#float ret (return value: float) + -------------------------------- -- Gets the touch scale enabled of label.
-- return Touch scale enabled of label. @@ -145,6 +169,12 @@ -- @param #int outlineSize -- @return Text#Text self (return value: ccui.Text) +-------------------------------- +-- Return current effect color vlaue. +-- @function [parent=#Text] getEffectColor +-- @param self +-- @return color4b_table#color4b_table ret (return value: color4b_table) + -------------------------------- -- Gets the font type.
-- return The font type. @@ -159,6 +189,12 @@ -- @param self -- @return int#int ret (return value: int) +-------------------------------- +-- Return whether the shadow effect is enabled. +-- @function [parent=#Text] isShadowEnabled +-- @param self +-- @return bool#bool ret (return value: bool) + -------------------------------- -- Sets the font size of label.
-- param size The font size. @@ -167,6 +203,12 @@ -- @param #float size -- @return Text#Text self (return value: ccui.Text) +-------------------------------- +-- Return the shadow effect color value. +-- @function [parent=#Text] getShadowColor +-- @param self +-- @return color4b_table#color4b_table ret (return value: color4b_table) + -------------------------------- -- Sets text color.
-- param color Text color. diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 1e4ee24c1c..bf8c38c53f 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -51243,6 +51243,53 @@ int lua_cocos2dx_Label_setDimensions(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_getWidth(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getWidth'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getWidth'", nullptr); + return 0; + } + double ret = cobj->getWidth(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getWidth",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getWidth'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_getString(lua_State* tolua_S) { int argc = 0; @@ -51632,6 +51679,53 @@ int lua_cocos2dx_Label_setWidth(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_getAdditionalKerning(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getAdditionalKerning'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getAdditionalKerning'", nullptr); + return 0; + } + double ret = cobj->getAdditionalKerning(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getAdditionalKerning",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getAdditionalKerning'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_getBMFontSize(lua_State* tolua_S) { int argc = 0; @@ -51773,6 +51867,53 @@ int lua_cocos2dx_Label_getHorizontalAlignment(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_getShadowOffset(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getShadowOffset'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getShadowOffset'", nullptr); + return 0; + } + cocos2d::Size ret = cobj->getShadowOffset(); + size_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getShadowOffset",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getShadowOffset'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_setClipMarginEnabled(lua_State* tolua_S) { int argc = 0; @@ -51923,6 +52064,53 @@ int lua_cocos2dx_Label_setSystemFontName(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_getOutlineSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getOutlineSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getOutlineSize'", nullptr); + return 0; + } + int ret = cobj->getOutlineSize(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getOutlineSize",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getOutlineSize'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_setBMFontFilePath(lua_State* tolua_S) { int argc = 0; @@ -52707,7 +52895,7 @@ int lua_cocos2dx_Label_enableOutline(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Label_getAdditionalKerning(lua_State* tolua_S) +int lua_cocos2dx_Label_getShadowBlurRadius(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; @@ -52727,7 +52915,7 @@ int lua_cocos2dx_Label_getAdditionalKerning(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getAdditionalKerning'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getShadowBlurRadius'", nullptr); return 0; } #endif @@ -52737,19 +52925,66 @@ int lua_cocos2dx_Label_getAdditionalKerning(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getAdditionalKerning'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getShadowBlurRadius'", nullptr); return 0; } - double ret = cobj->getAdditionalKerning(); + double ret = cobj->getShadowBlurRadius(); tolua_pushnumber(tolua_S,(lua_Number)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getAdditionalKerning",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getShadowBlurRadius",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getAdditionalKerning'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getShadowBlurRadius'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_Label_getEffectColor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getEffectColor'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getEffectColor'", nullptr); + return 0; + } + cocos2d::Color4F ret = cobj->getEffectColor(); + color4f_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getEffectColor",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getEffectColor'.",&tolua_err); #endif return 0; @@ -53186,6 +53421,53 @@ int lua_cocos2dx_Label_getLineHeight(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_getShadowColor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getShadowColor'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getShadowColor'", nullptr); + return 0; + } + cocos2d::Color4F ret = cobj->getShadowColor(); + color4f_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getShadowColor",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getShadowColor'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_getTTFConfig(lua_State* tolua_S) { int argc = 0; @@ -53430,7 +53712,7 @@ int lua_cocos2dx_Label_setHeight(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Label_getWidth(lua_State* tolua_S) +int lua_cocos2dx_Label_isShadowEnabled(lua_State* tolua_S) { int argc = 0; cocos2d::Label* cobj = nullptr; @@ -53450,7 +53732,7 @@ int lua_cocos2dx_Label_getWidth(lua_State* tolua_S) #if COCOS2D_DEBUG >= 1 if (!cobj) { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getWidth'", nullptr); + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_isShadowEnabled'", nullptr); return 0; } #endif @@ -53460,19 +53742,19 @@ int lua_cocos2dx_Label_getWidth(lua_State* tolua_S) { if(!ok) { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getWidth'", nullptr); + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_isShadowEnabled'", nullptr); return 0; } - double ret = cobj->getWidth(); - tolua_pushnumber(tolua_S,(lua_Number)ret); + bool ret = cobj->isShadowEnabled(); + tolua_pushboolean(tolua_S,(bool)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getWidth",argc, 0); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:isShadowEnabled",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getWidth'.",&tolua_err); + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_isShadowEnabled'.",&tolua_err); #endif return 0; @@ -53912,6 +54194,53 @@ int lua_cocos2dx_Label_isWrapEnabled(lua_State* tolua_S) return 0; } +int lua_cocos2dx_Label_getLabelEffectType(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Label* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Label",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Label*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Label_getLabelEffectType'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Label_getLabelEffectType'", nullptr); + return 0; + } + int ret = (int)cobj->getLabelEffectType(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Label:getLabelEffectType",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Label_getLabelEffectType'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_Label_setAlignment(lua_State* tolua_S) { int argc = 0; @@ -54394,6 +54723,7 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"isClipMarginEnabled",lua_cocos2dx_Label_isClipMarginEnabled); tolua_function(tolua_S,"enableShadow",lua_cocos2dx_Label_enableShadow); tolua_function(tolua_S,"setDimensions",lua_cocos2dx_Label_setDimensions); + tolua_function(tolua_S,"getWidth",lua_cocos2dx_Label_getWidth); tolua_function(tolua_S,"getString",lua_cocos2dx_Label_getString); tolua_function(tolua_S,"getHeight",lua_cocos2dx_Label_getHeight); tolua_function(tolua_S,"disableEffect",lua_cocos2dx_Label_disableEffect); @@ -54402,12 +54732,15 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_Label_getBlendFunc); tolua_function(tolua_S,"enableWrap",lua_cocos2dx_Label_enableWrap); tolua_function(tolua_S,"setWidth",lua_cocos2dx_Label_setWidth); + tolua_function(tolua_S,"getAdditionalKerning",lua_cocos2dx_Label_getAdditionalKerning); tolua_function(tolua_S,"getBMFontSize",lua_cocos2dx_Label_getBMFontSize); tolua_function(tolua_S,"getMaxLineWidth",lua_cocos2dx_Label_getMaxLineWidth); tolua_function(tolua_S,"getHorizontalAlignment",lua_cocos2dx_Label_getHorizontalAlignment); + tolua_function(tolua_S,"getShadowOffset",lua_cocos2dx_Label_getShadowOffset); tolua_function(tolua_S,"setClipMarginEnabled",lua_cocos2dx_Label_setClipMarginEnabled); tolua_function(tolua_S,"setString",lua_cocos2dx_Label_setString); tolua_function(tolua_S,"setSystemFontName",lua_cocos2dx_Label_setSystemFontName); + tolua_function(tolua_S,"getOutlineSize",lua_cocos2dx_Label_getOutlineSize); tolua_function(tolua_S,"setBMFontFilePath",lua_cocos2dx_Label_setBMFontFilePath); tolua_function(tolua_S,"initWithTTF",lua_cocos2dx_Label_initWithTTF); tolua_function(tolua_S,"getFontAtlas",lua_cocos2dx_Label_getFontAtlas); @@ -54420,7 +54753,8 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"setLineBreakWithoutSpace",lua_cocos2dx_Label_setLineBreakWithoutSpace); tolua_function(tolua_S,"getStringNumLines",lua_cocos2dx_Label_getStringNumLines); tolua_function(tolua_S,"enableOutline",lua_cocos2dx_Label_enableOutline); - tolua_function(tolua_S,"getAdditionalKerning",lua_cocos2dx_Label_getAdditionalKerning); + tolua_function(tolua_S,"getShadowBlurRadius",lua_cocos2dx_Label_getShadowBlurRadius); + tolua_function(tolua_S,"getEffectColor",lua_cocos2dx_Label_getEffectColor); tolua_function(tolua_S,"removeAllChildrenWithCleanup",lua_cocos2dx_Label_removeAllChildrenWithCleanup); tolua_function(tolua_S,"setCharMap",lua_cocos2dx_Label_setCharMap); tolua_function(tolua_S,"getDimensions",lua_cocos2dx_Label_getDimensions); @@ -54429,12 +54763,13 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"setVerticalAlignment",lua_cocos2dx_Label_setVerticalAlignment); tolua_function(tolua_S,"setLineSpacing",lua_cocos2dx_Label_setLineSpacing); tolua_function(tolua_S,"getLineHeight",lua_cocos2dx_Label_getLineHeight); + tolua_function(tolua_S,"getShadowColor",lua_cocos2dx_Label_getShadowColor); tolua_function(tolua_S,"getTTFConfig",lua_cocos2dx_Label_getTTFConfig); tolua_function(tolua_S,"getVerticalAlignment",lua_cocos2dx_Label_getVerticalAlignment); tolua_function(tolua_S,"setTextColor",lua_cocos2dx_Label_setTextColor); tolua_function(tolua_S,"getLetter",lua_cocos2dx_Label_getLetter); tolua_function(tolua_S,"setHeight",lua_cocos2dx_Label_setHeight); - tolua_function(tolua_S,"getWidth",lua_cocos2dx_Label_getWidth); + tolua_function(tolua_S,"isShadowEnabled",lua_cocos2dx_Label_isShadowEnabled); tolua_function(tolua_S,"enableGlow",lua_cocos2dx_Label_enableGlow); tolua_function(tolua_S,"getOverflow",lua_cocos2dx_Label_getOverflow); tolua_function(tolua_S,"setAdditionalKerning",lua_cocos2dx_Label_setAdditionalKerning); @@ -54444,6 +54779,7 @@ int lua_register_cocos2dx_Label(lua_State* tolua_S) tolua_function(tolua_S,"getBMFontFilePath",lua_cocos2dx_Label_getBMFontFilePath); tolua_function(tolua_S,"setHorizontalAlignment",lua_cocos2dx_Label_setHorizontalAlignment); tolua_function(tolua_S,"isWrapEnabled",lua_cocos2dx_Label_isWrapEnabled); + tolua_function(tolua_S,"getLabelEffectType",lua_cocos2dx_Label_getLabelEffectType); tolua_function(tolua_S,"setAlignment",lua_cocos2dx_Label_setAlignment); tolua_function(tolua_S,"requestSystemFontRefresh",lua_cocos2dx_Label_requestSystemFontRefresh); tolua_function(tolua_S,"setBMFontSize",lua_cocos2dx_Label_setBMFontSize); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index f1b53ac43b..aae102f844 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2169,6 +2169,13 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + + + + + diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp index 895c676c35..a4e91d3be1 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp @@ -2466,24 +2466,27 @@ int lua_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite(lua_St #endif argc = lua_gettop(tolua_S)-1; - if (argc == 2) + if (argc == 3) { cocos2d::Node* arg0; cocos2d::ui::Scale9Sprite* arg1; + bool arg2; ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0, "cc.ControlButton:initWithLabelAndBackgroundSprite"); ok &= luaval_to_object(tolua_S, 3, "ccui.Scale9Sprite",&arg1, "cc.ControlButton:initWithLabelAndBackgroundSprite"); + + ok &= luaval_to_boolean(tolua_S, 4,&arg2, "cc.ControlButton:initWithLabelAndBackgroundSprite"); if(!ok) { tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_extension_ControlButton_initWithLabelAndBackgroundSprite'", nullptr); return 0; } - bool ret = cobj->initWithLabelAndBackgroundSprite(arg0, arg1); + bool ret = cobj->initWithLabelAndBackgroundSprite(arg0, arg1, arg2); tolua_pushboolean(tolua_S,(bool)ret); return 1; } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.ControlButton:initWithLabelAndBackgroundSprite",argc, 2); + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.ControlButton:initWithLabelAndBackgroundSprite",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 @@ -2662,6 +2665,25 @@ int lua_cocos2dx_extension_ControlButton_create(lua_State* tolua_S) } } while (0); ok = true; + do + { + if (argc == 3) + { + cocos2d::Node* arg0; + ok &= luaval_to_object(tolua_S, 2, "cc.Node",&arg0, "cc.ControlButton:create"); + if (!ok) { break; } + cocos2d::ui::Scale9Sprite* arg1; + ok &= luaval_to_object(tolua_S, 3, "ccui.Scale9Sprite",&arg1, "cc.ControlButton:create"); + if (!ok) { break; } + bool arg2; + ok &= luaval_to_boolean(tolua_S, 4,&arg2, "cc.ControlButton:create"); + if (!ok) { break; } + cocos2d::extension::ControlButton* ret = cocos2d::extension::ControlButton::create(arg0, arg1, arg2); + object_to_luaval(tolua_S, "cc.ControlButton",(cocos2d::extension::ControlButton*)ret); + return 1; + } + } while (0); + ok = true; luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.ControlButton:create",argc, 3); return 0; #if COCOS2D_DEBUG >= 1 diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index 845968cd4e..d7ce78c146 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -11530,6 +11530,53 @@ int lua_cocos2dx_ui_Text_disableEffect(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_getLabelEffectType(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_getLabelEffectType'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Text_getLabelEffectType'", nullptr); + return 0; + } + int ret = (int)cobj->getLabelEffectType(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Text:getLabelEffectType",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_getLabelEffectType'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_getTextColor(lua_State* tolua_S) { int argc = 0; @@ -11727,6 +11774,53 @@ int lua_cocos2dx_ui_Text_setTouchScaleChangeEnabled(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_getShadowOffset(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_getShadowOffset'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Text_getShadowOffset'", nullptr); + return 0; + } + cocos2d::Size ret = cobj->getShadowOffset(); + size_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Text:getShadowOffset",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_getShadowOffset'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_setString(lua_State* tolua_S) { int argc = 0; @@ -11777,6 +11871,53 @@ int lua_cocos2dx_ui_Text_setString(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_getOutlineSize(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_getOutlineSize'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Text_getOutlineSize'", nullptr); + return 0; + } + int ret = cobj->getOutlineSize(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Text:getOutlineSize",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_getOutlineSize'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_init(lua_State* tolua_S) { int argc = 0; @@ -11833,6 +11974,53 @@ int lua_cocos2dx_ui_Text_init(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_getShadowBlurRadius(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_getShadowBlurRadius'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Text_getShadowBlurRadius'", nullptr); + return 0; + } + double ret = cobj->getShadowBlurRadius(); + tolua_pushnumber(tolua_S,(lua_Number)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Text:getShadowBlurRadius",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_getShadowBlurRadius'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_isTouchScaleChangeEnabled(lua_State* tolua_S) { int argc = 0; @@ -12138,6 +12326,53 @@ int lua_cocos2dx_ui_Text_enableOutline(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_getEffectColor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_getEffectColor'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Text_getEffectColor'", nullptr); + return 0; + } + cocos2d::Color4B ret = cobj->getEffectColor(); + color4b_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Text:getEffectColor",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_getEffectColor'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_getType(lua_State* tolua_S) { int argc = 0; @@ -12232,6 +12467,53 @@ int lua_cocos2dx_ui_Text_getTextHorizontalAlignment(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_isShadowEnabled(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_isShadowEnabled'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Text_isShadowEnabled'", nullptr); + return 0; + } + bool ret = cobj->isShadowEnabled(); + tolua_pushboolean(tolua_S,(bool)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Text:isShadowEnabled",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_isShadowEnabled'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_setFontSize(lua_State* tolua_S) { int argc = 0; @@ -12282,6 +12564,53 @@ int lua_cocos2dx_ui_Text_setFontSize(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Text_getShadowColor(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Text* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Text",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Text*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Text_getShadowColor'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Text_getShadowColor'", nullptr); + return 0; + } + cocos2d::Color4B ret = cobj->getShadowColor(); + color4b_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Text:getShadowColor",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Text_getShadowColor'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Text_setTextColor(lua_State* tolua_S) { int argc = 0; @@ -12665,21 +12994,28 @@ int lua_register_cocos2dx_ui_Text(lua_State* tolua_S) tolua_function(tolua_S,"getFontSize",lua_cocos2dx_ui_Text_getFontSize); tolua_function(tolua_S,"getString",lua_cocos2dx_ui_Text_getString); tolua_function(tolua_S,"disableEffect",lua_cocos2dx_ui_Text_disableEffect); + tolua_function(tolua_S,"getLabelEffectType",lua_cocos2dx_ui_Text_getLabelEffectType); tolua_function(tolua_S,"getTextColor",lua_cocos2dx_ui_Text_getTextColor); tolua_function(tolua_S,"setTextVerticalAlignment",lua_cocos2dx_ui_Text_setTextVerticalAlignment); tolua_function(tolua_S,"setFontName",lua_cocos2dx_ui_Text_setFontName); tolua_function(tolua_S,"setTouchScaleChangeEnabled",lua_cocos2dx_ui_Text_setTouchScaleChangeEnabled); + tolua_function(tolua_S,"getShadowOffset",lua_cocos2dx_ui_Text_getShadowOffset); tolua_function(tolua_S,"setString",lua_cocos2dx_ui_Text_setString); + tolua_function(tolua_S,"getOutlineSize",lua_cocos2dx_ui_Text_getOutlineSize); tolua_function(tolua_S,"init",lua_cocos2dx_ui_Text_init); + tolua_function(tolua_S,"getShadowBlurRadius",lua_cocos2dx_ui_Text_getShadowBlurRadius); tolua_function(tolua_S,"isTouchScaleChangeEnabled",lua_cocos2dx_ui_Text_isTouchScaleChangeEnabled); tolua_function(tolua_S,"getFontName",lua_cocos2dx_ui_Text_getFontName); tolua_function(tolua_S,"setTextAreaSize",lua_cocos2dx_ui_Text_setTextAreaSize); tolua_function(tolua_S,"getStringLength",lua_cocos2dx_ui_Text_getStringLength); tolua_function(tolua_S,"getAutoRenderSize",lua_cocos2dx_ui_Text_getAutoRenderSize); tolua_function(tolua_S,"enableOutline",lua_cocos2dx_ui_Text_enableOutline); + tolua_function(tolua_S,"getEffectColor",lua_cocos2dx_ui_Text_getEffectColor); tolua_function(tolua_S,"getType",lua_cocos2dx_ui_Text_getType); tolua_function(tolua_S,"getTextHorizontalAlignment",lua_cocos2dx_ui_Text_getTextHorizontalAlignment); + tolua_function(tolua_S,"isShadowEnabled",lua_cocos2dx_ui_Text_isShadowEnabled); tolua_function(tolua_S,"setFontSize",lua_cocos2dx_ui_Text_setFontSize); + tolua_function(tolua_S,"getShadowColor",lua_cocos2dx_ui_Text_getShadowColor); tolua_function(tolua_S,"setTextColor",lua_cocos2dx_ui_Text_setTextColor); tolua_function(tolua_S,"enableGlow",lua_cocos2dx_ui_Text_enableGlow); tolua_function(tolua_S,"getTextVerticalAlignment",lua_cocos2dx_ui_Text_getTextVerticalAlignment); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp index 53e67879ca..abef41775e 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.hpp @@ -650,6 +650,13 @@ int register_all_cocos2dx_ui(lua_State* tolua_S); + + + + + + + From b32d013dc434f0ce9779eac785b24ff54cfbd8ba Mon Sep 17 00:00:00 2001 From: "lunhao.guo" Date: Tue, 15 Dec 2015 20:06:16 +0800 Subject: [PATCH 32/66] update cocos2d-console submodule to SH1 1ad9331a9e3cbef9c499b6c785d64c25b2f7e133 --- tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index c33fea773d..1ad9331a9e 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit c33fea773db67e94818ce7ac9e2146895fd15d53 +Subproject commit 1ad9331a9e3cbef9c499b6c785d64c25b2f7e133 From 7d72f66f5b850110f32927079f861699c91fa0bc Mon Sep 17 00:00:00 2001 From: GuoLunHao Date: Tue, 15 Dec 2015 21:00:24 +0800 Subject: [PATCH 33/66] add 'js_module_register.cpp' and 'lua_module_register.cpp' in Compile Sources on iOS Targets' Build Phases --- .../proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj | 3 ++- .../cocos2d_lua_bindings.xcodeproj/project.pbxproj | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj index 9f0006befa..0039e587d0 100644 --- a/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj/project.pbxproj @@ -164,6 +164,7 @@ 83A5661A18DA878400FC31A0 /* jsb_socketio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83A5661718DA878400FC31A0 /* jsb_socketio.cpp */; }; 83A5661B18DA878400FC31A0 /* jsb_socketio.h in Headers */ = {isa = PBXBuildFile; fileRef = 83A5661818DA878400FC31A0 /* jsb_socketio.h */; }; 83A5661C18DA878400FC31A0 /* jsb_socketio.h in Headers */ = {isa = PBXBuildFile; fileRef = 83A5661818DA878400FC31A0 /* jsb_socketio.h */; }; + ADAC23EE1C2044DC0049A6A2 /* js_module_register.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADD1C0D91C196BDF00733781 /* js_module_register.cpp */; }; ADD1C0DC1C196BDF00733781 /* js_module_register.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADD1C0D91C196BDF00733781 /* js_module_register.cpp */; }; ADD1C0DD1C196BDF00733781 /* js_module_register.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD1C0DA1C196BDF00733781 /* js_module_register.h */; }; ADD1C0DE1C196BDF00733781 /* js-BindingsExport.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD1C0DB1C196BDF00733781 /* js-BindingsExport.h */; }; @@ -844,7 +845,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - ADD1C0DF1C196BFC00733781 /* js_module_register.cpp in Sources */, + ADAC23EE1C2044DC0049A6A2 /* js_module_register.cpp in Sources */, 0541A75B19738AD200E45470 /* JavaScriptObjCBridge.mm in Sources */, 420BBCF81AA48EE900493976 /* jsb_cocos2dx_3d_manual.cpp in Sources */, 1A119E8A18BDF19200352BAA /* jsb_cocos2dx_builder_auto.cpp in Sources */, diff --git a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj index 9320ffdca5..0092be9288 100644 --- a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj @@ -287,6 +287,7 @@ BA0CBB5F1BB0756F00003364 /* CCComponentLua.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA0CBB5C1BB0756F00003364 /* CCComponentLua.cpp */; settings = {ASSET_TAGS = (); }; }; BA0CBB601BB0756F00003364 /* CCComponentLua.h in Headers */ = {isa = PBXBuildFile; fileRef = BA0CBB5D1BB0756F00003364 /* CCComponentLua.h */; settings = {ASSET_TAGS = (); }; }; BA0CBB611BB0756F00003364 /* CCComponentLua.h in Headers */ = {isa = PBXBuildFile; fileRef = BA0CBB5D1BB0756F00003364 /* CCComponentLua.h */; settings = {ASSET_TAGS = (); }; }; + ADAC23ED1C2044A60049A6A2 /* lua_module_register.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADD1C0D21C196B9500733781 /* lua_module_register.cpp */; }; ADD1C0D51C196B9500733781 /* lua_module_register.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADD1C0D21C196B9500733781 /* lua_module_register.cpp */; }; ADD1C0D61C196B9500733781 /* lua_module_register.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD1C0D31C196B9500733781 /* lua_module_register.h */; }; ADD1C0D71C196B9500733781 /* Lua-BindingsExport.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD1C0D41C196B9500733781 /* Lua-BindingsExport.h */; }; @@ -1145,7 +1146,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - ADD1C0D81C196BBF00733781 /* lua_module_register.cpp in Sources */, + ADAC23ED1C2044A60049A6A2 /* lua_module_register.cpp in Sources */, 15415AC619A71A53004F1E71 /* select.c in Sources */, 15A561ED1B00A3F1005D4720 /* lua_cocos2dx_physics3d_manual.cpp in Sources */, 15EFA646198B3311000C57D3 /* tolua_event.c in Sources */, From 43a573f4fd4750783581662219f81b3912f0c460 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 15 Dec 2015 12:27:53 -0800 Subject: [PATCH 34/66] ccvector_to / ccmap_to converted to new API and more fixes --- cocos/base/CCRef.cpp | 9 +- .../js-bindings/manual/ScriptingCore.cpp | 117 +++++++++++------- .../js-bindings/manual/ScriptingCore.h | 3 - .../js-bindings/manual/cocos2d_specifics.hpp | 3 +- .../jsb_cocos2dx_extension_manual.cpp | 3 +- .../js-bindings/manual/js_bindings_opengl.cpp | 6 +- .../manual/js_manual_conversions.h | 21 ++-- .../manual/network/jsb_socketio.cpp | 3 +- .../manual/spidermonkey_specifics.h | 39 ------ 9 files changed, 91 insertions(+), 113 deletions(-) diff --git a/cocos/base/CCRef.cpp b/cocos/base/CCRef.cpp index 4c4ce17674..eed860e602 100644 --- a/cocos/base/CCRef.cpp +++ b/cocos/base/CCRef.cpp @@ -65,7 +65,7 @@ Ref::Ref() Ref::~Ref() { -#if CC_ENABLE_SCRIPT_BINDING +#if CC_ENABLE_SCRIPT_BINDING && not CC_ENABLE_GC_FOR_NATIVE_OBJECTS // if the object is referenced by Lua engine, remove it if (_luaID) { @@ -100,11 +100,7 @@ void Ref::retain() if (scriptMgr && scriptMgr->getScriptType() == kScriptTypeJavascript) { _referenceCountAtRootTime = _referenceCount-1; - - CCLOG("retain + root: %p (%s) rc=%d rcrt=%d", this, typeid(*this).name(), _referenceCount, _referenceCountAtRootTime); - scriptMgr->rootObject(this); - _rooted = true; } } #endif // CC_ENABLE_SCRIPT_BINDING @@ -116,13 +112,12 @@ void Ref::release() --_referenceCount; #if CC_ENABLE_SCRIPT_BINDING && CC_ENABLE_GC_FOR_NATIVE_OBJECTS - if (_scriptOwned && _rooted && _referenceCount==_referenceCountAtRootTime) + if (_scriptOwned && _rooted && _referenceCount==/*_referenceCountAtRootTime*/ 1) { auto scriptMgr = ScriptEngineManager::getInstance()->getScriptEngine(); if (scriptMgr && scriptMgr->getScriptType() == kScriptTypeJavascript) { scriptMgr->unrootObject(this); - _rooted = false; } } #endif // CC_ENABLE_SCRIPT_BINDING diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 86e9ac2833..2c1af9f782 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -212,18 +212,30 @@ static std::string getMouseFuncName(EventMouse::MouseEventType eventType) return funcName; } -void removeJSObject(JSContext* cx, void* nativeObj) +static void removeJSObject(JSContext* cx, cocos2d::Ref* nativeObj) { js_proxy_t* nproxy; js_proxy_t* jsproxy; nproxy = jsb_get_native_proxy(nativeObj); - if (nproxy) { - JS::RootedObject jsobj(cx, nproxy->obj); - jsproxy = jsb_get_js_proxy(jsobj); - RemoveObjectRoot(cx, &jsproxy->obj); + if (nproxy) + { + jsproxy = jsb_get_js_proxy(nproxy->obj); + JS::RemoveObjectRoot(cx, &jsproxy->obj); + +#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS + nativeObj->_rooted = false; + + // FIXME BUG TODO: remove this line... but if I do so + // another misterious bug appears jsb_remove_proxy(nproxy, jsproxy); +#else + // only remove when not using GC, + // otherwise finalize won't be able to find the proxy + jsb_remove_proxy(nproxy, jsproxy); +#endif } + else CCLOG("removeJSObject: BUG: cannot find native object = %p", nativeObj); } void ScriptingCore::executeJSFunctionWithThisObj(JS::HandleValue thisObj, JS::HandleValue callback) @@ -874,15 +886,16 @@ void ScriptingCore::removeScriptObjectByObject(Ref* pObj) nproxy = jsb_get_native_proxy(ptr); if (nproxy) { - JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); - JS::RootedObject jsobj(cx, nproxy->obj); - jsproxy = jsb_get_js_proxy(jsobj); + JSContext *cx = getGlobalContext(); + jsproxy = jsb_get_js_proxy(nproxy->obj); if (jsproxy) { RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(nproxy, jsproxy); } + else CCLOG("removeScriptObjectByObject. BUG: jsproxy not found = %p", nproxy); } + else CCLOG("removeScriptObjectByObject. BUG: nproxy not found = %p", nproxy); } @@ -1185,7 +1198,6 @@ bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::Eve JS::RootedObject jsretArr(_cx, JS_NewArrayObject(this->_cx, 0)); -// AddNamedObjectRoot(this->_cx, &jsretArr, "touchArray"); int count = 0; js_type_class_t *typeClassEvent = nullptr; @@ -1214,8 +1226,6 @@ bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::Eve ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet); } -// JS_RemoveObjectRoot(this->_cx, &jsretArr); - for (auto& touch : touches) { removeJSObject(this->_cx, touch); @@ -1570,11 +1580,9 @@ void ScriptingCore::rootObject(Ref* ref) JSContext *cx = getGlobalContext(); jsproxy = jsb_get_js_proxy(nproxy->obj); JS::AddNamedObjectRoot(cx, &jsproxy->obj, typeid(*ref).name()); + ref->_rooted = true; } - else - { - CCLOG("BUG in rootObject"); - } + else CCLOG("rootObject: BUG. native not found: %p", ref); } void ScriptingCore::unrootObject(Ref* ref) @@ -1588,11 +1596,9 @@ void ScriptingCore::unrootObject(Ref* ref) JSContext *cx = getGlobalContext(); jsproxy = jsb_get_js_proxy(nproxy->obj); JS::RemoveObjectRoot(cx, &jsproxy->obj); + ref->_rooted = false; } - else - { - CCLOG("BUG in unrootObject"); - } + else CCLOG("unrootObject: BUG. native not found: %p", ref); } #pragma mark - Debug @@ -1922,44 +1928,59 @@ js_proxy_t* jsb_new_proxy(void* nativeObj, JS::HandleObject jsObj) { js_proxy_t* p = nullptr; JSObject* ptr = jsObj.get(); - do { - p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); - assert(p); - js_proxy_t* nativeObjJsObjtmp = NULL; - HASH_FIND_PTR(_native_js_global_ht, &nativeObj, nativeObjJsObjtmp); - assert(!nativeObjJsObjtmp); - p->ptr = nativeObj; - p->obj = ptr; - HASH_ADD_PTR(_native_js_global_ht, ptr, p); - p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); - assert(p); - nativeObjJsObjtmp = NULL; - HASH_FIND_PTR(_js_native_global_ht, &ptr, nativeObjJsObjtmp); - assert(!nativeObjJsObjtmp); - p->ptr = nativeObj; - p->obj = ptr; - HASH_ADD_PTR(_js_native_global_ht, obj, p); - } while(0); + + // native to JS index + p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); + assert(p); + js_proxy_t* nativeObjJsObjtmp = NULL; + HASH_FIND_PTR(_native_js_global_ht, &nativeObj, nativeObjJsObjtmp); + assert(!nativeObjJsObjtmp); + p->ptr = nativeObj; + p->obj = ptr; + HASH_ADD_PTR(_native_js_global_ht, ptr, p); + + // JS to native Index + p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); + assert(p); + nativeObjJsObjtmp = NULL; + HASH_FIND_PTR(_js_native_global_ht, &ptr, nativeObjJsObjtmp); + assert(!nativeObjJsObjtmp); + p->ptr = nativeObj; + p->obj = ptr; + HASH_ADD_PTR(_js_native_global_ht, obj, p); + return p; } js_proxy_t* jsb_get_native_proxy(void* nativeObj) { js_proxy_t* p = nullptr; - JS_GET_PROXY(p, nativeObj); + HASH_FIND_PTR(_native_js_global_ht, &nativeObj, p); return p; } js_proxy_t* jsb_get_js_proxy(JSObject* jsObj) { js_proxy_t* p = nullptr; - JS_GET_NATIVE_PROXY(p, jsObj); + HASH_FIND_PTR(_js_native_global_ht, &jsObj, p); return p; } void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy) { - JS_REMOVE_PROXY(nativeProxy, jsProxy); + if (nativeProxy) + { + HASH_DEL(_native_js_global_ht, nativeProxy); + free(nativeProxy); + } + else CCLOG("jsb_remove_proxy: BUG: nativeProxy is null"); + + if (jsProxy) + { + HASH_DEL(_js_native_global_ht, jsProxy); + free(jsProxy); + } + else CCLOG("jsb_remove_proxy: BUG: jsProxy is null"); } // @@ -2001,7 +2022,10 @@ JSObject* jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_ty js_proxy_t* newproxy = jsb_new_proxy(ref, js_obj); #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS CC_UNUSED_PARAM(newproxy); - // don't retain it. + + // retain first copy, and before "owning" to prevent it + // from calling "rootObject" + ref->retain(); ref->_scriptOwned = true; #else // don't autorelease it @@ -2029,7 +2053,7 @@ void jsb_ref_init(JSContext* cx, JS::Heap *obj, Ref* ref, const char* (void)cx; (void)obj; ref->_scriptOwned = true; - // don't retain it. + // don't retain it, already retained #else // autorelease it ref->autorelease(); @@ -2043,9 +2067,10 @@ void jsb_ref_autoreleased_init(JSContext* cx, JS::Heap *obj, Ref* ref #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS (void)cx; (void)obj; - ref->_scriptOwned = true; - // retain it, since the object is autoreleased + // retain first copy, and before "owning" to prevent it + // from calling "rootObject" ref->retain(); + ref->_scriptOwned = true; #else // don't autorelease it, since it is already autoreleased JS::AddNamedObjectRoot(cx, obj, debug); @@ -2059,8 +2084,7 @@ void jsb_ref_finalize(JSFreeOp* fop, JSObject* obj) js_proxy_t* nproxy; js_proxy_t* jsproxy; - JS::RootedObject jsobj(fop->runtime(), obj); - jsproxy = jsb_get_js_proxy(jsobj); + jsproxy = jsb_get_js_proxy(obj); if (jsproxy) { auto ref = static_cast(jsproxy->ptr); @@ -2074,6 +2098,7 @@ void jsb_ref_finalize(JSFreeOp* fop, JSObject* obj) else jsb_remove_proxy(nullptr, jsproxy); } + else CCLOG("jsb_ref_finalize: BUG: proxy not found for %p", obj); #else // CCLOG("jsb_ref_finalize: JSObject address = %p", obj); #endif diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 5f206004da..9b8e500c6b 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -618,7 +618,4 @@ JSObject* jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_ty */ JSObject* jsb_ref_autoreleased_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug); - -void removeJSObject(JSContext* cx, void* nativeObj); - #endif /* __SCRIPTING_CORE_H__ */ diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp index 30a096d314..e8605d9ade 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.hpp @@ -87,8 +87,7 @@ inline js_type_class_t *js_get_type_from_native(T* native_obj) { */ template inline js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj) { - js_proxy_t *proxy; - HASH_FIND_PTR(_native_js_global_ht, &native_obj, proxy); + js_proxy_t *proxy = jsb_get_native_proxy(native_obj); if (!proxy) { js_type_class_t *typeProxy = js_get_type_from_native(native_obj); // Return NULL if can't find its type rather than making an assert. diff --git a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp index f0ac2167cd..cda9a02ba9 100644 --- a/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp @@ -557,8 +557,7 @@ public: virtual void onEvent(Ref *controlButton, Control::EventType event) { - js_proxy_t * p; - JS_GET_PROXY(p, controlButton); + js_proxy_t* p = jsb_get_native_proxy(controlButton); if (!p) { log("Failed to get proxy for control button"); diff --git a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp index bb69e13000..3459ef2f71 100644 --- a/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp +++ b/cocos/scripting/js-bindings/manual/js_bindings_opengl.cpp @@ -35,12 +35,10 @@ void GLNode::onDraw(Mat4 &transform, uint32_t flags) JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); js_type_class_t *typeClass = js_get_type_from_native(this); - auto j = jsb_ref_get_or_create_jsobject(cx, this, typeClass, "cocos2d::GLNode"); + JS::RootedObject jsObj(cx, jsb_ref_get_or_create_jsobject(cx, this, typeClass, "cocos2d::GLNode")); - if (j) + if (jsObj.get()) { - JS::RootedObject jsObj(cx, j); - bool found = false; JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index e2d2f538f0..1b5fd0c08b 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -280,9 +280,11 @@ jsval meshVertexAttrib_to_jsval(JSContext* cx, const cocos2d::MeshVertexAttrib& jsval uniform_to_jsval(JSContext* cx, const cocos2d::Uniform* uniform); jsval resourcedata_to_jsval(JSContext* cx, const cocos2d::ResourceData& v); -template -js_proxy_t *js_get_or_create_proxy(JSContext *cx, T *native_obj); +// forward declaration +template js_type_class_t *js_get_type_from_native(T* native_obj); + +// Ref version of ccvector_to_jsval template jsval ccvector_to_jsval(JSContext* cx, const cocos2d::Vector& v) { @@ -294,9 +296,10 @@ jsval ccvector_to_jsval(JSContext* cx, const cocos2d::Vector& v) JS::RootedValue arrElement(cx); //First, check whether object is associated with js object. - js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); - if (jsproxy) { - arrElement = OBJECT_TO_JSVAL(jsproxy->obj); + js_type_class_t *typeClass = js_get_type_from_native(obj); + JS::RootedObject jsobject(cx, jsb_ref_get_or_create_jsobject(cx, obj, typeClass, typeid(*obj).name())); + if (jsobject.get()) { + arrElement = OBJECT_TO_JSVAL(jsobject); } if (!JS_SetElement(cx, jsretArr, i, arrElement)) { @@ -322,9 +325,11 @@ jsval ccmap_string_key_to_jsval(JSContext* cx, const cocos2d::Mapsecond; //First, check whether object is associated with js object. - js_proxy_t* jsproxy = js_get_or_create_proxy(cx, obj); - if (jsproxy) { - element = OBJECT_TO_JSVAL(jsproxy->obj); + js_type_class_t *typeClass = js_get_type_from_native(obj); + JS::RootedObject jsobject(cx, jsb_ref_get_or_create_jsobject(cx, obj, typeClass, typeid(*obj).name())); + + if (jsobject.get()) { + element = OBJECT_TO_JSVAL(jsobject); } if (!key.empty()) diff --git a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp index 886254a0a0..be81403dd2 100644 --- a/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp +++ b/cocos/scripting/js-bindings/manual/network/jsb_socketio.cpp @@ -164,8 +164,7 @@ bool js_cocos2dx_SocketIO_connect(JSContext* cx, uint32_t argc, jsval* vp) if (ret) { // link the native object with the javascript object - js_proxy_t *p; - HASH_FIND_PTR(_native_js_global_ht, &ret, p); + js_proxy_t *p = jsb_get_native_proxy(ret); if(!p) { //previous connection not found, create a new one diff --git a/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h b/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h index 535752474a..9e9a529e90 100644 --- a/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h +++ b/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h @@ -35,9 +35,6 @@ typedef struct js_proxy { UT_hash_handle hh; } js_proxy_t; -extern js_proxy_t *_native_js_global_ht; -extern js_proxy_t *_js_native_global_ht; - typedef struct js_type_class { JSClass *jsclass; mozilla::Maybe proto; @@ -60,42 +57,6 @@ public: }; -#define JS_NEW_PROXY(p, native_obj, js_obj) \ -do { \ - p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \ - assert(p); \ - js_proxy_t* native_obj##js_obj##tmp = NULL; \ - HASH_FIND_PTR(_native_js_global_ht, &native_obj, native_obj##js_obj##tmp); \ - assert(!native_obj##js_obj##tmp); \ - p->ptr = native_obj; \ - p->obj = js_obj; \ - HASH_ADD_PTR(_native_js_global_ht, ptr, p); \ - p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); \ - assert(p); \ - native_obj##js_obj##tmp = NULL; \ - HASH_FIND_PTR(_js_native_global_ht, &js_obj, native_obj##js_obj##tmp); \ - assert(!native_obj##js_obj##tmp); \ - p->ptr = native_obj; \ - p->obj = js_obj; \ - HASH_ADD_PTR(_js_native_global_ht, obj, p); \ -} while(0) \ - -#define JS_GET_PROXY(p, native_obj) \ -do { \ - HASH_FIND_PTR(_native_js_global_ht, &native_obj, p); \ -} while (0) - -#define JS_GET_NATIVE_PROXY(p, js_obj) \ -do { \ - HASH_FIND_PTR(_js_native_global_ht, &js_obj, p); \ -} while (0) - -#define JS_REMOVE_PROXY(nproxy, jsproxy) \ -do { \ - if (nproxy) { HASH_DEL(_native_js_global_ht, nproxy); free(nproxy); } \ - if (jsproxy) { HASH_DEL(_js_native_global_ht, jsproxy); free(jsproxy); } \ -} while (0) - #define TEST_NATIVE_OBJECT(cx, native_obj) \ if (!native_obj) { \ JS_ReportError(cx, "Invalid Native Object"); \ From eb8e755362141995f5151fd464269a488daa9cec Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 15 Dec 2015 18:21:44 -0800 Subject: [PATCH 35/66] removes logs --- cocos/scripting/js-bindings/manual/ScriptingCore.cpp | 4 ++-- cocos/scripting/js-bindings/manual/js_manual_conversions.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 2c1af9f782..31182e0efa 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -893,9 +893,9 @@ void ScriptingCore::removeScriptObjectByObject(Ref* pObj) RemoveObjectRoot(cx, &jsproxy->obj); jsb_remove_proxy(nproxy, jsproxy); } - else CCLOG("removeScriptObjectByObject. BUG: jsproxy not found = %p", nproxy); +// else CCLOG("removeScriptObjectByObject. BUG: jsproxy not found = %p", nproxy); } - else CCLOG("removeScriptObjectByObject. BUG: nproxy not found = %p", nproxy); +// else CCLOG("removeScriptObjectByObject. BUG: nproxy not found = %p", nproxy); } diff --git a/cocos/scripting/js-bindings/manual/js_manual_conversions.h b/cocos/scripting/js-bindings/manual/js_manual_conversions.h index 1b5fd0c08b..f11936a001 100644 --- a/cocos/scripting/js-bindings/manual/js_manual_conversions.h +++ b/cocos/scripting/js-bindings/manual/js_manual_conversions.h @@ -282,7 +282,8 @@ jsval resourcedata_to_jsval(JSContext* cx, const cocos2d::ResourceData& v); // forward declaration -template js_type_class_t *js_get_type_from_native(T* native_obj); +template +js_type_class_t *js_get_type_from_native(T* native_obj); // Ref version of ccvector_to_jsval template From 5e61e37d80de845df9ed1b2da5cb9d2a66e5b7b7 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Wed, 16 Dec 2015 13:54:43 +0800 Subject: [PATCH 36/66] fix crash when shader can not compile --- .../Classes/ShaderTest/ShaderTest2.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp index 03bc8abe48..0e97ed4e41 100644 --- a/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp +++ b/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp @@ -93,11 +93,14 @@ public: if(std::get<0>(effect) >=0) break; - QuadCommand &q = std::get<2>(effect); - q.init(_globalZOrder, _texture->getName(), std::get<1>(effect)->getGLProgramState(), _blendFunc, &_quad, 1, transform, flags); - renderer->addCommand(&q); + auto glProgramState = std::get<1>(effect)->getGLProgramState(); + if (glProgramState) + { + QuadCommand &q = std::get<2>(effect); + q.init(_globalZOrder, _texture->getName(), glProgramState, _blendFunc, &_quad, 1, transform, flags); + renderer->addCommand(&q); + } idx++; - } // normal effect: order == 0 @@ -144,8 +147,8 @@ bool Effect::initGLProgramState(const std::string &fragmentFilename) _fragSource = fragSource; #endif - _glprogramstate = GLProgramState::getOrCreateWithGLProgram(glprogram); - _glprogramstate->retain(); + _glprogramstate = (glprogram == nullptr ? nullptr : GLProgramState::getOrCreateWithGLProgram(glprogram)); + CC_SAFE_RETAIN(_glprogramstate); return _glprogramstate != nullptr; } @@ -194,6 +197,9 @@ protected: void EffectBlur::setTarget(EffectSprite *sprite) { + if (_glprogramstate == nullptr) + return; + Size size = sprite->getTexture()->getContentSizeInPixels(); _glprogramstate->setUniformVec2("resolution", size); #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) From 73038958661541612028f1b24ee84eec64dd0cc0 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 16 Dec 2015 15:43:18 +0800 Subject: [PATCH 37/66] Improve error message for Downloader and add test case --- cocos/network/CCDownloader-apple.mm | 5 +++-- .../Classes/DownloaderTest/DownloaderTest.cpp | 5 +++-- tests/cpp-tests/proj.ios/Info.plist | 9 +++++++++ .../src/TextureCacheTest/TextureCacheTest.js | 17 +++++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/cocos/network/CCDownloader-apple.mm b/cocos/network/CCDownloader-apple.mm index 04676f9de4..e94481e62f 100644 --- a/cocos/network/CCDownloader-apple.mm +++ b/cocos/network/CCDownloader-apple.mm @@ -25,6 +25,7 @@ #include "network/CCDownloader-apple.h" #include "network/CCDownloader.h" +#include "CCString.h" #include //////////////////////////////////////////////////////////////////////////////// @@ -399,7 +400,7 @@ namespace cocos2d { namespace network { else if(![wrapper get]->storagePath.length()) { // call onTaskFinish for a data task // (for a file download task, callback is called in didFinishDownloadingToURL) - std::string errorString; + std::string errorString = cocos2d::StringUtils::format("Downloader: Failed to download %s with no error", [task.originalRequest.URL.absoluteString cStringUsingEncoding:NSUTF8StringEncoding]); const int64_t buflen = [wrapper totalBytesReceived]; char buf[buflen]; @@ -522,7 +523,7 @@ namespace cocos2d { namespace network { NSInteger statusCode = ((NSHTTPURLResponse*)downloadTask.response).statusCode; if (statusCode >= 400) { std::vector buf; // just a placeholder - std::string response = [[NSString stringWithContentsOfURL:location] UTF8String] ?: ""; + std::string response = cocos2d::StringUtils::format("Downloader: Failed to download %s with status code (%d)", [downloadTask.originalRequest.URL.absoluteString cStringUsingEncoding:NSUTF8StringEncoding], (int)statusCode); _outer->onTaskFinish(*[wrapper get], cocos2d::network::DownloadTask::ERROR_IMPL_INTERNAL, noErr, response, buf); return; } diff --git a/tests/cpp-tests/Classes/DownloaderTest/DownloaderTest.cpp b/tests/cpp-tests/Classes/DownloaderTest/DownloaderTest.cpp index 7c36e30ef7..6229c6536e 100644 --- a/tests/cpp-tests/Classes/DownloaderTest/DownloaderTest.cpp +++ b/tests/cpp-tests/Classes/DownloaderTest/DownloaderTest.cpp @@ -36,7 +36,7 @@ static const char* sURLList[] = { "http://www.cocos2d-x.org/attachments/802/cocos2dx_landscape.png", "http://www.cocos2d-x.org/docs/manual/framework/native/wiki/logo-resources-of-cocos2d-x/res/2dx_icon_512_rounded.png", - "http://www.cocos2d-x.org/attachments/1503/Cocos2CoordinateRelease.png", + "http://www.cocos2d-x.org/attachments/1503/inexist.png", "http://download.sdkbox.com/installer/v1/sdkbox-iap_v1.2.3.3.tar.gz", }; const static int sListSize = (sizeof(sURLList)/sizeof(sURLList[0])); @@ -44,7 +44,7 @@ static const char* sNameList[sListSize] = { "cocos2dx_landscape.png", "2dx_icon_512_rounded.png", - "Cocos2CoordinateRelease.png", + "inexist file", "big file", }; @@ -112,6 +112,7 @@ struct DownloaderTest : public TestCase label->setPosition(Vec2(viewSize.width / 2, viewSize.height / 2)); label->setContentSize(Size(viewSize.width, 0)); label->setAlignment(TextHAlignment::CENTER, TextVAlignment::CENTER); + label->setDimensions(viewSize.width, viewSize.height); bg->addChild(label, 20); return bg; diff --git a/tests/cpp-tests/proj.ios/Info.plist b/tests/cpp-tests/proj.ios/Info.plist index a08bb21d3b..84b34b2f90 100644 --- a/tests/cpp-tests/proj.ios/Info.plist +++ b/tests/cpp-tests/proj.ios/Info.plist @@ -8,6 +8,15 @@ NSExceptionDomains + sdkbox.com + + NSIncludesSubdomains + + NSTemporaryExceptionAllowsInsecureHTTPLoads + + NSTemporaryExceptionMinimumTLSVersion + TLSv1.1 + cocos2d-x.org NSIncludesSubdomains diff --git a/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js b/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js index 5c6c0c2190..0f9d06c645 100644 --- a/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js +++ b/tests/js-tests/src/TextureCacheTest/TextureCacheTest.js @@ -282,6 +282,8 @@ var RemoteTextureTest = TextureCacheTestBase.extend({ for (var i = 0; i < imageUrlArray.length; i++) { cc.textureCache.addImageAsync(imageUrlArray[i], this.texLoaded, this); } + + cc.loader.loadImg("http://www.cocos2d-x.org/no_such_file.jpg", this.failLoaded.bind(this)); }, texLoaded: function(texture) { @@ -296,6 +298,21 @@ var RemoteTextureTest = TextureCacheTestBase.extend({ else { cc.log("Fail to load remote texture"); } + }, + + failLoaded: function (err, img) { + var str = ""; + if (err) { + str = "Correct behavior: failed to download from wrong url"; + } + else { + str = "!!! Wrong behavior: succeed to download from wrong url"; + } + + var label = new cc.LabelTTF(str, "Times New Roman", 28); + label.x = winSize.width / 2; + label.y = winSize.height / 2; + this.addChild(label, 100); } }); From ffcf45ef788b91ec17b746b8c65640640ab635ed Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 16 Dec 2015 17:41:31 +0800 Subject: [PATCH 38/66] Improved solution for Downloader status code issue on iOS 9 --- cocos/network/CCDownloader-apple.mm | 58 ++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/cocos/network/CCDownloader-apple.mm b/cocos/network/CCDownloader-apple.mm index e94481e62f..ba8318ef5e 100644 --- a/cocos/network/CCDownloader-apple.mm +++ b/cocos/network/CCDownloader-apple.mm @@ -389,7 +389,8 @@ namespace cocos2d { namespace network { if(_outer) { - if(error) { + if(error) + { std::vector buf; // just a placeholder _outer->onTaskFinish(*[wrapper get], cocos2d::network::DownloadTask::ERROR_IMPL_INTERNAL, @@ -397,24 +398,47 @@ namespace cocos2d { namespace network { [error.localizedDescription cStringUsingEncoding:NSUTF8StringEncoding], buf); } - else if(![wrapper get]->storagePath.length()) { + else if (![wrapper get]->storagePath.length()) + { // call onTaskFinish for a data task // (for a file download task, callback is called in didFinishDownloadingToURL) - std::string errorString = cocos2d::StringUtils::format("Downloader: Failed to download %s with no error", [task.originalRequest.URL.absoluteString cStringUsingEncoding:NSUTF8StringEncoding]); - + std::string errorString; + const int64_t buflen = [wrapper totalBytesReceived]; char buf[buflen]; - [wrapper transferDataToBuffer:buf lengthOfBuffer:buflen]; - std::vector data(buf, buf + buflen); _outer->onTaskFinish(*[wrapper get], cocos2d::network::DownloadTask::ERROR_NO_ERROR, - 0, + 0, errorString, data); } + else + { + NSInteger statusCode = ((NSHTTPURLResponse*)task.response).statusCode; + std::vector buf; // just a placeholder + const char *orignalURL = [task.originalRequest.URL.absoluteString cStringUsingEncoding:NSUTF8StringEncoding]; + std::string errorMessage = ""; + + // Check for error status code + if (statusCode >= 400) + { + errorMessage = cocos2d::StringUtils::format("Downloader: Failed to download %s with status code (%d)", orignalURL, (int)statusCode); + } + // Unknown issue + else + { + errorMessage = cocos2d::StringUtils::format("Downloader: Failed to download %s with unknown error", orignalURL); + } + + _outer->onTaskFinish(*[wrapper get], + cocos2d::network::DownloadTask::ERROR_IMPL_INTERNAL, + 0, + errorMessage, + buf); + } } [self.taskDict removeObjectForKey:task]; [wrapper release]; @@ -511,23 +535,21 @@ namespace cocos2d { namespace network { return; } + // On iOS 9 a response with status code 4xx(Client Error) or 5xx(Server Error) + // might end up calling this delegate method, saving the error message to the storage path + // and treating this download task as a successful one, so we need to check the status code here + NSInteger statusCode = ((NSHTTPURLResponse*)downloadTask.response).statusCode; + if (statusCode >= 400) + { + return; + } + DownloadTaskWrapper *wrapper = [self.taskDict objectForKey:downloadTask]; const char * storagePath = [wrapper get]->storagePath.c_str(); NSString *destPath = [NSString stringWithUTF8String:storagePath]; NSFileManager *fileManager = [NSFileManager defaultManager]; NSURL *destURL = nil; - // On iOS 9 a response with status code 4xx(Client Error) or 5xx(Server Error) - // might end up calling this delegate method, saving the error message to the storage path - // and treating this download task as a successful one, so we need to check the status code here - NSInteger statusCode = ((NSHTTPURLResponse*)downloadTask.response).statusCode; - if (statusCode >= 400) { - std::vector buf; // just a placeholder - std::string response = cocos2d::StringUtils::format("Downloader: Failed to download %s with status code (%d)", [downloadTask.originalRequest.URL.absoluteString cStringUsingEncoding:NSUTF8StringEncoding], (int)statusCode); - _outer->onTaskFinish(*[wrapper get], cocos2d::network::DownloadTask::ERROR_IMPL_INTERNAL, noErr, response, buf); - return; - } - do { if ([destPath hasPrefix:@"file://"]) From 58902f0711e2f7df5c0c1dc51e64a596194c9702 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 16 Dec 2015 21:19:46 +0800 Subject: [PATCH 39/66] Fix issue in URLSession:task:didCompleteWithError: --- cocos/network/CCDownloader-apple.mm | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/cocos/network/CCDownloader-apple.mm b/cocos/network/CCDownloader-apple.mm index ba8318ef5e..709998d682 100644 --- a/cocos/network/CCDownloader-apple.mm +++ b/cocos/network/CCDownloader-apple.mm @@ -418,26 +418,20 @@ namespace cocos2d { namespace network { else { NSInteger statusCode = ((NSHTTPURLResponse*)task.response).statusCode; - std::vector buf; // just a placeholder - const char *orignalURL = [task.originalRequest.URL.absoluteString cStringUsingEncoding:NSUTF8StringEncoding]; - std::string errorMessage = ""; // Check for error status code if (statusCode >= 400) { - errorMessage = cocos2d::StringUtils::format("Downloader: Failed to download %s with status code (%d)", orignalURL, (int)statusCode); + std::vector buf; // just a placeholder + const char *orignalURL = [task.originalRequest.URL.absoluteString cStringUsingEncoding:NSUTF8StringEncoding]; + std::string errorMessage = cocos2d::StringUtils::format("Downloader: Failed to download %s with status code (%d)", orignalURL, (int)statusCode); + + _outer->onTaskFinish(*[wrapper get], + cocos2d::network::DownloadTask::ERROR_IMPL_INTERNAL, + 0, + errorMessage, + buf); } - // Unknown issue - else - { - errorMessage = cocos2d::StringUtils::format("Downloader: Failed to download %s with unknown error", orignalURL); - } - - _outer->onTaskFinish(*[wrapper get], - cocos2d::network::DownloadTask::ERROR_IMPL_INTERNAL, - 0, - errorMessage, - buf); } } [self.taskDict removeObjectForKey:task]; From f023d5a3786970b2d87c6b8ed70183623d3be07b Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 16 Dec 2015 17:37:44 -0800 Subject: [PATCH 40/66] no more uthash Instead of using two uthash entires, it uses two unordered_map entries. Benefits are: easier to debug. I can inspect the contents of the unorderd_map with the debugger less memory. I don't need to allocate two proxies. I only allocate one proxy and I added it into both maps If also fixes an important bug when unrooting objects. Unroot was cleaning the heap object. So now proxy adds a _jsobj, which is a raw pointer. Needed under certain cases. --- .../js-bindings/manual/ScriptingCore.cpp | 248 +++++++++--------- .../js-bindings/manual/ScriptingCore.h | 7 + .../js-bindings/manual/cocos2d_specifics.cpp | 26 +- .../manual/component/CCComponentJS.cpp | 9 +- .../manual/network/jsb_websocket.cpp | 7 +- .../manual/spidermonkey_specifics.h | 12 +- 6 files changed, 161 insertions(+), 148 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 31182e0efa..a5d0ab8c64 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -93,9 +93,12 @@ static uint32_t s_nestedLoopLevel = 0; // server entry point for the bg thread static void serverEntryPoint(unsigned int port); -js_proxy_t *_native_js_global_ht = NULL; -js_proxy_t *_js_native_global_ht = NULL; +//js_proxy_t *_native_js_global_ht = NULL; +//js_proxy_t *_js_native_global_ht = NULL; std::unordered_map _js_global_type_map; +static std::unordered_map _native_js_global_map; +static std::unordered_map _js_native_global_map; + static char *_js_log_buf = NULL; @@ -214,25 +217,20 @@ static std::string getMouseFuncName(EventMouse::MouseEventType eventType) static void removeJSObject(JSContext* cx, cocos2d::Ref* nativeObj) { - js_proxy_t* nproxy; - js_proxy_t* jsproxy; - - nproxy = jsb_get_native_proxy(nativeObj); - if (nproxy) + auto proxy = jsb_get_native_proxy(nativeObj); + if (proxy) { - jsproxy = jsb_get_js_proxy(nproxy->obj); - JS::RemoveObjectRoot(cx, &jsproxy->obj); - #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS nativeObj->_rooted = false; - - // FIXME BUG TODO: remove this line... but if I do so - // another misterious bug appears - jsb_remove_proxy(nproxy, jsproxy); + // remove the proxy here, since this was a "stack" object, not heap + // when js_finalize will be called, it will fail, but + // the correct solution is to have a new finalize for event + jsb_remove_proxy(proxy); #else // only remove when not using GC, // otherwise finalize won't be able to find the proxy - jsb_remove_proxy(nproxy, jsproxy); + JS::RemoveObjectRoot(cx, &proxy->obj); + jsb_remove_proxy(proxy); #endif } else CCLOG("removeJSObject: BUG: cannot find native object = %p", nativeObj); @@ -539,19 +537,20 @@ void ScriptingCore::addRegisterCallback(sc_register_sth callback) { registrationList.push_back(callback); } -void ScriptingCore::removeAllRoots(JSContext *cx) { - js_proxy_t *current, *tmp; - HASH_ITER(hh, _js_native_global_ht, current, tmp) { - RemoveObjectRoot(cx, ¤t->obj); - HASH_DEL(_js_native_global_ht, current); - free(current); +void ScriptingCore::removeAllRoots(JSContext *cx) +{ + // Native -> JS. No need to free "second" + _native_js_global_map.clear(); + + // JS -> Native: free "second" and "unroot" it. + auto it_js = _js_native_global_map.begin(); + while (it_js != _js_native_global_map.end()) + { + JS::RemoveObjectRoot(cx, &it_js->second->obj); + free(it_js->second); + it_js = _js_native_global_map.erase(it_js); } - HASH_ITER(hh, _native_js_global_ht, current, tmp) { - HASH_DEL(_native_js_global_ht, current); - free(current); - } - HASH_CLEAR(hh, _js_native_global_ht); - HASH_CLEAR(hh, _native_js_global_ht); + _js_native_global_map.clear(); } // Just a wrapper around JSPrincipals that allows static construction. @@ -878,22 +877,14 @@ bool ScriptingCore::log(JSContext* cx, uint32_t argc, jsval *vp) } -void ScriptingCore::removeScriptObjectByObject(Ref* pObj) +void ScriptingCore::removeScriptObjectByObject(cocos2d::Ref* nativeObj) { - js_proxy_t* nproxy; - js_proxy_t* jsproxy; - void *ptr = (void*)pObj; - nproxy = jsb_get_native_proxy(ptr); - if (nproxy) + auto proxy = jsb_get_native_proxy(nativeObj); + if (proxy) { JSContext *cx = getGlobalContext(); - jsproxy = jsb_get_js_proxy(nproxy->obj); - if (jsproxy) - { - RemoveObjectRoot(cx, &jsproxy->obj); - jsb_remove_proxy(nproxy, jsproxy); - } -// else CCLOG("removeScriptObjectByObject. BUG: jsproxy not found = %p", nproxy); + JS::RemoveObjectRoot(cx, &proxy->obj); + jsb_remove_proxy(proxy); } // else CCLOG("removeScriptObjectByObject. BUG: nproxy not found = %p", nproxy); } @@ -978,7 +969,7 @@ bool ScriptingCore::removeRootJS(JSContext *cx, uint32_t argc, jsval *vp) JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::Heap o(args.get(0).toObjectOrNull()); if (o != nullptr) { - RemoveObjectRoot(cx, &o); + JS::RemoveObjectRoot(cx, &o); } return true; } @@ -1154,7 +1145,7 @@ int ScriptingCore::handleComponentEvent(void* data) JS::RootedValue retval(_cx); jsval dataVal = INT_TO_JSVAL(1); - JS::RootedValue nodeValue(_cx, OBJECT_TO_JSVAL(p->obj.get())); + JS::RootedValue nodeValue(_cx, OBJECT_TO_JSVAL(p->obj)); if (action == kComponentOnAdd) { @@ -1284,13 +1275,13 @@ bool ScriptingCore::handleMouseEvent(void* nativeObj, cocos2d::EventMouse::Mouse js_proxy_t * p = jsb_get_native_proxy(nativeObj); if (p) { - jsval dataVal[1]; js_type_class_t *typeClass = js_get_type_from_native(event); - dataVal[0] = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, event, typeClass, "cocos2d::Event")); - ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 1, dataVal, jsvalRet); - } + jsval dataVal = OBJECT_TO_JSVAL(jsb_ref_get_or_create_jsobject(_cx, event, typeClass, "cocos2d::Event")); + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 1, &dataVal, jsvalRet); - removeJSObject(_cx, event); + removeJSObject(_cx, event); + } + else CCLOG("ScriptingCore::handleMouseEvent native proxy NOT found"); return ret; } @@ -1572,14 +1563,10 @@ bool ScriptingCore::isObjectValid(JSContext *cx, uint32_t argc, jsval *vp) void ScriptingCore::rootObject(Ref* ref) { - js_proxy_t* nproxy; - js_proxy_t* jsproxy; - void *ptr = (void*)ref; - nproxy = jsb_get_native_proxy(ptr); - if (nproxy) { + auto proxy = jsb_get_native_proxy(ref); + if (proxy) { JSContext *cx = getGlobalContext(); - jsproxy = jsb_get_js_proxy(nproxy->obj); - JS::AddNamedObjectRoot(cx, &jsproxy->obj, typeid(*ref).name()); + JS::AddNamedObjectRoot(cx, &proxy->obj, typeid(*ref).name()); ref->_rooted = true; } else CCLOG("rootObject: BUG. native not found: %p", ref); @@ -1587,15 +1574,10 @@ void ScriptingCore::rootObject(Ref* ref) void ScriptingCore::unrootObject(Ref* ref) { - js_proxy_t* nproxy; - js_proxy_t* jsproxy; - void *ptr = (void*)ref; - - nproxy = jsb_get_native_proxy(ptr); - if (nproxy) { + auto proxy = jsb_get_native_proxy(ref); + if (proxy) { JSContext *cx = getGlobalContext(); - jsproxy = jsb_get_js_proxy(nproxy->obj); - JS::RemoveObjectRoot(cx, &jsproxy->obj); + JS::RemoveObjectRoot(cx, &proxy->obj); ref->_rooted = false; } else CCLOG("unrootObject: BUG. native not found: %p", ref); @@ -1924,63 +1906,94 @@ bool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret) return true; } -js_proxy_t* jsb_new_proxy(void* nativeObj, JS::HandleObject jsObj) +js_proxy_t* jsb_new_proxy(void* nativeObj, JS::HandleObject jsHandle) { - js_proxy_t* p = nullptr; - JSObject* ptr = jsObj.get(); + js_proxy_t* proxy = nullptr; + JSObject* jsObj = jsHandle.get(); - // native to JS index - p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); - assert(p); - js_proxy_t* nativeObjJsObjtmp = NULL; - HASH_FIND_PTR(_native_js_global_ht, &nativeObj, nativeObjJsObjtmp); - assert(!nativeObjJsObjtmp); - p->ptr = nativeObj; - p->obj = ptr; - HASH_ADD_PTR(_native_js_global_ht, ptr, p); + if (nativeObj && jsObj) + { + // native to JS index + proxy = (js_proxy_t *)malloc(sizeof(js_proxy_t)); + CC_ASSERT(proxy && "not enough memory"); - // JS to native Index - p = (js_proxy_t *)malloc(sizeof(js_proxy_t)); - assert(p); - nativeObjJsObjtmp = NULL; - HASH_FIND_PTR(_js_native_global_ht, &ptr, nativeObjJsObjtmp); - assert(!nativeObjJsObjtmp); - p->ptr = nativeObj; - p->obj = ptr; - HASH_ADD_PTR(_js_native_global_ht, obj, p); +#if 0 + if (_js_native_global_map.find(jsObj) != _js_native_global_map.end()) + { + CCLOG("BUG: old:%s new:%s", JS_GetClass(_js_native_global_map.at(jsObj)->_jsobj)->name, JS_GetClass(jsObj)->name); + } +#endif - return p; + CC_ASSERT(_native_js_global_map.find(nativeObj) == _native_js_global_map.end() && "Native Key should not be present"); + CC_ASSERT(_js_native_global_map.find(jsObj) == _js_native_global_map.end() && "JS Key should not be present"); + + proxy->ptr = nativeObj; + proxy->obj = jsObj; + proxy->_jsobj = jsObj; + + // One Proxy in two entries + _native_js_global_map[nativeObj] = proxy; + _js_native_global_map[jsObj] = proxy; + } + else CCLOG("jsb_new_proxy: Invalid keys"); + + return proxy; } js_proxy_t* jsb_get_native_proxy(void* nativeObj) { - js_proxy_t* p = nullptr; - HASH_FIND_PTR(_native_js_global_ht, &nativeObj, p); - return p; + auto search = _native_js_global_map.find(nativeObj); + if(search != _native_js_global_map.end()) + return search->second; + return nullptr; } js_proxy_t* jsb_get_js_proxy(JSObject* jsObj) { - js_proxy_t* p = nullptr; - HASH_FIND_PTR(_js_native_global_ht, &jsObj, p); - return p; + auto search = _js_native_global_map.find(jsObj); + if(search != _js_native_global_map.end()) + return search->second; + return nullptr; } void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy) { - if (nativeProxy) - { - HASH_DEL(_native_js_global_ht, nativeProxy); - free(nativeProxy); - } - else CCLOG("jsb_remove_proxy: BUG: nativeProxy is null"); + js_proxy_t* proxy = nativeProxy ? nativeProxy : jsProxy; + jsb_remove_proxy(proxy); +} - if (jsProxy) +void jsb_remove_proxy(js_proxy_t* proxy) +{ + void* nativeKey = proxy->ptr; + JSObject* jsKey = proxy->_jsobj; + + CC_ASSERT(nativeKey && "Invalid nativeKey"); + CC_ASSERT(jsKey && "Invalid JSKey"); + + auto it_nat = _native_js_global_map.find(nativeKey); + auto it_js = _js_native_global_map.find(jsKey); + +#if 0 + // XXX FIXME: sanity check. Remove me once it is tested that it works Ok + if (it_nat != _native_js_global_map.end() && it_js != _js_native_global_map.end()) { - HASH_DEL(_js_native_global_ht, jsProxy); - free(jsProxy); + CC_ASSERT(it_nat->second == it_js->second && "BUG. Different enties"); } - else CCLOG("jsb_remove_proxy: BUG: jsProxy is null"); +#endif + + if (it_nat != _native_js_global_map.end()) + { + _native_js_global_map.erase(it_nat); + } + else CCLOG("jsb_remove_proxy: failed. Native key not found"); + + if (it_js != _js_native_global_map.end()) + { + // Free it once, since we only have one proxy alloced entry + free(it_js->second); + _js_native_global_map.erase(it_js); + } + else CCLOG("jsb_remove_proxy: failed. JS key not found"); } // @@ -2012,8 +2025,13 @@ JSObject* jsb_ref_autoreleased_create_jsobject(JSContext *cx, cocos2d::Ref *ref, JSObject* jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug) { auto proxy = jsb_get_native_proxy(ref); - if (proxy) + if (proxy) { +#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS + // needed, since removeObject() might "unown it" + ref->_scriptOwned = true; +#endif // return proxy->obj; + } // don't auto-release, don't retain. JS::RootedObject proto(cx, typeClass->proto.ref()); @@ -2081,36 +2099,30 @@ void jsb_ref_autoreleased_init(JSContext* cx, JS::Heap *obj, Ref* ref void jsb_ref_finalize(JSFreeOp* fop, JSObject* obj) { #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS - js_proxy_t* nproxy; - js_proxy_t* jsproxy; - - jsproxy = jsb_get_js_proxy(obj); - if (jsproxy) + auto proxy = jsb_get_js_proxy(obj); + if (proxy) { - auto ref = static_cast(jsproxy->ptr); - nproxy = jsb_get_native_proxy(jsproxy->ptr); - + auto ref = static_cast(proxy->ptr); + jsb_remove_proxy(proxy); if (ref) - { - jsb_remove_proxy(nproxy, jsproxy); ref->release(); - } - else - jsb_remove_proxy(nullptr, jsproxy); } - else CCLOG("jsb_ref_finalize: BUG: proxy not found for %p", obj); + else + { + CCLOG("jsb_ref_finalize: BUG: proxy not found for %p (%s)", obj, JS_GetClass(obj)->name); + } #else // CCLOG("jsb_ref_finalize: JSObject address = %p", obj); #endif } // rebind -void jsb_ref_rebind(JSContext* cx, JS::HandleObject jsobj, js_proxy_t *js2native_proxy, cocos2d::Ref* oldRef, cocos2d::Ref* newRef, const char* debug) +void jsb_ref_rebind(JSContext* cx, JS::HandleObject jsobj, js_proxy_t *proxy, cocos2d::Ref* oldRef, cocos2d::Ref* newRef, const char* debug) { #if not CC_ENABLE_GC_FOR_NATIVE_OBJECTS - JS::RemoveObjectRoot(cx, &js2native_proxy->obj); + JS::RemoveObjectRoot(cx, &proxy->obj); #endif - jsb_remove_proxy(jsb_get_native_proxy(oldRef), js2native_proxy); + jsb_remove_proxy(proxy); // Rebind js obj with new action js_proxy_t* newProxy = jsb_new_proxy(newRef, jsobj); diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.h b/cocos/scripting/js-bindings/manual/ScriptingCore.h index 9b8e500c6b..bb03a5fac8 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.h +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.h @@ -562,10 +562,17 @@ js_type_class_t *jsb_register_class(JSContext *cx, JSClass *jsClass, JS::HandleO return p; } +/** creates two new proxies: one associaged with the nativeObj, + and another one associated with the JsObj */ js_proxy_t* jsb_new_proxy(void* nativeObj, JS::HandleObject jsObj); +/** returns the proxy associated with the Native* */ js_proxy_t* jsb_get_native_proxy(void* nativeObj); +/** returns the proxy associated with the JSObject* */ js_proxy_t* jsb_get_js_proxy(JSObject* jsObj); +/** deprecated: use jsb_remove_proxy(js_proxy_t* proxy) instead */ void jsb_remove_proxy(js_proxy_t* nativeProxy, js_proxy_t* jsProxy); +/** removes both the native and js proxies */ +void jsb_remove_proxy(js_proxy_t* proxy); /** * Generic initialization function for subclasses of Ref diff --git a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp index 4b46a0f9e5..918a287806 100644 --- a/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp +++ b/cocos/scripting/js-bindings/manual/cocos2d_specifics.cpp @@ -5549,20 +5549,15 @@ bool js_cocos2dx_PolygonInfo_constructor(JSContext *cx, uint32_t argc, jsval *vp void js_cocos2d_PolygonInfo_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (PolygonInfo)", obj); - js_proxy_t* nproxy; - js_proxy_t* jsproxy; JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JS::RootedObject jsobj(cx, obj); - jsproxy = jsb_get_js_proxy(jsobj); - if (jsproxy) + auto proxy = jsb_get_js_proxy(jsobj); + if (proxy) { - nproxy = jsb_get_native_proxy(jsproxy->ptr); - - cocos2d::PolygonInfo *nobj = static_cast(nproxy->ptr); + cocos2d::PolygonInfo *nobj = static_cast(proxy->ptr); if (nobj) delete nobj; - - jsb_remove_proxy(nproxy, jsproxy); + jsb_remove_proxy(proxy); } } @@ -5712,19 +5707,14 @@ bool js_cocos2dx_AutoPolygon_constructor(JSContext *cx, uint32_t argc, jsval *vp void js_cocos2d_AutoPolygon_finalize(JSFreeOp *fop, JSObject *obj) { CCLOGINFO("jsbindings: finalizing JS object %p (AutoPolygon)", obj); - js_proxy_t* nproxy; - js_proxy_t* jsproxy; JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JS::RootedObject jsobj(cx, obj); - jsproxy = jsb_get_js_proxy(jsobj); - if (jsproxy) { - nproxy = jsb_get_native_proxy(jsproxy->ptr); - - cocos2d::AutoPolygon *nobj = static_cast(nproxy->ptr); + auto proxy = jsb_get_js_proxy(jsobj); + if (proxy) { + cocos2d::AutoPolygon *nobj = static_cast(proxy->ptr); if (nobj) delete nobj; - - jsb_remove_proxy(nproxy, jsproxy); + jsb_remove_proxy(proxy); } } diff --git a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp index 1f3ef212ad..67bade919d 100644 --- a/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp +++ b/cocos/scripting/js-bindings/manual/component/CCComponentJS.cpp @@ -88,12 +88,9 @@ ComponentJS::~ComponentJS() if (jsObj && !jsObj->empty()) { // Remove proxy - js_proxy_t* jsproxy = jsb_get_js_proxy(jsObj->ref()); - if (jsproxy) - { - js_proxy_t* nproxy = jsb_get_native_proxy(jsproxy->ptr); - jsb_remove_proxy(nproxy, jsproxy); - } + js_proxy_t* proxy = jsb_get_js_proxy(jsObj->ref()); + if (proxy) + jsb_remove_proxy(proxy); } // Delete rooted object if (jsObj != nullptr) diff --git a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp index fcaffca5ed..551eb0d499 100644 --- a/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp +++ b/cocos/scripting/js-bindings/manual/network/jsb_websocket.cpp @@ -139,10 +139,9 @@ public: jsval args = OBJECT_TO_JSVAL(jsobj); ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate.ref()), "onclose", 1, &args); - JS::RootedObject wsobj(cx, p->obj); - js_proxy_t* jsproxy = jsb_get_js_proxy(wsobj); - JS::RemoveObjectRoot(cx, &jsproxy->obj); - jsb_remove_proxy(p, jsproxy); + auto copy = &p->obj; + jsb_remove_proxy(p); + JS::RemoveObjectRoot(cx, copy); CC_SAFE_DELETE(ws); } diff --git a/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h b/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h index 9e9a529e90..1506d8214a 100644 --- a/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h +++ b/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h @@ -25,14 +25,22 @@ #include "jsapi.h" #include "jsfriendapi.h" -#include "uthash.h" #include "mozilla/Maybe.h" #include +// No need to keep this struct +// since we are using unordered_map now +// but can't remove it since easily since lot's of code depends on it typedef struct js_proxy { + /** the native object. usually a pointer to cocos2d::Ref, but could be a pointer to another object */ void *ptr; + /** the JS object, as a heap object. Required by GC best practices */ JS::Heap obj; - UT_hash_handle hh; + /** This is the raw pointer. The same as the "obj", but 'raw'. This is needed + because under certain circumstances JS::RemoveRootObject will be called on "obj" + and "obj" will became NULL. Which is not Ok if we need to use "obj" later for other stuff + */ + JSObject* _jsobj; } js_proxy_t; typedef struct js_type_class { From 1ba3f2badb9f8d86c7707330335a4dd37537ce48 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 16 Dec 2015 17:47:50 -0800 Subject: [PATCH 41/66] minor fixes --- cocos/scripting/js-bindings/manual/ScriptingCore.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index a5d0ab8c64..f7dc5e5cfa 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -221,7 +221,6 @@ static void removeJSObject(JSContext* cx, cocos2d::Ref* nativeObj) if (proxy) { #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS - nativeObj->_rooted = false; // remove the proxy here, since this was a "stack" object, not heap // when js_finalize will be called, it will fail, but // the correct solution is to have a new finalize for event @@ -2025,13 +2024,8 @@ JSObject* jsb_ref_autoreleased_create_jsobject(JSContext *cx, cocos2d::Ref *ref, JSObject* jsb_ref_get_or_create_jsobject(JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char* debug) { auto proxy = jsb_get_native_proxy(ref); - if (proxy) { -#if CC_ENABLE_GC_FOR_NATIVE_OBJECTS - // needed, since removeObject() might "unown it" - ref->_scriptOwned = true; -#endif // + if (proxy) return proxy->obj; - } // don't auto-release, don't retain. JS::RootedObject proto(cx, typeClass->proto.ref()); From d943381c65e3d45cfb52a122ad2d35e9c4e614a9 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 16 Dec 2015 20:03:09 -0800 Subject: [PATCH 42/66] Update spidermonkey_specifics.h updated docstrings --- cocos/scripting/js-bindings/manual/spidermonkey_specifics.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h b/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h index 1506d8214a..e6a2292c54 100644 --- a/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h +++ b/cocos/scripting/js-bindings/manual/spidermonkey_specifics.h @@ -28,9 +28,8 @@ #include "mozilla/Maybe.h" #include -// No need to keep this struct -// since we are using unordered_map now -// but can't remove it since easily since lot's of code depends on it +// Probably we can get rid of this struct, but since a lot of code +// depends on it, we cannot remove it easily typedef struct js_proxy { /** the native object. usually a pointer to cocos2d::Ref, but could be a pointer to another object */ void *ptr; From df98bf098b7305b39c26ab786e75f68db14d87f1 Mon Sep 17 00:00:00 2001 From: zhangcheng Date: Thu, 17 Dec 2015 14:07:01 +0800 Subject: [PATCH 43/66] Update web submodule to latest. --- web | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web b/web index 5ff018e81b..1fb1d53dee 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 5ff018e81bad24816373362146f2589e17706dfa +Subproject commit 1fb1d53dee1893dbec0012f1bbdad957e25c355a From a172cce8745189ea64f06f8d3c65d13b602392eb Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 4 Dec 2015 19:15:16 +0300 Subject: [PATCH 44/66] fix web socket crash --- cocos/network/WebSocket.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cocos/network/WebSocket.cpp b/cocos/network/WebSocket.cpp index b61c592589..6695986dbe 100644 --- a/cocos/network/WebSocket.cpp +++ b/cocos/network/WebSocket.cpp @@ -248,9 +248,12 @@ WebSocket::~WebSocket() close(); CC_SAFE_RELEASE_NULL(_wsHelper); - for (int i = 0; _wsProtocols[i].callback != nullptr; ++i) + if(_wsProtocols) { - CC_SAFE_DELETE_ARRAY(_wsProtocols[i].name); + for (int i = 0; _wsProtocols[i].callback != nullptr; ++i) + { + CC_SAFE_DELETE_ARRAY(_wsProtocols[i].name); + } } CC_SAFE_DELETE_ARRAY(_wsProtocols); } From b4f762befa8676addaf44aac73d0333a84d334fc Mon Sep 17 00:00:00 2001 From: Sergey Date: Thu, 10 Sep 2015 10:22:49 +0300 Subject: [PATCH 45/66] fix include in cocos network module --- cocos/network/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/network/Android.mk b/cocos/network/Android.mk index 835af9b73b..7278fda31a 100644 --- a/cocos/network/Android.mk +++ b/cocos/network/Android.mk @@ -11,7 +11,7 @@ WebSocket.cpp \ CCDownloader.cpp \ CCDownloader-android.cpp -LOCAL_EXPORT_C_INCLUDES := +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../external/curl/include/android \ $(LOCAL_PATH)/../../external/websockets/include/android From 3e049f80495cdf8bae9f43d84fa10eb60667d956 Mon Sep 17 00:00:00 2001 From: Sergey Date: Mon, 7 Dec 2015 18:12:21 +0300 Subject: [PATCH 46/66] slider misprint fix --- cocos/ui/UISlider.cpp | 8 ++++---- cocos/ui/UISlider.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/ui/UISlider.cpp b/cocos/ui/UISlider.cpp index 07ca7c3077..5eb9528329 100644 --- a/cocos/ui/UISlider.cpp +++ b/cocos/ui/UISlider.cpp @@ -258,7 +258,7 @@ void Slider::setScale9Enabled(bool able) ignoreContentAdaptWithSize(_prevIgnoreSize); } setCapInsetsBarRenderer(_capInsetsBarRenderer); - setCapInsetProgressBarRebderer(_capInsetsProgressBarRenderer); + setCapInsetProgressBarRenderer(_capInsetsProgressBarRenderer); _barRendererAdaptDirty = true; _progressBarRendererDirty = true; } @@ -280,7 +280,7 @@ void Slider::ignoreContentAdaptWithSize(bool ignore) void Slider::setCapInsets(const Rect &capInsets) { setCapInsetsBarRenderer(capInsets); - setCapInsetProgressBarRebderer(capInsets); + setCapInsetProgressBarRenderer(capInsets); } void Slider::setCapInsetsBarRenderer(const Rect &capInsets) @@ -298,7 +298,7 @@ const Rect& Slider::getCapInsetsBarRenderer()const return _capInsetsBarRenderer; } -void Slider::setCapInsetProgressBarRebderer(const Rect &capInsets) +void Slider::setCapInsetProgressBarRenderer(const Rect &capInsets) { _capInsetsProgressBarRenderer = ui::Helper::restrictCapInsetRect(capInsets, _progressBarRenderer->getContentSize()); if (!_scale9Enabled) @@ -308,7 +308,7 @@ void Slider::setCapInsetProgressBarRebderer(const Rect &capInsets) _progressBarRenderer->setCapInsets(_capInsetsProgressBarRenderer); } -const Rect& Slider::getCapInsetsProgressBarRebderer()const +const Rect& Slider::getCapInsetsProgressBarRenderer()const { return _capInsetsProgressBarRenderer; } diff --git a/cocos/ui/UISlider.h b/cocos/ui/UISlider.h index f06a337bfd..d35b514d87 100644 --- a/cocos/ui/UISlider.h +++ b/cocos/ui/UISlider.h @@ -143,14 +143,14 @@ public: * @param capInsets Capinsets for progress bar slider. * @js NA */ - void setCapInsetProgressBarRebderer(const Rect &capInsets); + void setCapInsetProgressBarRenderer(const Rect &capInsets); /** * Gets capinsets for progress bar slider, if slider is using scale9 renderer. * @return Capinsets for progress bar slider. * @js NA */ - const Rect& getCapInsetsProgressBarRebderer()const; + const Rect& getCapInsetsProgressBarRenderer()const; /** * Load textures for slider ball. From 6c08dd920e3c9012f742d1f4a964a5e6b9929c51 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Thu, 17 Dec 2015 18:29:23 +0800 Subject: [PATCH 47/66] Fix TextField missing default password style text setting --- cocos/ui/UITextField.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index dc13ee6b07..b2af80a606 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -299,7 +299,7 @@ _useTouchArea(false), _textFieldEventListener(nullptr), _textFieldEventSelector(nullptr), _eventCallback(nullptr), -_passwordStyleText(""), +_passwordStyleText("*"), _textFieldRendererAdaptDirty(true), _fontName("Thonburi"), _fontSize(10), From 98fe1d46cc9074e65f2a222ebac3c6064ddf7069 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 18 Dec 2015 00:32:59 +0300 Subject: [PATCH 48/66] Scale9Sprite now fully support cropped sprite frames in both mode simple & slice --- cocos/ui/UIScale9Sprite.cpp | 217 ++++++++++++------ cocos/ui/UIScale9Sprite.h | 5 +- .../CocoStudioGUITest/UIScale9SpriteTest.cpp | 94 +++++++- .../CocoStudioGUITest/UIScale9SpriteTest.h | 41 ++++ .../cpp-tests/Resources/Images/blocks9cr.png | Bin 0 -> 1208 bytes .../Resources/Images/blocks9ss.plist | 16 +- tests/cpp-tests/Resources/Images/blocks9с.png | Bin 0 -> 1191 bytes .../Resources/hd/Images/blocks9c.png | Bin 0 -> 4312 bytes .../Resources/hd/Images/blocks9cr.png | Bin 0 -> 2262 bytes .../Resources/hd/Images/blocks9r.png | Bin 0 -> 3141 bytes .../Resources/hd/Images/blocks9ss.plist | 16 +- 11 files changed, 297 insertions(+), 92 deletions(-) create mode 100644 tests/cpp-tests/Resources/Images/blocks9cr.png create mode 100644 tests/cpp-tests/Resources/Images/blocks9с.png create mode 100644 tests/cpp-tests/Resources/hd/Images/blocks9c.png create mode 100644 tests/cpp-tests/Resources/hd/Images/blocks9cr.png create mode 100644 tests/cpp-tests/Resources/hd/Images/blocks9r.png diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index aef00adf7a..dd10bd886c 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -454,6 +454,7 @@ namespace ui { _spriteFrameRotated = rotated; _originalSize = size; _preferredSize = size; + _offset = offset; _capInsetsInternal = capInsets; @@ -503,23 +504,31 @@ namespace ui { auto capInsets = CC_RECT_POINTS_TO_PIXELS(_capInsetsInternal); auto textureRect = CC_RECT_POINTS_TO_PIXELS(_spriteRect); - auto spriteRectSize = CC_SIZE_POINTS_TO_PIXELS(_originalSize); + auto spriteRectSize = _spriteRect.size; + auto originalSize = CC_SIZE_POINTS_TO_PIXELS(_originalSize); + auto offset = CC_POINT_POINTS_TO_PIXELS(_offset); + + Vec4 offsets; + offsets.x = offset.x + (originalSize.width - textureRect.size.width) / 2; + offsets.w = offset.y + (originalSize.height - textureRect.size.height) / 2; + offsets.z = originalSize.width - textureRect.size.width - offsets.x; + offsets.y = originalSize.height - textureRect.size.height - offsets.w; //handle .9.png if (_isPatch9) { - spriteRectSize = Size(spriteRectSize.width - 2, spriteRectSize.height-2); + originalSize = Size(originalSize.width - 2, originalSize.height-2); } if(capInsets.equals(Rect::ZERO)) { - capInsets = Rect(spriteRectSize.width/3, spriteRectSize.height/3, - spriteRectSize.width/3, spriteRectSize.height/3); + capInsets = Rect(originalSize.width/3, originalSize.height/3, + originalSize.width/3, originalSize.height/3); } - auto uv = this->calculateUV(tex, capInsets, spriteRectSize); - auto vertices = this->calculateVertices(capInsets, spriteRectSize); + auto uv = this->calculateUV(tex, capInsets, originalSize, offsets); + auto vertices = this->calculateVertices(capInsets, originalSize, offsets); auto triangles = this->calculateTriangles(uv, vertices); _scale9Image->getPolygonInfo().setTriangles(triangles); @@ -633,7 +642,7 @@ namespace ui { this->updateWithSprite(this->_scale9Image, _spriteRect, _spriteFrameRotated, - Vec2::ZERO, + _offset, _originalSize, capInsets); this->_insetLeft = capInsets.origin.x; @@ -1062,7 +1071,8 @@ namespace ui { // u0 u1 u2 u3 std::vector Scale9Sprite::calculateUV(Texture2D *tex, const Rect& capInsets, - const Size& spriteRectSize) + const Size& originalSize, + const Vec4& offsets) { auto atlasWidth = tex->getPixelsWide(); auto atlasHeight = tex->getPixelsHigh(); @@ -1073,23 +1083,46 @@ namespace ui { if (_spriteFrameRotated) { - rightWidth = capInsets.origin.y; + rightWidth = capInsets.origin.y - offsets.y; centerWidth = capInsets.size.height; - leftWidth = spriteRectSize.height - centerWidth - rightWidth; + leftWidth = originalSize.height - centerWidth - capInsets.origin.y - offsets.w; - topHeight = capInsets.origin.x; + topHeight = capInsets.origin.x - offsets.x; centerHeight = capInsets.size.width; - bottomHeight = spriteRectSize.width - (topHeight + centerHeight); + bottomHeight = originalSize.width - (capInsets.origin.x + centerHeight) - offsets.z; } else { - leftWidth = capInsets.origin.x; + leftWidth = capInsets.origin.x - offsets.x; centerWidth = capInsets.size.width; - rightWidth = spriteRectSize.width - (leftWidth + centerWidth); + rightWidth = originalSize.width - (capInsets.origin.x + centerWidth) - offsets.z; - topHeight = capInsets.origin.y; + topHeight = capInsets.origin.y - offsets.y; centerHeight = capInsets.size.height; - bottomHeight =spriteRectSize.height - (topHeight + centerHeight); + bottomHeight = originalSize.height - (capInsets.origin.x + centerHeight) - offsets.w; + } + + + if(leftWidth<0) + { + centerWidth += leftWidth; + leftWidth = 0; + } + if(rightWidth<0) + { + centerWidth += rightWidth; + rightWidth = 0; + } + + if(topHeight<0) + { + centerHeight += topHeight; + topHeight = 0; + } + if(bottomHeight<0) + { + centerHeight += bottomHeight; + bottomHeight = 0; } auto textureRect = CC_RECT_POINTS_TO_PIXELS(_spriteRect); @@ -1159,67 +1192,111 @@ namespace ui { //x0,y0-------------------- // x1 x2 x3 std::vector Scale9Sprite::calculateVertices(const Rect& capInsets, - const Size& spriteRectSize) + const Size& originalSize, + const Vec4& offsets) { - float leftWidth = 0, centerWidth = 0, rightWidth = 0; - float topHeight = 0, centerHeight = 0, bottomHeight = 0; - - leftWidth = capInsets.origin.x; - centerWidth = capInsets.size.width; - rightWidth = spriteRectSize.width - (leftWidth + centerWidth); - - topHeight = capInsets.origin.y; - centerHeight = capInsets.size.height; - bottomHeight = spriteRectSize.height - (topHeight + centerHeight); - - - leftWidth = leftWidth / CC_CONTENT_SCALE_FACTOR(); - rightWidth = rightWidth / CC_CONTENT_SCALE_FACTOR(); - topHeight = topHeight / CC_CONTENT_SCALE_FACTOR(); - bottomHeight = bottomHeight / CC_CONTENT_SCALE_FACTOR(); - float sizableWidth = _preferredSize.width - leftWidth - rightWidth; - float sizableHeight = _preferredSize.height - topHeight - bottomHeight; - float x0,x1,x2,x3; - float y0,y1,y2,y3; - if(sizableWidth >= 0) - { - x0 = 0; - x1 = leftWidth; - x2 = leftWidth + sizableWidth; - x3 = _preferredSize.width; - } - else - { - float xScale = _preferredSize.width / (leftWidth + rightWidth); - x0 = 0; - x1 = x2 = leftWidth * xScale; - x3 = (leftWidth + rightWidth) * xScale; - } - - if(sizableHeight >= 0) - { - y0 = 0; - y1 = bottomHeight; - y2 = bottomHeight + sizableHeight; - y3 = _preferredSize.height; - } - else - { - float yScale = _preferredSize.height / (topHeight + bottomHeight); - y0 = 0; - y1 = y2= bottomHeight * yScale; - y3 = (bottomHeight + topHeight) * yScale; - } - - std::vector vertices; + float offsetLeft = offsets.x / CC_CONTENT_SCALE_FACTOR(); + float offsetTop = offsets.y / CC_CONTENT_SCALE_FACTOR(); + float offsetRight = offsets.z / CC_CONTENT_SCALE_FACTOR(); + float offsetBottom = offsets.w / CC_CONTENT_SCALE_FACTOR(); + + std::vector vertices; if (_renderingType == RenderingType::SIMPLE) { - vertices = {Vec2(x0,y0), Vec2(x3,y3)}; + float hScale = _preferredSize.width / (originalSize.width / CC_CONTENT_SCALE_FACTOR()); + float vScale = _preferredSize.height / (originalSize.height / CC_CONTENT_SCALE_FACTOR()); + + vertices = {Vec2(offsetLeft * hScale, offsetBottom * vScale), + Vec2(_preferredSize.width - offsetRight * hScale, _preferredSize.height - offsetTop * vScale)}; } else { - vertices = {Vec2(x0,y0), Vec2(x1,y1), Vec2(x2,y2), Vec2(x3,y3)}; + float leftWidth = 0, centerWidth = 0, rightWidth = 0; + float topHeight = 0, centerHeight = 0, bottomHeight = 0; + + leftWidth = capInsets.origin.x; + centerWidth = capInsets.size.width; + rightWidth = originalSize.width - (leftWidth + centerWidth); + + topHeight = capInsets.origin.y; + centerHeight = capInsets.size.height; + bottomHeight = originalSize.height - (topHeight + centerHeight); + + leftWidth = leftWidth / CC_CONTENT_SCALE_FACTOR(); + rightWidth = rightWidth / CC_CONTENT_SCALE_FACTOR(); + centerWidth = centerWidth / CC_CONTENT_SCALE_FACTOR(); + topHeight = topHeight / CC_CONTENT_SCALE_FACTOR(); + bottomHeight = bottomHeight / CC_CONTENT_SCALE_FACTOR(); + centerHeight = centerHeight / CC_CONTENT_SCALE_FACTOR(); + + float sizableWidth = _preferredSize.width - leftWidth - rightWidth; + float sizableHeight = _preferredSize.height - topHeight - bottomHeight; + + leftWidth -= offsetLeft; + rightWidth -= offsetRight; + topHeight -= offsetTop; + bottomHeight -= offsetBottom; + + float hScale = sizableWidth / centerWidth; + float vScale = sizableHeight / centerHeight; + + if(leftWidth<0) + { + offsetLeft -= leftWidth * (hScale - 1.0f); + sizableWidth += leftWidth * hScale; + leftWidth = 0; + } + if(rightWidth<0) + { + sizableWidth += rightWidth * hScale; + rightWidth = 0; + } + if(topHeight<0) + { + sizableHeight += topHeight * vScale; + topHeight = 0; + } + if(bottomHeight<0) + { + offsetBottom -= bottomHeight * (vScale - 1.0f); + sizableHeight += bottomHeight * vScale; + bottomHeight = 0; + } + + float x0,x1,x2,x3; + float y0,y1,y2,y3; + if(sizableWidth >= 0) + { + x0 = offsetLeft; + x1 = x0 + leftWidth; + x2 = x1 + sizableWidth; + x3 = x2 + rightWidth; + } + else + { + float xScale = _preferredSize.width / (leftWidth + rightWidth); + x0 = offsetLeft; + x1 = x2 = offsetLeft + leftWidth * xScale; + x3 = x2 + rightWidth * xScale; + } + + if(sizableHeight >= 0) + { + y0 = offsetBottom; + y1 = y0 + bottomHeight; + y2 = y1 + sizableHeight; + y3 = y2 + topHeight; + } + else + { + float yScale = _preferredSize.height / (topHeight + bottomHeight); + y0 = offsetBottom; + y1 = y2 = y0 + bottomHeight * yScale; + y3 = y2 + topHeight * yScale; + } + + vertices = {Vec2(x0,y0), Vec2(x1,y1), Vec2(x2,y2), Vec2(x3,y3)}; } return vertices; } diff --git a/cocos/ui/UIScale9Sprite.h b/cocos/ui/UIScale9Sprite.h index 4404ac9a64..1dc5d851e9 100644 --- a/cocos/ui/UIScale9Sprite.h +++ b/cocos/ui/UIScale9Sprite.h @@ -685,8 +685,8 @@ namespace ui { void applyBlendFunc(); void updateBlendFunc(Texture2D *texture); std::vector calculateUV(Texture2D *tex, const Rect& capInsets, - const Size& spriteRectSize); - std::vector calculateVertices(const Rect& capInsets, const Size& spriteRectSize); + const Size& originalSize, const Vec4& offsets); + std::vector calculateVertices(const Rect& capInsets, const Size& originalSize, const Vec4& offsets); TrianglesCommand::Triangles calculateTriangles(const std::vector& uv, const std::vector& vertices); @@ -701,6 +701,7 @@ namespace ui { /** Original sprite's size. */ Size _originalSize; + Vec2 _offset; /** Preferred sprite's size. By default the preferred size is the original size. */ //if the preferredSize component is given as -1, it is ignored diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index 4357efc8ef..70e38afe42 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -38,6 +38,10 @@ UIScale9SpriteTests::UIScale9SpriteTests() ADD_TEST_CASE(UIS9FrameNameSpriteSheetRotated); ADD_TEST_CASE(UIS9FrameNameSpriteSheetCropped); ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedRotated); + ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedImage); + ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedRotatedImage); + ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedSimple); + ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedRotatedSimple); ADD_TEST_CASE(UIS9BatchNodeScaledNoInsets); ADD_TEST_CASE(UIS9FrameNameSpriteSheetScaledNoInsets); ADD_TEST_CASE(UIS9FrameNameSpriteSheetRotatedScaledNoInsets); @@ -330,6 +334,8 @@ bool UIS9FrameNameSpriteSheetRotated::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9r.png"); + blocks->setPreferredSize(Size(400,80)); + blocks->setPosition(Vec2(x, y)); this->addChild(blocks); @@ -350,9 +356,8 @@ bool UIS9FrameNameSpriteSheetCropped::init() SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9c.png"); - blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); + blocks->setPreferredSize(Size(400,80)); blocks->setPosition(Vec2(x, y)); - blocks->setCapInsets(Rect(5,5,5,5)); this->addChild(blocks); return true; @@ -371,9 +376,90 @@ bool UIS9FrameNameSpriteSheetCroppedRotated::init() SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9cr.png"); - blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); + blocks->setPreferredSize(Size(400,80)); + blocks->setPosition(Vec2(x, y)); + this->addChild(blocks); + + return true; + } + + return false; +} + +bool UIS9FrameNameSpriteSheetCroppedImage::init() +{ + if (UIScene::init()) { + auto winSize = Director::getInstance()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); + + auto blocks = Sprite::createWithSpriteFrameName("blocks9c.png"); + blocks->setScale(400/blocks->getContentSize().width, 80/blocks->getContentSize().height); + blocks->setPosition(Vec2(x, y)); + this->addChild(blocks); + + return true; + } + + return false; +} + +bool UIS9FrameNameSpriteSheetCroppedRotatedImage::init() +{ + if (UIScene::init()) { + auto winSize = Director::getInstance()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); + + auto blocks = Sprite::createWithSpriteFrameName("blocks9cr.png"); + blocks->setScale(400/blocks->getContentSize().width, 80/blocks->getContentSize().height); + blocks->setPosition(Vec2(x, y)); + this->addChild(blocks); + + return true; + } + + return false; +} + +bool UIS9FrameNameSpriteSheetCroppedSimple::init() +{ + if (UIScene::init()) { + auto winSize = Director::getInstance()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); + + auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9c.png"); + blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); + blocks->setPreferredSize(Size(400,80)); + blocks->setPosition(Vec2(x, y)); + this->addChild(blocks); + + return true; + } + + return false; +} + +bool UIS9FrameNameSpriteSheetCroppedRotatedSimple::init() +{ + if (UIScene::init()) { + auto winSize = Director::getInstance()->getWinSize(); + float x = winSize.width / 2; + float y = 0 + (winSize.height / 2); + + SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); + + auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9cr.png"); + blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); + blocks->setPreferredSize(Size(400,80)); blocks->setPosition(Vec2(x, y)); - blocks->setInsetBottom(10); this->addChild(blocks); return true; diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h index 66e6d238df..8d6f872b15 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h @@ -91,6 +91,47 @@ public: virtual bool init() override; }; +// S9FrameNameSpriteSheetCropped + +class UIS9FrameNameSpriteSheetCroppedImage : public UIScene +{ +public: + CREATE_FUNC(UIS9FrameNameSpriteSheetCroppedImage); + + virtual bool init() override; +}; + +// S9FrameNameSpriteSheetCroppedRotated + +class UIS9FrameNameSpriteSheetCroppedRotatedImage : public UIScene +{ +public: + CREATE_FUNC(UIS9FrameNameSpriteSheetCroppedRotatedImage); + + virtual bool init() override; +}; + +// S9FrameNameSpriteSheetCropped + +class UIS9FrameNameSpriteSheetCroppedSimple : public UIScene +{ +public: + CREATE_FUNC(UIS9FrameNameSpriteSheetCroppedSimple); + + virtual bool init() override; +}; + +// S9FrameNameSpriteSheetCroppedRotated + +class UIS9FrameNameSpriteSheetCroppedRotatedSimple : public UIScene +{ +public: + CREATE_FUNC(UIS9FrameNameSpriteSheetCroppedRotatedSimple); + + virtual bool init() override; +}; + + // S9FrameNameSpriteSheetCropped class UIS9FrameNameSpriteSheetCropped : public UIScene diff --git a/tests/cpp-tests/Resources/Images/blocks9cr.png b/tests/cpp-tests/Resources/Images/blocks9cr.png new file mode 100644 index 0000000000000000000000000000000000000000..0f25bdc6b9564a102cad1fc7dcebd72b1ed51338 GIT binary patch literal 1208 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wSy!iOI#yLg7ec#$`gxH85~pclTsBt za}(23gHjVyDhp4h+AuIMt7L{mltlRYSS9D@>Lr5I=vCwv0Ch7k*w|MTBqnF4mMA2p zrf25aD!t#mUr8Y|#a1cY)Yrhbz&SM|)1#^=HMq(zB)KX(*)m1R-cG@$!U||WZfZ%Q zLPc&)Ua?h$trFN=DVPg@)As;uP=V3xw&xF#U(+h2=`(&xHzP;AXPso zwK%`DC>a=WY04n03ap%qQWHz^i$e1Ab6}wukda@KU!0L&px_*Arl8@Qn4Fmh63_(e z@b$Iw%quQQ%u7!7bg@+enxU7OnPO#XXy#~aVPJ0QVq|P+=xXX{=IrWd>}+A;YGCYU zZsY{h>yn>bnwy$e0@Is<&})HHFDNnO765H_NiE7OOHFYr%Fk5*d)g`!w_8kcng`XJ zg4-=-IQ8lS9itD5TBN9k2?5g&hzU=)Kn^_Vr{)3Edl4{UpPUh>4$Ksy0X`wF>R(>u zL@xXP|NrbI^MGPs)ZYTxMZdp)0CLz%g8YJkTp(bO@@94e3Vri*aSW-r^=8IHz7_?Z z=5mAgf8~D`bRH9KYKv@K!uzW@e%q#58u1%i7??N|8sNl((1x6#$ugq=%3u;`$@#S6YYiR}Gdf2Qr5>l)l5TXyl?8^&GC>)9{K3b?b>XmPO$Iy7)^cxSbX zS#~S4Eyu>eFL~{IV8GZg{hbVav^CLxyLDA`gsyiXDhzD8I0eed(`$rjpg`XXt3@ zecGHkYx;ZPGA`By)(^}p!x-xO%31%gNH8?rSdrMf`?3%)1Qblocks9c.png frame - {{103,189},{50,60}} + {{101,197},{58, 48}} offset - {13,18} + {15, -20} rotated sourceColorRect - {{0,0},{192,192}} + {{34, 44}, {58, 48}} sourceSize - {96,96} + {96, 96} blocks9cr.png frame - {{103,91},{50,60}} + {{71,89},{58, 48}} offset - {13,18} + {15, -20} rotated sourceColorRect - {{0,0},{96,96}} + {{34, 44}, {58, 48}} sourceSize - {96,96} + {96, 96} grossini_dance_01.png diff --git a/tests/cpp-tests/Resources/Images/blocks9с.png b/tests/cpp-tests/Resources/Images/blocks9с.png new file mode 100644 index 0000000000000000000000000000000000000000..39674a445c4d61bf25e0739168c8515514dde30c GIT binary patch literal 1191 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wSy!iOI#yLg7ec#$`gxH85~pclTsBt za}(23gHjVyDhp4h+AuIMt7L{mltlRYSS9D@>Lr5I=vCwv0Ch7k*w|MTBqnF4mMA2p zrf25aD!t#mUr8Y|#a1cY)Yrhbz&SM|)1#^=HMq(zB)KX(*)m1R-cG@$!U||WZfZ%Q zLPc&)Ua?h$trFN=DVPg@)As;uP=V3xw&xF#U(+h2=`(&xHzP;AXPso zwK%`DC>a=WY04n03ap%qQWHz^i$e1Ab6}wukda@KU!0L&px_*Arl8@Qn4Fmh63_(e z@b$Iw%quQQ%u7!7bg@+enxU7OnPO#XXy#~aVPI_OVq|P+=xXX{=IrWd>}+A;YGCYU zZsY{h>yn>bnwy$e0@Is<&})KIFDNnO765H_NiE7OOHFYr%Fk5*d)g`!w_6Nxng`XJ zg4-=dIQ8lS9itD5TBN9k2?5g&hzU=)Kn^_Vr{)3Edl4{UtF76t1k4md0X`wF>R(=b zQGfgY|Nq%b<^jckjDnu{A3zpcNswPKko*5X!{+@<_5(#;db&7_nzzf>WK}S*=jElHJs! zUMIezXWcHDSLfNzF#^s1pr8bP0l+XkK%S(?Q literal 0 HcmV?d00001 diff --git a/tests/cpp-tests/Resources/hd/Images/blocks9c.png b/tests/cpp-tests/Resources/hd/Images/blocks9c.png new file mode 100644 index 0000000000000000000000000000000000000000..2dca8583566ca59580597fb48219b33f7f48ba3d GIT binary patch literal 4312 zcmd^CXIN8Pmkvdm(t8h~CP3&Qp-2k?N|7ciEhIrAC6GjED##TTQMiCeN08n{dPhXL zf*>GV1QEFO5_%+vflTnb-f!laasJJ(+0Qv=m$TNp-o47%&xx_KIm^x_!Ug~U*exy0 z>}h@H@y)_Od!p$xwP>9%0q#O@z9aK2S5;G2QKenl%4(W0Ep3>(4)E^= zqFKYCykYic=6~Cw%?v<31VSK8MI|^m7#ger#p152sOjqJ9%HDhE7K&D@u2|(M2K<# zUiv4385)noVFC#lYyj{W5#fcsPA~w`nEq=E{(=9%2H^j86U|{NA&5W~HK^+GmVOFa zTmSE({{H_+;|ccYfAjqxf$@%^foK(bG#+~$holA0Tl&~kAj}kpMi8(#M=aLwrx)#f zummjL2O9`9b+1ee_c$5+18J7c&^XKu zG|C)@^#}ggGz{}=F517u`&$?FYc4v!)K#I8Q8^Cne+u=_C0hO*5C2JA+T@?qM+eaI z9Y;%Smk8(-tzH0j=N;jCdU~|_NXbd(#-P&kvUqO6in19M((x*jO-&*NSw==iip&tPihNP((fgqR2<00ULUnR- zI#3|>^zaI{ytitzAB_*YVj3+@sK|F!iYHMrR^mU^JqKHIdZdpErN?ur8U_Gs!m7Yx8SeN# z_07)D=9cDT`Lz{RR(6H&TkQ5W`ISY_%L^o$ zUx2Cm5bD=RzMCCyUWu0H0S`$c`56@OSLx}IrLD!oOFQ`XN$N>r+v|?c-OD?>JKWT7 z#C2kERq4^u(W{=q z%d`WA4nVNCaX6m-KW+dAGP5iIz^ZO(X6zU;K^zZvbr=%|Y_*1%fgF*i5JpH%-pt^Z);#HD06>mC(PPnVX+$ zrye)$&EkV7TF(QmcHSvYP_*#4@uZKm*R|~YOnl_368SuGp`^ytbUYt$d8%sO-KUOo zesN=Jc)ZI~)rX!>lPq5e7T1?cTCxiZgD4u*4MjEx%5|^G?3}m}j$(@C&v@Z;2Wpus zQptYGn@) zQTYf!DO@VD4=!Ld@#WeqL@Qn3(x>0tT15JbE~JWxS~vN)x!|l_1G*!>7f_&H8E)NT5R_z_OBc}pI#RUbd!;wXwjnIu-0enCr&kke zr{Gz5%o}roj?M?#BQn(k3WYgt7ClQUaM@@ccrR#=X+G!BXCKN9gz5~733$heJ<=U` zyiXV;35Jrda{>$XhQ*2`^rE?pKvDo!79;L8f)`t%D;reF3Rhm$v^ z+7^;?KR(UP%#=EJ_7PKZOV<03X7MF9ANfBbgeMAwTOOnc*b!ianr=ROaQB7kCs75B zZ8O-AsD#>+p(&sV*PibGVjR zWr#bXoY?pso#&XB5YS!FO#F7@tl^PMTsSB--L3JfcW2n%?AJBH8s&WpRS_q)+e*zQ zN#63JDf_9?Xtu{TvUYA$cRh9_^uJnrVukdA>G&1nvmGEGbc13zp_(w8Nojn8x)3kjr`%;D0m+cW z!#X`ip)8yDd>*sm8B1~fcW*4#x&ej{yWnH%!5lL-1NZ235_OqvK8tY#@0cS)WbqrM zu;<`zlLT%|2Oi*oyxEC5{&)Cq?PfI{_4dJM!=Bfi9hA>49Q)rtPLp&C8E2|{+86Np z{F0FG^!ljjXLxlUggUEyRhV=oar0rzK~rxPgFoYcFeJWHYl4hn$sI(ht`p5&_TN zE62q_IfPAJ>K_TET!|kDiF7C{9zl*fD^|x`cJL6&wlA~m`{Xnu-3!W1;?DiB_4nWg>_G2? z>*a@i>znr)uf*7bwi@K=%VF2;33>3lZ#zd-2OwLLk;rpO?1p$bN$Tvkt9J8M3I{Ku zY^qo|-Y(pSD^6B)%X9C4rbyL@i*itc+=7y6p-y0pQ zj!s;vSuSh9Fla29@mBQF`&#kvp1XF<%Iexn_fxEC?^!Ypu37gR-jf^3(}2s+T_Zu` zUIF=r8Gbv*uwueTx4U?vywE@;6;RhcZU!^* zQ5EVMYu|o55$LGqSar#vKL{ZJE%P07!s$uhVCq`nU;X;YLHzTu$TKCvk&&jInG#KEukdek&myc&o z`Dk=soCM??@fLTy<(i&8lMINd_a{BML#qPJ&?M`7n<{iqvIJ#RVsDkn0_IR1gn@1|Oj?jf; z%d*s^e=m5GAw6Y&?zb3!zEP{7GHq2=BdpN4c@6#YA*cSJ?U=Kp&&pv#%i~1Gebh$m zrTvf{!#^O}5nI9mSr=M`#odPR`pn~*oy*fGZ-KK{`30~3#kjS{p`Hj($QqEe80Vv9+3Kzx)-8Ri`?KF?s6A0 z2+3Y zmc7AHalsQE?j6iWGm+Fke$=#Q7~KYrHu4~JQW=E+2JREZA`?W=@jFYnjaj9MXViZH DQ~)z- literal 0 HcmV?d00001 diff --git a/tests/cpp-tests/Resources/hd/Images/blocks9cr.png b/tests/cpp-tests/Resources/hd/Images/blocks9cr.png new file mode 100644 index 0000000000000000000000000000000000000000..f32d316174c7ac261b674e025f872c1ddf4fbd75 GIT binary patch literal 2262 zcmbtVYgiL!7M_4yE!T1p!G~!?lxh+Zk^qr3+!DD3As`o7gpdp*Kr%5INMNx>EDF*^ zR6u!9z=Bx36dQTtq7_qD0vg1k_b_LdEt+-5nVIu_-<k-wiW2ldx9x4t&|gtU%RP-lZMqmVE-5s`DH5a7j!6CluE#7%-Y z5SO2^^A_X*0NM`1@F*mT9Yo{7B0N_UgI9j7f7zzoOmjWSR0+b{a)3MW6+OVLI zPsc`5*v@Q;4=G{x9cz{e zSa2x>NugtZ6BWe{0exU81XA!WIG!_+2vVtdBAG&^5;uV)XCjHW;UJN4Xar7{Ax5|goLIJY znZXy5@uWftB80`DhLM{9ry+DKs`R%lh$J6q#j^LugdP|{!Icn*cxTO)mIK-B{~jt5 zeTbGJ9O!qwe@ZM1&yYX_4kUxqq&&26iEA~fBs3o>#6@6fI1HyQpJIprMqrr$mViEC zRB!{E%M*$<3regGhpA_JyRvbcoNA!Xj{K(=_3qXz?Ob zT`4T8*GKu@WBDJ~@^LHy6+_UJ_7A0AUPAjvGyKrF=;TA|Lt?bwrD$UdVz!(`KZ@3n zpm65;*~!%CnzHKh#l^+h_0K0JCmJp{t+{l;fKEe0+S=L}495A!y58Pi`;L}S?<`v@ zr!Sl9d>;-B4@|oK<8EPg%l6$(m)6wN4K|;wt^WCLzaDO*>bVMrVY6h&;qlP)^z^D@ zhX@3MaZF^S-##r9W6Qkkj;_vyR|^)V_Bg#w2M-=JF)@L{%C2>^4~-5J9Q|~44D&2= zOtg$WNUq9%E=v;X5XI)Y~8DT@qBS{Q`uJmu_FOx$GC&? zoZ8wB(N7V<)ci)+NJD0a`UROZrDfrUPJ^0@;D~9$P z*K;fO>{3pzYa6htpXywB)bu7~P*}S*EYAtNsv6i06pgX=@9Ld0nUPoCwN}3@4mf!> zC7U@an%jSsp?Wgy`5j#KYx}3UZ#nHVdn?`c>|k_SC?A6^7y%{R@KBNYYp3eu&oa~_ z4vmE`un~=gK^3CI+x_IWmidZkJ@ty*`$Ve1gjr(_g5`iPl(;&e@osw()u! zYUBPE5v6rFRxo5Kv%{Uy_?axmHM`2OUei;BrS%7<&R_^5*GtB~HQU_94Du-b`2j0$ zz3l#kaI^k_m3cVjrm(?Xolj8A_qbJfd|Gg!v`(!eQV#7V?1giQW#CuSAo!Qz!%jwZu z#8g`EYYE$+LQ*mKEmum3m;0lCu)*&i*e#NNQ&0Bbt zYc*M^Clj;EjGEUZ(f4L~9w(m+z-AcU(^9?AxlX1j%=*asbLm|`a$5a-xAn`{31YQ_ zl~QnV5$hOg>3J`@JEiee`y>BNfZiMXxF6nmSt=L87BTVm;GHK~&Tg0f5^zjASI48d zc~umCq8k(Oq;5bu>;Ss&KTjn)VuapbKh%#}7kZqPg-LdjFVqwc2jNZ?ZkYJymg?QB ze?I7S3>`{%@#;{b$Shx)xtiWxuAOMo*O2PYUg7uC_p>gh^Nh`Vs26J^b<$qjzhj)k%FEA4n;FTEiM$R9V)YtYY>Jp0@28*|{UIZ44W6zn-aFb*?(* zjXHKL1fnaS72vi`+__QQawTp8%&*uJ>zUb7ET8WxGFQ7iblZMzV4Kg4Rh8QVvMorI z(QP+yO$4{YYV1g4kRs4vxik{M*%$y6)5)(C3*PbB{{alu Bo#6lg literal 0 HcmV?d00001 diff --git a/tests/cpp-tests/Resources/hd/Images/blocks9r.png b/tests/cpp-tests/Resources/hd/Images/blocks9r.png new file mode 100644 index 0000000000000000000000000000000000000000..79c0c94604b8f993bcc153098e6610623659609e GIT binary patch literal 3141 zcmaJ@4Lp-;8-KRRe6{6UM=~SwF|#qUnJpn?%g2(J#PDE?ZMKOLR2^y&Ek;Jv(0U26f2U9-b$d^ z(0Cib7?y{K5BiJfj0n+=2**e?#Tn(4M3fW6fkGxKDK3^HASRK~pLvOLd&!MOqdtcS zcaYJ46%|PHL2cmjK@`E-787BE!=dc$t#Nh)dwZM}3U7nMV{PQ8JqBk-B-j)24yZ2& zTAqy`8AbGSb^nq}J|m-JghCz>i%m>Sv`)0O=JKPlI7dgvB@R3uBagrcc5#HvBn(Gj z{FT8K6h!b@JRytAK`k*d!?_7UGFo2gUrUJNeWT?FzHF0x!>~zA9u{Y9v$UkIfi&9x z4~>ia7A+9^fq&QgKZym5T|5x$2MV|e{0MpDqKubP@rWDvAXCWYGq~K?ue<0I!xeG` zFY+cQV zg#ZBA=;O_Bi~ZLb`SUR|Zzhw;%;qNxP8aLznESe<%$vFnM5add|KU>0S4AcLzyiWvvy4^;ZmfdwXjd>abWW=wE;}^)T#g z+0#@fOx|f~Zst1j;6ju5(TJ-->=k7bvf?roCw#~igL<+uiOc2A&d&A^4xFkwE$K8o zbm$NgiG*V;r)Q>3#)s6|p!T#gB6zD_-eI^tCYr7OY}{lS35l$?*3Q}oMIt)8yFPsU za4b*H3Im5(sRjlkFmNkv-z-Vz&7mj5P-SFVmUc-=iFzB}FrgEIfT^aUI}IgBC<1|m zW@)E|hK8DCjI-6Fm812?O`d5!C8|@{RAAIegG(252wN>9?g(RMJ$~pU~9j0^V zZ^ea*Y6vYg1wX{m6{sJn2hY6Uy&x;;w&`lFB?N^uzj=fYh9$mAs zhaz=WJE<%=7X3k>0lJ*Ho%_-2r-u+EFk4xZ@k+lGwPG*5tnkB!i}7yMKg7{4Hx$@Y zkn{o4HrL;p3-nN-Yscr(Mn_$?ugN*3Ue97YgsN2yhVke}U{r@FkTRxA#|O!<$~FMhJPm=%Vo_#UhT4KV7sD1NUr$w0e-SQPd``>ER?q@WbAng|gu}w-`Gsy0 zPFr~`;5|xEEs(vCl^Y9{vb-k3AX{KIUS~djluarbbd&?A)T;a(rlV$y=cClgU70=Z zTl|%)m3~(JwB78?3nQZb7TQD|+KyAxwBzMFHYE+XKKyP$%AfVFL*ula^t3o8J(8j z^L-K^>BV=UiWNTvLbBJqJNKevXcb}=l|RIQmQIPyE40MRNlkA6i|)x`QPt&E_Y2f} z^o4QU$-Xf&L}5}zYiod2ZB4(W&pbXG7LCfP)TjtIHMTFEq^1LOX#R5XEsK*mM;SMt zq}u3~!LhKqp;!)45H3xNnL7-L;l$b%Vai83%A7nD>V^uNj#nlpZ#FYk2+Gt10t|gu zn?PeY2SU4_?bl5n8-rpx47x5}9c5Z%W&x(1%#kWZpdW`f5}4V;^h%Uu!ixupijuPX z3ILin;NnGkeZxAh@8ys0@Y&$?EamkI2UWm%{Iz6&o>F(-psUUjvZlfV9xgsx>{<;x z$`zMwKMku_c6)0QPB>L+$yB5cw&O_geYrNaM%Pv!Tv^(xV$0R&D*NTmqcK35at<A|6>Jd)= zD0PppJW)>SudmcNLyx_mub)|)>KWamBH3wqRNYMDb;A~`ahJCb9@0&X>Cbi+@`RP%8{wQ_18jTAP}FFP?VwqaU{OcK4v5vK zggUlLUyN!g?E<#wj{rjJs88c%Z=+mIj47b)IQ#LUq8AT9%D#<*2OFcF>KUS1m>8P$g@yy+8&}4rJoX89=FJrG{ABt}f3s(q%;#NjI7+%8*S= zmzAHCzD>W}QK;uvHP>_g(suEstwn+d!eMn_(~Fx#@yE)=p*_Bbsye1N>CJchd#oAx zp;ikJB>;05;HCWmHzHrom;;5aX_1K9Q7;Xke~9O`d~S2a#drF_NqfCV5s&+yzp>la zzObpHzq(XOmtZ4f;FxUWucDY;)#pZTCP^JX(L{@%RClOfjYX9UCEW9M&0|Fk2+=X}FvC8#R49Rm zCEg|luVee`0*JnQ5WT!-YgaK(N4UTSp4^%UU{glIW^N7a=@_R}%>VPdCs#>_(yI~x Z23*dbWsW~iomu*^_jIGX*1Cl4`wt|m7#RQn literal 0 HcmV?d00001 diff --git a/tests/cpp-tests/Resources/hd/Images/blocks9ss.plist b/tests/cpp-tests/Resources/hd/Images/blocks9ss.plist index 9f77a49011..4548217df5 100755 --- a/tests/cpp-tests/Resources/hd/Images/blocks9ss.plist +++ b/tests/cpp-tests/Resources/hd/Images/blocks9ss.plist @@ -33,28 +33,28 @@ blocks9c.png frame - {{204,374},{100,120}} + {{197,388}, {122, 102}} offset - {26,36} + {30, -41} rotated sourceColorRect - {{0,0},{192,192}} + {{65, 86}, {122, 102}} sourceSize - {192,192} + {192, 192} blocks9cr.png frame - {{204,180},{100,120}} + {{136,173}, {122, 102}} offset - {26,36} + {30, -41} rotated sourceColorRect - {{0,0},{192,192}} + {{65, 86}, {122, 102}} sourceSize - {192,192} + {192, 192} grossini_dance_01.png From 714c01991eca86b20e23f5ac60ae68e24f35f273 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 18 Dec 2015 01:38:53 +0300 Subject: [PATCH 49/66] Scale9Sprite test improvemets --- .../CocoStudioGUITest/UIScale9SpriteTest.cpp | 68 ++++++------------ .../CocoStudioGUITest/UIScale9SpriteTest.h | 24 +------ .../cpp-tests/Resources/Images/blocks9cr.png | Bin 1208 -> 3808 bytes .../Resources/hd/Images/blocks9cr.png | Bin 2262 -> 4657 bytes 4 files changed, 25 insertions(+), 67 deletions(-) diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp index 70e38afe42..dd5628d656 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.cpp @@ -38,8 +38,6 @@ UIScale9SpriteTests::UIScale9SpriteTests() ADD_TEST_CASE(UIS9FrameNameSpriteSheetRotated); ADD_TEST_CASE(UIS9FrameNameSpriteSheetCropped); ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedRotated); - ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedImage); - ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedRotatedImage); ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedSimple); ADD_TEST_CASE(UIS9FrameNameSpriteSheetCroppedRotatedSimple); ADD_TEST_CASE(UIS9BatchNodeScaledNoInsets); @@ -357,9 +355,14 @@ bool UIS9FrameNameSpriteSheetCropped::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9c.png"); blocks->setPreferredSize(Size(400,80)); - blocks->setPosition(Vec2(x, y)); + blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); + auto blocks2 = ui::Scale9Sprite::create("Images/blocks9c.png"); + blocks2->setPreferredSize(Size(400,80)); + blocks2->setPosition(Vec2(x, y - 45)); + this->addChild(blocks2); + return true; } @@ -377,48 +380,13 @@ bool UIS9FrameNameSpriteSheetCroppedRotated::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9cr.png"); blocks->setPreferredSize(Size(400,80)); - blocks->setPosition(Vec2(x, y)); + blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); - return true; - } - - return false; -} - -bool UIS9FrameNameSpriteSheetCroppedImage::init() -{ - if (UIScene::init()) { - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); - - auto blocks = Sprite::createWithSpriteFrameName("blocks9c.png"); - blocks->setScale(400/blocks->getContentSize().width, 80/blocks->getContentSize().height); - blocks->setPosition(Vec2(x, y)); - this->addChild(blocks); - - return true; - } - - return false; -} - -bool UIS9FrameNameSpriteSheetCroppedRotatedImage::init() -{ - if (UIScene::init()) { - auto winSize = Director::getInstance()->getWinSize(); - float x = winSize.width / 2; - float y = 0 + (winSize.height / 2); - - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist); - - auto blocks = Sprite::createWithSpriteFrameName("blocks9cr.png"); - blocks->setScale(400/blocks->getContentSize().width, 80/blocks->getContentSize().height); - blocks->setPosition(Vec2(x, y)); - this->addChild(blocks); + auto blocks2 = ui::Scale9Sprite::create("Images/blocks9cr.png"); + blocks2->setPreferredSize(Size(400,80)); + blocks2->setPosition(Vec2(x, y - 45)); + this->addChild(blocks2); return true; } @@ -438,9 +406,14 @@ bool UIS9FrameNameSpriteSheetCroppedSimple::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9c.png"); blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); blocks->setPreferredSize(Size(400,80)); - blocks->setPosition(Vec2(x, y)); + blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); + auto blocksSprite = Sprite::createWithSpriteFrameName("blocks9c.png"); + blocksSprite->setScale(400/blocksSprite->getContentSize().width, 80/blocksSprite->getContentSize().height); + blocksSprite->setPosition(Vec2(x, y - 45)); + this->addChild(blocksSprite); + return true; } @@ -459,9 +432,14 @@ bool UIS9FrameNameSpriteSheetCroppedRotatedSimple::init() auto blocks = ui::Scale9Sprite::createWithSpriteFrameName("blocks9cr.png"); blocks->setRenderingType(Scale9Sprite::RenderingType::SIMPLE); blocks->setPreferredSize(Size(400,80)); - blocks->setPosition(Vec2(x, y)); + blocks->setPosition(Vec2(x, y + 45)); this->addChild(blocks); + auto blocksSprite = Sprite::createWithSpriteFrameName("blocks9cr.png"); + blocksSprite->setScale(400/blocksSprite->getContentSize().width, 80/blocksSprite->getContentSize().height); + blocksSprite->setPosition(Vec2(x, y - 45)); + this->addChild(blocksSprite); + return true; } diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h index 8d6f872b15..11042a7990 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIScale9SpriteTest.h @@ -91,27 +91,7 @@ public: virtual bool init() override; }; -// S9FrameNameSpriteSheetCropped - -class UIS9FrameNameSpriteSheetCroppedImage : public UIScene -{ -public: - CREATE_FUNC(UIS9FrameNameSpriteSheetCroppedImage); - - virtual bool init() override; -}; - -// S9FrameNameSpriteSheetCroppedRotated - -class UIS9FrameNameSpriteSheetCroppedRotatedImage : public UIScene -{ -public: - CREATE_FUNC(UIS9FrameNameSpriteSheetCroppedRotatedImage); - - virtual bool init() override; -}; - -// S9FrameNameSpriteSheetCropped +// S9FrameNameSpriteSheetCroppedSimple class UIS9FrameNameSpriteSheetCroppedSimple : public UIScene { @@ -121,7 +101,7 @@ public: virtual bool init() override; }; -// S9FrameNameSpriteSheetCroppedRotated +// S9FrameNameSpriteSheetCroppedRotatedSimple class UIS9FrameNameSpriteSheetCroppedRotatedSimple : public UIScene { diff --git a/tests/cpp-tests/Resources/Images/blocks9cr.png b/tests/cpp-tests/Resources/Images/blocks9cr.png index 0f25bdc6b9564a102cad1fc7dcebd72b1ed51338..beea86d7f8b02819a408787b44e0bb50a8a97092 100644 GIT binary patch literal 3808 zcmV<64j=J}P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z00093P)t-sC-mrSS*HL0|C^+q0002=C++|L{|5&L2nYxX2?+`c3JVJh3=9kn4Gj(s z4i66x5D*X%5fKs+5)%^>6ciK{6%`g178e&67#J8C85tTH8XFrM92^`S9UUGX9v>ec zARr(iAt53nA|oRsBqSsyB_$>%CMPE+C@3f?DJd!{Dl021EG#T7EiEoCE-x=HFfcGN zF)=bSGBYzXG&D3dH8nOiHa9mnI5;>tIXOByIy*Z%JUl!-Jv}}?K0iM{KtMo2K|w-7 zLPJACL_|bIMMXwNMn^|SNJvOYNl8jdN=r*iOiWBoO-)WtPESuyP*6}&QBhJ-Qd3h? zR8&+|RaI72R##V7SXfwDSy@_IT3cINTwGjTU0q&YUSD5dU|?WjVPRroVq;@tWMpJz zWo2e&W@l$-XlQ6@X=!R|YHMq2Y;0_8ZEbFDZf|dIaBy&OadC2Ta&vQYbaZreb#-=j zc6WDoczAeud3kzzdV70&e0+R;eSLm@et&;|fPjF3fq{a8f`fyDgoK2Jg@uNOhKGlT zh=_=ZiHVAeii?YjjEszpjg5|uj*pLzkdTm(k&%*;l9Q8@l$4Z}m6ev3mY0{8n3$NE znVFiJnwy)OoSdAUot>VZo}ZteprD|kp`oIpqNAguq@<*!rKP5(rl+T;sHmu^si~@} zs;jH3tgNi9t*x%EuCK4Ju&}VPv9YqUva_?Zw6wIfwY9dkwzs#pxVX5vxw*Q!y1To( zyu7@dCU$jHda$;ryf%FD~k%*@Qq z&CSlv&d<-!(9qD)(b3Y<($mw^)YR0~)z#M4*4Nk9*x1lt)=I7_<=;-L_>FMg~>g((4?Ck9A?d|UF?(gsK z@bK{Q@$vHV^7Hfa^z`)g_4W4l_V@Sq`1ttw`T6?#`uqF){QUg={r&#_{{R2~WZHe3 z00007bW%=J|NsC0|Nj6QO9Ms#008VsL_t(|+U(fP4ul{K1mM{+?E62mhXSHzUC7d8 zO=b>_UifVBClT-9K!5-N0t5&UAV7cs0RjXF5FlVFkjyN7j2*+S+8|(-(m}8*K++3K znF88M$x892YB4h!jaJKS2klCe_fjD5WCh@Bmf`FtXTV3~z|@G!CU+gw5nVQ!#~mL9 zZqu#K)B3A{YXk@oAmBj&Zu7c{009D?2hbA+uq6!0Ip>@^VG!UPkbeOP@GGzjqX0>O zBz(mE;Tiw{34q=~J@=zW0BuAdQAe~8n7mEnf$7^c{6YJdS4H^CP9K~=K)=+2vkd@+ Wgs5Sq-7nt&0000Lr5I=vCwv0Ch7k*w|MTBqnF4mMA2p zrf25aD!t#mUr8Y|#a1cY)Yrhbz&SM|)1#^=HMq(zB)KX(*)m1R-cG@$!U||WZfZ%Q zLPc&)Ua?h$trFN=DVPg@)As;uP=V3xw&xF#U(+h2=`(&xHzP;AXPso zwK%`DC>a=WY04n03ap%qQWHz^i$e1Ab6}wukda@KU!0L&px_*Arl8@Qn4Fmh63_(e z@b$Iw%quQQ%u7!7bg@+enxU7OnPO#XXy#~aVPJ0QVq|P+=xXX{=IrWd>}+A;YGCYU zZsY{h>yn>bnwy$e0@Is<&})HHFDNnO765H_NiE7OOHFYr%Fk5*d)g`!w_8kcng`XJ zg4-=-IQ8lS9itD5TBN9k2?5g&hzU=)Kn^_Vr{)3Edl4{UpPUh>4$Ksy0X`wF>R(>u zL@xXP|NrbI^MGPs)ZYTxMZdp)0CLz%g8YJkTp(bO@@94e3Vri*aSW-r^=8IHz7_?Z z=5mAgf8~D`bRH9KYKv@K!uzW@e%q#58u1%i7??N|8sNl((1x6#$ugq=%3u;`$@#S6YYiR}Gdf2Qr5>l)l5TXyl?8^&GC>)9{K3b?b>XmPO$Iy7)^cxSbX zS#~S4Eyu>eFL~{IV8GZg{hbVav^CLxyLDA`gsyiXDhzD8I0eed(`$rjpg`XXt3@ zecGHkYx;ZPGA`By)(^}p!x-xO%31%gNH8?rSdrMf`?3%)1Qf59&ghTmgWD0l;*TI7}*0BAb^tj|`8MF3bZ02F3R#5n-i zEdVe{S7t~6u(trf&JYW-00;~KFj0twDF6g}0AR=?BX|IWnE(_<@>e|ZE3OddDgXd@ znX){&BsoQaTL>+22Uk}v9w^R97b_GtVFF>AKrX_0nSU8Ffiw@`^UMGMppg|3;Dhu1 zc+L*4&dxTDwhmt{>c0m6B4T3W{^ifBa6kY6;dFk{{wy!E8h|?nfNlPwCGG@hUJIag z_lst-4?wj5py}FI^KkfnJUm6Akh$5}<>chpO2k52Vaiv1{%68pz*qfj`F=e7_x0eu z;v|7GU4MZ`1o+^>%=Ap99M6&ogks$0k4OBs3;+Bb(;~!4V!2o<6ys46agIcqjPo+3 zB8fthDa9qy|77CdEc*jK-!%ZRYCZvbku9iQV*~a}ClFY4z~c7+0P?$U!PF=S1Au6Q z;m>#f??3%Vpd|o+W=WE9003S@Bra6Svp>fO0Dk~Ppn)o|K^yeJ7%adB9Ki+L!3+Fg zHiSYX#KJ-lLJDMn9CBbOtb#%)hRv`YDqt_vKpix|QD}yfa1JiQRk#j4a1Z)n2%fLC6RbVIkUx0b+_+BaR3cnT7Zv!AJxWizFb)h!jyGOOZ85F;a?DAXP{m@;!0_ zIe&*-M!JzZ$N(~e{D!NlT@zqLtGcXcuVrX|L#Xx)I%#9!{6gSJKPrN9dR61N3(c z4Tcqi$B1Vr8Jidf7-t!G7_XR2rWw%BIv?Wdily+ylO`+*KY$4Vz$Cr4+G&IO(4Q`uA9rwXSQO+7mGt}d!;r5mBU zM0dY#r|y`ZzFvTyOmC;&dA;ZQ9DOhSRQ+xGr}ak+SO&8UBnI0I&KNw!HF0k|9WTe* z@liuv!$3o&VU=N*;e?U7(SJOn)kcj*4~%KXT;n9;ZN_cJqb3F>Atp;r>P_yNQcbz0 zDW*G2J50yT%*~?B)|oY%Ju%lZ=bPu7*PGwBU|M)uEVih&xMfMQu79>|wtZn|Vi#w( z#jeBdlf9FDx_yoPJqHbk*$%56S{;6Kv~mM9!g3B(KJ}#RZ#@)!h;8Eq#KMS9gFl*neeosSBfoHYnBQIkwkyowPu(zdm zs`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMeBmZRodjHV?r+_5^X9J0W zL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0?0=B0A@}E)&XLY(4uw#D z=+@8&Vdi0r!+s1Wg@=V#hChyQh*%oYF_$%W(cD9G-$eREmPFp0XE9GXuPsV7Dn6<% zYCPIEx-_~!#x7=A%+*+(SV?S4962s3t~PFLzTf=q^M~S{;tS(@7nm=|U2u7!&cgJC zrxvL$5-d8FKz~e#PB@hCK@cja7K|nG6L%$!3VFgE!e=5c(KgYD*h5?@9!~N|DouKl z?2)`Rc_hU%r7Y#SgeR$xyi5&D-J3d|7MgY-Z8AMNy)lE5k&tmhsv%92wrA>R=4N)w ztYw9={>5&Kw=W)*2gz%*kgNq+Eef_mrsz~!DAy_nvVUh~S7yJ>iOM;atDY;(?aZ^v z+mJV$@1Ote62cPUlD4IWOIIx&SmwQ~YB{nzae3Pc;}r!fhE@iwJh+OsDs9zItL;~p zu715HdQEGAUct(O!LkCy1<%NCg+}G`0PgpNm-?d@-hMgNe6^V+j6x$b<6@S<$ z+<4_1hktL%znR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX4c}I@?e+FW+b@^R zDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i&_B8C(+grT%{XWUQ z+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?SIDu(gXbmBM!FLxzyDi(mhmCkJc;e zM-ImyzW$x>cP$Mz4ONYt#^NJzM0w=t_X*$k9t}F$c8q(h;Rn+nb{%IOFKR-X@|s4Q zQ=0o*Vq3aT%s$c9>fU<%N829{oHRUHc}nwC$!Xf@g42^{^3RN&m7RTlF8SPG+oHC6 z=YM0)-)awU@466l;nGF_i|0GMJI-A4xODQe+vO8ixL2C5I$v$-bm~0*lhaSfyPUh4 zuDM)mx$b(swR>jw=^LIm&fWCAdGQwi*43UlJ>9+YdT;l|_x0Zv-F|W>{m#p~*>@-I zt-MdXU-UrjLD@syht)q@{@mE_+<$7ocYmPs(cDM(28Dyq{*m>M4?_iynUBkc4TkHU zI6gT!;y-fz>HMcd&t%Ugo)`Y2{>!cx7B7DI)$7;J(U{Spm-3gBzioV_{p!H$8L!*M z!p0uH$#^p{Ui4P`?ZJ24cOCDe-w#jZd?0@)|7iKK^;6KN`;!@ylm7$*nDhK&GcqmP z0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F}00093lX?Te ze?LDzKtMo2K|w-7LPJACL_|bIMMXwNMn^|SNJvOYNl8jdN=r*iOiWBoO-)WtPESuy zP*6}&QBhJ-Qd3h?R8&+|RaI72R##V7SXfwDSy@_IT3cINTwGjTU0q&YUSD5dU|?Wj zVPRroVq;@tWMpJzWo2e&W@l$-XlQ6@e`#rIYHDk1Yiw+6ZEbCCZfCf>sHv%`s;a81tE;T6tgWrBuCA`HudlGMu(7eRva+(Xv$M3cw6(Rhwzjsn zx3{>sxVgExy1Kf%ySu!+yuH1>f4;uHzrVl0z`()5!NS7A!^6YG#KgtL#m2_Q$H&LW z$jHgb$;!&g%gf8m%*@Tr&Cbrw&(F`$(9qG*(bCe=)6>(`)YR40)z;S5*VotB*x1?G z+1lFL+uPgR+}z#W-QM2b-{0Th;Naom;o{=ruz*=jZ3>OX%q7>FMg~ z>g((4?Ck9A?d|UF?(gsK@bK{Q@$vHV^7Hfa^z`)g_4W4l_V@Sq`1ttw`T6?#`uqF) z{QUg={r&#_{{R2~|KlIulRpGbK?O-fK~#9!?Ah6Nqc{)-;Pf~k5Q1cu?gS7v#tV3f zoju*Nz5iqNMIBk91CyK>r6KdzIf;dI!$*}CL0uH(46+DkbajYf{^ zI+b)BSvf8N_B%B~Icow0T>a@QHI>Z?Z4n?6St)=lUAL5uOC^7_+p7`ESyKu9G=MH4 zdbW;}2x95~dc-6*0n8FI0TxS0Phxtut}Ei_05$Rwz?{S;z}h4>mr;@IcTE6U?)GY= z4G?BoNZVDIskMi$RG%e)xskCG;+i{P^@=2RVy}IlYnTy&)EQYty}L0NRJ29)CQ%Sp;-g5!ds90j}ovE8mFKeOnfK3YcH7ZcM<$VYRW-pfJqchx_<>+UYs7{;oJJo_s`EP0;2Ia zvIqG3aJ#k)V4laG-x}rRrR=;6pd2*K0?Po(%S+jL4dCm;?Ye0ebO=b7j4?(}oLZA; znWjs|mT9_-Cc2j$f->_O!0GA5Wm6G#2w0?^=XvzRsTGaW#Uk~*bg@Xsk?!>lL7C|l zU^ZoJI)9_qbfy8bsp?&(sxMto+4TfKB{ZE8g0bmrHq|9GovGe*q576-uK;v2%=3NK z@)-5%mL50z0I*d;;m55IBgg34qs>n|CJJ7 z>Oaz-c@ literal 2262 zcmbtVYgiL!7M_4yE!T1p!G~!?lxh+Zk^qr3+!DD3As`o7gpdp*Kr%5INMNx>EDF*^ zR6u!9z=Bx36dQTtq7_qD0vg1k_b_LdEt+-5nVIu_-<k-wiW2ldx9x4t&|gtU%RP-lZMqmVE-5s`DH5a7j!6CluE#7%-Y z5SO2^^A_X*0NM`1@F*mT9Yo{7B0N_UgI9j7f7zzoOmjWSR0+b{a)3MW6+OVLI zPsc`5*v@Q;4=G{x9cz{e zSa2x>NugtZ6BWe{0exU81XA!WIG!_+2vVtdBAG&^5;uV)XCjHW;UJN4Xar7{Ax5|goLIJY znZXy5@uWftB80`DhLM{9ry+DKs`R%lh$J6q#j^LugdP|{!Icn*cxTO)mIK-B{~jt5 zeTbGJ9O!qwe@ZM1&yYX_4kUxqq&&26iEA~fBs3o>#6@6fI1HyQpJIprMqrr$mViEC zRB!{E%M*$<3regGhpA_JyRvbcoNA!Xj{K(=_3qXz?Ob zT`4T8*GKu@WBDJ~@^LHy6+_UJ_7A0AUPAjvGyKrF=;TA|Lt?bwrD$UdVz!(`KZ@3n zpm65;*~!%CnzHKh#l^+h_0K0JCmJp{t+{l;fKEe0+S=L}495A!y58Pi`;L}S?<`v@ zr!Sl9d>;-B4@|oK<8EPg%l6$(m)6wN4K|;wt^WCLzaDO*>bVMrVY6h&;qlP)^z^D@ zhX@3MaZF^S-##r9W6Qkkj;_vyR|^)V_Bg#w2M-=JF)@L{%C2>^4~-5J9Q|~44D&2= zOtg$WNUq9%E=v;X5XI)Y~8DT@qBS{Q`uJmu_FOx$GC&? zoZ8wB(N7V<)ci)+NJD0a`UROZrDfrUPJ^0@;D~9$P z*K;fO>{3pzYa6htpXywB)bu7~P*}S*EYAtNsv6i06pgX=@9Ld0nUPoCwN}3@4mf!> zC7U@an%jSsp?Wgy`5j#KYx}3UZ#nHVdn?`c>|k_SC?A6^7y%{R@KBNYYp3eu&oa~_ z4vmE`un~=gK^3CI+x_IWmidZkJ@ty*`$Ve1gjr(_g5`iPl(;&e@osw()u! zYUBPE5v6rFRxo5Kv%{Uy_?axmHM`2OUei;BrS%7<&R_^5*GtB~HQU_94Du-b`2j0$ zz3l#kaI^k_m3cVjrm(?Xolj8A_qbJfd|Gg!v`(!eQV#7V?1giQW#CuSAo!Qz!%jwZu z#8g`EYYE$+LQ*mKEmum3m;0lCu)*&i*e#NNQ&0Bbt zYc*M^Clj;EjGEUZ(f4L~9w(m+z-AcU(^9?AxlX1j%=*asbLm|`a$5a-xAn`{31YQ_ zl~QnV5$hOg>3J`@JEiee`y>BNfZiMXxF6nmSt=L87BTVm;GHK~&Tg0f5^zjASI48d zc~umCq8k(Oq;5bu>;Ss&KTjn)VuapbKh%#}7kZqPg-LdjFVqwc2jNZ?ZkYJymg?QB ze?I7S3>`{%@#;{b$Shx)xtiWxuAOMo*O2PYUg7uC_p>gh^Nh`Vs26J^b<$qjzhj)k%FEA4n;FTEiM$R9V)YtYY>Jp0@28*|{UIZ44W6zn-aFb*?(* zjXHKL1fnaS72vi`+__QQawTp8%&*uJ>zUb7ET8WxGFQ7iblZMzV4Kg4Rh8QVvMorI z(QP+yO$4{YYV1g4kRs4vxik{M*%$y6)5)(C3*PbB{{alu Bo#6lg From fb312a761c86297836b5b9fb2d90ef1e90b9e9b6 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 17 Dec 2015 16:53:38 +0800 Subject: [PATCH 50/66] update for 3D object render, revert old changes --- cocos/3d/CCMesh.cpp | 44 ++---------------- cocos/3d/CCMesh.h | 18 ++------ cocos/base/CCDirector.cpp | 3 -- cocos/renderer/CCTexture2D.h | 4 -- cocos/renderer/CCTextureCache.cpp | 8 +--- cocos/renderer/CCTextureCache.h | 5 -- extensions/Particle3D/CCParticle3DRender.cpp | 17 +++++++ extensions/Particle3D/CCParticle3DRender.h | 5 ++ extensions/Particle3D/CCParticleSystem3D.h | 4 ++ .../Particle3D/PU/CCPUBillboardChain.cpp | 16 ++----- extensions/Particle3D/PU/CCPURender.cpp | 46 ++++++++----------- extensions/Particle3D/PU/CCPURender.h | 5 +- extensions/cocos-ext.h | 1 + .../Classes/Sprite3DTest/Sprite3DTest.cpp | 35 +++++++++++++- .../Classes/Sprite3DTest/Sprite3DTest.h | 4 ++ 15 files changed, 98 insertions(+), 117 deletions(-) diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 4a9a347abb..3ed8cae596 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -133,7 +133,6 @@ Mesh::Mesh() , _blendDirty(true) , _force2DQueue(false) , _texFile("") -, _enableCheckTexture(false) { } @@ -282,7 +281,7 @@ void Mesh::setTexture(Texture2D* tex) setTexture(tex, NTextureData::Usage::Diffuse); } -void Mesh::setTexture(Texture2D* tex, NTextureData::Usage usage) +void Mesh::setTexture(Texture2D* tex, NTextureData::Usage usage, bool cacheFileName) { // Texture must be saved for future use // it doesn't matter if the material is already set or not @@ -307,7 +306,8 @@ void Mesh::setTexture(Texture2D* tex, NTextureData::Usage usage) } bindMeshCommand(); - _texFile = tex->getPath(); + if (cacheFileName) + _texFile = tex->getPath(); } else if (usage == NTextureData::Usage::Normal) // currently only diffuse and normal are supported { @@ -382,9 +382,6 @@ void Mesh::draw(Renderer* renderer, float globalZOrder, const Mat4& transform, u if (isTransparent) flags |= Node::FLAGS_RENDER_AS_3D; - if (_enableCheckTexture) - this->checkTexture(); - _meshCommand.init(globalZ, _material, getVertexBuffer(), @@ -706,39 +703,4 @@ GLuint Mesh::getIndexBuffer() const { return _meshIndexData->getIndexBuffer()->getVBO(); } - -void Mesh::checkTexture() -{ - Texture2D* cacheTex = nullptr; - auto& texture = _textures[NTextureData::Usage::Diffuse]; - if (Director::getInstance()->getTextureCache()->isDirty()) - { - cacheTex = Director::getInstance()->getTextureCache()->getTextureForKey(_texFile); - if (cacheTex == nullptr) - { - cacheTex = getDummyTexture(); - } - } - else if (texture != nullptr && !texture->isValid()) - { - cacheTex = getDummyTexture(); - } - - if (cacheTex != nullptr && texture != cacheTex) - { - CC_SAFE_RETAIN(cacheTex); - CC_SAFE_RELEASE(texture); - texture = cacheTex; - - if (_material) { - auto technique = _material->_currentTechnique; - for (auto& pass : technique->_passes) - { - pass->setTexture(texture); - } - } - bindMeshCommand(); - } -} - NS_CC_END diff --git a/cocos/3d/CCMesh.h b/cocos/3d/CCMesh.h index c9ccd792b9..f8019011e6 100644 --- a/cocos/3d/CCMesh.h +++ b/cocos/3d/CCMesh.h @@ -109,8 +109,9 @@ public: * set texture * @param tex texture to be set * @param usage Usage of this texture + * @param whether refresh the cache file name */ - void setTexture(Texture2D* tex, NTextureData::Usage usage); + void setTexture(Texture2D* tex, NTextureData::Usage usage,bool cacheFileName = true); /** * set texture * @param texPath texture path @@ -224,19 +225,7 @@ public: */ void setForce2DQueue(bool force2D) { _force2DQueue = force2D; } - /** - * check texture - */ - void checkTexture(); - - /** - * set enable check texture, check texture each frame if enable is true. It is false by default - */ - void setEnableCheckTexture(bool enableCheckTexture) { _enableCheckTexture = enableCheckTexture; } - /** - * check texture each frame? - */ - bool enableCheckTexture() const { return _enableCheckTexture; } + std::string getTextureFileName(){ return _texFile; } CC_CONSTRUCTOR_ACCESS: @@ -280,7 +269,6 @@ protected: std::vector _spotLightUniformRangeInverseValues; std::string _texFile; - bool _enableCheckTexture; }; // end of 3d group diff --git a/cocos/base/CCDirector.cpp b/cocos/base/CCDirector.cpp index 1494486bf1..a6d612677a 100644 --- a/cocos/base/CCDirector.cpp +++ b/cocos/base/CCDirector.cpp @@ -328,9 +328,6 @@ void Director::drawScene() { calculateMPF(); } - - if (_textureCache != nullptr) - _textureCache->setDirty(false); } void Director::calculateDeltaTime() diff --git a/cocos/renderer/CCTexture2D.h b/cocos/renderer/CCTexture2D.h index ced2f2e596..c88dbe7fe7 100644 --- a/cocos/renderer/CCTexture2D.h +++ b/cocos/renderer/CCTexture2D.h @@ -406,10 +406,6 @@ public: /** Get a shader program from the texture.*/ GLProgram* getGLProgram() const; - /** Set if the texture is valid, when it been set as false, it will display as default "file missing texture" */ - void setValid(bool valid) { _valid = valid; } - - bool isValid() const { return _valid; } std::string getPath()const { return _filePath; } public: diff --git a/cocos/renderer/CCTextureCache.cpp b/cocos/renderer/CCTextureCache.cpp index bfbf59cfd2..960c76b4a8 100644 --- a/cocos/renderer/CCTextureCache.cpp +++ b/cocos/renderer/CCTextureCache.cpp @@ -59,7 +59,6 @@ TextureCache::TextureCache() : _loadingThread(nullptr) , _needQuit(false) , _asyncRefCount(0) -, _dirty(false) { } @@ -496,8 +495,7 @@ void TextureCache::removeTexture(Texture2D* texture) for( auto it=_textures.cbegin(); it!=_textures.cend(); /* nothing */ ) { if( it->second == texture ) { - texture->setValid(false); - texture->autorelease(); + it->second->release(); _textures.erase(it++); break; } else @@ -516,8 +514,7 @@ void TextureCache::removeTextureForKey(const std::string &textureKeyName) } if( it != _textures.end() ) { - it->second->setValid(false); - (it->second)->autorelease(); + it->second->release(); _textures.erase(it); } } @@ -626,7 +623,6 @@ void TextureCache::renameTextureWithKey(const std::string srcName, const std::st tex->initWithImage(image); _textures.insert(std::make_pair(fullpath, tex)); _textures.erase(it); - this->setDirty(true); } CC_SAFE_DELETE(image); } diff --git a/cocos/renderer/CCTextureCache.h b/cocos/renderer/CCTextureCache.h index d592a632de..0a5ee7586d 100644 --- a/cocos/renderer/CCTextureCache.h +++ b/cocos/renderer/CCTextureCache.h @@ -204,9 +204,6 @@ public: */ const std::string getTextureFilePath(Texture2D* texture)const; - void setDirty(bool dirty) { _dirty = dirty; } - bool isDirty() const { return _dirty; } - /** Reload texture from a new file. * This function is mainly for editor, won't suggest use it in game for performance reason. * @@ -242,8 +239,6 @@ protected: int _asyncRefCount; std::unordered_map _textures; - - bool _dirty; }; #if CC_ENABLE_CACHE_TEXTURE_DATA diff --git a/extensions/Particle3D/CCParticle3DRender.cpp b/extensions/Particle3D/CCParticle3DRender.cpp index 14ca60de3f..6e6cb19ff8 100755 --- a/extensions/Particle3D/CCParticle3DRender.cpp +++ b/extensions/Particle3D/CCParticle3DRender.cpp @@ -43,6 +43,7 @@ Particle3DQuadRender::Particle3DQuadRender() , _glProgramState(nullptr) , _indexBuffer(nullptr) , _vertexBuffer(nullptr) +, _texFile("") { } @@ -60,6 +61,7 @@ Particle3DQuadRender* Particle3DQuadRender::create(const std::string& texFile) auto ret = new (std::nothrow)Particle3DQuadRender(); if (ret && ret->initQuadRender(texFile)) { + ret->_texFile = texFile; ret->autorelease(); } else @@ -187,6 +189,8 @@ bool Particle3DQuadRender::initQuadRender( const std::string& texFile ) _texture = tex; glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_PARTICLE_TEXTURE); } + else + _texture = nullptr; } auto glProgramState = GLProgramState::create(glProgram); glProgramState->retain(); @@ -213,6 +217,11 @@ bool Particle3DQuadRender::initQuadRender( const std::string& texFile ) return true; } +void Particle3DQuadRender::reset() +{ + this->initQuadRender(_texFile); +} + ////////////////////////////////////////////////////////////////////////////// Particle3DModelRender::Particle3DModelRender() : _spriteSize(Vec3::ONE) @@ -284,6 +293,14 @@ void Particle3DModelRender::render(Renderer* renderer, const Mat4 &transform, Pa } } +void Particle3DModelRender::reset() +{ + for (auto iter : _spriteList){ + iter->release(); + } + _spriteList.clear(); +} + // MARK: Particle3DRender Particle3DRender::Particle3DRender() diff --git a/extensions/Particle3D/CCParticle3DRender.h b/extensions/Particle3D/CCParticle3DRender.h index e2cf465222..2616071c0b 100644 --- a/extensions/Particle3D/CCParticle3DRender.h +++ b/extensions/Particle3D/CCParticle3DRender.h @@ -73,6 +73,8 @@ public: void copyAttributesTo (Particle3DRender *render); + virtual void reset(){} + CC_CONSTRUCTOR_ACCESS: Particle3DRender(); virtual ~Particle3DRender(); @@ -94,6 +96,7 @@ public: virtual void render(Renderer* renderer, const Mat4 &transform, ParticleSystem3D* particleSystem) override; + virtual void reset()override; CC_CONSTRUCTOR_ACCESS: Particle3DQuadRender(); virtual ~Particle3DQuadRender(); @@ -118,6 +121,7 @@ protected: std::vector _posuvcolors; //vertex data std::vector _indexData; //index data + std::string _texFile; }; // particle render for Sprite3D @@ -128,6 +132,7 @@ public: virtual void render(Renderer* renderer, const Mat4 &transform, ParticleSystem3D* particleSystem) override; + virtual void reset()override; CC_CONSTRUCTOR_ACCESS: Particle3DModelRender(); virtual ~Particle3DModelRender(); diff --git a/extensions/Particle3D/CCParticleSystem3D.h b/extensions/Particle3D/CCParticleSystem3D.h index ab577bb34f..fd5881cc75 100644 --- a/extensions/Particle3D/CCParticleSystem3D.h +++ b/extensions/Particle3D/CCParticleSystem3D.h @@ -204,6 +204,10 @@ public: * set particle render, can set your own particle render */ void setRender(Particle3DRender* render); + /** + * return particle render + */ + Particle3DRender* getRender(){ return _render; } /** * add particle affector */ diff --git a/extensions/Particle3D/PU/CCPUBillboardChain.cpp b/extensions/Particle3D/PU/CCPUBillboardChain.cpp index c023d108fc..2df9248e17 100644 --- a/extensions/Particle3D/PU/CCPUBillboardChain.cpp +++ b/extensions/Particle3D/PU/CCPUBillboardChain.cpp @@ -734,21 +734,15 @@ void PUBillboardChain::setBlendFunc(const BlendFunc& blendFunc) GLuint PUBillboardChain::getTextureName() { - if (Director::getInstance()->getTextureCache()->isDirty()) - { - if (Director::getInstance()->getTextureCache()->getTextureForKey(_texFile) == nullptr) - { - _texture = nullptr; - this->init(""); - } - else - this->init(_texFile); - } - else if (_texture != nullptr && !_texture->isValid()) + if (Director::getInstance()->getTextureCache()->getTextureForKey(_texFile) == nullptr) { _texture = nullptr; this->init(""); } + else if (_texture == nullptr) + { + this->init(_texFile); + } if (_texture == nullptr) return 0; diff --git a/extensions/Particle3D/PU/CCPURender.cpp b/extensions/Particle3D/PU/CCPURender.cpp index 6f7b2e8413..5d23e298bb 100644 --- a/extensions/Particle3D/PU/CCPURender.cpp +++ b/extensions/Particle3D/PU/CCPURender.cpp @@ -244,7 +244,7 @@ void PUParticle3DQuadRender::render(Renderer* renderer, const Mat4 &transform, P _stateBlock->setBlendFunc(particleSystem->getBlendFunc()); - GLuint texId = this->getTextureName(); + GLuint texId = (_texture ? _texture->getName() : 0); _meshCommand->init(0, texId, _glProgramState, @@ -525,6 +525,14 @@ PUParticle3DModelRender* PUParticle3DModelRender::clone() return mr; } +void PUParticle3DModelRender::reset() +{ + for (auto iter : _spriteList){ + iter->release(); + } + _spriteList.clear(); +} + PUParticle3DEntityRender::PUParticle3DEntityRender() : _meshCommand(nullptr) @@ -564,6 +572,8 @@ bool PUParticle3DEntityRender::initRender( const std::string &texFile ) _texture = tex; glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_3D_PARTICLE_TEXTURE); } + else + _texture = nullptr; } auto glProgramState = GLProgramState::create(glProgram); glProgramState->retain(); @@ -587,35 +597,16 @@ bool PUParticle3DEntityRender::initRender( const std::string &texFile ) return true; } -GLuint PUParticle3DEntityRender::getTextureName() -{ - if (Director::getInstance()->getTextureCache()->isDirty()) - { - if (Director::getInstance()->getTextureCache()->getTextureForKey(_texFile) == nullptr) - { - _texture = nullptr; - this->initRender(""); - } - else - this->initRender(_texFile); - } - else if (_texture != nullptr && !_texture->isValid()) - { - _texture = nullptr; - this->initRender(""); - } - - if (_texture == nullptr) - return 0; - - return _texture->getName(); -} - void PUParticle3DEntityRender::copyAttributesTo(PUParticle3DEntityRender *render) { PURender::copyAttributesTo(render); } +void PUParticle3DEntityRender::reset() +{ + this->initRender(_texFile); +} + PUParticle3DBoxRender::PUParticle3DBoxRender() { autoRotate = false; @@ -725,7 +716,7 @@ void PUParticle3DBoxRender::render( Renderer* renderer, const Mat4 &transform, P _vertexBuffer->updateVertices(&_vertices[0], vertexindex/* * sizeof(_posuvcolors[0])*/, 0); _indexBuffer->updateIndices(&_indices[0], index/* * sizeof(unsigned short)*/, 0); - GLuint texId = this->getTextureName(); + GLuint texId = (_texture ? _texture->getName() : 0); _stateBlock->setBlendFunc(_particleSystem->getBlendFunc()); _meshCommand->init(0, texId, @@ -889,8 +880,7 @@ void PUSphereRender::render( Renderer* renderer, const Mat4 &transform, Particle _vertexBuffer->updateVertices(&_vertices[0], vertexindex/* * sizeof(_posuvcolors[0])*/, 0); _indexBuffer->updateIndices(&_indices[0], index/* * sizeof(unsigned short)*/, 0); - GLuint texId = this->getTextureName(); - + GLuint texId = (_texture ? _texture->getName() : 0); _stateBlock->setBlendFunc(particleSystem->getBlendFunc()); _meshCommand->init( 0, diff --git a/extensions/Particle3D/PU/CCPURender.h b/extensions/Particle3D/PU/CCPURender.h index baf976c2b3..43232119a8 100644 --- a/extensions/Particle3D/PU/CCPURender.h +++ b/extensions/Particle3D/PU/CCPURender.h @@ -65,7 +65,7 @@ class CC_DLL PUParticle3DEntityRender : public PURender { public: void copyAttributesTo(PUParticle3DEntityRender *render); - + virtual void reset()override; CC_CONSTRUCTOR_ACCESS: PUParticle3DEntityRender(); virtual ~PUParticle3DEntityRender(); @@ -73,8 +73,6 @@ CC_CONSTRUCTOR_ACCESS: protected: bool initRender(const std::string &texFile); - GLuint getTextureName(); - protected: struct VertexInfo @@ -189,6 +187,7 @@ public: virtual PUParticle3DModelRender* clone() override; void copyAttributesTo(PUParticle3DModelRender *render); + virtual void reset()override; CC_CONSTRUCTOR_ACCESS: PUParticle3DModelRender(); virtual ~PUParticle3DModelRender(); diff --git a/extensions/cocos-ext.h b/extensions/cocos-ext.h index 226fc5dd31..9d491a1070 100644 --- a/extensions/cocos-ext.h +++ b/extensions/cocos-ext.h @@ -21,6 +21,7 @@ #include "ExtensionDeprecated.h" // Particle System, include Particle Universe Particle System +#include "Particle3D/CCParticle3DRender.h" #include "Particle3D/CCParticleSystem3D.h" #include "Particle3D/PU/CCPUParticleSystem3D.h" diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index 5c6da55cce..bae4787039 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -2602,6 +2602,7 @@ Sprite3DPropertyTest::Sprite3DPropertyTest() _sprite->setPosition(20.f, 0.f); _sprite->setRotation3D(Vec3(0, 180, 0)); _meshTex = _sprite->getMesh()->getTexture(); + _texFile = _meshTex->getPath(); addChild(_sprite); setCameraMask(2); @@ -2616,11 +2617,14 @@ Sprite3DPropertyTest::Sprite3DPropertyTest() auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(Sprite3DPropertyTest::printMeshName, this)); auto label2 = Label::createWithTTF(ttfConfig, "Remove Used Texture"); auto item2 = MenuItemLabel::create(label2, CC_CALLBACK_1(Sprite3DPropertyTest::removeUsedTexture, this)); + auto label3 = Label::createWithTTF(ttfConfig, "Reset"); + auto item3 = MenuItemLabel::create(label3, CC_CALLBACK_1(Sprite3DPropertyTest::resetTexture, this)); item1->setPosition(Vec2(VisibleRect::left().x + 100, VisibleRect::bottom().y + item1->getContentSize().height * 4)); item2->setPosition(Vec2(VisibleRect::left().x + 100, VisibleRect::bottom().y + item1->getContentSize().height * 5)); + item3->setPosition(Vec2(VisibleRect::left().x + 100, VisibleRect::bottom().y + item1->getContentSize().height * 6)); - auto pMenu1 = Menu::create(item1, item2, nullptr); + auto pMenu1 = Menu::create(item1, item2, item3,nullptr); pMenu1->setPosition(Vec2(0, 0)); this->addChild(pMenu1, 10); @@ -2654,5 +2658,34 @@ void Sprite3DPropertyTest::removeUsedTexture(cocos2d::Ref* sender) if (_meshTex != nullptr) { TextureCache::getInstance()->removeTexture(_meshTex); + this->refreshSpriteRender(); + } +} + +void Sprite3DPropertyTest::resetTexture(cocos2d::Ref* sender) +{ + if (_meshTex != nullptr) + { + _meshTex = TextureCache::getInstance()->addImage(_texFile); + this->refreshSpriteRender(); + } +} + +void Sprite3DPropertyTest::refreshSpriteRender() +{ + Vector meshes = _sprite->getMeshes(); + for (Mesh* mesh : meshes) + { + std::string file = mesh->getTextureFileName(); + Texture2D* cacheTex = Director::getInstance()->getTextureCache()->getTextureForKey(file); + if (cacheTex == nullptr) + { + unsigned char data[] = { 255, 0, 0, 255 };//1*1 red picture + Image * image = new (std::nothrow) Image(); + image->initWithRawData(data, sizeof(data), 1, 1, sizeof(unsigned char)); + cacheTex = Director::getInstance()->getTextureCache()->addImage(image, "/dummyTexture"); + image->release(); + } + mesh->setTexture(cacheTex, cocos2d::NTextureData::Usage::Diffuse, false); } } \ No newline at end of file diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 301b9f9356..bbfd47652c 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -606,9 +606,13 @@ public: void printMeshName(cocos2d::Ref* sender); void removeUsedTexture(cocos2d::Ref* sender); + void resetTexture(cocos2d::Ref* sender); + + void refreshSpriteRender(); protected: cocos2d::Sprite3D* _sprite; cocos2d::Texture2D* _meshTex; + std::string _texFile; }; #endif From 9025b010ba67fb7679190021821ca1495dfacd2a Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 18 Dec 2015 10:19:08 +0300 Subject: [PATCH 51/66] =?UTF-8?q?change=D0=B2=20russian=20letter=20=D1=81?= =?UTF-8?q?=20to=20english=20c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/Images/{blocks9с.png => blocks9c.png} | Bin 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/cpp-tests/Resources/Images/{blocks9с.png => blocks9c.png} (100%) diff --git a/tests/cpp-tests/Resources/Images/blocks9с.png b/tests/cpp-tests/Resources/Images/blocks9c.png similarity index 100% rename from tests/cpp-tests/Resources/Images/blocks9с.png rename to tests/cpp-tests/Resources/Images/blocks9c.png From a13a0c35d3e7786e87d6b0a854e71576850cdd51 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 18 Dec 2015 15:40:21 +0800 Subject: [PATCH 52/66] Update h5 sub-module ref Synchronize studio parser match change from h5 modify --- cocos/scripting/js-bindings/script/studio/parsers/action-1.x.js | 2 +- cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js | 2 +- web | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/action-1.x.js b/cocos/scripting/js-bindings/script/studio/parsers/action-1.x.js index 6bcebf2734..b03e849210 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/action-1.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/action-1.x.js @@ -233,6 +233,6 @@ }); }); - load.registerParser("action", "*", parser); + load.registerParser("action", "1.*", parser); })(ccs._load, ccs._parser); diff --git a/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js index 9a7dece156..76f284286f 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/action-2.x.js @@ -310,6 +310,6 @@ }); }); - load.registerParser("action", "2.*", parser); + load.registerParser("action", "*", parser); })(ccs._load, ccs._parser); diff --git a/web b/web index 1fb1d53dee..f723c34bd3 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit 1fb1d53dee1893dbec0012f1bbdad957e25c355a +Subproject commit f723c34bd3a9474d572cf29b7d4f43f8ba2a2eee From 92535703043c8e72f4fd7b25be21d96096817538 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Fri, 18 Dec 2015 17:32:44 +0800 Subject: [PATCH 53/66] update h5 sub-module ref --- web | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web b/web index f723c34bd3..f91d7a39e7 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit f723c34bd3a9474d572cf29b7d4f43f8ba2a2eee +Subproject commit f91d7a39e72c271e6e87ea269e2428c00f3c07cc From b5141a28bdf89695230b2c836a0478c71b0f0c2a Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Fri, 18 Dec 2015 13:28:14 +0000 Subject: [PATCH 54/66] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_3d_auto_api.js | 28 --- .../api/jsb_cocos2dx_3d_extension_auto_api.js | 10 + .../auto/api/jsb_cocos2dx_auto_api.js | 40 ---- .../js-bindings/auto/jsb_cocos2dx_3d_auto.cpp | 57 ----- .../js-bindings/auto/jsb_cocos2dx_3d_auto.hpp | 3 - .../auto/jsb_cocos2dx_3d_extension_auto.cpp | 23 ++ .../auto/jsb_cocos2dx_3d_extension_auto.hpp | 1 + .../js-bindings/auto/jsb_cocos2dx_auto.cpp | 80 ------- .../js-bindings/auto/jsb_cocos2dx_auto.hpp | 4 - .../scripting/lua-bindings/auto/api/Mesh.lua | 19 -- .../auto/api/ParticleSystem3D.lua | 6 + .../lua-bindings/auto/api/Texture2D.lua | 13 -- .../lua-bindings/auto/api/TextureCache.lua | 13 -- .../auto/lua_cocos2dx_3d_auto.cpp | 147 ------------- .../auto/lua_cocos2dx_3d_auto.hpp | 3 - .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 198 ------------------ .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 4 - .../auto/lua_cocos2dx_extension_auto.cpp | 48 +++++ .../auto/lua_cocos2dx_extension_auto.hpp | 1 + 19 files changed, 89 insertions(+), 609 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js index 319d1a4b8e..25ae6f026b 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_auto_api.js @@ -448,16 +448,6 @@ getVertexSizeInBytes : function ( return 0; }, -/** - * @method enableCheckTexture - * @return {bool} - */ -enableCheckTexture : function ( -) -{ - return false; -}, - /** * @method setMaterial * @param {cc.Material} arg0 @@ -558,14 +548,6 @@ str { }, -/** - * @method checkTexture - */ -checkTexture : function ( -) -{ -}, - /** * @method getIndexCount * @return {long} @@ -636,16 +618,6 @@ meshskin { }, -/** - * @method setEnableCheckTexture - * @param {bool} arg0 - */ -setEnableCheckTexture : function ( -bool -) -{ -}, - /** * @method isVisible * @return {bool} diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js index a8e7c2e3d9..214bb30c4e 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_3d_extension_auto_api.js @@ -34,6 +34,16 @@ isEnabled : function ( return false; }, +/** + * @method getRender + * @return {cc.Particle3DRender} + */ +getRender : function ( +) +{ + return cc.Particle3DRender; +}, + /** * @method isKeepLocal * @return {bool} diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 6714bd3924..cbb9e82ad3 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -120,16 +120,6 @@ getPixelsHigh : function ( return 0; }, -/** - * @method setValid - * @param {bool} arg0 - */ -setValid : function ( -bool -) -{ -}, - /** * @method getBitsPerPixelForFormat * @param {cc.Texture2D::PixelFormat} pixelformat @@ -214,16 +204,6 @@ getContentSize : function ( return cc.Size; }, -/** - * @method isValid - * @return {bool} - */ -isValid : function ( -) -{ - return false; -}, - /** * @method setAliasTexParameters */ @@ -21172,16 +21152,6 @@ texture2d return ; }, -/** - * @method setDirty - * @param {bool} arg0 - */ -setDirty : function ( -bool -) -{ -}, - /** * @method renameTextureWithKey * @param {String} arg0 @@ -21202,16 +21172,6 @@ removeUnusedTextures : function ( { }, -/** - * @method isDirty - * @return {bool} - */ -isDirty : function ( -) -{ - return false; -}, - /** * @method removeTexture * @param {cc.Texture2D} arg0 diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp index e429e644be..a3bd9eff57 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.cpp @@ -1232,24 +1232,6 @@ bool js_cocos2dx_3d_Mesh_getVertexSizeInBytes(JSContext *cx, uint32_t argc, jsva JS_ReportError(cx, "js_cocos2dx_3d_Mesh_getVertexSizeInBytes : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_3d_Mesh_enableCheckTexture(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_enableCheckTexture : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->enableCheckTexture(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_3d_Mesh_enableCheckTexture : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_3d_Mesh_setMaterial(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -1452,22 +1434,6 @@ bool js_cocos2dx_3d_Mesh_setName(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setName : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_3d_Mesh_checkTexture(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_checkTexture : Invalid Native Object"); - if (argc == 0) { - cobj->checkTexture(); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_3d_Mesh_checkTexture : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_3d_Mesh_getIndexCount(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -1618,26 +1584,6 @@ bool js_cocos2dx_3d_Mesh_setSkin(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setSkin : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_3d_Mesh_setEnableCheckTexture(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Mesh* cobj = (cocos2d::Mesh *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Mesh_setEnableCheckTexture : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(args.get(0)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Mesh_setEnableCheckTexture : Error processing arguments"); - cobj->setEnableCheckTexture(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_3d_Mesh_setEnableCheckTexture : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_3d_Mesh_isVisible(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -1761,7 +1707,6 @@ void js_register_cocos2dx_3d_Mesh(JSContext *cx, JS::HandleObject global) { JS_FN("getSkin", js_cocos2dx_3d_Mesh_getSkin, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMaterial", js_cocos2dx_3d_Mesh_getMaterial, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getVertexSizeInBytes", js_cocos2dx_3d_Mesh_getVertexSizeInBytes, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("enableCheckTexture", js_cocos2dx_3d_Mesh_enableCheckTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaterial", js_cocos2dx_3d_Mesh_setMaterial, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getName", js_cocos2dx_3d_Mesh_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getIndexFormat", js_cocos2dx_3d_Mesh_getIndexFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -1772,7 +1717,6 @@ void js_register_cocos2dx_3d_Mesh(JSContext *cx, JS::HandleObject global) { JS_FN("getBlendFunc", js_cocos2dx_3d_Mesh_getBlendFunc, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMeshIndexData", js_cocos2dx_3d_Mesh_getMeshIndexData, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setName", js_cocos2dx_3d_Mesh_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("checkTexture", js_cocos2dx_3d_Mesh_checkTexture, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getIndexCount", js_cocos2dx_3d_Mesh_getIndexCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMeshIndexData", js_cocos2dx_3d_Mesh_setMeshIndexData, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getMeshVertexAttribCount", js_cocos2dx_3d_Mesh_getMeshVertexAttribCount, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -1780,7 +1724,6 @@ void js_register_cocos2dx_3d_Mesh(JSContext *cx, JS::HandleObject global) { JS_FN("setForce2DQueue", js_cocos2dx_3d_Mesh_setForce2DQueue, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPrimitiveType", js_cocos2dx_3d_Mesh_getPrimitiveType, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setSkin", js_cocos2dx_3d_Mesh_setSkin, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setEnableCheckTexture", js_cocos2dx_3d_Mesh_setEnableCheckTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isVisible", js_cocos2dx_3d_Mesh_isVisible, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getIndexBuffer", js_cocos2dx_3d_Mesh_getIndexBuffer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setGLProgramState", js_cocos2dx_3d_Mesh_setGLProgramState, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp index 07ee9c6107..99a2b3babe 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp @@ -87,7 +87,6 @@ void register_all_cocos2dx_3d(JSContext* cx, JS::HandleObject obj); bool js_cocos2dx_3d_Mesh_getSkin(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_getMaterial(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_getVertexSizeInBytes(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_3d_Mesh_enableCheckTexture(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_setMaterial(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_getName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_getIndexFormat(JSContext *cx, uint32_t argc, jsval *vp); @@ -98,7 +97,6 @@ bool js_cocos2dx_3d_Mesh_hasVertexAttrib(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_3d_Mesh_getBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_getMeshIndexData(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_setName(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_3d_Mesh_checkTexture(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_getIndexCount(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_setMeshIndexData(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_getMeshVertexAttribCount(JSContext *cx, uint32_t argc, jsval *vp); @@ -106,7 +104,6 @@ bool js_cocos2dx_3d_Mesh_setBlendFunc(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_setForce2DQueue(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_getPrimitiveType(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_setSkin(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_3d_Mesh_setEnableCheckTexture(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_isVisible(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_getIndexBuffer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_Mesh_setGLProgramState(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp index 579fff1384..91304331d2 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.cpp @@ -72,6 +72,28 @@ bool js_cocos2dx_3d_extension_ParticleSystem3D_isEnabled(JSContext *cx, uint32_t JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_3d_extension_ParticleSystem3D_getRender(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ParticleSystem3D* cobj = (cocos2d::ParticleSystem3D *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_extension_ParticleSystem3D_getRender : Invalid Native Object"); + if (argc == 0) { + cocos2d::Particle3DRender* ret = cobj->getRender(); + jsval jsret = JSVAL_NULL; + if (ret) { + jsret = OBJECT_TO_JSVAL(js_get_or_create_jsobject(cx, (cocos2d::Particle3DRender*)ret)); + } else { + jsret = JSVAL_NULL; + }; + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_3d_extension_ParticleSystem3D_getRender : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_3d_extension_ParticleSystem3D_isKeepLocal(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -315,6 +337,7 @@ void js_register_cocos2dx_3d_extension_ParticleSystem3D(JSContext *cx, JS::Handl JS_FN("resumeParticleSystem", js_cocos2dx_3d_extension_ParticleSystem3D_resumeParticleSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("startParticleSystem", js_cocos2dx_3d_extension_ParticleSystem3D_startParticleSystem, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isEnabled", js_cocos2dx_3d_extension_ParticleSystem3D_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getRender", js_cocos2dx_3d_extension_ParticleSystem3D_getRender, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isKeepLocal", js_cocos2dx_3d_extension_ParticleSystem3D_isKeepLocal, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setEnabled", js_cocos2dx_3d_extension_ParticleSystem3D_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getParticleQuota", js_cocos2dx_3d_extension_ParticleSystem3D_getParticleQuota, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp index a10e2073e3..12b0ec79d1 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp @@ -15,6 +15,7 @@ void register_all_cocos2dx_3d_extension(JSContext* cx, JS::HandleObject obj); bool js_cocos2dx_3d_extension_ParticleSystem3D_resumeParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_extension_ParticleSystem3D_startParticleSystem(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_extension_ParticleSystem3D_isEnabled(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_3d_extension_ParticleSystem3D_getRender(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_extension_ParticleSystem3D_isKeepLocal(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_extension_ParticleSystem3D_setEnabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_3d_extension_ParticleSystem3D_getParticleQuota(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index b05b3690ec..4d21ee392d 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -272,26 +272,6 @@ bool js_cocos2dx_Texture2D_getPixelsHigh(JSContext *cx, uint32_t argc, jsval *vp JS_ReportError(cx, "js_cocos2dx_Texture2D_getPixelsHigh : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Texture2D_setValid(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_setValid : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(args.get(0)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_Texture2D_setValid : Error processing arguments"); - cobj->setValid(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Texture2D_setValid : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_Texture2D_getBitsPerPixelForFormat(JSContext *cx, uint32_t argc, jsval *vp) { bool ok = true; @@ -547,24 +527,6 @@ bool js_cocos2dx_Texture2D_getContentSize(JSContext *cx, uint32_t argc, jsval *v JS_ReportError(cx, "js_cocos2dx_Texture2D_getContentSize : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_Texture2D_isValid(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::Texture2D* cobj = (cocos2d::Texture2D *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Texture2D_isValid : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isValid(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_Texture2D_isValid : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_Texture2D_setAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -820,7 +782,6 @@ void js_register_cocos2dx_Texture2D(JSContext *cx, JS::HandleObject global) { JS_FN("hasPremultipliedAlpha", js_cocos2dx_Texture2D_hasPremultipliedAlpha, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithMipmaps", js_cocos2dx_Texture2D_initWithMipmaps, 5, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPixelsHigh", js_cocos2dx_Texture2D_getPixelsHigh, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setValid", js_cocos2dx_Texture2D_setValid, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBitsPerPixelForFormat", js_cocos2dx_Texture2D_getBitsPerPixelForFormat, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getName", js_cocos2dx_Texture2D_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("initWithString", js_cocos2dx_Texture2D_initWithString, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -828,7 +789,6 @@ void js_register_cocos2dx_Texture2D(JSContext *cx, JS::HandleObject global) { JS_FN("getPath", js_cocos2dx_Texture2D_getPath, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("drawInRect", js_cocos2dx_Texture2D_drawInRect, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getContentSize", js_cocos2dx_Texture2D_getContentSize, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isValid", js_cocos2dx_Texture2D_isValid, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAliasTexParameters", js_cocos2dx_Texture2D_setAliasTexParameters, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setAntiAliasTexParameters", js_cocos2dx_Texture2D_setAntiAliasTexParameters, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("generateMipmap", js_cocos2dx_Texture2D_generateMipmap, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), @@ -57727,26 +57687,6 @@ bool js_cocos2dx_TextureCache_getTextureFilePath(JSContext *cx, uint32_t argc, j JS_ReportError(cx, "js_cocos2dx_TextureCache_getTextureFilePath : wrong number of arguments: %d, was expecting %d", argc, 1); return false; } -bool js_cocos2dx_TextureCache_setDirty(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_setDirty : Invalid Native Object"); - if (argc == 1) { - bool arg0; - arg0 = JS::ToBoolean(args.get(0)); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_TextureCache_setDirty : Error processing arguments"); - cobj->setDirty(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_TextureCache_setDirty : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_TextureCache_renameTextureWithKey(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -57785,24 +57725,6 @@ bool js_cocos2dx_TextureCache_removeUnusedTextures(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_TextureCache_removeUnusedTextures : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_TextureCache_isDirty(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::TextureCache* cobj = (cocos2d::TextureCache *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_TextureCache_isDirty : Invalid Native Object"); - if (argc == 0) { - bool ret = cobj->isDirty(); - jsval jsret = JSVAL_NULL; - jsret = BOOLEAN_TO_JSVAL(ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_TextureCache_isDirty : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_TextureCache_removeTexture(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -57894,10 +57816,8 @@ void js_register_cocos2dx_TextureCache(JSContext *cx, JS::HandleObject global) { JS_FN("unbindImageAsync", js_cocos2dx_TextureCache_unbindImageAsync, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureForKey", js_cocos2dx_TextureCache_getTextureForKey, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getTextureFilePath", js_cocos2dx_TextureCache_getTextureFilePath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setDirty", js_cocos2dx_TextureCache_setDirty, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("renameTextureWithKey", js_cocos2dx_TextureCache_renameTextureWithKey, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeUnusedTextures", js_cocos2dx_TextureCache_removeUnusedTextures, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("isDirty", js_cocos2dx_TextureCache_isDirty, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("removeTexture", js_cocos2dx_TextureCache_removeTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("waitForQuit", js_cocos2dx_TextureCache_waitForQuit, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index 974408bf64..d4b96eb820 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -22,7 +22,6 @@ bool js_cocos2dx_Texture2D_releaseGLTexture(JSContext *cx, uint32_t argc, jsval bool js_cocos2dx_Texture2D_hasPremultipliedAlpha(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_initWithMipmaps(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_getPixelsHigh(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Texture2D_setValid(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_getBitsPerPixelForFormat(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_getName(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_initWithString(JSContext *cx, uint32_t argc, jsval *vp); @@ -30,7 +29,6 @@ bool js_cocos2dx_Texture2D_setMaxT(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_getPath(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_drawInRect(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_getContentSize(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_Texture2D_isValid(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_setAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_setAntiAliasTexParameters(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Texture2D_generateMipmap(JSContext *cx, uint32_t argc, jsval *vp); @@ -3761,10 +3759,8 @@ bool js_cocos2dx_TextureCache_addImage(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_unbindImageAsync(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_getTextureForKey(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_getTextureFilePath(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_TextureCache_setDirty(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_renameTextureWithKey(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_removeUnusedTextures(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_TextureCache_isDirty(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_removeTexture(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_waitForQuit(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_TextureCache_TextureCache(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/Mesh.lua b/cocos/scripting/lua-bindings/auto/api/Mesh.lua index 66f4bb433e..32cde6d633 100644 --- a/cocos/scripting/lua-bindings/auto/api/Mesh.lua +++ b/cocos/scripting/lua-bindings/auto/api/Mesh.lua @@ -16,12 +16,6 @@ -- @param self -- @return int#int ret (return value: int) --------------------------------- --- check texture each frame? --- @function [parent=#Mesh] enableCheckTexture --- @param self --- @return bool#bool ret (return value: bool) - -------------------------------- -- Sets a new Material to the Mesh -- @function [parent=#Mesh] setMaterial @@ -75,12 +69,6 @@ -- @param #string name -- @return Mesh#Mesh self (return value: cc.Mesh) --------------------------------- --- check texture --- @function [parent=#Mesh] checkTexture --- @param self --- @return Mesh#Mesh self (return value: cc.Mesh) - -------------------------------- -- Mesh index data setter -- @function [parent=#Mesh] setMeshIndexData @@ -115,13 +103,6 @@ -- @param #cc.MeshSkin skin -- @return Mesh#Mesh self (return value: cc.Mesh) --------------------------------- --- set enable check texture, check texture each frame if enable is true. It is false by default --- @function [parent=#Mesh] setEnableCheckTexture --- @param self --- @param #bool enableCheckTexture --- @return Mesh#Mesh self (return value: cc.Mesh) - -------------------------------- -- -- @function [parent=#Mesh] isVisible diff --git a/cocos/scripting/lua-bindings/auto/api/ParticleSystem3D.lua b/cocos/scripting/lua-bindings/auto/api/ParticleSystem3D.lua index 51d2580076..89ee632088 100644 --- a/cocos/scripting/lua-bindings/auto/api/ParticleSystem3D.lua +++ b/cocos/scripting/lua-bindings/auto/api/ParticleSystem3D.lua @@ -42,6 +42,12 @@ -- @param self -- @return bool#bool ret (return value: bool) +-------------------------------- +-- return particle render +-- @function [parent=#ParticleSystem3D] getRender +-- @param self +-- @return Particle3DRender#Particle3DRender ret (return value: cc.Particle3DRender) + -------------------------------- -- set emitter for particle system, can set your own particle emitter -- @function [parent=#ParticleSystem3D] setEmitter diff --git a/cocos/scripting/lua-bindings/auto/api/Texture2D.lua b/cocos/scripting/lua-bindings/auto/api/Texture2D.lua index b8e0e96a08..b4b552afb4 100644 --- a/cocos/scripting/lua-bindings/auto/api/Texture2D.lua +++ b/cocos/scripting/lua-bindings/auto/api/Texture2D.lua @@ -52,13 +52,6 @@ -- @param self -- @return int#int ret (return value: int) --------------------------------- --- Set if the texture is valid, when it been set as false, it will display as default "file missing texture" --- @function [parent=#Texture2D] setValid --- @param self --- @param #bool valid --- @return Texture2D#Texture2D self (return value: cc.Texture2D) - -------------------------------- -- @overload self, int -- @overload self @@ -112,12 +105,6 @@ -- @param self -- @return size_table#size_table ret (return value: size_table) --------------------------------- --- --- @function [parent=#Texture2D] isValid --- @param self --- @return bool#bool ret (return value: bool) - -------------------------------- -- Sets alias texture parameters:
-- - GL_TEXTURE_MIN_FILTER = GL_NEAREST
diff --git a/cocos/scripting/lua-bindings/auto/api/TextureCache.lua b/cocos/scripting/lua-bindings/auto/api/TextureCache.lua index 1d09cf832b..e5825a152f 100644 --- a/cocos/scripting/lua-bindings/auto/api/TextureCache.lua +++ b/cocos/scripting/lua-bindings/auto/api/TextureCache.lua @@ -94,13 +94,6 @@ -- @param #cc.Texture2D texture -- @return string#string ret (return value: string) --------------------------------- --- --- @function [parent=#TextureCache] setDirty --- @param self --- @param #bool dirty --- @return TextureCache#TextureCache self (return value: cc.TextureCache) - -------------------------------- -- Reload texture from a new file.
-- This function is mainly for editor, won't suggest use it in game for performance reason.
@@ -122,12 +115,6 @@ -- @param self -- @return TextureCache#TextureCache self (return value: cc.TextureCache) --------------------------------- --- --- @function [parent=#TextureCache] isDirty --- @param self --- @return bool#bool ret (return value: bool) - -------------------------------- -- Deletes a texture from the cache given a texture. -- @function [parent=#TextureCache] removeTexture diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index f71501db66..d331e4aed3 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -1843,53 +1843,6 @@ int lua_cocos2dx_3d_Mesh_getVertexSizeInBytes(lua_State* tolua_S) return 0; } -int lua_cocos2dx_3d_Mesh_enableCheckTexture(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Mesh* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Mesh",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Mesh*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Mesh_enableCheckTexture'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Mesh_enableCheckTexture'", nullptr); - return 0; - } - bool ret = cobj->enableCheckTexture(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Mesh:enableCheckTexture",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Mesh_enableCheckTexture'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_3d_Mesh_setMaterial(lua_State* tolua_S) { int argc = 0; @@ -2249,53 +2202,6 @@ int lua_cocos2dx_3d_Mesh_setName(lua_State* tolua_S) return 0; } -int lua_cocos2dx_3d_Mesh_checkTexture(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Mesh* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Mesh",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Mesh*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Mesh_checkTexture'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Mesh_checkTexture'", nullptr); - return 0; - } - cobj->checkTexture(); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Mesh:checkTexture",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Mesh_checkTexture'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_3d_Mesh_setMeshIndexData(lua_State* tolua_S) { int argc = 0; @@ -2543,56 +2449,6 @@ int lua_cocos2dx_3d_Mesh_setSkin(lua_State* tolua_S) return 0; } -int lua_cocos2dx_3d_Mesh_setEnableCheckTexture(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Mesh* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Mesh",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Mesh*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Mesh_setEnableCheckTexture'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Mesh:setEnableCheckTexture"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Mesh_setEnableCheckTexture'", nullptr); - return 0; - } - cobj->setEnableCheckTexture(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Mesh:setEnableCheckTexture",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Mesh_setEnableCheckTexture'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_3d_Mesh_isVisible(lua_State* tolua_S) { int argc = 0; @@ -2792,7 +2648,6 @@ int lua_register_cocos2dx_3d_Mesh(lua_State* tolua_S) tolua_function(tolua_S,"new",lua_cocos2dx_3d_Mesh_constructor); tolua_function(tolua_S,"getMaterial",lua_cocos2dx_3d_Mesh_getMaterial); tolua_function(tolua_S,"getVertexSizeInBytes",lua_cocos2dx_3d_Mesh_getVertexSizeInBytes); - tolua_function(tolua_S,"enableCheckTexture",lua_cocos2dx_3d_Mesh_enableCheckTexture); tolua_function(tolua_S,"setMaterial",lua_cocos2dx_3d_Mesh_setMaterial); tolua_function(tolua_S,"getName",lua_cocos2dx_3d_Mesh_getName); tolua_function(tolua_S,"getMeshVertexAttribute",lua_cocos2dx_3d_Mesh_getMeshVertexAttribute); @@ -2800,13 +2655,11 @@ int lua_register_cocos2dx_3d_Mesh(lua_State* tolua_S) tolua_function(tolua_S,"draw",lua_cocos2dx_3d_Mesh_draw); tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_3d_Mesh_getBlendFunc); tolua_function(tolua_S,"setName",lua_cocos2dx_3d_Mesh_setName); - tolua_function(tolua_S,"checkTexture",lua_cocos2dx_3d_Mesh_checkTexture); tolua_function(tolua_S,"setMeshIndexData",lua_cocos2dx_3d_Mesh_setMeshIndexData); tolua_function(tolua_S,"getMeshVertexAttribCount",lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount); tolua_function(tolua_S,"setBlendFunc",lua_cocos2dx_3d_Mesh_setBlendFunc); tolua_function(tolua_S,"setForce2DQueue",lua_cocos2dx_3d_Mesh_setForce2DQueue); tolua_function(tolua_S,"setSkin",lua_cocos2dx_3d_Mesh_setSkin); - tolua_function(tolua_S,"setEnableCheckTexture",lua_cocos2dx_3d_Mesh_setEnableCheckTexture); tolua_function(tolua_S,"isVisible",lua_cocos2dx_3d_Mesh_isVisible); tolua_function(tolua_S,"setGLProgramState",lua_cocos2dx_3d_Mesh_setGLProgramState); tolua_function(tolua_S,"setVisible",lua_cocos2dx_3d_Mesh_setVisible); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp index 032c267e7f..1be0eff86c 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp @@ -146,9 +146,6 @@ int register_all_cocos2dx_3d(lua_State* tolua_S); - - - diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index bf8c38c53f..f4a6a48909 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -782,56 +782,6 @@ int lua_cocos2dx_Texture2D_getPixelsHigh(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Texture2D_setValid(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Texture2D* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_setValid'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.Texture2D:setValid"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Texture2D_setValid'", nullptr); - return 0; - } - cobj->setValid(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Texture2D:setValid",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_setValid'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Texture2D_getBitsPerPixelForFormat(lua_State* tolua_S) { int argc = 0; @@ -1275,53 +1225,6 @@ int lua_cocos2dx_Texture2D_getContentSize(lua_State* tolua_S) return 0; } -int lua_cocos2dx_Texture2D_isValid(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::Texture2D* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.Texture2D",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::Texture2D*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Texture2D_isValid'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Texture2D_isValid'", nullptr); - return 0; - } - bool ret = cobj->isValid(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Texture2D:isValid",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Texture2D_isValid'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_Texture2D_setAliasTexParameters(lua_State* tolua_S) { int argc = 0; @@ -2022,7 +1925,6 @@ int lua_register_cocos2dx_Texture2D(lua_State* tolua_S) tolua_function(tolua_S,"releaseGLTexture",lua_cocos2dx_Texture2D_releaseGLTexture); tolua_function(tolua_S,"hasPremultipliedAlpha",lua_cocos2dx_Texture2D_hasPremultipliedAlpha); tolua_function(tolua_S,"getPixelsHigh",lua_cocos2dx_Texture2D_getPixelsHigh); - tolua_function(tolua_S,"setValid",lua_cocos2dx_Texture2D_setValid); tolua_function(tolua_S,"getBitsPerPixelForFormat",lua_cocos2dx_Texture2D_getBitsPerPixelForFormat); tolua_function(tolua_S,"getName",lua_cocos2dx_Texture2D_getName); tolua_function(tolua_S,"initWithString",lua_cocos2dx_Texture2D_initWithString); @@ -2030,7 +1932,6 @@ int lua_register_cocos2dx_Texture2D(lua_State* tolua_S) tolua_function(tolua_S,"getPath",lua_cocos2dx_Texture2D_getPath); tolua_function(tolua_S,"drawInRect",lua_cocos2dx_Texture2D_drawInRect); tolua_function(tolua_S,"getContentSize",lua_cocos2dx_Texture2D_getContentSize); - tolua_function(tolua_S,"isValid",lua_cocos2dx_Texture2D_isValid); tolua_function(tolua_S,"setAliasTexParameters",lua_cocos2dx_Texture2D_setAliasTexParameters); tolua_function(tolua_S,"setAntiAliasTexParameters",lua_cocos2dx_Texture2D_setAntiAliasTexParameters); tolua_function(tolua_S,"generateMipmap",lua_cocos2dx_Texture2D_generateMipmap); @@ -88657,56 +88558,6 @@ int lua_cocos2dx_TextureCache_getTextureFilePath(lua_State* tolua_S) return 0; } -int lua_cocos2dx_TextureCache_setDirty(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::TextureCache* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_setDirty'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - bool arg0; - - ok &= luaval_to_boolean(tolua_S, 2,&arg0, "cc.TextureCache:setDirty"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_TextureCache_setDirty'", nullptr); - return 0; - } - cobj->setDirty(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TextureCache:setDirty",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_setDirty'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_TextureCache_renameTextureWithKey(lua_State* tolua_S) { int argc = 0; @@ -88807,53 +88658,6 @@ int lua_cocos2dx_TextureCache_removeUnusedTextures(lua_State* tolua_S) return 0; } -int lua_cocos2dx_TextureCache_isDirty(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::TextureCache* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_isDirty'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_TextureCache_isDirty'", nullptr); - return 0; - } - bool ret = cobj->isDirty(); - tolua_pushboolean(tolua_S,(bool)ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.TextureCache:isDirty",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_isDirty'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_TextureCache_removeTexture(lua_State* tolua_S) { int argc = 0; @@ -89011,10 +88815,8 @@ int lua_register_cocos2dx_TextureCache(lua_State* tolua_S) tolua_function(tolua_S,"unbindImageAsync",lua_cocos2dx_TextureCache_unbindImageAsync); tolua_function(tolua_S,"getTextureForKey",lua_cocos2dx_TextureCache_getTextureForKey); tolua_function(tolua_S,"getTextureFilePath",lua_cocos2dx_TextureCache_getTextureFilePath); - tolua_function(tolua_S,"setDirty",lua_cocos2dx_TextureCache_setDirty); tolua_function(tolua_S,"renameTextureWithKey",lua_cocos2dx_TextureCache_renameTextureWithKey); tolua_function(tolua_S,"removeUnusedTextures",lua_cocos2dx_TextureCache_removeUnusedTextures); - tolua_function(tolua_S,"isDirty",lua_cocos2dx_TextureCache_isDirty); tolua_function(tolua_S,"removeTexture",lua_cocos2dx_TextureCache_removeTexture); tolua_function(tolua_S,"waitForQuit",lua_cocos2dx_TextureCache_waitForQuit); tolua_endmodule(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index aae102f844..c5ea706f82 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -2175,10 +2175,6 @@ int register_all_cocos2dx(lua_State* tolua_S); - - - - diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp index a4e91d3be1..c4692ef4f1 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp @@ -13318,6 +13318,53 @@ int lua_cocos2dx_extension_ParticleSystem3D_isEnabled(lua_State* tolua_S) return 0; } +int lua_cocos2dx_extension_ParticleSystem3D_getRender(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ParticleSystem3D* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.ParticleSystem3D",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ParticleSystem3D*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_extension_ParticleSystem3D_getRender'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_extension_ParticleSystem3D_getRender'", nullptr); + return 0; + } + cocos2d::Particle3DRender* ret = cobj->getRender(); + object_to_luaval(tolua_S, "cc.Particle3DRender",(cocos2d::Particle3DRender*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.ParticleSystem3D:getRender",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_extension_ParticleSystem3D_getRender'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_extension_ParticleSystem3D_setEmitter(lua_State* tolua_S) { int argc = 0; @@ -14003,6 +14050,7 @@ int lua_register_cocos2dx_extension_ParticleSystem3D(lua_State* tolua_S) tolua_function(tolua_S,"addAffector",lua_cocos2dx_extension_ParticleSystem3D_addAffector); tolua_function(tolua_S,"startParticleSystem",lua_cocos2dx_extension_ParticleSystem3D_startParticleSystem); tolua_function(tolua_S,"isEnabled",lua_cocos2dx_extension_ParticleSystem3D_isEnabled); + tolua_function(tolua_S,"getRender",lua_cocos2dx_extension_ParticleSystem3D_getRender); tolua_function(tolua_S,"setEmitter",lua_cocos2dx_extension_ParticleSystem3D_setEmitter); tolua_function(tolua_S,"isKeepLocal",lua_cocos2dx_extension_ParticleSystem3D_isKeepLocal); tolua_function(tolua_S,"setEnabled",lua_cocos2dx_extension_ParticleSystem3D_setEnabled); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp index c7a29df579..089d889ac6 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.hpp @@ -342,6 +342,7 @@ int register_all_cocos2dx_extension(lua_State* tolua_S); + #endif // __cocos2dx_extension_h__ From 9e6657d6b26808f878760cc22994a9d0958f578a Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 18 Dec 2015 22:40:12 +0300 Subject: [PATCH 55/66] fix scale9error error --- cocos/ui/UIScale9Sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/ui/UIScale9Sprite.cpp b/cocos/ui/UIScale9Sprite.cpp index dd10bd886c..914265a84f 100644 --- a/cocos/ui/UIScale9Sprite.cpp +++ b/cocos/ui/UIScale9Sprite.cpp @@ -1099,7 +1099,7 @@ namespace ui { topHeight = capInsets.origin.y - offsets.y; centerHeight = capInsets.size.height; - bottomHeight = originalSize.height - (capInsets.origin.x + centerHeight) - offsets.w; + bottomHeight = originalSize.height - (capInsets.origin.y + centerHeight) - offsets.w; } From f6021d502dcef6335b3a5123cefd884a6d81bcb3 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Sat, 19 Dec 2015 13:12:32 +0800 Subject: [PATCH 56/66] Fix pageViewTest Horizontal scroll won't work in Lua-test --- .../CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua index 237c35d62b..e5d876470e 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -1722,13 +1722,11 @@ add_new_testcase(function() local pageView = ccui.PageView:create() pageView:setTouchEnabled(true) pageView:setContentSize(cc.size(240, 130)) - pageView:setDirection(ccui.PageViewDirection.HORIZONTAL) local backgroundSize = background:getContentSize() pageView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + (backgroundSize.width - pageView:getContentSize().width) / 2, (widgetSize.height - backgroundSize.height) / 2 + (backgroundSize.height - pageView:getContentSize().height) / 2)) - for i = 1 , 3 do local layout = ccui.Layout:create() layout:setContentSize(cc.size(240, 130)) @@ -1788,7 +1786,7 @@ add_new_testcase(function() local pageView = ccui.PageView:create() pageView:setTouchEnabled(true) - pageView:setDirection(ccui.PageViewDirection.VERTICAL) + pageView:setDirection(ccui.ScrollViewDir.vertical) pageView:setContentSize(cc.size(240, 130)) local backgroundSize = background:getContentSize() pageView:setPosition(cc.p((widgetSize.width - backgroundSize.width) / 2 + From a13922161857ba36a79ac4c9b12a1e23db3920dc Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Sat, 19 Dec 2015 13:56:12 +0800 Subject: [PATCH 57/66] Synchronize parser match modify from h5 engine Update h5 engine ref --- cocos/scripting/js-bindings/script/studio/parsers/action-1.x.js | 1 + .../js-bindings/script/studio/parsers/timelineParser-1.x.js | 1 + web | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/js-bindings/script/studio/parsers/action-1.x.js b/cocos/scripting/js-bindings/script/studio/parsers/action-1.x.js index b03e849210..4b4bacff60 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/action-1.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/action-1.x.js @@ -233,6 +233,7 @@ }); }); + load.registerParser("action", "0.*", parser); load.registerParser("action", "1.*", parser); })(ccs._load, ccs._parser); diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-1.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-1.x.js index 2aa5de29b6..61a04a2fbf 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-1.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-1.x.js @@ -287,6 +287,7 @@ }); }); + load.registerParser("timeline", "0.*", parser); load.registerParser("timeline", "1.*", parser); })(ccs._load, ccs._parser); diff --git a/web b/web index f91d7a39e7..8586470e65 160000 --- a/web +++ b/web @@ -1 +1 @@ -Subproject commit f91d7a39e72c271e6e87ea269e2428c00f3c07cc +Subproject commit 8586470e65d43f60b06d2846bde72b384e884e5d From d8817f3cbb842db22dffa281880639bb5e82ccb8 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Sat, 19 Dec 2015 15:44:39 +0800 Subject: [PATCH 58/66] Fix TextField won't show security text when first time set password enable --- cocos/ui/UITextField.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/ui/UITextField.cpp b/cocos/ui/UITextField.cpp index b2af80a606..d2310a60c8 100644 --- a/cocos/ui/UITextField.cpp +++ b/cocos/ui/UITextField.cpp @@ -575,6 +575,8 @@ int TextField::getMaxLength()const void TextField::setPasswordEnabled(bool enable) { _textFieldRenderer->setPasswordEnabled(enable); + if (enable) + setPasswordStyleText(getPasswordStyleText()); } bool TextField::isPasswordEnabled()const From 8bf7908e93d14c9149144d089c4d506779dc3635 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 19 Dec 2015 15:59:27 +0800 Subject: [PATCH 59/66] fix loadingbar direction changed error --- cocos/ui/UILoadingBar.cpp | 32 -------- .../UILoadingBarTest/UILoadingBarTest.cpp | 74 +++++++++++++++++++ .../UILoadingBarTest/UILoadingBarTest.h | 13 ++++ 3 files changed, 87 insertions(+), 32 deletions(-) diff --git a/cocos/ui/UILoadingBar.cpp b/cocos/ui/UILoadingBar.cpp index d96f141369..b232697d92 100644 --- a/cocos/ui/UILoadingBar.cpp +++ b/cocos/ui/UILoadingBar.cpp @@ -111,26 +111,10 @@ void LoadingBar::setDirection(cocos2d::ui::LoadingBar::Direction direction) case Direction::LEFT: _barRenderer->setAnchorPoint(Vec2(0.0f,0.5f)); _barRenderer->setPosition(Vec2(0,_contentSize.height*0.5f)); - if (!_scale9Enabled) - { - auto innerSprite = _barRenderer->getSprite(); - if (nullptr != innerSprite) - { - innerSprite->setFlippedX(false); - } - } break; case Direction::RIGHT: _barRenderer->setAnchorPoint(Vec2(1.0f,0.5f)); _barRenderer->setPosition(Vec2(_totalLength,_contentSize.height*0.5f)); - if (!_scale9Enabled) - { - auto innerSprite = _barRenderer->getSprite(); - if (nullptr != innerSprite) - { - innerSprite->setFlippedX(true); - } - } break; } @@ -183,25 +167,9 @@ void LoadingBar::setupTexture() { case Direction::LEFT: _barRenderer->setAnchorPoint(Vec2(0.0f,0.5f)); - if (!_scale9Enabled) - { - auto innerSprite = _barRenderer->getSprite(); - if (nullptr != innerSprite) - { - innerSprite->setFlippedX(false); - } - } break; case Direction::RIGHT: _barRenderer->setAnchorPoint(Vec2(1.0f,0.5f)); - if (!_scale9Enabled) - { - auto innerSprite = _barRenderer->getSprite(); - if (nullptr != innerSprite) - { - innerSprite->setFlippedX(true); - } - } break; } _barRenderer->setCapInsets(_capInsets); diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index ecd6e31722..58f9aa1cfa 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -12,6 +12,7 @@ UILoadingBarTests::UILoadingBarTests() ADD_TEST_CASE(UILoadingBarTest_Scale9_State_Change); ADD_TEST_CASE(UILoadingBarReloadTexture); ADD_TEST_CASE(UILoadingBarIssue12249); + ADD_TEST_CASE(UILoadingBarTest_Direction); } // UILoadingBarTest_Left @@ -510,3 +511,76 @@ void UILoadingBarIssue12249::update(float delta) loadingBar->setPercent(_count); loadingBarCopy->setPercent(_count); } + +// UILoadingBarTest_Direction + +UILoadingBarTest_Direction::UILoadingBarTest_Direction() + : _count(0) +{ + +} + +UILoadingBarTest_Direction::~UILoadingBarTest_Direction() +{ + //unscheduleUpdate(); +} + +bool UILoadingBarTest_Direction::init() +{ + if (UIScene::init()) + { + //scheduleUpdate(); + + Size widgetSize = _widget->getContentSize(); + + // Add the alert + Text* alert = Text::create("Test LoadingBar Change Direction", + "fonts/Marker Felt.ttf", 30); + alert->setColor(Color3B(159, 168, 176)); + alert->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f - alert->getContentSize().height * 1.75f)); + _uiLayer->addChild(alert); + + // Create the loading bar + LoadingBar* loadingBar = LoadingBar::create("cocosui/sliderProgress.png"); + loadingBar->setTag(0); + loadingBar->setPercent(80); + loadingBar->setPosition(Vec2(widgetSize.width / 2.0f, + widgetSize.height / 2.0f + loadingBar->getContentSize().height / 4.0f)); + + auto loadingBarCopy = (LoadingBar*)loadingBar->clone(); + loadingBarCopy->setTag(1); + loadingBarCopy->setPosition(loadingBar->getPosition() + + Vec2(0, -40)); + loadingBarCopy->setDirection(LoadingBar::Direction::RIGHT); + + Button* button = Button::create("cocosui/animationbuttonnormal.png", + "cocosui/animationbuttonpressed.png"); + button->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + 50)); + button->setTitleText("Click to change direction!"); + + button->addTouchEventListener([=](Ref*, Widget::TouchEventType type) + { + if (type == Widget::TouchEventType::ENDED) + { + if (loadingBar->getDirection() == LoadingBar::Direction::LEFT) + { + loadingBar->setDirection(LoadingBar::Direction::RIGHT); + loadingBarCopy->setDirection(LoadingBar::Direction::LEFT); + } + else + { + loadingBar->setDirection(LoadingBar::Direction::LEFT); + loadingBarCopy->setDirection(LoadingBar::Direction::RIGHT); + } + } + }); + _uiLayer->addChild(loadingBar, 1); + _uiLayer->addChild(loadingBarCopy, 2); + _uiLayer->addChild(button); + + _loadingBar = loadingBar; + return true; + } + return false; +} \ No newline at end of file diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h index b405d34bf2..1d74955cea 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h @@ -129,4 +129,17 @@ protected: int _count; }; +class UILoadingBarTest_Direction : public UIScene +{ +public: + CREATE_FUNC(UILoadingBarTest_Direction); + + UILoadingBarTest_Direction(); + ~UILoadingBarTest_Direction(); + virtual bool init() override; +protected: + int _count; + cocos2d::ui::LoadingBar* _loadingBar; +}; + #endif /* defined(__TestCpp__UILoadingBarTest__) */ From 0f90f74df990dfcdf74afcdde5f89d3fa6e77f54 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Sat, 19 Dec 2015 09:12:27 +0000 Subject: [PATCH 60/66] [ci skip][AUTO]: updating luabinding & jsbinding automatically --- .../auto/api/jsb_cocos2dx_ui_auto_api.js | 40 ++-- .../js-bindings/auto/jsb_cocos2dx_ui_auto.cpp | 80 +++---- .../js-bindings/auto/jsb_cocos2dx_ui_auto.hpp | 4 +- .../lua-bindings/auto/api/Slider.lua | 34 +-- .../auto/lua_cocos2dx_ui_auto.cpp | 198 +++++++++--------- 5 files changed, 178 insertions(+), 178 deletions(-) diff --git a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js index bdbe144255..8c363ebb3e 100644 --- a/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js +++ b/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_ui_auto_api.js @@ -3873,16 +3873,6 @@ getBallNormalFile : function ( return cc.ResourceData; }, -/** - * @method getCapInsetsProgressBarRebderer - * @return {rect_object} - */ -getCapInsetsProgressBarRebderer : function ( -) -{ - return cc.Rect; -}, - /** * @method setScale9Enabled * @param {bool} arg0 @@ -3913,6 +3903,16 @@ getZoomScale : function ( return 0; }, +/** + * @method setCapInsetProgressBarRenderer + * @param {rect_object} arg0 + */ +setCapInsetProgressBarRenderer : function ( +rect +) +{ +}, + /** * @method loadSlidBallTextures * @param {String} arg0 @@ -3981,6 +3981,16 @@ getCapInsetsBarRenderer : function ( return cc.Rect; }, +/** + * @method getCapInsetsProgressBarRenderer + * @return {rect_object} + */ +getCapInsetsProgressBarRenderer : function ( +) +{ + return cc.Rect; +}, + /** * @method loadSlidBallTexturePressed * @param {String} arg0 @@ -4023,16 +4033,6 @@ getBallDisabledFile : function ( return cc.ResourceData; }, -/** - * @method setCapInsetProgressBarRebderer - * @param {rect_object} arg0 - */ -setCapInsetProgressBarRebderer : function ( -rect -) -{ -}, - /** * @method setCapInsetsBarRenderer * @param {rect_object} arg0 diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp index 9e37503e96..c0dd458c62 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.cpp @@ -9482,24 +9482,6 @@ bool js_cocos2dx_ui_Slider_getBallNormalFile(JSContext *cx, uint32_t argc, jsval JS_ReportError(cx, "js_cocos2dx_ui_Slider_getBallNormalFile : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer : Invalid Native Object"); - if (argc == 0) { - const cocos2d::Rect& ret = cobj->getCapInsetsProgressBarRebderer(); - jsval jsret = JSVAL_NULL; - jsret = ccrect_to_jsval(cx, ret); - args.rval().set(jsret); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer : wrong number of arguments: %d, was expecting %d", argc, 0); - return false; -} bool js_cocos2dx_ui_Slider_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -9556,6 +9538,26 @@ bool js_cocos2dx_ui_Slider_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp) JS_ReportError(cx, "js_cocos2dx_ui_Slider_getZoomScale : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + bool ok = true; + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer : Invalid Native Object"); + if (argc == 1) { + cocos2d::Rect arg0; + ok &= jsval_to_ccrect(cx, args.get(0), &arg0); + JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer : Error processing arguments"); + cobj->setCapInsetProgressBarRenderer(arg0); + args.rval().setUndefined(); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer : wrong number of arguments: %d, was expecting %d", argc, 1); + return false; +} bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -9745,6 +9747,24 @@ bool js_cocos2dx_ui_Slider_getCapInsetsBarRenderer(JSContext *cx, uint32_t argc, JS_ReportError(cx, "js_cocos2dx_ui_Slider_getCapInsetsBarRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } +bool js_cocos2dx_ui_Slider_getCapInsetsProgressBarRenderer(JSContext *cx, uint32_t argc, jsval *vp) +{ + JS::CallArgs args = JS::CallArgsFromVp(argc, vp); + JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_getCapInsetsProgressBarRenderer : Invalid Native Object"); + if (argc == 0) { + const cocos2d::Rect& ret = cobj->getCapInsetsProgressBarRenderer(); + jsval jsret = JSVAL_NULL; + jsret = ccrect_to_jsval(cx, ret); + args.rval().set(jsret); + return true; + } + + JS_ReportError(cx, "js_cocos2dx_ui_Slider_getCapInsetsProgressBarRenderer : wrong number of arguments: %d, was expecting %d", argc, 0); + return false; +} bool js_cocos2dx_ui_Slider_loadSlidBallTexturePressed(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -9829,26 +9849,6 @@ bool js_cocos2dx_ui_Slider_getBallDisabledFile(JSContext *cx, uint32_t argc, jsv JS_ReportError(cx, "js_cocos2dx_ui_Slider_getBallDisabledFile : wrong number of arguments: %d, was expecting %d", argc, 0); return false; } -bool js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - bool ok = true; - JS::RootedObject obj(cx, args.thisv().toObjectOrNull()); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::ui::Slider* cobj = (cocos2d::ui::Slider *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer : Invalid Native Object"); - if (argc == 1) { - cocos2d::Rect arg0; - ok &= jsval_to_ccrect(cx, args.get(0), &arg0); - JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer : Error processing arguments"); - cobj->setCapInsetProgressBarRebderer(arg0); - args.rval().setUndefined(); - return true; - } - - JS_ReportError(cx, "js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer : wrong number of arguments: %d, was expecting %d", argc, 1); - return false; -} bool js_cocos2dx_ui_Slider_setCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -10077,21 +10077,21 @@ void js_register_cocos2dx_ui_Slider(JSContext *cx, JS::HandleObject global) { JS_FN("loadSlidBallTextureNormal", js_cocos2dx_ui_Slider_loadSlidBallTextureNormal, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadProgressBarTexture", js_cocos2dx_ui_Slider_loadProgressBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBallNormalFile", js_cocos2dx_ui_Slider_getBallNormalFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("getCapInsetsProgressBarRebderer", js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setScale9Enabled", js_cocos2dx_ui_Slider_setScale9Enabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBallPressedFile", js_cocos2dx_ui_Slider_getBallPressedFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getZoomScale", js_cocos2dx_ui_Slider_getZoomScale, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("setCapInsetProgressBarRenderer", js_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadSlidBallTextures", js_cocos2dx_ui_Slider_loadSlidBallTextures, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("addEventListener", js_cocos2dx_ui_Slider_addEventListener, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setMaxPercent", js_cocos2dx_ui_Slider_setMaxPercent, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadBarTexture", js_cocos2dx_ui_Slider_loadBarTexture, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getProgressBarFile", js_cocos2dx_ui_Slider_getProgressBarFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getCapInsetsBarRenderer", js_cocos2dx_ui_Slider_getCapInsetsBarRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getCapInsetsProgressBarRenderer", js_cocos2dx_ui_Slider_getCapInsetsProgressBarRenderer, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("loadSlidBallTexturePressed", js_cocos2dx_ui_Slider_loadSlidBallTexturePressed, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBackFile", js_cocos2dx_ui_Slider_getBackFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("isScale9Enabled", js_cocos2dx_ui_Slider_isScale9Enabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getBallDisabledFile", js_cocos2dx_ui_Slider_getBallDisabledFile, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("setCapInsetProgressBarRebderer", js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsetsBarRenderer", js_cocos2dx_ui_Slider_setCapInsetsBarRenderer, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("getPercent", js_cocos2dx_ui_Slider_getPercent, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("setCapInsets", js_cocos2dx_ui_Slider_setCapInsets, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), diff --git a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp index a2c3cbc627..ac298496b4 100644 --- a/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp +++ b/cocos/scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp @@ -499,21 +499,21 @@ bool js_cocos2dx_ui_Slider_getMaxPercent(JSContext *cx, uint32_t argc, jsval *vp bool js_cocos2dx_ui_Slider_loadSlidBallTextureNormal(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_loadProgressBarTexture(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getBallNormalFile(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_setScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getBallPressedFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getZoomScale(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_loadSlidBallTextures(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_addEventListener(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_setMaxPercent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_loadBarTexture(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getProgressBarFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp); +bool js_cocos2dx_ui_Slider_getCapInsetsProgressBarRenderer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_loadSlidBallTexturePressed(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getBackFile(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_isScale9Enabled(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getBallDisabledFile(JSContext *cx, uint32_t argc, jsval *vp); -bool js_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_setCapInsetsBarRenderer(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_getPercent(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_ui_Slider_setCapInsets(JSContext *cx, uint32_t argc, jsval *vp); diff --git a/cocos/scripting/lua-bindings/auto/api/Slider.lua b/cocos/scripting/lua-bindings/auto/api/Slider.lua index 8e57df2476..ecae510fb8 100644 --- a/cocos/scripting/lua-bindings/auto/api/Slider.lua +++ b/cocos/scripting/lua-bindings/auto/api/Slider.lua @@ -46,14 +46,6 @@ -- @param self -- @return ResourceData#ResourceData ret (return value: cc.ResourceData) --------------------------------- --- Gets capinsets for progress bar slider, if slider is using scale9 renderer.
--- return Capinsets for progress bar slider.
--- js NA --- @function [parent=#Slider] getCapInsetsProgressBarRebderer --- @param self --- @return rect_table#rect_table ret (return value: rect_table) - -------------------------------- -- Sets if slider is using scale9 renderer.
-- param able True that using scale9 renderer, false otherwise. @@ -75,6 +67,15 @@ -- @param self -- @return float#float ret (return value: float) +-------------------------------- +-- Sets capinsets for progress bar slider, if slider is using scale9 renderer.
+-- param capInsets Capinsets for progress bar slider.
+-- js NA +-- @function [parent=#Slider] setCapInsetProgressBarRenderer +-- @param self +-- @param #rect_table capInsets +-- @return Slider#Slider self (return value: ccui.Slider) + -------------------------------- -- Load textures for slider ball.
-- param normal Normal state texture.
@@ -129,6 +130,14 @@ -- @param self -- @return rect_table#rect_table ret (return value: rect_table) +-------------------------------- +-- Gets capinsets for progress bar slider, if slider is using scale9 renderer.
+-- return Capinsets for progress bar slider.
+-- js NA +-- @function [parent=#Slider] getCapInsetsProgressBarRenderer +-- @param self +-- @return rect_table#rect_table ret (return value: rect_table) + -------------------------------- -- Load pressed state texture for slider ball.
-- param pressed Pressed state texture.
@@ -158,15 +167,6 @@ -- @param self -- @return ResourceData#ResourceData ret (return value: cc.ResourceData) --------------------------------- --- Sets capinsets for progress bar slider, if slider is using scale9 renderer.
--- param capInsets Capinsets for progress bar slider.
--- js NA --- @function [parent=#Slider] setCapInsetProgressBarRebderer --- @param self --- @param #rect_table capInsets --- @return Slider#Slider self (return value: ccui.Slider) - -------------------------------- -- Sets capinsets for bar slider, if slider is using scale9 renderer.
-- param capInsets Capinsets for bar slider. diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp index d7ce78c146..88275c8e48 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp @@ -18832,53 +18832,6 @@ int lua_cocos2dx_ui_Slider_getBallNormalFile(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Slider* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 0) - { - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer'", nullptr); - return 0; - } - const cocos2d::Rect& ret = cobj->getCapInsetsProgressBarRebderer(); - rect_to_luaval(tolua_S, ret); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getCapInsetsProgressBarRebderer",argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Slider_setScale9Enabled(lua_State* tolua_S) { int argc = 0; @@ -19023,6 +18976,56 @@ int lua_cocos2dx_ui_Slider_getZoomScale(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::Rect arg0; + + ok &= luaval_to_rect(tolua_S, 2, &arg0, "ccui.Slider:setCapInsetProgressBarRenderer"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer'", nullptr); + return 0; + } + cobj->setCapInsetProgressBarRenderer(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:setCapInsetProgressBarRenderer",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Slider_loadSlidBallTextures(lua_State* tolua_S) { int argc = 0; @@ -19398,6 +19401,53 @@ int lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer(lua_State* tolua_S) return 0; } +int lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRenderer(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::ui::Slider* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRenderer'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRenderer'", nullptr); + return 0; + } + const cocos2d::Rect& ret = cobj->getCapInsetsProgressBarRenderer(); + rect_to_luaval(tolua_S, ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:getCapInsetsProgressBarRenderer",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRenderer'.",&tolua_err); +#endif + + return 0; +} int lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed(lua_State* tolua_S) { int argc = 0; @@ -19606,56 +19656,6 @@ int lua_cocos2dx_ui_Slider_getBallDisabledFile(lua_State* tolua_S) return 0; } -int lua_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer(lua_State* tolua_S) -{ - int argc = 0; - cocos2d::ui::Slider* cobj = nullptr; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(tolua_S,1,"ccui.Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - cobj = (cocos2d::ui::Slider*)tolua_tousertype(tolua_S,1,0); - -#if COCOS2D_DEBUG >= 1 - if (!cobj) - { - tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer'", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S)-1; - if (argc == 1) - { - cocos2d::Rect arg0; - - ok &= luaval_to_rect(tolua_S, 2, &arg0, "ccui.Slider:setCapInsetProgressBarRebderer"); - if(!ok) - { - tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer'", nullptr); - return 0; - } - cobj->setCapInsetProgressBarRebderer(arg0); - lua_settop(tolua_S, 1); - return 1; - } - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccui.Slider:setCapInsetProgressBarRebderer",argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer'.",&tolua_err); -#endif - - return 0; -} int lua_cocos2dx_ui_Slider_setCapInsetsBarRenderer(lua_State* tolua_S) { int argc = 0; @@ -20076,21 +20076,21 @@ int lua_register_cocos2dx_ui_Slider(lua_State* tolua_S) tolua_function(tolua_S,"loadSlidBallTextureNormal",lua_cocos2dx_ui_Slider_loadSlidBallTextureNormal); tolua_function(tolua_S,"loadProgressBarTexture",lua_cocos2dx_ui_Slider_loadProgressBarTexture); tolua_function(tolua_S,"getBallNormalFile",lua_cocos2dx_ui_Slider_getBallNormalFile); - tolua_function(tolua_S,"getCapInsetsProgressBarRebderer",lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRebderer); tolua_function(tolua_S,"setScale9Enabled",lua_cocos2dx_ui_Slider_setScale9Enabled); tolua_function(tolua_S,"getBallPressedFile",lua_cocos2dx_ui_Slider_getBallPressedFile); tolua_function(tolua_S,"getZoomScale",lua_cocos2dx_ui_Slider_getZoomScale); + tolua_function(tolua_S,"setCapInsetProgressBarRenderer",lua_cocos2dx_ui_Slider_setCapInsetProgressBarRenderer); tolua_function(tolua_S,"loadSlidBallTextures",lua_cocos2dx_ui_Slider_loadSlidBallTextures); tolua_function(tolua_S,"addEventListener",lua_cocos2dx_ui_Slider_addEventListener); tolua_function(tolua_S,"setMaxPercent",lua_cocos2dx_ui_Slider_setMaxPercent); tolua_function(tolua_S,"loadBarTexture",lua_cocos2dx_ui_Slider_loadBarTexture); tolua_function(tolua_S,"getProgressBarFile",lua_cocos2dx_ui_Slider_getProgressBarFile); tolua_function(tolua_S,"getCapInsetsBarRenderer",lua_cocos2dx_ui_Slider_getCapInsetsBarRenderer); + tolua_function(tolua_S,"getCapInsetsProgressBarRenderer",lua_cocos2dx_ui_Slider_getCapInsetsProgressBarRenderer); tolua_function(tolua_S,"loadSlidBallTexturePressed",lua_cocos2dx_ui_Slider_loadSlidBallTexturePressed); tolua_function(tolua_S,"getBackFile",lua_cocos2dx_ui_Slider_getBackFile); tolua_function(tolua_S,"isScale9Enabled",lua_cocos2dx_ui_Slider_isScale9Enabled); tolua_function(tolua_S,"getBallDisabledFile",lua_cocos2dx_ui_Slider_getBallDisabledFile); - tolua_function(tolua_S,"setCapInsetProgressBarRebderer",lua_cocos2dx_ui_Slider_setCapInsetProgressBarRebderer); tolua_function(tolua_S,"setCapInsetsBarRenderer",lua_cocos2dx_ui_Slider_setCapInsetsBarRenderer); tolua_function(tolua_S,"getPercent",lua_cocos2dx_ui_Slider_getPercent); tolua_function(tolua_S,"setCapInsets",lua_cocos2dx_ui_Slider_setCapInsets); From 4f94b03b86ec9309625fc3fc789a887bdcd95e5d Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 19 Dec 2015 15:37:19 +0800 Subject: [PATCH 61/66] Upgrade bindings generator --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 26b56a42b7..54eff9fa73 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 26b56a42b7ea74ca7acb4003c7f98fe149741503 +Subproject commit 54eff9fa737a71fef7886a4c785dc1b10e079231 From ac4f66fff2131b74d1a087252c3c914fb1b73ca1 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Sat, 19 Dec 2015 18:32:43 +0800 Subject: [PATCH 62/66] fix lua focus test --- .../CocoStudioGUITest/CocoStudioGUITest.lua | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua index e5d876470e..114cd78764 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua @@ -2341,6 +2341,15 @@ add_new_testcase(function() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + local function onExit(tag) + if tag == "exit" then + if eventListener ~= nil then + eventDispatcher:removeEventListener(eventListener) + end + end + end + self:registerScriptHandler(onExit) + local winSize = cc.Director:getInstance():getVisibleSize() self._horizontalLayout = ccui.HBox:create() self._horizontalLayout:setPosition(cc.p(20, winSize.height / 2 + 40)) @@ -2474,6 +2483,15 @@ add_new_testcase(function() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + local function onExit(tag) + if tag == "exit" then + if eventListener ~= nil then + eventDispatcher:removeEventListener(eventListener) + end + end + end + self:registerScriptHandler(onExit) + local winSize = cc.Director:getInstance():getVisibleSize() self._verticalLayout = ccui.VBox:create() self._verticalLayout:setPosition(cc.p(winSize.width/2 - 100, winSize.height - 70)) @@ -2607,6 +2625,15 @@ add_new_testcase(function() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + local function onExit(tag) + if tag == "exit" then + if eventListener ~= nil then + eventDispatcher:removeEventListener(eventListener) + end + end + end + self:registerScriptHandler(onExit) + local winSize = cc.Director:getInstance():getVisibleSize() self._verticalLayout = ccui.VBox:create() @@ -2772,6 +2799,15 @@ add_new_testcase(function() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + local function onExit(tag) + if tag == "exit" then + if eventListener ~= nil then + eventDispatcher:removeEventListener(eventListener) + end + end + end + self:registerScriptHandler(onExit) + local winSize = cc.Director:getInstance():getVisibleSize() self._horizontalLayout = ccui.HBox:create() @@ -2937,6 +2973,15 @@ add_new_testcase(function() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithFixedPriority(eventListener, 1) + local function onExit(tag) + if tag == "exit" then + if eventListener ~= nil then + eventDispatcher:removeEventListener(eventListener) + end + end + end + self:registerScriptHandler(onExit) + local winSize = cc.Director:getInstance():getVisibleSize() self._verticalLayout = ccui.VBox:create() From ffbac99dc5a1c226aeb835f4b9d23991658426b5 Mon Sep 17 00:00:00 2001 From: fanli Date: Sat, 19 Dec 2015 22:03:37 +0800 Subject: [PATCH 63/66] fix script samples error with controlButton --- .../script/extension/jsb_ext_create_apis.js | 22 +++++++++++++------ .../CCControlButtonTest.js | 2 +- .../src/ExtensionTest/ExtensionTest.lua | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/cocos/scripting/js-bindings/script/extension/jsb_ext_create_apis.js b/cocos/scripting/js-bindings/script/extension/jsb_ext_create_apis.js index ab0b45867e..78672c48af 100644 --- a/cocos/scripting/js-bindings/script/extension/jsb_ext_create_apis.js +++ b/cocos/scripting/js-bindings/script/extension/jsb_ext_create_apis.js @@ -32,17 +32,25 @@ jsb.EventListenerAssetsManager.prototype._ctor = function(assetsManager, callbac -cc.ControlButton.prototype._ctor = function(label, backgroundSprite, fontSize){ - if(fontSize != undefined) - this.initWithTitleAndFontNameAndFontSize(label, backgroundSprite, fontSize); - else if(backgroundSprite != undefined) - this.initWithLabelAndBackgroundSprite(label, backgroundSprite); - else if(label != undefined) +cc.ControlButton.prototype._ctor = function(label, backgroundSprite, fontSize, fontName, autoSizeWithLabel ){ + if (autoSizeWithLabel !== undefined && backgroundSprite) { + this.initWithLabelAndBackgroundSprite(label, backgroundSprite, autoSizeWithLabel); + } + else if(fontName !== undefined && fontSize !== undefined) { + this.initWithTitleAndFontNameAndFontSize(label, fontName, fontSize); + } + else if(backgroundSprite !== undefined) { + this.initWithLabelAndBackgroundSprite(label, backgroundSprite, true); + } + else if(label !== undefined) { this.initWithBackgroundSprite(label); - else + } + else { this.init(); + } }; + cc.ControlColourPicker.prototype._ctor = function(){ this.init(); }; diff --git a/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.js b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.js index cb30419028..03092ff658 100644 --- a/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.js +++ b/tests/js-tests/src/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.js @@ -264,7 +264,7 @@ var ControlButtonTest_Styling = ControlScene.extend({ titleButton.color = cc.color(159, 168, 176); - var button = new cc.ControlButton(titleButton, backgroundButton); + var button = new cc.ControlButton(titleButton, backgroundButton, null, null, false); button.setBackgroundSpriteForState(backgroundHighlightedButton, cc.CONTROL_STATE_HIGHLIGHTED); button.setTitleColorForState(cc.color.WHITE, cc.CONTROL_STATE_HIGHLIGHTED); diff --git a/tests/lua-tests/src/ExtensionTest/ExtensionTest.lua b/tests/lua-tests/src/ExtensionTest/ExtensionTest.lua index e62cb39f23..e20f04c7c2 100644 --- a/tests/lua-tests/src/ExtensionTest/ExtensionTest.lua +++ b/tests/lua-tests/src/ExtensionTest/ExtensionTest.lua @@ -591,7 +591,7 @@ local function runCCControlTest() pTitleButton:setColor(cc.c3b(159, 168, 176)) - local pButton = cc.ControlButton:create(pTitleButton, pBackgroundButton) + local pButton = cc.ControlButton:create(pTitleButton, pBackgroundButton,false) pButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, cc.CONTROL_STATE_HIGH_LIGHTED ) pButton:setTitleColorForState(cc.c3b(255,255,255), cc.CONTROL_STATE_HIGH_LIGHTED ) From ae48253da6a659d8af1575bc5e8aee5d583d7b0a Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 19 Dec 2015 22:44:25 +0800 Subject: [PATCH 64/66] Fix UI addEventListener issue --- cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js b/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js index 3e88a1419b..6568a84fc1 100644 --- a/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js +++ b/cocos/scripting/js-bindings/script/ccui/jsb_cocos2d_ui.js @@ -521,9 +521,9 @@ ccui.Widget.prototype.addTouchEventListener = function (selector, target) { function _ui_addEventListener(selector, target) { if (target === undefined) - this._addTouchEventListener(selector); + this._addEventListener(selector); else - this._addTouchEventListener(selector.bind(target)); + this._addEventListener(selector.bind(target)); } function _ui_applyEventListener(ctor) { var proto = ctor.prototype; From 386b8508710c6d0572a89cd169a5dc9285e30395 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 19 Dec 2015 22:45:22 +0800 Subject: [PATCH 65/66] Fix issue in MenuItem init usage --- cocos/scripting/js-bindings/script/jsb_create_apis.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/js-bindings/script/jsb_create_apis.js b/cocos/scripting/js-bindings/script/jsb_create_apis.js index b3f24c3eb8..0001d2e9a0 100644 --- a/cocos/scripting/js-bindings/script/jsb_create_apis.js +++ b/cocos/scripting/js-bindings/script/jsb_create_apis.js @@ -254,7 +254,10 @@ _p._ctor = function(normalImage, selectedImage, three, four, five) { target = five; } callback = callback ? callback.bind(target) : null; - this.initWithNormalSprite(new cc.Sprite(normalImage), new cc.Sprite(selectedImage), disabledImage ? new cc.Sprite(disabledImage) : new cc.Sprite(normalImage), callback); + var normalSprite = new cc.Sprite(normalImage); + var selectedSprite = new cc.Sprite(selectedImage); + var disabledSprite = disabledImage ? new cc.Sprite(disabledImage) : new cc.Sprite(normalImage); + this.initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, callback); } }; From 8f836162aa2ebaa7aa9ec0859475824df6e2365f Mon Sep 17 00:00:00 2001 From: pandamicro Date: Sat, 19 Dec 2015 22:45:57 +0800 Subject: [PATCH 66/66] Temporary disable forceGC on win32 --- cocos/2d/CCMenuItem.cpp | 8 -------- .../js-bindings/manual/ScriptingCore.cpp | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp index b4695d01d3..ef446b0e02 100644 --- a/cocos/2d/CCMenuItem.cpp +++ b/cocos/2d/CCMenuItem.cpp @@ -104,14 +104,6 @@ void MenuItem::activate() { _callback(this); } -#if CC_ENABLE_SCRIPT_BINDING - if (kScriptTypeNone != _scriptType) - { - BasicScriptData data(this); - ScriptEvent scriptEvent(kMenuClickedEvent,&data); - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent); - } -#endif } } diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index f7dc5e5cfa..1c8d8ff674 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -925,8 +925,10 @@ bool ScriptingCore::executeScript(JSContext *cx, uint32_t argc, jsval *vp) bool ScriptingCore::forceGC(JSContext *cx, uint32_t argc, jsval *vp) { +#if CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 JSRuntime *rt = JS_GetRuntime(cx); JS_GC(rt); +#endif return true; } @@ -1047,6 +1049,8 @@ int ScriptingCore::handleActionEvent(void* data) js_proxy_t * p = jsb_get_native_proxy(actionObject); if (!p) return 0; + JSAutoCompartment ac(_cx, _global.ref()); + int ret = 0; JS::RootedValue retval(_cx); @@ -1076,7 +1080,9 @@ int ScriptingCore::handleNodeEvent(void* data) js_proxy_t * p = jsb_get_native_proxy(node); if (!p) return 0; - + + JSAutoCompartment ac(_cx, _global.ref()); + int ret = 0; JS::RootedValue retval(_cx); jsval dataVal = INT_TO_JSVAL(1); @@ -1140,6 +1146,8 @@ int ScriptingCore::handleComponentEvent(void* data) js_proxy_t * p = jsb_get_native_proxy(node); if (!p) return 0; + JSAutoCompartment ac(_cx, _global.ref()); + int ret = 0; JS::RootedValue retval(_cx); jsval dataVal = INT_TO_JSVAL(1); @@ -1180,7 +1188,7 @@ bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::Eve bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, const std::vector& touches, cocos2d::Event* event, JS::MutableHandleValue jsvalRet) { - JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JSAutoCompartment ac(_cx, _global.ref()); bool ret = false; @@ -1234,7 +1242,7 @@ bool ScriptingCore::handleTouchEvent(void* nativeObj, cocos2d::EventTouch::Event bool ScriptingCore::handleTouchEvent(void* nativeObj, cocos2d::EventTouch::EventCode eventCode, cocos2d::Touch* touch, cocos2d::Event* event, JS::MutableHandleValue jsvalRet) { - JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET + JSAutoCompartment ac(_cx, _global.ref()); std::string funcName = getTouchFuncName(eventCode); bool ret = false; @@ -1491,7 +1499,7 @@ int ScriptingCore::sendEvent(ScriptEvent* evt) return 0; } - JSAutoCompartment ac(_cx, _global.ref().get()); + JSAutoCompartment ac(_cx, _global.ref()); switch (evt->type) {