From 6efa17cddf1ee00a67fc7be76902b3e34278b83e Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Tue, 11 Mar 2014 11:53:44 +0800 Subject: [PATCH 01/35] Add event type to ListView --- cocos/gui/UIListView.cpp | 20 +++++++++++--- cocos/gui/UIListView.h | 5 ++-- .../UIListViewTest/UIListViewTest.cpp | 26 +++++++++++++------ 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index ba3b3084bb..28b3defab0 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -407,12 +407,24 @@ void ListView::addEventListenerListView(Ref *target, SEL_ListViewEvent selector) _listViewEventSelector = selector; } -void ListView::selectedItemEvent() +void ListView::selectedItemEvent(int state) { - if (_listViewEventListener && _listViewEventSelector) + switch (state) { - (_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECTEDITEM); + case 0: + if (_listViewEventListener && _listViewEventSelector) + { + (_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECTEDITEM_START); + } + break; + default: + if (_listViewEventListener && _listViewEventSelector) + { + (_listViewEventListener->*_listViewEventSelector)(this, LISTVIEW_ONSELECTEDITEM_END); + } + break; } + } void ListView::interceptTouchEvent(int handleState, Widget *sender, const Point &touchPoint) @@ -430,7 +442,7 @@ void ListView::interceptTouchEvent(int handleState, Widget *sender, const Point } parent = dynamic_cast(parent->getParent()); } - selectedItemEvent(); + selectedItemEvent(handleState); } } diff --git a/cocos/gui/UIListView.h b/cocos/gui/UIListView.h index 58cf81ff46..bd806b899e 100644 --- a/cocos/gui/UIListView.h +++ b/cocos/gui/UIListView.h @@ -45,7 +45,8 @@ typedef enum typedef enum { - LISTVIEW_ONSELECTEDITEM + LISTVIEW_ONSELECTEDITEM_START, + LISTVIEW_ONSELECTEDITEM_END }ListViewEventType; typedef void (Ref::*SEL_ListViewEvent)(Ref*,ListViewEventType); @@ -193,7 +194,7 @@ protected: virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; virtual void copyClonedWidgetChildren(Widget* model) override; - void selectedItemEvent(); + void selectedItemEvent(int state); virtual void interceptTouchEvent(int handleState,Widget* sender,const Point &touchPoint) override; protected: diff --git a/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp b/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp index 3939de5b26..748dcf03b2 100644 --- a/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp +++ b/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp @@ -176,13 +176,18 @@ void UIListViewTest_Vertical::selectedItemEvent(Ref *pSender, ListViewEventType { switch (type) { - case LISTVIEW_ONSELECTEDITEM: + case cocos2d::ui::LISTVIEW_ONSELECTEDITEM_START: { ListView* listView = static_cast(pSender); - CCLOG("select child index = %ld", listView->getCurSelectedIndex()); - } + CCLOG("select child start index = %ld", listView->getCurSelectedIndex()); break; - + } + case cocos2d::ui::LISTVIEW_ONSELECTEDITEM_END: + { + ListView* listView = static_cast(pSender); + CCLOG("select child end index = %ld", listView->getCurSelectedIndex()); + break; + } default: break; } @@ -354,13 +359,18 @@ void UIListViewTest_Horizontal::selectedItemEvent(Ref *pSender, ListViewEventTyp { switch (type) { - case LISTVIEW_ONSELECTEDITEM: + case cocos2d::ui::LISTVIEW_ONSELECTEDITEM_START: { ListView* listView = static_cast(pSender); - CCLOG("select child index = %ld", listView->getCurSelectedIndex()); - } + CCLOG("select child start index = %ld", listView->getCurSelectedIndex()); break; - + } + case cocos2d::ui::LISTVIEW_ONSELECTEDITEM_END: + { + ListView* listView = static_cast(pSender); + CCLOG("select child end index = %ld", listView->getCurSelectedIndex()); + break; + } default: break; } From 8db680b9eeca2eefa74ecb15bac16a52d34a4d40 Mon Sep 17 00:00:00 2001 From: heliclei Date: Tue, 11 Mar 2014 13:58:43 +0800 Subject: [PATCH 02/35] add EnumChildNodesByName, walk node tree with callback --- cocos/2d/CCNode.cpp | 20 +++++- cocos/2d/CCNode.h | 14 +++- .../cpp-tests/Classes/NodeTest/NodeTest.cpp | 67 ++++++++++++++++++- samples/cpp-tests/Classes/NodeTest/NodeTest.h | 10 +++ 4 files changed, 106 insertions(+), 5 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index bb41763ca5..db29d20954 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -715,7 +715,6 @@ Node* Node::getChildByTag(int tag) Node* Node::getChildByName(const std::string& name) { - for (auto& child : _children) { @@ -733,6 +732,25 @@ Node* Node::getChildByName(const std::string& name) return nullptr; } +void Node::EnumChildNodesByName(const std::string& name, std::function callback) +{ + for (auto& child : _children) + { + + if(child->_name == name) + { + bool stop = false; + callback(child, &stop); + if(stop == true) + { + return; + } + } + child->EnumChildNodesByName(name, callback); + } + return; +} + /* "add" logic MUST only be on this method * If a class want's to extend the 'addChild' behavior it only needs * to override this method diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index b324a67609..6d87db907a 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -789,17 +789,25 @@ public: player = parent->getChildByName("player") @endcode * - * @return A C string that identifies the node. + * @return A string that identifies the node. */ virtual std::string& getName(); /** - * Changes the string TAG that is used to identify the node easily. + * Changes the name that is used to identify the node easily. * - * Please refer to getLabel for the sample code. + * Please refer to getName for the sample code. * * @param name A string that indentifies the node. */ virtual void setName(const std::string& name); + /** + * Search the children to perform processing for nodes which share a name. + * @param name the name to search for + * @param callback, A callback to execute on nodes that match the name parameter. The callback takes the following arguments: + * node: A node that matches the name. + * stop: A pointer to a Boolean variable. Your callback can set this to YES to terminate the enumeration. + */ + virtual void EnumChildNodesByName(const std::string& name, std::function callback); /** * Returns a custom user data pointer * diff --git a/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp b/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp index 5c88e07a50..00abe06cf4 100644 --- a/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -57,6 +57,7 @@ static std::function createFunctions[] = CL(Test4), CL(Test5), CL(Test6), + CL(NodeEnumChildByNameTest), CL(StressTest1), CL(StressTest2), CL(NodeToWorld), @@ -108,7 +109,7 @@ TestCocosNodeDemo::~TestCocosNodeDemo(void) std::string TestCocosNodeDemo::title() const { - return "No title"; + return "Node Test"; } std::string TestCocosNodeDemo::subtitle() const @@ -352,6 +353,70 @@ std::string Test6::subtitle() const return "remove/cleanup with children"; } +//------------------------------------------------------------------ +// +// NodeEnumChildByNameTest +// +//------------------------------------------------------------------ +void NodeEnumChildByNameTest::onEnter() +{ + TestCocosNodeDemo::onEnter(); + auto sp10 = Sprite::create(s_pathSister1); + auto sp11 = Sprite::create(s_pathSister1); + auto sp12 = Sprite::create(s_pathSister1); + auto sp20 = Sprite::create(s_pathSister2); + auto sp21 = Sprite::create(s_pathSister2); + auto sp22 = Sprite::create(s_pathSister2); + + sp10->setPosition(Point(100,60)); + sp11->setPosition(Point(100,160)); + sp12->setPosition(Point(100,260)); + sp20->setPosition(Point(380,60)); + sp21->setPosition(Point(380,160)); + sp22->setPosition(Point(380,260)); + + sp10->setName("sister1"); + sp11->setName("sister1"); + sp12->setName("sister1"); + sp20->setName("sister2"); + sp21->setName("sister2"); + sp22->setName("sister2"); + + addChild(sp10); + addChild(sp11); + addChild(sp12); + addChild(sp20); + addChild(sp21); + addChild(sp22); + + auto fn1 = std::bind(&NodeEnumChildByNameTest::runAction1, this, std::placeholders::_1, std::placeholders::_2); + auto fn2 = std::bind(&NodeEnumChildByNameTest::runAction2, this, std::placeholders::_1, std::placeholders::_2); + + EnumChildNodesByName("sister1", fn1); + EnumChildNodesByName("sister2", fn2); +} + +void NodeEnumChildByNameTest::runAction1(Node* node, bool* stop) +{ + auto rot = RotateBy::create(2, 360); + auto rot_back = rot->reverse(); + auto forever1 = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); + node->runAction(forever1); + +} + +void NodeEnumChildByNameTest::runAction2(Node* node, bool* stop) +{ + auto actionUp = JumpBy::create(2, Point(0,0), 80, 4); + auto forever2 = RepeatForever::create(Sequence::create(actionUp, NULL)); + node->runAction(forever2); +} + +std::string NodeEnumChildByNameTest::subtitle() const +{ + return "Enum child nodes by name"; +} + //------------------------------------------------------------------ // // StressTest1 diff --git a/samples/cpp-tests/Classes/NodeTest/NodeTest.h b/samples/cpp-tests/Classes/NodeTest/NodeTest.h index 5938eb9a4f..04ca240519 100644 --- a/samples/cpp-tests/Classes/NodeTest/NodeTest.h +++ b/samples/cpp-tests/Classes/NodeTest/NodeTest.h @@ -263,6 +263,16 @@ protected: Sprite *_sprite; }; +class NodeEnumChildByNameTest : public TestCocosNodeDemo +{ +public: + CREATE_FUNC(NodeEnumChildByNameTest); + virtual void onEnter() override; + virtual std::string subtitle() const override; + void runAction1(Node* node, bool* stop); + void runAction2(Node* node, bool* stop); +}; + class CocosNodeTestScene : public TestScene { public: From 80417f0f3509fb433ab7e74b0e75002f56cc35b3 Mon Sep 17 00:00:00 2001 From: heliclei Date: Tue, 11 Mar 2014 15:27:28 +0800 Subject: [PATCH 03/35] correct naming convetion --- cocos/2d/CCNode.cpp | 4 ++-- cocos/2d/CCNode.h | 2 +- samples/cpp-tests/Classes/NodeTest/NodeTest.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index db29d20954..0a70fcb79e 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -732,7 +732,7 @@ Node* Node::getChildByName(const std::string& name) return nullptr; } -void Node::EnumChildNodesByName(const std::string& name, std::function callback) +void Node::enumChildNodesByName(const std::string& name, std::function callback) { for (auto& child : _children) { @@ -746,7 +746,7 @@ void Node::EnumChildNodesByName(const std::string& name, std::functionEnumChildNodesByName(name, callback); + child->enumChildNodesByName(name, callback); } return; } diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 6d87db907a..f870be2baf 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -807,7 +807,7 @@ public: * node: A node that matches the name. * stop: A pointer to a Boolean variable. Your callback can set this to YES to terminate the enumeration. */ - virtual void EnumChildNodesByName(const std::string& name, std::function callback); + virtual void enumChildNodesByName(const std::string& name, std::function callback); /** * Returns a custom user data pointer * diff --git a/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp b/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp index 00abe06cf4..a9c08dea82 100644 --- a/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -392,8 +392,8 @@ void NodeEnumChildByNameTest::onEnter() auto fn1 = std::bind(&NodeEnumChildByNameTest::runAction1, this, std::placeholders::_1, std::placeholders::_2); auto fn2 = std::bind(&NodeEnumChildByNameTest::runAction2, this, std::placeholders::_1, std::placeholders::_2); - EnumChildNodesByName("sister1", fn1); - EnumChildNodesByName("sister2", fn2); + enumChildNodesByName("sister1", fn1); + enumChildNodesByName("sister2", fn2); } void NodeEnumChildByNameTest::runAction1(Node* node, bool* stop) From f2c483876ad923b5464c8ef21e111024b7fb745d Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Wed, 12 Mar 2014 10:07:55 +0800 Subject: [PATCH 04/35] Fixed bug of guireader --- .../cocostudio/CCSGUIReader.cpp | 4 ++++ .../CustomWidget/CustomParticleWidget.cpp | 20 ++++++++++++++++++- .../CustomWidget/CustomParticleWidget.h | 4 ++++ .../CustomParticleWidgetReader.cpp | 12 +++++++---- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 1787772d07..4cdf348b33 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1070,6 +1070,10 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va { readerName = "PageViewReader"; } + else if (dynamic_cast(widget)) + { + readerName = "WidgetReader"; + } reader = ObjectFactory::getInstance()->createWidgetReaderProtocol(readerName); setPropsForAllWidgetFromJsonDictionary(reader, widget, uiOptions); diff --git a/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp b/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp index a37b6a1f03..1f618a04d7 100644 --- a/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp +++ b/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp @@ -89,9 +89,27 @@ void CustomParticleWidget::setParticlePosition(const Point &pos) _emitterPostion = pos; } -const CCPoint& CustomParticleWidget::getParticlePosition() const +const Point& CustomParticleWidget::getParticlePosition() const { return _emitterPostion; } +void CustomParticleWidget::playParticle() +{ + if (_emitter) + { + _emitter->resetSystem(); + } + +} + +void CustomParticleWidget::stopParticle() +{ + if (_emitter) + { + _emitter->stopSystem(); + } + +} + diff --git a/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h b/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h index dee49860a8..2bb5264f96 100644 --- a/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h +++ b/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.h @@ -27,6 +27,10 @@ public: void setParticlePosition(const cocos2d::Point& pos); const cocos2d::Point& getParticlePosition() const; + void playParticle(); + + void stopParticle(); + protected: virtual bool init(); virtual void initRenderer(); diff --git a/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp b/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp index f070381ed4..1e8c955e3d 100644 --- a/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp +++ b/samples/cpp-tests/Classes/ExtensionsTest/CocoStudioGUITest/CustomWidget/CustomParticleWidgetReader.cpp @@ -8,6 +8,7 @@ #include "CustomParticleWidgetReader.h" #include "CustomParticleWidget.h" +#include "cocostudio/CCSGUIReader.h" USING_NS_CC; USING_NS_CC_EXT; @@ -39,13 +40,16 @@ void CustomParticleWidgetReader::setProperties(const std::string& classType, Widget *widget, const rapidjson::Value &customOptions) { + GUIReader* guiReader = GUIReader::getInstance(); CustomParticleWidget* custom = static_cast(widget); - bool isExistParticlePlist = DICTOOL->checkObjectExist_json(customOptions, "ParticlePlist"); - if (isExistParticlePlist) + bool isExistPlistFile = DICTOOL->checkObjectExist_json(customOptions, "PlistFile"); + if (isExistPlistFile) { - const char* ParticlePlist = DICTOOL->getStringValue_json(customOptions, "ParticlePlist"); - custom->setParticlePlist(ParticlePlist); + const char* PlistFile = DICTOOL->getStringValue_json(customOptions, "PlistFile"); + std::string PlistFilePath = guiReader->getFilePath(); + PlistFilePath.append(PlistFile); + custom->setParticlePlist(PlistFilePath.c_str()); } } From 4153667249be1e3b33e36c735cd3d21a85e24116 Mon Sep 17 00:00:00 2001 From: chuanweizhang2013 Date: Wed, 12 Mar 2014 11:04:56 +0800 Subject: [PATCH 05/35] add runtime template --- .../frameworks/runtime-src/Classes/Runtime.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp index de4c76df02..5fc3dc5d2f 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/Runtime.cpp @@ -503,10 +503,10 @@ public: for (int i=0;i< sizeof(commands)/sizeof(Console::Command);i++) { _console->addCommand(commands[i]); } - _console->listenOnTCP(6001); + _console->listenOnTCP(6010); _fileserver=new FileServer(); - _fileserver->listenOnTCP(6002); + _fileserver->listenOnTCP(6020); } ~ConsoleCustomCommand() { From a907580d0af746aad96ad450c4a498fddab063bf Mon Sep 17 00:00:00 2001 From: heliclei Date: Wed, 12 Mar 2014 14:15:45 +0800 Subject: [PATCH 06/35] use lambda callback --- cocos/2d/CCNode.cpp | 2 +- cocos/2d/CCNode.h | 4 +-- .../cpp-tests/Classes/NodeTest/NodeTest.cpp | 35 ++++++++----------- samples/cpp-tests/Classes/NodeTest/NodeTest.h | 2 -- 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 0a70fcb79e..7a49183eb5 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -732,7 +732,7 @@ Node* Node::getChildByName(const std::string& name) return nullptr; } -void Node::enumChildNodesByName(const std::string& name, std::function callback) +void Node::enumChildNodesByName(const std::string& name, const std::function& callback) { for (auto& child : _children) { diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index f870be2baf..a6021113c1 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -805,9 +805,9 @@ public: * @param name the name to search for * @param callback, A callback to execute on nodes that match the name parameter. The callback takes the following arguments: * node: A node that matches the name. - * stop: A pointer to a Boolean variable. Your callback can set this to YES to terminate the enumeration. + * stop: A pointer to a Boolean variable. Your callback can set this to true to terminate the enumeration. */ - virtual void enumChildNodesByName(const std::string& name, std::function callback); + virtual void enumChildNodesByName(const std::string& name, const std::function& callback); /** * Returns a custom user data pointer * diff --git a/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp b/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp index a9c08dea82..c5d7a00f15 100644 --- a/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/samples/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -389,28 +389,23 @@ void NodeEnumChildByNameTest::onEnter() addChild(sp21); addChild(sp22); - auto fn1 = std::bind(&NodeEnumChildByNameTest::runAction1, this, std::placeholders::_1, std::placeholders::_2); - auto fn2 = std::bind(&NodeEnumChildByNameTest::runAction2, this, std::placeholders::_1, std::placeholders::_2); - - enumChildNodesByName("sister1", fn1); - enumChildNodesByName("sister2", fn2); + enumChildNodesByName("sister1", + [&](Node* node, bool* stop) + { + auto rot = RotateBy::create(2, 360); + auto rot_back = rot->reverse(); + auto forever1 = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); + node->runAction(forever1); + }); + enumChildNodesByName("sister2", + [&](Node* node, bool* stop) + { + auto actionUp = JumpBy::create(2, Point(0,0), 80, 4); + auto forever2 = RepeatForever::create(Sequence::create(actionUp, NULL)); + node->runAction(forever2); + }); } -void NodeEnumChildByNameTest::runAction1(Node* node, bool* stop) -{ - auto rot = RotateBy::create(2, 360); - auto rot_back = rot->reverse(); - auto forever1 = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); - node->runAction(forever1); - -} - -void NodeEnumChildByNameTest::runAction2(Node* node, bool* stop) -{ - auto actionUp = JumpBy::create(2, Point(0,0), 80, 4); - auto forever2 = RepeatForever::create(Sequence::create(actionUp, NULL)); - node->runAction(forever2); -} std::string NodeEnumChildByNameTest::subtitle() const { diff --git a/samples/cpp-tests/Classes/NodeTest/NodeTest.h b/samples/cpp-tests/Classes/NodeTest/NodeTest.h index 04ca240519..9506fd6181 100644 --- a/samples/cpp-tests/Classes/NodeTest/NodeTest.h +++ b/samples/cpp-tests/Classes/NodeTest/NodeTest.h @@ -269,8 +269,6 @@ public: CREATE_FUNC(NodeEnumChildByNameTest); virtual void onEnter() override; virtual std::string subtitle() const override; - void runAction1(Node* node, bool* stop); - void runAction2(Node* node, bool* stop); }; class CocosNodeTestScene : public TestScene From 9c95c1e456cde31b247b614bbf8dde9c4ebc4318 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 12 Mar 2014 14:27:52 +0800 Subject: [PATCH 07/35] Replace cc.LabelTTF:create with cc.Label:create --- .../AccelerometerTest/AccelerometerTest.lua | 4 ++-- .../ActionManagerTest/ActionManagerTest.lua | 9 ++++--- .../ActionsProgressTest.lua | 6 ++--- .../lua-tests/src/ActionsTest/ActionsTest.lua | 24 ++++++++++++------- .../AssetsManagerTest/AssetsManagerModule.lua | 3 ++- .../AssetsManagerTest/AssetsManagerTest.lua | 3 ++- tests/lua-tests/src/BugsTest/BugsTest.lua | 18 +++++++++----- .../CocoStudioArmatureTest.lua | 17 ++++++++----- .../CocoStudioSceneTest.lua | 3 ++- .../CocosDenshionTest/CocosDenshionTest.lua | 3 ++- .../CurrentLanguageTest.lua | 6 +++-- .../DrawPrimitivesTest/DrawPrimitivesTest.lua | 6 +++-- tests/lua-tests/src/testResource.lua | 5 ++++ 13 files changed, 71 insertions(+), 36 deletions(-) diff --git a/tests/lua-tests/src/AccelerometerTest/AccelerometerTest.lua b/tests/lua-tests/src/AccelerometerTest/AccelerometerTest.lua index 76aeb3a008..795d04f49d 100644 --- a/tests/lua-tests/src/AccelerometerTest/AccelerometerTest.lua +++ b/tests/lua-tests/src/AccelerometerTest/AccelerometerTest.lua @@ -7,9 +7,9 @@ local function AccelerometerMainLayer() local function onEnter() layer:setAccelerometerEnabled(true) - - local label = cc.LabelTTF:create(title(), "Arial", 32) + local label = cc.Label:create(title(), "fonts/arial.ttf", 32) layer:addChild(label, 1) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 50) ) local ball = cc.Sprite:create("Images/ball.png") diff --git a/tests/lua-tests/src/ActionManagerTest/ActionManagerTest.lua b/tests/lua-tests/src/ActionManagerTest/ActionManagerTest.lua index 5d3941c3bf..91e33220f6 100644 --- a/tests/lua-tests/src/ActionManagerTest/ActionManagerTest.lua +++ b/tests/lua-tests/src/ActionManagerTest/ActionManagerTest.lua @@ -68,8 +68,9 @@ local function PauseTest() local function onNodeEvent(event) if event == "enter" then local s = cc.Director:getInstance():getWinSize() - local l = cc.LabelTTF:create("After 3 seconds grossini should move", "Thonburi", 16) + local l = cc.Label:create("After 3 seconds grossini should move", "fonts/Thonburi.ttf", 16) ret:addChild(l) + l:setAnchorPoint(cc.p(0.5, 0.5)) l:setPosition( cc.p(s.width / 2, 245) ) local grossini = cc.Sprite:create(s_pPathGrossini) @@ -101,9 +102,10 @@ end -------------------------------------------------------------------- local function RemoveTest() local ret = createTestLayer("Remove Test") - local l = cc.LabelTTF:create("Should not crash", "Thonburi", 16) + local l = cc.Label:create("Should not crash", "fonts/Thonburi.ttf", 16) local s = cc.Director:getInstance():getWinSize() ret:addChild(l) + l:setAnchorPoint(cc.p(0.5, 0.5)) l:setPosition( cc.p(s.width / 2, 245)) local pMove = cc.MoveBy:create(2, cc.p(200, 0)) @@ -145,9 +147,10 @@ local function ResumeTest() local function onNodeEvent(event) if event == "enter" then - local l = cc.LabelTTF:create("Grossini only rotate/scale in 3 seconds", "Thonburi", 16) + local l = cc.Label:create("Grossini only rotate/scale in 3 seconds", "fonts/Thonburi.ttf", 16) ret:addChild(l) local s = cc.Director:getInstance():getWinSize() + l:setAnchorPoint(cc.p(0.5, 0.5)) l:setPosition( s.width / 2, 245) local pGrossini = cc.Sprite:create(s_pPathGrossini) diff --git a/tests/lua-tests/src/ActionsProgressTest/ActionsProgressTest.lua b/tests/lua-tests/src/ActionsProgressTest/ActionsProgressTest.lua index 8d53dcd301..84db9cdc97 100644 --- a/tests/lua-tests/src/ActionsProgressTest/ActionsProgressTest.lua +++ b/tests/lua-tests/src/ActionsProgressTest/ActionsProgressTest.lua @@ -198,7 +198,7 @@ local function SpriteProgressBarTintAndFade() left:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.TintTo:create(1, 255, 0, 0), cc.TintTo:create(1, 0, 255, 0), cc.TintTo:create(1, 0, 0, 255)))) layer:addChild(left) - left:addChild(cc.LabelTTF:create("Tint", "Marker Felt", 20.0)) + left:addChild(cc.Label:create("Tint", "fonts/Marker Felt.ttf", 20.0)) local middle = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) middle:setType(cc.PROGRESS_TIMER_TYPE_BAR) @@ -213,7 +213,7 @@ local function SpriteProgressBarTintAndFade() middle:runAction(cc.RepeatForever:create(fade2)) layer:addChild(middle) - middle:addChild(cc.LabelTTF:create("Fade", "Marker Felt", 20.0)) + middle:addChild(cc.Label:create("Fade", "fonts/Marker Felt.ttf", 20.0)) local right = cc.ProgressTimer:create(cc.Sprite:create(s_pPathSister2)) right:setType(cc.PROGRESS_TIMER_TYPE_BAR) @@ -227,7 +227,7 @@ local function SpriteProgressBarTintAndFade() right:runAction(cc.RepeatForever:create(cc.Sequence:create(cc.FadeTo:create(1.0, 0), cc.FadeTo:create(1.0, 255)))) layer:addChild(right) - right:addChild(cc.LabelTTF:create("Tint and Fade", "Marker Felt", 20.0)) + right:addChild(cc.Label:create("Tint and Fade", "fonts/Marker Felt.ttf", 20.0)) Helper.subtitleLabel:setString("ProgressTo Bar Mid") return layer diff --git a/tests/lua-tests/src/ActionsTest/ActionsTest.lua b/tests/lua-tests/src/ActionsTest/ActionsTest.lua index 9b70078388..734677ae92 100644 --- a/tests/lua-tests/src/ActionsTest/ActionsTest.lua +++ b/tests/lua-tests/src/ActionsTest/ActionsTest.lua @@ -184,7 +184,8 @@ local function ActionRotationalSkewVSStandardSkew() box:ignoreAnchorPointForPosition(false); box:setPosition(cc.p(s.width/2, s.height - 100 - box:getContentSize().height/2)); layer:addChild(box); - local label = cc.LabelTTF:create("Standard cocos2d Skew", "Marker Felt", 16); + local label = cc.Label:create("Standard cocos2d Skew", s_MarkerFeltFontPath, 16); + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p(s.width/2, s.height - 100 + label:getContentSize().height)); layer:addChild(label); local actionTo = cc.SkewBy:create(2, 360, 0); @@ -199,7 +200,8 @@ local function ActionRotationalSkewVSStandardSkew() box:ignoreAnchorPointForPosition(false); box:setPosition(cc.p(s.width/2, s.height - 250 - box:getContentSize().height/2)); layer:addChild(box); - label = cc.LabelTTF:create("Rotational Skew", "Marker Felt", 16); + label = cc.Label:create("Rotational Skew", s_MarkerFeltFontPath, 16); + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p(s.width/2, s.height - 250 + label:getContentSize().height/2)); layer:addChild(label); local actionTo2 = cc.RotateBy:create(2, 360); @@ -588,21 +590,24 @@ end local actionSequenceLayer = nil local function ActionSequenceCallback1() - local label = cc.LabelTTF:create("callback 1 called", "Marker Felt", 16) + local label = cc.Label:create("callback 1 called", s_MarkerFeltFontPath, 16) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(size.width / 4, size.height / 2) actionSequenceLayer:addChild(label) end local function ActionSequenceCallback2(sender) - local label = cc.LabelTTF:create("callback 2 called", "Marker Felt", 16) + local label = cc.Label:create("callback 2 called", s_MarkerFeltFontPath, 16) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p(size.width / 4 * 2, size.height / 2)) actionSequenceLayer:addChild(label) end local function ActionSequenceCallback3(sender) - local label = cc.LabelTTF:create("callback 3 called", "Marker Felt", 16) + local label = cc.Label:create("callback 3 called", s_MarkerFeltFontPath, 16) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p(size.width / 4 * 3, size.height / 2)) actionSequenceLayer:addChild(label) @@ -784,21 +789,24 @@ end local callFuncLayer = nil local function CallFucnCallback1() - local label = cc.LabelTTF:create("callback 1 called", "Marker Felt", 16) + local label = cc.Label:create("callback 1 called", s_MarkerFeltFontPath, 16) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(size.width / 4, size.height / 2) callFuncLayer:addChild(label) end local function CallFucnCallback2(sender) - local label = cc.LabelTTF:create("callback 2 called", "Marker Felt", 16) + local label = cc.Label:create("callback 2 called", s_MarkerFeltFontPath, 16) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(size.width / 4 * 2, size.height / 2) callFuncLayer:addChild(label) end local function CallFucnCallback3(sender) - local label = cc.LabelTTF:create("callback 3 called", "Marker Felt", 16) + local label = cc.Label:create("callback 3 called", s_MarkerFeltFontPath, 16) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(size.width / 4 * 3, size.height / 2) callFuncLayer:addChild(label) diff --git a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua index ab9b3874a6..0fbe58efca 100644 --- a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua +++ b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua @@ -26,7 +26,8 @@ function AssetManagerModule.newScene(backfunc) backMenu:addChild(backMenuItem) layer:addChild(backMenu,6) - local helloLabel = cc.LabelTTF:create("Hello World", "Arial", 38) + local helloLabel = cc.Label:create("Hello World", s_arialPath, 38) + helloLabel:setAnchorPoint(cc.p(0.5, 0.5)) helloLabel:setPosition(cc.p(winSize.width / 2, winSize.height - 40)) layer:addChild(helloLabel, 5) diff --git a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua index 83e7c33d3c..eecbf1b83e 100644 --- a/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua +++ b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerTest.lua @@ -35,7 +35,8 @@ local function updateLayer() cc.MenuItemFont:setFontName("Arial") cc.MenuItemFont:setFontSize(24) - local progressLable = cc.LabelTTF:create("","Arial",30) + local progressLable = cc.Label:create("",s_arialPath,30) + progressLable:setAnchorPoint(cc.p(0.5, 0.5)) progressLable:setPosition(cc.p(140,50)) layer:addChild(progressLable) diff --git a/tests/lua-tests/src/BugsTest/BugsTest.lua b/tests/lua-tests/src/BugsTest/BugsTest.lua index 822f7be3ad..3ad2898899 100644 --- a/tests/lua-tests/src/BugsTest/BugsTest.lua +++ b/tests/lua-tests/src/BugsTest/BugsTest.lua @@ -90,7 +90,8 @@ local function BugTest458() local function InitQuestionContainerSprite(pSprite) --Add label - local pLabel = cc.LabelTTF:create("Answer 1", "Arial", 12) + local pLabel = cc.Label:create("Answer 1", s_arialPath, 12) + pLabel:setAnchorPoint(cc.p(0.5,0.5)) pLabel:setTag(100) --Add the background @@ -189,7 +190,8 @@ local BugTest624_2_entry = nil local function BugTest624() local pLayer = cc.Layer:create() - local pLabel = cc.LabelTTF:create("Layer1", "Marker Felt", 36) + local pLabel = cc.Label:create("Layer1", s_markerFeltFontPath, 36) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(Winsize.width / 2, Winsize.height / 2)) pLayer:addChild(pLabel) pLayer:setAccelerometerEnabled(true) @@ -228,7 +230,8 @@ end function BugTest624_2() local pLayer = cc.Layer:create() - local pLabel = cc.LabelTTF:create("Layer2", "Marker Felt", 36) + local pLabel = cc.Label:create("Layer2", s_markerFeltFontPath, 36) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(Winsize.width / 2, Winsize.height / 2)) pLayer:addChild(pLabel) pLayer:setAccelerometerEnabled(true) @@ -316,7 +319,8 @@ local function BugTest914() cc.Director:getInstance():replaceScene(scene) end - local label = cc.LabelTTF:create("Hello World", "Marker Felt", 64) + local label = cc.Label:create("Hello World", s_markerFeltFontPath, 64) + label:setAnchorPoint(cc.p(0.5, 0.5)) --position the label on the center of the screen label:setPosition(cc.p( Winsize.width /2 , Winsize.height/2 )) layer:addChild(label) @@ -378,7 +382,8 @@ local function BugTest1159() pScene:addChild(pLayer) cc.Director:getInstance():replaceScene(cc.TransitionPageTurn:create(1.0, pScene, false)) end - local label = cc.MenuItemLabel:create(cc.LabelTTF:create("Flip Me", "Helvetica", 24)) + local label = cc.MenuItemLabel:create(cc.Label:create("Flip Me", "Helvetica", 24)) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:registerScriptTapHandler(menuCallback) local menu = cc.Menu:create() menu:addChild(label) @@ -589,7 +594,8 @@ local function BugsTestMainLayer() local i = 1 for i = 1, nTestCount do - local label = cc.LabelTTF:create(testNames[i], "Arial", 24) + local label = cc.Label:create(testNames[i], s_arialPath, 24) + label:setAnchorPoint(cc.p(0.5, 0.5)) local pMenuItem = cc.MenuItemLabel:create(label) pMenuItem:registerScriptTapHandler(menuCallback) pItemMenu:addChild(pMenuItem, i + kItemTagBasic) diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua index adca6996a5..0eee54fb29 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua @@ -195,13 +195,15 @@ function ArmatureTestLayer:createToExtensionMenu() end function ArmatureTestLayer:creatTitleAndSubTitle(idx) - local title = cc.LabelTTF:create(ArmatureTestLayer.title(idx),"Arial",18) + local title = cc.Label:create(ArmatureTestLayer.title(idx), s_arialPath, 18) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setColor(cc.c3b(0,0,0)) self:addChild(title, 1, 10000) title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) local subTitle = nil if "" ~= ArmatureTestLayer.subTitle(idx) then - local subTitle = cc.LabelTTF:create(ArmatureTestLayer.subTitle(idx), "Arial", 18) + local subTitle = cc.Label:create(ArmatureTestLayer.subTitle(idx), s_arialPath, 18) + subTitle:setAnchorPoint(cc.p(0.5, 0.5)) subTitle:setColor(cc.c3b(0,0,0)) self:addChild(subTitle, 1, 10001) subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) @@ -226,16 +228,18 @@ function TestAsynchronousLoading:onEnter() self._restarItem:setEnabled(false) self._nextItem:setEnabled(false) - local title = cc.LabelTTF:create(ArmatureTestLayer.title(1),"Arial",18) + local title = cc.Label:create(ArmatureTestLayer.title(1), s_arialPath, 18) title:setColor(cc.c3b(0,0,0)) self:addChild(title, 1, 10000) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) local subTitle = nil if "" ~= ArmatureTestLayer.subTitle(1) then local subInfo = ArmatureTestLayer.subTitle(1) .. 0.0 - local subTitle = cc.LabelTTF:create(subInfo, "Arial", 18) + local subTitle = cc.Label:create(subInfo, s_arialPath, 18) subTitle:setColor(cc.c3b(0,0,0)) self:addChild(subTitle, 1, 10001) + subTitle:setAnchorPoint(cc.p(0.5, 0.5)) subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) end @@ -428,7 +432,7 @@ end function TestPerformance:refreshTitle() local subTitleInfo = ArmatureTestLayer.subTitle(5) .. self._armatureCount - local label = tolua.cast(self:getChildByTag(10001),"cc.LabelTTF") + local label = tolua.cast(self:getChildByTag(10001),"cc.Label") label:setString(subTitleInfo) end @@ -1160,7 +1164,8 @@ function TestArmatureNesting2:onEnter() end self._touchedMenu = false - local label = cc.LabelTTF:create("Change Mount", "Arial", 20) + local label = cc.Label:create("Change Mount", s_arialPath, 20) + label:setAnchorPoint(cc.p(0.5, 0.5)) local menuItem = cc.MenuItemLabel:create(label) menuItem:registerScriptTapHandler(changeMountCallback) local menu = cc.Menu:create(menuItem) diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua index 292352189a..a56fadc849 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua @@ -63,7 +63,8 @@ function SceneEditorTestLayer.create() end function SceneEditorTestLayer:createTitle() - local title = cc.LabelTTF:create(self.title[sceneEditorTestIdx],"Arial",18) + local title = cc.Label:create(self.title[sceneEditorTestIdx], s_arialPath, 18) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setColor(cc.c3b(255, 255, 255)) self:addChild(title, 1, 10000) title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) diff --git a/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua b/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua index 5cc281471a..89ec9223d8 100644 --- a/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua +++ b/tests/lua-tests/src/CocosDenshionTest/CocosDenshionTest.lua @@ -98,7 +98,8 @@ local function CocosDenshionTest() m_nTestCount = table.getn(testItems) local i = 1 for i = 1, m_nTestCount do - local label = cc.LabelTTF:create(testItems[i], "Arial", 24) + local label = cc.Label:create(testItems[i], s_arialPath, 24) + label:setAnchorPoint(cc.p(0.5, 0.5)) local pMenuItem = cc.MenuItemLabel:create(label) pMenuItem:registerScriptTapHandler(menuCallback) m_pItmeMenu:addChild(pMenuItem, i + 10000 -1) diff --git a/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua b/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua index b89f7da164..2fd67c6271 100644 --- a/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua +++ b/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua @@ -1,10 +1,12 @@ local function CurrentLanguageTest() local ret = cc.Layer:create() - local label = cc.LabelTTF:create("Current language Test", "Arial", 28) + local label = cc.Label:create("Current language Test", s_arialPath, 28) ret:addChild(label, 0) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y-50) ) - local labelLanguage = cc.LabelTTF:create("", "Arial", 20) + local labelLanguage = cc.LabelTTF:create("", s_arialPath, 20) + labelLanguage:setAnchorPoint(cc.p(0.5, 0.5)) labelLanguage:setPosition(VisibleRect:center()) local currentLanguageType = cc.Application:getInstance():getCurrentLanguage() diff --git a/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua b/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua index a2884fb64d..14aed46552 100644 --- a/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua +++ b/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua @@ -66,13 +66,15 @@ local function drawPrimitivesMainLayer() local function InitTitle(layer) --Title - local lableTitle = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local lableTitle = cc.Label:create(GetTitle(), s_arialPath, 40) layer:addChild(lableTitle, 15) + lableTitle:setAnchorPoint(cc.p(0.5, 0.5)) lableTitle:setPosition(cc.p(size.width / 2, size.height - 32)) lableTitle:setColor(cc.c3b(255, 255, 40)) --SubTitle - local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16) + local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), s_thonburiPath, 16) layer:addChild(subLabelTitle, 15) + subLabelTitle:setAnchorPoint(cc.p(0.5, 0.5)) subLabelTitle:setPosition(cc.p(size.width / 2, size.height - 80)) end diff --git a/tests/lua-tests/src/testResource.lua b/tests/lua-tests/src/testResource.lua index ca53adaa85..b490e3a6dc 100644 --- a/tests/lua-tests/src/testResource.lua +++ b/tests/lua-tests/src/testResource.lua @@ -39,3 +39,8 @@ s_LevelMapTga = "TileMaps/levelmap.tga" -- spine test resource s_pPathSpineBoyJson = "spine/spineboy.json" s_pPathSpineBoyAtlas = "spine/spineboy.atlas" + +-- fonts resource +s_markerFeltFontPath = "fonts/Marker Felt.ttf" +s_arialPath = "fonts/arial.ttf" +s_thonburiPath = "fonts/Thonburi.ttf" From fa40bee0230dfee59914fae1b51c018fb6f64b72 Mon Sep 17 00:00:00 2001 From: heliclei Date: Wed, 12 Mar 2014 14:50:44 +0800 Subject: [PATCH 08/35] fix lambda introducer --- tests/cpp-tests/Classes/NodeTest/NodeTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index c5d7a00f15..625a6a7808 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -390,7 +390,7 @@ void NodeEnumChildByNameTest::onEnter() addChild(sp22); enumChildNodesByName("sister1", - [&](Node* node, bool* stop) + [](Node* node, bool* stop) { auto rot = RotateBy::create(2, 360); auto rot_back = rot->reverse(); @@ -398,7 +398,7 @@ void NodeEnumChildByNameTest::onEnter() node->runAction(forever1); }); enumChildNodesByName("sister2", - [&](Node* node, bool* stop) + [](Node* node, bool* stop) { auto actionUp = JumpBy::create(2, Point(0,0), 80, 4); auto forever2 = RepeatForever::create(Sequence::create(actionUp, NULL)); From 611cccd3e7f76c8e0f428685b34a2ae11408009b Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 12 Mar 2014 15:59:48 +0800 Subject: [PATCH 09/35] [win32] HelloCpp -> cpp-empty-test, HelloLua -> lua-empty-test. --- build/cocos2d-win32.vc2012.sln | 14 +++++++++- ...elloCpp.vcxproj => cpp-empty-test.vcxproj} | 14 +++++----- ...filters => cpp-empty-test.vcxproj.filters} | 0 ...xproj.user => cpp-empty-test.vcxproj.user} | 0 tests/cpp-empty-test/proj.win32/main.cpp | 3 -- ...elloLua.vcxproj => lua-empty-test.vcxproj} | 20 ++++++------- ...filters => lua-empty-test.vcxproj.filters} | 0 ...xproj.user => lua-empty-test.vcxproj.user} | 0 .../project/proj.win32/main.cpp | 3 -- .../proj.win32/lua-tests.win32.vcxproj | 28 +++++++++---------- .../proj.win32/lua-tests.win32.vcxproj.user | 4 +-- 11 files changed, 46 insertions(+), 40 deletions(-) rename tests/cpp-empty-test/proj.win32/{HelloCpp.vcxproj => cpp-empty-test.vcxproj} (94%) rename tests/cpp-empty-test/proj.win32/{HelloCpp.vcxproj.filters => cpp-empty-test.vcxproj.filters} (100%) rename tests/cpp-empty-test/proj.win32/{HelloCpp.vcxproj.user => cpp-empty-test.vcxproj.user} (100%) rename tests/lua-empty-test/project/proj.win32/{HelloLua.vcxproj => lua-empty-test.vcxproj} (94%) rename tests/lua-empty-test/project/proj.win32/{HelloLua.vcxproj.filters => lua-empty-test.vcxproj.filters} (100%) rename tests/lua-empty-test/project/proj.win32/{HelloLua.vcxproj.user => lua-empty-test.vcxproj.user} (100%) diff --git a/build/cocos2d-win32.vc2012.sln b/build/cocos2d-win32.vc2012.sln index 55948b4cba..dc713f721a 100644 --- a/build/cocos2d-win32.vc2012.sln +++ b/build/cocos2d-win32.vc2012.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 +# Visual Studio Express 2012 for Windows Desktop Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" @@ -29,6 +29,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua-tests", "..\tests\lua-t EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGUI", "..\cocos\ui\proj.win32\libGUI.vcxproj", "{7E06E92C-537A-442B-9E4A-4761C84F8A1A}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-empty-test", "..\tests\cpp-empty-test\proj.win32\cpp-empty-test.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua-empty-test", "..\tests\lua-empty-test\project\proj.win32\lua-empty-test.vcxproj", "{13E55395-94A2-4CD9-BFC2-1A051F80C17D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -91,6 +95,14 @@ Global {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Debug|Win32.Build.0 = Debug|Win32 {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Release|Win32.ActiveCfg = Release|Win32 {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Release|Win32.Build.0 = Release|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.ActiveCfg = Debug|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.Build.0 = Debug|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.ActiveCfg = Release|Win32 + {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.Build.0 = Release|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.ActiveCfg = Debug|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Debug|Win32.Build.0 = Debug|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.ActiveCfg = Release|Win32 + {13E55395-94A2-4CD9-BFC2-1A051F80C17D}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/tests/cpp-empty-test/proj.win32/HelloCpp.vcxproj b/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj similarity index 94% rename from tests/cpp-empty-test/proj.win32/HelloCpp.vcxproj rename to tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj index 6da099a164..e38b7d723d 100644 --- a/tests/cpp-empty-test/proj.win32/HelloCpp.vcxproj +++ b/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj @@ -12,7 +12,7 @@ {B8BF9E81-35FD-4582-BA1C-B85FA365BABB} - HelloCppwin32 + cpp-empty-test-win32 Win32Proj @@ -36,12 +36,12 @@ - - + + - - + + @@ -133,11 +133,11 @@ - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} false - + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/tests/cpp-empty-test/proj.win32/HelloCpp.vcxproj.filters b/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj.filters similarity index 100% rename from tests/cpp-empty-test/proj.win32/HelloCpp.vcxproj.filters rename to tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj.filters diff --git a/tests/cpp-empty-test/proj.win32/HelloCpp.vcxproj.user b/tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj.user similarity index 100% rename from tests/cpp-empty-test/proj.win32/HelloCpp.vcxproj.user rename to tests/cpp-empty-test/proj.win32/cpp-empty-test.vcxproj.user diff --git a/tests/cpp-empty-test/proj.win32/main.cpp b/tests/cpp-empty-test/proj.win32/main.cpp index bcc0e091d4..a0fce34fd3 100644 --- a/tests/cpp-empty-test/proj.win32/main.cpp +++ b/tests/cpp-empty-test/proj.win32/main.cpp @@ -1,6 +1,5 @@ #include "main.h" #include "../Classes/AppDelegate.h" -#include "CCEGLView.h" USING_NS_CC; @@ -14,7 +13,5 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView eglView; - eglView.init("HelloCpp",900,640); return Application::getInstance()->run(); } diff --git a/tests/lua-empty-test/project/proj.win32/HelloLua.vcxproj b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj similarity index 94% rename from tests/lua-empty-test/project/proj.win32/HelloLua.vcxproj rename to tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj index 1967dfe52d..e86789ad2d 100644 --- a/tests/lua-empty-test/project/proj.win32/HelloLua.vcxproj +++ b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj @@ -12,7 +12,7 @@ {13E55395-94A2-4CD9-BFC2-1A051F80C17D} - HelloLua.win32 + lua-empty-test.win32 @@ -70,12 +70,12 @@ false Win32 true - $(IntDir)HelloLua.tlb - HelloLua.h + $(IntDir)lua-empty-test.tlb + lua-empty-test.h - HelloLua_i.c - HelloLua_p.c + lua-empty-test_i.c + lua-empty-test_p.c Disabled @@ -104,7 +104,7 @@ MachineX86 - xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua\script" "$(ProjectDir)..\..\HelloLua\Resources" /e /Y + xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua\script" "$(ProjectDir)..\..\lua-empty-test\Resources" /e /Y if not exist "$(OutDir)" mkdir "$(OutDir)" @@ -118,12 +118,12 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ false Win32 true - $(IntDir)HelloLua.tlb - HelloLua.h + $(IntDir)lua-empty-test.tlb + lua-empty-test.h - HelloLua_i.c - HelloLua_p.c + lua-empty-test_i.c + lua-empty-test_p.c $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\scripting\lua\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) diff --git a/tests/lua-empty-test/project/proj.win32/HelloLua.vcxproj.filters b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj.filters similarity index 100% rename from tests/lua-empty-test/project/proj.win32/HelloLua.vcxproj.filters rename to tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj.filters diff --git a/tests/lua-empty-test/project/proj.win32/HelloLua.vcxproj.user b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj.user similarity index 100% rename from tests/lua-empty-test/project/proj.win32/HelloLua.vcxproj.user rename to tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj.user diff --git a/tests/lua-empty-test/project/proj.win32/main.cpp b/tests/lua-empty-test/project/proj.win32/main.cpp index b07e50bc66..5c23b025b9 100644 --- a/tests/lua-empty-test/project/proj.win32/main.cpp +++ b/tests/lua-empty-test/project/proj.win32/main.cpp @@ -24,9 +24,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, // create the application instance AppDelegate app; - EGLView eglView; - eglView.init("HelloLua",900,640); - int ret = Application::getInstance()->run(); #ifdef USE_WIN32_CONSOLE diff --git a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj index fedc339b88..c302683476 100644 --- a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj +++ b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj @@ -105,13 +105,13 @@ if not exist "$(OutDir)" mkdir "$(OutDir)" -if exist "$(OutDir)\test-lua-res" rd /s /q "$(OutDir)\test-lua-res" -mkdir "$(OutDir)\test-lua-res" -mkdir "$(OutDir)\test-lua-res\src" -xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script" "$(OutDir)\test-lua-res" /e /Y -xcopy "$(ProjectDir)..\..\src" "$(OutDir)\test-lua-res\src" /e /Y -xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(OutDir)\test-lua-res" /e /Y -xcopy "$(ProjectDir)..\..\res" "$(OutDir)\test-lua-res" /e /Y +if exist "$(OutDir)\lua-tests-res" rd /s /q "$(OutDir)\lua-tests-res" +mkdir "$(OutDir)\lua-tests-res" +mkdir "$(OutDir)\lua-tests-res\src" +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script" "$(OutDir)\lua-tests-res" /e /Y +xcopy "$(ProjectDir)..\..\src" "$(OutDir)\lua-tests-res\src" /e /Y +xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(OutDir)\lua-tests-res" /e /Y +xcopy "$(ProjectDir)..\..\res" "$(OutDir)\lua-tests-res" /e /Y copy files @@ -159,13 +159,13 @@ xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\win32\*.*" "$(OutDir)" if not exist "$(OutDir)" mkdir "$(OutDir)" -if exist "$(OutDir)\test-lua-res" rd /s /q "$(OutDir)\test-lua-res" -mkdir "$(OutDir)\test-lua-res" -mkdir "$(OutDir)\test-lua-res\src" -xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script" "$(OutDir)\test-lua-res" /e /Y -xcopy "$(ProjectDir)..\..\src" "$(OutDir)\test-lua-res\src" /e /Y -xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(OutDir)\test-lua-res" /e /Y -xcopy "$(ProjectDir)..\..\res" "$(OutDir)\test-lua-res" /e /Y +if exist "$(OutDir)\lua-tests-res" rd /s /q "$(OutDir)\lua-tests-res" +mkdir "$(OutDir)\lua-tests-res" +mkdir "$(OutDir)\lua-tests-res\src" +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script" "$(OutDir)\lua-tests-res" /e /Y +xcopy "$(ProjectDir)..\..\src" "$(OutDir)\lua-tests-res\src" /e /Y +xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(OutDir)\lua-tests-res" /e /Y +xcopy "$(ProjectDir)..\..\res" "$(OutDir)\lua-tests-res" /e /Y copy files diff --git a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.user b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.user index 63179a676c..e03bdd0e1f 100644 --- a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.user +++ b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.user @@ -2,8 +2,8 @@ false - $(OutDir)/test-lua-res - $(OutDir)/test-lua-res + $(OutDir)/lua-tests-res + $(OutDir)/lua-tests-res WindowsLocalDebugger WindowsLocalDebugger From c11ef679dae053cd5b35d4b2fc8ab2ef3e642191 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Wed, 12 Mar 2014 16:11:12 +0800 Subject: [PATCH 10/35] fixed incorrect initial value of label's TextVAlignment. --- cocos/2d/CCLabel.cpp | 8 +++++--- cocos/2d/CCLabel.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 8199bf5b06..6cf883bd29 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -66,7 +66,7 @@ Label* Label::createWithFontDefinition(const std::string& text, const FontDefini Label* Label::create(const std::string& text, const std::string& fontName, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */) { - auto ret = new Label(nullptr,hAlignment); + auto ret = new Label(nullptr,hAlignment,vAlignment); if (ret) { @@ -251,7 +251,8 @@ bool Label::setCharMap(const std::string& charMapFile, int itemWidth, int itemHe return false; } -Label::Label(FontAtlas *atlas, TextHAlignment alignment, bool useDistanceField,bool useA8Shader) +Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, + TextVAlignment vAlignment /* = TextVAlignment::TOP */,bool useDistanceField /* = false */,bool useA8Shader /* = false */) : _reusedLetter(nullptr) , _commonLineHeight(0.0f) , _lineBreakWithoutSpaces(false) @@ -259,7 +260,8 @@ Label::Label(FontAtlas *atlas, TextHAlignment alignment, bool useDistanceField,b , _labelWidth(0) , _labelHeight(0) , _labelDimensions(Size::ZERO) -, _hAlignment(alignment) +, _hAlignment(hAlignment) +, _vAlignment(vAlignment) , _currentUTF16String(nullptr) , _originalUTF16String(nullptr) , _horizontalKernings(nullptr) diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index c887a8726a..b203cc916a 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -251,7 +251,8 @@ protected: /** * @js NA */ - Label(FontAtlas *atlas = nullptr, TextHAlignment alignment = TextHAlignment::LEFT, bool useDistanceField = false,bool useA8Shader = false); + Label(FontAtlas *atlas = nullptr, TextHAlignment hAlignment = TextHAlignment::LEFT, + TextVAlignment vAlignment = TextVAlignment::TOP,bool useDistanceField = false,bool useA8Shader = false); /** * @js NA * @lua NA From 27a7dce447bb31e8d4819d091cd5a4190f357c76 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 12 Mar 2014 16:20:27 +0800 Subject: [PATCH 11/35] Adds lua-empty-test to VS project. --- .../project/proj.win32/lua-empty-test.vcxproj | 29 ++++++++++++++----- .../proj.win32/lua-empty-test.vcxproj.user | 4 +-- .../project/proj.win32/main.cpp | 1 - 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj index e86789ad2d..f8f6d94ae9 100644 --- a/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj +++ b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj @@ -79,7 +79,7 @@ Disabled - $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\scripting\lua\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -104,7 +104,13 @@ MachineX86 - xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua\script" "$(ProjectDir)..\..\lua-empty-test\Resources" /e /Y + if not exist "$(OutDir)" mkdir "$(OutDir)" +if exist "$(OutDir)\lua-empty-test-res" rd /s /q "$(OutDir)\lua-empty-test-res" +mkdir "$(OutDir)\lua-empty-test-res\res" +mkdir "$(OutDir)\lua-empty-test-res\src" +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script" "$(OutDir)\lua-empty-test-res" /e /Y +xcopy "$(ProjectDir)..\..\src" "$(OutDir)\lua-empty-test-res\src" /e /Y +xcopy "$(ProjectDir)..\..\res" "$(OutDir)\lua-empty-test-res\res" /e /Y if not exist "$(OutDir)" mkdir "$(OutDir)" @@ -126,7 +132,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ lua-empty-test_p.c - $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\auto-generated\lua-bindings;$(EngineRoot)cocos\scripting\lua\bindings;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) @@ -156,6 +162,15 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" + + if not exist "$(OutDir)" mkdir "$(OutDir)" +if exist "$(OutDir)\lua-empty-test-res" rd /s /q "$(OutDir)\lua-empty-test-res" +mkdir "$(OutDir)\lua-empty-test-res\res" +mkdir "$(OutDir)\lua-empty-test-res\src" +xcopy "$(ProjectDir)..\..\..\..\cocos\scripting\lua-bindings\script" "$(OutDir)\lua-empty-test-res" /e /Y +xcopy "$(ProjectDir)..\..\src" "$(OutDir)\lua-empty-test-res\src" /e /Y +xcopy "$(ProjectDir)..\..\res" "$(OutDir)\lua-empty-test-res\res" /e /Y + @@ -181,15 +196,15 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ {b7c2a162-dec9-4418-972e-240ab3cbfcae} + + {ddc3e27f-004d-4dd4-9dd3-931a013d2159} + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} {df2638c0-8128-4847-867c-6eafe3dee7b5} - - {ddc3e27f-004d-4dd4-9dd3-931a013d2159} - {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} @@ -203,4 +218,4 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ - + \ No newline at end of file diff --git a/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj.user b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj.user index 32a6296820..a53adf3b0e 100644 --- a/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj.user +++ b/tests/lua-empty-test/project/proj.win32/lua-empty-test.vcxproj.user @@ -1,11 +1,11 @@  - $(ProjectDir)..\Resources + $(OutDir)/lua-empty-test-res WindowsLocalDebugger - $(ProjectDir)..\Resources + $(OutDir)/lua-empty-test-res WindowsLocalDebugger \ No newline at end of file diff --git a/tests/lua-empty-test/project/proj.win32/main.cpp b/tests/lua-empty-test/project/proj.win32/main.cpp index 5c23b025b9..a4ef80f78f 100644 --- a/tests/lua-empty-test/project/proj.win32/main.cpp +++ b/tests/lua-empty-test/project/proj.win32/main.cpp @@ -1,6 +1,5 @@ #include "main.h" #include "AppDelegate.h" -#include "CCEGLView.h" USING_NS_CC; From 884229e8988f693c6c58797cb665eef4b869037c Mon Sep 17 00:00:00 2001 From: chuanweizhang2013 Date: Wed, 12 Mar 2014 17:20:15 +0800 Subject: [PATCH 12/35] modify generate-template-files --- tools/travis-scripts/config.gitingore | 2 +- .../travis-scripts/generate-template-files.py | 21 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tools/travis-scripts/config.gitingore b/tools/travis-scripts/config.gitingore index e16be3535a..b4153b6d07 100644 --- a/tools/travis-scripts/config.gitingore +++ b/tools/travis-scripts/config.gitingore @@ -109,4 +109,4 @@ tags #include !/tools/cocos2d-console/console/bin/ !/plugin-x/plugin-x_ios.xcworkspace/ - +!/cocos/2d/platform/android/java/res/ diff --git a/tools/travis-scripts/generate-template-files.py b/tools/travis-scripts/generate-template-files.py index ee974866be..36b70a02c7 100755 --- a/tools/travis-scripts/generate-template-files.py +++ b/tools/travis-scripts/generate-template-files.py @@ -27,6 +27,7 @@ THE SOFTWARE. import os import sys import re +import json class CocosFileList: """ @@ -39,7 +40,10 @@ class CocosFileList: self.excludeConfig=[] self.inludeConfig=[] self.rootDir = "" - self.fileList=[] + self.fileList_com=[] + self.fileList_lua=[] + + self.luaPath ="cocos/scripting/lua-bindings" def readIngoreFile(self, fileName): """ @@ -84,7 +88,10 @@ class CocosFileList: self.__bInclude(item) or self.__bInclude("%s/" %item) ): - self.fileList.append("%s/" %relativePath) + if relativePath.upper().find(self.luaPath.upper())==0: + self.fileList_lua.append("%s/" %relativePath) + else: + self.fileList_com.append("%s/" %relativePath) continue if ( self.__bExclude("/%s" %relativePath) or @@ -105,7 +112,10 @@ class CocosFileList: ): continue # print(relativePath) - self.fileList.append(relativePath) + if relativePath.upper().find(self.luaPath.upper())==0: + self.fileList_lua.append(relativePath) + else: + self.fileList_com.append(relativePath) def __bExclude(self, item): bexclude = False @@ -128,9 +138,8 @@ class CocosFileList: Save content to file with json format. """ f = open(fileName,"w") - self.fileList.sort() - content = "[\n\"%s\"\n]" % ("\",\n\"".join(self.fileList)) - f.write(content) + content ={'common':self.fileList_com,'lua':self.fileList_lua} + json.dump(content,f,sort_keys=True,indent=4) f.close() return True From 1c32c6d96f877c7551fc99ad7fcef586d5b03211 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 12 Mar 2014 17:51:34 +0800 Subject: [PATCH 13/35] Replace cc.LabelTTF:create with cc.Label:create --- .../CocoStudioArmatureTest.lua | 15 ++++--- .../CurrentLanguageTest.lua | 2 +- .../DrawPrimitivesTest/DrawPrimitivesTest.lua | 2 +- .../lua-tests/src/EffectsTest/EffectsTest.lua | 3 +- .../src/ExtensionTest/WebProxyTest.lua | 15 ++++--- tests/lua-tests/src/KeypadTest/KeypadTest.lua | 6 ++- tests/lua-tests/src/LayerTest/LayerTest.lua | 6 ++- .../src/LuaBridgeTest/LuaBridgeTest.lua | 12 ++++-- tests/lua-tests/src/MenuTest/MenuTest.lua | 3 +- .../NewEventDispatcherTest.lua | 20 ++++++---- tests/lua-tests/src/OpenGLTest/OpenGLTest.lua | 6 ++- .../src/ParticleTest/ParticleTest.lua | 6 ++- .../PerformanceTest/PerformanceSpriteTest.lua | 6 ++- .../src/PerformanceTest/PerformanceTest.lua | 39 ++++++++++++------- .../lua-tests/src/PhysicsTest/PhysicsTest.lua | 24 ++++++++---- .../src/RotateWorldTest/RotateWorldTest.lua | 3 +- .../src/Texture2dTest/Texture2dTest.lua | 3 +- .../src/TransitionsTest/TransitionsTest.lua | 12 ++++-- .../src/UserDefaultTest/UserDefaultTest.lua | 3 +- .../XMLHttpRequestTest/XMLHttpRequestTest.lua | 18 ++++++--- tests/lua-tests/src/helper.lua | 9 +++-- tests/lua-tests/src/mainMenu.lua | 3 +- tests/lua-tests/src/testResource.lua | 1 + 23 files changed, 143 insertions(+), 74 deletions(-) diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua index 895e157be8..0e3774b505 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua @@ -195,15 +195,17 @@ function ArmatureTestLayer:createToExtensionMenu() end function ArmatureTestLayer:creatTitleAndSubTitle(idx) - local title = cc.LabelTTF:create(ArmatureTestLayer.title(idx),"Arial",18) + local title = cc.Label:create(ArmatureTestLayer.title(idx), s_arialPath, 18) title:setColor(cc.c3b(0,0,0)) self:addChild(title, 1, 10000) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) local subTitle = nil if "" ~= ArmatureTestLayer.subTitle(idx) then - local subTitle = cc.LabelTTF:create(ArmatureTestLayer.subTitle(idx), "Arial", 18) + local subTitle = cc.Label:create(ArmatureTestLayer.subTitle(idx), s_arialPath, 18) subTitle:setColor(cc.c3b(0,0,0)) self:addChild(subTitle, 1, 10001) + subTitle:setAnchorPoint(cc.p(0.5, 0.5)) subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) end end @@ -226,16 +228,18 @@ function TestAsynchronousLoading:onEnter() self._restarItem:setEnabled(false) self._nextItem:setEnabled(false) - local title = cc.LabelTTF:create(ArmatureTestLayer.title(1),"Arial",18) + local title = cc.Label:create(ArmatureTestLayer.title(1), s_arialPath, 18) title:setColor(cc.c3b(0,0,0)) self:addChild(title, 1, 10000) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) local subTitle = nil if "" ~= ArmatureTestLayer.subTitle(1) then local subInfo = ArmatureTestLayer.subTitle(1) .. 0.0 - local subTitle = cc.LabelTTF:create(subInfo, "Arial", 18) + local subTitle = cc.Label:create(subInfo, s_arialPath, 18) subTitle:setColor(cc.c3b(0,0,0)) self:addChild(subTitle, 1, 10001) + subTitle:setAnchorPoint(cc.p(0.5, 0.5)) subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) end @@ -1160,7 +1164,8 @@ function TestArmatureNesting2:onEnter() end self._touchedMenu = false - local label = cc.LabelTTF:create("Change Mount", "Arial", 20) + local label = cc.Label:create("Change Mount", s_arialPath, 20) + label:setAnchorPoint(cc.p(0.5, 0.5)) local menuItem = cc.MenuItemLabel:create(label) menuItem:registerScriptTapHandler(changeMountCallback) local menu = cc.Menu:create(menuItem) diff --git a/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua b/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua index 2fd67c6271..934a147865 100644 --- a/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua +++ b/tests/lua-tests/src/CurrentLanguageTest/CurrentLanguageTest.lua @@ -5,7 +5,7 @@ local function CurrentLanguageTest() label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y-50) ) - local labelLanguage = cc.LabelTTF:create("", s_arialPath, 20) + local labelLanguage = cc.Label:create("", s_arialPath, 20) labelLanguage:setAnchorPoint(cc.p(0.5, 0.5)) labelLanguage:setPosition(VisibleRect:center()) diff --git a/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua b/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua index 14aed46552..68428b5450 100644 --- a/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua +++ b/tests/lua-tests/src/DrawPrimitivesTest/DrawPrimitivesTest.lua @@ -72,7 +72,7 @@ local function drawPrimitivesMainLayer() lableTitle:setPosition(cc.p(size.width / 2, size.height - 32)) lableTitle:setColor(cc.c3b(255, 255, 40)) --SubTitle - local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), s_thonburiPath, 16) + local subLabelTitle = cc.Label:create(GetSubTitle(), s_thonburiPath, 16) layer:addChild(subLabelTitle, 15) subLabelTitle:setAnchorPoint(cc.p(0.5, 0.5)) subLabelTitle:setPosition(cc.p(size.width / 2, size.height - 80)) diff --git a/tests/lua-tests/src/EffectsTest/EffectsTest.lua b/tests/lua-tests/src/EffectsTest/EffectsTest.lua index 3696df33ee..4558f65c3c 100644 --- a/tests/lua-tests/src/EffectsTest/EffectsTest.lua +++ b/tests/lua-tests/src/EffectsTest/EffectsTest.lua @@ -352,7 +352,8 @@ function CreateEffectsTestLayer() local x, y = size.width, size.height - titleLabel = cc.LabelTTF:create(EffectsList[ActionIdx], "Marker Felt", 32) + titleLabel = cc.Label:create(EffectsList[ActionIdx], s_markerFeltFontPath, 32) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(x / 2, y - 80) testLayer:addChild(titleLabel) titleLabel:setTag(kTagLabel) diff --git a/tests/lua-tests/src/ExtensionTest/WebProxyTest.lua b/tests/lua-tests/src/ExtensionTest/WebProxyTest.lua index 9a2c203ffd..79fc85b03d 100644 --- a/tests/lua-tests/src/ExtensionTest/WebProxyTest.lua +++ b/tests/lua-tests/src/ExtensionTest/WebProxyTest.lua @@ -15,7 +15,8 @@ local receiveTextTimes = 0 local receiveBinaryTimes = 0 - local label = cc.LabelTTF:create("WebSocket Test", "Arial", 28) + local label = cc.Label:create("WebSocket Test", s_arialPath, 28) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p( winSize.width / 2, winSize.height - MARGIN)) layer:addChild(label, 0) @@ -36,7 +37,8 @@ end end end - local labelSendText = cc.LabelTTF:create("Send Text", "Arial", 22) + local labelSendText = cc.Label:create("Send Text", s_arialPath, 22) + labelSendText:setAnchorPoint(0.5, 0.5) local itemSendText = cc.MenuItemLabel:create(labelSendText) itemSendText:registerScriptTapHandler(onMenuSendTextClicked) itemSendText:setPosition(cc.p(winSize.width / 2, winSize.height - MARGIN - SPACE)) @@ -54,26 +56,27 @@ end end end - local labelSendBinary = cc.LabelTTF:create("Send Binary", "Arial", 22) + local labelSendBinary = cc.Label:create("Send Binary", s_arialPath, 22) + labelSendBinary:setAnchorPoint(cc.p(0.5, 0.5)) local itemSendBinary = cc.MenuItemLabel:create(labelSendBinary) itemSendBinary:registerScriptTapHandler(onMenuSendBinaryClicked) itemSendBinary:setPosition(cc.p(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)) menuRequest:addChild(itemSendBinary) --Send Text Status Label - sendTextStatus = cc.LabelTTF:create("Send Text WS is waiting...", "Arial", 14,cc.size(160, 100),cc.VERTICAL_TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_TOP) + sendTextStatus = cc.Label:create("Send Text WS is waiting...", s_arialPath, 14,cc.size(160, 100),cc.VERTICAL_TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_TOP) sendTextStatus:setAnchorPoint(cc.p(0, 0)) sendTextStatus:setPosition(cc.p(0, 25)) layer:addChild(sendTextStatus) --Send Binary Status Label - sendBinaryStatus = cc.LabelTTF:create("Send Binary WS is waiting...", "Arial", 14, cc.size(160, 100), cc.VERTICAL_TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP) + sendBinaryStatus = cc.Label:create("Send Binary WS is waiting...", s_arialPath, 14, cc.size(160, 100), cc.VERTICAL_TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP) sendBinaryStatus:setAnchorPoint(cc.p(0, 0)) sendBinaryStatus:setPosition(cc.p(160, 25)) layer:addChild(sendBinaryStatus) --Error Label - errorStatus = cc.LabelTTF:create("Error WS is waiting...", "Arial", 14, cc.size(160, 100), cc.VERTICAL_TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP) + errorStatus = cc.Label:create("Error WS is waiting...", s_arialPath, 14, cc.size(160, 100), cc.VERTICAL_TEXT_ALIGNMENT_CENTER, cc.VERTICAL_TEXT_ALIGNMENT_TOP) errorStatus:setAnchorPoint(cc.p(0, 0)) errorStatus:setPosition(cc.p(320, 25)) layer:addChild(errorStatus) diff --git a/tests/lua-tests/src/KeypadTest/KeypadTest.lua b/tests/lua-tests/src/KeypadTest/KeypadTest.lua index 850a908225..12f1ef0947 100644 --- a/tests/lua-tests/src/KeypadTest/KeypadTest.lua +++ b/tests/lua-tests/src/KeypadTest/KeypadTest.lua @@ -4,11 +4,13 @@ local function KeypadMainLayer() local function onEnter() print("come in") local s = cc.Director:getInstance():getWinSize() - local label = cc.LabelTTF:create("Keypad Test", "Arial", 28) + local label = cc.Label:create("Keypad Test", s_thonburiPath, 28) layer:addChild(label, 0) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p(s.width/2, s.height-50)) - local labelTip = cc.LabelTTF:create("Please press any key...", "Arial", 22) + local labelTip = cc.Label:create("Please press any key...", "s_thonburiPath", 22) + labelTip:setAnchorPoint(cc.p(0.5, 0.5)) labelTip:setPosition(cc.p(s.width / 2, s.height / 2)) layer:addChild(labelTip, 0) diff --git a/tests/lua-tests/src/LayerTest/LayerTest.lua b/tests/lua-tests/src/LayerTest/LayerTest.lua index 053bd2af63..ec74ef6430 100644 --- a/tests/lua-tests/src/LayerTest/LayerTest.lua +++ b/tests/lua-tests/src/LayerTest/LayerTest.lua @@ -436,8 +436,10 @@ local function LayerGradient() local layer1 = cc.LayerGradient:create(cc.c4b(255,0,0,255), cc.c4b(0,255,0,255), cc.p(0.9, 0.9)) ret:addChild(layer1, 0, kTagLayer) - local label1 = cc.LabelTTF:create("Compressed Interpolation: Enabled", "Marker Felt", 26) - local label2 = cc.LabelTTF:create("Compressed Interpolation: Disabled", "Marker Felt", 26) + local label1 = cc.Label:create("Compressed Interpolation: Enabled", s_markerFeltFontPath, 26) + label1:setAnchorPoint(cc.p(0.5, 0.5)) + local label2 = cc.Label:create("Compressed Interpolation: Disabled", s_markerFeltFontPath, 26) + label2:setAnchorPoint(cc.p(0.5, 0.5)) local item1 = cc.MenuItemLabel:create(label1) local item2 = cc.MenuItemLabel:create(label2) local item = cc.MenuItemToggle:create(item1) diff --git a/tests/lua-tests/src/LuaBridgeTest/LuaBridgeTest.lua b/tests/lua-tests/src/LuaBridgeTest/LuaBridgeTest.lua index 6fea800fee..baae0ff7c4 100644 --- a/tests/lua-tests/src/LuaBridgeTest/LuaBridgeTest.lua +++ b/tests/lua-tests/src/LuaBridgeTest/LuaBridgeTest.lua @@ -48,13 +48,15 @@ local function LuaBridgeLayer() local function newLuaJavaBridge() local newScene = cc.Scene:create() - local titleLabel = cc.LabelTTF:create("", "Arial", 28) + local titleLabel = cc.Label:create("", s_arialPath, 28) newScene:addChild(titleLabel, 1) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(s.width / 2, s.height - 50) titleLabel:setString("LuaJavaBridge Test") - subtitleLabel = cc.LabelTTF:create("", "Thonburi", 16) + subtitleLabel = cc.Label:create("", s_thonburiPath, 16) newScene:addChild(subtitleLabel, 1) + subtitleLabel:setAnchorPoint(cc.p(0.5, 0.5)) subtitleLabel:setPosition(s.width / 2, s.height - 80) subtitleLabel:setString("See the console.") if (cc.PLATFORM_OS_ANDROID == targetPlatform) then @@ -86,13 +88,15 @@ local function LuaBridgeLayer() local function newLuaObjectCBridge() local newScene = cc.Scene:create() - local titleLabel = cc.LabelTTF:create("", "Arial", 28) + local titleLabel = cc.Label:create("", s_arialPath, 28) newScene:addChild(titleLabel, 1) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(s.width / 2, s.height - 50) titleLabel:setString("LuaObjectCBridge Test") - subtitleLabel = cc.LabelTTF:create("", "Thonburi", 16) + subtitleLabel = cc.Label:create("", s_thonburiPath, 16) newScene:addChild(subtitleLabel, 1) + subtitleLabel:setAnchorPoint(cc.p(0.5, 0.5)) subtitleLabel:setPosition(s.width / 2, s.height - 80) subtitleLabel:setString("See the console.") if (cc.PLATFORM_OS_IPHONE == targetPlatform) or (cc.PLATFORM_OS_IPAD == targetPlatform) or (cc.PLATFORM_OS_MAC == targetPlatform) then diff --git a/tests/lua-tests/src/MenuTest/MenuTest.lua b/tests/lua-tests/src/MenuTest/MenuTest.lua index 73d3574653..00bbe470b1 100644 --- a/tests/lua-tests/src/MenuTest/MenuTest.lua +++ b/tests/lua-tests/src/MenuTest/MenuTest.lua @@ -517,7 +517,8 @@ local function RemoveMenuItemWhenMove() local ret = cc.Layer:create() local s = cc.Director:getInstance():getWinSize() - local label = cc.LabelTTF:create("click item and move, should not crash", "Arial", 20) + local label = cc.Label:create("click item and move, should not crash", s_arialPath, 20) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p(s.width/2, s.height - 30)) ret:addChild(label) diff --git a/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua b/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua index 3d422f005a..d3ddd73adb 100644 --- a/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua +++ b/tests/lua-tests/src/NewEventDispatcherTest/NewEventDispatcherTest.lua @@ -140,15 +140,17 @@ function EventDispatcherTestDemo:createMenu() end function EventDispatcherTestDemo:creatTitleAndSubTitle(idx) - local title = cc.LabelTTF:create(EventDispatcherTestDemo.title(idx),"Arial",18) + local title = cc.Label:create(EventDispatcherTestDemo.title(idx),s_arialPath,18) title:setColor(cc.c3b(128,128,0)) self:addChild(title, 1, 10000) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30)) local subTitle = nil if "" ~= EventDispatcherTestDemo.subTitle(idx) then - local subTitle = cc.LabelTTF:create(EventDispatcherTestDemo.subTitle(idx), "Arial", 18) + local subTitle = cc.Label:create(EventDispatcherTestDemo.subTitle(idx), s_arialPath, 18) subTitle:setColor(cc.c3b(128,128,0)) self:addChild(subTitle, 1, 10001) + subTitle:setAnchorPoint(cc.p(0.5, 0.5)) subTitle:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 60) ) end end @@ -463,7 +465,8 @@ function RemoveListenerWhenDispatchingTest:onEnter() local eventDispatcher = self:getEventDispatcher() eventDispatcher:addEventListenerWithSceneGraphPriority(listener1, sprite1) - local statusLabel = cc.LabelTTF:create("The sprite could be touched!", "", 20) + local statusLabel = cc.Label:create("The sprite could be touched!", "", 20) + statusLabel:setAnchorPoint(cc.p(0.5, 0.5)) statusLabel:setPosition(cc.p(origin.x + size.width/2, origin.y + size.height - 90)) self:addChild(statusLabel) @@ -529,7 +532,8 @@ function CustomEventTest:onEnter() cc.MenuItemFont:setFontSize(20) - local statusLabel1 = cc.LabelTTF:create("No custom event 1 received!", "", 20) + local statusLabel1 = cc.Label:create("No custom event 1 received!", "", 20) + statusLabel1:setAnchorPoint(cc.p(0.5, 0.5)) statusLabel1:setPosition(cc.p(origin.x + size.width/2, origin.y + size.height-90 )) self:addChild(statusLabel1) @@ -554,7 +558,8 @@ function CustomEventTest:onEnter() sendItem1:registerScriptTapHandler(sendCallback1) sendItem1:setPosition(cc.p(origin.x + size.width/2, origin.y + size.height/2)) - local statusLabel2 = cc.LabelTTF:create("No custom event 2 received!", "", 20) + local statusLabel2 = cc.Label:create("No custom event 2 received!", "", 20) + statusLabel2:setAnchorPoint(cc.p(0.5, 0.5)) statusLabel2:setPosition(cc.p(origin.x + size.width/2, origin.y + size.height-120 )) self:addChild(statusLabel2) @@ -626,7 +631,8 @@ function LabelKeyboardEventTest:onEnter() local origin = cc.Director:getInstance():getVisibleOrigin() local size = cc.Director:getInstance():getVisibleSize() - local statusLabel = cc.LabelTTF:create("No keyboard event received!", "", 20) + local statusLabel = cc.Label:create("No keyboard event received!", "", 20) + statusLabel:setAnchorPoint(cc.p(0.5, 0.5)) statusLabel:setPosition(cc.p(origin.x + size.width/2,origin.y + size.height/2)) self:addChild(statusLabel) @@ -905,7 +911,7 @@ function RemoveListenerAfterAddingTest:onEnter() listener:registerScriptHandler(onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN) eventDispatcher:addEventListenerWithFixedPriority(listener, -1) - eventDispatcher:removeEventListeners(cc.EVENT_TOUCH_ONE_BY_ONE) + eventDispatcher:removeEventListenersForType(cc.EVENT_TOUCH_ONE_BY_ONE) addNextButton() diff --git a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua index c2aff9d3c6..f1f2bbb33a 100644 --- a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua +++ b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua @@ -125,13 +125,15 @@ local function OpenGLTestMainLayer() local function InitTitle(layer) --Title - local lableTitle = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local lableTitle = cc.Label:create(GetTitle(), s_arialPath, 40) layer:addChild(lableTitle, 15) + lableTitle:setAnchorPoint(cc.p(0.5, 0.5)) lableTitle:setPosition(cc.p(size.width/2, size.height-32)) lableTitle:setColor(cc.c3b(255,255,40)) --SubTitle - local subLabelTitle = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16) + local subLabelTitle = cc.Label:create(GetSubTitle(), s_thonburiPath, 16) layer:addChild(subLabelTitle, 15) + subLabelTitle:setAnchorPoint(cc.p(0.5, 0.5)) subLabelTitle:setPosition(cc.p(size.width/2, size.height-80)) end diff --git a/tests/lua-tests/src/ParticleTest/ParticleTest.lua b/tests/lua-tests/src/ParticleTest/ParticleTest.lua index 4cece01d69..9d04e86532 100644 --- a/tests/lua-tests/src/ParticleTest/ParticleTest.lua +++ b/tests/lua-tests/src/ParticleTest/ParticleTest.lua @@ -98,12 +98,14 @@ local function getBaseLayer() emitter = nil - titleLabel = cc.LabelTTF:create("", "Arial", 28) + titleLabel = cc.Label:create("", s_arialPath, 28) layer:addChild(titleLabel, 100, 1000) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(s.width / 2, s.height - 50) - subtitleLabel = cc.LabelTTF:create("", "Arial", 16) + subtitleLabel = cc.Label:create("", s_arialPath, 16) layer:addChild(subtitleLabel, 100) + subtitleLabel:setAnchorPoint(cc.p(0.5, 0.5)) subtitleLabel:setPosition(s.width / 2, s.height - 80) diff --git a/tests/lua-tests/src/PerformanceTest/PerformanceSpriteTest.lua b/tests/lua-tests/src/PerformanceTest/PerformanceSpriteTest.lua index a2707f5a51..7f9cadc484 100644 --- a/tests/lua-tests/src/PerformanceTest/PerformanceSpriteTest.lua +++ b/tests/lua-tests/src/PerformanceTest/PerformanceSpriteTest.lua @@ -357,8 +357,9 @@ local function initWithMainTest(scene, asubtest, nNodes) menu:setPosition(s.width / 2, s.height - 65) scene:addChild(menu, 1) - infoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + infoLabel = cc.Label:create("0 nodes", s_markerFeltFontPath, 30) infoLabel:setColor(cc.c3b(0, 200, 20)) + infoLabel:setAnchorPoint(cc.p(0.5, 0.5)) infoLabel:setPosition(s.width / 2, s.height - 90) scene:addChild(infoLabel, 1) @@ -388,8 +389,9 @@ local function initWithMainTest(scene, asubtest, nNodes) scene:addChild(subMenu, 1) -- add title label - titleLabel = cc.LabelTTF:create("No title", "Arial", 40) + titleLabel = cc.Label:create("No title", s_arialPath, 40) scene:addChild(titleLabel, 1) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(s.width / 2, s.height - 32) titleLabel:setColor(cc.c3b(255, 255, 40)) diff --git a/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua b/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua index 97f70e5071..d2231ac000 100644 --- a/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua +++ b/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua @@ -338,14 +338,16 @@ local function runNodeChildrenTest() local s = cc.Director:getInstance():getWinSize() --Title - local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.Label:create(GetTitle(), s_arialPath, 40) pNewscene:addChild(pLabel, 1) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(s.width/2, s.height-32)) pLabel:setColor(cc.c3b(255,255,40)) if (nil ~= GetSubTitle()) and ("" ~= GetSubTitle()) then - local pSubLabel = cc.LabelTTF:create(GetSubTitle(), "Thonburi", 16) + local pSubLabel = cc.Label:create(GetSubTitle(), s_thonburiPath, 16) pNewscene:addChild(pSubLabel, 1) + pSubLabel:setAnchorPoint(cc.p(0.5, 0.5)) pSubLabel:setPosition(cc.p(s.width/2, s.height-80)) end @@ -370,8 +372,9 @@ local function runNodeChildrenTest() pNewscene:addChild(pMenuAddOrSub,1) --InfoLayer - local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + local pInfoLabel = cc.Label:create("0 nodes", s_markerFeltFontPath, 30) pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setAnchorPoint(cc.p(0.5, 0.5)) pInfoLabel:setPosition(cc.p(s.width/2, s.height/2-15)) pNewscene:addChild(pInfoLabel, 1, NodeChildrenTestParam.kTagInfoLayer) @@ -825,8 +828,9 @@ local function runParticleTest() pMenuAddOrSub:setPosition(cc.p(s.width/2, s.height/2+15)) pNewScene:addChild(pMenuAddOrSub,1) - local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + local pInfoLabel = cc.Label:create("0 nodes", s_markerFeltFontPath, 30) pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setAnchorPoint(cc.p(0.5, 0.5)) pInfoLabel:setPosition(cc.p(s.width/2, s.height - 90)) pNewScene:addChild(pInfoLabel, 1, ParticleTestParam.kTagInfoLayer) @@ -863,8 +867,9 @@ local function runParticleTest() pSubMenu:setPosition(cc.p(s.width/2, 80)) pNewScene:addChild(pSubMenu, 2) - local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.Label:create(GetTitle(), s_arialPath, 40) pNewScene:addChild(pLabel, 1) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(s.width/2, s.height-32)) pLabel:setColor(cc.c3b(255,255,40)) @@ -1269,8 +1274,9 @@ local function runSpriteTest() pMenuAddOrSub:setPosition(cc.p(s.width/2, s.height/2+15)) pNewScene:addChild(pMenuAddOrSub,1) - local pInfoLabel = cc.LabelTTF:create("0 nodes", "Marker Felt", 30) + local pInfoLabel = cc.Label:create("0 nodes", s_markerFeltFontPath, 30) pInfoLabel:setColor(cc.c3b(0,200,20)) + pInfoLabel:setAnchorPoint(cc.p(0.5, 0.5)) pInfoLabel:setPosition(cc.p(s.width/2, s.height - 90)) pNewScene:addChild(pInfoLabel, 1, SpriteTestParam.kTagInfoLayer) @@ -1307,8 +1313,9 @@ local function runSpriteTest() pSubMenu:setPosition(cc.p(s.width/2, 80)) pNewScene:addChild(pSubMenu, 2) - local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.Label:create(GetTitle(), s_arialPath, 40) pNewScene:addChild(pLabel, 1) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(s.width/2, s.height-32)) pLabel:setColor(cc.c3b(255,255,40)) while nQuantityNodes < nNodes do @@ -1431,14 +1438,16 @@ local function runTextureTest() end --Title - local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.Label:create(GetTitle(), s_arialPath, 40) pLayer:addChild(pLabel, 1) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(s.width/2, s.height-32)) pLabel:setColor(cc.c3b(255,255,40)) --Subtitle - local pSubLabel = cc.LabelTTF:create(GetSubtitle(), "Thonburi", 16) + local pSubLabel = cc.Label:create(GetSubtitle(), s_thonburiPath, 16) pLayer:addChild(pSubLabel, 1) + pSubLabel:setAnchorPoint(cc.p(0.5, 0.5)) pSubLabel:setPosition(cc.p(s.width/2, s.height-80)) --menu @@ -1596,8 +1605,9 @@ local function runTouchesTest() pLayer:addChild(pTouchesTestMenu) --Title - local pLabel = cc.LabelTTF:create(GetTitle(), "Arial", 40) + local pLabel = cc.Label:create(GetTitle(), s_arialPath, 40) pLayer:addChild(pLabel, 1) + pLabel:setAnchorPoint(cc.p(0.5, 0.5)) pLabel:setPosition(cc.p(s.width/2, s.height-32)) pLabel:setColor(cc.c3b(255,255,40)) @@ -1686,13 +1696,15 @@ local function runFuncRelateWithTable() end --Title - local title = cc.LabelTTF:create(GetTitle(), "Arial", 28) + local title = cc.Label:create(GetTitle(), s_arialPath, 28) layer:addChild(title, 1) + title:setAnchorPoint(cc.p(0.5, 0.5)) title:setPosition(cc.p(s.width/2, s.height-32)) title:setColor(cc.c3b(255,255,40)) --Subtitle - local subTitle = cc.LabelTTF:create(GetSubtitle(), "Thonburi", 16) + local subTitle = cc.Label:create(GetSubtitle(), s_thonburiPath, 16) layer:addChild(subTitle, 1) + subTitle:setAnchorPoint(cc.p(0.5, 0.5)) subTitle:setPosition(cc.p(s.width/2, s.height-80)) --"+","-" Menu @@ -1729,8 +1741,9 @@ local function runFuncRelateWithTable() layer:addChild(menuAddOrSub,1) --num - local numLabel = cc.LabelTTF:create("10000", "Marker Felt", 30) + local numLabel = cc.Label:create("10000", s_markerFeltFontPath, 30) numLabel:setColor(cc.c3b(0,200,20)) + numLabel:setAnchorPoint(cc.p(0.5, 0.5)) numLabel:setPosition(cc.p(s.width/2, s.height/2-15)) layer:addChild(numLabel, 1, NodeChildrenTestParam.kTagInfoLayer) diff --git a/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua b/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua index 409a8a28a4..beb8c9adb7 100644 --- a/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua +++ b/tests/lua-tests/src/PhysicsTest/PhysicsTest.lua @@ -1076,20 +1076,24 @@ local function PhysicsContactTest() local s = cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height); - local label = cc.LabelTTF:create(tostring(layer.yellowBoxNum), "Arial", 32); + local label = cc.Label:create(tostring(layer.yellowBoxNum), s_arialPath, 32); root:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2, s.height-50)); - label = cc.LabelTTF:create(tostring(layer.blueBoxNum), "Arial", 32); + label = cc.Label:create(tostring(layer.blueBoxNum), s_arialPath, 32); root:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2, s.height-90)); - label = cc.LabelTTF:create(tostring(layer.yellowTriangleNum), "Arial", 32); + label = cc.Label:create(tostring(layer.yellowTriangleNum), s_arialPath, 32); root:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2, s.height-130)); - label = cc.LabelTTF:create(tostring(layer.blueTriangleNum), "Arial", 32); + label = cc.Label:create(tostring(layer.blueTriangleNum), s_arialPath, 32); root:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2, s.height-170)); local wall = cc.Node:create(); @@ -1209,8 +1213,9 @@ local function PhysicsContactTest() menu1:setPosition(cc.p(s.width/2, s.height-50)); layer:addChild(menu1, 1); - local label = cc.LabelTTF:create("yellow box", "Arial", 32); + local label = cc.Label:create("yellow box", s_arialPath, 32); layer:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2 - 150, s.height-50)); local decrease2 = cc.MenuItemFont:create(" - "); @@ -1227,8 +1232,9 @@ local function PhysicsContactTest() menu2:setPosition(cc.p(s.width/2, s.height-90)); layer:addChild(menu2, 1); - label = cc.LabelTTF:create("blue box", "Arial", 32); + label = cc.Label:create("blue box", s_arialPath, 32); layer:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2 - 150, s.height-90)); local decrease3 = cc.MenuItemFont:create(" - "); @@ -1245,8 +1251,9 @@ local function PhysicsContactTest() menu3:setPosition(cc.p(s.width/2, s.height-130)); layer:addChild(menu3, 1); - label = cc.LabelTTF:create("yellow triangle", "Arial", 32); + label = cc.Label:create("yellow triangle", s_arialPath, 32); layer:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2 - 150, s.height-130)); local decrease4 = cc.MenuItemFont:create(" - "); @@ -1263,8 +1270,9 @@ local function PhysicsContactTest() menu4:setPosition(cc.p(s.width/2, s.height-170)); layer:addChild(menu4, 1); - label = cc.LabelTTF:create("blue triangle", "Arial", 32); + label = cc.Label:create("blue triangle", s_arialPath, 32); layer:addChild(label, 1); + label:setAnchorPoint(cc.p(0.5, 0.5)); label:setPosition(cc.p(s.width/2 - 150, s.height-170)); diff --git a/tests/lua-tests/src/RotateWorldTest/RotateWorldTest.lua b/tests/lua-tests/src/RotateWorldTest/RotateWorldTest.lua index e196832723..1d2f03f387 100644 --- a/tests/lua-tests/src/RotateWorldTest/RotateWorldTest.lua +++ b/tests/lua-tests/src/RotateWorldTest/RotateWorldTest.lua @@ -54,7 +54,8 @@ local function CreateTestLayer() x = size.width y = size.height - local label = cc.LabelTTF:create("cocos2d", "Tahoma", 64) + local label = cc.Label:create("cocos2d", s_tahomaPath, 64) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(x / 2, y / 2) layer:addChild(label) diff --git a/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua b/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua index 3f58c1f0bd..67870e3900 100644 --- a/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua +++ b/tests/lua-tests/src/Texture2dTest/Texture2dTest.lua @@ -959,7 +959,8 @@ local function TextureAsync() local size =cc.Director:getInstance():getWinSize() - local label = cc.LabelTTF:create("Loading...", "Marker Felt", 32) + local label = cc.Label:create("Loading...", s_markerFeltFontPath, 32) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p( size.width/2, size.height/2)) ret:addChild(label, 10) diff --git a/tests/lua-tests/src/TransitionsTest/TransitionsTest.lua b/tests/lua-tests/src/TransitionsTest/TransitionsTest.lua index b2811f5780..cddc951f9c 100644 --- a/tests/lua-tests/src/TransitionsTest/TransitionsTest.lua +++ b/tests/lua-tests/src/TransitionsTest/TransitionsTest.lua @@ -62,13 +62,15 @@ local function createLayer1() bg1:setPosition(cc.p(s.width / 2, s.height / 2)) layer:addChild(bg1, -1) - local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32) + local titleLabel = cc.Label:create(Transition_Name[SceneIdx], s_thonburiPath, 32) layer:addChild(titleLabel) titleLabel:setColor(cc.c3b(255,32,32)) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setPosition(x / 2, y - 100) - local label = cc.LabelTTF:create("SCENE 1", "Marker Felt", 38) + local label = cc.Label:create("SCENE 1", s_markerFeltFontPath, 38) label:setColor(cc.c3b(16,16,255)) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(x / 2, y / 2) layer:addChild(label) @@ -105,13 +107,15 @@ local function createLayer2() bg1:setPosition(cc.p(s.width / 2, s.height / 2)) layer:addChild(bg1, -1) - local titleLabel = cc.LabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 ) + local titleLabel = cc.Label:create(Transition_Name[SceneIdx], s_thonburiPath, 32 ) layer:addChild(titleLabel) + titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) titleLabel:setColor(cc.c3b(255,32,32)) titleLabel:setPosition(x / 2, y - 100) - local label = cc.LabelTTF:create("SCENE 2", "Marker Felt", 38) + local label = cc.Label:create("SCENE 2", s_markerFeltFontPath, 38) label:setColor(cc.c3b(16,16,255)) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(x / 2, y / 2) layer:addChild(label) diff --git a/tests/lua-tests/src/UserDefaultTest/UserDefaultTest.lua b/tests/lua-tests/src/UserDefaultTest/UserDefaultTest.lua index b86eb3a1d3..7ed6578d47 100644 --- a/tests/lua-tests/src/UserDefaultTest/UserDefaultTest.lua +++ b/tests/lua-tests/src/UserDefaultTest/UserDefaultTest.lua @@ -72,8 +72,9 @@ end function UserDefaultTestMain() local ret = cc.Scene:create() local s = cc.Director:getInstance():getWinSize() - local label = cc.LabelTTF:create("UserDefault test see log", "Arial", 28) + local label = cc.Label:create("UserDefault test see log", s_arialPath, 28) ret:addChild(label, 0) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition( cc.p(s.width/2, s.height-50) ) ret:addChild(CreateBackMenuItem()) doTest() diff --git a/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua b/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua index 4bec50a734..5208580401 100644 --- a/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua +++ b/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua @@ -7,12 +7,14 @@ local function XMLHttpRequestLayer() local space = 35 local function init() - local label = cc.LabelTTF:create("XML Http Request Test", "Arial", 28) + local label = cc.Label:create("XML Http Request Test", s_arialPath, 28) + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setPosition(cc.p(winSize.width / 2, winSize.height - margin)) layer:addChild(label, 0) --Response Code Label - local labelStatusCode = cc.LabelTTF:create("HTTP Status Code", "Marker Felt", 20) + local labelStatusCode = cc.Label:create("HTTP Status Code", s_markerFeltFontPath, 20) + labelStatusCode:setAnchorPoint(cc.p(0.5, 0.5)) labelStatusCode:setPosition(cc.p(winSize.width / 2, winSize.height - margin - 6 * space)) layer:addChild(labelStatusCode) @@ -38,7 +40,8 @@ local function XMLHttpRequestLayer() labelStatusCode:setString("waiting...") end - local labelGet = cc.LabelTTF:create("Test Get", "Arial", 22) + local labelGet = cc.Label:create("Test Get", s_arialPath, 22) + labelGet:setAnchorPoint(cc.p(0.5, 0.5)) local itemGet = cc.MenuItemLabel:create(labelGet) itemGet:registerScriptTapHandler(onMenuGetClicked) itemGet:setPosition(cc.p(winSize.width / 2, winSize.height - margin - space)) @@ -59,7 +62,8 @@ local function XMLHttpRequestLayer() labelStatusCode:setString("waiting...") end - local labelPost = cc.LabelTTF:create("Test Post", "Arial", 22) + local labelPost = cc.Label:create("Test Post", s_arialPath, 22) + labelPost:setAnchorPoint(cc.p(0.5, 0.5)) local itemPost = cc.MenuItemLabel:create(labelPost) itemPost:registerScriptTapHandler(onMenuPostClicked) itemPost:setPosition(cc.p(winSize.width / 2, winSize.height - margin - 2 * space)) @@ -93,7 +97,8 @@ local function XMLHttpRequestLayer() labelStatusCode:setString("waiting...") end - local labelPostBinary = cc.LabelTTF:create("Test Post Binary", "Arial", 22) + local labelPostBinary = cc.Label:create("Test Post Binary", s_arialPath, 22) + labelPostBinary:setAnchorPoint(cc.p(0.5, 0.5)) local itemPostBinary = cc.MenuItemLabel:create(labelPostBinary) itemPostBinary:registerScriptTapHandler(onMenuPostBinaryClicked) itemPostBinary:setPosition(cc.p(winSize.width / 2, winSize.height - margin - 3 * space)) @@ -121,7 +126,8 @@ local function XMLHttpRequestLayer() labelStatusCode:setString("waiting...") end - local labelPostJson = cc.LabelTTF:create("Test Post Json", "Arial", 22) + local labelPostJson = cc.LabelTTF:create("Test Post Json", s_arialPath, 22) + labelPostJson:setAnchorPoint(cc.p(0.5, 0.5)) local itemPostJson = cc.MenuItemLabel:create(labelPostJson) itemPostJson:registerScriptTapHandler(onMenuPostJsonClicked) itemPostJson:setPosition(cc.p(winSize.width / 2, winSize.height - margin - 4 * space)) diff --git a/tests/lua-tests/src/helper.lua b/tests/lua-tests/src/helper.lua index c2706d02d3..05763b944b 100644 --- a/tests/lua-tests/src/helper.lua +++ b/tests/lua-tests/src/helper.lua @@ -40,7 +40,8 @@ end -- add the menu item for back to main menu function CreateBackMenuItem() - local label = cc.LabelTTF:create("MainMenu", "Arial", 20) + local label = cc.Label:create("MainMenu", s_arialPath, 20) + label:setAnchorPoint(cc.p(0.5, 0.5)) local MenuItem = cc.MenuItemLabel:create(label) MenuItem:registerScriptTapHandler(MainMenuCallback) @@ -100,11 +101,13 @@ function Helper.initWithLayer(layer) Helper.currentLayer = layer local size = cc.Director:getInstance():getWinSize() - Helper.titleLabel = cc.LabelTTF:create("", "Arial", 28) + Helper.titleLabel = cc.Label:create("", s_arialPath, 28) + Helper.titleLabel:setAnchorPoint(cc.p(0.5, 0.5)) layer:addChild(Helper.titleLabel, 1) Helper.titleLabel:setPosition(size.width / 2, size.height - 50) - Helper.subtitleLabel = cc.LabelTTF:create("", "Thonburi", 16) + Helper.subtitleLabel = cc.Label:create("", s_thonburiPath, 16) + Helper.subtitleLabel:setAnchorPoint(cc.p(0.5, 0.5)) layer:addChild(Helper.subtitleLabel, 1) Helper.subtitleLabel:setPosition(size.width / 2, size.height - 80) diff --git a/tests/lua-tests/src/mainMenu.lua b/tests/lua-tests/src/mainMenu.lua index 4d0b967332..8afcc3bcda 100644 --- a/tests/lua-tests/src/mainMenu.lua +++ b/tests/lua-tests/src/mainMenu.lua @@ -155,7 +155,8 @@ function CreateTestMenu() local index = 0 local obj = nil for index, obj in pairs(_allTests) do - local testLabel = cc.LabelTTF:create(obj.name, "Arial", 24) + local testLabel = cc.Label:create(obj.name, s_arialPath, 24) + testLabel:setAnchorPoint(cc.p(0.5, 0.5)) local testMenuItem = cc.MenuItemLabel:create(testLabel) if not obj.isSupported then testMenuItem:setEnabled(false) diff --git a/tests/lua-tests/src/testResource.lua b/tests/lua-tests/src/testResource.lua index b490e3a6dc..466082560f 100644 --- a/tests/lua-tests/src/testResource.lua +++ b/tests/lua-tests/src/testResource.lua @@ -44,3 +44,4 @@ s_pPathSpineBoyAtlas = "spine/spineboy.atlas" s_markerFeltFontPath = "fonts/Marker Felt.ttf" s_arialPath = "fonts/arial.ttf" s_thonburiPath = "fonts/Thonburi.ttf" +s_tahomaPath = "fonts/tahoma.ttf" From 2a3cb0847eda0f987310494ba2807d61fef05986 Mon Sep 17 00:00:00 2001 From: heliclei Date: Wed, 12 Mar 2014 18:10:45 +0800 Subject: [PATCH 14/35] refactor api name --- cocos/2d/CCNode.cpp | 4 ++-- cocos/2d/CCNode.h | 5 +++-- tests/cpp-tests/Classes/NodeTest/NodeTest.cpp | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 7a49183eb5..b2a7856289 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -732,7 +732,7 @@ Node* Node::getChildByName(const std::string& name) return nullptr; } -void Node::enumChildNodesByName(const std::string& name, const std::function& callback) +void Node::enumerateChildrenByName(const std::string& name, const std::function& callback) { for (auto& child : _children) { @@ -746,7 +746,7 @@ void Node::enumChildNodesByName(const std::string& name, const std::functionenumChildNodesByName(name, callback); + child->enumerateChildrenByName(name, callback); } return; } diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index a6021113c1..0ae342f34d 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -647,7 +647,7 @@ public: virtual Node * getChildByTag(int tag); /** - * Gets a child from the container with its name + * get a child node with its name, will recursively search the whole node tree * * @param name A string identifier to find the child node. * @@ -802,12 +802,13 @@ public: virtual void setName(const std::string& name); /** * Search the children to perform processing for nodes which share a name. + * Note: this function will search the whole node tree recursively. * @param name the name to search for * @param callback, A callback to execute on nodes that match the name parameter. The callback takes the following arguments: * node: A node that matches the name. * stop: A pointer to a Boolean variable. Your callback can set this to true to terminate the enumeration. */ - virtual void enumChildNodesByName(const std::string& name, const std::function& callback); + virtual void enumerateChildrenByName(const std::string& name, const std::function& callback); /** * Returns a custom user data pointer * diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index 625a6a7808..0038b3db43 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -389,7 +389,7 @@ void NodeEnumChildByNameTest::onEnter() addChild(sp21); addChild(sp22); - enumChildNodesByName("sister1", + enumerateChildrenByName("sister1", [](Node* node, bool* stop) { auto rot = RotateBy::create(2, 360); @@ -397,7 +397,7 @@ void NodeEnumChildByNameTest::onEnter() auto forever1 = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); node->runAction(forever1); }); - enumChildNodesByName("sister2", + enumerateChildrenByName("sister2", [](Node* node, bool* stop) { auto actionUp = JumpBy::create(2, Point(0,0), 80, 4); From 27390f3282238bf49b7ae31b851649ebc74d67e6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 12 Mar 2014 18:25:15 +0800 Subject: [PATCH 15/35] Update CHANGELOG [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index c88784dcd9..e071d04655 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -14c85247a5f8b18ac4e064c8afb58f55b58911f7 \ No newline at end of file +2ba216b4ae56fa741405d81c01614f325fc19874 \ No newline at end of file From 2f582dcdb5f2aadcb8bafda4d7100d587feac5a7 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 12 Mar 2014 10:33:14 +0000 Subject: [PATCH 16/35] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/cocos2dx_files.json.REMOVED.git-id b/templates/cocos2dx_files.json.REMOVED.git-id index 5374f37ae3..953df89f6c 100644 --- a/templates/cocos2dx_files.json.REMOVED.git-id +++ b/templates/cocos2dx_files.json.REMOVED.git-id @@ -1 +1 @@ -aaa15588eceeedb1870d9326a5e367b2a47d5694 \ No newline at end of file +944571d5d58e1c6ffe42b48e175a19125fc95556 \ No newline at end of file From 9713a246ee4eb14cf4f459b76d4338d5f4d3333f Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Wed, 12 Mar 2014 18:33:28 +0800 Subject: [PATCH 17/35] Replace cc.LabelBMFont:create with cc.Label:createBMFont --- tests/lua-tests/src/FontTest/FontTest.lua | 8 ++++---- .../src/IntervalTest/IntervalTest.lua | 15 ++++++++++----- tests/lua-tests/src/LayerTest/LayerTest.lua | 18 ++++++++++++------ tests/lua-tests/src/MenuTest/MenuTest.lua | 9 ++++++--- tests/lua-tests/src/OpenGLTest/OpenGLTest.lua | 3 ++- .../src/PerformanceTest/PerformanceTest.lua | 3 ++- .../XMLHttpRequestTest/XMLHttpRequestTest.lua | 2 +- 7 files changed, 37 insertions(+), 21 deletions(-) diff --git a/tests/lua-tests/src/FontTest/FontTest.lua b/tests/lua-tests/src/FontTest/FontTest.lua index 7ec20ed132..18eb6de81e 100644 --- a/tests/lua-tests/src/FontTest/FontTest.lua +++ b/tests/lua-tests/src/FontTest/FontTest.lua @@ -37,12 +37,12 @@ local function showFont(ret, pFont) ret:removeChildByTag(kTagLabel3, true) ret:removeChildByTag(kTagLabel4, true) - local top = cc.LabelTTF:create(pFont, pFont, 24) - local left = cc.LabelTTF:create("alignment left", pFont, fontSize, + local top = cc.Label:create(pFont, pFont, 24) + local left = cc.Label:create("alignment left", pFont, fontSize, blockSize, cc.TEXT_ALIGNMENT_LEFT, verticalAlignment[vAlignIdx]) - local center = cc.LabelTTF:create("alignment center", pFont, fontSize, + local center = cc.Label:create("alignment center", pFont, fontSize, blockSize, cc.TEXT_ALIGNMENT_CENTER, verticalAlignment[vAlignIdx]) - local right = cc.LabelTTF:create("alignment right", pFont, fontSize, + local right = cc.Label:create("alignment right", pFont, fontSize, blockSize, cc.TEXT_ALIGNMENT_RIGHT, verticalAlignment[vAlignIdx]) local leftColor = cc.LayerColor:create(cc.c4b(100, 100, 100, 255), blockSize.width, blockSize.height) diff --git a/tests/lua-tests/src/IntervalTest/IntervalTest.lua b/tests/lua-tests/src/IntervalTest/IntervalTest.lua index 3f09c0bf0e..a7512e3ad6 100644 --- a/tests/lua-tests/src/IntervalTest/IntervalTest.lua +++ b/tests/lua-tests/src/IntervalTest/IntervalTest.lua @@ -23,11 +23,16 @@ local function IntervalLayer() ret:addChild(sun) -- timers - m_label0 = cc.LabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") - m_label1 = cc.LabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") - m_label2 = cc.LabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") - m_label3 = cc.LabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") - m_label4 = cc.LabelBMFont:create("0", "fonts/bitmapFontTest4.fnt") + m_label0 = cc.Label:createWithBMFont("fonts/bitmapFontTest4.fnt", "0") + m_label0:setAnchorPoint(cc.p(0.5, 0.5)) + m_label1 = cc.Label:createWithBMFont("fonts/bitmapFontTest4.fnt", "0") + m_label1:setAnchorPoint(cc.p(0.5, 0.5)) + m_label2 = cc.Label:createWithBMFont("fonts/bitmapFontTest4.fnt", "0") + m_label2:setAnchorPoint(cc.p(0.5, 0.5)) + m_label3 = cc.Label:createWithBMFont("fonts/bitmapFontTest4.fnt", "0") + m_label3:setAnchorPoint(cc.p(0.5, 0.5)) + m_label4 = cc.Label:createWithBMFont("fonts/bitmapFontTest4.fnt", "0") + m_label4:setAnchorPoint(cc.p(0.5, 0.5)) local function update(dt) m_time0 = m_time0 + dt diff --git a/tests/lua-tests/src/LayerTest/LayerTest.lua b/tests/lua-tests/src/LayerTest/LayerTest.lua index ec74ef6430..1e360038bf 100644 --- a/tests/lua-tests/src/LayerTest/LayerTest.lua +++ b/tests/lua-tests/src/LayerTest/LayerTest.lua @@ -68,7 +68,8 @@ local function LayerTestCascadingOpacityA() local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") - local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local label = cc.Label:createWithBMFont("fonts/bitmapFontTest.fnt", "Test") + label:setAnchorPoint(cc.p(0.5, 0.5)) layer1:addChild(sister1) layer1:addChild(sister2) @@ -109,7 +110,8 @@ local function LayerTestCascadingOpacityB() local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") - local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local label = cc.Label:createWithBMFont("fonts/bitmapFontTest.fnt","Test") + label:setAnchorPoint(cc.p(0.5, 0.5)) layer1:addChild(sister1) layer1:addChild(sister2) @@ -142,7 +144,8 @@ local function LayerTestCascadingOpacityC() local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") - local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local label = cc.Label:createWithBMFont("fonts/bitmapFontTest.fnt","Test") + label:setAnchorPoint(cc.p(0.5, 0.5)) layer1:addChild(sister1) layer1:addChild(sister2) @@ -172,7 +175,8 @@ local function LayerTestCascadingColorA() local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") - local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local label = cc.Label:createWithBMFont("fonts/bitmapFontTest.fnt","Test") + label:setAnchorPoint(cc.p(0.5, 0.5)) layer1:addChild(sister1) layer1:addChild(sister2) @@ -218,7 +222,8 @@ local function LayerTestCascadingColorB() local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") - local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local label = cc.Label:createWithBMFont("fonts/bitmapFontTest.fnt","Test") + label:setAnchorPoint(cc.p(0.5, 0.5)) layer1:addChild(sister1) layer1:addChild(sister2) @@ -263,7 +268,8 @@ local function LayerTestCascadingColorC() local sister1 = cc.Sprite:create("Images/grossinis_sister1.png") local sister2 = cc.Sprite:create("Images/grossinis_sister2.png") - local label = cc.LabelBMFont:create("Test", "fonts/bitmapFontTest.fnt") + local label = cc.Label:createWithBMFont("fonts/bitmapFontTest.fnt","Test") + label:setAnchorPoint(cc.p(0.5, 0.5)) layer1:addChild(sister1) layer1:addChild(sister2) diff --git a/tests/lua-tests/src/MenuTest/MenuTest.lua b/tests/lua-tests/src/MenuTest/MenuTest.lua index 00bbe470b1..3f0cda793f 100644 --- a/tests/lua-tests/src/MenuTest/MenuTest.lua +++ b/tests/lua-tests/src/MenuTest/MenuTest.lua @@ -89,7 +89,8 @@ local function MenuLayerMainMenu() end -- Label Item (cc.LabelBMFont) - local label = cc.LabelBMFont:create("configuration", "fonts/bitmapFontTest3.fnt") + local label = cc.Label:createWithBMFont("fonts/bitmapFontTest3.fnt", "configuration") + label:setAnchorPoint(cc.p(0.5, 0.5)) local item5 = cc.MenuItemLabel:create(label) item5:registerScriptTapHandler(menuCallbackConfig) @@ -321,7 +322,8 @@ local function MenuLayer3() cc.MenuItemFont:setFontName("Marker Felt") cc.MenuItemFont:setFontSize(28) - local label = cc.LabelBMFont:create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt") + local label = cc.Label:createWithBMFont("fonts/bitmapFontTest3.fnt", "Enable AtlasItem") + label:setAnchorPoint(cc.p(0.5, 0.5)) local item1 = cc.MenuItemLabel:create(label) item1:registerScriptTapHandler(menuCallback2) @@ -446,7 +448,8 @@ local function MenuLayer4() cc.MenuItemFont:setFontName( "Marker Felt" ) cc.MenuItemFont:setFontSize( 34 ) - local label = cc.LabelBMFont:create( "go back", "fonts/bitmapFontTest3.fnt" ) + local label = cc.Label:createWithBMFont("fonts/bitmapFontTest3.fnt", "go back") + label:setAnchorPoint(cc.p(0.5, 0.5)) local back = cc.MenuItemLabel:create(label) back:registerScriptTapHandler(backCallback) diff --git a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua index f1f2bbb33a..d8c50d7842 100644 --- a/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua +++ b/tests/lua-tests/src/OpenGLTest/OpenGLTest.lua @@ -166,7 +166,8 @@ local function OpenGLTestMainLayer() program:link() program:updateUniforms() - label = cc.LabelBMFont:create("RETRO EFFECT","fonts/west_england-64.fnt") + label = cc.Label:createWithBMFont("fonts/west_england-64.fnt", "RETRO EFFECT") + label:setAnchorPoint(cc.p(0.5, 0.5)) label:setShaderProgram( program ) label:setPosition(size.width/2, size.height/2) diff --git a/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua b/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua index d2231ac000..23cb329d94 100644 --- a/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua +++ b/tests/lua-tests/src/PerformanceTest/PerformanceTest.lua @@ -1613,7 +1613,8 @@ local function runTouchesTest() pLayer:scheduleUpdateWithPriorityLua(update,0) - pClassLabel = cc.LabelBMFont:create("00.0", "fonts/arial16.fnt") + pClassLabel = cc.Label:createWithBMFont("fonts/arial16.fnt", "00.0") + pClassLabel:setAnchorPoint(cc.p(0.5, 0.5)) pClassLabel:setPosition(cc.p(s.width/2, s.height/2)) pLayer:addChild(pClassLabel) diff --git a/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua b/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua index 5208580401..6151b4ff56 100644 --- a/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua +++ b/tests/lua-tests/src/XMLHttpRequestTest/XMLHttpRequestTest.lua @@ -126,7 +126,7 @@ local function XMLHttpRequestLayer() labelStatusCode:setString("waiting...") end - local labelPostJson = cc.LabelTTF:create("Test Post Json", s_arialPath, 22) + local labelPostJson = cc.Label:create("Test Post Json", s_arialPath, 22) labelPostJson:setAnchorPoint(cc.p(0.5, 0.5)) local itemPostJson = cc.MenuItemLabel:create(labelPostJson) itemPostJson:registerScriptTapHandler(onMenuPostJsonClicked) From 6721b1521712edb22bb75d18b5278e5138efe101 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 12 Mar 2014 11:38:24 +0000 Subject: [PATCH 18/35] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/cocos2dx_files.json.REMOVED.git-id b/templates/cocos2dx_files.json.REMOVED.git-id index 953df89f6c..0798302044 100644 --- a/templates/cocos2dx_files.json.REMOVED.git-id +++ b/templates/cocos2dx_files.json.REMOVED.git-id @@ -1 +1 @@ -944571d5d58e1c6ffe42b48e175a19125fc95556 \ No newline at end of file +80cc792ef1c7dd359131c0519fe3d1b74660fc26 \ No newline at end of file From e93feaa068e5d097e7668b087b638387d6de58d1 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 12 Mar 2014 11:41:17 +0000 Subject: [PATCH 19/35] [AUTO]: updating luabinding automatically --- .../scripting/lua-bindings/auto/api/Node.lua | 36 +++++++++++-------- .../auto/lua_cocos2dx_auto.cpp.REMOVED.git-id | 2 +- .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 1 + 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/cocos/scripting/lua-bindings/auto/api/Node.lua b/cocos/scripting/lua-bindings/auto/api/Node.lua index 498123f9d6..fab16bbe5d 100644 --- a/cocos/scripting/lua-bindings/auto/api/Node.lua +++ b/cocos/scripting/lua-bindings/auto/api/Node.lua @@ -100,9 +100,10 @@ -- @param #float float -------------------------------- --- @function [parent=#Node] setScaleY +-- @function [parent=#Node] enumerateChildrenByName -- @param self --- @param #float float +-- @param #string str +-- @param #function func -------------------------------- -- @function [parent=#Node] setScaleX @@ -329,16 +330,11 @@ -- @return bool#bool ret (return value: bool) -------------------------------- --- overload function: visit() --- --- overload function: visit(cc.Renderer, kmMat4, bool) --- --- @function [parent=#Node] visit +-- @function [parent=#Node] runAction -- @param self --- @param #cc.Renderer renderer --- @param #kmMat4 kmmat4 --- @param #bool bool - +-- @param #cc.Action action +-- @return Action#Action ret (return value: cc.Action) + -------------------------------- -- @function [parent=#Node] setShaderProgram -- @param self @@ -355,11 +351,16 @@ -- @return point_table#point_table ret (return value: point_table) -------------------------------- --- @function [parent=#Node] runAction +-- overload function: visit() +-- +-- overload function: visit(cc.Renderer, kmMat4, bool) +-- +-- @function [parent=#Node] visit -- @param self --- @param #cc.Action action --- @return Action#Action ret (return value: cc.Action) - +-- @param #cc.Renderer renderer +-- @param #kmMat4 kmmat4 +-- @param #bool bool + -------------------------------- -- @function [parent=#Node] setScheduler -- @param self @@ -503,6 +504,11 @@ -- @param self -- @param #float float +-------------------------------- +-- @function [parent=#Node] setScaleY +-- @param self +-- @param #float float + -------------------------------- -- overload function: setScale(float, float) -- diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id index 73d95bcbd9..709c9efccc 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp.REMOVED.git-id @@ -1 +1 @@ -c0580e239bc0d30c6d09103a806ab3e6e76da123 \ No newline at end of file +fa5cf8075e2b31cc61b8c17783dbdc435feae281 \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 5eeff5ebfd..754ee1efa1 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -1547,6 +1547,7 @@ int register_all_cocos2dx(lua_State* tolua_S); + #endif // __cocos2dx_h__ From c4752b260b5495e54738234b08e5b9befc8ea46c Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 12 Mar 2014 20:18:55 +0800 Subject: [PATCH 20/35] Updates tools/travis-scripts/generate-template-files.py. --- tools/travis-scripts/generate-template-files.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/travis-scripts/generate-template-files.py b/tools/travis-scripts/generate-template-files.py index 36b70a02c7..b0b5fbb159 100755 --- a/tools/travis-scripts/generate-template-files.py +++ b/tools/travis-scripts/generate-template-files.py @@ -43,7 +43,7 @@ class CocosFileList: self.fileList_com=[] self.fileList_lua=[] - self.luaPath ="cocos/scripting/lua-bindings" + self.luaPath = ["cocos/scripting/lua-bindings", "external/lua"] def readIngoreFile(self, fileName): """ @@ -88,7 +88,12 @@ class CocosFileList: self.__bInclude(item) or self.__bInclude("%s/" %item) ): - if relativePath.upper().find(self.luaPath.upper())==0: + foundLuaModule = False + for luaPath in self.luaPath: + if relativePath.upper().find(luaPath.upper()) == 0: + foundLuaModule = True + break + if foundLuaModule: self.fileList_lua.append("%s/" %relativePath) else: self.fileList_com.append("%s/" %relativePath) @@ -112,7 +117,12 @@ class CocosFileList: ): continue # print(relativePath) - if relativePath.upper().find(self.luaPath.upper())==0: + foundLuaModule = False + for luaPath in self.luaPath: + if relativePath.upper().find(luaPath.upper()) == 0: + foundLuaModule = True + break + if foundLuaModule: self.fileList_lua.append(relativePath) else: self.fileList_com.append(relativePath) From 6d867fb29491ea38e5446cdec6a1e1608829321c Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 12 Mar 2014 12:24:03 +0000 Subject: [PATCH 21/35] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/cocos2dx_files.json.REMOVED.git-id b/templates/cocos2dx_files.json.REMOVED.git-id index 0798302044..91d277d59a 100644 --- a/templates/cocos2dx_files.json.REMOVED.git-id +++ b/templates/cocos2dx_files.json.REMOVED.git-id @@ -1 +1 @@ -80cc792ef1c7dd359131c0519fe3d1b74660fc26 \ No newline at end of file +b62fb6be563e97ce42e4b6c9e531aefe1e3fe834 \ No newline at end of file From 04038a912f4d6945965230e64516086da5bd771c Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 12 Mar 2014 20:34:49 +0800 Subject: [PATCH 22/35] [travis ci] Sort file list in generate-template-files.py. --- tools/travis-scripts/generate-template-files.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/travis-scripts/generate-template-files.py b/tools/travis-scripts/generate-template-files.py index b0b5fbb159..f0a1dea422 100755 --- a/tools/travis-scripts/generate-template-files.py +++ b/tools/travis-scripts/generate-template-files.py @@ -148,6 +148,8 @@ class CocosFileList: Save content to file with json format. """ f = open(fileName,"w") + self.fileList_com.sort() + self.fileList_lua.sort() content ={'common':self.fileList_com,'lua':self.fileList_lua} json.dump(content,f,sort_keys=True,indent=4) f.close() From be51779c4e5a582c9d3457f2b07e9c0b38d314dc Mon Sep 17 00:00:00 2001 From: zhangbin Date: Wed, 12 Mar 2014 20:35:05 +0800 Subject: [PATCH 23/35] Update the reference of submodule "cocos2d-console". --- tools/cocos2d-console | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cocos2d-console b/tools/cocos2d-console index 6605a5de18..f52d834ee7 160000 --- a/tools/cocos2d-console +++ b/tools/cocos2d-console @@ -1 +1 @@ -Subproject commit 6605a5de1840db1983c6a34bf9fbf8958290f814 +Subproject commit f52d834ee7b4f412f7b972ef484a0e406ce6c1fd From 0c68e4b1d53ffcd2448ec6a66cb038398f646e2a Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Wed, 12 Mar 2014 12:39:13 +0000 Subject: [PATCH 24/35] [AUTO][ci skip]: updating cocos2dx_files.json --- templates/cocos2dx_files.json.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/cocos2dx_files.json.REMOVED.git-id b/templates/cocos2dx_files.json.REMOVED.git-id index 91d277d59a..4dbbf4bbd5 100644 --- a/templates/cocos2dx_files.json.REMOVED.git-id +++ b/templates/cocos2dx_files.json.REMOVED.git-id @@ -1 +1 @@ -b62fb6be563e97ce42e4b6c9e531aefe1e3fe834 \ No newline at end of file +9f3063090daa92453372f232d777b4b625e31f98 \ No newline at end of file From 3acaf3ece5ce7e33196d29236b5bc14783168c80 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Wed, 12 Mar 2014 20:39:13 +0800 Subject: [PATCH 25/35] 1.Label:Fixes the font rendering on Windows. 2.fixed Label::setColor crash when create the label by font name. --- cocos/2d/CCLabel.cpp | 7 +++++-- cocos/2d/CCLabel.h | 4 ++-- cocos/2d/platform/win32/CCDevice.cpp | 23 +---------------------- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 6cf883bd29..574a3f33ec 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -972,7 +972,7 @@ void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parent if (_textSprite) { - _textSprite->visit(); + _textSprite->visit(renderer, _modelViewTransform, dirty); } else { @@ -1149,7 +1149,10 @@ void Label::setColor(const Color3B& color) { updateContent(); } - _reusedLetter->setColor(color); + if (_reusedLetter) + { + _reusedLetter->setColor(color); + } SpriteBatchNode::setColor(color); } diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index b203cc916a..cbfcacf985 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -59,7 +59,7 @@ typedef struct _ttfConfig bool distanceFieldEnabled; int outlineSize; - _ttfConfig(const char* filePath = "",int size = 36, const GlyphCollection& glyphCollection = GlyphCollection::NEHE, + _ttfConfig(const char* filePath = "",int size = 36, const GlyphCollection& glyphCollection = GlyphCollection::DYNAMIC, const char *customGlyphCollection = nullptr,bool useDistanceField = false,int outline = 0) :fontFilePath(filePath) ,fontSize(size) @@ -91,7 +91,7 @@ public: CC_DEPRECATED_ATTRIBUTE static Label* createWithTTF(const std::string& label, const std::string& fontFilePath, int fontSize, int lineSize = 0, TextHAlignment alignment = TextHAlignment::LEFT, - GlyphCollection glyphs = GlyphCollection::NEHE, const char *customGlyphs = 0, bool useDistanceField = false); + GlyphCollection glyphs = GlyphCollection::DYNAMIC, const char *customGlyphs = 0, bool useDistanceField = false); /** create a label with TTF configuration * It will generate texture of character by freetype. diff --git a/cocos/2d/platform/win32/CCDevice.cpp b/cocos/2d/platform/win32/CCDevice.cpp index 9d3bf94ce2..b0d5260457 100644 --- a/cocos/2d/platform/win32/CCDevice.cpp +++ b/cocos/2d/platform/win32/CCDevice.cpp @@ -74,24 +74,6 @@ public: { DeleteDC(_DC); } - /*HFONT hDefFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); - if (hDefFont != _font) - { - DeleteObject(_font); - _font = hDefFont; - } - // release temp font resource - if (_curFontPath.size() > 0) - { - wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath); - if (pwszBuffer) - { - RemoveFontResource(pwszBuffer); - SendMessage( _wnd, WM_FONTCHANGE, 0, 0); - delete [] pwszBuffer; - pwszBuffer = NULL; - } - }*/ removeCustomFont(); } @@ -441,10 +423,7 @@ Data Device::getTextureDataForText(const char * text,const FontDefinition& textD for (int x = 0; x < width; ++x) { COLORREF& clr = *pPixel; - if (GetRValue(clr) || GetGValue(clr) || GetBValue(clr)) - { - clr |= 0xff000000; - } + clr = (0xffffff | (GetRValue(clr) << 24)); ++pPixel; } } From 656211a72f71fdf82b23064b85aa834f2b730c38 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 12 Mar 2014 21:28:38 +0800 Subject: [PATCH 26/35] add description for how to load .so --- .../src/org/cocos2dx/cpp/Cocos2dxActivity.java | 3 +++ .../src/org/cocos2dx/lua/Cocos2dxActivity.java | 16 +++------------- .../src/org/cocos2dx/lua/Cocos2dxActivity.java | 3 +++ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/templates/cpp-template-default/proj.android/src/org/cocos2dx/cpp/Cocos2dxActivity.java b/templates/cpp-template-default/proj.android/src/org/cocos2dx/cpp/Cocos2dxActivity.java index 449d0683ec..e751eca333 100644 --- a/templates/cpp-template-default/proj.android/src/org/cocos2dx/cpp/Cocos2dxActivity.java +++ b/templates/cpp-template-default/proj.android/src/org/cocos2dx/cpp/Cocos2dxActivity.java @@ -3,6 +3,9 @@ package org.cocos2dx.cpp; import android.app.NativeActivity; import android.os.Bundle; +// The name of .so is specified in AndroidMenifest.xml. NativityActivity will load it automatically for you. +// You can use "System.loadLibrary()" to load other .so files. + public class Cocos2dxActivity extends NativeActivity{ @Override diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/Cocos2dxActivity.java b/templates/lua-template-default/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/Cocos2dxActivity.java index 8a6f1a6f1c..074f831a1a 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/Cocos2dxActivity.java +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/Cocos2dxActivity.java @@ -1,20 +1,10 @@ package org.cocos2dx.lua; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.util.Enumeration; - import android.app.NativeActivity; -import android.content.Context; -import android.content.Intent; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; import android.os.Bundle; -import android.os.Environment; -import android.provider.Settings; -import android.util.Log; -import android.widget.Toast; + +// The name of .so is specified in AndroidMenifest.xml. NativityActivity will load it automatically for you. +// You can use "System.loadLibrary()" to load other .so files. public class Cocos2dxActivity extends NativeActivity{ diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/Cocos2dxActivity.java b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/Cocos2dxActivity.java index 932794051e..76e0797690 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/Cocos2dxActivity.java +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/Cocos2dxActivity.java @@ -16,6 +16,9 @@ import android.provider.Settings; import android.util.Log; import android.widget.Toast; +// The name of .so is specified in AndroidMenifest.xml. NativityActivity will load it automatically for you. +// You can use "System.loadLibrary()" to load other .so files. + public class Cocos2dxActivity extends NativeActivity{ @Override From cc8738ee94d98bd4362dfe55809b9c55a090f67a Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 12 Mar 2014 21:45:15 +0800 Subject: [PATCH 27/35] Simulator fix: After main loop, NSApplication needs to be terminated immediately. --- .../runtime-src/proj.ios_mac/mac/SimulatorApp.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm b/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm index f79e3924d2..7ef45ef4e9 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm @@ -41,9 +41,9 @@ using namespace cocos2d; -bool g_landscape=false; -CCSize g_screenSize; -GLView* g_eglView=NULL; +bool g_landscape = false; +cocos2d::Size g_screenSize; +GLView* g_eglView = nullptr; using namespace std; using namespace cocos2d; @@ -54,7 +54,7 @@ using namespace cocos2d; -(void) dealloc { - CCDirector::sharedDirector()->end(); + Director::getInstance()->end(); [super dealloc]; } @@ -63,11 +63,11 @@ using namespace cocos2d; - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { - AppDelegate app; [self createSimulator:[NSString stringWithUTF8String:"HelloLua"] viewWidth:960 viewHeight:640 factor:1.0]; - int ret = Application::getInstance()->run(); - + Application::getInstance()->run(); + // After run, application needs to be terminated immediately. + [NSApp terminate: self]; } From 77a8476c8078b66b02f87fd60b7f9d4684758a41 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 12 Mar 2014 21:45:57 +0800 Subject: [PATCH 28/35] GLView::end needs to release self. --- cocos/2d/platform/desktop/CCGLView.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/2d/platform/desktop/CCGLView.cpp b/cocos/2d/platform/desktop/CCGLView.cpp index 1f140dafde..0b4dcc7e11 100644 --- a/cocos/2d/platform/desktop/CCGLView.cpp +++ b/cocos/2d/platform/desktop/CCGLView.cpp @@ -386,7 +386,8 @@ void GLView::end() glfwSetWindowShouldClose(_mainWindow,1); _mainWindow = nullptr; } - + // Release self. Otherwise, GLView could not be freed. + release(); } void GLView::swapBuffers() From 372c26b5ba3a9623cb3694224cc3b5ce6c48f948 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 12 Mar 2014 08:40:04 -0700 Subject: [PATCH 29/35] only active arch for DEBUG RELEAES compiles all valid archs --- build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id index 82864a9aa4..e6f0599f23 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -08fd638cd925dfad54a49df207a72130942102d3 \ No newline at end of file +66526d30a3e76bb1b54c7615a18c467845798e78 \ No newline at end of file From 0dc85e42a7558ef364e016853186087b34d19989 Mon Sep 17 00:00:00 2001 From: chuanweizhang2013 Date: Thu, 13 Mar 2014 09:51:43 +0800 Subject: [PATCH 30/35] modify module_path --- .../frameworks/runtime-src/proj.android/jni/Android.mk | 5 ++--- .../frameworks/runtime-src/proj.android/jni/Android.mk | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/Android.mk b/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/Android.mk index dfa01aa1a1..f60e92fa51 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/Android.mk +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android/jni/Android.mk @@ -10,8 +10,7 @@ LOCAL_SRC_FILES := hellolua/main.cpp \ ../../Classes/AppDelegate.cpp -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \ - $(LOCAL_PATH)/../../cocos2d-x/external/lua/tolua +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_STATIC_LIBRARIES := curl_static_prebuilt @@ -19,4 +18,4 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_lua_static include $(BUILD_SHARED_LIBRARY) -$(call import-module,bindings) \ No newline at end of file +$(call import-module,scripting/lua-bindings) \ No newline at end of file diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk index f87974d44c..ea55d615e5 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.android/jni/Android.mk @@ -12,8 +12,7 @@ LOCAL_SRC_FILES := hellolua/main.cpp \ ../../Classes/Runtime.cpp -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \ - $(LOCAL_PATH)/../../cocos2d-x/external/lua/tolua +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_STATIC_LIBRARIES := curl_static_prebuilt @@ -21,4 +20,4 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_lua_static include $(BUILD_SHARED_LIBRARY) -$(call import-module,bindings) \ No newline at end of file +$(call import-module,scripting/lua-bindings) \ No newline at end of file From b8ce59962a39e12d2620062486c320a30c61d9ec Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 13 Mar 2014 10:11:41 +0800 Subject: [PATCH 31/35] Fixed bug of ScrollView --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos/ui/UIScrollView.cpp | 37 +++- cocos/ui/UIScrollView.h | 9 + cocos/ui/UIWidget.cpp | 113 +++-------- cocos/ui/UIWidget.h | 4 + .../ButtonReader/ButtonReader.cpp | 158 -------------- .../WidgetReader/ButtonReader/ButtonReader.h | 47 ----- .../CheckBoxReader/CheckBoxReader.cpp | 153 -------------- .../CheckBoxReader/CheckBoxReader.h | 47 ----- .../ImageViewReader/ImageViewReader.cpp | 98 --------- .../ImageViewReader/ImageViewReader.h | 47 ----- .../LayoutReader/LayoutReader.cpp | 119 ----------- .../WidgetReader/LayoutReader/LayoutReader.h | 47 ----- .../ListViewReader/ListViewReader.cpp | 48 ----- .../ListViewReader/ListViewReader.h | 47 ----- .../LoadingBarReader/LoadingBarReader.cpp | 91 --------- .../LoadingBarReader/LoadingBarReader.h | 47 ----- .../PageViewReader/PageViewReader.cpp | 35 ---- .../PageViewReader/PageViewReader.h | 47 ----- .../ScrollViewReader/ScrollViewReader.cpp | 47 ----- .../ScrollViewReader/ScrollViewReader.h | 47 ----- .../SliderReader/SliderReader.cpp | 192 ------------------ .../WidgetReader/SliderReader/SliderReader.h | 47 ----- .../TextAtlasReader/TextAtlasReader.cpp | 69 ------- .../TextAtlasReader/TextAtlasReader.h | 46 ----- .../TextBMFontReader/TextBMFontReader.cpp | 65 ------ .../TextBMFontReader/TextBMFontReader.h | 47 ----- .../TextFieldReader/TextFieldReader.cpp | 84 -------- .../TextFieldReader/TextFieldReader.h | 47 ----- .../ui/WidgetReader/TextReader/TextReader.cpp | 74 ------- cocos/ui/WidgetReader/TextReader/TextReader.h | 47 ----- cocos/ui/WidgetReader/WidgetReader.cpp | 173 ---------------- cocos/ui/WidgetReader/WidgetReader.h | 51 ----- cocos/ui/WidgetReader/WidgetReaderProtocol.h | 53 ----- .../Hello.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../GUI/missing-font.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../Hello.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../background.png.REMOVED.git-id | 0 .../UITest/background.png.REMOVED.git-id | 0 .../b11.png.REMOVED.git-id | 0 .../bitmapFontTest2.png.REMOVED.git-id | 0 .../examples/examples.json.REMOVED.git-id | 0 .../map_1/map_pve.png.REMOVED.git-id | 0 .../page_1/background.png.REMOVED.git-id | 0 68 files changed, 82 insertions(+), 2203 deletions(-) delete mode 100644 cocos/ui/WidgetReader/ButtonReader/ButtonReader.cpp delete mode 100644 cocos/ui/WidgetReader/ButtonReader/ButtonReader.h delete mode 100644 cocos/ui/WidgetReader/CheckBoxReader/CheckBoxReader.cpp delete mode 100644 cocos/ui/WidgetReader/CheckBoxReader/CheckBoxReader.h delete mode 100644 cocos/ui/WidgetReader/ImageViewReader/ImageViewReader.cpp delete mode 100644 cocos/ui/WidgetReader/ImageViewReader/ImageViewReader.h delete mode 100644 cocos/ui/WidgetReader/LayoutReader/LayoutReader.cpp delete mode 100644 cocos/ui/WidgetReader/LayoutReader/LayoutReader.h delete mode 100644 cocos/ui/WidgetReader/ListViewReader/ListViewReader.cpp delete mode 100644 cocos/ui/WidgetReader/ListViewReader/ListViewReader.h delete mode 100644 cocos/ui/WidgetReader/LoadingBarReader/LoadingBarReader.cpp delete mode 100644 cocos/ui/WidgetReader/LoadingBarReader/LoadingBarReader.h delete mode 100644 cocos/ui/WidgetReader/PageViewReader/PageViewReader.cpp delete mode 100644 cocos/ui/WidgetReader/PageViewReader/PageViewReader.h delete mode 100644 cocos/ui/WidgetReader/ScrollViewReader/ScrollViewReader.cpp delete mode 100644 cocos/ui/WidgetReader/ScrollViewReader/ScrollViewReader.h delete mode 100644 cocos/ui/WidgetReader/SliderReader/SliderReader.cpp delete mode 100644 cocos/ui/WidgetReader/SliderReader/SliderReader.h delete mode 100644 cocos/ui/WidgetReader/TextAtlasReader/TextAtlasReader.cpp delete mode 100644 cocos/ui/WidgetReader/TextAtlasReader/TextAtlasReader.h delete mode 100644 cocos/ui/WidgetReader/TextBMFontReader/TextBMFontReader.cpp delete mode 100644 cocos/ui/WidgetReader/TextBMFontReader/TextBMFontReader.h delete mode 100644 cocos/ui/WidgetReader/TextFieldReader/TextFieldReader.cpp delete mode 100644 cocos/ui/WidgetReader/TextFieldReader/TextFieldReader.h delete mode 100644 cocos/ui/WidgetReader/TextReader/TextReader.cpp delete mode 100644 cocos/ui/WidgetReader/TextReader/TextReader.h delete mode 100644 cocos/ui/WidgetReader/WidgetReader.cpp delete mode 100644 cocos/ui/WidgetReader/WidgetReader.h delete mode 100644 cocos/ui/WidgetReader/WidgetReaderProtocol.h rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/Hello.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UIButton_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UICheckBox_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UIImageView_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILabelAtlas_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILabelBMFont_Editor/GUI/missing-font.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILabelBMFont_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILabel_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/Hello.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILayout_Editor/UILayout_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UILoadingBar_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UIPageView_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UISlider_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UITextField_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UIEditorTest/UIWidgetAddNode_Editor/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/UITest/background.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/b11.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/bitmapFontTest2.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/examples/examples.json.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/gui_examples/map_1/map_pve.png.REMOVED.git-id (100%) rename tests/cpp-tests/Resources/hd/{cocosgui => cocosui}/gui_examples/page_1/background.png.REMOVED.git-id (100%) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index f04874a8ec..8088b36f0b 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -71a61fb97a4db05adaabc4cc03035fe419cc35d6 \ No newline at end of file +bbf0323293cba3d7ee58ef36706831a8761692d8 \ No newline at end of file diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index f286c9ba29..3b6b4e4421 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -27,6 +27,41 @@ THE SOFTWARE. NS_CC_BEGIN namespace ui { + +ScrollInnerContainer::ScrollInnerContainer() +{ + +} + +ScrollInnerContainer::~ScrollInnerContainer() +{ + +} + +ScrollInnerContainer* ScrollInnerContainer::create() +{ + ScrollInnerContainer* widget = new ScrollInnerContainer(); + if (widget && widget->init()) + { + widget->autorelease(); + return widget; + } + CC_SAFE_DELETE(widget); + return nullptr; +} + +const Size& ScrollInnerContainer::getLayoutSize() +{ + Widget* parent = getWidgetParent(); + if (parent) + { + return parent->getSize(); + } + else + { + return _size; + } +} static const float AUTOSCROLLMAXSPEED = 1000.0f; @@ -233,7 +268,7 @@ void ScrollView::addChild(Node * child, int zOrder) void ScrollView::addChild(Node *child, int zOrder, int tag) { - return _innerContainer->addChild(child, zOrder, tag); + _innerContainer->addChild(child, zOrder, tag); } void ScrollView::removeAllChildren() diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 1f0150e2ea..ad06d519ce 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -31,6 +31,15 @@ THE SOFTWARE. NS_CC_BEGIN namespace ui { + +class ScrollInnerContainer : public Layout +{ +public: + ScrollInnerContainer(); + virtual ~ScrollInnerContainer(); + static ScrollInnerContainer* create(); + virtual const Size& getLayoutSize() override; +}; enum SCROLLVIEW_DIR { diff --git a/cocos/ui/UIWidget.cpp b/cocos/ui/UIWidget.cpp index 9b7f613a51..3459f9e2ec 100644 --- a/cocos/ui/UIWidget.cpp +++ b/cocos/ui/UIWidget.cpp @@ -396,6 +396,21 @@ void Widget::setSizePercent(const Point &percent) } void Widget::updateSizeAndPosition() +{ + Widget* widgetParent = getWidgetParent(); + Size pSize; + if (widgetParent) + { + pSize = widgetParent->getLayoutSize(); + } + else + { + pSize = _parent->getContentSize(); + } + updateSizeAndPosition(pSize); +} + +void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize) { switch (_sizeType) { @@ -409,70 +424,33 @@ void Widget::updateSizeAndPosition() { _size = _customSize; } - Widget* widgetParent = getWidgetParent(); - if (widgetParent) + float spx = 0.0f; + float spy = 0.0f; + if (parentSize.width > 0.0f) { - Size pSize = widgetParent->getSize(); - float spx = 0.0f; - float spy = 0.0f; - if (pSize.width > 0.0f) - { - spx = _customSize.width / pSize.width; - } - if (pSize.height > 0.0f) - { - spy = _customSize.height / pSize.height; - } - _sizePercent = Point(spx, spy); + spx = _customSize.width / parentSize.width; } - else + if (parentSize.height > 0.0f) { - Size pSize = _parent->getContentSize(); - float spx = 0.0f; - float spy = 0.0f; - if (pSize.width > 0.0f) - { - spx = _customSize.width / pSize.width; - } - if (pSize.height > 0.0f) - { - spy = _customSize.height / pSize.height; - } - _sizePercent = Point(spx, spy); + spy = _customSize.height / parentSize.height; } + _sizePercent = Point(spx, spy); break; } case SIZE_PERCENT: { - Widget* widgetParent = getWidgetParent(); - if (widgetParent) + Size cSize = Size(parentSize.width * _sizePercent.x , parentSize.height * _sizePercent.y); + if (_ignoreSize) { - Size cSize = Size(widgetParent->getSize().width * _sizePercent.x , widgetParent->getSize().height * _sizePercent.y); - if (_ignoreSize) - { - _size = getContentSize(); - } - else - { - _size = cSize; - } - _customSize = cSize; + _size = getContentSize(); } else { - Size cSize = Size(_parent->getContentSize().width * _sizePercent.x , _parent->getContentSize().height * _sizePercent.y); - if (_ignoreSize) - { - _size = getContentSize(); - } - else - { - _size = cSize; - } - _customSize = cSize; + _size = cSize; } - } + _customSize = cSize; break; + } default: break; } @@ -482,46 +460,19 @@ void Widget::updateSizeAndPosition() { case POSITION_ABSOLUTE: { - Widget* widgetParent = getWidgetParent(); - if (widgetParent) + if (parentSize.width <= 0.0f || parentSize.height <= 0.0f) { - Size pSize = widgetParent->getSize(); - if (pSize.width <= 0.0f || pSize.height <= 0.0f) - { - _positionPercent = Point::ZERO; - } - else - { - _positionPercent = Point(absPos.x / pSize.width, absPos.y / pSize.height); - } + _positionPercent = Point::ZERO; } else { - Size pSize = _parent->getContentSize(); - if (pSize.width <= 0.0f || pSize.height <= 0.0f) - { - _positionPercent = Point::ZERO; - } - else - { - _positionPercent = Point(absPos.x / pSize.width, absPos.y / pSize.height); - } + _positionPercent = Point(absPos.x / parentSize.width, absPos.y / parentSize.height); } break; } case POSITION_PERCENT: { - Widget* widgetParent = getWidgetParent(); - if (widgetParent) - { - Size parentSize = widgetParent->getSize(); - absPos = Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); - } - else - { - Size parentSize = _parent->getContentSize(); - absPos = Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); - } + absPos = Point(parentSize.width * _positionPercent.x, parentSize.height * _positionPercent.y); break; } default: diff --git a/cocos/ui/UIWidget.h b/cocos/ui/UIWidget.h index eaa4bb692e..a91ac6102e 100644 --- a/cocos/ui/UIWidget.h +++ b/cocos/ui/UIWidget.h @@ -549,6 +549,8 @@ public: const Size& getSize() const; const Size& getCustomSize() const; + + virtual const Size& getLayoutSize() {return _size;}; /** * Returns size percent of widget @@ -642,6 +644,8 @@ public: void updateSizeAndPosition(); + void updateSizeAndPosition(const Size& parentSize); + /*temp action*/ void setActionTag(int tag); int getActionTag(); diff --git a/cocos/ui/WidgetReader/ButtonReader/ButtonReader.cpp b/cocos/ui/WidgetReader/ButtonReader/ButtonReader.cpp deleted file mode 100644 index 5bf321dc84..0000000000 --- a/cocos/ui/WidgetReader/ButtonReader/ButtonReader.cpp +++ /dev/null @@ -1,158 +0,0 @@ - - -#include "ButtonReader.h" -#include "ui/UIButton.h" - -namespace cocostudio -{ - static ButtonReader* instanceButtonReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(ButtonReader) - - ButtonReader::ButtonReader() - { - - } - - ButtonReader::~ButtonReader() - { - - } - - ButtonReader* ButtonReader::getInstance() - { - if (!instanceButtonReader) - { - instanceButtonReader = new ButtonReader(); - } - return instanceButtonReader; - } - - void ButtonReader::purge() - { - CC_SAFE_DELETE(instanceButtonReader); - } - - void ButtonReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) - { - WidgetReader::setPropsFromJsonDictionary(widget, options); - - - std::string jsonPath = GUIReader::getInstance()->getFilePath(); - - Button* button = static_cast(widget); - bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - button->setScale9Enabled(scale9Enable); - - const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "normalData"); - int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); - switch (normalType) - { - case 0: - { - std::string tp_n = jsonPath; - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr; - button->loadTextureNormal(normalFileName_tp); - break; - } - case 1: - { - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - button->loadTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "pressedData"); - int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); - switch (pressedType) - { - case 0: - { - std::string tp_p = jsonPath; - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr; - button->loadTexturePressed(pressedFileName_tp); - break; - } - case 1: - { - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - button->loadTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "disabledData"); - int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); - switch (disabledType) - { - case 0: - { - std::string tp_d = jsonPath; - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; - button->loadTextureDisabled(disabledFileName_tp); - break; - } - case 1: - { - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - button->loadTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - if (scale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - button->setCapInsets(Rect(cx, cy, cw, ch)); - bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); - bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); - float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); - button->setSize(Size(swf, shf)); - } - } - bool tt = DICTOOL->checkObjectExist_json(options, "text"); - if (tt) - { - const char* text = DICTOOL->getStringValue_json(options, "text"); - if (text) - { - button->setTitleText(text); - } - } - - bool cr = DICTOOL->checkObjectExist_json(options, "textColorR"); - bool cg = DICTOOL->checkObjectExist_json(options, "textColorG"); - bool cb = DICTOOL->checkObjectExist_json(options, "textColorB"); - int cri = cr?DICTOOL->getIntValue_json(options, "textColorR"):255; - int cgi = cg?DICTOOL->getIntValue_json(options, "textColorG"):255; - int cbi = cb?DICTOOL->getIntValue_json(options, "textColorB"):255; - button->setTitleColor(Color3B(cri,cgi,cbi)); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); - if (fs) - { - button->setTitleFontSize(DICTOOL->getIntValue_json(options, "fontSize")); - } - bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); - if (fn) - { - button->setTitleFontName(DICTOOL->getStringValue_json(options, "fontName")); - } - - - WidgetReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/ButtonReader/ButtonReader.h b/cocos/ui/WidgetReader/ButtonReader/ButtonReader.h deleted file mode 100644 index f3ec7b406a..0000000000 --- a/cocos/ui/WidgetReader/ButtonReader/ButtonReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__ButtonReader__ -#define __TestCpp__ButtonReader__ - -#include "../WidgetReader.h" - -namespace cocostudio -{ - class ButtonReader : public WidgetReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - ButtonReader(); - virtual ~ButtonReader(); - - static ButtonReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__ButtonReader__) */ diff --git a/cocos/ui/WidgetReader/CheckBoxReader/CheckBoxReader.cpp b/cocos/ui/WidgetReader/CheckBoxReader/CheckBoxReader.cpp deleted file mode 100644 index 06ac1bc0a7..0000000000 --- a/cocos/ui/WidgetReader/CheckBoxReader/CheckBoxReader.cpp +++ /dev/null @@ -1,153 +0,0 @@ - - -#include "CheckBoxReader.h" -#include "ui/UICheckBox.h" - -namespace cocostudio -{ - static CheckBoxReader* instanceCheckBoxReader = NULL; - using cocos2d::ui::CheckBox; - IMPLEMENT_CLASS_WIDGET_READER_INFO(CheckBoxReader) - - CheckBoxReader::CheckBoxReader() - { - - } - - CheckBoxReader::~CheckBoxReader() - { - - } - - CheckBoxReader* CheckBoxReader::getInstance() - { - if (!instanceCheckBoxReader) - { - instanceCheckBoxReader = new CheckBoxReader(); - } - return instanceCheckBoxReader; - } - - void CheckBoxReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) - { - WidgetReader::setPropsFromJsonDictionary(widget, options); - - - std::string jsonPath = GUIReader::getInstance()->getFilePath(); - - CheckBox* checkBox = static_cast(widget); - - const rapidjson::Value& backGroundDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxData"); - int backGroundType = DICTOOL->getIntValue_json(backGroundDic, "resourceType"); - switch (backGroundType) - { - case 0: - { - std::string tp_b = jsonPath; - const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path"); - const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():nullptr; - checkBox->loadTextureBackGround(backGroundFileName_tp); - break; - } - case 1: - { - const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path"); - checkBox->loadTextureBackGround(backGroundFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - const rapidjson::Value& backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxSelectedData"); - int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, "resourceType"); - switch (backGroundSelectedType) - { - case 0: - { - std::string tp_bs = jsonPath; - const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path"); - const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():nullptr; - checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName_tp); - break; - } - case 1: - { - const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path"); - checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - const rapidjson::Value& frontCrossDic = DICTOOL->getSubDictionary_json(options, "frontCrossData"); - int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, "resourceType"); - switch (frontCrossType) - { - case 0: - { - std::string tp_c = jsonPath; - const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path"); - const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():nullptr; - checkBox->loadTextureFrontCross(frontCrossFileName_tp); - break; - } - case 1: - { - const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path"); - checkBox->loadTextureFrontCross(frontCrossFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - const rapidjson::Value& backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxDisabledData"); - int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, "resourceType"); - switch (backGroundDisabledType) - { - case 0: - { - std::string tp_bd = jsonPath; - const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path"); - const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():nullptr; - checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName_tp); - break; - } - case 1: - { - const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path"); - checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - const rapidjson::Value& frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, "frontCrossDisabledData"); - int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, "resourceType"); - switch (frontCrossDisabledType) - { - case 0: - { - std::string tp_cd = jsonPath; - const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path"); - const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():nullptr; - checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp); - break; - } - case 1: - { - const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path"); - checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - - WidgetReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/CheckBoxReader/CheckBoxReader.h b/cocos/ui/WidgetReader/CheckBoxReader/CheckBoxReader.h deleted file mode 100644 index cbfed76584..0000000000 --- a/cocos/ui/WidgetReader/CheckBoxReader/CheckBoxReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__CheckBoxReader__ -#define __TestCpp__CheckBoxReader__ - -#include "../WidgetReader.h" - -namespace cocostudio -{ - class CheckBoxReader : public WidgetReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - CheckBoxReader(); - virtual ~CheckBoxReader(); - - static CheckBoxReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__CheckBoxReader__) */ diff --git a/cocos/ui/WidgetReader/ImageViewReader/ImageViewReader.cpp b/cocos/ui/WidgetReader/ImageViewReader/ImageViewReader.cpp deleted file mode 100644 index 083d81f261..0000000000 --- a/cocos/ui/WidgetReader/ImageViewReader/ImageViewReader.cpp +++ /dev/null @@ -1,98 +0,0 @@ - - -#include "ImageViewReader.h" -#include "ui/UIImageView.h" - -namespace cocostudio -{ - static ImageViewReader* instanceImageViewReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(ImageViewReader) - - ImageViewReader::ImageViewReader() - { - - } - - ImageViewReader::~ImageViewReader() - { - - } - - ImageViewReader* ImageViewReader::getInstance() - { - if (!instanceImageViewReader) - { - instanceImageViewReader = new ImageViewReader(); - } - return instanceImageViewReader; - } - - void ImageViewReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) - { - WidgetReader::setPropsFromJsonDictionary(widget, options); - - - std::string jsonPath = GUIReader::getInstance()->getFilePath(); - - ImageView* imageView = static_cast(widget); - - const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); - int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileNameType) - { - case 0: - { - std::string tp_i = jsonPath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = nullptr; - if (imageFileName && (strcmp(imageFileName, "") != 0)) - { - imageFileName_tp = tp_i.append(imageFileName).c_str(); - imageView->loadTexture(imageFileName_tp); - } - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable"); - bool scale9Enable = false; - if (scale9EnableExist) - { - scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - } - imageView->setScale9Enabled(scale9Enable); - - - if (scale9Enable) - { - bool sw = DICTOOL->checkObjectExist_json(options, "scale9Width"); - bool sh = DICTOOL->checkObjectExist_json(options, "scale9Height"); - if (sw && sh) - { - float swf = DICTOOL->getFloatValue_json(options, "scale9Width"); - float shf = DICTOOL->getFloatValue_json(options, "scale9Height"); - imageView->setSize(Size(swf, shf)); - } - - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - imageView->setCapInsets(Rect(cx, cy, cw, ch)); - - } - - - WidgetReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/ImageViewReader/ImageViewReader.h b/cocos/ui/WidgetReader/ImageViewReader/ImageViewReader.h deleted file mode 100644 index 09d4ae2b43..0000000000 --- a/cocos/ui/WidgetReader/ImageViewReader/ImageViewReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__ImageViewReader__ -#define __TestCpp__ImageViewReader__ - -#include "../WidgetReader.h" - -namespace cocostudio -{ - class ImageViewReader : public WidgetReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - ImageViewReader(); - virtual ~ImageViewReader(); - - static ImageViewReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__ImageViewReader__) */ diff --git a/cocos/ui/WidgetReader/LayoutReader/LayoutReader.cpp b/cocos/ui/WidgetReader/LayoutReader/LayoutReader.cpp deleted file mode 100644 index ec137e7ca4..0000000000 --- a/cocos/ui/WidgetReader/LayoutReader/LayoutReader.cpp +++ /dev/null @@ -1,119 +0,0 @@ - - -#include "LayoutReader.h" -#include "ui/UILayout.h" - -namespace cocostudio -{ - static LayoutReader* instanceLayoutReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(LayoutReader) - - LayoutReader::LayoutReader() - { - - } - - LayoutReader::~LayoutReader() - { - - } - - LayoutReader* LayoutReader::getInstance() - { - if (!instanceLayoutReader) - { - instanceLayoutReader = new LayoutReader(); - } - return instanceLayoutReader; - } - - void LayoutReader::setPropsFromJsonDictionary(ui::Widget *widget, const rapidjson::Value &options) - { - WidgetReader::setPropsFromJsonDictionary(widget, options); - - - std::string jsonPath = GUIReader::getInstance()->getFilePath(); - - Layout* panel = static_cast(widget); - - /* adapt screen gui */ - float w = 0, h = 0; - bool adaptScrenn = DICTOOL->getBooleanValue_json(options, "adaptScreen"); - if (adaptScrenn) - { - Size screenSize = CCDirector::getInstance()->getWinSize(); - w = screenSize.width; - h = screenSize.height; - } - else - { - w = DICTOOL->getFloatValue_json(options, "width"); - h = DICTOOL->getFloatValue_json(options, "height"); - } - panel->setSize(Size(w, h)); - /**/ - - bool backGroundScale9Enable = DICTOOL->getBooleanValue_json(options, "backGroundScale9Enable"); - panel->setBackGroundImageScale9Enabled(backGroundScale9Enable); - int cr = DICTOOL->getIntValue_json(options, "bgColorR"); - int cg = DICTOOL->getIntValue_json(options, "bgColorG"); - int cb = DICTOOL->getIntValue_json(options, "bgColorB"); - - int scr = DICTOOL->getIntValue_json(options, "bgStartColorR"); - int scg = DICTOOL->getIntValue_json(options, "bgStartColorG"); - int scb = DICTOOL->getIntValue_json(options, "bgStartColorB"); - - int ecr = DICTOOL->getIntValue_json(options, "bgEndColorR"); - int ecg = DICTOOL->getIntValue_json(options, "bgEndColorG"); - int ecb = DICTOOL->getIntValue_json(options, "bgEndColorB"); - - float bgcv1 = DICTOOL->getFloatValue_json(options, "vectorX"); - float bgcv2 = DICTOOL->getFloatValue_json(options, "vectorY"); - panel->setBackGroundColorVector(Point(bgcv1, bgcv2)); - - int co = DICTOOL->getIntValue_json(options, "bgColorOpacity"); - - int colorType = DICTOOL->getIntValue_json(options, "colorType"); - panel->setBackGroundColorType(LayoutBackGroundColorType(colorType)); - panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb)); - panel->setBackGroundColor(Color3B(cr, cg, cb)); - panel->setBackGroundColorOpacity(co); - - - const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "backGroundImageData"); - int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileNameType) - { - case 0: - { - std::string tp_b = jsonPath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; - panel->setBackGroundImage(imageFileName_tp); - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - if (backGroundScale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch)); - } - panel->setLayoutType((LayoutType)DICTOOL->getIntValue_json(options, "layoutType")); - - - WidgetReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/LayoutReader/LayoutReader.h b/cocos/ui/WidgetReader/LayoutReader/LayoutReader.h deleted file mode 100644 index e4d2f3b479..0000000000 --- a/cocos/ui/WidgetReader/LayoutReader/LayoutReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__LayoutReader__ -#define __TestCpp__LayoutReader__ - -#include "../WidgetReader.h" - -namespace cocostudio -{ - class LayoutReader : public WidgetReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - LayoutReader(); - virtual ~LayoutReader(); - - static LayoutReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__LayoutReader__) */ diff --git a/cocos/ui/WidgetReader/ListViewReader/ListViewReader.cpp b/cocos/ui/WidgetReader/ListViewReader/ListViewReader.cpp deleted file mode 100644 index 44a58941b5..0000000000 --- a/cocos/ui/WidgetReader/ListViewReader/ListViewReader.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -#include "ListViewReader.h" -#include "ui/UIListView.h" - -namespace cocostudio -{ - static ListViewReader* instanceListViewReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(ListViewReader) - - ListViewReader::ListViewReader() - { - - } - - ListViewReader::~ListViewReader() - { - - } - - ListViewReader* ListViewReader::getInstance() - { - if (!instanceListViewReader) - { - instanceListViewReader = new ListViewReader(); - } - return instanceListViewReader; - } - - void ListViewReader::setPropsFromJsonDictionary(ui::Widget *widget, const rapidjson::Value &options) - { - ScrollViewReader::setPropsFromJsonDictionary(widget, options); - - - ListView* listView = static_cast(widget); - - int direction = DICTOOL->getFloatValue_json(options, "direction"); - listView->setDirection((SCROLLVIEW_DIR)direction); - - ListViewGravity gravity = (ListViewGravity)DICTOOL->getIntValue_json(options, "gravity"); - listView->setGravity(gravity); - - float itemMargin = DICTOOL->getFloatValue_json(options, "itemMargin"); - listView->setItemsMargin(itemMargin); - } -} - diff --git a/cocos/ui/WidgetReader/ListViewReader/ListViewReader.h b/cocos/ui/WidgetReader/ListViewReader/ListViewReader.h deleted file mode 100644 index 6c10b2114b..0000000000 --- a/cocos/ui/WidgetReader/ListViewReader/ListViewReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__ListViewReader__ -#define __TestCpp__ListViewReader__ - -#include "../ScrollViewReader/ScrollViewReader.h" - -namespace cocostudio -{ - class ListViewReader : public ScrollViewReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - ListViewReader(); - virtual ~ListViewReader(); - - static ListViewReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__ListViewReader__) */ diff --git a/cocos/ui/WidgetReader/LoadingBarReader/LoadingBarReader.cpp b/cocos/ui/WidgetReader/LoadingBarReader/LoadingBarReader.cpp deleted file mode 100644 index 864e19a473..0000000000 --- a/cocos/ui/WidgetReader/LoadingBarReader/LoadingBarReader.cpp +++ /dev/null @@ -1,91 +0,0 @@ - - -#include "LoadingBarReader.h" -#include "ui/UILoadingBar.h" - -namespace cocostudio -{ - static LoadingBarReader* instanceLoadingBar = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(LoadingBarReader) - - LoadingBarReader::LoadingBarReader() - { - - } - - LoadingBarReader::~LoadingBarReader() - { - - } - - LoadingBarReader* LoadingBarReader::getInstance() - { - if (!instanceLoadingBar) - { - instanceLoadingBar = new LoadingBarReader(); - } - return instanceLoadingBar; - } - - void LoadingBarReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) - { - WidgetReader::setPropsFromJsonDictionary(widget, options); - - - std::string jsonPath = GUIReader::getInstance()->getFilePath(); - - LoadingBar* loadingBar = static_cast(widget); - - const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "textureData"); - int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileNameType) - { - case 0: - { - std::string tp_i = jsonPath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = nullptr; - if (imageFileName && (strcmp(imageFileName, "") != 0)) - { - imageFileName_tp = tp_i.append(imageFileName).c_str(); - loadingBar->loadTexture(imageFileName_tp); - } - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - /* gui mark add load bar scale9 parse */ - bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable"); - loadingBar->setScale9Enabled(scale9Enable); - - if (scale9Enable) - { - float cx = DICTOOL->getFloatValue_json(options, "capInsetsX"); - float cy = DICTOOL->getFloatValue_json(options, "capInsetsY"); - float cw = DICTOOL->getFloatValue_json(options, "capInsetsWidth"); - float ch = DICTOOL->getFloatValue_json(options, "capInsetsHeight"); - - loadingBar->setCapInsets(Rect(cx, cy, cw, ch)); - - float width = DICTOOL->getFloatValue_json(options, "width"); - float height = DICTOOL->getFloatValue_json(options, "height"); - loadingBar->setSize(Size(width, height)); - } - /**/ - - loadingBar->setDirection(LoadingBarType(DICTOOL->getIntValue_json(options, "direction"))); - loadingBar->setPercent(DICTOOL->getIntValue_json(options, "percent")); - - - WidgetReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/LoadingBarReader/LoadingBarReader.h b/cocos/ui/WidgetReader/LoadingBarReader/LoadingBarReader.h deleted file mode 100644 index 69d12e3f33..0000000000 --- a/cocos/ui/WidgetReader/LoadingBarReader/LoadingBarReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__LoadingBarReader__ -#define __TestCpp__LoadingBarReader__ - -#include "../WidgetReader.h" - -namespace cocostudio -{ - class LoadingBarReader : public WidgetReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - LoadingBarReader(); - virtual ~LoadingBarReader(); - - static LoadingBarReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__LoadingBarReader__) */ diff --git a/cocos/ui/WidgetReader/PageViewReader/PageViewReader.cpp b/cocos/ui/WidgetReader/PageViewReader/PageViewReader.cpp deleted file mode 100644 index c5692277e2..0000000000 --- a/cocos/ui/WidgetReader/PageViewReader/PageViewReader.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -#include "PageViewReader.h" -#include "ui/UIPageView.h" - -namespace cocostudio -{ - static PageViewReader* instancePageViewReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(PageViewReader) - - PageViewReader::PageViewReader() - { - - } - - PageViewReader::~PageViewReader() - { - - } - - PageViewReader* PageViewReader::getInstance() - { - if (!instancePageViewReader) - { - instancePageViewReader = new PageViewReader(); - } - return instancePageViewReader; - } - - void PageViewReader::setPropsFromJsonDictionary(ui::Widget *widget, const rapidjson::Value &options) - { - LayoutReader::setPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/PageViewReader/PageViewReader.h b/cocos/ui/WidgetReader/PageViewReader/PageViewReader.h deleted file mode 100644 index 07b7719565..0000000000 --- a/cocos/ui/WidgetReader/PageViewReader/PageViewReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__PageViewReader__ -#define __TestCpp__PageViewReader__ - -#include "../LayoutReader/LayoutReader.h" - -namespace cocostudio -{ - class PageViewReader : public LayoutReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - PageViewReader(); - virtual ~PageViewReader(); - - static PageViewReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(ui::Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__PageViewReader__) */ diff --git a/cocos/ui/WidgetReader/ScrollViewReader/ScrollViewReader.cpp b/cocos/ui/WidgetReader/ScrollViewReader/ScrollViewReader.cpp deleted file mode 100644 index a09480d8e1..0000000000 --- a/cocos/ui/WidgetReader/ScrollViewReader/ScrollViewReader.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -#include "ScrollViewReader.h" -#include "ui/UIScrollView.h" - -namespace cocostudio -{ - static ScrollViewReader* instanceScrollViewReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(ScrollViewReader) - - ScrollViewReader::ScrollViewReader() - { - - } - - ScrollViewReader::~ScrollViewReader() - { - - } - - ScrollViewReader* ScrollViewReader::getInstance() - { - if (!instanceScrollViewReader) - { - instanceScrollViewReader = new ScrollViewReader(); - } - return instanceScrollViewReader; - } - - void ScrollViewReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) - { - LayoutReader::setPropsFromJsonDictionary(widget, options); - - - ScrollView* scrollView = static_cast(widget); - float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); - float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight"); - scrollView->setInnerContainerSize(Size(innerWidth, innerHeight)); - int direction = DICTOOL->getFloatValue_json(options, "direction"); - scrollView->setDirection((SCROLLVIEW_DIR)direction); - scrollView->setBounceEnabled(DICTOOL->getBooleanValue_json(options, "bounceEnable")); - - - LayoutReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/ScrollViewReader/ScrollViewReader.h b/cocos/ui/WidgetReader/ScrollViewReader/ScrollViewReader.h deleted file mode 100644 index 429a2ad9fe..0000000000 --- a/cocos/ui/WidgetReader/ScrollViewReader/ScrollViewReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__ScrollViewReader__ -#define __TestCpp__ScrollViewReader__ - -#include "../LayoutReader/LayoutReader.h" - -namespace cocostudio -{ - class ScrollViewReader : public LayoutReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - ScrollViewReader(); - virtual ~ScrollViewReader(); - - static ScrollViewReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__ScrollViewReader__) */ diff --git a/cocos/ui/WidgetReader/SliderReader/SliderReader.cpp b/cocos/ui/WidgetReader/SliderReader/SliderReader.cpp deleted file mode 100644 index 9e290d28e3..0000000000 --- a/cocos/ui/WidgetReader/SliderReader/SliderReader.cpp +++ /dev/null @@ -1,192 +0,0 @@ - - -#include "SliderReader.h" -#include "ui/UISlider.h" - -namespace cocostudio -{ - static SliderReader* instanceSliderReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(SliderReader) - - SliderReader::SliderReader() - { - - } - - SliderReader::~SliderReader() - { - - } - - SliderReader* SliderReader::getInstance() - { - if (!instanceSliderReader) - { - instanceSliderReader = new SliderReader(); - } - return instanceSliderReader; - } - - void SliderReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) - { - WidgetReader::setPropsFromJsonDictionary(widget, options); - - - std::string jsonPath = GUIReader::getInstance()->getFilePath(); - - Slider* slider = static_cast(widget); - - bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "barTextureScale9Enable"); - slider->setScale9Enabled(barTextureScale9Enable); - bool bt = DICTOOL->checkObjectExist_json(options, "barFileName"); - float barLength = DICTOOL->getFloatValue_json(options, "length"); - if (bt) - { - if (barTextureScale9Enable) - { - - const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData"); - int imageFileType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileType) - { - case 0: - { - std::string tp_b = jsonPath; - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; - slider->loadBarTexture(imageFileName_tp); - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - slider->setSize(Size(barLength, slider->getContentSize().height)); - } - else - { - const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData"); - int imageFileType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType"); - switch (imageFileType) - { - case 0: - { - std::string tp_b = jsonPath; - const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; - slider->loadBarTexture(imageFileName_tp); - break; - } - case 1: - { - const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path"); - slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - } - } - - const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "ballNormalData"); - int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType"); - switch (normalType) - { - case 0: - { - std::string tp_n = jsonPath; - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr; - slider->loadSlidBallTextureNormal(normalFileName_tp); - break; - } - case 1: - { - const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path"); - slider->loadSlidBallTextureNormal(normalFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "ballPressedData"); - int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType"); - switch (pressedType) - { - case 0: - { - std::string tp_p = jsonPath; - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr; - slider->loadSlidBallTexturePressed(pressedFileName_tp); - break; - } - case 1: - { - const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path"); - slider->loadSlidBallTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "ballDisabledData"); - int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType"); - switch (disabledType) - { - case 0: - { - std::string tp_d = jsonPath; - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr; - slider->loadSlidBallTextureDisabled(disabledFileName_tp); - break; - } - case 1: - { - const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path"); - slider->loadSlidBallTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - slider->setPercent(DICTOOL->getIntValue_json(options, "percent")); - - const rapidjson::Value& progressBarDic = DICTOOL->getSubDictionary_json(options, "progressBarData"); - int progressBarType = DICTOOL->getIntValue_json(progressBarDic, "resourceType"); - switch (progressBarType) - { - case 0: - { - std::string tp_b = jsonPath; - const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path"); - const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr; - slider->loadProgressBarTexture(imageFileName_tp); - break; - } - case 1: - { - const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path"); - slider->loadProgressBarTexture(imageFileName,UI_TEX_TYPE_PLIST); - break; - } - default: - break; - } - - - WidgetReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/SliderReader/SliderReader.h b/cocos/ui/WidgetReader/SliderReader/SliderReader.h deleted file mode 100644 index 1fa0390c07..0000000000 --- a/cocos/ui/WidgetReader/SliderReader/SliderReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__SliderReader__ -#define __TestCpp__SliderReader__ - -#include "../WidgetReader.h" - -namespace cocostudio -{ - class SliderReader : public WidgetReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - SliderReader(); - virtual ~SliderReader(); - - static SliderReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__SliderReader__) */ diff --git a/cocos/ui/WidgetReader/TextAtlasReader/TextAtlasReader.cpp b/cocos/ui/WidgetReader/TextAtlasReader/TextAtlasReader.cpp deleted file mode 100644 index 9fd20de2f2..0000000000 --- a/cocos/ui/WidgetReader/TextAtlasReader/TextAtlasReader.cpp +++ /dev/null @@ -1,69 +0,0 @@ - - -#include "TextAtlasReader.h" -#include "ui/UITextAtlas.h" - -namespace cocostudio -{ - static TextAtlasReader* instanceTextAtalsReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(TextAtlasReader) - - TextAtlasReader::TextAtlasReader() - { - - } - - TextAtlasReader::~TextAtlasReader() - { - - } - - TextAtlasReader* TextAtlasReader::getInstance() - { - if (!instanceTextAtalsReader) - { - instanceTextAtalsReader = new TextAtlasReader(); - } - return instanceTextAtalsReader; - } - - void TextAtlasReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) - { - WidgetReader::setPropsFromJsonDictionary(widget, options); - - - std::string jsonPath = GUIReader::getInstance()->getFilePath(); - - TextAtlas* labelAtlas = static_cast(widget); - bool sv = DICTOOL->checkObjectExist_json(options, "stringValue"); - bool cmf = DICTOOL->checkObjectExist_json(options, "charMapFile"); - bool iw = DICTOOL->checkObjectExist_json(options, "itemWidth"); - bool ih = DICTOOL->checkObjectExist_json(options, "itemHeight"); - bool scm = DICTOOL->checkObjectExist_json(options, "startCharMap"); - if (sv && cmf && iw && ih && scm) - { - const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, "charMapFileData"); - int cmfType = DICTOOL->getIntValue_json(cmftDic, "resourceType"); - switch (cmfType) - { - case 0: - { - std::string tp_c = jsonPath; - const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, "path"); - const char* cmf_tp = tp_c.append(cmfPath).c_str(); - labelAtlas->setProperty(DICTOOL->getStringValue_json(options, "stringValue"),cmf_tp,DICTOOL->getIntValue_json(options, "itemWidth"),DICTOOL->getIntValue_json(options,"itemHeight"), DICTOOL->getStringValue_json(options, "startCharMap")); - break; - } - case 1: - CCLOG("Wrong res type of LabelAtlas!"); - break; - default: - break; - } - } - - - WidgetReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/TextAtlasReader/TextAtlasReader.h b/cocos/ui/WidgetReader/TextAtlasReader/TextAtlasReader.h deleted file mode 100644 index a065162769..0000000000 --- a/cocos/ui/WidgetReader/TextAtlasReader/TextAtlasReader.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__TextAtlasReader__ -#define __TestCpp__TextAtlasReader__ - -#include "../WidgetReader.h" - -namespace cocostudio -{ - class TextAtlasReader : public WidgetReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - TextAtlasReader(); - virtual ~TextAtlasReader(); - - static TextAtlasReader* getInstance(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__TextAtlasReader__) */ diff --git a/cocos/ui/WidgetReader/TextBMFontReader/TextBMFontReader.cpp b/cocos/ui/WidgetReader/TextBMFontReader/TextBMFontReader.cpp deleted file mode 100644 index daec7016a0..0000000000 --- a/cocos/ui/WidgetReader/TextBMFontReader/TextBMFontReader.cpp +++ /dev/null @@ -1,65 +0,0 @@ - - -#include "TextBMFontReader.h" -#include "ui/UITextBMFont.h" - -namespace cocostudio -{ - static TextBMFontReader* instanceTextBMFontReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(TextBMFontReader) - - TextBMFontReader::TextBMFontReader() - { - - } - - TextBMFontReader::~TextBMFontReader() - { - - } - - TextBMFontReader* TextBMFontReader::getInstance() - { - if (!instanceTextBMFontReader) - { - instanceTextBMFontReader = new TextBMFontReader(); - } - return instanceTextBMFontReader; - } - - void TextBMFontReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) - { - WidgetReader::setPropsFromJsonDictionary(widget, options); - - - std::string jsonPath = GUIReader::getInstance()->getFilePath(); - - TextBMFont* labelBMFont = static_cast(widget); - - const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); - int cmfType = DICTOOL->getIntValue_json(cmftDic, "resourceType"); - switch (cmfType) - { - case 0: - { - std::string tp_c = jsonPath; - const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, "path"); - const char* cmf_tp = tp_c.append(cmfPath).c_str(); - labelBMFont->setFntFile(cmf_tp); - break; - } - case 1: - CCLOG("Wrong res type of LabelAtlas!"); - break; - default: - break; - } - - const char* text = DICTOOL->getStringValue_json(options, "text"); - labelBMFont->setText(text); - - - WidgetReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/TextBMFontReader/TextBMFontReader.h b/cocos/ui/WidgetReader/TextBMFontReader/TextBMFontReader.h deleted file mode 100644 index bfba2f3cfc..0000000000 --- a/cocos/ui/WidgetReader/TextBMFontReader/TextBMFontReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__TextBMFontReader__ -#define __TestCpp__TextBMFontReader__ - -#include "../WidgetReader.h" - -namespace cocostudio -{ - class TextBMFontReader : public WidgetReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - TextBMFontReader(); - virtual ~TextBMFontReader(); - - static TextBMFontReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__TextBMFontReader__) */ diff --git a/cocos/ui/WidgetReader/TextFieldReader/TextFieldReader.cpp b/cocos/ui/WidgetReader/TextFieldReader/TextFieldReader.cpp deleted file mode 100644 index 0066e796fc..0000000000 --- a/cocos/ui/WidgetReader/TextFieldReader/TextFieldReader.cpp +++ /dev/null @@ -1,84 +0,0 @@ - - -#include "TextFieldReader.h" -#include "ui/UITextField.h" - -namespace cocostudio -{ - static TextFieldReader* instanceTextFieldReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(TextFieldReader) - - TextFieldReader::TextFieldReader() - { - - } - - TextFieldReader::~TextFieldReader() - { - - } - - TextFieldReader* TextFieldReader::getInstance() - { - if (!instanceTextFieldReader) - { - instanceTextFieldReader = new TextFieldReader(); - } - return instanceTextFieldReader; - } - - void TextFieldReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) - { - WidgetReader::setPropsFromJsonDictionary(widget, options); - - - TextField* textField = static_cast(widget); - bool ph = DICTOOL->checkObjectExist_json(options, "placeHolder"); - if (ph) - { - textField->setPlaceHolder(DICTOOL->getStringValue_json(options, "placeHolder")); - } - textField->setText(DICTOOL->getStringValue_json(options, "text")); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); - if (fs) - { - textField->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); - } - bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); - if (fn) - { - textField->setFontName(DICTOOL->getStringValue_json(options, "fontName")); - } - bool tsw = DICTOOL->checkObjectExist_json(options, "touchSizeWidth"); - bool tsh = DICTOOL->checkObjectExist_json(options, "touchSizeHeight"); - if (tsw && tsh) - { - textField->setTouchSize(Size(DICTOOL->getFloatValue_json(options, "touchSizeWidth"), DICTOOL->getFloatValue_json(options,"touchSizeHeight"))); - } - - float dw = DICTOOL->getFloatValue_json(options, "width"); - float dh = DICTOOL->getFloatValue_json(options, "height"); - if (dw > 0.0f || dh > 0.0f) - { - //textField->setSize(Size(dw, dh)); - } - bool maxLengthEnable = DICTOOL->getBooleanValue_json(options, "maxLengthEnable"); - textField->setMaxLengthEnabled(maxLengthEnable); - - if (maxLengthEnable) - { - int maxLength = DICTOOL->getIntValue_json(options, "maxLength"); - textField->setMaxLength(maxLength); - } - bool passwordEnable = DICTOOL->getBooleanValue_json(options, "passwordEnable"); - textField->setPasswordEnabled(passwordEnable); - if (passwordEnable) - { - textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, "passwordStyleText")); - } - - - WidgetReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/TextFieldReader/TextFieldReader.h b/cocos/ui/WidgetReader/TextFieldReader/TextFieldReader.h deleted file mode 100644 index 30d467787a..0000000000 --- a/cocos/ui/WidgetReader/TextFieldReader/TextFieldReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__TextFieldReader__ -#define __TestCpp__TextFieldReader__ - -#include "../WidgetReader.h" - -namespace cocostudio -{ - class TextFieldReader : public WidgetReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - TextFieldReader(); - virtual ~TextFieldReader(); - - static TextFieldReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__TextFieldReader__) */ diff --git a/cocos/ui/WidgetReader/TextReader/TextReader.cpp b/cocos/ui/WidgetReader/TextReader/TextReader.cpp deleted file mode 100644 index 5910122767..0000000000 --- a/cocos/ui/WidgetReader/TextReader/TextReader.cpp +++ /dev/null @@ -1,74 +0,0 @@ - - -#include "TextReader.h" -#include "ui/UIText.h" - -namespace cocostudio -{ - static TextReader* instanceTextReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(TextReader) - - TextReader::TextReader() - { - - } - - TextReader::~TextReader() - { - - } - - TextReader* TextReader::getInstance() - { - if (!instanceTextReader) - { - instanceTextReader = new TextReader(); - } - return instanceTextReader; - } - - void TextReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options) - { - WidgetReader::setPropsFromJsonDictionary(widget, options); - - - std::string jsonPath = GUIReader::getInstance()->getFilePath(); - - Text* label = static_cast(widget); - bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable"); - label->setTouchScaleChangeEnabled(touchScaleChangeAble); - const char* text = DICTOOL->getStringValue_json(options, "text"); - label->setText(text); - bool fs = DICTOOL->checkObjectExist_json(options, "fontSize"); - if (fs) - { - label->setFontSize(DICTOOL->getIntValue_json(options, "fontSize")); - } - bool fn = DICTOOL->checkObjectExist_json(options, "fontName"); - if (fn) - { - label->setFontName(DICTOOL->getStringValue_json(options, "fontName")); - } - bool aw = DICTOOL->checkObjectExist_json(options, "areaWidth"); - bool ah = DICTOOL->checkObjectExist_json(options, "areaHeight"); - if (aw && ah) - { - Size size = Size(DICTOOL->getFloatValue_json(options, "areaWidth"),DICTOOL->getFloatValue_json(options,"areaHeight")); - label->setTextAreaSize(size); - } - bool ha = DICTOOL->checkObjectExist_json(options, "hAlignment"); - if (ha) - { - label->setTextHorizontalAlignment((TextHAlignment)DICTOOL->getIntValue_json(options, "hAlignment")); - } - bool va = DICTOOL->checkObjectExist_json(options, "vAlignment"); - if (va) - { - label->setTextVerticalAlignment((TextVAlignment)DICTOOL->getIntValue_json(options, "vAlignment")); - } - - - WidgetReader::setColorPropsFromJsonDictionary(widget, options); - } -} diff --git a/cocos/ui/WidgetReader/TextReader/TextReader.h b/cocos/ui/WidgetReader/TextReader/TextReader.h deleted file mode 100644 index 18d15e6323..0000000000 --- a/cocos/ui/WidgetReader/TextReader/TextReader.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__TextReader__ -#define __TestCpp__TextReader__ - -#include "../WidgetReader.h" - -namespace cocostudio -{ - class TextReader : public WidgetReader - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - TextReader(); - virtual ~TextReader(); - - static TextReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__TextReader__) */ diff --git a/cocos/ui/WidgetReader/WidgetReader.cpp b/cocos/ui/WidgetReader/WidgetReader.cpp deleted file mode 100644 index 29570ecff3..0000000000 --- a/cocos/ui/WidgetReader/WidgetReader.cpp +++ /dev/null @@ -1,173 +0,0 @@ - - -#include "WidgetReader.h" - -namespace cocostudio -{ - using namespace cocos2d::ui; - static WidgetReader* instanceWidgetReader = NULL; - - IMPLEMENT_CLASS_WIDGET_READER_INFO(WidgetReader) - - WidgetReader::WidgetReader() - { - - } - - WidgetReader::~WidgetReader() - { - - } - - WidgetReader* WidgetReader::getInstance() - { - if (!instanceWidgetReader) - { - instanceWidgetReader = new WidgetReader(); - } - return instanceWidgetReader; - } - - void WidgetReader::purge() - { - CC_SAFE_DELETE(instanceWidgetReader); - } - - void WidgetReader::setPropsFromJsonDictionary(cocos2d::ui::Widget *widget, const rapidjson::Value &options) - { - bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, "ignoreSize"); - if (ignoreSizeExsit) - { - widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, "ignoreSize")); - } - - widget->setSizeType((SizeType)DICTOOL->getIntValue_json(options, "sizeType")); - widget->setPositionType((PositionType)DICTOOL->getIntValue_json(options, "positionType")); - - widget->setSizePercent(Point(DICTOOL->getFloatValue_json(options, "sizePercentX"), DICTOOL->getFloatValue_json(options, "sizePercentY"))); - widget->setPositionPercent(Point(DICTOOL->getFloatValue_json(options, "positionPercentX"), DICTOOL->getFloatValue_json(options, "positionPercentY"))); - - /* adapt screen */ - float w = 0, h = 0; - bool adaptScrenn = DICTOOL->getBooleanValue_json(options, "adaptScreen"); - if (adaptScrenn) - { - Size screenSize = CCDirector::getInstance()->getWinSize(); - w = screenSize.width; - h = screenSize.height; - } - else - { - w = DICTOOL->getFloatValue_json(options, "width"); - h = DICTOOL->getFloatValue_json(options, "height"); - } - widget->setSize(Size(w, h)); - // before - /* - float w = DICTOOL->getFloatValue_json(options, "width"); - float h = DICTOOL->getFloatValue_json(options, "height"); - widget->setSize(CCSizeMake(w, h)); - */ - /**/ - - widget->setTag(DICTOOL->getIntValue_json(options, "tag")); - widget->setActionTag(DICTOOL->getIntValue_json(options, "actiontag")); - widget->setTouchEnabled(DICTOOL->getBooleanValue_json(options, "touchAble")); - const char* name = DICTOOL->getStringValue_json(options, "name"); - const char* widgetName = name?name:"default"; - widget->setName(widgetName); - float x = DICTOOL->getFloatValue_json(options, "x"); - float y = DICTOOL->getFloatValue_json(options, "y"); - widget->setPosition(Point(x,y)); - bool sx = DICTOOL->checkObjectExist_json(options, "scaleX"); - if (sx) - { - widget->setScaleX(DICTOOL->getFloatValue_json(options, "scaleX")); - } - bool sy = DICTOOL->checkObjectExist_json(options, "scaleY"); - if (sy) - { - widget->setScaleY(DICTOOL->getFloatValue_json(options, "scaleY")); - } - bool rt = DICTOOL->checkObjectExist_json(options, "rotation"); - if (rt) - { - widget->setRotation(DICTOOL->getFloatValue_json(options, "rotation")); - } - bool vb = DICTOOL->checkObjectExist_json(options, "visible"); - if (vb) - { - widget->setVisible(DICTOOL->getBooleanValue_json(options, "visible")); - } - int z = DICTOOL->getIntValue_json(options, "ZOrder"); - widget->setLocalZOrder(z); - - bool layout = DICTOOL->checkObjectExist_json(options, "layoutParameter"); - if (layout) - { - const rapidjson::Value& layoutParameterDic = DICTOOL->getSubDictionary_json(options, "layoutParameter"); - int paramType = DICTOOL->getIntValue_json(layoutParameterDic, "type"); - LayoutParameter* parameter = nullptr; - switch (paramType) - { - case 0: - break; - case 1: - { - parameter = LinearLayoutParameter::create(); - int gravity = DICTOOL->getIntValue_json(layoutParameterDic, "gravity"); - ((LinearLayoutParameter*)parameter)->setGravity((LinearGravity)gravity); - break; - } - case 2: - { - parameter = RelativeLayoutParameter::create(); - RelativeLayoutParameter* rParameter = (RelativeLayoutParameter*)parameter; - const char* relativeName = DICTOOL->getStringValue_json(layoutParameterDic, "relativeName"); - rParameter->setRelativeName(relativeName); - const char* relativeToName = DICTOOL->getStringValue_json(layoutParameterDic, "relativeToName"); - rParameter->setRelativeToWidgetName(relativeToName); - int align = DICTOOL->getIntValue_json(layoutParameterDic, "align"); - rParameter->setAlign((RelativeAlign)align); - break; - } - default: - break; - } - if (parameter) - { - float mgl = DICTOOL->getFloatValue_json(layoutParameterDic, "marginLeft"); - float mgt = DICTOOL->getFloatValue_json(layoutParameterDic, "marginTop"); - float mgr = DICTOOL->getFloatValue_json(layoutParameterDic, "marginRight"); - float mgb = DICTOOL->getFloatValue_json(layoutParameterDic, "marginDown"); - parameter->setMargin(Margin(mgl, mgt, mgr, mgb)); - widget->setLayoutParameter(parameter); - } - } - } - - void WidgetReader::setColorPropsFromJsonDictionary(ui::Widget *widget, const rapidjson::Value &options) - { - bool op = DICTOOL->checkObjectExist_json(options, "opacity"); - if (op) - { - widget->setOpacity(DICTOOL->getIntValue_json(options, "opacity")); - } - bool cr = DICTOOL->checkObjectExist_json(options, "colorR"); - bool cg = DICTOOL->checkObjectExist_json(options, "colorG"); - bool cb = DICTOOL->checkObjectExist_json(options, "colorB"); - int colorR = cr ? DICTOOL->getIntValue_json(options, "colorR") : 255; - int colorG = cg ? DICTOOL->getIntValue_json(options, "colorG") : 255; - int colorB = cb ? DICTOOL->getIntValue_json(options, "colorB") : 255; - widget->setColor(Color3B(colorR, colorG, colorB)); - bool apx = DICTOOL->checkObjectExist_json(options, "anchorPointX"); - float apxf = apx ? DICTOOL->getFloatValue_json(options, "anchorPointX") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); - bool apy = DICTOOL->checkObjectExist_json(options, "anchorPointY"); - float apyf = apy ? DICTOOL->getFloatValue_json(options, "anchorPointY") : ((widget->getWidgetType() == WidgetTypeWidget) ? 0.5f : 0.0f); - widget->setAnchorPoint(Point(apxf, apyf)); - bool flipX = DICTOOL->getBooleanValue_json(options, "flipX"); - bool flipY = DICTOOL->getBooleanValue_json(options, "flipY"); - widget->setFlipX(flipX); - widget->setFlipY(flipY); - } -} diff --git a/cocos/ui/WidgetReader/WidgetReader.h b/cocos/ui/WidgetReader/WidgetReader.h deleted file mode 100644 index 7e10cfd8ef..0000000000 --- a/cocos/ui/WidgetReader/WidgetReader.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__WidgetReader__ -#define __TestCpp__WidgetReader__ - -#include "WidgetReaderProtocol.h" -#include "CCSGUIReader.h" -#include "ui/GUIDefine.h" -#include "ui/UIWidget.h" - -namespace cocostudio -{ - class WidgetReader : public Object, public WidgetReaderProtocol - { - public: - DECLARE_CLASS_WIDGET_READER_INFO - - WidgetReader(); - virtual ~WidgetReader(); - - static WidgetReader* getInstance(); - static void purge(); - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - virtual void setColorPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options); - }; -} - -#endif /* defined(__TestCpp__WidgetReader__) */ diff --git a/cocos/ui/WidgetReader/WidgetReaderProtocol.h b/cocos/ui/WidgetReader/WidgetReaderProtocol.h deleted file mode 100644 index 574262743a..0000000000 --- a/cocos/ui/WidgetReader/WidgetReaderProtocol.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** - Copyright (c) 2014 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__WidgetReaderProtocol__ -#define __TestCpp__WidgetReaderProtocol__ - -#include "cocos2d.h" -#include "cocostudio/DictionaryHelper.h" - -namespace cocos2d -{ - namespace ui - { - class Widget; - } -} - -USING_NS_CC; -using namespace cocos2d::ui; - -namespace cocostudio -{ - class WidgetReaderProtocol - { - public: - virtual ~WidgetReaderProtocol() {}; - - virtual void setPropsFromJsonDictionary(Widget* widget, const rapidjson::Value& options) = 0; - }; -} - -#endif /* defined(__TestCpp__WidgetReaderProtocol__) */ diff --git a/tests/cpp-tests/Resources/hd/cocosgui/Hello.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/Hello.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/Hello.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/Hello.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIButton_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIButton_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIButton_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIButton_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UICheckBox_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UICheckBox_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UICheckBox_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UICheckBox_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIImageView_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIImageView_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIImageView_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIImageView_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILabelAtlas_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILabelAtlas_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILabelAtlas_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILabelAtlas_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILabelBMFont_Editor/GUI/missing-font.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILabelBMFont_Editor/GUI/missing-font.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILabelBMFont_Editor/GUI/missing-font.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILabelBMFont_Editor/GUI/missing-font.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILabelBMFont_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILabelBMFont_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILabelBMFont_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILabelBMFont_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILabel_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILabel_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILabel_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILabel_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/Hello.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/Hello.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/Hello.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/Hello.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILoadingBar_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILoadingBar_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UILoadingBar_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UILoadingBar_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIPageView_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIPageView_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIPageView_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIPageView_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UISlider_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UISlider_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UISlider_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UISlider_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UITextField_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UITextField_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UITextField_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UITextField_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIWidgetAddNode_Editor/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIWidgetAddNode_Editor/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UIEditorTest/UIWidgetAddNode_Editor/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UIEditorTest/UIWidgetAddNode_Editor/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/UITest/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/UITest/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/UITest/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/UITest/background.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/b11.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/b11.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/b11.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/b11.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/bitmapFontTest2.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/bitmapFontTest2.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/bitmapFontTest2.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/bitmapFontTest2.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/examples/examples.json.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/examples/examples.json.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/examples/examples.json.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/examples/examples.json.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/gui_examples/map_1/map_pve.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/gui_examples/map_1/map_pve.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/gui_examples/map_1/map_pve.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/gui_examples/map_1/map_pve.png.REMOVED.git-id diff --git a/tests/cpp-tests/Resources/hd/cocosgui/gui_examples/page_1/background.png.REMOVED.git-id b/tests/cpp-tests/Resources/hd/cocosui/gui_examples/page_1/background.png.REMOVED.git-id similarity index 100% rename from tests/cpp-tests/Resources/hd/cocosgui/gui_examples/page_1/background.png.REMOVED.git-id rename to tests/cpp-tests/Resources/hd/cocosui/gui_examples/page_1/background.png.REMOVED.git-id From a567d467b3e89d461c3c233dd55f4c1ef5a07594 Mon Sep 17 00:00:00 2001 From: dingpinglv Date: Thu, 13 Mar 2014 10:14:24 +0800 Subject: [PATCH 32/35] Issue #4277: fixed a bug of ControlButton that it will crash when it deletes itself in its callback. --- extensions/GUI/CCControlExtension/CCControl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extensions/GUI/CCControlExtension/CCControl.cpp b/extensions/GUI/CCControlExtension/CCControl.cpp index 04cd0219d0..94bbec65ab 100644 --- a/extensions/GUI/CCControlExtension/CCControl.cpp +++ b/extensions/GUI/CCControlExtension/CCControl.cpp @@ -102,6 +102,7 @@ Control::~Control() void Control::sendActionsForControlEvents(EventType controlEvents) { + retain(); // For each control events for (int i = 0; i < kControlEventTotalNumber; i++) { @@ -126,6 +127,7 @@ void Control::sendActionsForControlEvents(EventType controlEvents) #endif } } + release(); } void Control::addTargetWithActionForControlEvents(Ref* target, Handler action, EventType controlEvents) { From c26b103b2351a0dceb2998be11d242b350ee9eb0 Mon Sep 17 00:00:00 2001 From: heliclei Date: Thu, 13 Mar 2014 10:45:02 +0800 Subject: [PATCH 33/35] remove node name related features from v3.0 --- cocos/2d/CCNode.cpp | 49 --------------- cocos/2d/CCNode.h | 51 +--------------- tests/cpp-tests/Classes/NodeTest/NodeTest.cpp | 59 ------------------- tests/cpp-tests/Classes/NodeTest/NodeTest.h | 8 --- 4 files changed, 1 insertion(+), 166 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index b2a7856289..9125d50393 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -598,17 +598,6 @@ void Node::setTag(int var) _tag = var; } -//name getter -std::string& Node::getName() -{ - return _name; -} - -//name setter -void Node::setName(const std::string& name) -{ - _name = name; -} /// userData setter void Node::setUserData(void *var) { @@ -713,44 +702,6 @@ Node* Node::getChildByTag(int tag) return nullptr; } -Node* Node::getChildByName(const std::string& name) -{ - for (auto& child : _children) - { - - if(child->_name == name) - { - return child; - } - - auto found = child->getChildByName(name); - if(found != nullptr) - { - return found; - } - } - return nullptr; -} - -void Node::enumerateChildrenByName(const std::string& name, const std::function& callback) -{ - for (auto& child : _children) - { - - if(child->_name == name) - { - bool stop = false; - callback(child, &stop); - if(stop == true) - { - return; - } - } - child->enumerateChildrenByName(name, callback); - } - return; -} - /* "add" logic MUST only be on this method * If a class want's to extend the 'addChild' behavior it only needs * to override this method diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 0ae342f34d..a6ea4ed04d 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -645,15 +645,6 @@ public: * @return a Node object whose tag equals to the input parameter */ virtual Node * getChildByTag(int tag); - - /** - * get a child node with its name, will recursively search the whole node tree - * - * @param name A string identifier to find the child node. - * - * @return the first Node object whose name equals to the input parameter - */ - virtual Node* getChildByName(const std::string& name); /** * Returns the array of the node's children * @@ -768,47 +759,7 @@ public: */ virtual void setTag(int tag); - /// @{ - /// @name name - - /** - * Returns a name that is used to identify the node easily. - * - * You can set name to node then identify them easily. - @code - - // set name - node1->setName("player"); - node2->setName("monster"); - node3->setName("boss"); - parent->addChild(node1); - parent->addChild(node2); - parent->addChild(node3); - // identify by name - Node* player = nullptr; - player = parent->getChildByName("player") - @endcode - * - * @return A string that identifies the node. - */ - virtual std::string& getName(); - /** - * Changes the name that is used to identify the node easily. - * - * Please refer to getName for the sample code. - * - * @param name A string that indentifies the node. - */ - virtual void setName(const std::string& name); - /** - * Search the children to perform processing for nodes which share a name. - * Note: this function will search the whole node tree recursively. - * @param name the name to search for - * @param callback, A callback to execute on nodes that match the name parameter. The callback takes the following arguments: - * node: A node that matches the name. - * stop: A pointer to a Boolean variable. Your callback can set this to true to terminate the enumeration. - */ - virtual void enumerateChildrenByName(const std::string& name, const std::function& callback); + /** * Returns a custom user data pointer * diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp index 0038b3db43..b3b58bac47 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.cpp @@ -57,7 +57,6 @@ static std::function createFunctions[] = CL(Test4), CL(Test5), CL(Test6), - CL(NodeEnumChildByNameTest), CL(StressTest1), CL(StressTest2), CL(NodeToWorld), @@ -353,64 +352,6 @@ std::string Test6::subtitle() const return "remove/cleanup with children"; } -//------------------------------------------------------------------ -// -// NodeEnumChildByNameTest -// -//------------------------------------------------------------------ -void NodeEnumChildByNameTest::onEnter() -{ - TestCocosNodeDemo::onEnter(); - auto sp10 = Sprite::create(s_pathSister1); - auto sp11 = Sprite::create(s_pathSister1); - auto sp12 = Sprite::create(s_pathSister1); - auto sp20 = Sprite::create(s_pathSister2); - auto sp21 = Sprite::create(s_pathSister2); - auto sp22 = Sprite::create(s_pathSister2); - - sp10->setPosition(Point(100,60)); - sp11->setPosition(Point(100,160)); - sp12->setPosition(Point(100,260)); - sp20->setPosition(Point(380,60)); - sp21->setPosition(Point(380,160)); - sp22->setPosition(Point(380,260)); - - sp10->setName("sister1"); - sp11->setName("sister1"); - sp12->setName("sister1"); - sp20->setName("sister2"); - sp21->setName("sister2"); - sp22->setName("sister2"); - - addChild(sp10); - addChild(sp11); - addChild(sp12); - addChild(sp20); - addChild(sp21); - addChild(sp22); - - enumerateChildrenByName("sister1", - [](Node* node, bool* stop) - { - auto rot = RotateBy::create(2, 360); - auto rot_back = rot->reverse(); - auto forever1 = RepeatForever::create(Sequence::create(rot, rot_back, NULL)); - node->runAction(forever1); - }); - enumerateChildrenByName("sister2", - [](Node* node, bool* stop) - { - auto actionUp = JumpBy::create(2, Point(0,0), 80, 4); - auto forever2 = RepeatForever::create(Sequence::create(actionUp, NULL)); - node->runAction(forever2); - }); -} - - -std::string NodeEnumChildByNameTest::subtitle() const -{ - return "Enum child nodes by name"; -} //------------------------------------------------------------------ // diff --git a/tests/cpp-tests/Classes/NodeTest/NodeTest.h b/tests/cpp-tests/Classes/NodeTest/NodeTest.h index 9506fd6181..5938eb9a4f 100644 --- a/tests/cpp-tests/Classes/NodeTest/NodeTest.h +++ b/tests/cpp-tests/Classes/NodeTest/NodeTest.h @@ -263,14 +263,6 @@ protected: Sprite *_sprite; }; -class NodeEnumChildByNameTest : public TestCocosNodeDemo -{ -public: - CREATE_FUNC(NodeEnumChildByNameTest); - virtual void onEnter() override; - virtual std::string subtitle() const override; -}; - class CocosNodeTestScene : public TestScene { public: From 2da4b7f37512bdc3729d5aa04d7fcf42385ea249 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 13 Mar 2014 10:52:47 +0800 Subject: [PATCH 34/35] Update CHANGELOG [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index e071d04655..bc32718262 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -2ba216b4ae56fa741405d81c01614f325fc19874 \ No newline at end of file +89b662adad809bb82801b21aef538a38f04e4bd7 \ No newline at end of file From 5f376e0b5bcb8a66e20b17f41f54846dc092575c Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 13 Mar 2014 11:10:53 +0800 Subject: [PATCH 35/35] Update CHANGELOG [ci skip] --- CHANGELOG.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.REMOVED.git-id b/CHANGELOG.REMOVED.git-id index bc32718262..b224457f2d 100644 --- a/CHANGELOG.REMOVED.git-id +++ b/CHANGELOG.REMOVED.git-id @@ -1 +1 @@ -89b662adad809bb82801b21aef538a38f04e4bd7 \ No newline at end of file +b8bc5839895bfc413816baa425d43a2b8e48205d \ No newline at end of file