From 3206727b9c9be8de0484910268c9d9c08b2d921f Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 26 Dec 2013 17:01:31 +0800 Subject: [PATCH 01/14] Modify actionnode --- cocos/editor-support/cocostudio/CCActionNode.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index 6074480b39..3b7da60ae4 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -151,10 +151,6 @@ void ActionNode::initActionNodeFromRoot(Object* root) { Node* rootNode = dynamic_cast(root); if (rootNode != NULL) - { - log("Need a definition of for gameObject"); - } - else { Widget* rootWidget = dynamic_cast(root); if (rootWidget != NULL) @@ -165,7 +161,7 @@ void ActionNode::initActionNodeFromRoot(Object* root) setObject(widget); } } - } + } } void ActionNode::setUnitTime(float fTime) From ad535e2fcbde0cbe899964fd6b4088a7affc48b0 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 26 Dec 2013 17:53:22 +0800 Subject: [PATCH 02/14] Add listview and pageview reader --- .../cocostudio/CCSGUIReader.cpp | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index bec3ea845c..091c3a674f 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -619,7 +619,7 @@ void WidgetPropertiesReader0250::setPropsForLabelAtlasFromJsonDictionary(Widget* const char* cmft = dicHelper->getStringValue_json(options, "charMapFile"); cmf_tp = tp_c.append(cmft).c_str(); - labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth"),dicHelper->getIntValue_json(options,"itemHeight"),dicHelper->getStringValue_json(options, "startCharMap")); + labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth") / CC_CONTENT_SCALE_FACTOR() ,dicHelper->getIntValue_json(options,"itemHeight") / CC_CONTENT_SCALE_FACTOR(), dicHelper->getStringValue_json(options, "startCharMap")); } setColorPropsForWidgetFromJsonDictionary(widget,options); } @@ -1025,7 +1025,18 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *dat Widget* child = widgetFromJsonDictionary(subData); if (child) { - widget->addChild(child); + if (dynamic_cast(widget)) + { + dynamic_cast(widget)->addPage(static_cast(child)); + } + else if (dynamic_cast(widget)) + { + dynamic_cast(widget)->pushBackCustomItem(child); + } + else + { + widget->addChild(child); + } } CC_SAFE_DELETE(subData); } @@ -1525,7 +1536,7 @@ void WidgetPropertiesReader0300::setPropsForLabelAtlasFromJsonDictionary(Widget* std::string tp_c = m_strFilePath; const char* cmfPath = dicHelper->getStringValue_json(cmftDic, "path"); const char* cmf_tp = tp_c.append(cmfPath).c_str(); - labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth"),dicHelper->getIntValue_json(options,"itemHeight"),dicHelper->getStringValue_json(options, "startCharMap")); + labelAtlas->setProperty(dicHelper->getStringValue_json(options, "stringValue"),cmf_tp,dicHelper->getIntValue_json(options, "itemWidth") / CC_CONTENT_SCALE_FACTOR(),dicHelper->getIntValue_json(options,"itemHeight") / CC_CONTENT_SCALE_FACTOR(), dicHelper->getStringValue_json(options, "startCharMap")); break; } case 1: @@ -1931,11 +1942,26 @@ void WidgetPropertiesReader0300::setPropsForLabelBMFontFromJsonDictionary(Widget void WidgetPropertiesReader0300::setPropsForPageViewFromJsonDictionary(Widget*widget,JsonDictionary* options) { - + setPropsForLayoutFromJsonDictionary(widget, options); } void WidgetPropertiesReader0300::setPropsForListViewFromJsonDictionary(Widget* widget, JsonDictionary* options) { + setPropsForLayoutFromJsonDictionary(widget, options); + ListView* listView = (ListView*)widget; + + float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); + float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight"); + listView->setInnerContainerSize(Size(innerWidth, innerHeight)); + int direction = DICTOOL->getFloatValue_json(options, "direction"); + listView->setDirection((SCROLLVIEW_DIR)direction); + + ListViewGravity gravity = (ListViewGravity)DICTOOL->getIntValue_json(options, "gravity"); + listView->setGravity(gravity); + + float itemMargin = DICTOOL->getFloatValue_json(options, "itemMargin"); + listView->setItemsMargin(itemMargin); } + } \ No newline at end of file From 902490c79a88475b82e60f05813f26bb8d8d6598 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Dec 2013 04:07:15 -0800 Subject: [PATCH 03/14] Generates execute file in cocos root_dir/bin folder for HelloCpp. --- samples/Cpp/HelloCpp/CMakeLists.txt | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/samples/Cpp/HelloCpp/CMakeLists.txt b/samples/Cpp/HelloCpp/CMakeLists.txt index cb9c3f0fd1..f5af51def4 100644 --- a/samples/Cpp/HelloCpp/CMakeLists.txt +++ b/samples/Cpp/HelloCpp/CMakeLists.txt @@ -41,13 +41,11 @@ add_executable(${APP_NAME} ${SAMPLE_SRC} ) -#get our resources -add_custom_command(TARGET ${APP_NAME} PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${CMAKE_CURRENT_BINARY_DIR}) - if(WIN32 AND MSVC) - + #get our resources + add_custom_command(TARGET ${APP_NAME} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${CMAKE_CURRENT_BINARY_DIR}) #get our dlls add_custom_command(TARGET ${APP_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy @@ -62,6 +60,16 @@ if(WIN32 AND MSVC) #Visual Studio Defaults to wrong type set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") +else() + set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}") + + set_target_properties(${APP_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") + + pre_build(${APP_NAME} + COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources + ) endif() target_link_libraries(${APP_NAME} audio cocos2d) From 93ed5a4f0f209f0253d27a4b07d79098dcd00957 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Dec 2013 04:07:36 -0800 Subject: [PATCH 04/14] long --> ssize_t for TableView callback. --- .../bindings/extension/jsb_cocos2dx_extension_manual.cpp | 6 +++--- .../lua/bindings/lua_cocos2dx_extension_manual.cpp | 8 ++++---- extensions/GUI/CCScrollView/CCTableView.h | 2 +- .../ExtensionsTest/TableViewTest/TableViewTestScene.cpp | 2 +- .../ExtensionsTest/TableViewTest/TableViewTestScene.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp index 2371ebbad6..6deed71add 100644 --- a/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp @@ -288,15 +288,15 @@ public: return NULL; } - virtual long numberOfCellsInTableView(TableView *table) + virtual ssize_t numberOfCellsInTableView(TableView *table) { jsval ret; bool ok = callJSDelegate(table, "numberOfCellsInTableView", ret); if (ok) { JSContext* cx = ScriptingCore::getInstance()->getGlobalContext(); - long count = 0; - JSBool isSucceed = jsval_to_long(cx, ret, &count); + ssize_t count = 0; + JSBool isSucceed = jsval_to_ssize(cx, ret, &count); if (isSucceed) return count; } return 0; diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp index fd58ccd5ba..f0136d44bf 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp @@ -1026,7 +1026,7 @@ public: LUA_TableViewDataSource(){} virtual ~LUA_TableViewDataSource(){} - virtual Size tableCellSizeForIndex(TableView *table, long idx) + virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) { if (nullptr != table ) { @@ -1052,7 +1052,7 @@ public: return Size::ZERO; } - virtual TableViewCell* tableCellAtIndex(TableView *table, long idx) + virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) { if (nullptr != table ) { @@ -1078,7 +1078,7 @@ public: return NULL; } - virtual long numberOfCellsInTableView(TableView *table) + virtual ssize_t numberOfCellsInTableView(TableView *table) { if (nullptr != table ) { @@ -1094,7 +1094,7 @@ public: Double* numbers = dynamic_cast(resultArray.getObjectAtIndex(0)); if (NULL != numbers) { - return (long)numbers->getValue(); + return (ssize_t)numbers->getValue(); } } } diff --git a/extensions/GUI/CCScrollView/CCTableView.h b/extensions/GUI/CCScrollView/CCTableView.h index c01b3eb4a2..649fc19175 100644 --- a/extensions/GUI/CCScrollView/CCTableView.h +++ b/extensions/GUI/CCScrollView/CCTableView.h @@ -129,7 +129,7 @@ public: * * @return number of cells */ - virtual long numberOfCellsInTableView(TableView *table) = 0; + virtual ssize_t numberOfCellsInTableView(TableView *table) = 0; }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp index 24e3fb34d0..917225c14b 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp @@ -96,7 +96,7 @@ TableViewCell* TableViewTestLayer::tableCellAtIndex(TableView *table, ssize_t id return cell; } -long TableViewTestLayer::numberOfCellsInTableView(TableView *table) +ssize_t TableViewTestLayer::numberOfCellsInTableView(TableView *table) { return 20; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.h index fa4f8e6b05..fb406ef91d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/TableViewTestScene.h @@ -20,7 +20,7 @@ public: virtual void tableCellTouched(cocos2d::extension::TableView* table, cocos2d::extension::TableViewCell* cell); virtual cocos2d::Size tableCellSizeForIndex(cocos2d::extension::TableView *table, ssize_t idx); virtual cocos2d::extension::TableViewCell* tableCellAtIndex(cocos2d::extension::TableView *table, ssize_t idx); - virtual long numberOfCellsInTableView(cocos2d::extension::TableView *table); + virtual ssize_t numberOfCellsInTableView(cocos2d::extension::TableView *table); }; #endif // __TABLEVIEWTESTSCENE_H__ From 26a7f3474c837c35d493af502b867481131a4e98 Mon Sep 17 00:00:00 2001 From: CaiWenzhi Date: Thu, 26 Dec 2013 21:02:47 +0800 Subject: [PATCH 05/14] Modify reader --- .../cocostudio/CCSGUIReader.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index 091c3a674f..ef913c9c12 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1025,17 +1025,22 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(JsonDictionary *dat Widget* child = widgetFromJsonDictionary(subData); if (child) { - if (dynamic_cast(widget)) + PageView* pageView = dynamic_cast(widget); + if (pageView) { - dynamic_cast(widget)->addPage(static_cast(child)); - } - else if (dynamic_cast(widget)) - { - dynamic_cast(widget)->pushBackCustomItem(child); + pageView->addPage(static_cast(child)); } else { - widget->addChild(child); + ListView* listView = dynamic_cast(widget); + if (listView) + { + listView->pushBackCustomItem(child); + } + else + { + widget->addChild(child); + } } } CC_SAFE_DELETE(subData); @@ -1949,7 +1954,7 @@ void WidgetPropertiesReader0300::setPropsForListViewFromJsonDictionary(Widget* w { setPropsForLayoutFromJsonDictionary(widget, options); - ListView* listView = (ListView*)widget; + ListView* listView = static_cast(widget); float innerWidth = DICTOOL->getFloatValue_json(options, "innerWidth"); float innerHeight = DICTOOL->getFloatValue_json(options, "innerHeight"); From a8d93ddf7242ada8f6e4bb5675c084435717d6a6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Dec 2013 21:49:40 +0800 Subject: [PATCH 06/14] Restricts the element type for Vector and Map, it has to be `Object*` or `ObjectSubClass*`. --- cocos/base/CCMap.h | 6 +++++- cocos/base/CCVector.h | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cocos/base/CCMap.h b/cocos/base/CCMap.h index 627d723940..e9e2eb1e37 100644 --- a/cocos/base/CCMap.h +++ b/cocos/base/CCMap.h @@ -26,7 +26,7 @@ #define __CCMAP_H__ #include "ccMacros.h" - +#include "CCObject.h" #include #include @@ -62,6 +62,7 @@ public: Map() : _data() { + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the default constructor of Map!"); } @@ -69,6 +70,7 @@ public: explicit Map(ssize_t capacity) : _data() { + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the constructor with capacity of Map!"); _data.reserve(capacity); } @@ -76,6 +78,7 @@ public: /** Copy constructor */ Map(const Map& other) { + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the copy constructor of Map!"); _data = other._data; addRefForAllObjects(); @@ -84,6 +87,7 @@ public: /** Move constructor */ Map(Map&& other) { + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Map!"); CCLOGINFO("In the move constructor of Map!"); _data = std::move(other._data); } diff --git a/cocos/base/CCVector.h b/cocos/base/CCVector.h index a575001243..5fd07e4dc7 100644 --- a/cocos/base/CCVector.h +++ b/cocos/base/CCVector.h @@ -26,7 +26,7 @@ THE SOFTWARE. #define __CCVECTOR_H__ #include "ccMacros.h" - +#include "CCObject.h" #include #include #include // for std::find @@ -68,13 +68,14 @@ public: Vector() : _data() { - + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); } /** Constructor with a capacity */ explicit Vector(ssize_t capacity) : _data() { + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); CCLOGINFO("In the default constructor with capacity of Vector."); reserve(capacity); } @@ -89,6 +90,7 @@ public: /** Copy constructor */ Vector(const Vector& other) { + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); CCLOGINFO("In the copy constructor!"); _data = other._data; addRefForAllObjects(); @@ -97,6 +99,7 @@ public: /** Move constructor */ Vector(Vector&& other) { + static_assert(std::is_convertible::value, "Invalid Type for cocos2d::Vector!"); CCLOGINFO("In the move constructor of Vector!"); _data = std::move(other._data); } From 17ff6ef76435765d6985b5e9ce6a42536604a508 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Dec 2013 22:07:20 +0800 Subject: [PATCH 07/14] =?UTF-8?q?Renames:=20IntValueMap=20=E2=80=94>=20Val?= =?UTF-8?q?ueMapIntKey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos/2d/CCTMXTiledMap.h | 2 +- cocos/2d/CCTMXXMLParser.cpp | 2 +- cocos/2d/CCTMXXMLParser.h | 6 +++--- cocos/base/CCValue.cpp | 20 +++++++++---------- cocos/base/CCValue.h | 16 +++++++-------- .../bindings/js_manual_conversions.cpp | 14 ++++++------- .../bindings/js_manual_conversions.h | 4 ++-- .../lua/bindings/LuaBasicConversions.cpp | 14 ++++++------- .../lua/bindings/LuaBasicConversions.h | 4 ++-- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/cocos/2d/CCTMXTiledMap.h b/cocos/2d/CCTMXTiledMap.h index 7f39531a7f..77530cf5d3 100644 --- a/cocos/2d/CCTMXTiledMap.h +++ b/cocos/2d/CCTMXTiledMap.h @@ -204,7 +204,7 @@ protected: ValueMap _properties; //! tile properties - IntValueMap _tileProperties; + ValueMapIntKey _tileProperties; private: CC_DISALLOW_COPY_AND_ASSIGN(TMXTiledMap); diff --git a/cocos/2d/CCTMXXMLParser.cpp b/cocos/2d/CCTMXXMLParser.cpp index 71bb6993bb..21ef31a986 100644 --- a/cocos/2d/CCTMXXMLParser.cpp +++ b/cocos/2d/CCTMXXMLParser.cpp @@ -536,7 +536,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } else if ( tmxMapInfo->getParentElement() == TMXPropertyTile ) { - IntValueMap& dict = tmxMapInfo->getTileProperties().at(tmxMapInfo->getParentGID()).asIntKeyMap(); + ValueMapIntKey& dict = tmxMapInfo->getTileProperties().at(tmxMapInfo->getParentGID()).asIntKeyMap(); int propertyName = attributeDict["name"].asInt(); dict[propertyName] = attributeDict["value"]; diff --git a/cocos/2d/CCTMXXMLParser.h b/cocos/2d/CCTMXXMLParser.h index 4753bf81a0..ddb2398b94 100644 --- a/cocos/2d/CCTMXXMLParser.h +++ b/cocos/2d/CCTMXXMLParser.h @@ -195,8 +195,8 @@ public: /* initializes parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */ bool parseXMLString(const std::string& xmlString); - IntValueMap& getTileProperties() { return _tileProperties; }; - void setTileProperties(const IntValueMap& tileProperties) { + ValueMapIntKey& getTileProperties() { return _tileProperties; }; + void setTileProperties(const ValueMapIntKey& tileProperties) { _tileProperties = tileProperties; }; @@ -311,7 +311,7 @@ protected: //! current string std::string _currentString; //! tile properties - IntValueMap _tileProperties; + ValueMapIntKey _tileProperties; unsigned int _currentFirstGID; }; diff --git a/cocos/base/CCValue.cpp b/cocos/base/CCValue.cpp index 82da7b9b15..ac63402a50 100644 --- a/cocos/base/CCValue.cpp +++ b/cocos/base/CCValue.cpp @@ -32,7 +32,7 @@ const Value Value::Null; Value::Value() : _vectorData(new ValueVector()) , _mapData(new ValueMap()) -, _intKeyMapData(new IntValueMap()) +, _intKeyMapData(new ValueMapIntKey()) , _type(Type::NONE) { @@ -137,19 +137,19 @@ Value::Value(ValueMap&& v) *_mapData = std::move(v); } -Value::Value(const IntValueMap& v) +Value::Value(const ValueMapIntKey& v) : _vectorData(nullptr) , _mapData(nullptr) -, _intKeyMapData(new IntValueMap()) +, _intKeyMapData(new ValueMapIntKey()) , _type(Type::INT_KEY_MAP) { *_intKeyMapData = v; } -Value::Value(IntValueMap&& v) +Value::Value(ValueMapIntKey&& v) : _vectorData(nullptr) , _mapData(nullptr) -, _intKeyMapData(new IntValueMap()) +, _intKeyMapData(new ValueMapIntKey()) , _type(Type::INT_KEY_MAP) { *_intKeyMapData = std::move(v); @@ -209,7 +209,7 @@ Value& Value::operator= (const Value& other) break; case Type::INT_KEY_MAP: if (_intKeyMapData == nullptr) - _intKeyMapData = new IntValueMap(); + _intKeyMapData = new ValueMapIntKey(); *_intKeyMapData = *other._intKeyMapData; break; default: @@ -357,20 +357,20 @@ Value& Value::operator= (ValueMap&& v) return *this; } -Value& Value::operator= (const IntValueMap& v) +Value& Value::operator= (const ValueMapIntKey& v) { clear(); _type = Type::INT_KEY_MAP; - _intKeyMapData = new IntValueMap(); + _intKeyMapData = new ValueMapIntKey(); *_intKeyMapData = v; return *this; } -Value& Value::operator= (IntValueMap&& v) +Value& Value::operator= (ValueMapIntKey&& v) { clear(); _type = Type::INT_KEY_MAP; - _intKeyMapData = new IntValueMap(); + _intKeyMapData = new ValueMapIntKey(); *_intKeyMapData = std::move(v); return *this; } diff --git a/cocos/base/CCValue.h b/cocos/base/CCValue.h index 189c9236e0..4aa0a8daa2 100644 --- a/cocos/base/CCValue.h +++ b/cocos/base/CCValue.h @@ -37,7 +37,7 @@ class Value; typedef std::vector ValueVector; typedef std::unordered_map ValueMap; -typedef std::unordered_map IntValueMap; +typedef std::unordered_map ValueMapIntKey; class Value { @@ -59,8 +59,8 @@ public: explicit Value(const ValueMap& v); explicit Value(ValueMap&& v); - explicit Value(const IntValueMap& v); - explicit Value(IntValueMap&& v); + explicit Value(const ValueMapIntKey& v); + explicit Value(ValueMapIntKey&& v); Value(const Value& other); Value(Value&& other); @@ -84,8 +84,8 @@ public: Value& operator= (const ValueMap& v); Value& operator= (ValueMap&& v); - Value& operator= (const IntValueMap& v); - Value& operator= (IntValueMap&& v); + Value& operator= (const ValueMapIntKey& v); + Value& operator= (ValueMapIntKey&& v); unsigned char asByte() const; int asInt() const; @@ -100,8 +100,8 @@ public: inline ValueMap& asValueMap() { return *_mapData; } inline const ValueMap& asValueMap() const { return *_mapData; } - inline IntValueMap& asIntKeyMap() { return *_intKeyMapData; } - inline const IntValueMap& asIntKeyMap() const { return *_intKeyMapData; } + inline ValueMapIntKey& asIntKeyMap() { return *_intKeyMapData; } + inline const ValueMapIntKey& asIntKeyMap() const { return *_intKeyMapData; } inline bool isNull() const { return _type == Type::NONE; } @@ -138,7 +138,7 @@ private: std::string _strData; ValueVector* _vectorData; ValueMap* _mapData; - IntValueMap* _intKeyMapData; + ValueMapIntKey* _intKeyMapData; Type _type; }; diff --git a/cocos/scripting/javascript/bindings/js_manual_conversions.cpp b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp index 5ac6c5cf8d..fe3c22d985 100644 --- a/cocos/scripting/javascript/bindings/js_manual_conversions.cpp +++ b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp @@ -1034,7 +1034,7 @@ JSBool jsval_to_ccvaluemap(JSContext* cx, jsval v, cocos2d::ValueMap* ret) return JS_TRUE; } -JSBool jsval_to_ccintvaluemap(JSContext* cx, jsval v, cocos2d::IntValueMap* ret) +JSBool jsval_to_ccvaluemapintkey(JSContext* cx, jsval v, cocos2d::ValueMapIntKey* ret) { if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) { @@ -1049,7 +1049,7 @@ JSBool jsval_to_ccintvaluemap(JSContext* cx, jsval v, cocos2d::IntValueMap* ret) JSObject* it = JS_NewPropertyIterator(cx, tmp); - IntValueMap& dict = *ret; + ValueMapIntKey& dict = *ret; while (true) { @@ -2040,7 +2040,7 @@ jsval ccvalue_to_jsval(JSContext* cx, const cocos2d::Value& v) ret = ccvaluemap_to_jsval(cx, obj.asValueMap()); break; case Value::Type::INT_KEY_MAP: - ret = ccintvaluemap_to_jsval(cx, obj.asIntKeyMap()); + ret = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); break; default: break; @@ -2082,7 +2082,7 @@ jsval ccvaluemap_to_jsval(JSContext* cx, const cocos2d::ValueMap& v) dictElement = ccvaluemap_to_jsval(cx, obj.asValueMap()); break; case Value::Type::INT_KEY_MAP: - dictElement = ccintvaluemap_to_jsval(cx, obj.asIntKeyMap()); + dictElement = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); break; default: break; @@ -2096,7 +2096,7 @@ jsval ccvaluemap_to_jsval(JSContext* cx, const cocos2d::ValueMap& v) return OBJECT_TO_JSVAL(jsRet); } -jsval ccintvaluemap_to_jsval(JSContext* cx, const cocos2d::IntValueMap& v) +jsval ccvaluemapintkey_to_jsval(JSContext* cx, const cocos2d::ValueMapIntKey& v) { JSObject* jsRet = JS_NewObject(cx, NULL, NULL, NULL); @@ -2131,7 +2131,7 @@ jsval ccintvaluemap_to_jsval(JSContext* cx, const cocos2d::IntValueMap& v) dictElement = ccvaluemap_to_jsval(cx, obj.asValueMap()); break; case Value::Type::INT_KEY_MAP: - dictElement = ccintvaluemap_to_jsval(cx, obj.asIntKeyMap()); + dictElement = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); break; default: break; @@ -2176,7 +2176,7 @@ jsval ccvaluevector_to_jsval(JSContext* cx, const cocos2d::ValueVector& v) arrElement = ccvaluemap_to_jsval(cx, obj.asValueMap()); break; case Value::Type::INT_KEY_MAP: - arrElement = ccintvaluemap_to_jsval(cx, obj.asIntKeyMap()); + arrElement = ccvaluemapintkey_to_jsval(cx, obj.asIntKeyMap()); break; default: break; diff --git a/cocos/scripting/javascript/bindings/js_manual_conversions.h b/cocos/scripting/javascript/bindings/js_manual_conversions.h index ec6da697a6..751cd995ee 100644 --- a/cocos/scripting/javascript/bindings/js_manual_conversions.h +++ b/cocos/scripting/javascript/bindings/js_manual_conversions.h @@ -149,7 +149,7 @@ JSBool jsval_to_ccvector(JSContext* cx, jsval v, cocos2d::Vector* ret) JSBool jsval_to_ccvalue(JSContext* cx, jsval v, cocos2d::Value* ret); JSBool jsval_to_ccvaluemap(JSContext* cx, jsval v, cocos2d::ValueMap* ret); -JSBool jsval_to_ccintvaluemap(JSContext* cx, jsval v, cocos2d::IntValueMap* ret); +JSBool jsval_to_ccvaluemapintkey(JSContext* cx, jsval v, cocos2d::ValueMapIntKey* ret); JSBool jsval_to_ccvaluevector(JSContext* cx, jsval v, cocos2d::ValueVector* ret); JSBool jsval_to_ssize( JSContext *cx, jsval vp, ssize_t* ret); JSBool jsval_to_std_vector_string( JSContext *cx, jsval vp, std::vector* ret); @@ -292,7 +292,7 @@ jsval ccmap_string_key_to_jsval(JSContext* cx, const cocos2d::Map void ccvalue_to_luaval(lua_State* L,const cocos2d::Value& inValue); void ccvaluemap_to_luaval(lua_State* L,const cocos2d::ValueMap& inValue); -void ccintvaluemap_to_luaval(lua_State* L, const cocos2d::IntValueMap& inValue); +void ccvaluemapintkey_to_luaval(lua_State* L, const cocos2d::ValueMapIntKey& inValue); void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue); #endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ From 31188710a039e71046c0f321488d4f1ff18cf313 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Dec 2013 22:14:48 +0800 Subject: [PATCH 08/14] Updates Bindings-generator. --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index 6e880d8843..c842ccaa4b 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 6e880d8843dd51fb5c4094f2672c7c846bb85401 +Subproject commit c842ccaa4b31121ac5f7be99ca64cafeb8d422c5 From edeeae4ff950cf7e4318281eb112a6b4edcb66b4 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Thu, 26 Dec 2013 14:48:08 +0000 Subject: [PATCH 09/14] [AUTO] : updating submodule reference to latest autogenerated bindings --- cocos/scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index f8780070ba..6f6b1240ec 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit f8780070ba5aa2b640ef1da1008a6acc77f66217 +Subproject commit 6f6b1240ecac0cbf3e4a2a0bd7356b708c054daf From fc655162fa7d185bec408740c16fbd0ab3cf9091 Mon Sep 17 00:00:00 2001 From: luocker Date: Fri, 27 Dec 2013 00:26:02 +0800 Subject: [PATCH 10/14] Update CCString.cpp we can't change _string value after get Array. --- cocos/base/CCString.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos/base/CCString.cpp b/cocos/base/CCString.cpp index 9e0f4b314f..a8643372a0 100644 --- a/cocos/base/CCString.cpp +++ b/cocos/base/CCString.cpp @@ -181,20 +181,20 @@ void __String::appendWithFormat(const char* format, ...) __Array* __String::componentsSeparatedByString(const char *delimiter) { __Array* result = __Array::create(); - + std::string strTmp = _string; size_t cutAt; - while( (cutAt = _string.find_first_of(delimiter)) != _string.npos ) + while( (cutAt = strTmp.find_first_of(delimiter)) != strTmp.npos ) { if(cutAt > 0) { - result->addObject(__String::create(_string.substr(0, cutAt))); + result->addObject(__String::create(strTmp.substr(0, cutAt))); } - _string = _string.substr(cutAt + 1); + strTmp = strTmp.substr(cutAt + 1); } - if(_string.length() > 0) + if(strTmp.length() > 0) { - result->addObject(__String::create(_string)); + result->addObject(__String::create(strTmp)); } return result; From 476157fd0999f8cb8adf92771adbc7b0cceab643 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 27 Dec 2013 10:08:34 +0800 Subject: [PATCH 11/14] Update AUTHORS [ci skip] --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index a59404c1e6..b31fa3b766 100644 --- a/AUTHORS +++ b/AUTHORS @@ -678,6 +678,9 @@ Developers: seobyeongky Updates spine runtime. + luocker + Fix a bug that string itself is also modified in `String::componentsSeparatedByString`. + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, From 48d3e8e334df5475b75d9323dd8b79f09f041bb0 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 27 Dec 2013 10:09:49 +0800 Subject: [PATCH 12/14] Update CHANGELOG [ci skip] --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index d77d9144e2..5961c04625 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ cocos2d-x-3.0beta0 ?? 2013 [FIX] LabelBMFont string can't be shown integrally. [FIX] Deprecates FileUtils::getFileData, adds FileUtils::getStringFromFile/getDataFromFile. [FIX] GUI refactoring: Removes UI prefix, Widget is inherited from Node, uses new containers(Vector, Map). + [FIX] String itself is also modified in `String::componentsSeparatedByString`. [Android] [NEW] build/android-build.sh: add supporting to generate .apk file [FIX] XMLHttpRequest receives wrong binary array. From 0d9fe874a3dad79fd6eca97afdaf1bc3765111c8 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 26 Dec 2013 19:49:54 -0800 Subject: [PATCH 13/14] Fix set FPS broken. --- cocos/2d/CCDirector.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index 40468aa179..27dea6ac61 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -1076,6 +1076,8 @@ void DisplayLinkDirector::startAnimation() } _invalid = false; + + Application::getInstance()->setAnimationInterval(_animationInterval); } void DisplayLinkDirector::mainLoop() From f250d247669b368c6b0091898872dada91b548c3 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Fri, 27 Dec 2013 11:56:56 +0800 Subject: [PATCH 14/14] fix black screen when back to foreground on android. --- cocos/2d/CCShaderCache.cpp | 5 +++++ cocos/2d/renderer/CCRenderer.cpp | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cocos/2d/CCShaderCache.cpp b/cocos/2d/CCShaderCache.cpp index f9c9da8f2a..5c751aa843 100644 --- a/cocos/2d/CCShaderCache.cpp +++ b/cocos/2d/CCShaderCache.cpp @@ -185,6 +185,11 @@ void ShaderCache::reloadDefaultShaders() p->reset(); loadDefaultShader(p, kShaderType_PositionTextureColor); + // Position Texture Color without MVP shader + p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); + p->reset(); + loadDefaultShader(p, kShaderType_PositionTextureColor_noMVP); + // Position Texture Color alpha test p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); p->reset(); diff --git a/cocos/2d/renderer/CCRenderer.cpp b/cocos/2d/renderer/CCRenderer.cpp index 0eeca3844f..d6e046c6d1 100644 --- a/cocos/2d/renderer/CCRenderer.cpp +++ b/cocos/2d/renderer/CCRenderer.cpp @@ -65,11 +65,14 @@ Renderer::~Renderer() glDeleteVertexArrays(1, &_quadVAO); GL::bindVAO(0); } +#if CC_ENABLE_CACHE_TEXTURE_DATA + NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); +#endif } void Renderer::initGLView() { -#if 0//CC_ENABLE_CACHE_TEXTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA // listen the event when app go to background NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(Renderer::onBackToForeground),