From 1c91e73a8cfb7a3c52ef92a30c9ef51146d6e939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=B1=EB=82=99=ED=98=B8?= Date: Wed, 7 Aug 2013 14:07:01 +0900 Subject: [PATCH 01/37] added jsb support for AssetsMAnager --- extensions/AssetsManager/AssetsManager.cpp | 40 ++++++++++++++++++++++ extensions/AssetsManager/AssetsManager.h | 20 ++++++++--- extensions/cocos-ext.h | 2 ++ tools/tojs/cocos2dx_extension.ini | 5 +-- 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/extensions/AssetsManager/AssetsManager.cpp b/extensions/AssetsManager/AssetsManager.cpp index ac0ca37dac..e4bc2e721d 100644 --- a/extensions/AssetsManager/AssetsManager.cpp +++ b/extensions/AssetsManager/AssetsManager.cpp @@ -88,6 +88,10 @@ AssetsManager::AssetsManager(const char* packageUrl/* =NULL */, const char* vers AssetsManager::~AssetsManager() { + if (_delegate) + { + _delegate->release(); + } if (_schedule) { _schedule->release(); @@ -479,7 +483,17 @@ void AssetsManager::deleteVersion() void AssetsManager::setDelegate(AssetsManagerDelegateProtocol *delegate) { + if (_delegate) + { + _delegate->release(); + } + _delegate = delegate; + + if (_delegate) + { + _delegate->retain(); + } } void AssetsManager::setConnectionTimeout(unsigned int timeout) @@ -604,4 +618,30 @@ void AssetsManager::Helper::handleUpdateSucceed(Message *msg) if (manager) manager->_delegate->onSuccess(); } +AssetsManager* AssetsManager::create(const char* packageUrl, const char* versionFileUrl, const char* storagePath, ErrorCallback errorCallback, ProgressCallback progressCallback, SuccessCallback successCallback ) +{ + class DelegateProtocolImpl : public AssetsManagerDelegateProtocol + { + public : + DelegateProtocolImpl(ErrorCallback errorCallback, ProgressCallback progressCallback, SuccessCallback successCallback) + : errorCallback(errorCallback), progressCallback(progressCallback), successCallback(successCallback) + {} + + virtual void onError(AssetsManager::ErrorCode errorCode) { errorCallback(int(errorCode)); } + virtual void onProgress(int percent) { progressCallback(percent); } + virtual void onSuccess() { successCallback(); } + + private : + ErrorCallback errorCallback; + ProgressCallback progressCallback; + SuccessCallback successCallback; + }; + + auto* manager = new AssetsManager(packageUrl,versionFileUrl,storagePath); + auto* delegate = new DelegateProtocolImpl(errorCallback,progressCallback,successCallback); + delegate->autorelease(); + manager->setDelegate(delegate); + return manager; +} + NS_CC_EXT_END; diff --git a/extensions/AssetsManager/AssetsManager.h b/extensions/AssetsManager/AssetsManager.h index b150e073e0..c9603f0188 100644 --- a/extensions/AssetsManager/AssetsManager.h +++ b/extensions/AssetsManager/AssetsManager.h @@ -26,7 +26,7 @@ #define __AssetsManager__ #include -#include + #include #include "cocos2d.h" @@ -41,7 +41,7 @@ class AssetsManagerDelegateProtocol; * The updated package should be a zip file. And there should be a file named * version in the server, which contains version code. */ -class AssetsManager +class AssetsManager : public Node { public: enum class ErrorCode @@ -77,6 +77,14 @@ public: virtual ~AssetsManager(); + typedef std::function ErrorCallback; + typedef std::function ProgressCallback; + typedef std::function SuccessCallback; + + /* @brief To access within scripting environment + */ + static AssetsManager* create(const char* packageUrl, const char* versionFileUrl, const char* storagePath, ErrorCallback errorCallback, ProgressCallback progressCallback, SuccessCallback successCallback ); + /* @brief Check out if there is a new version resource. * You may use this method before updating, then let user determine whether * he wants to update resources. @@ -172,6 +180,7 @@ private: std::list *_messageQueue; std::mutex _messageQueueMutex; }; + private: //! The path to store downloaded resources. @@ -185,16 +194,17 @@ private: std::string _downloadedVersion; - CURL *_curl; + void *_curl; + Helper *_schedule; unsigned int _connectionTimeout; - AssetsManagerDelegateProtocol *_delegate; // weak reference + AssetsManagerDelegateProtocol *_delegate; bool _isDownloading; }; -class AssetsManagerDelegateProtocol +class AssetsManagerDelegateProtocol : public Object { public: /* @brief Call back function for error diff --git a/extensions/cocos-ext.h b/extensions/cocos-ext.h index 716f269065..13f5d25ee5 100644 --- a/extensions/cocos-ext.h +++ b/extensions/cocos-ext.h @@ -56,4 +56,6 @@ #include "CCDeprecated-ext.h" +#include "AssetsManager/AssetsManager.h" + #endif /* __COCOS2D_EXT_H__ */ diff --git a/tools/tojs/cocos2dx_extension.ini b/tools/tojs/cocos2dx_extension.ini index 6a31b61f3c..6c812165bc 100644 --- a/tools/tojs/cocos2dx_extension.ini +++ b/tools/tojs/cocos2dx_extension.ini @@ -13,7 +13,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include -I%(cocosdir)s/extensions +cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include -I%(cocosdir)s/extensions cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common @@ -26,7 +26,7 @@ headers = %(cocosdir)s/extensions/cocos-ext.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = CCBReader.* CCBAnimationManager.* Scale9Sprite Control$ ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ +classes = AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control$ ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -43,6 +43,7 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType], EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], TableView::[create (g|s)etDataSource$ (g|s)etDelegate], + AssetsManager::[setDelegate], Control::[removeHandleOfControlEvent addHandleOfControlEvent] rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager], From 3fc48ecf15a0c0e4e3f9db37acf54fc4c58a2923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=B1=EB=82=99=ED=98=B8?= Date: Wed, 7 Aug 2013 14:36:26 +0900 Subject: [PATCH 02/37] purgeStoragePath added --- extensions/AssetsManager/AssetsManager.cpp | 33 ++++++++++++++++++++++ extensions/AssetsManager/AssetsManager.h | 5 ++++ 2 files changed, 38 insertions(+) diff --git a/extensions/AssetsManager/AssetsManager.cpp b/extensions/AssetsManager/AssetsManager.cpp index e4bc2e721d..f1ac337744 100644 --- a/extensions/AssetsManager/AssetsManager.cpp +++ b/extensions/AssetsManager/AssetsManager.cpp @@ -34,8 +34,10 @@ #include #include #include +#include #endif + #include "support/zip_support/unzip.h" using namespace cocos2d; @@ -644,4 +646,35 @@ AssetsManager* AssetsManager::create(const char* packageUrl, const char* version return manager; } +void AssetsManager::purgeStoragePath() +{ + // Delete recorded version codes. + deleteVersion(); + + // Remove downloaded files +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) + string command = "rm -r "; + // Path may include space. + command += "\"" + _storagePath + "\""; + system(command.c_str()); + DIR *pDir = NULL; + + pDir = opendir (_storagePath.c_str()); + if (! pDir) + { + mkdir(_storagePath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); + } +#else + string command = "rd /s /q "; + // Path may include space. + command += "\"" + _storagePath + "\""; + system(command.c_str()); + + if ((GetFileAttributesA(_storagePath.c_str())) == INVALID_FILE_ATTRIBUTES) + { + CreateDirectoryA(_storagePath.c_str(), 0); + } +#endif +} + NS_CC_EXT_END; diff --git a/extensions/AssetsManager/AssetsManager.h b/extensions/AssetsManager/AssetsManager.h index c9603f0188..e7dcb4a88d 100644 --- a/extensions/AssetsManager/AssetsManager.h +++ b/extensions/AssetsManager/AssetsManager.h @@ -146,6 +146,11 @@ public: /* downloadAndUncompress is the entry of a new thread */ friend int assetsManagerProgressFunc(void *, double, double, double, double); + + /** @brief Initialize storage path. + */ + void purgeStoragePath(); + protected: bool downLoad(); From 31a3fd65c104c70c5efbf9859c6a6f62063221a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=B1=EB=82=99=ED=98=B8?= Date: Thu, 8 Aug 2013 17:29:29 +0900 Subject: [PATCH 03/37] key with hash to support multiple assetsManager --- extensions/AssetsManager/AssetsManager.cpp | 69 +++++++++++++++------- extensions/AssetsManager/AssetsManager.h | 11 +++- 2 files changed, 57 insertions(+), 23 deletions(-) diff --git a/extensions/AssetsManager/AssetsManager.cpp b/extensions/AssetsManager/AssetsManager.cpp index f1ac337744..8060f86445 100644 --- a/extensions/AssetsManager/AssetsManager.cpp +++ b/extensions/AssetsManager/AssetsManager.cpp @@ -108,6 +108,26 @@ void AssetsManager::checkStoragePath() } } +// Multiple key names +static std::string key_with_hash( const char* prefix, const std::string& url ) +{ + char buf[256]; + sprintf(buf,"%s%zd",prefix,std::hash()(url)); + return buf; +} + +// hashed version +std::string AssetsManager::key_of_version() const +{ + return key_with_hash(KEY_OF_VERSION,_packageUrl); +} + +// hashed version +std::string AssetsManager::key_of_downloaded_version() const +{ + return key_with_hash(KEY_OF_DOWNLOADED_VERSION,_packageUrl); +} + static size_t getVersionCode(void *ptr, size_t size, size_t nmemb, void *userdata) { string *version = (string*)userdata; @@ -146,7 +166,7 @@ bool AssetsManager::checkUpdate() return false; } - string recordedVersion = UserDefault::getInstance()->getStringForKey(KEY_OF_VERSION); + string recordedVersion = UserDefault::getInstance()->getStringForKey(key_of_version().c_str()); if (recordedVersion == _version) { sendErrorMessage(ErrorCode::NO_NEW_VERSION); @@ -218,7 +238,7 @@ void AssetsManager::update() } // Is package already downloaded? - _downloadedVersion = UserDefault::getInstance()->getStringForKey(KEY_OF_DOWNLOADED_VERSION); + _downloadedVersion = UserDefault::getInstance()->getStringForKey(key_of_downloaded_version().c_str()); auto t = std::thread(&AssetsManager::downloadAndUncompress, this); t.detach(); @@ -475,12 +495,12 @@ void AssetsManager::setVersionFileUrl(const char *versionFileUrl) string AssetsManager::getVersion() { - return UserDefault::getInstance()->getStringForKey(KEY_OF_VERSION); + return UserDefault::getInstance()->getStringForKey(key_of_version().c_str()); } void AssetsManager::deleteVersion() { - UserDefault::getInstance()->setStringForKey(KEY_OF_VERSION, ""); + UserDefault::getInstance()->setStringForKey(key_of_version().c_str(), ""); } void AssetsManager::setDelegate(AssetsManagerDelegateProtocol *delegate) @@ -565,7 +585,7 @@ void AssetsManager::Helper::update(float dt) break; case ASSETSMANAGER_MESSAGE_RECORD_DOWNLOADED_VERSION: - UserDefault::getInstance()->setStringForKey(KEY_OF_DOWNLOADED_VERSION, + UserDefault::getInstance()->setStringForKey(((AssetsManager*)msg->obj)->key_of_downloaded_version().c_str(), ((AssetsManager*)msg->obj)->_version.c_str()); UserDefault::getInstance()->flush(); @@ -601,10 +621,10 @@ void AssetsManager::Helper::handleUpdateSucceed(Message *msg) AssetsManager* manager = (AssetsManager*)msg->obj; // Record new version code. - UserDefault::getInstance()->setStringForKey(KEY_OF_VERSION, manager->_version.c_str()); + UserDefault::getInstance()->setStringForKey(manager->key_of_version().c_str(), manager->_version.c_str()); // Unrecord downloaded version code. - UserDefault::getInstance()->setStringForKey(KEY_OF_DOWNLOADED_VERSION, ""); + UserDefault::getInstance()->setStringForKey(manager->key_of_downloaded_version().c_str(), ""); UserDefault::getInstance()->flush(); // Set resource search path. @@ -646,7 +666,26 @@ AssetsManager* AssetsManager::create(const char* packageUrl, const char* version return manager; } -void AssetsManager::purgeStoragePath() +void AssetsManager::createStoragePath() +{ + // Remove downloaded files +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) + DIR *pDir = NULL; + + pDir = opendir (_storagePath.c_str()); + if (! pDir) + { + mkdir(_storagePath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); + } +#else + if ((GetFileAttributesA(_storagePath.c_str())) == INVALID_FILE_ATTRIBUTES) + { + CreateDirectoryA(_storagePath.c_str(), 0); + } +#endif +} + +void AssetsManager::destroyStoragePath() { // Delete recorded version codes. deleteVersion(); @@ -656,24 +695,12 @@ void AssetsManager::purgeStoragePath() string command = "rm -r "; // Path may include space. command += "\"" + _storagePath + "\""; - system(command.c_str()); - DIR *pDir = NULL; - - pDir = opendir (_storagePath.c_str()); - if (! pDir) - { - mkdir(_storagePath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); - } + system(command.c_str()); #else string command = "rd /s /q "; // Path may include space. command += "\"" + _storagePath + "\""; system(command.c_str()); - - if ((GetFileAttributesA(_storagePath.c_str())) == INVALID_FILE_ATTRIBUTES) - { - CreateDirectoryA(_storagePath.c_str(), 0); - } #endif } diff --git a/extensions/AssetsManager/AssetsManager.h b/extensions/AssetsManager/AssetsManager.h index e7dcb4a88d..a1e81302c1 100644 --- a/extensions/AssetsManager/AssetsManager.h +++ b/extensions/AssetsManager/AssetsManager.h @@ -147,9 +147,13 @@ public: */ friend int assetsManagerProgressFunc(void *, double, double, double, double); - /** @brief Initialize storage path. + /** @brief Initializes storage path. */ - void purgeStoragePath(); + void createStoragePath(); + + /** @brief Destroys storage path. + */ + void destroyStoragePath(); protected: @@ -207,6 +211,9 @@ private: AssetsManagerDelegateProtocol *_delegate; bool _isDownloading; + + std::string key_of_version() const; + std::string key_of_downloaded_version() const; }; class AssetsManagerDelegateProtocol : public Object From eda9846e6f7aaee1e7adeac2aeb94fa6293253ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=B1=EB=82=99=ED=98=B8?= Date: Thu, 8 Aug 2013 18:36:56 +0900 Subject: [PATCH 04/37] DelegateProtocol is weak-referenced again --- extensions/AssetsManager/AssetsManager.cpp | 21 ++++++--------------- extensions/AssetsManager/AssetsManager.h | 3 ++- tools/tojs/cocos2dx_extension.ini | 1 + 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/extensions/AssetsManager/AssetsManager.cpp b/extensions/AssetsManager/AssetsManager.cpp index 8060f86445..04d1fde900 100644 --- a/extensions/AssetsManager/AssetsManager.cpp +++ b/extensions/AssetsManager/AssetsManager.cpp @@ -83,6 +83,7 @@ AssetsManager::AssetsManager(const char* packageUrl/* =NULL */, const char* vers , _connectionTimeout(0) , _delegate(NULL) , _isDownloading(false) +, _shouldDeleteDelegateWhenExit(false) { checkStoragePath(); _schedule = new Helper(); @@ -90,14 +91,14 @@ AssetsManager::AssetsManager(const char* packageUrl/* =NULL */, const char* vers AssetsManager::~AssetsManager() { - if (_delegate) - { - _delegate->release(); - } if (_schedule) { _schedule->release(); } + if (_shouldDeleteDelegateWhenExit) + { + delete _delegate; + } } void AssetsManager::checkStoragePath() @@ -505,17 +506,7 @@ void AssetsManager::deleteVersion() void AssetsManager::setDelegate(AssetsManagerDelegateProtocol *delegate) { - if (_delegate) - { - _delegate->release(); - } - _delegate = delegate; - - if (_delegate) - { - _delegate->retain(); - } } void AssetsManager::setConnectionTimeout(unsigned int timeout) @@ -661,8 +652,8 @@ AssetsManager* AssetsManager::create(const char* packageUrl, const char* version auto* manager = new AssetsManager(packageUrl,versionFileUrl,storagePath); auto* delegate = new DelegateProtocolImpl(errorCallback,progressCallback,successCallback); - delegate->autorelease(); manager->setDelegate(delegate); + manager->_shouldDeleteDelegateWhenExit = true; return manager; } diff --git a/extensions/AssetsManager/AssetsManager.h b/extensions/AssetsManager/AssetsManager.h index a1e81302c1..8e0bcd859a 100644 --- a/extensions/AssetsManager/AssetsManager.h +++ b/extensions/AssetsManager/AssetsManager.h @@ -211,12 +211,13 @@ private: AssetsManagerDelegateProtocol *_delegate; bool _isDownloading; + bool _shouldDeleteDelegateWhenExit; std::string key_of_version() const; std::string key_of_downloaded_version() const; }; -class AssetsManagerDelegateProtocol : public Object +class AssetsManagerDelegateProtocol { public: /* @brief Call back function for error diff --git a/tools/tojs/cocos2dx_extension.ini b/tools/tojs/cocos2dx_extension.ini index 6c812165bc..d620fb6753 100644 --- a/tools/tojs/cocos2dx_extension.ini +++ b/tools/tojs/cocos2dx_extension.ini @@ -44,6 +44,7 @@ skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getC EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], TableView::[create (g|s)etDataSource$ (g|s)etDelegate], AssetsManager::[setDelegate], + AssetsManagerDelegateProtocol::[*], Control::[removeHandleOfControlEvent addHandleOfControlEvent] rename_functions = CCBReader::[getAnimationManager=getActionManager setAnimationManager=setActionManager], From d202a6fa241416ac5b155c9cfd31aee298064ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=B1=EB=82=99=ED=98=B8?= Date: Fri, 9 Aug 2013 14:39:40 +0900 Subject: [PATCH 05/37] applied cocos2d-x coding style --- extensions/AssetsManager/AssetsManager.cpp | 24 +++++++++++----------- extensions/AssetsManager/AssetsManager.h | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/extensions/AssetsManager/AssetsManager.cpp b/extensions/AssetsManager/AssetsManager.cpp index 04d1fde900..15acacb49e 100644 --- a/extensions/AssetsManager/AssetsManager.cpp +++ b/extensions/AssetsManager/AssetsManager.cpp @@ -118,13 +118,13 @@ static std::string key_with_hash( const char* prefix, const std::string& url ) } // hashed version -std::string AssetsManager::key_of_version() const +std::string AssetsManager::keyOfVersion() const { return key_with_hash(KEY_OF_VERSION,_packageUrl); } // hashed version -std::string AssetsManager::key_of_downloaded_version() const +std::string AssetsManager::keyOfDownloadedVersion() const { return key_with_hash(KEY_OF_DOWNLOADED_VERSION,_packageUrl); } @@ -167,7 +167,7 @@ bool AssetsManager::checkUpdate() return false; } - string recordedVersion = UserDefault::getInstance()->getStringForKey(key_of_version().c_str()); + string recordedVersion = UserDefault::getInstance()->getStringForKey(keyOfVersion().c_str()); if (recordedVersion == _version) { sendErrorMessage(ErrorCode::NO_NEW_VERSION); @@ -239,7 +239,7 @@ void AssetsManager::update() } // Is package already downloaded? - _downloadedVersion = UserDefault::getInstance()->getStringForKey(key_of_downloaded_version().c_str()); + _downloadedVersion = UserDefault::getInstance()->getStringForKey(keyOfDownloadedVersion().c_str()); auto t = std::thread(&AssetsManager::downloadAndUncompress, this); t.detach(); @@ -496,12 +496,12 @@ void AssetsManager::setVersionFileUrl(const char *versionFileUrl) string AssetsManager::getVersion() { - return UserDefault::getInstance()->getStringForKey(key_of_version().c_str()); + return UserDefault::getInstance()->getStringForKey(keyOfVersion().c_str()); } void AssetsManager::deleteVersion() { - UserDefault::getInstance()->setStringForKey(key_of_version().c_str(), ""); + UserDefault::getInstance()->setStringForKey(keyOfVersion().c_str(), ""); } void AssetsManager::setDelegate(AssetsManagerDelegateProtocol *delegate) @@ -576,7 +576,7 @@ void AssetsManager::Helper::update(float dt) break; case ASSETSMANAGER_MESSAGE_RECORD_DOWNLOADED_VERSION: - UserDefault::getInstance()->setStringForKey(((AssetsManager*)msg->obj)->key_of_downloaded_version().c_str(), + UserDefault::getInstance()->setStringForKey(((AssetsManager*)msg->obj)->keyOfDownloadedVersion().c_str(), ((AssetsManager*)msg->obj)->_version.c_str()); UserDefault::getInstance()->flush(); @@ -612,10 +612,10 @@ void AssetsManager::Helper::handleUpdateSucceed(Message *msg) AssetsManager* manager = (AssetsManager*)msg->obj; // Record new version code. - UserDefault::getInstance()->setStringForKey(manager->key_of_version().c_str(), manager->_version.c_str()); + UserDefault::getInstance()->setStringForKey(manager->keyOfVersion().c_str(), manager->_version.c_str()); // Unrecord downloaded version code. - UserDefault::getInstance()->setStringForKey(manager->key_of_downloaded_version().c_str(), ""); + UserDefault::getInstance()->setStringForKey(manager->keyOfDownloadedVersion().c_str(), ""); UserDefault::getInstance()->flush(); // Set resource search path. @@ -661,10 +661,10 @@ void AssetsManager::createStoragePath() { // Remove downloaded files #if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) - DIR *pDir = NULL; + DIR *dir = NULL; - pDir = opendir (_storagePath.c_str()); - if (! pDir) + dir = opendir (_storagePath.c_str()); + if (!dir) { mkdir(_storagePath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); } diff --git a/extensions/AssetsManager/AssetsManager.h b/extensions/AssetsManager/AssetsManager.h index 8e0bcd859a..6229ba8934 100644 --- a/extensions/AssetsManager/AssetsManager.h +++ b/extensions/AssetsManager/AssetsManager.h @@ -213,8 +213,8 @@ private: bool _isDownloading; bool _shouldDeleteDelegateWhenExit; - std::string key_of_version() const; - std::string key_of_downloaded_version() const; + std::string keyOfVersion() const; + std::string keyOfDownloadedVersion() const; }; class AssetsManagerDelegateProtocol From 200a1ec8312d25917f85e430eb6a9717dbaa3e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=B1=EB=82=99=ED=98=B8?= Date: Fri, 16 Aug 2013 19:03:27 +0900 Subject: [PATCH 06/37] style edited --- extensions/AssetsManager/AssetsManager.cpp | 1 + .../AssetsManagerTest/Classes/AppDelegate.cpp | 26 ++++++------------- .../AssetsManagerTest/Classes/AppDelegate.h | 2 +- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/extensions/AssetsManager/AssetsManager.cpp b/extensions/AssetsManager/AssetsManager.cpp index 15acacb49e..61b9081121 100644 --- a/extensions/AssetsManager/AssetsManager.cpp +++ b/extensions/AssetsManager/AssetsManager.cpp @@ -654,6 +654,7 @@ AssetsManager* AssetsManager::create(const char* packageUrl, const char* version auto* delegate = new DelegateProtocolImpl(errorCallback,progressCallback,successCallback); manager->setDelegate(delegate); manager->_shouldDeleteDelegateWhenExit = true; + manager->autorelease(); return manager; } diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp index bcb045c351..4768e7d038 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp @@ -85,8 +85,6 @@ UpdateLayer::UpdateLayer() UpdateLayer::~UpdateLayer() { - AssetsManager *pAssetsManager = getAssetsManager(); - CC_SAFE_DELETE(pAssetsManager); } void UpdateLayer::update(cocos2d::Object *pSender) @@ -141,6 +139,14 @@ bool UpdateLayer::init() { Layer::init(); + /** Creates assets manager */ + pAssetsManager = new AssetsManager("https://raw.github.com/minggo/AssetsManagerTest/master/package.zip", + "https://raw.github.com/minggo/AssetsManagerTest/master/version", + pathToSave.c_str()); + pAssetsManager->setDelegate(this); + pAssetsManager->setConnectionTimeout(3); + addChild(pAssetsManager); + createDownloadedDir(); Size size = Director::getInstance()->getWinSize(); @@ -164,22 +170,6 @@ bool UpdateLayer::init() return true; } -AssetsManager* UpdateLayer::getAssetsManager() -{ - static AssetsManager *pAssetsManager = NULL; - - if (! pAssetsManager) - { - pAssetsManager = new AssetsManager("https://raw.github.com/minggo/AssetsManagerTest/master/package.zip", - "https://raw.github.com/minggo/AssetsManagerTest/master/version", - pathToSave.c_str()); - pAssetsManager->setDelegate(this); - pAssetsManager->setConnectionTimeout(3); - } - - return pAssetsManager; -} - void UpdateLayer::createDownloadedDir() { pathToSave = FileUtils::getInstance()->getWritablePath(); diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.h b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.h index a6518be098..7fcf54741d 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.h +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.h @@ -60,7 +60,7 @@ public: virtual void onSuccess(); private: - cocos2d::extension::AssetsManager* getAssetsManager(); + cocos2d::extension::AssetsManager* pAssetsManager; void createDownloadedDir(); cocos2d::MenuItemFont *pItemEnter; From 95c6c66d58875354a022f0e9b56c04a886da8e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=BC=E1=84=82=E1=85=A1=E1=86=A8?= =?UTF-8?q?=E1=84=92=E1=85=A9?= Date: Fri, 6 Sep 2013 16:10:11 +0900 Subject: [PATCH 07/37] * obey naming convention * hide unnecessary methods from public. --- extensions/AssetsManager/AssetsManager.cpp | 6 +++--- extensions/AssetsManager/AssetsManager.h | 17 ++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/extensions/AssetsManager/AssetsManager.cpp b/extensions/AssetsManager/AssetsManager.cpp index 61b9081121..b1b909bce2 100644 --- a/extensions/AssetsManager/AssetsManager.cpp +++ b/extensions/AssetsManager/AssetsManager.cpp @@ -110,7 +110,7 @@ void AssetsManager::checkStoragePath() } // Multiple key names -static std::string key_with_hash( const char* prefix, const std::string& url ) +static std::string keyWithHash( const char* prefix, const std::string& url ) { char buf[256]; sprintf(buf,"%s%zd",prefix,std::hash()(url)); @@ -120,13 +120,13 @@ static std::string key_with_hash( const char* prefix, const std::string& url ) // hashed version std::string AssetsManager::keyOfVersion() const { - return key_with_hash(KEY_OF_VERSION,_packageUrl); + return keyWithHash(KEY_OF_VERSION,_packageUrl); } // hashed version std::string AssetsManager::keyOfDownloadedVersion() const { - return key_with_hash(KEY_OF_DOWNLOADED_VERSION,_packageUrl); + return keyWithHash(KEY_OF_DOWNLOADED_VERSION,_packageUrl); } static size_t getVersionCode(void *ptr, size_t size, size_t nmemb, void *userdata) diff --git a/extensions/AssetsManager/AssetsManager.h b/extensions/AssetsManager/AssetsManager.h index 6229ba8934..1a5993e364 100644 --- a/extensions/AssetsManager/AssetsManager.h +++ b/extensions/AssetsManager/AssetsManager.h @@ -147,15 +147,6 @@ public: */ friend int assetsManagerProgressFunc(void *, double, double, double, double); - /** @brief Initializes storage path. - */ - void createStoragePath(); - - /** @brief Destroys storage path. - */ - void destroyStoragePath(); - - protected: bool downLoad(); void checkStoragePath(); @@ -190,6 +181,14 @@ private: std::mutex _messageQueueMutex; }; +private: + /** @brief Initializes storage path. + */ + void createStoragePath(); + + /** @brief Destroys storage path. + */ + void destroyStoragePath(); private: //! The path to store downloaded resources. From b78382d5e55b329b243efbba6b55b7d6e28057a1 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 6 Sep 2013 15:33:28 -0700 Subject: [PATCH 08/37] Performance improvements in FileUtils / TextureCache Added common "apple" platform to avoid duplicate files in FileUtils and other common files Improves performance in fetching files. --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos2dx/CCDirector.cpp | 4 +- cocos2dx/platform/CCFileUtils.cpp | 41 +- cocos2dx/platform/CCFileUtils.h | 5 +- .../CCFileUtilsApple.h} | 11 +- .../CCFileUtilsApple.mm} | 34 +- cocos2dx/platform/{ios => apple}/CCLock.cpp | 0 cocos2dx/platform/{ios => apple}/CCLock.h | 0 cocos2dx/platform/{mac => apple}/CCThread.mm | 2 +- cocos2dx/platform/ios/CCFileUtilsIOS.h | 62 --- cocos2dx/platform/ios/CCThread.mm | 39 -- cocos2dx/platform/mac/CCFileUtilsMac.mm | 354 ------------------ cocos2dx/sprite_nodes/CCSprite.cpp | 4 +- cocos2dx/textures/CCTextureCache.cpp | 93 ++--- cocos2dx/textures/CCTextureCache.h | 11 +- .../PerformanceTest/PerformanceAllocTest.cpp | 10 +- 16 files changed, 90 insertions(+), 582 deletions(-) rename cocos2dx/platform/{mac/CCFileUtilsMac.h => apple/CCFileUtilsApple.h} (91%) rename cocos2dx/platform/{ios/CCFileUtilsIOS.mm => apple/CCFileUtilsApple.mm} (92%) rename cocos2dx/platform/{ios => apple}/CCLock.cpp (100%) rename cocos2dx/platform/{ios => apple}/CCLock.h (100%) rename cocos2dx/platform/{mac => apple}/CCThread.mm (98%) delete mode 100644 cocos2dx/platform/ios/CCFileUtilsIOS.h delete mode 100644 cocos2dx/platform/ios/CCThread.mm delete mode 100644 cocos2dx/platform/mac/CCFileUtilsMac.mm diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index ff4b7a32dd..dd6e2cc334 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -fd0dee451420604712c1327679395cd1faca91b6 \ No newline at end of file +0bd142a09d7aacd3dbff8f23c7a14966430e9c01 \ No newline at end of file diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 4ba8ce2087..3993a77694 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -861,7 +861,7 @@ void Director::createStatsLabel() CC_SAFE_RELEASE_NULL(_FPSLabel); CC_SAFE_RELEASE_NULL(_SPFLabel); CC_SAFE_RELEASE_NULL(_drawsLabel); - textureCache->removeTextureForKey("cc_fps_images"); + textureCache->removeTextureForKey("/cc_fps_images"); FileUtils::getInstance()->purgeCachedEntries(); } @@ -878,7 +878,7 @@ void Director::createStatsLabel() return; } - texture = textureCache->addUIImage(image, "cc_fps_images"); + texture = textureCache->addImage(image, "/cc_fps_images"); CC_SAFE_RELEASE(image); /* diff --git a/cocos2dx/platform/CCFileUtils.cpp b/cocos2dx/platform/CCFileUtils.cpp index 2de469e5e3..f783d0ac75 100644 --- a/cocos2dx/platform/CCFileUtils.cpp +++ b/cocos2dx/platform/CCFileUtils.cpp @@ -449,7 +449,7 @@ static tinyxml2::XMLElement* generateElementForArray(cocos2d::Array *array, tiny #else NS_CC_BEGIN -/* The subclass FileUtilsIOS and FileUtilsMac should override these two method. */ +/* The subclass FileUtilsApple should override these two method. */ Dictionary* FileUtils::createDictionaryWithContentsOfFile(const std::string& filename) {return NULL;} bool FileUtils::writeToFile(cocos2d::Dictionary *dict, const std::string &fullPath) {return NULL;} Array* FileUtils::createArrayWithContentsOfFile(const std::string& filename) {return NULL;} @@ -459,23 +459,12 @@ Array* FileUtils::createArrayWithContentsOfFile(const std::string& filename) {re FileUtils* FileUtils::s_sharedFileUtils = NULL; -// XXX: deprecated -FileUtils* FileUtils::sharedFileUtils() -{ - return FileUtils::getInstance(); -} void FileUtils::destroyInstance() { CC_SAFE_DELETE(s_sharedFileUtils); } -// XXX: deprecated -void FileUtils::purgeFileUtils() -{ - FileUtils::destroyInstance(); -} - FileUtils::FileUtils() : _filenameLookupDict(NULL) { @@ -572,17 +561,17 @@ unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const c std::string FileUtils::getNewFilename(const char* filename) { - const char* pszNewFileName = NULL; + const char* newFileName = NULL; + // in Lookup Filename dictionary ? String* fileNameFound = _filenameLookupDict ? (String*)_filenameLookupDict->objectForKey(filename) : NULL; if( NULL == fileNameFound || fileNameFound->length() == 0) { - pszNewFileName = filename; + newFileName = filename; } else { - pszNewFileName = fileNameFound->getCString(); - //CCLOG("FOUND NEW FILE NAME: %s.", pszNewFileName); + newFileName = fileNameFound->getCString(); } - return pszNewFileName; + return newFileName; } std::string FileUtils::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) @@ -615,15 +604,13 @@ std::string FileUtils::fullPathForFilename(const char* filename) std::string strFileName = filename; if (isAbsolutePath(filename)) { - //CCLOG("Return absolute path( %s ) directly.", filename); return filename; } // Already Cached ? - std::map::iterator cacheIter = _fullPathCache.find(filename); + auto cacheIter = _fullPathCache.find(filename); if (cacheIter != _fullPathCache.end()) { - //CCLOG("Return full path from cache: %s", cacheIter->second.c_str()); return cacheIter->second; } @@ -632,27 +619,23 @@ std::string FileUtils::fullPathForFilename(const char* filename) string fullpath = ""; - for (auto searchPathsIter = _searchPathArray.begin(); - searchPathsIter != _searchPathArray.end(); ++searchPathsIter) { - for (auto resOrderIter = _searchResolutionsOrderArray.begin(); - resOrderIter != _searchResolutionsOrderArray.end(); ++resOrderIter) { + for (auto searchIt = _searchPathArray.begin(); searchIt != _searchPathArray.end(); ++searchIt) { + for (auto resolutionIt = _searchResolutionsOrderArray.begin(); resolutionIt != _searchResolutionsOrderArray.end(); ++resolutionIt) { -// CCLOG("SEARCHING: %s\n", std::string(*searchPathsIter + *resOrderIter + newFilename).c_str() ); - - fullpath = this->getPathForFilename(newFilename, *resOrderIter, *searchPathsIter); + fullpath = this->getPathForFilename(newFilename, *resolutionIt, *searchIt); if (fullpath.length() > 0) { // Using the filename passed in as key. _fullPathCache.insert(std::pair(filename, fullpath)); -// CCLOG("Returning path: %s\n", fullpath.c_str()); return fullpath; } } } -// CCLOG("cocos2d: fullPathForFilename: No file found at %s. Possible missing file.", filename); + CCLOG("cocos2d: fullPathForFilename: No file found at %s. Possible missing file.", filename); + // XXX: Should it return nullptr ? or an empty string ? // The file wasn't found, return the file name passed in. return filename; } diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index 709e3cdf86..cc7478e156 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -57,10 +57,10 @@ public: static void destroyInstance(); /** @deprecated Use getInstance() instead */ - CC_DEPRECATED_ATTRIBUTE static FileUtils* sharedFileUtils(); + CC_DEPRECATED_ATTRIBUTE static FileUtils* sharedFileUtils() { return getInstance(); } /** @deprecated Use destroyInstance() instead */ - CC_DEPRECATED_ATTRIBUTE static void purgeFileUtils(); + CC_DEPRECATED_ATTRIBUTE static void purgeFileUtils() { destroyInstance(); } /** * The destructor of FileUtils. @@ -308,6 +308,7 @@ protected: /** * Gets the new filename from the filename lookup dictionary. + * It is possible to have a override names. * @param filename The original filename. * @return The new filename after searching in the filename lookup dictionary. * If the original filename wasn't in the dictionary, it will return the original filename. diff --git a/cocos2dx/platform/mac/CCFileUtilsMac.h b/cocos2dx/platform/apple/CCFileUtilsApple.h similarity index 91% rename from cocos2dx/platform/mac/CCFileUtilsMac.h rename to cocos2dx/platform/apple/CCFileUtilsApple.h index 59027609a8..30102636b2 100644 --- a/cocos2dx/platform/mac/CCFileUtilsMac.h +++ b/cocos2dx/platform/apple/CCFileUtilsApple.h @@ -21,8 +21,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __CC_FILEUTILSMAC_H__ -#define __CC_FILEUTILSMAC_H__ +#ifndef __CC_FILEUTILS_APPLE_H__ +#define __CC_FILEUTILS_APPLE_H__ #include "CCFileUtils.h" #include @@ -31,26 +31,25 @@ #include "ccTypes.h" NS_CC_BEGIN + /** * @addtogroup platform * @{ */ //! @brief Helper class to handle file operations -class CC_DLL FileUtilsMac : public FileUtils +class CC_DLL FileUtilsApple : public FileUtils { public: /* override funtions */ virtual std::string getWritablePath(); virtual bool isFileExist(const std::string& strFilePath); - virtual bool isAbsolutePath(const std::string& strPath); virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename); virtual Dictionary* createDictionaryWithContentsOfFile(const std::string& filename); virtual bool writeToFile(Dictionary *dict, const std::string& fullPath); virtual Array* createArrayWithContentsOfFile(const std::string& filename); - }; // end of platform group @@ -58,5 +57,5 @@ public: NS_CC_END -#endif // __CC_FILEUTILSMAC_H__ +#endif // __CC_FILEUTILS_APPLE_H__ diff --git a/cocos2dx/platform/ios/CCFileUtilsIOS.mm b/cocos2dx/platform/apple/CCFileUtilsApple.mm similarity index 92% rename from cocos2dx/platform/ios/CCFileUtilsIOS.mm rename to cocos2dx/platform/apple/CCFileUtilsApple.mm index 0bee59a452..ebbdaab6c5 100644 --- a/cocos2dx/platform/ios/CCFileUtilsIOS.mm +++ b/cocos2dx/platform/apple/CCFileUtilsApple.mm @@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #import -#import #include #include @@ -34,7 +33,7 @@ THE SOFTWARE. #include "CCDictionary.h" #include "support/zip_support/unzip.h" -#include "CCFileUtilsIOS.h" +#include "CCFileUtilsApple.h" NS_CC_BEGIN @@ -210,25 +209,28 @@ static void addObjectToNSDict(const char * key, Object* object, NSMutableDiction } } + +#pragma mark - FileUtils + +static NSFileManager* s_fileManager = [NSFileManager defaultManager]; + FileUtils* FileUtils::getInstance() { if (s_sharedFileUtils == NULL) { - s_sharedFileUtils = new FileUtilsIOS(); + s_sharedFileUtils = new FileUtilsApple(); if(!s_sharedFileUtils->init()) { delete s_sharedFileUtils; s_sharedFileUtils = NULL; - CCLOG("ERROR: Could not init CCFileUtilsIOS"); + CCLOG("ERROR: Could not init CCFileUtilsApple"); } } return s_sharedFileUtils; } -static NSFileManager* s_fileManager = [NSFileManager defaultManager]; - -std::string FileUtilsIOS::getWritablePath() +std::string FileUtilsApple::getWritablePath() { // save to document folder NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); @@ -238,9 +240,9 @@ std::string FileUtilsIOS::getWritablePath() return strRet; } -bool FileUtilsIOS::isFileExist(const std::string& strFilePath) +bool FileUtilsApple::isFileExist(const std::string& strFilePath) { - if (0 == strFilePath.length()) + if(strFilePath.length() == 0) { return false; } @@ -280,7 +282,7 @@ bool FileUtilsIOS::isFileExist(const std::string& strFilePath) return bRet; } -std::string FileUtilsIOS::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) +std::string FileUtilsApple::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) { if (strDirectory[0] != '/') { @@ -302,13 +304,7 @@ std::string FileUtilsIOS::getFullPathForDirectoryAndFilename(const std::string& return ""; } -bool FileUtilsIOS::isAbsolutePath(const std::string& strPath) -{ - NSString* path = [NSString stringWithUTF8String:strPath.c_str()]; - return [path isAbsolutePath] ? true : false; -} - -Dictionary* FileUtilsIOS::createDictionaryWithContentsOfFile(const std::string& filename) +Dictionary* FileUtilsApple::createDictionaryWithContentsOfFile(const std::string& filename) { std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str()); NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; @@ -330,7 +326,7 @@ Dictionary* FileUtilsIOS::createDictionaryWithContentsOfFile(const std::string& } } -bool FileUtilsIOS::writeToFile(Dictionary *dict, const std::string &fullPath) +bool FileUtilsApple::writeToFile(Dictionary *dict, const std::string &fullPath) { //CCLOG("iOS||Mac Dictionary %d write to file %s", dict->_ID, fullPath.c_str()); NSMutableDictionary *nsDict = [NSMutableDictionary dictionary]; @@ -348,7 +344,7 @@ bool FileUtilsIOS::writeToFile(Dictionary *dict, const std::string &fullPath) return true; } -Array* FileUtilsIOS::createArrayWithContentsOfFile(const std::string& filename) +Array* FileUtilsApple::createArrayWithContentsOfFile(const std::string& filename) { // NSString* pPath = [NSString stringWithUTF8String:pFileName]; // NSString* pathExtension= [pPath pathExtension]; diff --git a/cocos2dx/platform/ios/CCLock.cpp b/cocos2dx/platform/apple/CCLock.cpp similarity index 100% rename from cocos2dx/platform/ios/CCLock.cpp rename to cocos2dx/platform/apple/CCLock.cpp diff --git a/cocos2dx/platform/ios/CCLock.h b/cocos2dx/platform/apple/CCLock.h similarity index 100% rename from cocos2dx/platform/ios/CCLock.h rename to cocos2dx/platform/apple/CCLock.h diff --git a/cocos2dx/platform/mac/CCThread.mm b/cocos2dx/platform/apple/CCThread.mm similarity index 98% rename from cocos2dx/platform/mac/CCThread.mm rename to cocos2dx/platform/apple/CCThread.mm index 61291796da..80b319bae4 100644 --- a/cocos2dx/platform/mac/CCThread.mm +++ b/cocos2dx/platform/apple/CCThread.mm @@ -21,7 +21,7 @@ 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. ****************************************************************************/ - +//#import #include "CCThread.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/ios/CCFileUtilsIOS.h b/cocos2dx/platform/ios/CCFileUtilsIOS.h deleted file mode 100644 index d48ad765f5..0000000000 --- a/cocos2dx/platform/ios/CCFileUtilsIOS.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** - Copyright (c) 2010 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 __CC_FILEUTILS_IOS_H__ -#define __CC_FILEUTILS_IOS_H__ - -#include "CCFileUtils.h" -#include -#include -#include "CCPlatformMacros.h" -#include "ccTypes.h" - -NS_CC_BEGIN - -/** - * @addtogroup platform - * @{ - */ - -//! @brief Helper class to handle file operations -class CC_DLL FileUtilsIOS : public FileUtils -{ -public: - /* override funtions */ - virtual std::string getWritablePath(); - virtual bool isFileExist(const std::string& strFilePath); - virtual bool isAbsolutePath(const std::string& strPath); - virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename); - - virtual Dictionary* createDictionaryWithContentsOfFile(const std::string& filename); - virtual bool writeToFile(Dictionary *dict, const std::string& fullPath); - - virtual Array* createArrayWithContentsOfFile(const std::string& filename); -}; - -// end of platform group -/// @} - -NS_CC_END - -#endif // __CC_FILEUTILS_IOS_H__ - diff --git a/cocos2dx/platform/ios/CCThread.mm b/cocos2dx/platform/ios/CCThread.mm deleted file mode 100644 index 8948c10acc..0000000000 --- a/cocos2dx/platform/ios/CCThread.mm +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 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. -****************************************************************************/ -#import -#include "CCThread.h" - -NS_CC_BEGIN - -Thread::~Thread() -{ - [(id)_autoReleasePool release]; -} - -void Thread::createAutoreleasePool() -{ - _autoReleasePool = [[NSAutoreleasePool alloc] init]; -} - -NS_CC_END diff --git a/cocos2dx/platform/mac/CCFileUtilsMac.mm b/cocos2dx/platform/mac/CCFileUtilsMac.mm deleted file mode 100644 index 340aa00562..0000000000 --- a/cocos2dx/platform/mac/CCFileUtilsMac.mm +++ /dev/null @@ -1,354 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2011 Zynga Inc. - -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. -****************************************************************************/ -#include "CCFileUtilsMac.h" -#import -#include -#include -#include "cocoa/CCString.h" -#include "CCFileUtils.h" -#include "CCDirector.h" -#include "CCSAXParser.h" -#include "CCDictionary.h" -#include "support/zip_support/unzip.h" - -NS_CC_BEGIN - -static void addValueToDict(id key, id value, Dictionary* pDict); -static void addObjectToNSDict(const char*key, Object* object, NSMutableDictionary *dict); - -static void addItemToArray(id item, Array *array) -{ - // add string value into array - if ([item isKindOfClass:[NSString class]]) { - String* pValue = new String([item UTF8String]); - - array->addObject(pValue); - pValue->release(); - return; - } - - // add number value into array(such as int, float, bool and so on) - if ([item isKindOfClass:[NSNumber class]]) { - NSString* pStr = [item stringValue]; - String* pValue = new String([pStr UTF8String]); - - array->addObject(pValue); - pValue->release(); - return; - } - - // add dictionary value into array - if ([item isKindOfClass:[NSDictionary class]]) { - Dictionary* pDictItem = new Dictionary(); - pDictItem->init(); - for (id subKey in [item allKeys]) { - id subValue = [item objectForKey:subKey]; - addValueToDict(subKey, subValue, pDictItem); - } - array->addObject(pDictItem); - pDictItem->release(); - return; - } - - // add array value into array - if ([item isKindOfClass:[NSArray class]]) { - Array *arrayItem = new Array(); - arrayItem->initWithCapacity( [item count] ); - for (id subItem in item) { - addItemToArray(subItem, arrayItem); - } - array->addObject(arrayItem); - arrayItem->release(); - return; - } -} - -static void addObjectToNSArray(Object *object, NSMutableArray *array) -{ - // add string into array - if (String *ccString = dynamic_cast(object)) { - NSString *strElement = [NSString stringWithCString:ccString->getCString() encoding:NSUTF8StringEncoding]; - [array addObject:strElement]; - return; - } - - // add array into array - if (Array *ccArray = dynamic_cast(object)) { - NSMutableArray *arrElement = [NSMutableArray array]; - Object *element = NULL; - CCARRAY_FOREACH(ccArray, element) - { - addObjectToNSArray(element, arrElement); - } - [array addObject:arrElement]; - return; - } - - // add dictionary value into array - if (Dictionary *ccDict = dynamic_cast(object)) { - NSMutableDictionary *dictElement = [NSMutableDictionary dictionary]; - DictElement *element = NULL; - CCDICT_FOREACH(ccDict, element) - { - addObjectToNSDict(element->getStrKey(), element->getObject(), dictElement); - } - [array addObject:dictElement]; - } - -} - -static void addValueToDict(id key, id value, Dictionary* pDict) -{ - // the key must be a string - CCASSERT([key isKindOfClass:[NSString class]], "The key should be a string!"); - std::string pKey = [key UTF8String]; - - // the value is a new dictionary - if ([value isKindOfClass:[NSDictionary class]]) { - Dictionary* pSubDict = new Dictionary(); - for (id subKey in [value allKeys]) { - id subValue = [value objectForKey:subKey]; - addValueToDict(subKey, subValue, pSubDict); - } - pDict->setObject(pSubDict, pKey.c_str()); - pSubDict->release(); - return; - } - - // the value is a string - if ([value isKindOfClass:[NSString class]]) { - String* pValue = new String([value UTF8String]); - - pDict->setObject(pValue, pKey.c_str()); - pValue->release(); - return; - } - - // the value is a number - if ([value isKindOfClass:[NSNumber class]]) { - NSString* pStr = [value stringValue]; - String* pValue = new String([pStr UTF8String]); - - pDict->setObject(pValue, pKey.c_str()); - pValue->release(); - return; - } - - // the value is a array - if ([value isKindOfClass:[NSArray class]]) { - Array *array = new Array(); - array->initWithCapacity([value count]); - for (id item in value) { - addItemToArray(item, array); - } - pDict->setObject(array, pKey.c_str()); - array->release(); - return; - } -} - -static void addObjectToNSDict(const char * key, Object* object, NSMutableDictionary *dict) -{ - NSString *NSkey = [NSString stringWithCString:key encoding:NSUTF8StringEncoding]; - - // the object is a Dictionary - if (Dictionary *ccDict = dynamic_cast(object)) { - NSMutableDictionary *dictElement = [NSMutableDictionary dictionary]; - DictElement *element = NULL; - CCDICT_FOREACH(ccDict, element) - { - addObjectToNSDict(element->getStrKey(), element->getObject(), dictElement); - } - - [dict setObject:dictElement forKey:NSkey]; - return; - } - - // the object is a String - if (String *element = dynamic_cast(object)) { - NSString *strElement = [NSString stringWithCString:element->getCString() encoding:NSUTF8StringEncoding]; - [dict setObject:strElement forKey:NSkey]; - return; - } - - // the object is a Array - if (Array *ccArray = dynamic_cast(object)) { - NSMutableArray *arrElement = [NSMutableArray array]; - Object *element = NULL; - CCARRAY_FOREACH(ccArray, element) - { - addObjectToNSArray(element, arrElement); - } - [dict setObject:arrElement forKey:NSkey]; - return; - } -} - -FileUtils* FileUtils::getInstance() -{ - if (s_sharedFileUtils == NULL) - { - s_sharedFileUtils = new FileUtilsMac(); - if(!s_sharedFileUtils->init()) - { - delete s_sharedFileUtils; - s_sharedFileUtils = NULL; - CCLOG("ERROR: Could not init CCFileUtilsMac"); - } - } - return s_sharedFileUtils; -} - - -static NSFileManager* s_fileManager = [NSFileManager defaultManager]; - -std::string FileUtilsMac::getWritablePath() -{ - // save to document folder - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - NSString *documentsDirectory = [paths objectAtIndex:0]; - std::string strRet = [documentsDirectory UTF8String]; - strRet.append("/"); - return strRet; -} - -bool FileUtilsMac::isFileExist(const std::string& strFilePath) -{ - if (0 == strFilePath.length()) - { - return false; - } - - bool bRet = false; - - if (strFilePath[0] != '/') - { - std::string path = strFilePath; - std::string file; - size_t pos = path.find_last_of("/"); - if (pos != std::string::npos) - { - file = path.substr(pos+1); - path = path.substr(0, pos+1); - NSString* fullpath = [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:file.c_str()] - ofType:nil - inDirectory:[NSString stringWithUTF8String:path.c_str()]]; - if (fullpath != nil) { - bRet = true; - } - } - } - else - { - // Search path is an absolute path. - if ([s_fileManager fileExistsAtPath:[NSString stringWithUTF8String:strFilePath.c_str()]]) { - bRet = true; - } - } - - return bRet; -} - -std::string FileUtilsMac::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) -{ - if (strDirectory[0] != '/') - { - NSString* fullpath = [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:strFilename.c_str()] - ofType:nil - inDirectory:[NSString stringWithUTF8String:strDirectory.c_str()]]; - if (fullpath != nil) { - return [fullpath UTF8String]; - } - } - else - { - std::string fullPath = strDirectory+strFilename; - // Search path is an absolute path. - if ([s_fileManager fileExistsAtPath:[NSString stringWithUTF8String:fullPath.c_str()]]) { - return fullPath; - } - } - return ""; -} - -bool FileUtilsMac::isAbsolutePath(const std::string& strPath) -{ - NSString* path = [NSString stringWithUTF8String:strPath.c_str()]; - return [path isAbsolutePath] ? true : false; -} - -Dictionary* FileUtilsMac::createDictionaryWithContentsOfFile(const std::string& filename) -{ - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str()); - NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; - NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath]; - - Dictionary* pRet = Dictionary::create(); - for (id key in [pDict allKeys]) { - id value = [pDict objectForKey:key]; - addValueToDict(key, value, pRet); - } - - return pRet; -} - -bool FileUtilsMac::writeToFile(Dictionary *dict, const std::string &fullPath) -{ - CCLOG("iOS||Mac Dictionary %d write to file %s", dict->_ID, fullPath.c_str()); - NSMutableDictionary *nsDict = [NSMutableDictionary dictionary]; - - DictElement *element = NULL; - CCDICT_FOREACH(dict, element) - { - addObjectToNSDict(element->getStrKey(), element->getObject(), nsDict); - } - - NSString *file = [NSString stringWithUTF8String:fullPath.c_str()]; - // do it atomically - return [nsDict writeToFile:file atomically:YES]; -} - -Array* FileUtilsMac::createArrayWithContentsOfFile(const std::string& filename) -{ - // NSString* pPath = [NSString stringWithUTF8String:pFileName]; - // NSString* pathExtension= [pPath pathExtension]; - // pPath = [pPath stringByDeletingPathExtension]; - // pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension]; - // fixing cannot read data using Array::createWithContentsOfFile - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str()); - NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; - NSArray* array = [NSArray arrayWithContentsOfFile:pPath]; - - Array* ret = Array::createWithCapacity( [array count] ); - for (id value in array) { - addItemToArray(value, ret); - } - - return ret; -} - - -NS_CC_END - diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 272605d861..33e67f1a4e 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -1089,7 +1089,7 @@ static unsigned char cc_2x2_white_image[] = { 0xFF, 0xFF, 0xFF, 0xFF }; -#define CC_2x2_WHITE_IMAGE_KEY "cc_2x2_white_image" +#define CC_2x2_WHITE_IMAGE_KEY "/cc_2x2_white_image" void Sprite::setTexture(Texture2D *texture) { @@ -1110,7 +1110,7 @@ void Sprite::setTexture(Texture2D *texture) bool isOK = image->initWithRawData(cc_2x2_white_image, sizeof(cc_2x2_white_image), 2, 2, 8); CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully."); - texture = TextureCache::getInstance()->addUIImage(image, CC_2x2_WHITE_IMAGE_KEY); + texture = TextureCache::getInstance()->addImage(image, CC_2x2_WHITE_IMAGE_KEY); CC_SAFE_RELEASE(image); } } diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 1f11b60eba..373f82c282 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -178,7 +178,7 @@ void TextureCache::addImageAsync(const char *path, Object *target, SEL_CallFuncO void TextureCache::loadImage() { - AsyncStruct *pAsyncStruct = nullptr; + AsyncStruct *asyncStruct = nullptr; while (true) { @@ -202,30 +202,30 @@ void TextureCache::loadImage() } else { - pAsyncStruct = pQueue->front(); + asyncStruct = pQueue->front(); pQueue->pop(); _asyncStructQueueMutex.unlock(); } - const char *filename = pAsyncStruct->filename.c_str(); + const char *filename = asyncStruct->filename.c_str(); // generate image - Image *pImage = new Image(); - if (pImage && !pImage->initWithImageFileThreadSafe(filename)) + Image *image = new Image(); + if (image && !image->initWithImageFileThreadSafe(filename)) { - CC_SAFE_RELEASE(pImage); + CC_SAFE_RELEASE(image); CCLOG("can not load %s", filename); continue; } // generate image info - ImageInfo *pImageInfo = new ImageInfo(); - pImageInfo->asyncStruct = pAsyncStruct; - pImageInfo->image = pImage; + ImageInfo *imageInfo = new ImageInfo(); + imageInfo->asyncStruct = asyncStruct; + imageInfo->image = image; // put the image info into the queue _imageInfoMutex.lock(); - _imageInfoQueue->push(pImageInfo); + _imageInfoQueue->push(imageInfo); _imageInfoMutex.unlock(); } @@ -250,21 +250,21 @@ void TextureCache::addImageAsyncCallBack(float dt) } else { - ImageInfo *pImageInfo = imagesQueue->front(); + ImageInfo *imageInfo = imagesQueue->front(); imagesQueue->pop(); _imageInfoMutex.unlock(); - AsyncStruct *pAsyncStruct = pImageInfo->asyncStruct; - Image *pImage = pImageInfo->image; + AsyncStruct *asyncStruct = imageInfo->asyncStruct; + Image *image = imageInfo->image; - Object *target = pAsyncStruct->target; - SEL_CallFuncO selector = pAsyncStruct->selector; - const char* filename = pAsyncStruct->filename.c_str(); + Object *target = asyncStruct->target; + SEL_CallFuncO selector = asyncStruct->selector; + const char* filename = asyncStruct->filename.c_str(); // generate texture in render thread Texture2D *texture = new Texture2D(); - texture->initWithImage(pImage); + texture->initWithImage(image); #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name @@ -280,9 +280,9 @@ void TextureCache::addImageAsyncCallBack(float dt) target->release(); } - pImage->release(); - delete pAsyncStruct; - delete pImageInfo; + image->release(); + delete asyncStruct; + delete imageInfo; --_asyncRefCount; if (0 == _asyncRefCount) @@ -297,47 +297,39 @@ Texture2D * TextureCache::addImage(const char * path) CCASSERT(path != NULL, "TextureCache: fileimage MUST not be NULL"); Texture2D * texture = NULL; - Image* pImage = NULL; + Image* image = NULL; // Split up directory and filename // MUTEX: // Needed since addImageAsync calls this method from a different thread - std::string pathKey = path; - - pathKey = FileUtils::getInstance()->fullPathForFilename(pathKey.c_str()); + std::string pathKey = FileUtils::getInstance()->fullPathForFilename(path); if (pathKey.size() == 0) { return NULL; } - texture = static_cast(_textures->objectForKey(pathKey.c_str())); + texture = static_cast(_textures->objectForKey(pathKey)); - std::string fullpath = pathKey; + std::string fullpath(pathKey); if (! texture) { - std::string lowerCase(pathKey); - for (unsigned int i = 0; i < lowerCase.length(); ++i) - { - lowerCase[i] = tolower(lowerCase[i]); - } // all images are handled by UIImage except PVR extension that is handled by our own handler do { - pImage = new Image(); - CC_BREAK_IF(NULL == pImage); + image = new Image(); + CC_BREAK_IF(NULL == image); - bool bRet = pImage->initWithImageFile(fullpath.c_str()); + bool bRet = image->initWithImageFile(fullpath.c_str()); CC_BREAK_IF(!bRet); texture = new Texture2D(); - if( texture && - texture->initWithImage(pImage) ) + if( texture && texture->initWithImage(image) ) { #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name VolatileTexture::addImageTexture(texture, fullpath.c_str()); #endif - _textures->setObject(texture, pathKey.c_str()); + _textures->setObject(texture, pathKey); texture->release(); } else @@ -347,30 +339,21 @@ Texture2D * TextureCache::addImage(const char * path) } while (0); } - CC_SAFE_RELEASE(pImage); + CC_SAFE_RELEASE(image); return texture; } -Texture2D* TextureCache::addUIImage(Image *image, const char *key) +Texture2D* TextureCache::addImage(Image *image, const char *key) { CCASSERT(image != NULL, "TextureCache: image MUST not be nil"); Texture2D * texture = NULL; - // textureForKey() use full path,so the key should be full path - std::string forKey; - if (key) - { - forKey = FileUtils::getInstance()->fullPathForFilename(key); - } - // Don't have to lock here, because addImageAsync() will not - // invoke opengl function in loading thread. - - do + do { // If key is nil, then create a new texture each time - if(key && (texture = (Texture2D *)_textures->objectForKey(forKey.c_str()))) + if(key && (texture = static_cast(_textures->objectForKey(key))) ) { break; } @@ -381,7 +364,7 @@ Texture2D* TextureCache::addUIImage(Image *image, const char *key) if(key && texture) { - _textures->setObject(texture, forKey.c_str()); + _textures->setObject(texture, key); texture->autorelease(); } else @@ -652,20 +635,20 @@ void VolatileTexture::reloadAllTextures() { case kImageFile: { - Image* pImage = new Image(); + Image* image = new Image(); unsigned long nSize = 0; unsigned char* pBuffer = FileUtils::getInstance()->getFileData(vt->_fileName.c_str(), "rb", &nSize); - if (pImage && pImage->initWithImageData(pBuffer, nSize)) + if (image && image->initWithImageData(pBuffer, nSize)) { Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat(); Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat); - vt->_texture->initWithImage(pImage); + vt->_texture->initWithImage(image); Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat); } CC_SAFE_DELETE_ARRAY(pBuffer); - CC_SAFE_RELEASE(pImage); + CC_SAFE_RELEASE(image); } break; case kImageData: diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index aa23aef997..d725dddf64 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -85,8 +85,8 @@ public: Dictionary* snapshotTextures(); - /** Returns a Texture2D object given an file image - * If the file image was not previously loaded, it will create a new Texture2D + /** Returns a Texture2D object given an filename. + * If the filename was not previously loaded, it will create a new Texture2D * object and it will return it. It will use the filename as a key. * Otherwise it will return a reference of a previously loaded image. * Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif @@ -102,13 +102,14 @@ public: */ virtual void addImageAsync(const char *path, Object *target, SEL_CallFuncO selector); - /** Returns a Texture2D object given an UIImage image + /** Returns a Texture2D object given an Image. * If the image was not previously loaded, it will create a new Texture2D object and it will return it. - * Otherwise it will return a reference of a previously loaded image + * Otherwise it will return a reference of a previously loaded image. * The "key" parameter will be used as the "key" for the cache. * If "key" is nil, then a new texture will be created each time. */ - Texture2D* addUIImage(Image *image, const char *key); + Texture2D* addImage(Image *image, const char *key); + CC_DEPRECATED_ATTRIBUTE Texture2D* addUIImage(Image *image, const char *key) { return addImage(image,key); } /** Returns an already created texture. Returns nil if the texture doesn't exist. @since v0.99.5 diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp index bbf9b67085..55da98b32d 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp @@ -280,7 +280,7 @@ void NodeDeallocTest::initWithQuantityOfNodes(unsigned int nNodes) { PerformceAllocScene::initWithQuantityOfNodes(nNodes); - printf("Size of Sprite: %lu\n", sizeof(Node)); + printf("Size of Node: %lu\n", sizeof(Node)); scheduleUpdate(); } @@ -333,7 +333,7 @@ void SpriteCreateEmptyTest::initWithQuantityOfNodes(unsigned int nNodes) { PerformceAllocScene::initWithQuantityOfNodes(nNodes); - printf("Size of Node: %lu\n", sizeof(Sprite)); + printf("Size of Sprite: %lu\n", sizeof(Sprite)); scheduleUpdate(); } @@ -383,7 +383,7 @@ void SpriteCreateTest::initWithQuantityOfNodes(unsigned int nNodes) { PerformceAllocScene::initWithQuantityOfNodes(nNodes); - printf("Size of Node: %lu\n", sizeof(Sprite)); + printf("Size of Sprite: %lu\n", sizeof(Sprite)); scheduleUpdate(); } @@ -406,7 +406,7 @@ void SpriteCreateTest::update(float dt) std::string SpriteCreateTest::title() { - return "Create Sprite."; + return "Create Sprite"; } std::string SpriteCreateTest::subtitle() @@ -433,7 +433,7 @@ void SpriteDeallocTest::initWithQuantityOfNodes(unsigned int nNodes) { PerformceAllocScene::initWithQuantityOfNodes(nNodes); - printf("Size of Node: %lu\n", sizeof(Sprite)); + printf("Size of sprite: %lu\n", sizeof(Sprite)); scheduleUpdate(); } From ef622b23bd6754b9cd8da13e3aaf8d35254766b0 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 6 Sep 2013 16:00:24 -0700 Subject: [PATCH 09/37] lazy alloc component container faster and less memory --- cocos2dx/base_nodes/CCNode.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index ef111dfbce..0ee44d3340 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -130,7 +130,6 @@ Node::Node(void) ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine(); _scriptType = pEngine != NULL ? pEngine->getScriptType() : kScriptTypeNone; - _componentContainer = new ComponentContainer(this); } Node::~Node() @@ -167,8 +166,6 @@ Node::~Node() // children CC_SAFE_RELEASE(_children); - // _comsContainer - _componentContainer->removeAll(); CC_SAFE_DELETE(_componentContainer); } @@ -1253,22 +1250,30 @@ void Node::updateTransform() Component* Node::getComponent(const char *pName) { - return _componentContainer->get(pName); + if( _componentContainer ) + return _componentContainer->get(pName); + return nullptr; } bool Node::addComponent(Component *pComponent) { + // lazy alloc + if( !_componentContainer ) + _componentContainer = new ComponentContainer(this); return _componentContainer->add(pComponent); } bool Node::removeComponent(const char *pName) { - return _componentContainer->remove(pName); + if( _componentContainer ) + return _componentContainer->remove(pName); + return false; } void Node::removeAllComponents() { - _componentContainer->removeAll(); + if( _componentContainer ) + _componentContainer->removeAll(); } // NodeRGBA From b2a81b5b8647f92f69a8d1d51fc7132bbcbf863e Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 6 Sep 2013 18:46:33 -0700 Subject: [PATCH 10/37] Removes some Hungarion notation... ...and improves performance in FileUtils: String is not created --- .../particle_nodes/CCParticleExamples.cpp | 2 +- cocos2dx/particle_nodes/CCParticleSystem.cpp | 2 +- cocos2dx/platform/CCFileUtils.cpp | 94 +++++++++---------- cocos2dx/platform/CCFileUtils.h | 16 ++-- .../RenderTextureTest/RenderTextureTest.cpp | 10 +- 5 files changed, 61 insertions(+), 63 deletions(-) diff --git a/cocos2dx/particle_nodes/CCParticleExamples.cpp b/cocos2dx/particle_nodes/CCParticleExamples.cpp index 3d69cae209..c33c2a41a2 100644 --- a/cocos2dx/particle_nodes/CCParticleExamples.cpp +++ b/cocos2dx/particle_nodes/CCParticleExamples.cpp @@ -50,7 +50,7 @@ static Texture2D* getDefaultTexture() bRet = pImage->initWithImageData(__firePngData, sizeof(__firePngData)); CC_BREAK_IF(!bRet); - texture = TextureCache::getInstance()->addUIImage(pImage, key); + texture = TextureCache::getInstance()->addImage(pImage, key); } while (0); CC_SAFE_RELEASE(pImage); diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 865d05ec86..499dc37fdf 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -372,7 +372,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn CCASSERT(isOK, "CCParticleSystem: error init image with Data"); CC_BREAK_IF(!isOK); - setTexture(TextureCache::getInstance()->addUIImage(image, textureName.c_str())); + setTexture(TextureCache::getInstance()->addImage(image, textureName.c_str())); image->release(); } diff --git a/cocos2dx/platform/CCFileUtils.cpp b/cocos2dx/platform/CCFileUtils.cpp index f783d0ac75..5bcfc20de5 100644 --- a/cocos2dx/platform/CCFileUtils.cpp +++ b/cocos2dx/platform/CCFileUtils.cpp @@ -488,41 +488,41 @@ void FileUtils::purgeCachedEntries() _fullPathCache.clear(); } -unsigned char* FileUtils::getFileData(const char* filename, const char* pszMode, unsigned long * pSize) +unsigned char* FileUtils::getFileData(const char* filename, const char* mode, unsigned long * size) { - unsigned char * pBuffer = NULL; - CCASSERT(filename != NULL && pSize != NULL && pszMode != NULL, "Invalid parameters."); - *pSize = 0; + unsigned char * buffer = NULL; + CCASSERT(filename != NULL && size != NULL && mode != NULL, "Invalid parameters."); + *size = 0; do { // read the file from hardware std::string fullPath = fullPathForFilename(filename); - FILE *fp = fopen(fullPath.c_str(), pszMode); + FILE *fp = fopen(fullPath.c_str(), mode); CC_BREAK_IF(!fp); fseek(fp,0,SEEK_END); - *pSize = ftell(fp); + *size = ftell(fp); fseek(fp,0,SEEK_SET); - pBuffer = new unsigned char[*pSize]; - *pSize = fread(pBuffer,sizeof(unsigned char), *pSize,fp); + buffer = new unsigned char[*size]; + *size = fread(buffer,sizeof(unsigned char), *size,fp); fclose(fp); } while (0); - if (! pBuffer) + if (! buffer) { std::string msg = "Get data from file("; msg.append(filename).append(") failed!"); CCLOG("%s", msg.c_str()); } - return pBuffer; + return buffer; } -unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const char* filename, unsigned long * pSize) +unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const char* filename, unsigned long * size) { - unsigned char * pBuffer = NULL; + unsigned char * buffer = NULL; unzFile pFile = NULL; - *pSize = 0; + *size = 0; do { @@ -543,11 +543,11 @@ unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const c nRet = unzOpenCurrentFile(pFile); CC_BREAK_IF(UNZ_OK != nRet); - pBuffer = new unsigned char[FileInfo.uncompressed_size]; - int CC_UNUSED nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed_size); + buffer = new unsigned char[FileInfo.uncompressed_size]; + int CC_UNUSED nSize = unzReadCurrentFile(pFile, buffer, FileInfo.uncompressed_size); CCASSERT(nSize == 0 || nSize == (int)FileInfo.uncompressed_size, "the file size is wrong"); - *pSize = FileInfo.uncompressed_size; + *size = FileInfo.uncompressed_size; unzCloseCurrentFile(pFile); } while (0); @@ -556,7 +556,7 @@ unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const c unzClose(pFile); } - return pBuffer; + return buffer; } std::string FileUtils::getNewFilename(const char* filename) @@ -601,21 +601,20 @@ std::string FileUtils::fullPathForFilename(const char* filename) { CCASSERT(filename != NULL, "CCFileUtils: Invalid path"); - std::string strFileName = filename; if (isAbsolutePath(filename)) { return filename; } - + // Already Cached ? auto cacheIter = _fullPathCache.find(filename); - if (cacheIter != _fullPathCache.end()) + if( cacheIter != _fullPathCache.end() ) { return cacheIter->second; } // Get the new file name. - std::string newFilename = getNewFilename(filename); + std::string newFilename( getNewFilename(filename) ); string fullpath = ""; @@ -640,26 +639,24 @@ std::string FileUtils::fullPathForFilename(const char* filename) return filename; } -const char* FileUtils::fullPathFromRelativeFile(const char *filename, const char *pszRelativeFile) +std::string FileUtils::fullPathFromRelativeFile(const char *filename, const char *relFile) { - std::string relativeFile = pszRelativeFile; - String *pRet = String::create(""); - pRet->_string = relativeFile.substr(0, relativeFile.rfind('/')+1); - pRet->_string += getNewFilename(filename); - return pRet->getCString(); + std::string relativeFile( relFile ); + + return relativeFile.substr(0, relativeFile.rfind('/')+1) + getNewFilename(filename); } void FileUtils::setSearchResolutionsOrder(const std::vector& searchResolutionsOrder) { - bool bExistDefault = false; + bool existDefault = false; _fullPathCache.clear(); _searchResolutionsOrderArray.clear(); - for (std::vector::const_iterator iter = searchResolutionsOrder.begin(); iter != searchResolutionsOrder.end(); ++iter) + for(auto iter = searchResolutionsOrder.begin(); iter != searchResolutionsOrder.end(); ++iter) { std::string resolutionDirectory = *iter; - if (!bExistDefault && resolutionDirectory == "") + if (!existDefault && resolutionDirectory == "") { - bExistDefault = true; + existDefault = true; } if (resolutionDirectory.length() > 0 && resolutionDirectory[resolutionDirectory.length()-1] != '/') @@ -669,7 +666,7 @@ void FileUtils::setSearchResolutionsOrder(const std::vector& search _searchResolutionsOrderArray.push_back(resolutionDirectory); } - if (!bExistDefault) + if (!existDefault) { _searchResolutionsOrderArray.push_back(""); } @@ -692,31 +689,32 @@ const std::vector& FileUtils::getSearchPaths() void FileUtils::setSearchPaths(const std::vector& searchPaths) { - bool bExistDefaultRootPath = false; + bool existDefaultRootPath = false; _fullPathCache.clear(); _searchPathArray.clear(); - for (std::vector::const_iterator iter = searchPaths.begin(); iter != searchPaths.end(); ++iter) + for (auto iter = searchPaths.begin(); iter != searchPaths.end(); ++iter) { std::string strPrefix; std::string path; + if (!isAbsolutePath(*iter)) { // Not an absolute path strPrefix = _defaultResRootPath; } - path = strPrefix+(*iter); + path = strPrefix + (*iter); if (path.length() > 0 && path[path.length()-1] != '/') { path += "/"; } - if (!bExistDefaultRootPath && path == _defaultResRootPath) + if (!existDefaultRootPath && path == _defaultResRootPath) { - bExistDefaultRootPath = true; + existDefaultRootPath = true; } _searchPathArray.push_back(path); } - if (!bExistDefaultRootPath) + if (!existDefaultRootPath) { //CCLOG("Default root path doesn't exist, adding it."); _searchPathArray.push_back(_defaultResRootPath); @@ -752,17 +750,17 @@ void FileUtils::loadFilenameLookupDictionaryFromFile(const char* filename) std::string fullPath = this->fullPathForFilename(filename); if (fullPath.length() > 0) { - Dictionary* pDict = Dictionary::createWithContentsOfFile(fullPath.c_str()); - if (pDict) + Dictionary* dict = Dictionary::createWithContentsOfFile(fullPath.c_str()); + if (dict) { - Dictionary* pMetadata = (Dictionary*)pDict->objectForKey("metadata"); - int version = ((String*)pMetadata->objectForKey("version"))->intValue(); + Dictionary* metadata = static_cast( dict->objectForKey("metadata") ); + int version = static_cast( metadata->objectForKey("version"))->intValue(); if (version != 1) { CCLOG("cocos2d: ERROR: Invalid filenameLookup dictionary version: %ld. Filename: %s", (long)version, filename); return; } - setFilenameLookupDictionary((Dictionary*)pDict->objectForKey("filenames")); + setFilenameLookupDictionary( static_cast( dict->objectForKey("filenames")) ); } } } @@ -785,22 +783,22 @@ std::string FileUtils::getFullPathForDirectoryAndFilename(const std::string& str bool FileUtils::isAbsolutePath(const std::string& strPath) { - return strPath[0] == '/' ? true : false; + return (strPath[0] == '/'); } ////////////////////////////////////////////////////////////////////////// // Notification support when getFileData from invalid file path. ////////////////////////////////////////////////////////////////////////// -static bool s_bPopupNotify = true; +static bool s_popupNotify = true; -void FileUtils::setPopupNotify(bool bNotify) +void FileUtils::setPopupNotify(bool notify) { - s_bPopupNotify = bNotify; + s_popupNotify = notify; } bool FileUtils::isPopupNotify() { - return s_bPopupNotify; + return s_popupNotify; } NS_CC_END diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index cc7478e156..467b2a4b0d 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -86,7 +86,7 @@ public: * @return Upon success, a pointer to the data is returned, otherwise NULL. * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ - virtual unsigned char* getFileData(const char* filename, const char* pszMode, unsigned long * pSize); + virtual unsigned char* getFileData(const char* filename, const char* mode, unsigned long * size); /** * Gets resource file data from a zip file. @@ -96,7 +96,7 @@ public: * @return Upon success, a pointer to the data is returned, otherwise NULL. * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ - virtual unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* filename, unsigned long *size); + virtual unsigned char* getFileDataFromZip(const char* zipFilePath, const char* filename, unsigned long *size); /** Returns the fullpath for a given filename. @@ -185,7 +185,7 @@ public: * @param pFilenameLookupDict The dictionary for replacing filename. * @since v2.1 */ - virtual void setFilenameLookupDictionary(Dictionary* pFilenameLookupDict); + virtual void setFilenameLookupDictionary(Dictionary* filenameLookupDict); /** * Gets full path from a file name and the path of the reletive file. @@ -196,7 +196,7 @@ public: * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. ) * */ - virtual const char* fullPathFromRelativeFile(const char *filename, const char *pszRelativeFile); + virtual std::string fullPathFromRelativeFile(const char *filename, const char *relativeFile); /** * Sets the array that contains the search order of the resources. @@ -270,7 +270,7 @@ public: * @param strFilePath The path of the file, it could be a relative or absolute path. * @return true if the file exists, otherwise it will return false. */ - virtual bool isFileExist(const std::string& strFilePath) = 0; + virtual bool isFileExist(const std::string& filePath) = 0; /** * Checks whether the path is an absolute path. @@ -281,13 +281,13 @@ public: * @param strPath The path that needs to be checked. * @return true if it's an absolute path, otherwise it will return false. */ - virtual bool isAbsolutePath(const std::string& strPath); + virtual bool isAbsolutePath(const std::string& path); /** * Sets/Gets whether to pop-up a message box when failed to load an image. */ - virtual void setPopupNotify(bool bNotify); + virtual void setPopupNotify(bool notify); virtual bool isPopupNotify(); protected: @@ -335,7 +335,7 @@ protected: * @param strFilename The name of the file. * @return The full path of the file, if the file can't be found, it will return an empty string. */ - virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename); + virtual std::string getFullPathForDirectoryAndFilename(const std::string& directory, const std::string& filename); /** * Creates a dictionary by the contents of a file. diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index 03431c852e..f2fc3eb142 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -133,12 +133,12 @@ string RenderTextureSave::subtitle() return "Press 'Save Image' to create an snapshot of the render texture"; } -void RenderTextureSave::clearImage(cocos2d::Object *pSender) +void RenderTextureSave::clearImage(cocos2d::Object *sender) { _target->clear(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1()); } -void RenderTextureSave::saveImage(cocos2d::Object *pSender) +void RenderTextureSave::saveImage(cocos2d::Object *sender) { static int counter = 0; @@ -151,11 +151,11 @@ void RenderTextureSave::saveImage(cocos2d::Object *pSender) _target->saveToFile(jpg, Image::Format::JPG); - auto pImage = _target->newImage(); + auto image = _target->newImage(); - auto tex = TextureCache::getInstance()->addUIImage(pImage, png); + auto tex = TextureCache::getInstance()->addImage(image, png); - CC_SAFE_DELETE(pImage); + CC_SAFE_DELETE(image); auto sprite = Sprite::createWithTexture(tex); From bf6750067fdd28d6e7bfd1fb2c7818250719f8ed Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 6 Sep 2013 19:00:12 -0700 Subject: [PATCH 11/37] little optimization. string is created when needed --- cocos2dx/textures/CCTextureCache.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 373f82c282..2e608952c4 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -309,9 +309,10 @@ Texture2D * TextureCache::addImage(const char * path) } texture = static_cast(_textures->objectForKey(pathKey)); - std::string fullpath(pathKey); - if (! texture) + if (! texture) { + std::string fullpath(pathKey); + // all images are handled by UIImage except PVR extension that is handled by our own handler do { From 3a0e957e9e0a7d7c2175f5161a6ebe01b5efe94a Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 6 Sep 2013 19:02:24 -0700 Subject: [PATCH 12/37] compatible with cocos2d c++ guidelines --- cocos2dx/textures/CCTexture2D.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index cd4e870979..9942ae22d9 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -119,22 +119,22 @@ public: struct PixelFormatInfo { - public: + + PixelFormatInfo(GLenum internalFormat, GLenum format, GLenum type, int bpp, bool compressed, bool alpha) + : internalFormat(internalFormat) + , format(format) + , type(type) + , bpp(bpp) + , compressed(compressed) + , alpha(alpha) + {} + GLenum internalFormat; GLenum format; GLenum type; int bpp; bool compressed; bool alpha; - - PixelFormatInfo(GLenum internalFormat, GLenum format, GLenum type, int bpp, bool compressed, bool alpha) - :internalFormat(internalFormat), - format(format), - type(type), - bpp(bpp), - compressed(compressed), - alpha(alpha) - {} }; typedef std::map PixelFormatInfoMap; From 2d2e15d2750cceddaa8ea684219732763ee7350d Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 6 Sep 2013 22:51:47 -0700 Subject: [PATCH 13/37] Key should start with '/' to gain performance Signed-off-by: Ricardo Quesada --- cocos2dx/particle_nodes/CCParticleExamples.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/particle_nodes/CCParticleExamples.cpp b/cocos2dx/particle_nodes/CCParticleExamples.cpp index c33c2a41a2..465e4af325 100644 --- a/cocos2dx/particle_nodes/CCParticleExamples.cpp +++ b/cocos2dx/particle_nodes/CCParticleExamples.cpp @@ -41,8 +41,8 @@ static Texture2D* getDefaultTexture() do { bool bRet = false; - const char* key = "__firePngData"; - texture = TextureCache::getInstance()->textureForKey(key); + const char* key = "/__firePngData"; + texture = TextureCache::getInstance()->getTextureForKey(key); CC_BREAK_IF(texture != NULL); pImage = new Image(); From 028deae84689787382f2cf17a4a31b3915f71774 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 6 Sep 2013 22:52:23 -0700 Subject: [PATCH 14/37] Adds const in FileUtils `const` was missing in some getters Signed-off-by: Ricardo Quesada --- cocos2dx/platform/android/CCFileUtilsAndroid.cpp | 6 +++--- cocos2dx/platform/android/CCFileUtilsAndroid.h | 7 ++++--- cocos2dx/platform/apple/CCFileUtilsApple.h | 12 ++++++------ cocos2dx/platform/apple/CCFileUtilsApple.mm | 8 ++++---- .../platform/emscripten/CCFileUtilsEmscripten.cpp | 6 +++--- cocos2dx/platform/emscripten/CCFileUtilsEmscripten.h | 7 ++++--- cocos2dx/platform/linux/CCFileUtilsLinux.cpp | 4 ++-- cocos2dx/platform/linux/CCFileUtilsLinux.h | 4 ++-- cocos2dx/platform/qt5/CCFileUtilsQt5.cpp | 4 ++-- cocos2dx/platform/tizen/CCFileUtilsTizen.cpp | 4 ++-- cocos2dx/platform/tizen/CCFileUtilsTizen.h | 4 ++-- cocos2dx/platform/win32/CCFileUtilsWin32.cpp | 6 +++--- cocos2dx/platform/win32/CCFileUtilsWin32.h | 6 +++--- 13 files changed, 40 insertions(+), 38 deletions(-) diff --git a/cocos2dx/platform/android/CCFileUtilsAndroid.cpp b/cocos2dx/platform/android/CCFileUtilsAndroid.cpp index 53e3096c74..d15e4f874a 100644 --- a/cocos2dx/platform/android/CCFileUtilsAndroid.cpp +++ b/cocos2dx/platform/android/CCFileUtilsAndroid.cpp @@ -76,7 +76,7 @@ bool FileUtilsAndroid::init() return FileUtils::init(); } -bool FileUtilsAndroid::isFileExist(const std::string& strFilePath) +bool FileUtilsAndroid::isFileExist(const std::string& strFilePath) const { if (0 == strFilePath.length()) { @@ -116,7 +116,7 @@ bool FileUtilsAndroid::isFileExist(const std::string& strFilePath) return bFound; } -bool FileUtilsAndroid::isAbsolutePath(const std::string& strPath) +bool FileUtilsAndroid::isAbsolutePath(const std::string& strPath) const { // On Android, there are two situations for full path. // 1) Files in APK, e.g. assets/path/path/file.png @@ -235,7 +235,7 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* return pData; } -string FileUtilsAndroid::getWritablePath() +string FileUtilsAndroid::getWritablePath() const { // Fix for Nexus 10 (Android 4.2 multi-user environment) // the path is retrieved through Java Context.getCacheDir() method diff --git a/cocos2dx/platform/android/CCFileUtilsAndroid.h b/cocos2dx/platform/android/CCFileUtilsAndroid.h index 8bf3b4d7a0..5eb56e0787 100644 --- a/cocos2dx/platform/android/CCFileUtilsAndroid.h +++ b/cocos2dx/platform/android/CCFileUtilsAndroid.h @@ -52,9 +52,10 @@ public: /* override funtions */ bool init(); virtual unsigned char* getFileData(const char* filename, const char* pszMode, unsigned long * pSize); - virtual std::string getWritablePath(); - virtual bool isFileExist(const std::string& strFilePath); - virtual bool isAbsolutePath(const std::string& strPath); + + virtual std::string getWritablePath() const; + virtual bool isFileExist(const std::string& strFilePath) const; + virtual bool isAbsolutePath(const std::string& strPath) const; /** This function is android specific. It is used for TextureCache::addImageAsync(). Don't use it in your codes. diff --git a/cocos2dx/platform/apple/CCFileUtilsApple.h b/cocos2dx/platform/apple/CCFileUtilsApple.h index 30102636b2..5be1708df1 100644 --- a/cocos2dx/platform/apple/CCFileUtilsApple.h +++ b/cocos2dx/platform/apple/CCFileUtilsApple.h @@ -42,14 +42,14 @@ class CC_DLL FileUtilsApple : public FileUtils { public: /* override funtions */ - virtual std::string getWritablePath(); - virtual bool isFileExist(const std::string& strFilePath); - virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename); + virtual std::string getWritablePath() const override; + virtual bool isFileExist(const std::string& strFilePath) const override; + virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) override; - virtual Dictionary* createDictionaryWithContentsOfFile(const std::string& filename); - virtual bool writeToFile(Dictionary *dict, const std::string& fullPath); + virtual Dictionary* createDictionaryWithContentsOfFile(const std::string& filename) override; + virtual bool writeToFile(Dictionary *dict, const std::string& fullPath) override; - virtual Array* createArrayWithContentsOfFile(const std::string& filename); + virtual Array* createArrayWithContentsOfFile(const std::string& filename) override; }; // end of platform group diff --git a/cocos2dx/platform/apple/CCFileUtilsApple.mm b/cocos2dx/platform/apple/CCFileUtilsApple.mm index ebbdaab6c5..5aae811b52 100644 --- a/cocos2dx/platform/apple/CCFileUtilsApple.mm +++ b/cocos2dx/platform/apple/CCFileUtilsApple.mm @@ -230,7 +230,7 @@ FileUtils* FileUtils::getInstance() } -std::string FileUtilsApple::getWritablePath() +std::string FileUtilsApple::getWritablePath() const { // save to document folder NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); @@ -240,7 +240,7 @@ std::string FileUtilsApple::getWritablePath() return strRet; } -bool FileUtilsApple::isFileExist(const std::string& strFilePath) +bool FileUtilsApple::isFileExist(const std::string& strFilePath) const { if(strFilePath.length() == 0) { @@ -306,7 +306,7 @@ std::string FileUtilsApple::getFullPathForDirectoryAndFilename(const std::string Dictionary* FileUtilsApple::createDictionaryWithContentsOfFile(const std::string& filename) { - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str()); + std::string fullPath = fullPathForFilename(filename); NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()]; NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath]; @@ -351,7 +351,7 @@ Array* FileUtilsApple::createArrayWithContentsOfFile(const std::string& filename // pPath = [pPath stringByDeletingPathExtension]; // pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension]; // fixing cannot read data using Array::createWithContentsOfFile - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str()); + std::string fullPath = fullPathForFilename(filename); NSString* path = [NSString stringWithUTF8String:fullPath.c_str()]; NSArray* array = [NSArray arrayWithContentsOfFile:path]; diff --git a/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.cpp b/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.cpp index f21ff121fa..3daf78d7d6 100644 --- a/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.cpp +++ b/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.cpp @@ -33,7 +33,7 @@ bool FileUtilsEmscripten::init() return FileUtils::init(); } -string FileUtilsEmscripten::getWritablePath() +string FileUtilsEmscripten::getWritablePath() const { // Let's write it in the current working directory's data folder char cwd[FILENAME_MAX] = {0}; @@ -47,7 +47,7 @@ string FileUtilsEmscripten::getWritablePath() return path; } -bool FileUtilsEmscripten::isAbsolutePath(const std::string& strPath) +bool FileUtilsEmscripten::isAbsolutePath(const std::string& strPath) const { if (strPath[0] == '/' || strPath.find(_defaultResRootPath) == 0) { @@ -56,7 +56,7 @@ bool FileUtilsEmscripten::isAbsolutePath(const std::string& strPath) return false; } -bool FileUtilsEmscripten::isFileExist(const std::string& strFilePath) +bool FileUtilsEmscripten::isFileExist(const std::string& strFilePath) const { std::string strPath = strFilePath; if (strPath[0] != '/') diff --git a/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.h b/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.h index e6ec10f82c..6825f3fae1 100644 --- a/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.h +++ b/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.h @@ -42,12 +42,13 @@ class CC_DLL FileUtilsEmscripten : public FileUtils { friend class FileUtils; FileUtilsEmscripten(); + public: /* override funtions */ bool init(); - virtual std::string getWritablePath(); - virtual bool isFileExist(const std::string& strFilePath); - virtual bool isAbsolutePath(const std::string& strPath); + virtual std::string getWritablePath() const; + virtual bool isFileExist(const std::string& strFilePath) const; + virtual bool isAbsolutePath(const std::string& strPath) const; }; // end of platform group diff --git a/cocos2dx/platform/linux/CCFileUtilsLinux.cpp b/cocos2dx/platform/linux/CCFileUtilsLinux.cpp index 90ff1e0e04..13a88a1c3d 100644 --- a/cocos2dx/platform/linux/CCFileUtilsLinux.cpp +++ b/cocos2dx/platform/linux/CCFileUtilsLinux.cpp @@ -67,7 +67,7 @@ bool FileUtilsLinux::init() return FileUtils::init(); } -string FileUtilsLinux::getWritablePath() +string FileUtilsLinux::getWritablePath() const { struct stat st; stat(_writablePath.c_str(), &st); @@ -78,7 +78,7 @@ string FileUtilsLinux::getWritablePath() return _writablePath; } -bool FileUtilsLinux::isFileExist(const std::string& strFilePath) +bool FileUtilsLinux::isFileExist(const std::string& strFilePath) const { if (0 == strFilePath.length()) { diff --git a/cocos2dx/platform/linux/CCFileUtilsLinux.h b/cocos2dx/platform/linux/CCFileUtilsLinux.h index 23552c3837..9aed872e80 100644 --- a/cocos2dx/platform/linux/CCFileUtilsLinux.h +++ b/cocos2dx/platform/linux/CCFileUtilsLinux.h @@ -46,8 +46,8 @@ class CC_DLL FileUtilsLinux : public FileUtils public: /* override funtions */ bool init(); - virtual std::string getWritablePath(); - virtual bool isFileExist(const std::string& strFilePath); + virtual std::string getWritablePath() const; + virtual bool isFileExist(const std::string& strFilePath) const; }; // end of platform group diff --git a/cocos2dx/platform/qt5/CCFileUtilsQt5.cpp b/cocos2dx/platform/qt5/CCFileUtilsQt5.cpp index 6c5f0f7653..3159a37dc5 100644 --- a/cocos2dx/platform/qt5/CCFileUtilsQt5.cpp +++ b/cocos2dx/platform/qt5/CCFileUtilsQt5.cpp @@ -84,7 +84,7 @@ FileUtilsQt5::init() } std::string -FileUtilsQt5::getWritablePath() +FileUtilsQt5::getWritablePath() const { QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); @@ -96,7 +96,7 @@ FileUtilsQt5::getWritablePath() return dir.path().toStdString(); } -bool FileUtilsQt5::isFileExist(const std::string& strFilePath) +bool FileUtilsQt5::isFileExist(const std::string& strFilePath) const { QString filePath = QString::fromStdString(strFilePath); diff --git a/cocos2dx/platform/tizen/CCFileUtilsTizen.cpp b/cocos2dx/platform/tizen/CCFileUtilsTizen.cpp index dad418107f..2653d427f8 100644 --- a/cocos2dx/platform/tizen/CCFileUtilsTizen.cpp +++ b/cocos2dx/platform/tizen/CCFileUtilsTizen.cpp @@ -80,7 +80,7 @@ bool FileUtilsTizen::init() return FileUtils::init(); } -string FileUtilsTizen::getWritablePath() +string FileUtilsTizen::getWritablePath() const { UiApp* pApp = UiApp::GetInstance(); if (!pApp) @@ -101,7 +101,7 @@ string FileUtilsTizen::getWritablePath() return path; } -bool FileUtilsTizen::isFileExist(const std::string& strFilePath) +bool FileUtilsTizen::isFileExist(const std::string& strFilePath) const { std::string strPath = strFilePath; if (!isAbsolutePath(strPath)) diff --git a/cocos2dx/platform/tizen/CCFileUtilsTizen.h b/cocos2dx/platform/tizen/CCFileUtilsTizen.h index b1c25b32ab..644f933446 100644 --- a/cocos2dx/platform/tizen/CCFileUtilsTizen.h +++ b/cocos2dx/platform/tizen/CCFileUtilsTizen.h @@ -47,8 +47,8 @@ class CC_DLL FileUtilsTizen : public FileUtils public: /* override funtions */ bool init(); - virtual std::string getWritablePath(); - virtual bool isFileExist(const std::string& strFilePath); + virtual std::string getWritablePath() const; + virtual bool isFileExist(const std::string& strFilePath) const; }; // end of platform group diff --git a/cocos2dx/platform/win32/CCFileUtilsWin32.cpp b/cocos2dx/platform/win32/CCFileUtilsWin32.cpp index 5f570a92b7..a5c94dac90 100644 --- a/cocos2dx/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos2dx/platform/win32/CCFileUtilsWin32.cpp @@ -91,7 +91,7 @@ bool FileUtilsWin32::init() return FileUtils::init(); } -bool FileUtilsWin32::isFileExist(const std::string& strFilePath) +bool FileUtilsWin32::isFileExist(const std::string& strFilePath) const { if (0 == strFilePath.length()) { @@ -110,7 +110,7 @@ bool FileUtilsWin32::isFileExist(const std::string& strFilePath) return GetFileAttributesW(utf16Buf) != -1 ? true : false; } -bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) +bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const { if ( strPath.length() > 2 && ( (strPath[0] >= 'a' && strPath[0] <= 'z') || (strPath[0] >= 'A' && strPath[0] <= 'Z') ) @@ -182,7 +182,7 @@ std::string FileUtilsWin32::getFullPathForDirectoryAndFilename(const std::string return FileUtils::getFullPathForDirectoryAndFilename(unixDirectory, unixFilename); } -string FileUtilsWin32::getWritablePath() +string FileUtilsWin32::getWritablePath() const { // Get full path of executable, e.g. c:\Program Files (x86)\My Game Folder\MyGame.exe char full_path[CC_MAX_PATH + 1]; diff --git a/cocos2dx/platform/win32/CCFileUtilsWin32.h b/cocos2dx/platform/win32/CCFileUtilsWin32.h index 6d6ae12e9f..bd52a82ede 100644 --- a/cocos2dx/platform/win32/CCFileUtilsWin32.h +++ b/cocos2dx/platform/win32/CCFileUtilsWin32.h @@ -45,9 +45,9 @@ class CC_DLL FileUtilsWin32 : public FileUtils public: /* override funtions */ bool init(); - virtual std::string getWritablePath(); - virtual bool isFileExist(const std::string& strFilePath); - virtual bool isAbsolutePath(const std::string& strPath); + virtual std::string getWritablePath() const; + virtual bool isFileExist(const std::string& strFilePath) const; + virtual bool isAbsolutePath(const std::string& strPath) const; protected: /** * Gets resource file data From 7d8261c722ddb5a293078a91b05d922c65fa61d0 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 6 Sep 2013 22:54:08 -0700 Subject: [PATCH 15/37] Optimization + standardization in FileUtils Since `FileUtils` was using `std::string` internally, it is more efficient to accept `const std::string &` as parameter than `char *` to avoid the creation of unneeded strings. Signed-off-by: Ricardo Quesada --- cocos2dx/platform/CCFileUtils.cpp | 44 +++++++++++++------------------ cocos2dx/platform/CCFileUtils.h | 20 +++++++------- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/cocos2dx/platform/CCFileUtils.cpp b/cocos2dx/platform/CCFileUtils.cpp index 5bcfc20de5..6f286607fb 100644 --- a/cocos2dx/platform/CCFileUtils.cpp +++ b/cocos2dx/platform/CCFileUtils.cpp @@ -518,7 +518,7 @@ unsigned char* FileUtils::getFileData(const char* filename, const char* mode, un return buffer; } -unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const char* filename, unsigned long * size) +unsigned char* FileUtils::getFileDataFromZip(const char* zipFilePath, const char* filename, unsigned long * size) { unsigned char * buffer = NULL; unzFile pFile = NULL; @@ -526,10 +526,10 @@ unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const c do { - CC_BREAK_IF(!pszZipFilePath || !filename); - CC_BREAK_IF(strlen(pszZipFilePath) == 0); + CC_BREAK_IF(!zipFilePath || !filename); + CC_BREAK_IF(strlen(zipFilePath) == 0); - pFile = unzOpen(pszZipFilePath); + pFile = unzOpen(zipFilePath); CC_BREAK_IF(!pFile); int nRet = unzLocateFile(pFile, filename, 1); @@ -559,9 +559,9 @@ unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const c return buffer; } -std::string FileUtils::getNewFilename(const char* filename) +std::string FileUtils::getNewFilename(const std::string &filename) { - const char* newFileName = NULL; + std::string newFileName; // in Lookup Filename dictionary ? String* fileNameFound = _filenameLookupDict ? (String*)_filenameLookupDict->objectForKey(filename) : NULL; @@ -597,10 +597,8 @@ std::string FileUtils::getPathForFilename(const std::string& filename, const std } -std::string FileUtils::fullPathForFilename(const char* filename) +std::string FileUtils::fullPathForFilename(const std::string &filename) { - CCASSERT(filename != NULL, "CCFileUtils: Invalid path"); - if (isAbsolutePath(filename)) { return filename; @@ -632,17 +630,15 @@ std::string FileUtils::fullPathForFilename(const char* filename) } } - CCLOG("cocos2d: fullPathForFilename: No file found at %s. Possible missing file.", filename); + CCLOG("cocos2d: fullPathForFilename: No file found at %s. Possible missing file.", filename.c_str()); // XXX: Should it return nullptr ? or an empty string ? // The file wasn't found, return the file name passed in. return filename; } -std::string FileUtils::fullPathFromRelativeFile(const char *filename, const char *relFile) +std::string FileUtils::fullPathFromRelativeFile(const std::string &filename, const std::string &relativeFile) { - std::string relativeFile( relFile ); - return relativeFile.substr(0, relativeFile.rfind('/')+1) + getNewFilename(filename); } @@ -672,7 +668,7 @@ void FileUtils::setSearchResolutionsOrder(const std::vector& search } } -void FileUtils::addSearchResolutionsOrder(const char* order) +void FileUtils::addSearchResolutionsOrder(const std::string &order) { _searchResolutionsOrderArray.push_back(order); } @@ -682,7 +678,7 @@ const std::vector& FileUtils::getSearchResolutionsOrder() return _searchResolutionsOrderArray; } -const std::vector& FileUtils::getSearchPaths() +const std::vector& FileUtils::getSearchPaths() const { return _searchPathArray; } @@ -721,15 +717,13 @@ void FileUtils::setSearchPaths(const std::vector& searchPaths) } } -void FileUtils::addSearchPath(const char* path_) +void FileUtils::addSearchPath(const std::string &searchpath) { std::string strPrefix; - std::string path(path_); - if (!isAbsolutePath(path)) - { // Not an absolute path + if (!isAbsolutePath(searchpath)) strPrefix = _defaultResRootPath; - } - path = strPrefix + path; + + std::string path = strPrefix + searchpath; if (path.length() > 0 && path[path.length()-1] != '/') { path += "/"; @@ -745,9 +739,9 @@ void FileUtils::setFilenameLookupDictionary(Dictionary* pFilenameLookupDict) CC_SAFE_RETAIN(_filenameLookupDict); } -void FileUtils::loadFilenameLookupDictionaryFromFile(const char* filename) +void FileUtils::loadFilenameLookupDictionaryFromFile(const std::string &filename) { - std::string fullPath = this->fullPathForFilename(filename); + std::string fullPath = fullPathForFilename(filename); if (fullPath.length() > 0) { Dictionary* dict = Dictionary::createWithContentsOfFile(fullPath.c_str()); @@ -757,7 +751,7 @@ void FileUtils::loadFilenameLookupDictionaryFromFile(const char* filename) int version = static_cast( metadata->objectForKey("version"))->intValue(); if (version != 1) { - CCLOG("cocos2d: ERROR: Invalid filenameLookup dictionary version: %ld. Filename: %s", (long)version, filename); + CCLOG("cocos2d: ERROR: Invalid filenameLookup dictionary version: %ld. Filename: %s", (long)version, filename.c_str()); return; } setFilenameLookupDictionary( static_cast( dict->objectForKey("filenames")) ); @@ -781,7 +775,7 @@ std::string FileUtils::getFullPathForDirectoryAndFilename(const std::string& str return ret; } -bool FileUtils::isAbsolutePath(const std::string& strPath) +bool FileUtils::isAbsolutePath(const std::string& strPath) const { return (strPath[0] == '/'); } diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index 467b2a4b0d..cff1d8fdb0 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -144,7 +144,7 @@ public: @since v2.1 */ - virtual std::string fullPathForFilename(const char* filename); + virtual std::string fullPathForFilename(const std::string &filename); /** * Loads the filenameLookup dictionary from the contents of a filename. @@ -177,7 +177,7 @@ public: * @since v2.1 */ - virtual void loadFilenameLookupDictionaryFromFile(const char* filename); + virtual void loadFilenameLookupDictionaryFromFile(const std::string &filename); /** * Sets the filenameLookup dictionary. @@ -196,7 +196,7 @@ public: * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. ) * */ - virtual std::string fullPathFromRelativeFile(const char *filename, const char *relativeFile); + virtual std::string fullPathFromRelativeFile(const std::string &filename, const std::string &relativeFile); /** * Sets the array that contains the search order of the resources. @@ -213,7 +213,7 @@ public: * @see setSearchResolutionsOrder(), fullPathForFilename(). * @since v2.1 */ - virtual void addSearchResolutionsOrder(const char* order); + virtual void addSearchResolutionsOrder(const std::string &order); /** * Gets the array that contains the search order of the resources. @@ -247,7 +247,7 @@ public: * * @since v2.1 */ - void addSearchPath(const char* path); + void addSearchPath(const std::string & path); /** * Gets the array of search paths. @@ -255,13 +255,13 @@ public: * @return The array of search paths. * @see fullPathForFilename(const char*). */ - virtual const std::vector& getSearchPaths(); + virtual const std::vector& getSearchPaths() const; /** * Gets the writable path. * @return The path that can be write/read a file in */ - virtual std::string getWritablePath() = 0; + virtual std::string getWritablePath() const = 0; /** * Checks whether a file exists. @@ -270,7 +270,7 @@ public: * @param strFilePath The path of the file, it could be a relative or absolute path. * @return true if the file exists, otherwise it will return false. */ - virtual bool isFileExist(const std::string& filePath) = 0; + virtual bool isFileExist(const std::string& filePath) const = 0; /** * Checks whether the path is an absolute path. @@ -281,7 +281,7 @@ public: * @param strPath The path that needs to be checked. * @return true if it's an absolute path, otherwise it will return false. */ - virtual bool isAbsolutePath(const std::string& path); + virtual bool isAbsolutePath(const std::string& path) const; /** @@ -313,7 +313,7 @@ protected: * @return The new filename after searching in the filename lookup dictionary. * If the original filename wasn't in the dictionary, it will return the original filename. */ - virtual std::string getNewFilename(const char* filename); + virtual std::string getNewFilename(const std::string &filename); /** * Gets full path for filename, resolution directory and search path. From 487f65af2e26fc6a6ea527a46443e84cb669938f Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 6 Sep 2013 22:55:11 -0700 Subject: [PATCH 16/37] Replaces `Dictionary` with `std::unordered_map` I did some performance tests, and `std::unordered_map` is more performant than `Dictionary`. I need to do more tests, but so far, the results are good. Signed-off-by: Ricardo Quesada --- cocos2dx/shaders/CCShaderCache.cpp | 56 +++----- cocos2dx/shaders/CCShaderCache.h | 11 +- cocos2dx/textures/CCTextureCache.cpp | 194 ++++++++++++--------------- cocos2dx/textures/CCTextureCache.h | 25 ++-- 4 files changed, 126 insertions(+), 160 deletions(-) diff --git a/cocos2dx/shaders/CCShaderCache.cpp b/cocos2dx/shaders/CCShaderCache.cpp index 82c20362d0..0c37ee339b 100644 --- a/cocos2dx/shaders/CCShaderCache.cpp +++ b/cocos2dx/shaders/CCShaderCache.cpp @@ -76,22 +76,22 @@ void ShaderCache::purgeSharedShaderCache() } ShaderCache::ShaderCache() -: _programs(0) +: _programs() { } ShaderCache::~ShaderCache() { + for( auto it = _programs.begin(); it != _programs.end(); ++it ) { + (it->second)->release(); + } + CCLOGINFO("deallocing ShaderCache: %p", this); - _programs->release(); } bool ShaderCache::init() -{ - _programs = Dictionary::create(); - _programs->retain(); - +{ loadDefaultShaders(); return true; } @@ -101,70 +101,54 @@ void ShaderCache::loadDefaultShaders() // Position Texture Color shader GLProgram *p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTextureColor); - - _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); - p->release(); + _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR, p ) ); // Position Texture Color alpha test p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); - - _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); - p->release(); + _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST, p) ); // // Position, Color shader // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionColor); - - _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_COLOR); - p->release(); + _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_COLOR, p) ); // // Position Texture shader // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTexture); - - _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE); - p->release(); + _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE, p) ); // // Position, Texture attribs, 1 Color as uniform shader // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTexture_uColor); - - _programs->setObject(p ,GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR); - p->release(); + _programs.insert( std::make_pair( GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR, p) ); // // Position Texture A8 Color shader // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTextureA8Color); - - _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR); - p->release(); + _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR, p) ); // // Position and 1 color passed as a uniform (to simulate glColor4ub ) // p = new GLProgram(); loadDefaultShader(p, kShaderType_Position_uColor); - - _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_U_COLOR); - p->release(); + _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_U_COLOR, p) ); // // Position, Legth(TexCoords, Color (used by Draw Node basically ) // p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionLengthTexureColor); - - _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR); - p->release(); + _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR, p) ); } void ShaderCache::reloadDefaultShaders() @@ -297,14 +281,18 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type) CHECK_GL_ERROR_DEBUG(); } -GLProgram* ShaderCache::programForKey(const char* key) +GLProgram* ShaderCache::programForKey(const std::string &key) { - return static_cast(_programs->objectForKey(key)); + auto it = _programs.find(key); + if( it != _programs.end() ) + return it->second; + return nullptr; } -void ShaderCache::addProgram(GLProgram* program, const char* key) +void ShaderCache::addProgram(GLProgram* program, const std::string &key) { - _programs->setObject(program, key); + program->retain(); + _programs.insert( std::make_pair( key, program) ); } NS_CC_END diff --git a/cocos2dx/shaders/CCShaderCache.h b/cocos2dx/shaders/CCShaderCache.h index deccfb065a..47581290c0 100644 --- a/cocos2dx/shaders/CCShaderCache.h +++ b/cocos2dx/shaders/CCShaderCache.h @@ -27,6 +27,9 @@ THE SOFTWARE. #ifndef __CCSHADERCACHE_H__ #define __CCSHADERCACHE_H__ +#include +#include + #include "cocoa/CCDictionary.h" NS_CC_BEGIN @@ -68,17 +71,17 @@ public: void reloadDefaultShaders(); /** returns a GL program for a given key */ - GLProgram * programForKey(const char* key); + GLProgram * programForKey(const std::string &key); /** adds a GLProgram to the cache for a given name */ - void addProgram(GLProgram* program, const char* key); + void addProgram(GLProgram* program, const std::string &key); private: bool init(); void loadDefaultShader(GLProgram *program, int type); - Dictionary* _programs; - +// Dictionary* _programs; + std::unordered_map _programs; }; // end of shaders group diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 2e608952c4..958316e2be 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -74,17 +74,14 @@ TextureCache::TextureCache() , _asyncRefCount(0) { CCASSERT(_sharedTextureCache == nullptr, "Attempted to allocate a second instance of a singleton."); - - _textures = new Dictionary(); - _textures->init(); - } TextureCache::~TextureCache() { CCLOGINFO("deallocing TextureCache: %p", this); - CC_SAFE_RELEASE(_textures); + for( auto it=_textures.begin(); it!=_textures.end(); ++it) + (it->second)->release(); CC_SAFE_DELETE(_loadingThread); _sharedTextureCache = nullptr; @@ -102,42 +99,34 @@ void TextureCache::destroyInstance() const char* TextureCache::description() const { - return String::createWithFormat("", _textures->count())->getCString(); + return String::createWithFormat("", _textures.size() )->getCString(); } -Dictionary* TextureCache::snapshotTextures() -{ - Dictionary* pRet = new Dictionary(); - DictElement* pElement = NULL; - CCDICT_FOREACH(_textures, pElement) - { - pRet->setObject(pElement->getObject(), pElement->getStrKey()); - } - pRet->autorelease(); - return pRet; -} +//Dictionary* TextureCache::snapshotTextures() +//{ +// Dictionary* pRet = new Dictionary(); +// DictElement* pElement = NULL; +// CCDICT_FOREACH(_textures, pElement) +// { +// pRet->setObject(pElement->getObject(), pElement->getStrKey()); +// } +// pRet->autorelease(); +// return pRet; +//} -void TextureCache::addImageAsync(const char *path, Object *target, SEL_CallFuncO selector) +void TextureCache::addImageAsync(const std::string &path, Object *target, SEL_CallFuncO selector) { - CCASSERT(path != NULL, "TextureCache: fileimage MUST not be NULL"); - Texture2D *texture = NULL; - // optimization + std::string fullpath = FileUtils::getInstance()->fullPathForFilename(path.c_str()); - std::string pathKey = path; + auto it = _textures.find(fullpath); + if( it != _textures.end() ) + texture = it->second; - pathKey = FileUtils::getInstance()->fullPathForFilename(pathKey.c_str()); - texture = static_cast(_textures->objectForKey(pathKey.c_str())); - - std::string fullpath = pathKey; - if (texture != NULL) + if (texture != NULL && target && selector) { - if (target && selector) - { - (target->*selector)(texture); - } - + (target->*selector)(texture); return; } @@ -270,8 +259,10 @@ void TextureCache::addImageAsyncCallBack(float dt) // cache the texture file name VolatileTexture::addImageTexture(texture, filename); #endif - // cache the texture - _textures->setObject(texture, filename); + // cache the texture. retain it, since it is added in the map + _textures.insert( std::make_pair(filename, texture) ); + texture->retain(); + texture->autorelease(); if (target && selector) @@ -292,27 +283,25 @@ void TextureCache::addImageAsyncCallBack(float dt) } } -Texture2D * TextureCache::addImage(const char * path) +Texture2D * TextureCache::addImage(const std::string &path) { - CCASSERT(path != NULL, "TextureCache: fileimage MUST not be NULL"); - Texture2D * texture = NULL; Image* image = NULL; // Split up directory and filename // MUTEX: // Needed since addImageAsync calls this method from a different thread - std::string pathKey = FileUtils::getInstance()->fullPathForFilename(path); - if (pathKey.size() == 0) + std::string fullpath = FileUtils::getInstance()->fullPathForFilename(path.c_str()); + if (fullpath.size() == 0) { return NULL; } - texture = static_cast(_textures->objectForKey(pathKey)); + auto it = _textures.find(fullpath); + if( it != _textures.end() ) + texture = it->second; if (! texture) { - std::string fullpath(pathKey); - // all images are handled by UIImage except PVR extension that is handled by our own handler do { @@ -330,12 +319,12 @@ Texture2D * TextureCache::addImage(const char * path) // cache the texture file name VolatileTexture::addImageTexture(texture, fullpath.c_str()); #endif - _textures->setObject(texture, pathKey); - texture->release(); + // texture already retained, no need to re-retain it + _textures.insert( std::make_pair(fullpath, texture) ); } else { - CCLOG("cocos2d: Couldn't create texture for file:%s in TextureCache", path); + CCLOG("cocos2d: Couldn't create texture for file:%s in TextureCache", path.c_str()); } } while (0); } @@ -345,7 +334,7 @@ Texture2D * TextureCache::addImage(const char * path) return texture; } -Texture2D* TextureCache::addImage(Image *image, const char *key) +Texture2D* TextureCache::addImage(Image *image, const std::string &key) { CCASSERT(image != NULL, "TextureCache: image MUST not be nil"); @@ -353,9 +342,9 @@ Texture2D* TextureCache::addImage(Image *image, const char *key) do { - // If key is nil, then create a new texture each time - if(key && (texture = static_cast(_textures->objectForKey(key))) ) - { + auto it = _textures.find(key); + if( it != _textures.end() ) { + texture = it->second; break; } @@ -363,9 +352,11 @@ Texture2D* TextureCache::addImage(Image *image, const char *key) texture = new Texture2D(); texture->initWithImage(image); - if(key && texture) + if(texture) { - _textures->setObject(texture, key); + _textures.insert( std::make_pair(key, texture) ); + texture->retain(); + texture->autorelease(); } else @@ -386,48 +377,25 @@ Texture2D* TextureCache::addImage(Image *image, const char *key) void TextureCache::removeAllTextures() { - _textures->removeAllObjects(); + for( auto it=_textures.begin(); it!=_textures.end(); ++it ) { + (it->second)->release(); + } + _textures.clear(); } void TextureCache::removeUnusedTextures() { - /* - DictElement* pElement = NULL; - CCDICT_FOREACH(_textures, pElement) - { - CCLOG("cocos2d: TextureCache: texture: %s", pElement->getStrKey()); - Texture2D *value = static_cast(pElement->getObject()); - if (value->retainCount() == 1) - { - CCLOG("cocos2d: TextureCache: removing unused texture: %s", pElement->getStrKey()); - _textures->removeObjectForElememt(pElement); - } - } - */ - - /** Inter engineer zhuoshi sun finds that this way will get better performance - */ - if (_textures->count()) - { - // find elements to be removed - DictElement* pElement = NULL; - list elementToRemove; - CCDICT_FOREACH(_textures, pElement) - { - CCLOG("cocos2d: TextureCache: texture: %s", pElement->getStrKey()); - Texture2D *value = static_cast(pElement->getObject()); - if (value->retainCount() == 1) - { - elementToRemove.push_back(pElement); - } - } - - // remove elements - for (auto iter = elementToRemove.begin(); iter != elementToRemove.end(); ++iter) - { - CCLOG("cocos2d: TextureCache: removing unused texture: %s", (*iter)->getStrKey()); - _textures->removeObjectForElememt(*iter); + for( auto it=_textures.cbegin(); it!=_textures.cend(); /* nothing */) { + Texture2D *tex = it->second; + if( tex->retainCount() == 1 ) { + CCLOG("cocos2d: TextureCache: removing unused texture: %s", it->first.c_str()); + + tex->release(); + _textures.erase(it++); + } else { + ++it; } + } } @@ -438,24 +406,31 @@ void TextureCache::removeTexture(Texture2D* texture) return; } - Array* keys = _textures->allKeysForObject(texture); - _textures->removeObjectsForKeys(keys); -} - -void TextureCache::removeTextureForKey(const char *textureKeyName) -{ - if (textureKeyName == NULL) - { - return; + for( auto it=_textures.cbegin(); it!=_textures.cend(); /* nothing */ ) { + if( it->second == texture ) { + texture->release(); + _textures.erase(it++); + break; + } else + ++it; } - - string fullPath = FileUtils::getInstance()->fullPathForFilename(textureKeyName); - _textures->removeObjectForKey(fullPath); } -Texture2D* TextureCache::textureForKey(const char* key) +void TextureCache::removeTextureForKey(const std::string &textureKeyName) { - return static_cast(_textures->objectForKey(FileUtils::getInstance()->fullPathForFilename(key))); + auto it = _textures.find(textureKeyName); + if( it != _textures.end() ) { + (it->second)->release(); + _textures.erase(it); + } +} + +Texture2D* TextureCache::getTextureForKey(const std::string &key) const +{ + auto it = _textures.find(key); + if( it != _textures.end() ) + return it->second; + return NULL; } void TextureCache::reloadAllTextures() @@ -465,22 +440,21 @@ void TextureCache::reloadAllTextures() #endif } -void TextureCache::dumpCachedTextureInfo() +void TextureCache::dumpCachedTextureInfo() const { unsigned int count = 0; unsigned int totalBytes = 0; - DictElement* pElement = NULL; - CCDICT_FOREACH(_textures, pElement) - { - Texture2D* tex = static_cast(pElement->getObject()); + for( auto it = _textures.begin(); it != _textures.end(); ++it ) { + + Texture2D* tex = it->second; unsigned int bpp = tex->getBitsPerPixelForFormat(); // Each texture takes up width * height * bytesPerPixel bytes. unsigned int bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8; totalBytes += bytes; count++; - CCLOG("cocos2d: \"%s\" rc=%lu id=%lu %lu x %lu @ %ld bpp => %lu KB", - pElement->getStrKey(), + log("cocos2d: \"%s\" rc=%lu id=%lu %lu x %lu @ %ld bpp => %lu KB", + it->first.c_str(), (long)tex->retainCount(), (long)tex->getName(), (long)tex->getPixelsWide(), @@ -489,7 +463,7 @@ void TextureCache::dumpCachedTextureInfo() (long)bytes / 1024); } - CCLOG("cocos2d: TextureCache dumpDebugInfo: %ld textures, for %lu KB (%.2f MB)", (long)count, (long)totalBytes / 1024, totalBytes / (1024.0f*1024.0f)); + log("cocos2d: TextureCache dumpDebugInfo: %ld textures, for %lu KB (%.2f MB)", (long)count, (long)totalBytes / 1024, totalBytes / (1024.0f*1024.0f)); } #if CC_ENABLE_CACHE_TEXTURE_DATA diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index d725dddf64..0a922a0807 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -33,9 +33,9 @@ THE SOFTWARE. #include #include #include +#include #include "cocoa/CCObject.h" -#include "cocoa/CCDictionary.h" #include "textures/CCTexture2D.h" #include "platform/CCImage.h" @@ -83,7 +83,7 @@ public: const char* description(void) const; - Dictionary* snapshotTextures(); +// Dictionary* snapshotTextures(); /** Returns a Texture2D object given an filename. * If the filename was not previously loaded, it will create a new Texture2D @@ -91,7 +91,7 @@ public: * Otherwise it will return a reference of a previously loaded image. * Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif */ - Texture2D* addImage(const char* fileimage); + Texture2D* addImage(const std::string &filepath); /* Returns a Texture2D object given a file image * If the file image was not previously loaded, it will create a new Texture2D object and it will return it. @@ -100,7 +100,7 @@ public: * Supported image extensions: .png, .jpg * @since v0.8 */ - virtual void addImageAsync(const char *path, Object *target, SEL_CallFuncO selector); + virtual void addImageAsync(const std::string &filepath, Object *target, SEL_CallFuncO selector); /** Returns a Texture2D object given an Image. * If the image was not previously loaded, it will create a new Texture2D object and it will return it. @@ -108,13 +108,14 @@ public: * The "key" parameter will be used as the "key" for the cache. * If "key" is nil, then a new texture will be created each time. */ - Texture2D* addImage(Image *image, const char *key); + Texture2D* addImage(Image *image, const std::string &key); CC_DEPRECATED_ATTRIBUTE Texture2D* addUIImage(Image *image, const char *key) { return addImage(image,key); } /** Returns an already created texture. Returns nil if the texture doesn't exist. @since v0.99.5 */ - Texture2D* textureForKey(const char* key); + Texture2D* getTextureForKey(const std::string& key) const; + CC_DEPRECATED_ATTRIBUTE Texture2D* textureForKey(const char* key) const { return getTextureForKey(key); } /** Purges the dictionary of loaded textures. * Call this method if you receive the "Memory Warning" @@ -138,14 +139,14 @@ public: /** Deletes a texture from the cache given a its key name @since v0.99.4 */ - void removeTextureForKey(const char *textureKeyName); + void removeTextureForKey(const std::string &key); /** Output to CCLOG the current contents of this TextureCache * This will attempt to calculate the size of each texture, and the total texture memory in use * * @since v1.0 */ - void dumpCachedTextureInfo(); + void dumpCachedTextureInfo() const; private: void addImageAsyncCallBack(float dt); @@ -157,9 +158,9 @@ public: public: AsyncStruct(const std::string& fn, Object *t, SEL_CallFuncO s) : filename(fn), target(t), selector(s) {} - std::string filename; - Object *target; - SEL_CallFuncO selector; + std::string filename; + Object *target; + SEL_CallFuncO selector; }; protected: @@ -184,7 +185,7 @@ protected: int _asyncRefCount; - Dictionary* _textures; + std::unordered_map _textures; static TextureCache *_sharedTextureCache; }; From 8078a574c21b3755ee746adb4269cc6d9086cdf3 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 6 Sep 2013 22:55:36 -0700 Subject: [PATCH 17/37] snapshopTextures are no longer supported Signed-off-by: Ricardo Quesada --- .../Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp b/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp index 476a126ad4..4f8a1fb932 100644 --- a/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DataVisitorTest/DataVisitorTest.cpp @@ -71,9 +71,9 @@ void PrettyPrinterDemo::onEnter() vistor.clear(); addSprite(); - dict = TextureCache::getInstance()->snapshotTextures(); - dict->acceptVisitor(vistor); - log("%s", vistor.getResult().c_str()); +// dict = TextureCache::getInstance()->snapshotTextures(); +// dict->acceptVisitor(vistor); +// log("%s", vistor.getResult().c_str()); } void DataVisitorTestScene::runThisTest() From a4ca30b9c33dc2f38ed5421d0ebc43073bd6a406 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Mon, 9 Sep 2013 02:55:48 +0000 Subject: [PATCH 18/37] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/auto-generated b/scripting/auto-generated index f966a8fc67..e57e43aaf1 160000 --- a/scripting/auto-generated +++ b/scripting/auto-generated @@ -1 +1 @@ -Subproject commit f966a8fc67e1a388b167c8b56279ff3e444b3351 +Subproject commit e57e43aaf1aea16ecefad50de1c7db8c401468a5 From 3a4c9f9fb0eacf69f499cc552eecbd511c90091e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=89=E1=85=A5=E1=86=BC=E1=84=82=E1=85=A1=E1=86=A8?= =?UTF-8?q?=E1=84=92=E1=85=A9?= Date: Mon, 9 Sep 2013 17:07:32 +0900 Subject: [PATCH 19/37] men leak fixed (life-cycle management was hand downed to scene-graph) --- samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp index 4768e7d038..52e45d963d 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp @@ -146,6 +146,7 @@ bool UpdateLayer::init() pAssetsManager->setDelegate(this); pAssetsManager->setConnectionTimeout(3); addChild(pAssetsManager); + pAssetsManager->release(); createDownloadedDir(); From d763de3d3cce41d071a08d126faab57f03e31c0a Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 9 Sep 2013 17:49:13 +0800 Subject: [PATCH 21/37] new shader test code --- .../Classes/ShaderTest/ShaderTest2.cpp | 535 ++++++++++++++++++ .../TestCpp/Classes/ShaderTest/ShaderTest2.h | 88 +++ samples/Cpp/TestCpp/Classes/controller.cpp | 1 + samples/Cpp/TestCpp/Classes/tests.h | 1 + .../project.pbxproj.REMOVED.git-id | 2 +- 5 files changed, 626 insertions(+), 1 deletion(-) create mode 100644 samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp create mode 100644 samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp new file mode 100644 index 0000000000..ce0043c355 --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp @@ -0,0 +1,535 @@ +#include "ShaderTest2.h" +#include "ShaderTest.h" +#include "../testResource.h" +#include "cocos2d.h" + +namespace ShaderTest2 +{ + static std::function createFunctions[] = + { + CL(NormalSpriteTest), + CL(GreyScaleSpriteTest), + CL(BlurSpriteTest), + CL(NoiseSpriteTest), + CL(EdgeDetectionSpriteTest), + CL(BloomSpriteTest), + CL(CelShadingSpriteTest), + CL(FlameTest3) + }; + + static unsigned int TEST_CASE_COUNT = sizeof(ShaderTest2::createFunctions) / sizeof(ShaderTest2::createFunctions[0]); + + static int sceneIdx=-1; + Layer* createTest(int index) + { + auto layer = (createFunctions[index])();; + + if (layer) + { + layer->autorelease(); + } + + return layer; + } + + Layer* nextAction(); + Layer* backAction(); + Layer* restartAction(); + + Layer* nextAction() + { + sceneIdx++; + sceneIdx = sceneIdx % TEST_CASE_COUNT; + + return createTest(sceneIdx); + } + + Layer* backAction() + { + sceneIdx--; + if( sceneIdx < 0 ) + sceneIdx = TEST_CASE_COUNT -1; + + return createTest(sceneIdx); + } + + Layer* restartAction() + { + return createTest(sceneIdx); + } + +} + +ShaderTestDemo2::ShaderTestDemo2() +{ + +} + +void ShaderTestDemo2::backCallback(Object* sender) +{ + auto s = new ShaderTestScene2(); + s->addChild( ShaderTest2::backAction() ); + Director::getInstance()->replaceScene(s); + s->release(); +} + +void ShaderTestDemo2::nextCallback(Object* sender) +{ + auto s = new ShaderTestScene2();//CCScene::create(); + s->addChild( ShaderTest2::nextAction() ); + Director::getInstance()->replaceScene(s); + s->release(); +} + +void ShaderTestDemo2::restartCallback(Object* sender) +{ + auto s = new ShaderTestScene2(); + s->addChild(ShaderTest2::restartAction()); + + Director::getInstance()->replaceScene(s); + s->release(); +} + +void ShaderTestScene2::runThisTest() +{ + auto layer = ShaderTest2::nextAction(); + addChild(layer); + Director::getInstance()->replaceScene(this); +} + +template +class ShaderSpriteCreator +{ +public: + static spriteType* createSprite(const char* pszFileName) + { + spriteType* pRet = new spriteType(); + if (pRet && pRet->initWithFile(pszFileName)) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + return pRet; + } +}; + +class ShaderSprite : public Sprite +{ +public: + ShaderSprite(); + ~ShaderSprite(); + + bool initWithTexture(Texture2D* texture, const Rect& rect); + void draw(); + void initProgram(); + void listenBackToForeground(Object *obj); + +protected: + virtual void buildCustomUniforms() = 0; + virtual void setCustomUniforms() = 0; +protected: + std::string _fragSourceFile; + +}; + +ShaderSprite::ShaderSprite() +{ +} + +ShaderSprite::~ShaderSprite() +{ + NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); +} + +void ShaderSprite::listenBackToForeground(Object *obj) +{ + setShaderProgram(NULL); + initProgram(); +} + +bool ShaderSprite::initWithTexture(Texture2D* texture, const Rect& rect) +{ + if( Sprite::initWithTexture(texture, rect) ) + { + NotificationCenter::getInstance()->addObserver(this, + callfuncO_selector(ShaderSprite::listenBackToForeground), + EVNET_COME_TO_FOREGROUND, + NULL); + + this->initProgram(); + + return true; + } + + return false; +} + +void ShaderSprite::initProgram() +{ + GLchar * fragSource = (GLchar*) String::createWithContentsOfFile( + FileUtils::getInstance()->fullPathForFilename(_fragSourceFile.c_str()).c_str())->getCString(); + auto pProgram = new GLProgram(); + pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource); + setShaderProgram(pProgram); + pProgram->release(); + + CHECK_GL_ERROR_DEBUG(); + + getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); + getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); + + CHECK_GL_ERROR_DEBUG(); + + getShaderProgram()->link(); + + CHECK_GL_ERROR_DEBUG(); + + getShaderProgram()->updateUniforms(); + + CHECK_GL_ERROR_DEBUG(); + + buildCustomUniforms(); + + CHECK_GL_ERROR_DEBUG(); +} + +void ShaderSprite::draw() +{ + GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); + BlendFunc blend = getBlendFunc(); + GL::blendFunc(blend.src, blend.dst); + + getShaderProgram()->use(); + getShaderProgram()->setUniformsForBuiltins(); + setCustomUniforms(); + + GL::bindTexture2D( getTexture()->getName()); + + // + // Attributes + // +#define kQuadSize sizeof(_quad.bl) + long offset = (long)&_quad; + + // vertex + int diff = offsetof( V3F_C4B_T2F, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + + // texCoods + diff = offsetof( V3F_C4B_T2F, texCoords); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + + // color + diff = offsetof( V3F_C4B_T2F, colors); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); + + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + CC_INCREMENT_GL_DRAWS(1); +} + +class NormalSprite : public ShaderSprite, public ShaderSpriteCreator +{ +public: + NormalSprite(); +protected: + virtual void buildCustomUniforms(); + virtual void setCustomUniforms(); +}; + +NormalSprite::NormalSprite() +{ + _fragSourceFile = "Shaders/example_normal.fsh"; +} + +void NormalSprite::buildCustomUniforms() +{ + +} + +void NormalSprite::setCustomUniforms() +{ + +} + +class GreyScaleSprite : public ShaderSprite, public ShaderSpriteCreator +{ +public: + GreyScaleSprite(); +protected: + virtual void buildCustomUniforms(); + virtual void setCustomUniforms(); +}; + +GreyScaleSprite::GreyScaleSprite() +{ + _fragSourceFile = "Shaders/example_greyScale.fsh"; +} + +void GreyScaleSprite::buildCustomUniforms() +{ + +} + +void GreyScaleSprite::setCustomUniforms() +{ + +} + +class BlurSprite : public ShaderSprite, public ShaderSpriteCreator +{ +public: + BlurSprite(); + void setBlurSize(float f); +protected: + virtual void buildCustomUniforms(); + virtual void setCustomUniforms(); +protected: + Point blur_; + GLfloat sub_[4]; + + GLuint blurLocation; + GLuint subLocation; +}; + +BlurSprite::BlurSprite() +{ + _fragSourceFile = "Shaders/example_Blur.fsh"; +} + +void BlurSprite::buildCustomUniforms() +{ + auto s = getTexture()->getContentSizeInPixels(); + + blur_ = Point(1/s.width, 1/s.height); + sub_[0] = sub_[1] = sub_[2] = sub_[3] = 0; + + subLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "substract"); + blurLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "blurSize"); +} + +void BlurSprite::setCustomUniforms() +{ + + getShaderProgram()->setUniformLocationWith2f(blurLocation, blur_.x, blur_.y); + getShaderProgram()->setUniformLocationWith4fv(subLocation, sub_, 1); +} + +void BlurSprite::setBlurSize(float f) +{ + auto s = getTexture()->getContentSizeInPixels(); + + blur_ = Point(1/s.width, 1/s.height); + blur_ = blur_ * f; +} + +class NoiseSprite : public ShaderSprite, public ShaderSpriteCreator +{ +public: + NoiseSprite(); + +private: + GLfloat _resolution[2]; + GLuint _resolutionLoc; +protected: + virtual void buildCustomUniforms(); + virtual void setCustomUniforms(); +}; + +NoiseSprite::NoiseSprite() +{ + _fragSourceFile = "Shaders/example_Noisy.fsh"; +} + +void NoiseSprite::buildCustomUniforms() +{ + _resolutionLoc = glGetUniformLocation( getShaderProgram()->getProgram(), "resolution"); +} + +void NoiseSprite::setCustomUniforms() +{ + _resolution[0] = getTexture()->getContentSizeInPixels().width; + _resolution[1] = getTexture()->getContentSizeInPixels().height; + + getShaderProgram()->setUniformLocationWith2fv(_resolutionLoc, _resolution, 1); +} + +class EdgeDetectionSprite : public ShaderSprite, public ShaderSpriteCreator +{ +public: + EdgeDetectionSprite(); + +private: + GLfloat _resolution[2]; + GLuint _resolutionLoc; +protected: + virtual void buildCustomUniforms(); + virtual void setCustomUniforms(); +}; + +EdgeDetectionSprite::EdgeDetectionSprite() +{ + _fragSourceFile = "Shaders/example_edgeDetection.fsh"; +} + +void EdgeDetectionSprite::buildCustomUniforms() +{ + _resolutionLoc = glGetUniformLocation( getShaderProgram()->getProgram(), "resolution"); +} + +void EdgeDetectionSprite::setCustomUniforms() +{ + _resolution[0] = getTexture()->getContentSizeInPixels().width; + _resolution[1] = getTexture()->getContentSizeInPixels().height; + + getShaderProgram()->setUniformLocationWith2fv(_resolutionLoc, _resolution, 1); +} + +class BloomSprite : public ShaderSprite, public ShaderSpriteCreator +{ +public: + BloomSprite(); + +private: + GLfloat _resolution[2]; + GLuint _resolutionLoc; +protected: + virtual void buildCustomUniforms(); + virtual void setCustomUniforms(); +}; + +BloomSprite::BloomSprite() +{ + _fragSourceFile = "Shaders/example_bloom.fsh"; +} + +void BloomSprite::buildCustomUniforms() +{ + _resolutionLoc = glGetUniformLocation( getShaderProgram()->getProgram(), "resolution"); +} + +void BloomSprite::setCustomUniforms() +{ + _resolution[0] = getTexture()->getContentSizeInPixels().width; + _resolution[1] = getTexture()->getContentSizeInPixels().height; + + getShaderProgram()->setUniformLocationWith2fv(_resolutionLoc, _resolution, 1); +} + +class CelShadingSprite : public ShaderSprite, public ShaderSpriteCreator +{ +public: + CelShadingSprite(); + +private: + GLfloat _resolution[2]; + GLuint _resolutionLoc; +protected: + virtual void buildCustomUniforms(); + virtual void setCustomUniforms(); +}; + +CelShadingSprite::CelShadingSprite() +{ + _fragSourceFile = "Shaders/example_celShading.fsh"; +} + +void CelShadingSprite::buildCustomUniforms() +{ + _resolutionLoc = glGetUniformLocation( getShaderProgram()->getProgram(), "resolution"); +} + +void CelShadingSprite::setCustomUniforms() +{ + _resolution[0] = getTexture()->getContentSizeInPixels().width; + _resolution[1] = getTexture()->getContentSizeInPixels().height; + + getShaderProgram()->setUniformLocationWith2fv(_resolutionLoc, _resolution, 1); +} + +NormalSpriteTest::NormalSpriteTest() +{ + if (ShaderTestDemo2::init()) + { + auto s = Director::getInstance()->getWinSize(); + NormalSprite* sprite = NormalSprite::createSprite("Images/powered.png"); + sprite->setPosition(Point(s.width/2, s.height/2)); + addChild(sprite); + } + +} + +GreyScaleSpriteTest::GreyScaleSpriteTest() +{ + if (ShaderTestDemo2::init()) + { + auto s = Director::getInstance()->getWinSize(); + GreyScaleSprite* sprite = GreyScaleSprite::createSprite("Images/powered.png"); + sprite->setPosition(Point(s.width/2, s.height/2)); + addChild(sprite); + } + +} + +BlurSpriteTest::BlurSpriteTest() +{ + if (ShaderTestDemo2::init()) + { + auto s = Director::getInstance()->getWinSize(); + BlurSprite* sprite = BlurSprite::createSprite("Images/powered.png"); + sprite->setPosition(Point(s.width/2, s.height/2)); + sprite->setBlurSize(1.5); + addChild(sprite); + } + +} + +NoiseSpriteTest::NoiseSpriteTest() +{ + if (ShaderTestDemo2::init()) + { + auto s = Director::getInstance()->getWinSize(); + NoiseSprite* sprite = NoiseSprite::createSprite("Images/powered.png"); + sprite->setPosition(Point(s.width/2, s.height/2)); + addChild(sprite); + } +} + +EdgeDetectionSpriteTest::EdgeDetectionSpriteTest() +{ + if (ShaderTestDemo2::init()) + { + auto s = Director::getInstance()->getWinSize(); + EdgeDetectionSprite* sprite = EdgeDetectionSprite::createSprite("Images/powered.png"); + sprite->setPosition(Point(s.width/2, s.height/2)); + addChild(sprite); + } +} + +BloomSpriteTest::BloomSpriteTest() +{ + if (ShaderTestDemo2::init()) + { + auto s = Director::getInstance()->getWinSize(); + BloomSprite* sprite = BloomSprite::createSprite("Images/powered.png"); + sprite->setPosition(Point(s.width/2, s.height/2)); + addChild(sprite); + } +} + +CelShadingSpriteTest::CelShadingSpriteTest() +{ + if (ShaderTestDemo2::init()) + { + auto s = Director::getInstance()->getWinSize(); + CelShadingSprite* sprite = CelShadingSprite::createSprite("Images/powered.png"); + sprite->setPosition(Point(s.width/2, s.height/2)); + addChild(sprite); + } +} + diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h new file mode 100644 index 0000000000..b284540075 --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h @@ -0,0 +1,88 @@ +#ifndef _SHADER_TEST2_H_ +#define _SHADER_TEST2_H_ +#include "../testBasic.h" +#include "cocos-ext.h" +#include "../BaseTest.h" + +USING_NS_CC_EXT; + +class ShaderTestDemo2 : public BaseTest +{ +public: + ShaderTestDemo2(void); + virtual std::string title() { return "New Shader Test!";} + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); + + CREATE_FUNC(ShaderTestDemo2); +}; + +class ShaderTestScene2 : public TestScene +{ +public: + virtual void runThisTest(); +}; + + + +class NormalSpriteTest : public ShaderTestDemo2 +{ +public: + NormalSpriteTest(); + + virtual std::string subtitle() {return "NormalSpriteTest";} +}; + +class GreyScaleSpriteTest : public ShaderTestDemo2 +{ +public: + GreyScaleSpriteTest(); + + virtual std::string subtitle() {return "GreyScaleSpriteTest";} +}; + +class BlurSpriteTest : public ShaderTestDemo2 +{ +public: + BlurSpriteTest(); + + virtual std::string subtitle() {return "BlurSpriteTest";} +}; + +class NoiseSpriteTest : public ShaderTestDemo2 +{ +public: + NoiseSpriteTest(); + virtual std::string subtitle() {return "NoiseSpriteTest";} +}; + +class EdgeDetectionSpriteTest : public ShaderTestDemo2 +{ +public: + EdgeDetectionSpriteTest(); + virtual std::string subtitle() {return "EdgeDetectionSpriteTest";} +}; + +class BloomSpriteTest : public ShaderTestDemo2 +{ +public: + BloomSpriteTest(); + virtual std::string subtitle() {return "BloomSpriteTest";} +}; + +class CelShadingSpriteTest : public ShaderTestDemo2 +{ +public: + CelShadingSpriteTest(); + virtual std::string subtitle() {return "CelShadingSpriteTest";} +}; + +class FlameTest3 : public ShaderTestDemo2 +{ +public: + FlameTest3() {} + virtual std::string subtitle() {return "FlameTest3";} +}; + +#endif \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp index 26971f6452..cd2f4e02b0 100644 --- a/samples/Cpp/TestCpp/Classes/controller.cpp +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -70,6 +70,7 @@ struct { { "SceneTest", [](){return new SceneTestScene();} }, { "SchedulerTest", [](){return new SchedulerTestScene(); } }, { "ShaderTest", []() { return new ShaderTestScene(); } }, + { "NewShaderTest", []() { return new ShaderTestScene2(); } }, { "SpineTest", []() { return new SpineTestScene(); } }, { "SpriteTest", [](){return new SpriteTestScene(); } }, { "TextInputTest", [](){return new TextInputTestScene(); } }, diff --git a/samples/Cpp/TestCpp/Classes/tests.h b/samples/Cpp/TestCpp/Classes/tests.h index ea26d0223c..7bf7893a75 100644 --- a/samples/Cpp/TestCpp/Classes/tests.h +++ b/samples/Cpp/TestCpp/Classes/tests.h @@ -52,6 +52,7 @@ #include "TextureCacheTest/TextureCacheTest.h" #include "NodeTest/NodeTest.h" #include "ShaderTest/ShaderTest.h" +#include "ShaderTest/ShaderTest2.h" #include "ExtensionsTest/ExtensionsTest.h" #include "MutiTouchTest/MutiTouchTest.h" #if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index 42c17a6004..6e2a278b84 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -d36d2542f8c085962b01d856a008b085589e62e6 \ No newline at end of file +03e60de189259aa934135a3492ddbe49112cda61 \ No newline at end of file From 1115d0d3f909dd0363e787c8721de63c3ec422bc Mon Sep 17 00:00:00 2001 From: zhangcheng Date: Mon, 9 Sep 2013 19:51:26 +0800 Subject: [PATCH 22/37] 1. merge scenereader Armature merge to cocos2dx 3.0. --- extensions/Android.mk | 65 +- .../Json/CSContentJsonDictionary.cpp | 375 ----- .../Armature}/CCArmature.cpp | 0 .../Armature}/CCArmature.h | 0 .../Armature}/CCBone.cpp | 0 .../Armature}/CCBone.h | 0 .../animation/CCArmatureAnimation.cpp | 0 .../Armature}/animation/CCArmatureAnimation.h | 0 .../Armature}/animation/CCProcessBase.cpp | 0 .../Armature}/animation/CCProcessBase.h | 0 .../Armature}/animation/CCTween.cpp | 0 .../Armature}/animation/CCTween.h | 0 .../Armature}/datas/CCDatas.cpp | 2 +- .../Armature}/datas/CCDatas.h | 0 .../Armature}/display/CCBatchNode.cpp | 0 .../Armature}/display/CCBatchNode.h | 0 .../Armature}/display/CCDecorativeDisplay.cpp | 0 .../Armature}/display/CCDecorativeDisplay.h | 0 .../Armature}/display/CCDisplayFactory.cpp | 0 .../Armature}/display/CCDisplayFactory.h | 0 .../Armature}/display/CCDisplayManager.cpp | 0 .../Armature}/display/CCDisplayManager.h | 0 .../Armature}/display/CCShaderNode.cpp | 0 .../Armature}/display/CCShaderNode.h | 0 .../Armature}/display/CCSkin.cpp | 0 .../Armature}/display/CCSkin.h | 0 .../external_tool/CCTexture2DMutable.cpp | 0 .../external_tool/CCTexture2DMutable.h | 0 .../Armature}/external_tool/GLES-Render.cpp | 0 .../Armature}/external_tool/GLES-Render.h | 0 .../Armature}/external_tool/sigslot.h | 0 .../Armature}/physics/CCColliderDetector.cpp | 0 .../Armature}/physics/CCColliderDetector.h | 0 .../Armature}/physics/CCPhysicsWorld.cpp | 0 .../Armature}/physics/CCPhysicsWorld.h | 0 .../Armature}/utils/CCArmatureDataManager.cpp | 0 .../Armature}/utils/CCArmatureDataManager.h | 0 .../Armature}/utils/CCArmatureDefine.h | 0 .../Armature}/utils/CCConstValue.h | 0 .../Armature}/utils/CCDataReaderHelper.cpp | 44 +- .../Armature}/utils/CCDataReaderHelper.h | 22 +- .../utils/CCSpriteFrameCacheHelper.cpp | 0 .../utils/CCSpriteFrameCacheHelper.h | 0 .../Armature}/utils/CCTransformHelp.cpp | 0 .../Armature}/utils/CCTransformHelp.h | 0 .../Armature}/utils/CCTweenFunction.cpp | 0 .../Armature}/utils/CCTweenFunction.h | 0 .../Armature}/utils/CCUtilMath.cpp | 0 .../Armature}/utils/CCUtilMath.h | 0 .../Components/CCComAttribute.cpp | 9 + .../Components/CCComAttribute.h | 3 + .../Components/CCComAudio.cpp | 21 + .../{ => CocoStudio}/Components/CCComAudio.h | 7 + .../Components/CCComController.cpp | 0 .../Components/CCComController.h | 0 .../CocoStudio/Components/CCComRender.cpp | 79 + .../CocoStudio/Components/CCComRender.h | 53 + .../Components/CCInputDelegate.cpp | 0 .../Components/CCInputDelegate.h | 0 .../Json/CSContentJsonDictionary.cpp | 388 +++++ .../Json/CSContentJsonDictionary.h | 17 +- .../CocoStudio/Json/DictionaryHelper.cpp | 289 ++++ extensions/CocoStudio/Json/DictionaryHelper.h | 72 + .../Json/lib_json/autolink.h | 0 .../Json/lib_json/config.h | 0 .../Json/lib_json/features.h | 0 .../Json/lib_json/forwards.h | 0 .../Json/lib_json/json_batchallocator.h | 0 .../Json/lib_json/json_internalarray.inl | 0 .../Json/lib_json/json_internalmap.inl | 0 .../Json/lib_json/json_lib.h | 0 .../Json/lib_json/json_reader.cpp | 0 .../Json/lib_json/json_tool.h | 0 .../Json/lib_json/json_value.cpp | 14 +- .../Json/lib_json/json_valueiterator.inl | 0 .../Json/lib_json/json_writer.cpp | 0 .../Json/lib_json/reader.h | 0 .../Json/lib_json/sconscript | 0 .../Json/lib_json/value.h | 0 .../Json/lib_json/writer.h | 0 .../CocoStudio/Reader/CCSSceneReader.cpp | 397 +++++ extensions/CocoStudio/Reader/CCSSceneReader.h | 56 + extensions/cocos-ext.h | 31 +- extensions/proj.win32/libExtensions.vcxproj | 151 +- .../proj.win32/libExtensions.vcxproj.filters | 1493 +++++++++-------- 85 files changed, 2329 insertions(+), 1259 deletions(-) delete mode 100644 extensions/CCArmature/external_tool/Json/CSContentJsonDictionary.cpp rename extensions/{CCArmature => CocoStudio/Armature}/CCArmature.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/CCArmature.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/CCBone.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/CCBone.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/animation/CCArmatureAnimation.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/animation/CCArmatureAnimation.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/animation/CCProcessBase.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/animation/CCProcessBase.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/animation/CCTween.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/animation/CCTween.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/datas/CCDatas.cpp (99%) rename extensions/{CCArmature => CocoStudio/Armature}/datas/CCDatas.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCBatchNode.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCBatchNode.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCDecorativeDisplay.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCDecorativeDisplay.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCDisplayFactory.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCDisplayFactory.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCDisplayManager.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCDisplayManager.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCShaderNode.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCShaderNode.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCSkin.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/display/CCSkin.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/external_tool/CCTexture2DMutable.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/external_tool/CCTexture2DMutable.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/external_tool/GLES-Render.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/external_tool/GLES-Render.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/external_tool/sigslot.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/physics/CCColliderDetector.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/physics/CCColliderDetector.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/physics/CCPhysicsWorld.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/physics/CCPhysicsWorld.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCArmatureDataManager.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCArmatureDataManager.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCArmatureDefine.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCConstValue.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCDataReaderHelper.cpp (95%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCDataReaderHelper.h (85%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCSpriteFrameCacheHelper.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCSpriteFrameCacheHelper.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCTransformHelp.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCTransformHelp.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCTweenFunction.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCTweenFunction.h (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCUtilMath.cpp (100%) rename extensions/{CCArmature => CocoStudio/Armature}/utils/CCUtilMath.h (100%) rename extensions/{ => CocoStudio}/Components/CCComAttribute.cpp (96%) rename extensions/{ => CocoStudio}/Components/CCComAttribute.h (95%) rename extensions/{ => CocoStudio}/Components/CCComAudio.cpp (94%) rename extensions/{ => CocoStudio}/Components/CCComAudio.h (94%) rename extensions/{ => CocoStudio}/Components/CCComController.cpp (100%) rename extensions/{ => CocoStudio}/Components/CCComController.h (100%) create mode 100644 extensions/CocoStudio/Components/CCComRender.cpp create mode 100644 extensions/CocoStudio/Components/CCComRender.h rename extensions/{ => CocoStudio}/Components/CCInputDelegate.cpp (100%) rename extensions/{ => CocoStudio}/Components/CCInputDelegate.h (100%) create mode 100644 extensions/CocoStudio/Json/CSContentJsonDictionary.cpp rename extensions/{CCArmature/external_tool => CocoStudio}/Json/CSContentJsonDictionary.h (87%) create mode 100644 extensions/CocoStudio/Json/DictionaryHelper.cpp create mode 100644 extensions/CocoStudio/Json/DictionaryHelper.h rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/autolink.h (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/config.h (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/features.h (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/forwards.h (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/json_batchallocator.h (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/json_internalarray.inl (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/json_internalmap.inl (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/json_lib.h (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/json_reader.cpp (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/json_tool.h (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/json_value.cpp (99%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/json_valueiterator.inl (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/json_writer.cpp (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/reader.h (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/sconscript (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/value.h (100%) rename extensions/{CCArmature/external_tool => CocoStudio}/Json/lib_json/writer.h (100%) create mode 100644 extensions/CocoStudio/Reader/CCSSceneReader.cpp create mode 100644 extensions/CocoStudio/Reader/CCSSceneReader.h diff --git a/extensions/Android.mk b/extensions/Android.mk index bead6fce42..6d07ce4349 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -8,32 +8,7 @@ LOCAL_MODULE_FILENAME := libextension LOCAL_SRC_FILES := \ CCDeprecated-ext.cpp \ AssetsManager/AssetsManager.cpp \ -CCArmature/CCArmature.cpp \ -CCArmature/CCBone.cpp \ -CCArmature/animation/CCArmatureAnimation.cpp \ -CCArmature/animation/CCProcessBase.cpp \ -CCArmature/animation/CCTween.cpp \ -CCArmature/datas/CCDatas.cpp \ -CCArmature/display/CCBatchNode.cpp \ -CCArmature/display/CCDecorativeDisplay.cpp \ -CCArmature/display/CCDisplayFactory.cpp \ -CCArmature/display/CCDisplayManager.cpp \ -CCArmature/display/CCShaderNode.cpp \ -CCArmature/display/CCSkin.cpp \ -CCArmature/external_tool/CCTexture2DMutable.cpp \ -CCArmature/external_tool/GLES-Render.cpp \ -CCArmature/external_tool/Json/CSContentJsonDictionary.cpp \ -CCArmature/external_tool/Json/lib_json/json_reader.cpp \ -CCArmature/external_tool/Json/lib_json/json_value.cpp \ -CCArmature/external_tool/Json/lib_json/json_writer.cpp \ -CCArmature/physics/CCColliderDetector.cpp \ -CCArmature/physics/CCPhysicsWorld.cpp \ -CCArmature/utils/CCArmatureDataManager.cpp \ -CCArmature/utils/CCDataReaderHelper.cpp \ -CCArmature/utils/CCSpriteFrameCacheHelper.cpp \ -CCArmature/utils/CCTransformHelp.cpp \ -CCArmature/utils/CCTweenFunction.cpp \ -CCArmature/utils/CCUtilMath.cpp \ + CCBReader/CCBAnimationManager.cpp \ CCBReader/CCBFileLoader.cpp \ CCBReader/CCBKeyframe.cpp \ @@ -56,11 +31,7 @@ CCBReader/CCNodeLoaderLibrary.cpp \ CCBReader/CCParticleSystemQuadLoader.cpp \ CCBReader/CCScale9SpriteLoader.cpp \ CCBReader/CCScrollViewLoader.cpp \ -CCBReader/CCSpriteLoader.cpp \ -Components/CCComAttribute.cpp \ -Components/CCComAudio.cpp \ -Components/CCComController.cpp \ -Components/CCInputDelegate.cpp \ +CCBReader/CCSpriteLoader.cpp GUI/CCControlExtension/CCControl.cpp \ GUI/CCControlExtension/CCControlButton.cpp \ GUI/CCControlExtension/CCControlColourPicker.cpp \ @@ -89,6 +60,38 @@ network/SocketIO.cpp \ network/WebSocket.cpp \ physics_nodes/CCPhysicsDebugNode.cpp \ physics_nodes/CCPhysicsSprite.cpp \ +CocoStudio/Armature/CCArmature.cpp \ +CocoStudio/Armature/CCBone.cpp \ +CocoStudio/Armature/animation/CCArmatureAnimation.cpp \ +CocoStudio/Armature/animation/CCProcessBase.cpp \ +CocoStudio/Armature/animation/CCTween.cpp \ +CocoStudio/Armature/datas/CCDatas.cpp \ +CocoStudio/Armature/display/CCBatchNode.cpp \ +CocoStudio/Armature/display/CCDecorativeDisplay.cpp \ +CocoStudio/Armature/display/CCDisplayFactory.cpp \ +CocoStudio/Armature/display/CCDisplayManager.cpp \ +CocoStudio/Armature/display/CCSkin.cpp \ +CocoStudio/Armature/external_tool/CCTexture2DMutable.cpp \ +CocoStudio/Armature/external_tool/GLES-Render.cpp \ +CocoStudio/Armature/physics/CCColliderDetector.cpp \ +CocoStudio/Armature/physics/CCPhysicsWorld.cpp \ +CocoStudio/Armature/utils/CCArmatureDataManager.cpp \ +CocoStudio/Armature/utils/CCDataReaderHelper.cpp \ +CocoStudio/Armature/utils/CCSpriteFrameCacheHelper.cpp \ +CocoStudio/Armature/utils/CCTransformHelp.cpp \ +CocoStudio/Armature/utils/CCTweenFunction.cpp \ +CocoStudio/Armature/utils/CCUtilMath.cpp \ +CocoStudio/Components/CCComAttribute.cpp \ +CocoStudio/Components/CCComAudio.cpp \ +CocoStudio/Components/CCComController.cpp \ +CocoStudio/Components/CCComRender.cpp \ +CocoStudio/Components/CCInputDelegate.cpp \ +CocoStudio/Json/CSContentJsonDictionary.cpp \ +CocoStudio/Json/DictionaryHelper.cpp \ +CocoStudio/Json/lib_json/json_value.cpp \ +CocoStudio/Json/lib_json/json_reader.cpp \ +CocoStudio/Json/lib_json/json_writer.cpp \ +CocoStudio/Reader/CCSSceneReader.cpp \ spine/Animation.cpp \ spine/AnimationState.cpp \ spine/AnimationStateData.cpp \ diff --git a/extensions/CCArmature/external_tool/Json/CSContentJsonDictionary.cpp b/extensions/CCArmature/external_tool/Json/CSContentJsonDictionary.cpp deleted file mode 100644 index b8ece40388..0000000000 --- a/extensions/CCArmature/external_tool/Json/CSContentJsonDictionary.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (c) 2012 Chukong Technologies, Inc. - * - * http://www.cocostudio.com - * http://tools.cocoachina.com - * - * 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. - */ - -#include -#include "CSContentJsonDictionary.h" - -namespace cs { - - CSJsonDictionary::CSJsonDictionary() - { - _value.clear(); - } - - - CSJsonDictionary::~CSJsonDictionary() - { - _value.clear(); - } - - - void CSJsonDictionary::initWithDescription(const char *pszDescription) - { - CSJson::Reader cReader; - _value.clear(); - if (pszDescription && *pszDescription) - { - std::string strValue = pszDescription; - cReader.parse(strValue, _value, false); - } - } - - - void CSJsonDictionary::initWithValue(CSJson::Value& value) - { - _value = value; - } - - - void CSJsonDictionary::insertItem(const char *pszKey, int nValue) - { - _value[pszKey] = nValue; - } - - - void CSJsonDictionary::insertItem(const char *pszKey, double fValue) - { - _value[pszKey] = fValue; - } - - - void CSJsonDictionary::insertItem(const char *pszKey, const char * pszValue) - { - _value[pszKey] = pszValue; - } - - void CSJsonDictionary::insertItem(const char *pszKey, bool bValue) - { - _value[pszKey] = bValue; - } - - void CSJsonDictionary::insertItem(const char *pszKey, CSJsonDictionary * subDictionary) - { - if (subDictionary) - _value[pszKey] = subDictionary->_value; - } - - - bool CSJsonDictionary::deleteItem(const char *pszKey) - { - if(!_value.isMember(pszKey)) - return false; - - _value.removeMember(pszKey); - - return true; - } - - - void CSJsonDictionary::cleanUp() - { - _value.clear(); - } - - - bool CSJsonDictionary::isKeyValidate(const char *pszKey) - { - return _value.isMember(pszKey); - } - - - int CSJsonDictionary::getItemIntValue(const char *pszKey, int nDefaultValue) - { - if (!isKeyValidate(pszKey, _value) || !_value[pszKey].isNumeric()) - return nDefaultValue; - - return _value[pszKey].asInt(); - } - - - double CSJsonDictionary::getItemFloatValue(const char *pszKey, double fDefaultValue) - { - if (!isKeyValidate(pszKey, _value) || !_value[pszKey].isNumeric()) - return fDefaultValue; - - return _value[pszKey].asDouble(); - } - - - const char * CSJsonDictionary::getItemStringValue(const char *pszKey) - { - if (!isKeyValidate(pszKey, _value) || !_value[pszKey].isString()) - return NULL; - - return _value[pszKey].asCString(); - } - - bool CSJsonDictionary::getItemBoolvalue(const char *pszKey, bool bDefaultValue) - { - if (!isKeyValidate(pszKey, _value) || !_value[pszKey].isBool()) - return bDefaultValue; - - return _value[pszKey].asBool(); - } - - - CSJsonDictionary * CSJsonDictionary::getSubDictionary(const char *pszKey) - { - CSJsonDictionary * pNewDictionary; - if (!isKeyValidate(pszKey, _value) || (!_value[pszKey].isArray() && - !_value[pszKey].isObject() && - !_value[pszKey].isConvertibleTo(CSJson::arrayValue) && - !_value[pszKey].isConvertibleTo(CSJson::objectValue))) - { - pNewDictionary = NULL; - } - else - { - pNewDictionary = new CSJsonDictionary(); - pNewDictionary->initWithValue(_value[pszKey]); - } - return pNewDictionary; - } - - - std::string CSJsonDictionary::getDescription() - { - std::string strReturn = _value.toStyledString(); - return strReturn; - } - - - bool CSJsonDictionary::insertItemToArray(const char *pszArrayKey, int nValue) - { - CSJson::Value array; - if(_value.isMember(pszArrayKey)) - { - if (!_value[pszArrayKey].isArray() && !_value[pszArrayKey].isConvertibleTo(CSJson::arrayValue)) - return false; - - array = _value[pszArrayKey]; - } - - array.append(nValue); - _value[pszArrayKey] = array; - - return true; - } - - - bool CSJsonDictionary::insertItemToArray(const char *pszArrayKey, double fValue) - { - CSJson::Value array; - if(_value.isMember(pszArrayKey)) - { - if (!_value[pszArrayKey].isArray() && !_value[pszArrayKey].isConvertibleTo(CSJson::arrayValue)) - return false; - - array = _value[pszArrayKey]; - } - - array.append(fValue); - _value[pszArrayKey] = array; - - return true; - } - - - bool CSJsonDictionary::insertItemToArray(const char *pszArrayKey, const char * pszValue) - { - CSJson::Value array; - if(_value.isMember(pszArrayKey)) - { - if (!_value[pszArrayKey].isArray() && !_value[pszArrayKey].isConvertibleTo(CSJson::arrayValue)) - return false; - - array = _value[pszArrayKey]; - } - - array.append(pszValue); - _value[pszArrayKey] = array; - - return true; - } - - - bool CSJsonDictionary::insertItemToArray(const char *pszArrayKey, CSJsonDictionary * subDictionary) - { - CSJson::Value array; - if(_value.isMember(pszArrayKey)) - { - if (!_value[pszArrayKey].isArray() && !_value[pszArrayKey].isConvertibleTo(CSJson::arrayValue)) - return false; - - array = _value[pszArrayKey]; - } - - array.append(subDictionary->_value); - _value[pszArrayKey] = array; - - return true; - } - - - int CSJsonDictionary::getItemCount() - { - return _value.size(); - } - - - DicItemType CSJsonDictionary::getItemType(int nIndex) - { - return (DicItemType)_value[nIndex].type(); - } - - - DicItemType CSJsonDictionary::getItemType(const char *pszKey) - { - return (DicItemType)_value[pszKey].type(); - } - - std::vector CSJsonDictionary::getAllMemberNames() - { - return _value.getMemberNames(); - } - - - int CSJsonDictionary::getArrayItemCount(const char *pszArrayKey) - { - int nRet = 0; - if (!isKeyValidate(pszArrayKey, _value) || - (!_value[pszArrayKey].isArray() && !_value[pszArrayKey].isObject() && - !_value[pszArrayKey].isConvertibleTo(CSJson::arrayValue) && !_value[pszArrayKey].isConvertibleTo(CSJson::objectValue))) - { - nRet = 0; - } - else - { - CSJson::Value arrayValue = _value[pszArrayKey]; - nRet = arrayValue.size(); - } - - return nRet; - } - - - int CSJsonDictionary::getIntValueFromArray(const char *pszArrayKey, int nIndex, int nDefaultValue) - { - int nRet = nDefaultValue; - CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); - if (arrayValue) - { - if ((*arrayValue)[nIndex].isNumeric()) - nRet = (*arrayValue)[nIndex].asInt(); - } - - return nRet; - } - - - double CSJsonDictionary::getFloatValueFromArray(const char *pszArrayKey, int nIndex, double fDefaultValue) - { - double fRet = fDefaultValue; - CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); - if (arrayValue) - { - if ((*arrayValue)[nIndex].isNumeric()) - fRet = (*arrayValue)[nIndex].asDouble(); - } - - return fRet; - } - - - const char * CSJsonDictionary::getStringValueFromArray(const char *pszArrayKey, int nIndex) - { - CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); - if (arrayValue) - { - if ((*arrayValue)[nIndex].isString()) - return (*arrayValue)[nIndex].asCString(); - } - - return NULL; - } - - - CSJsonDictionary * CSJsonDictionary::getSubItemFromArray(const char *pszArrayKey, int nIndex) - { - CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); - if (arrayValue) - { - if ((*arrayValue)[nIndex].isArray() || (*arrayValue)[nIndex].isObject()) - { - CSJsonDictionary * pNewDictionary = new CSJsonDictionary(); - pNewDictionary->initWithValue((*arrayValue)[nIndex]); - return pNewDictionary; - } - } - - return NULL; - } - - - DicItemType CSJsonDictionary::getItemTypeFromArray(const char *pszArrayKey, int nIndex) - { - CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); - if (arrayValue) - return (DicItemType)((*arrayValue)[nIndex].type()); - - return (DicItemType)CSJson::nullValue; - } - - - inline bool CSJsonDictionary::isKeyValidate(const char *pszKey, CSJson::Value& root) - { - if (root.isNull() || !root.isMember(pszKey)) - return false; - - return true; - } - - - inline CSJson::Value * CSJsonDictionary::validateArrayItem(const char *pszArrayKey, int nIndex) - { - if (!isKeyValidate(pszArrayKey, _value) && !_value[pszArrayKey].isArray() && !_value[pszArrayKey].isConvertibleTo(CSJson::arrayValue)) - return NULL; - if (!_value[pszArrayKey].isValidIndex(nIndex)) - return NULL; - - return &_value[pszArrayKey]; - } -} diff --git a/extensions/CCArmature/CCArmature.cpp b/extensions/CocoStudio/Armature/CCArmature.cpp similarity index 100% rename from extensions/CCArmature/CCArmature.cpp rename to extensions/CocoStudio/Armature/CCArmature.cpp diff --git a/extensions/CCArmature/CCArmature.h b/extensions/CocoStudio/Armature/CCArmature.h similarity index 100% rename from extensions/CCArmature/CCArmature.h rename to extensions/CocoStudio/Armature/CCArmature.h diff --git a/extensions/CCArmature/CCBone.cpp b/extensions/CocoStudio/Armature/CCBone.cpp similarity index 100% rename from extensions/CCArmature/CCBone.cpp rename to extensions/CocoStudio/Armature/CCBone.cpp diff --git a/extensions/CCArmature/CCBone.h b/extensions/CocoStudio/Armature/CCBone.h similarity index 100% rename from extensions/CCArmature/CCBone.h rename to extensions/CocoStudio/Armature/CCBone.h diff --git a/extensions/CCArmature/animation/CCArmatureAnimation.cpp b/extensions/CocoStudio/Armature/animation/CCArmatureAnimation.cpp similarity index 100% rename from extensions/CCArmature/animation/CCArmatureAnimation.cpp rename to extensions/CocoStudio/Armature/animation/CCArmatureAnimation.cpp diff --git a/extensions/CCArmature/animation/CCArmatureAnimation.h b/extensions/CocoStudio/Armature/animation/CCArmatureAnimation.h similarity index 100% rename from extensions/CCArmature/animation/CCArmatureAnimation.h rename to extensions/CocoStudio/Armature/animation/CCArmatureAnimation.h diff --git a/extensions/CCArmature/animation/CCProcessBase.cpp b/extensions/CocoStudio/Armature/animation/CCProcessBase.cpp similarity index 100% rename from extensions/CCArmature/animation/CCProcessBase.cpp rename to extensions/CocoStudio/Armature/animation/CCProcessBase.cpp diff --git a/extensions/CCArmature/animation/CCProcessBase.h b/extensions/CocoStudio/Armature/animation/CCProcessBase.h similarity index 100% rename from extensions/CCArmature/animation/CCProcessBase.h rename to extensions/CocoStudio/Armature/animation/CCProcessBase.h diff --git a/extensions/CCArmature/animation/CCTween.cpp b/extensions/CocoStudio/Armature/animation/CCTween.cpp similarity index 100% rename from extensions/CCArmature/animation/CCTween.cpp rename to extensions/CocoStudio/Armature/animation/CCTween.cpp diff --git a/extensions/CCArmature/animation/CCTween.h b/extensions/CocoStudio/Armature/animation/CCTween.h similarity index 100% rename from extensions/CCArmature/animation/CCTween.h rename to extensions/CocoStudio/Armature/animation/CCTween.h diff --git a/extensions/CCArmature/datas/CCDatas.cpp b/extensions/CocoStudio/Armature/datas/CCDatas.cpp similarity index 99% rename from extensions/CCArmature/datas/CCDatas.cpp rename to extensions/CocoStudio/Armature/datas/CCDatas.cpp index e6330873bb..95863980db 100644 --- a/extensions/CCArmature/datas/CCDatas.cpp +++ b/extensions/CocoStudio/Armature/datas/CCDatas.cpp @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCDatas.h" -#include "CCArmature/utils/CCUtilMath.h" +#include "../utils/CCUtilMath.h" namespace cocos2d { namespace extension { namespace armature { diff --git a/extensions/CCArmature/datas/CCDatas.h b/extensions/CocoStudio/Armature/datas/CCDatas.h similarity index 100% rename from extensions/CCArmature/datas/CCDatas.h rename to extensions/CocoStudio/Armature/datas/CCDatas.h diff --git a/extensions/CCArmature/display/CCBatchNode.cpp b/extensions/CocoStudio/Armature/display/CCBatchNode.cpp similarity index 100% rename from extensions/CCArmature/display/CCBatchNode.cpp rename to extensions/CocoStudio/Armature/display/CCBatchNode.cpp diff --git a/extensions/CCArmature/display/CCBatchNode.h b/extensions/CocoStudio/Armature/display/CCBatchNode.h similarity index 100% rename from extensions/CCArmature/display/CCBatchNode.h rename to extensions/CocoStudio/Armature/display/CCBatchNode.h diff --git a/extensions/CCArmature/display/CCDecorativeDisplay.cpp b/extensions/CocoStudio/Armature/display/CCDecorativeDisplay.cpp similarity index 100% rename from extensions/CCArmature/display/CCDecorativeDisplay.cpp rename to extensions/CocoStudio/Armature/display/CCDecorativeDisplay.cpp diff --git a/extensions/CCArmature/display/CCDecorativeDisplay.h b/extensions/CocoStudio/Armature/display/CCDecorativeDisplay.h similarity index 100% rename from extensions/CCArmature/display/CCDecorativeDisplay.h rename to extensions/CocoStudio/Armature/display/CCDecorativeDisplay.h diff --git a/extensions/CCArmature/display/CCDisplayFactory.cpp b/extensions/CocoStudio/Armature/display/CCDisplayFactory.cpp similarity index 100% rename from extensions/CCArmature/display/CCDisplayFactory.cpp rename to extensions/CocoStudio/Armature/display/CCDisplayFactory.cpp diff --git a/extensions/CCArmature/display/CCDisplayFactory.h b/extensions/CocoStudio/Armature/display/CCDisplayFactory.h similarity index 100% rename from extensions/CCArmature/display/CCDisplayFactory.h rename to extensions/CocoStudio/Armature/display/CCDisplayFactory.h diff --git a/extensions/CCArmature/display/CCDisplayManager.cpp b/extensions/CocoStudio/Armature/display/CCDisplayManager.cpp similarity index 100% rename from extensions/CCArmature/display/CCDisplayManager.cpp rename to extensions/CocoStudio/Armature/display/CCDisplayManager.cpp diff --git a/extensions/CCArmature/display/CCDisplayManager.h b/extensions/CocoStudio/Armature/display/CCDisplayManager.h similarity index 100% rename from extensions/CCArmature/display/CCDisplayManager.h rename to extensions/CocoStudio/Armature/display/CCDisplayManager.h diff --git a/extensions/CCArmature/display/CCShaderNode.cpp b/extensions/CocoStudio/Armature/display/CCShaderNode.cpp similarity index 100% rename from extensions/CCArmature/display/CCShaderNode.cpp rename to extensions/CocoStudio/Armature/display/CCShaderNode.cpp diff --git a/extensions/CCArmature/display/CCShaderNode.h b/extensions/CocoStudio/Armature/display/CCShaderNode.h similarity index 100% rename from extensions/CCArmature/display/CCShaderNode.h rename to extensions/CocoStudio/Armature/display/CCShaderNode.h diff --git a/extensions/CCArmature/display/CCSkin.cpp b/extensions/CocoStudio/Armature/display/CCSkin.cpp similarity index 100% rename from extensions/CCArmature/display/CCSkin.cpp rename to extensions/CocoStudio/Armature/display/CCSkin.cpp diff --git a/extensions/CCArmature/display/CCSkin.h b/extensions/CocoStudio/Armature/display/CCSkin.h similarity index 100% rename from extensions/CCArmature/display/CCSkin.h rename to extensions/CocoStudio/Armature/display/CCSkin.h diff --git a/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp b/extensions/CocoStudio/Armature/external_tool/CCTexture2DMutable.cpp similarity index 100% rename from extensions/CCArmature/external_tool/CCTexture2DMutable.cpp rename to extensions/CocoStudio/Armature/external_tool/CCTexture2DMutable.cpp diff --git a/extensions/CCArmature/external_tool/CCTexture2DMutable.h b/extensions/CocoStudio/Armature/external_tool/CCTexture2DMutable.h similarity index 100% rename from extensions/CCArmature/external_tool/CCTexture2DMutable.h rename to extensions/CocoStudio/Armature/external_tool/CCTexture2DMutable.h diff --git a/extensions/CCArmature/external_tool/GLES-Render.cpp b/extensions/CocoStudio/Armature/external_tool/GLES-Render.cpp similarity index 100% rename from extensions/CCArmature/external_tool/GLES-Render.cpp rename to extensions/CocoStudio/Armature/external_tool/GLES-Render.cpp diff --git a/extensions/CCArmature/external_tool/GLES-Render.h b/extensions/CocoStudio/Armature/external_tool/GLES-Render.h similarity index 100% rename from extensions/CCArmature/external_tool/GLES-Render.h rename to extensions/CocoStudio/Armature/external_tool/GLES-Render.h diff --git a/extensions/CCArmature/external_tool/sigslot.h b/extensions/CocoStudio/Armature/external_tool/sigslot.h similarity index 100% rename from extensions/CCArmature/external_tool/sigslot.h rename to extensions/CocoStudio/Armature/external_tool/sigslot.h diff --git a/extensions/CCArmature/physics/CCColliderDetector.cpp b/extensions/CocoStudio/Armature/physics/CCColliderDetector.cpp similarity index 100% rename from extensions/CCArmature/physics/CCColliderDetector.cpp rename to extensions/CocoStudio/Armature/physics/CCColliderDetector.cpp diff --git a/extensions/CCArmature/physics/CCColliderDetector.h b/extensions/CocoStudio/Armature/physics/CCColliderDetector.h similarity index 100% rename from extensions/CCArmature/physics/CCColliderDetector.h rename to extensions/CocoStudio/Armature/physics/CCColliderDetector.h diff --git a/extensions/CCArmature/physics/CCPhysicsWorld.cpp b/extensions/CocoStudio/Armature/physics/CCPhysicsWorld.cpp similarity index 100% rename from extensions/CCArmature/physics/CCPhysicsWorld.cpp rename to extensions/CocoStudio/Armature/physics/CCPhysicsWorld.cpp diff --git a/extensions/CCArmature/physics/CCPhysicsWorld.h b/extensions/CocoStudio/Armature/physics/CCPhysicsWorld.h similarity index 100% rename from extensions/CCArmature/physics/CCPhysicsWorld.h rename to extensions/CocoStudio/Armature/physics/CCPhysicsWorld.h diff --git a/extensions/CCArmature/utils/CCArmatureDataManager.cpp b/extensions/CocoStudio/Armature/utils/CCArmatureDataManager.cpp similarity index 100% rename from extensions/CCArmature/utils/CCArmatureDataManager.cpp rename to extensions/CocoStudio/Armature/utils/CCArmatureDataManager.cpp diff --git a/extensions/CCArmature/utils/CCArmatureDataManager.h b/extensions/CocoStudio/Armature/utils/CCArmatureDataManager.h similarity index 100% rename from extensions/CCArmature/utils/CCArmatureDataManager.h rename to extensions/CocoStudio/Armature/utils/CCArmatureDataManager.h diff --git a/extensions/CCArmature/utils/CCArmatureDefine.h b/extensions/CocoStudio/Armature/utils/CCArmatureDefine.h similarity index 100% rename from extensions/CCArmature/utils/CCArmatureDefine.h rename to extensions/CocoStudio/Armature/utils/CCArmatureDefine.h diff --git a/extensions/CCArmature/utils/CCConstValue.h b/extensions/CocoStudio/Armature/utils/CCConstValue.h similarity index 100% rename from extensions/CCArmature/utils/CCConstValue.h rename to extensions/CocoStudio/Armature/utils/CCConstValue.h diff --git a/extensions/CCArmature/utils/CCDataReaderHelper.cpp b/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp similarity index 95% rename from extensions/CCArmature/utils/CCDataReaderHelper.cpp rename to extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp index f0c33086f3..99442e5bb7 100644 --- a/extensions/CCArmature/utils/CCDataReaderHelper.cpp +++ b/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.cpp @@ -807,14 +807,14 @@ void DataReaderHelper::addDataFromJson(const char *filePath) void DataReaderHelper::addDataFromJsonCache(const char *fileContent) { - cs::CSJsonDictionary json; + cs::JsonDictionary json; json.initWithDescription(fileContent); // Decode armatures int length = json.getArrayItemCount(ARMATURE_DATA); for (int i = 0; i < length; i++) { - cs::CSJsonDictionary *armatureDic = json.getSubItemFromArray(ARMATURE_DATA, i); + cs::JsonDictionary *armatureDic = json.getSubItemFromArray(ARMATURE_DATA, i); ArmatureData *armatureData = decodeArmature(*armatureDic); ArmatureDataManager::sharedArmatureDataManager()->addArmatureData(armatureData->name.c_str(), armatureData); @@ -825,7 +825,7 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent) length = json.getArrayItemCount(ANIMATION_DATA); for (int i = 0; i < length; i++) { - cs::CSJsonDictionary *animationDic = json.getSubItemFromArray(ANIMATION_DATA, i); + cs::JsonDictionary *animationDic = json.getSubItemFromArray(ANIMATION_DATA, i); AnimationData *animationData = decodeAnimation(*animationDic); ArmatureDataManager::sharedArmatureDataManager()->addAnimationData(animationData->name.c_str(), animationData); @@ -836,7 +836,7 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent) length = json.getArrayItemCount(TEXTURE_DATA); for (int i = 0; i < length; i++) { - cs::CSJsonDictionary *textureDic = json.getSubItemFromArray(TEXTURE_DATA, i); + cs::JsonDictionary *textureDic = json.getSubItemFromArray(TEXTURE_DATA, i); TextureData *textureData = decodeTexture(*textureDic); ArmatureDataManager::sharedArmatureDataManager()->addTextureData(textureData->name.c_str(), textureData); @@ -844,7 +844,7 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent) } } -ArmatureData *DataReaderHelper::decodeArmature(cs::CSJsonDictionary &json) +ArmatureData *DataReaderHelper::decodeArmature(cs::JsonDictionary &json) { ArmatureData *armatureData = ArmatureData::create(); @@ -857,7 +857,7 @@ ArmatureData *DataReaderHelper::decodeArmature(cs::CSJsonDictionary &json) int length = json.getArrayItemCount(BONE_DATA); for (int i = 0; i < length; i++) { - cs::CSJsonDictionary *dic = json.getSubItemFromArray(BONE_DATA, i); + cs::JsonDictionary *dic = json.getSubItemFromArray(BONE_DATA, i); armatureData->addBoneData(decodeBone(*dic)); delete dic; @@ -866,7 +866,7 @@ ArmatureData *DataReaderHelper::decodeArmature(cs::CSJsonDictionary &json) return armatureData; } -BoneData *DataReaderHelper::decodeBone(cs::CSJsonDictionary &json) +BoneData *DataReaderHelper::decodeBone(cs::JsonDictionary &json) { BoneData *boneData = BoneData::create(); @@ -888,7 +888,7 @@ BoneData *DataReaderHelper::decodeBone(cs::CSJsonDictionary &json) for (int i = 0; i < length; i++) { - cs::CSJsonDictionary *dic = json.getSubItemFromArray(DISPLAY_DATA, i); + cs::JsonDictionary *dic = json.getSubItemFromArray(DISPLAY_DATA, i); boneData->addDisplayData(decodeBoneDisplay(*dic)); delete dic; @@ -897,7 +897,7 @@ BoneData *DataReaderHelper::decodeBone(cs::CSJsonDictionary &json) return boneData; } -DisplayData *DataReaderHelper::decodeBoneDisplay(cs::CSJsonDictionary &json) +DisplayData *DataReaderHelper::decodeBoneDisplay(cs::JsonDictionary &json) { DisplayType displayType = (DisplayType)json.getItemIntValue(A_DISPLAY_TYPE, CS_DISPLAY_SPRITE); @@ -963,7 +963,7 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(cs::CSJsonDictionary &json) return displayData; } -AnimationData *DataReaderHelper::decodeAnimation(cs::CSJsonDictionary &json) +AnimationData *DataReaderHelper::decodeAnimation(cs::JsonDictionary &json) { AnimationData *aniData = AnimationData::create(); @@ -977,7 +977,7 @@ AnimationData *DataReaderHelper::decodeAnimation(cs::CSJsonDictionary &json) for (int i = 0; i < length; i++) { - cs::CSJsonDictionary *dic = json.getSubItemFromArray(MOVEMENT_DATA, i); + cs::JsonDictionary *dic = json.getSubItemFromArray(MOVEMENT_DATA, i); aniData->addMovement(decodeMovement(*dic)); delete dic; @@ -986,7 +986,7 @@ AnimationData *DataReaderHelper::decodeAnimation(cs::CSJsonDictionary &json) return aniData; } -MovementData *DataReaderHelper::decodeMovement(cs::CSJsonDictionary &json) +MovementData *DataReaderHelper::decodeMovement(cs::JsonDictionary &json) { MovementData *movementData = MovementData::create(); @@ -1005,7 +1005,7 @@ MovementData *DataReaderHelper::decodeMovement(cs::CSJsonDictionary &json) int length = json.getArrayItemCount(MOVEMENT_BONE_DATA); for (int i = 0; i < length; i++) { - cs::CSJsonDictionary *dic = json.getSubItemFromArray(MOVEMENT_BONE_DATA, i); + cs::JsonDictionary *dic = json.getSubItemFromArray(MOVEMENT_BONE_DATA, i); movementData->addMovementBoneData(decodeMovementBone(*dic)); delete dic; @@ -1014,7 +1014,7 @@ MovementData *DataReaderHelper::decodeMovement(cs::CSJsonDictionary &json) return movementData; } -MovementBoneData *DataReaderHelper::decodeMovementBone(cs::CSJsonDictionary &json) +MovementBoneData *DataReaderHelper::decodeMovementBone(cs::JsonDictionary &json) { MovementBoneData *movementBoneData = MovementBoneData::create(); @@ -1030,7 +1030,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(cs::CSJsonDictionary &jso int length = json.getArrayItemCount(FRAME_DATA); for (int i = 0; i < length; i++) { - cs::CSJsonDictionary *dic = json.getSubItemFromArray(FRAME_DATA, i); + cs::JsonDictionary *dic = json.getSubItemFromArray(FRAME_DATA, i); FrameData *frameData = decodeFrame(*dic); movementBoneData->addFrameData(frameData); //movementBoneData->duration += frameData->duration; @@ -1041,7 +1041,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(cs::CSJsonDictionary &jso return movementBoneData; } -FrameData *DataReaderHelper::decodeFrame(cs::CSJsonDictionary &json) +FrameData *DataReaderHelper::decodeFrame(cs::JsonDictionary &json) { FrameData *frameData = FrameData::create(); @@ -1060,7 +1060,7 @@ FrameData *DataReaderHelper::decodeFrame(cs::CSJsonDictionary &json) return frameData; } -TextureData *DataReaderHelper::decodeTexture(cs::CSJsonDictionary &json) +TextureData *DataReaderHelper::decodeTexture(cs::JsonDictionary &json) { TextureData *textureData = TextureData::create(); @@ -1078,7 +1078,7 @@ TextureData *DataReaderHelper::decodeTexture(cs::CSJsonDictionary &json) int length = json.getArrayItemCount(CONTOUR_DATA); for (int i = 0; i < length; i++) { - cs::CSJsonDictionary *dic = json.getSubItemFromArray(CONTOUR_DATA, i); + cs::JsonDictionary *dic = json.getSubItemFromArray(CONTOUR_DATA, i); textureData->contourDataList->addObject(decodeContour(*dic)); delete dic; @@ -1087,14 +1087,14 @@ TextureData *DataReaderHelper::decodeTexture(cs::CSJsonDictionary &json) return textureData; } -ContourData *DataReaderHelper::decodeContour(cs::CSJsonDictionary &json) +ContourData *DataReaderHelper::decodeContour(cs::JsonDictionary &json) { ContourData *contourData = ContourData::create(); int length = json.getArrayItemCount(VERTEX_POINT); for (int i = length - 1; i >= 0; i--) { - cs::CSJsonDictionary *dic = json.getSubItemFromArray(VERTEX_POINT, i); + cs::JsonDictionary *dic = json.getSubItemFromArray(VERTEX_POINT, i); ContourVertex2F *vertex = new ContourVertex2F(0, 0); @@ -1110,7 +1110,7 @@ ContourData *DataReaderHelper::decodeContour(cs::CSJsonDictionary &json) return contourData; } -void DataReaderHelper::decodeNode(BaseData *node, cs::CSJsonDictionary &json) +void DataReaderHelper::decodeNode(BaseData *node, cs::JsonDictionary &json) { node->x = json.getItemFloatValue(A_X, 0) * s_PositionReadScale; node->y = json.getItemFloatValue(A_Y, 0) * s_PositionReadScale; @@ -1121,7 +1121,7 @@ void DataReaderHelper::decodeNode(BaseData *node, cs::CSJsonDictionary &json) node->scaleX = json.getItemFloatValue(A_SCALE_X, 1); node->scaleY = json.getItemFloatValue(A_SCALE_Y, 1); - cs::CSJsonDictionary *colorDic = json.getSubItemFromArray(COLOR_INFO, 0); + cs::JsonDictionary *colorDic = json.getSubItemFromArray(COLOR_INFO, 0); if (colorDic) { diff --git a/extensions/CCArmature/utils/CCDataReaderHelper.h b/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.h similarity index 85% rename from extensions/CCArmature/utils/CCDataReaderHelper.h rename to extensions/CocoStudio/Armature/utils/CCDataReaderHelper.h index 7e16e35ad3..69d310623b 100644 --- a/extensions/CCArmature/utils/CCDataReaderHelper.h +++ b/extensions/CocoStudio/Armature/utils/CCDataReaderHelper.h @@ -29,7 +29,7 @@ THE SOFTWARE. #include "../datas/CCDatas.h" #include "../utils/CCConstValue.h" #include "../CCArmature.h" -#include "../external_tool/Json/CSContentJsonDictionary.h" +#include "../../Json/CSContentJsonDictionary.h" namespace tinyxml2 { class XMLElement; } @@ -110,20 +110,20 @@ public: static void addDataFromJson(const char *filePath); static void addDataFromJsonCache(const char *fileContent); - static ArmatureData *decodeArmature(cs::CSJsonDictionary &json); - static BoneData *decodeBone(cs::CSJsonDictionary &json); - static DisplayData *decodeBoneDisplay(cs::CSJsonDictionary &json); + static ArmatureData *decodeArmature(cs::JsonDictionary &json); + static BoneData *decodeBone(cs::JsonDictionary &json); + static DisplayData *decodeBoneDisplay(cs::JsonDictionary &json); - static AnimationData *decodeAnimation(cs::CSJsonDictionary &json); - static MovementData *decodeMovement(cs::CSJsonDictionary &json); - static MovementBoneData *decodeMovementBone(cs::CSJsonDictionary &json); - static FrameData *decodeFrame(cs::CSJsonDictionary &json); + static AnimationData *decodeAnimation(cs::JsonDictionary &json); + static MovementData *decodeMovement(cs::JsonDictionary &json); + static MovementBoneData *decodeMovementBone(cs::JsonDictionary &json); + static FrameData *decodeFrame(cs::JsonDictionary &json); - static TextureData *decodeTexture(cs::CSJsonDictionary &json); + static TextureData *decodeTexture(cs::JsonDictionary &json); - static ContourData *decodeContour(cs::CSJsonDictionary &json); + static ContourData *decodeContour(cs::JsonDictionary &json); - static void decodeNode(BaseData *node, cs::CSJsonDictionary &json); + static void decodeNode(BaseData *node, cs::JsonDictionary &json); }; }}} // namespace cocos2d { namespace extension { namespace armature { diff --git a/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp b/extensions/CocoStudio/Armature/utils/CCSpriteFrameCacheHelper.cpp similarity index 100% rename from extensions/CCArmature/utils/CCSpriteFrameCacheHelper.cpp rename to extensions/CocoStudio/Armature/utils/CCSpriteFrameCacheHelper.cpp diff --git a/extensions/CCArmature/utils/CCSpriteFrameCacheHelper.h b/extensions/CocoStudio/Armature/utils/CCSpriteFrameCacheHelper.h similarity index 100% rename from extensions/CCArmature/utils/CCSpriteFrameCacheHelper.h rename to extensions/CocoStudio/Armature/utils/CCSpriteFrameCacheHelper.h diff --git a/extensions/CCArmature/utils/CCTransformHelp.cpp b/extensions/CocoStudio/Armature/utils/CCTransformHelp.cpp similarity index 100% rename from extensions/CCArmature/utils/CCTransformHelp.cpp rename to extensions/CocoStudio/Armature/utils/CCTransformHelp.cpp diff --git a/extensions/CCArmature/utils/CCTransformHelp.h b/extensions/CocoStudio/Armature/utils/CCTransformHelp.h similarity index 100% rename from extensions/CCArmature/utils/CCTransformHelp.h rename to extensions/CocoStudio/Armature/utils/CCTransformHelp.h diff --git a/extensions/CCArmature/utils/CCTweenFunction.cpp b/extensions/CocoStudio/Armature/utils/CCTweenFunction.cpp similarity index 100% rename from extensions/CCArmature/utils/CCTweenFunction.cpp rename to extensions/CocoStudio/Armature/utils/CCTweenFunction.cpp diff --git a/extensions/CCArmature/utils/CCTweenFunction.h b/extensions/CocoStudio/Armature/utils/CCTweenFunction.h similarity index 100% rename from extensions/CCArmature/utils/CCTweenFunction.h rename to extensions/CocoStudio/Armature/utils/CCTweenFunction.h diff --git a/extensions/CCArmature/utils/CCUtilMath.cpp b/extensions/CocoStudio/Armature/utils/CCUtilMath.cpp similarity index 100% rename from extensions/CCArmature/utils/CCUtilMath.cpp rename to extensions/CocoStudio/Armature/utils/CCUtilMath.cpp diff --git a/extensions/CCArmature/utils/CCUtilMath.h b/extensions/CocoStudio/Armature/utils/CCUtilMath.h similarity index 100% rename from extensions/CCArmature/utils/CCUtilMath.h rename to extensions/CocoStudio/Armature/utils/CCUtilMath.h diff --git a/extensions/Components/CCComAttribute.cpp b/extensions/CocoStudio/Components/CCComAttribute.cpp similarity index 96% rename from extensions/Components/CCComAttribute.cpp rename to extensions/CocoStudio/Components/CCComAttribute.cpp index 314cf2e426..30505ab486 100644 --- a/extensions/Components/CCComAttribute.cpp +++ b/extensions/CocoStudio/Components/CCComAttribute.cpp @@ -28,12 +28,14 @@ NS_CC_EXT_BEGIN ComAttribute::ComAttribute(void) : _attributes(NULL) +, _jsonDict(NULL) { _name = "ComAttribute"; } ComAttribute::~ComAttribute(void) { + CC_SAFE_DELETE(_jsonDict); CC_SAFE_RELEASE(_attributes); } @@ -41,6 +43,8 @@ bool ComAttribute::init() { _attributes = Dictionary::create(); _attributes->retain(); + + _jsonDict = new cs::JsonDictionary(); return true; } @@ -180,4 +184,9 @@ Object* ComAttribute::getObject(const char *key) const return _attributes->objectForKey(key); } +cs::JsonDictionary* ComAttribute::getDict() const +{ + return _jsonDict; +} + NS_CC_EXT_END diff --git a/extensions/Components/CCComAttribute.h b/extensions/CocoStudio/Components/CCComAttribute.h similarity index 95% rename from extensions/Components/CCComAttribute.h rename to extensions/CocoStudio/Components/CCComAttribute.h index 3e0855b1d0..3f714f4824 100644 --- a/extensions/Components/CCComAttribute.h +++ b/extensions/CocoStudio/Components/CCComAttribute.h @@ -28,6 +28,7 @@ THE SOFTWARE. #include "cocos2d.h" #include "ExtensionMacros.h" #include +#include "../Json/CSContentJsonDictionary.h" NS_CC_EXT_BEGIN @@ -55,8 +56,10 @@ public: const char* getCString(const char *key) const; Object* getObject(const char *key) const; + cs::JsonDictionary* getDict() const; private: Dictionary *_attributes; + cs::JsonDictionary *_jsonDict; }; diff --git a/extensions/Components/CCComAudio.cpp b/extensions/CocoStudio/Components/CCComAudio.cpp similarity index 94% rename from extensions/Components/CCComAudio.cpp rename to extensions/CocoStudio/Components/CCComAudio.cpp index 93a55b594e..87afa64348 100644 --- a/extensions/Components/CCComAudio.cpp +++ b/extensions/CocoStudio/Components/CCComAudio.cpp @@ -28,6 +28,8 @@ THE SOFTWARE. NS_CC_EXT_BEGIN ComAudio::ComAudio(void) +: _filePath("") +, _loop(false) { _name = "Audio"; } @@ -201,5 +203,24 @@ void ComAudio::unloadEffect(const char *pszFilePath) CocosDenshion::SimpleAudioEngine::getInstance()->unloadEffect(pszFilePath); } +void ComAudio::setFile(const char* pszFilePath) +{ + _filePath.assign(pszFilePath); +} + +void ComAudio::setLoop(bool bLoop) +{ + _loop = bLoop; +} + +const char* ComAudio::getFile() +{ + return _filePath.c_str(); +} + +bool ComAudio::isLoop() +{ + return _loop; +} NS_CC_EXT_END diff --git a/extensions/Components/CCComAudio.h b/extensions/CocoStudio/Components/CCComAudio.h similarity index 94% rename from extensions/Components/CCComAudio.h rename to extensions/CocoStudio/Components/CCComAudio.h index ebf7c38bed..0360bcaac0 100644 --- a/extensions/Components/CCComAudio.h +++ b/extensions/CocoStudio/Components/CCComAudio.h @@ -71,6 +71,13 @@ public: void stopAllEffects(); void preloadEffect(const char* pszFilePath); void unloadEffect(const char* pszFilePath); + void setFile(const char* pszFilePath); + const char* getFile(); + void setLoop(bool bLoop); + bool isLoop(); +private: + std::string _filePath; + bool _loop; }; NS_CC_EXT_END diff --git a/extensions/Components/CCComController.cpp b/extensions/CocoStudio/Components/CCComController.cpp similarity index 100% rename from extensions/Components/CCComController.cpp rename to extensions/CocoStudio/Components/CCComController.cpp diff --git a/extensions/Components/CCComController.h b/extensions/CocoStudio/Components/CCComController.h similarity index 100% rename from extensions/Components/CCComController.h rename to extensions/CocoStudio/Components/CCComController.h diff --git a/extensions/CocoStudio/Components/CCComRender.cpp b/extensions/CocoStudio/Components/CCComRender.cpp new file mode 100644 index 0000000000..4dbc18c464 --- /dev/null +++ b/extensions/CocoStudio/Components/CCComRender.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +Copyright (c) 2013 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. +****************************************************************************/ + +#include "CCComRender.h" + +NS_CC_EXT_BEGIN + +ComRender::ComRender(void) +: _render(NULL) +{ + +} + + +ComRender::ComRender(cocos2d::Node *node, const char *comName) +{ + _render = node; + _name.assign(comName); +} + +ComRender::~ComRender(void) +{ + _render = NULL; +} + +void ComRender::onEnter() +{ + if (_owner != NULL) + { + _owner->addChild(_render); + } +} + +void ComRender::onExit() +{ + _render = NULL; +} + +cocos2d::Node* ComRender::getNode() +{ + return _render; +} + +ComRender* ComRender::create(cocos2d::Node *pNode, const char *comName) +{ + ComRender * pRet = new ComRender(pNode, comName); + if (pRet != NULL && pRet->init()) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + return pRet; +} + +NS_CC_EXT_END diff --git a/extensions/CocoStudio/Components/CCComRender.h b/extensions/CocoStudio/Components/CCComRender.h new file mode 100644 index 0000000000..2be80d6d81 --- /dev/null +++ b/extensions/CocoStudio/Components/CCComRender.h @@ -0,0 +1,53 @@ +/**************************************************************************** +Copyright (c) 2013 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 __CC_EXTENTIONS_CCCOMNODE_H__ +#define __CC_EXTENTIONS_CCCOMNODE_H__ + +#include "cocos2d.h" +#include "cocos-ext.h" +#include "ExtensionMacros.h" + +NS_CC_EXT_BEGIN + +class ComRender : public cocos2d::Component +{ +protected: + ComRender(void); + ComRender(cocos2d::Node *node, const char *comName); + virtual ~ComRender(void); + +public: + virtual void onEnter(); + virtual void onExit(); + cocos2d::Node* getNode(); + + static ComRender* create(cocos2d::Node *pNode, const char *comName); + +private: + cocos2d::Node *_render; +}; + +NS_CC_EXT_END +#endif // __FUNDATION__CCCOMPONENT_H__ diff --git a/extensions/Components/CCInputDelegate.cpp b/extensions/CocoStudio/Components/CCInputDelegate.cpp similarity index 100% rename from extensions/Components/CCInputDelegate.cpp rename to extensions/CocoStudio/Components/CCInputDelegate.cpp diff --git a/extensions/Components/CCInputDelegate.h b/extensions/CocoStudio/Components/CCInputDelegate.h similarity index 100% rename from extensions/Components/CCInputDelegate.h rename to extensions/CocoStudio/Components/CCInputDelegate.h diff --git a/extensions/CocoStudio/Json/CSContentJsonDictionary.cpp b/extensions/CocoStudio/Json/CSContentJsonDictionary.cpp new file mode 100644 index 0000000000..afb37dc624 --- /dev/null +++ b/extensions/CocoStudio/Json/CSContentJsonDictionary.cpp @@ -0,0 +1,388 @@ +/* + * Copyright (c) 2012 Chukong Technologies, Inc. + * + * http://www.cocostudio.com + * http://tools.cocoachina.com + * + * 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. + */ + +#include +#include "CSContentJsonDictionary.h" + +namespace cs { + + JsonDictionary::JsonDictionary() + { + m_cValue.clear(); + } + + + JsonDictionary::~JsonDictionary() + { + m_cValue.clear(); + } + + + void JsonDictionary::initWithDescription(const char *pszDescription) + { + CSJson::Reader cReader; + m_cValue.clear(); + if (pszDescription && *pszDescription) + { + std::string strValue = pszDescription; + cReader.parse(strValue, m_cValue, false); + } + } + + + void JsonDictionary::initWithValue(CSJson::Value& value) + { + m_cValue = value; + } + + + void JsonDictionary::insertItem(const char *pszKey, int nValue) + { + m_cValue[pszKey] = nValue; + } + + + void JsonDictionary::insertItem(const char *pszKey, double fValue) + { + m_cValue[pszKey] = fValue; + } + + + void JsonDictionary::insertItem(const char *pszKey, const char * pszValue) + { + m_cValue[pszKey] = pszValue; + } + + void JsonDictionary::insertItem(const char *pszKey, bool bValue) + { + m_cValue[pszKey] = bValue; + } + + void JsonDictionary::insertItem(const char *pszKey, JsonDictionary * subDictionary) + { + if (subDictionary) + m_cValue[pszKey] = subDictionary->m_cValue; + } + + + bool JsonDictionary::deleteItem(const char *pszKey) + { + if(!m_cValue.isMember(pszKey)) + return false; + + m_cValue.removeMember(pszKey); + + return true; + } + + + void JsonDictionary::cleanUp() + { + m_cValue.clear(); + } + + + bool JsonDictionary::isKeyValidate(const char *pszKey) + { + return m_cValue.isMember(pszKey); + } + + + int JsonDictionary::getItemIntValue(const char *pszKey, int nDefaultValue) + { + if (!isKeyValidate(pszKey, m_cValue) || !m_cValue[pszKey].isNumeric()) + return nDefaultValue; + + return m_cValue[pszKey].asInt(); + } + + + double JsonDictionary::getItemFloatValue(const char *pszKey, double fDefaultValue) + { + if (!isKeyValidate(pszKey, m_cValue) || !m_cValue[pszKey].isNumeric()) + return fDefaultValue; + + return m_cValue[pszKey].asDouble(); + } + + + const char * JsonDictionary::getItemStringValue(const char *pszKey) + { + if (!isKeyValidate(pszKey, m_cValue) || !m_cValue[pszKey].isString()) + return NULL; + + return m_cValue[pszKey].asCString(); + } + + bool JsonDictionary::getItemBoolvalue(const char *pszKey, bool bDefaultValue) + { + if (!isKeyValidate(pszKey, m_cValue) || !m_cValue[pszKey].isBool()) + return bDefaultValue; + + return m_cValue[pszKey].asBool(); + } + + + JsonDictionary * JsonDictionary::getSubDictionary(const char *pszKey) + { + JsonDictionary * pNewDictionary; + if (!isKeyValidate(pszKey, m_cValue) || (!m_cValue[pszKey].isArray() && + !m_cValue[pszKey].isObject() && + !m_cValue[pszKey].isConvertibleTo(CSJson::arrayValue) && + !m_cValue[pszKey].isConvertibleTo(CSJson::objectValue))) + { + pNewDictionary = NULL; + } + else + { + pNewDictionary = new JsonDictionary(); + pNewDictionary->initWithValue(m_cValue[pszKey]); + } + return pNewDictionary; + } + + + std::string JsonDictionary::getDescription() + { + std::string strReturn = m_cValue.toStyledString(); + return strReturn; + } + + + bool JsonDictionary::insertItemToArray(const char *pszArrayKey, int nValue) + { + CSJson::Value array; + if(m_cValue.isMember(pszArrayKey)) + { + if (!m_cValue[pszArrayKey].isArray() && !m_cValue[pszArrayKey].isConvertibleTo(CSJson::arrayValue)) + return false; + + array = m_cValue[pszArrayKey]; + } + + array.append(nValue); + m_cValue[pszArrayKey] = array; + + return true; + } + + + bool JsonDictionary::insertItemToArray(const char *pszArrayKey, double fValue) + { + CSJson::Value array; + if(m_cValue.isMember(pszArrayKey)) + { + if (!m_cValue[pszArrayKey].isArray() && !m_cValue[pszArrayKey].isConvertibleTo(CSJson::arrayValue)) + return false; + + array = m_cValue[pszArrayKey]; + } + + array.append(fValue); + m_cValue[pszArrayKey] = array; + + return true; + } + + + bool JsonDictionary::insertItemToArray(const char *pszArrayKey, const char * pszValue) + { + CSJson::Value array; + if(m_cValue.isMember(pszArrayKey)) + { + if (!m_cValue[pszArrayKey].isArray() && !m_cValue[pszArrayKey].isConvertibleTo(CSJson::arrayValue)) + return false; + + array = m_cValue[pszArrayKey]; + } + + array.append(pszValue); + m_cValue[pszArrayKey] = array; + + return true; + } + + + bool JsonDictionary::insertItemToArray(const char *pszArrayKey, JsonDictionary * subDictionary) + { + CSJson::Value array; + if(m_cValue.isMember(pszArrayKey)) + { + if (!m_cValue[pszArrayKey].isArray() && !m_cValue[pszArrayKey].isConvertibleTo(CSJson::arrayValue)) + return false; + + array = m_cValue[pszArrayKey]; + } + + array.append(subDictionary->m_cValue); + m_cValue[pszArrayKey] = array; + + return true; + } + + + int JsonDictionary::getItemCount() + { + return m_cValue.size(); + } + + + DicItemType JsonDictionary::getItemType(int nIndex) + { + return (DicItemType)m_cValue[nIndex].type(); + } + + + DicItemType JsonDictionary::getItemType(const char *pszKey) + { + return (DicItemType)m_cValue[pszKey].type(); + } + + std::vector JsonDictionary::getAllMemberNames() + { + return m_cValue.getMemberNames(); + } + + + int JsonDictionary::getArrayItemCount(const char *pszArrayKey) + { + int nRet = 0; + if (!isKeyValidate(pszArrayKey, m_cValue) || + (!m_cValue[pszArrayKey].isArray() && !m_cValue[pszArrayKey].isObject() && + !m_cValue[pszArrayKey].isConvertibleTo(CSJson::arrayValue) && !m_cValue[pszArrayKey].isConvertibleTo(CSJson::objectValue))) + { + nRet = 0; + } + else + { + CSJson::Value arrayValue = m_cValue[pszArrayKey]; + nRet = arrayValue.size(); + } + + return nRet; + } + + + int JsonDictionary::getIntValueFromArray(const char *pszArrayKey, int nIndex, int nDefaultValue) + { + int nRet = nDefaultValue; + CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); + if (arrayValue) + { + if ((*arrayValue)[nIndex].isNumeric()) + nRet = (*arrayValue)[nIndex].asInt(); + } + + return nRet; + } + + + double JsonDictionary::getFloatValueFromArray(const char *pszArrayKey, int nIndex, double fDefaultValue) + { + double fRet = fDefaultValue; + CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); + if (arrayValue) + { + if ((*arrayValue)[nIndex].isNumeric()) + fRet = (*arrayValue)[nIndex].asDouble(); + } + + return fRet; + } + + bool JsonDictionary::getBoolValueFromArray(const char *pszArrayKey, int nIndex, bool bDefaultValue) + { + bool bRet = bDefaultValue; + CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); + if (arrayValue) + { + if ((*arrayValue)[nIndex].isNumeric()) + bRet = (*arrayValue)[nIndex].asBool(); + } + + return bRet; + } + + + const char * JsonDictionary::getStringValueFromArray(const char *pszArrayKey, int nIndex) + { + CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); + if (arrayValue) + { + if ((*arrayValue)[nIndex].isString()) + return (*arrayValue)[nIndex].asCString(); + } + + return NULL; + } + + + JsonDictionary * JsonDictionary::getSubItemFromArray(const char *pszArrayKey, int nIndex) + { + CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); + if (arrayValue) + { + if ((*arrayValue)[nIndex].isArray() || (*arrayValue)[nIndex].isObject()) + { + JsonDictionary * pNewDictionary = new JsonDictionary(); + pNewDictionary->initWithValue((*arrayValue)[nIndex]); + return pNewDictionary; + } + } + + return NULL; + } + + + DicItemType JsonDictionary::getItemTypeFromArray(const char *pszArrayKey, int nIndex) + { + CSJson::Value * arrayValue = validateArrayItem(pszArrayKey, nIndex); + if (arrayValue) + return (DicItemType)((*arrayValue)[nIndex].type()); + + return (DicItemType)CSJson::nullValue; + } + + + inline bool JsonDictionary::isKeyValidate(const char *pszKey, CSJson::Value& root) + { + if (root.isNull() || !root.isMember(pszKey)) + return false; + + return true; + } + + + inline CSJson::Value * JsonDictionary::validateArrayItem(const char *pszArrayKey, int nIndex) + { + if (!isKeyValidate(pszArrayKey, m_cValue) && !m_cValue[pszArrayKey].isArray() && !m_cValue[pszArrayKey].isConvertibleTo(CSJson::arrayValue)) + return NULL; + if (!m_cValue[pszArrayKey].isValidIndex(nIndex)) + return NULL; + + return &m_cValue[pszArrayKey]; + } +} diff --git a/extensions/CCArmature/external_tool/Json/CSContentJsonDictionary.h b/extensions/CocoStudio/Json/CSContentJsonDictionary.h similarity index 87% rename from extensions/CCArmature/external_tool/Json/CSContentJsonDictionary.h rename to extensions/CocoStudio/Json/CSContentJsonDictionary.h index 1d95f8c8b0..3908e71545 100644 --- a/extensions/CCArmature/external_tool/Json/CSContentJsonDictionary.h +++ b/extensions/CocoStudio/Json/CSContentJsonDictionary.h @@ -46,18 +46,18 @@ namespace cs { EDIC_TYPEOBJECT }DicItemType; - class CSJsonDictionary + class JsonDictionary { public: - CSJsonDictionary(); - ~CSJsonDictionary(); + JsonDictionary(); + ~JsonDictionary(); public: void initWithDescription(const char *pszDescription); void insertItem(const char *pszKey, int nValue); void insertItem(const char *pszKey, double fValue); void insertItem(const char *pszKey, const char * pszValue); - void insertItem(const char *pszKey, CSJsonDictionary * subDictionary); + void insertItem(const char *pszKey, JsonDictionary * subDictionary); void insertItem(const char *pszKey, bool bValue); bool deleteItem(const char *pszKey); void cleanUp(); @@ -67,20 +67,21 @@ namespace cs { double getItemFloatValue(const char *pszKey, double fDefaultValue); const char * getItemStringValue(const char *pszKey); bool getItemBoolvalue(const char *pszKey, bool bDefaultValue); - CSJsonDictionary * getSubDictionary(const char *pszKey); + JsonDictionary * getSubDictionary(const char *pszKey); std::string getDescription(); bool insertItemToArray(const char *pszArrayKey, int nValue); bool insertItemToArray(const char *pszArrayKey, double fValue); bool insertItemToArray(const char *pszArrayKey, const char * pszValue); - bool insertItemToArray(const char *pszArrayKey, CSJsonDictionary * subDictionary); + bool insertItemToArray(const char *pszArrayKey, JsonDictionary * subDictionary); int getArrayItemCount(const char *pszArrayKey); int getIntValueFromArray(const char *pszArrayKey, int nIndex, int nDefaultValue); double getFloatValueFromArray(const char *pszArrayKey, int nIndex, double fDefaultValue); + bool getBoolValueFromArray(const char *pszArrayKey, int nIndex, bool bDefaultValue); const char * getStringValueFromArray(const char *pszArrayKey, int nIndex); - CSJsonDictionary *getSubItemFromArray(const char *pszArrayKey, int nIndex); + JsonDictionary *getSubItemFromArray(const char *pszArrayKey, int nIndex); DicItemType getItemTypeFromArray(const char *pszArrayKey, int nIndex); int getItemCount(); @@ -89,7 +90,7 @@ namespace cs { std::vector getAllMemberNames(); protected: - CSJson::Value _value; + CSJson::Value m_cValue; private: void initWithValue(CSJson::Value& value); diff --git a/extensions/CocoStudio/Json/DictionaryHelper.cpp b/extensions/CocoStudio/Json/DictionaryHelper.cpp new file mode 100644 index 0000000000..db93ba1563 --- /dev/null +++ b/extensions/CocoStudio/Json/DictionaryHelper.cpp @@ -0,0 +1,289 @@ +/**************************************************************************** + Copyright (c) 2013 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. + ****************************************************************************/ + +#include "DictionaryHelper.h" + +NS_CC_EXT_BEGIN + +static DictionaryHelper* sharedHelper = NULL; + +DictionaryHelper::DictionaryHelper() +{ + +} + +DictionaryHelper::~DictionaryHelper() +{ + +} + +DictionaryHelper* DictionaryHelper::shareHelper() +{ + if (!sharedHelper) { + sharedHelper = new DictionaryHelper(); + } + return sharedHelper; +} + +void DictionaryHelper::purgeDictionaryHelper() +{ + CC_SAFE_DELETE(sharedHelper); +} + +cocos2d::Dictionary* DictionaryHelper::getSubDictionary(cocos2d::Dictionary* root,const char* key) +{ + if (!root) { + return NULL; + } + cocos2d::Object* obj = root->objectForKey(key); + if (!obj) { + return NULL; + } + return (cocos2d::Dictionary*)(obj); +} + +int DictionaryHelper::getIntValue(cocos2d::Dictionary* root,const char* key) +{ + if (!root) { + return 0; + } + cocos2d::Object* obj = root->objectForKey(key); + if (!obj) { + return 0; + } + + cocos2d::String* cstr = (cocos2d::String*)(obj); + return cstr->intValue(); +} + +float DictionaryHelper::getFloatValue(cocos2d::Dictionary* root,const char* key) +{ + if (!root) { + return 0.0; + } + cocos2d::Object* obj = root->objectForKey(key); + if (!obj) { + return 0.0f; + } + cocos2d::String* cstr = (cocos2d::String*)(obj); + return cstr->floatValue(); +} + +const char* DictionaryHelper::getStringValue(cocos2d::Dictionary* root,const char* key) +{ + if (!root) { + return NULL; + } + cocos2d::Object* obj = root->objectForKey(key); + if (!obj) { + return NULL; + } + cocos2d::String* cstr = (cocos2d::String*)(obj); + return cstr->_string.c_str(); +} + +bool DictionaryHelper::getBooleanValue(cocos2d::Dictionary* root,const char* key) +{ + return this->getIntValue(root, key); +} + +cocos2d::Array* DictionaryHelper::getArrayValue(cocos2d::Dictionary *root, const char *key) +{ + if (!root) { + return NULL; + } + cocos2d::Object* obj = root->objectForKey(key); + if (!obj) { + return NULL; + } + cocos2d::Array* array = (cocos2d::Array*)(obj); + return array; +} + +cocos2d::Object* DictionaryHelper::checkObjectExist(cocos2d::Dictionary *root, const char *key) +{ + if (!root) { + return NULL; + } + return root->objectForKey(key); +} + +int DictionaryHelper::objectToIntValue(cocos2d::Object *obj) +{ + if (!obj) + { + return 0; + } + cocos2d::String* cstr = (cocos2d::String*)(obj); + return cstr->intValue(); +} + +float DictionaryHelper::objectToFloatValue(cocos2d::Object *obj) +{ + if (!obj) + { + return 0.0f; + } + cocos2d::String* cstr = (cocos2d::String*)(obj); + return cstr->floatValue(); +} + +const char* DictionaryHelper::objectToStringValue(cocos2d::Object *obj) +{ + if (!obj) + { + return NULL; + } + cocos2d::String* cstr = (cocos2d::String*)(obj); + return cstr->_string.c_str(); +} + +bool DictionaryHelper::objectToBooleanValue(cocos2d::Object *obj) +{ + if (!obj) + { + return 0; + } + return this->objectToIntValue(obj); +} + +cocos2d::Array* DictionaryHelper::objectToCCArray(cocos2d::Object *obj) +{ + if (!obj) + { + return NULL; + } + cocos2d::Array* array = (cocos2d::Array*)(obj); + return array; +} + +cs::JsonDictionary* DictionaryHelper::getSubDictionary_json(cs::JsonDictionary* root,const char* key) +{ + if (!root) + { + return NULL; + } + return root->getSubDictionary(key); +} + +int DictionaryHelper::getIntValue_json(cs::JsonDictionary* root,const char* key) +{ + if (!root) + { + return 0; + } + return root->getItemIntValue(key, 0); +} + +float DictionaryHelper::getFloatValue_json(cs::JsonDictionary* root,const char* key) +{ + if (!root) + { + return 0.0f; + } + return root->getItemFloatValue(key, 0.0); +} + +const char* DictionaryHelper::getStringValue_json(cs::JsonDictionary* root,const char* key) +{ + if (!root) + { + return NULL; + } + return root->getItemStringValue(key); +} + +bool DictionaryHelper::getBooleanValue_json(cs::JsonDictionary* root,const char* key) +{ + if (!root) + { + return 0; + } + return root->getItemBoolvalue(key, false); +} + +int DictionaryHelper::getArrayCount_json(cs::JsonDictionary* root,const char* key) +{ + if (!root) + { + return 0; + } + return root->getArrayItemCount(key); +} + +int DictionaryHelper::getIntValueFromArray_json(cs::JsonDictionary* root,const char* arrayKey,int idx) +{ + if (!root) + { + return 0; + } + return root->getIntValueFromArray(arrayKey, idx, 0); +} + +float DictionaryHelper::getFloatValueFromArray_json(cs::JsonDictionary* root,const char* arrayKey,int idx) +{ + if (!root) + { + return 0.0f; + } + return root->getFloatValueFromArray(arrayKey, idx, 0.0); +} + +bool DictionaryHelper::getBoolValueFromArray_json(cs::JsonDictionary* root,const char* arrayKey,int idx) +{ + if (!root) + { + return false; + } + return root->getBoolValueFromArray(arrayKey, idx, false); +} + +const char* DictionaryHelper::getStringValueFromArray_json(cs::JsonDictionary *root, const char *arrayKey, int idx) +{ + if (!root) + { + return NULL; + } + return root->getStringValueFromArray(arrayKey, idx); +} + +cs::JsonDictionary* DictionaryHelper::getDictionaryFromArray_json(cs::JsonDictionary* root,const char* arrayKey,int idx) +{ + if (!root) + { + return NULL; + } + return root->getSubItemFromArray(arrayKey, idx); +} + +bool DictionaryHelper::checkObjectExist_json(cs::JsonDictionary *root, const char *key) +{ + if (!root) + { + return false; + } + return root->isKeyValidate(key); +} + +NS_CC_EXT_END \ No newline at end of file diff --git a/extensions/CocoStudio/Json/DictionaryHelper.h b/extensions/CocoStudio/Json/DictionaryHelper.h new file mode 100644 index 0000000000..e63e3173e2 --- /dev/null +++ b/extensions/CocoStudio/Json/DictionaryHelper.h @@ -0,0 +1,72 @@ +/**************************************************************************** + Copyright (c) 2013 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 __DICTIONARYHELPER_H__ +#define __DICTIONARYHELPER_H__ + +#include "cocos2d.h" +#include "cocos-ext.h" +#include "ExtensionMacros.h" + +#define DICTOOL DictionaryHelper::shareHelper() + +NS_CC_EXT_BEGIN + +class DictionaryHelper +{ +public: + DictionaryHelper(); + ~DictionaryHelper(); + static DictionaryHelper* shareHelper(); + static void purgeDictionaryHelper(); + cocos2d::CCDictionary* getSubDictionary(cocos2d::CCDictionary* root,const char* key); + int getIntValue(cocos2d::CCDictionary* root,const char* key); + float getFloatValue(cocos2d::CCDictionary* root,const char* key); + const char* getStringValue(cocos2d::CCDictionary* root,const char* key); + bool getBooleanValue(cocos2d::CCDictionary* root,const char* key); + cocos2d::CCArray* getArrayValue(cocos2d::CCDictionary* root,const char* key); + cocos2d::CCObject* checkObjectExist(cocos2d::CCDictionary* root,const char* key); + int objectToIntValue(cocos2d::CCObject* obj); + float objectToFloatValue(cocos2d::CCObject* obj); + const char* objectToStringValue(cocos2d::CCObject* obj); + bool objectToBooleanValue(cocos2d::CCObject* obj); + cocos2d::CCArray* objectToCCArray(cocos2d::CCObject* obj); + + cs::JsonDictionary* getSubDictionary_json(cs::JsonDictionary* root,const char* key); + int getIntValue_json(cs::JsonDictionary* root,const char* key); + float getFloatValue_json(cs::JsonDictionary* root,const char* key); + const char* getStringValue_json(cs::JsonDictionary* root,const char* key); + bool getBooleanValue_json(cs::JsonDictionary* root,const char* key); + int getArrayCount_json(cs::JsonDictionary* root,const char* key); + int getIntValueFromArray_json(cs::JsonDictionary* root,const char* arrayKey,int idx); + float getFloatValueFromArray_json(cs::JsonDictionary* root,const char* arrayKey,int idx); + bool getBoolValueFromArray_json(cs::JsonDictionary* root,const char* arrayKey,int idx); + const char* getStringValueFromArray_json(cs::JsonDictionary* root,const char* arrayKey,int idx); + cs::JsonDictionary* getDictionaryFromArray_json(cs::JsonDictionary* root,const char* arrayKey,int idx); + bool checkObjectExist_json(cs::JsonDictionary* root,const char* key); +}; + +NS_CC_EXT_END + +#endif /* defined(__CocoGUI__DictionaryHelper__) */ diff --git a/extensions/CCArmature/external_tool/Json/lib_json/autolink.h b/extensions/CocoStudio/Json/lib_json/autolink.h similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/autolink.h rename to extensions/CocoStudio/Json/lib_json/autolink.h diff --git a/extensions/CCArmature/external_tool/Json/lib_json/config.h b/extensions/CocoStudio/Json/lib_json/config.h similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/config.h rename to extensions/CocoStudio/Json/lib_json/config.h diff --git a/extensions/CCArmature/external_tool/Json/lib_json/features.h b/extensions/CocoStudio/Json/lib_json/features.h similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/features.h rename to extensions/CocoStudio/Json/lib_json/features.h diff --git a/extensions/CCArmature/external_tool/Json/lib_json/forwards.h b/extensions/CocoStudio/Json/lib_json/forwards.h similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/forwards.h rename to extensions/CocoStudio/Json/lib_json/forwards.h diff --git a/extensions/CCArmature/external_tool/Json/lib_json/json_batchallocator.h b/extensions/CocoStudio/Json/lib_json/json_batchallocator.h similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/json_batchallocator.h rename to extensions/CocoStudio/Json/lib_json/json_batchallocator.h diff --git a/extensions/CCArmature/external_tool/Json/lib_json/json_internalarray.inl b/extensions/CocoStudio/Json/lib_json/json_internalarray.inl similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/json_internalarray.inl rename to extensions/CocoStudio/Json/lib_json/json_internalarray.inl diff --git a/extensions/CCArmature/external_tool/Json/lib_json/json_internalmap.inl b/extensions/CocoStudio/Json/lib_json/json_internalmap.inl similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/json_internalmap.inl rename to extensions/CocoStudio/Json/lib_json/json_internalmap.inl diff --git a/extensions/CCArmature/external_tool/Json/lib_json/json_lib.h b/extensions/CocoStudio/Json/lib_json/json_lib.h similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/json_lib.h rename to extensions/CocoStudio/Json/lib_json/json_lib.h diff --git a/extensions/CCArmature/external_tool/Json/lib_json/json_reader.cpp b/extensions/CocoStudio/Json/lib_json/json_reader.cpp similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/json_reader.cpp rename to extensions/CocoStudio/Json/lib_json/json_reader.cpp diff --git a/extensions/CCArmature/external_tool/Json/lib_json/json_tool.h b/extensions/CocoStudio/Json/lib_json/json_tool.h similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/json_tool.h rename to extensions/CocoStudio/Json/lib_json/json_tool.h diff --git a/extensions/CCArmature/external_tool/Json/lib_json/json_value.cpp b/extensions/CocoStudio/Json/lib_json/json_value.cpp similarity index 99% rename from extensions/CCArmature/external_tool/Json/lib_json/json_value.cpp rename to extensions/CocoStudio/Json/lib_json/json_value.cpp index 0090a5279d..e62b9c36a1 100644 --- a/extensions/CCArmature/external_tool/Json/lib_json/json_value.cpp +++ b/extensions/CocoStudio/Json/lib_json/json_value.cpp @@ -480,7 +480,12 @@ Value::~Value() #ifndef JSON_VALUE_USE_INTERNAL_MAP case arrayValue: case objectValue: - delete value_.map_; + if (value_.map_ != NULL) + { + value_.map_->clear(); + delete value_.map_; + value_.map_ = NULL; + } break; #else case arrayValue: @@ -1028,12 +1033,17 @@ Value::clear() case arrayValue: case objectValue: // value_.map_->clear(); - if (!value_.map_) + if (value_.map_ != NULL) { value_.map_->clear(); delete value_.map_; value_.map_ = NULL; } + if (value_.string_ != NULL) + { + delete value_.string_; + value_.string_ = NULL; + } break; #else case arrayValue: diff --git a/extensions/CCArmature/external_tool/Json/lib_json/json_valueiterator.inl b/extensions/CocoStudio/Json/lib_json/json_valueiterator.inl similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/json_valueiterator.inl rename to extensions/CocoStudio/Json/lib_json/json_valueiterator.inl diff --git a/extensions/CCArmature/external_tool/Json/lib_json/json_writer.cpp b/extensions/CocoStudio/Json/lib_json/json_writer.cpp similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/json_writer.cpp rename to extensions/CocoStudio/Json/lib_json/json_writer.cpp diff --git a/extensions/CCArmature/external_tool/Json/lib_json/reader.h b/extensions/CocoStudio/Json/lib_json/reader.h similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/reader.h rename to extensions/CocoStudio/Json/lib_json/reader.h diff --git a/extensions/CCArmature/external_tool/Json/lib_json/sconscript b/extensions/CocoStudio/Json/lib_json/sconscript similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/sconscript rename to extensions/CocoStudio/Json/lib_json/sconscript diff --git a/extensions/CCArmature/external_tool/Json/lib_json/value.h b/extensions/CocoStudio/Json/lib_json/value.h similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/value.h rename to extensions/CocoStudio/Json/lib_json/value.h diff --git a/extensions/CCArmature/external_tool/Json/lib_json/writer.h b/extensions/CocoStudio/Json/lib_json/writer.h similarity index 100% rename from extensions/CCArmature/external_tool/Json/lib_json/writer.h rename to extensions/CocoStudio/Json/lib_json/writer.h diff --git a/extensions/CocoStudio/Reader/CCSSceneReader.cpp b/extensions/CocoStudio/Reader/CCSSceneReader.cpp new file mode 100644 index 0000000000..e4abe0e35d --- /dev/null +++ b/extensions/CocoStudio/Reader/CCSSceneReader.cpp @@ -0,0 +1,397 @@ +/**************************************************************************** + Copyright (c) 2013 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. + ****************************************************************************/ + +#include "CCSSceneReader.h" +#include "cocos-ext.h" + +NS_CC_EXT_BEGIN + + SceneReader* SceneReader::s_sharedReader = NULL; + + SceneReader::SceneReader() + { + } + + SceneReader::~SceneReader() + { + } + + const char* SceneReader::sceneReaderVersion() + { + return "0.1.0.0"; + } + + cocos2d::Node* SceneReader::createNodeWithSceneFile(const char* pszFileName) + { + unsigned long size = 0; + const char* pData = 0; + cocos2d::Node *pNode = NULL; + do { + CC_BREAK_IF(pszFileName == NULL); + std::string strFileName(pszFileName); + if (std::string::npos != strFileName.find_last_of('/')) + { + strFileName = strFileName.substr(0, strFileName.find_last_of('/') + 1); + cocos2d::CCFileUtils::sharedFileUtils()->addSearchPath(strFileName.c_str()); + } + pData = (char*)(cocos2d::CCFileUtils::sharedFileUtils()->getFileData(pszFileName, "r", &size)); + CC_BREAK_IF(pData == NULL || strcmp(pData, "") == 0); + cs::JsonDictionary *jsonDict = new cs::JsonDictionary(); + jsonDict->initWithDescription(pData); + pNode = createObject(jsonDict,NULL); + CC_SAFE_DELETE(jsonDict); + } while (0); + + return pNode; + } + + Node* SceneReader::createObject(cs::JsonDictionary * inputFiles, Node* parenet) + { + const char *className = inputFiles->getItemStringValue("classname"); + if(strcmp(className, "CCNode") == 0) + { + Node* gb = NULL; + if(NULL == parenet) + { + gb = Node::create(); + } + else + { + gb = Node::create(); + parenet->addChild(gb); + } + + setPropertyFromJsonDict(gb, inputFiles); + + int count = inputFiles->getArrayItemCount("components"); + for (int i = 0; i < count; i++) + { + cs::JsonDictionary * subDict = inputFiles->getSubItemFromArray("components", i); + if (!subDict) + { + CC_SAFE_DELETE(subDict); + break; + } + const char *comName = subDict->getItemStringValue("classname"); + const char *pComName = subDict->getItemStringValue("name"); + + cs::JsonDictionary *fileData = subDict->getSubDictionary("fileData"); + std::string pPath; + std::string pPlistFile; + int nResType = 0; + if (fileData != NULL) + { + const char *file = fileData->getItemStringValue("path"); + nResType = fileData->getItemIntValue("resourceType", -1); + const char *plistFile = fileData->getItemStringValue("plistFile"); + if (file != NULL) + { + pPath.append(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(file)); + } + + if (plistFile != NULL) + { + pPlistFile.append(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(plistFile)); + } + CC_SAFE_DELETE(fileData); + } + + if (comName != NULL && strcmp(comName, "CCSprite") == 0) + { + cocos2d::Sprite *pSprite = NULL; + + if (nResType == 0) + { + if (pPath.find(".png") == pPath.npos) + { + continue; + } + pSprite = Sprite::create(pPath.c_str()); + } + else if (nResType == 1) + { + std::string pngFile = pPlistFile; + std::string::size_type pos = pngFile.find(".plist"); + if (pos == pPath.npos) + { + continue; + } + pngFile.replace(pos, pngFile.length(), ".png"); + CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(pPlistFile.c_str(), pngFile.c_str()); + pSprite = Sprite::createWithSpriteFrameName(pPath.c_str()); + } + else + { + continue; + } + + ComRender *pRender = ComRender::create(pSprite, "CCSprite"); + if (pComName != NULL) + { + pRender->setName(pComName); + } + + gb->addComponent(pRender); + } + else if(comName != NULL && strcmp(comName, "CCTMXTiledMap") == 0) + { + cocos2d::TMXTiledMap *pTmx = NULL; + if (nResType == 0) + { + if (pPath.find(".tmx") == pPath.npos) + { + continue; + } + pTmx = TMXTiledMap::create(pPath.c_str()); + } + else + { + continue; + } + + ComRender *pRender = ComRender::create(pTmx, "CCTMXTiledMap"); + if (pComName != NULL) + { + pRender->setName(pComName); + } + gb->addComponent(pRender); + } + else if(comName != NULL && strcmp(comName, "CCParticleSystemQuad") == 0) + { + std::string::size_type pos = pPath.find(".plist"); + if (pos == pPath.npos) + { + continue; + } + + cocos2d::ParticleSystemQuad *pParticle = NULL; + if (nResType == 0) + { + pParticle = ParticleSystemQuad::create(pPath.c_str()); + } + else + { + CCLog("unknown resourcetype on CCParticleSystemQuad!"); + } + + pParticle->setPosition(0, 0); + ComRender *pRender = ComRender::create(pParticle, "CCParticleSystemQuad"); + if (pComName != NULL) + { + pRender->setName(pComName); + } + gb->addComponent(pRender); + } + else if(comName != NULL && strcmp(comName, "CCArmature") == 0) + { + continue; + if (nResType != 0) + { + continue; + } + std::string reDir = pPath; + std::string file_path = ""; + size_t pos = reDir.find_last_of('/'); + if (pos != std::string::npos) + { + file_path = reDir.substr(0, pos+1); + } + unsigned long size = 0; + const char *des = (char*)(cocos2d::FileUtils::sharedFileUtils()->getFileData(pPath.c_str(),"r" , &size)); + cs::JsonDictionary *jsonDict = new cs::JsonDictionary(); + jsonDict->initWithDescription(des); + if(NULL == des || strcmp(des, "") == 0) + { + CCLog("read json file[%s] error!\n", pPath.c_str()); + } + + int childrenCount = DICTOOL->getArrayCount_json(jsonDict, "armature_data"); + cs::JsonDictionary* subData = DICTOOL->getDictionaryFromArray_json(jsonDict, "armature_data", 0); + const char *name = DICTOOL->getStringValue_json(subData, "name"); + + childrenCount = DICTOOL->getArrayCount_json(jsonDict, "config_file_path"); + for (int i = 0; i < childrenCount; ++i) + { + const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", i); + std::string plistpath; + plistpath += file_path; + plistpath.append(plist); + cocos2d::CCDictionary *root = CCDictionary::createWithContentsOfFile(plistpath.c_str()); + CCDictionary* metadata = DICTOOL->getSubDictionary(root, "metadata"); + const char* textureFileName = DICTOOL->getStringValue(metadata, "textureFileName"); + + std::string textupath; + textupath += file_path; + textupath.append(textureFileName); + + cocos2d::extension::armature::CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo(textupath.c_str(), plistpath.c_str(), pPath.c_str()); + + } + + cocos2d::extension::armature::Armature *pAr = cocos2d::extension::armature::Armature::create(name); + ComRender *pRender = ComRender::create(pAr, "CCArmature"); + if (pComName != NULL) + { + pRender->setName(pComName); + } + gb->addComponent(pRender); + + const char *actionName = subDict->getItemStringValue("selectedactionname"); + if (actionName != NULL && pAr->getAnimation() != NULL) + { + pAr->getAnimation()->play(actionName); + } + + CC_SAFE_DELETE(jsonDict); + CC_SAFE_DELETE(subData); + CC_SAFE_DELETE_ARRAY(des); + } + else if(comName != NULL && strcmp(comName, "CCComAudio") == 0) + { + CCComAudio *pAudio = NULL; + if (nResType == 0) + { + pAudio = CCComAudio::create(); + } + else + { + continue; + } + pAudio->preloadEffect(pPath.c_str()); + gb->addComponent(pAudio); + } + else if(comName != NULL && strcmp(comName, "CCComAttribute") == 0) + { + ComAttribute *pAttribute = NULL; + if (nResType == 0) + { + pAttribute = ComAttribute::create(); + unsigned long size = 0; + const char* pData = 0; + pData = (char*)(cocos2d::CCFileUtils::sharedFileUtils()->getFileData(pPath.c_str(), "r", &size)); + if(pData != NULL && strcmp(pData, "") != 0) + { + pAttribute->getDict()->initWithDescription(pData); + } + } + else + { + CCLog("unknown resourcetype on CCComAttribute!"); + continue; + } + gb->addComponent(pAttribute); + } + else if (comName != NULL && strcmp(comName, "CCBackgroundAudio") == 0) + { + ComAudio *pAudio = NULL; + if (nResType == 0) + { + pAudio = CCComAudio::create(); + } + else + { + continue; + } + pAudio->preloadBackgroundMusic(pPath.c_str()); + pAudio->setFile(pPath.c_str()); + bool bLoop = subDict->getItemIntValue("loop", 0); + pAudio->setLoop(bLoop); + gb->addComponent(pAudio); + pAudio->playBackgroundMusic(pPath.c_str(), bLoop); + } + else if(comName != NULL && strcmp(comName, "GUIComponent") == 0) + { + /* cocos2d::extension::UILayer *pLayer = cocos2d::extension::UILayer::create(); + pLayer->scheduleUpdate(); + UIWidget* widget=cocos2d::extension::UIHelper::instance()->createWidgetFromJsonFile(pPath.c_str()); + pLayer->addWidget(widget); + CCComRender *pRender = CCComRender::create(pLayer, "GUIComponent"); + if (pComName != NULL) + { + pRender->setName(pComName); + } + gb->addComponent(pRender);*/ + } + + CC_SAFE_DELETE(subDict); + } + + for (int i = 0; i < inputFiles->getArrayItemCount("gameobjects"); i++) + { + cs::JsonDictionary * subDict = inputFiles->getSubItemFromArray("gameobjects", i); + if (!subDict) + { + break; + } + createObject(subDict, gb); + CC_SAFE_DELETE(subDict); + } + + return gb; + } + + return NULL; + } + + + void SceneReader::setPropertyFromJsonDict(cocos2d::Node *node, cs::JsonDictionary* dict) + { + int x = dict->getItemIntValue("x", 0); + int y = dict->getItemIntValue("y", 0); + node->setPosition(ccp(x, y)); + + bool bVisible = (bool)(dict->getItemIntValue("visible", 1)); + node->setVisible(bVisible); + + int nTag = dict->getItemIntValue("objecttag", -1); + node->setTag(nTag); + + int nZorder = dict->getItemIntValue("zorder", 0); + node->setZOrder(nZorder); + + float fScaleX = dict->getItemFloatValue("scalex", 1.0); + float fScaleY = dict->getItemFloatValue("scaley", 1.0); + node->setScaleX(fScaleX); + node->setScaleY(fScaleY); + + float fRotationZ = dict->getItemIntValue("rotation", 0); + node->setRotation(fRotationZ); + } + + SceneReader* SceneReader::sharedSceneReader() + { + if (s_sharedReader == NULL) + { + s_sharedReader = new SceneReader(); + } + return s_sharedReader; + } + + void SceneReader::purgeSceneReader() + { + CC_SAFE_DELETE(s_sharedReader); + cocos2d::extension::DictionaryHelper::shareHelper()->purgeDictionaryHelper(); + } + +NS_CC_EXT_END diff --git a/extensions/CocoStudio/Reader/CCSSceneReader.h b/extensions/CocoStudio/Reader/CCSSceneReader.h new file mode 100644 index 0000000000..0595509cf0 --- /dev/null +++ b/extensions/CocoStudio/Reader/CCSSceneReader.h @@ -0,0 +1,56 @@ +/**************************************************************************** + Copyright (c) 2013 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 __CCSSCENEREADER_H__ +#define __CCSSCENEREADER_H__ + +#include "cocos2d.h" +#include "cocos-ext.h" +#include "ExtensionMacros.h" + +NS_CC_EXT_BEGIN + + class SceneReader + { + public: + SceneReader(void); + ~SceneReader(void); + + public: + static SceneReader* sharedSceneReader(); + void purgeSceneReader(); + static const char* sceneReaderVersion(); + cocos2d::Node* createNodeWithSceneFile(const char *pszFileName); + private: + cocos2d::Node* createObject(cs::JsonDictionary * inputFiles, cocos2d::Node* parent); + void setPropertyFromJsonDict(cocos2d::Node *node, cs::JsonDictionary* dict); + + private: + static SceneReader* s_sharedReader; + }; + + +NS_CC_EXT_END + +#endif diff --git a/extensions/cocos-ext.h b/extensions/cocos-ext.h index 716f269065..761372c1d4 100644 --- a/extensions/cocos-ext.h +++ b/extensions/cocos-ext.h @@ -50,9 +50,34 @@ #include "spine/spine-cocos2dx.h" -#include "Components/CCComAttribute.h" -#include "Components/CCComAudio.h" -#include "Components/CCComController.h" +#include "CocoStudio/Armature/CCArmature.h" +#include "CocoStudio/Armature/CCBone.h" +#include "CocoStudio/Armature/animation/CCArmatureAnimation.h" +#include "CocoStudio/Armature/datas/CCDatas.h" +#include "CocoStudio/Armature/display/CCBatchNode.h" +#include "CocoStudio/Armature/display/CCDecorativeDisplay.h" +#include "CocoStudio/Armature/display/CCDisplayManager.h" +#include "CocoStudio/Armature/display/CCSkin.h" +#include "CocoStudio/Armature/physics/CCColliderDetector.h" +#include "CocoStudio/Armature/physics/CCPhysicsWorld.h" +#include "CocoStudio/Armature/utils/CCArmatureDataManager.h" +#include "CocoStudio/Armature/utils/CCConstValue.h" +#include "CocoStudio/Armature/utils/CCDataReaderHelper.h" +#include "CocoStudio/Armature/utils/CCTweenFunction.h" +#include "CocoStudio/Armature/utils/CCArmatureDataManager.h" +#include "CocoStudio/Armature/external_tool/sigslot.h" + +#include "CocoStudio/Components/CCComAttribute.h" +#include "CocoStudio/Components/CCComAudio.h" +#include "CocoStudio/Components/CCComController.h" +#include "CocoStudio/Components/CCComRender.h" + +#include "CocoStudio/Json/CSContentJsonDictionary.h" +#include "CocoStudio/Json/DictionaryHelper.h" + +#include "CocoStudio/Reader/CCSSceneReader.h" + + #include "CCDeprecated-ext.h" diff --git a/extensions/proj.win32/libExtensions.vcxproj b/extensions/proj.win32/libExtensions.vcxproj index 03fa7848c0..964cc89d22 100644 --- a/extensions/proj.win32/libExtensions.vcxproj +++ b/extensions/proj.win32/libExtensions.vcxproj @@ -93,32 +93,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -143,10 +117,38 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -196,42 +198,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -259,10 +225,48 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -318,9 +322,10 @@ - - - + + + + diff --git a/extensions/proj.win32/libExtensions.vcxproj.filters b/extensions/proj.win32/libExtensions.vcxproj.filters index 47fcc20bd4..9bcc34aceb 100644 --- a/extensions/proj.win32/libExtensions.vcxproj.filters +++ b/extensions/proj.win32/libExtensions.vcxproj.filters @@ -1,734 +1,761 @@ - - - - - {d37545ef-285b-4315-9fca-40da6fc2a6c9} - - - {202b519b-b5e0-499f-b3b8-ed5da144b248} - - - {c07abd14-e9dd-4e2d-85c4-a180070161b4} - - - {46797895-f71d-4ddb-b381-d0884e678d39} - - - {d5806151-7ae1-4fef-af5a-2fa1d1c7377b} - - - {4da8061d-80f3-45fd-aa7e-2c0a96701b79} - - - {5d186e3d-0aaf-4904-a5d8-e5cb0f35f4cc} - - - {49487dbe-5758-436a-b014-8e2edc6b33ae} - - - {ff4b5934-99d4-4ea7-9f50-a774192d9ca9} - - - {2a7741ff-87a5-41c8-8e51-d7a1cf0c8e4d} - - - {cf3469d5-421b-4990-a9be-4cd95129fb73} - - - {f48d1291-33fe-49a1-8f9f-4d203e782d4a} - - - {043f8489-822e-43c8-8d9d-5d171a701663} - - - {b8c65820-b5c9-4bd6-83c8-180fdc6100fb} - - - {fa9a165e-cc7c-45e9-ae4f-cae3c2f16e6a} - - - {5e5b3d7d-62a7-493e-a130-ed72ee7c65f2} - - - {5258a1e1-5d50-4fee-9216-da08d2ec19de} - - - {bd365bbb-6972-4073-b268-8360df428166} - - - - - GUI\CCScrollView - - - network - - - GUI\CCScrollView - - - GUI\CCScrollView - - - GUI\CCScrollView - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - physics_nodes - - - physics_nodes - - - LocalStorage - - - GUI\CCEditBox - - - GUI\CCEditBox - - - GUI\CCEditBox - - - AssetsManager - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - network - - - CCArmature - - - CCArmature - - - CCArmature\animation - - - CCArmature\animation - - - CCArmature\animation - - - CCArmature\datas - - - CCArmature\display - - - CCArmature\display - - - CCArmature\display - - - CCArmature\display - - - CCArmature\display - - - CCArmature\display - - - CCArmature\physics - - - CCArmature\physics - - - CCArmature\utils - - - CCArmature\utils - - - CCArmature\utils - - - CCArmature\utils - - - CCArmature\utils - - - CCArmature\utils - - - Components - - - Components - - - Components - - - Components - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - network - - - - - - GUI\CCScrollView - - - - - network - - - network - - - network - - - GUI\CCScrollView - - - GUI\CCScrollView - - - GUI\CCScrollView - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - CCBReader - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - GUI\CCControlExtension - - - physics_nodes - - - physics_nodes - - - LocalStorage - - - GUI\CCEditBox - - - GUI\CCEditBox - - - GUI\CCEditBox - - - GUI\CCEditBox - - - AssetsManager - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - spine - - - network - - - CCArmature - - - CCArmature - - - CCArmature\animation - - - CCArmature\animation - - - CCArmature\animation - - - CCArmature\datas - - - CCArmature\display - - - CCArmature\display - - - CCArmature\display - - - CCArmature\display - - - CCArmature\display - - - CCArmature\display - - - CCArmature\physics - - - CCArmature\physics - - - CCArmature\utils - - - CCArmature\utils - - - CCArmature\utils - - - CCArmature\utils - - - CCArmature\utils - - - CCArmature\utils - - - CCArmature\utils - - - CCArmature\utils - - - Components - - - Components - - - Components - - - Components - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - - network - - - - - CCArmature\external_tool - - - CCArmature\external_tool - - - CCArmature\external_tool - - + + + + + {d37545ef-285b-4315-9fca-40da6fc2a6c9} + + + {202b519b-b5e0-499f-b3b8-ed5da144b248} + + + {c07abd14-e9dd-4e2d-85c4-a180070161b4} + + + {46797895-f71d-4ddb-b381-d0884e678d39} + + + {d5806151-7ae1-4fef-af5a-2fa1d1c7377b} + + + {4da8061d-80f3-45fd-aa7e-2c0a96701b79} + + + {5d186e3d-0aaf-4904-a5d8-e5cb0f35f4cc} + + + {49487dbe-5758-436a-b014-8e2edc6b33ae} + + + {ff4b5934-99d4-4ea7-9f50-a774192d9ca9} + + + {2a7741ff-87a5-41c8-8e51-d7a1cf0c8e4d} + + + {87250d95-2afd-45e7-bc9d-760478c4e709} + + + {5258a1e1-5d50-4fee-9216-da08d2ec19de} + + + {cf3469d5-421b-4990-a9be-4cd95129fb73} + + + {f48d1291-33fe-49a1-8f9f-4d203e782d4a} + + + {043f8489-822e-43c8-8d9d-5d171a701663} + + + {b8c65820-b5c9-4bd6-83c8-180fdc6100fb} + + + {fa9a165e-cc7c-45e9-ae4f-cae3c2f16e6a} + + + {5e5b3d7d-62a7-493e-a130-ed72ee7c65f2} + + + {bd365bbb-6972-4073-b268-8360df428166} + + + {d797adcd-2e59-4486-944e-b3e7f3a954b8} + + + {a824cea6-86d7-4230-8738-513a869a1882} + + + {d305abea-33cc-4ae8-b78d-b5fb59927e59} + + + + + GUI\CCScrollView + + + network + + + GUI\CCScrollView + + + GUI\CCScrollView + + + GUI\CCScrollView + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + physics_nodes + + + physics_nodes + + + LocalStorage + + + GUI\CCEditBox + + + GUI\CCEditBox + + + GUI\CCEditBox + + + AssetsManager + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + network + + + network + + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Armature\animation + + + CocoStudio\Armature\animation + + + CocoStudio\Armature\animation + + + CocoStudio\Armature\datas + + + CocoStudio\Armature\display + + + CocoStudio\Armature\display + + + CocoStudio\Armature\display + + + CocoStudio\Armature\display + + + CocoStudio\Armature\display + + + CocoStudio\Armature\display + + + CocoStudio\Armature\physics + + + CocoStudio\Armature\physics + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature + + + CocoStudio\Armature + + + CocoStudio\Json + + + CocoStudio\Json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Reader + + + CocoStudio\Components + + + CocoStudio\Armature\external_tool + + + + + GUI\CCScrollView + + + + + network + + + network + + + network + + + GUI\CCScrollView + + + GUI\CCScrollView + + + GUI\CCScrollView + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + CCBReader + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + GUI\CCControlExtension + + + physics_nodes + + + physics_nodes + + + LocalStorage + + + GUI\CCEditBox + + + GUI\CCEditBox + + + GUI\CCEditBox + + + GUI\CCEditBox + + + AssetsManager + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + spine + + + network + + + network + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Components + + + CocoStudio\Armature\animation + + + CocoStudio\Armature\animation + + + CocoStudio\Armature\animation + + + CocoStudio\Armature\datas + + + CocoStudio\Armature\display + + + CocoStudio\Armature\display + + + CocoStudio\Armature\display + + + CocoStudio\Armature\display + + + CocoStudio\Armature\display + + + CocoStudio\Armature\display + + + CocoStudio\Armature\external_tool + + + CocoStudio\Armature\physics + + + CocoStudio\Armature\physics + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature\utils + + + CocoStudio\Armature + + + CocoStudio\Armature + + + CocoStudio\Json + + + CocoStudio\Json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Reader + + + CocoStudio\Components + + + CocoStudio\Armature\external_tool + + + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + + CocoStudio\Json\lib_json + + \ No newline at end of file From 99f32077d2f01b9d0fcfe75366ad4688439978df Mon Sep 17 00:00:00 2001 From: zhangcheng Date: Mon, 9 Sep 2013 19:52:07 +0800 Subject: [PATCH 23/37] 1. upload SceneTest Resources. --- .../Resources/scenetest/Images/startMenuBG.png.REMOVED.git-id | 1 + .../Resources/scenetest/Misc/music_logo.mp3.REMOVED.git-id | 1 + .../fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id | 1 + .../scenetest/fishes/blowFish/Blowfish0.png.REMOVED.git-id | 1 + 4 files changed, 4 insertions(+) create mode 100644 samples/Cpp/TestCpp/Resources/scenetest/Images/startMenuBG.png.REMOVED.git-id create mode 100644 samples/Cpp/TestCpp/Resources/scenetest/Misc/music_logo.mp3.REMOVED.git-id create mode 100644 samples/Cpp/TestCpp/Resources/scenetest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id create mode 100644 samples/Cpp/TestCpp/Resources/scenetest/fishes/blowFish/Blowfish0.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/scenetest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/Images/startMenuBG.png.REMOVED.git-id new file mode 100644 index 0000000000..ab08309b7e --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/Images/startMenuBG.png.REMOVED.git-id @@ -0,0 +1 @@ +5d84575ee663bd1c3d56b7501b6183302afb62e2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/Misc/music_logo.mp3.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/Misc/music_logo.mp3.REMOVED.git-id new file mode 100644 index 0000000000..604b21ac01 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/Misc/music_logo.mp3.REMOVED.git-id @@ -0,0 +1 @@ +4b2aa3f3fbf2f96bced91d0da0e8fc2f7f863a61 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..13d9610346 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +e22c64c159404622ff93915eb9f01be011001dac \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/fishes/blowFish/Blowfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/fishes/blowFish/Blowfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..d35dbb70ac --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/fishes/blowFish/Blowfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +d7d85cd75e382c2dd04ddc34ca1d07e2ffff66d5 \ No newline at end of file From 8a86a883d0901250c7f469c8857c1009063c0cc0 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 9 Sep 2013 21:33:01 +0800 Subject: [PATCH 24/37] issue #2782: update mac version, update test case title --- samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp | 1 - samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h | 2 +- samples/Cpp/TestCpp/Classes/controller.cpp | 2 +- samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp index ce0043c355..df59d624bc 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp @@ -532,4 +532,3 @@ CelShadingSpriteTest::CelShadingSpriteTest() addChild(sprite); } } - diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h index b284540075..af41389ff8 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h @@ -10,7 +10,7 @@ class ShaderTestDemo2 : public BaseTest { public: ShaderTestDemo2(void); - virtual std::string title() { return "New Shader Test!";} + virtual std::string title() { return "Shader Sprite!";} void restartCallback(Object* sender); void nextCallback(Object* sender); void backCallback(Object* sender); diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp index cd2f4e02b0..7bb555beef 100644 --- a/samples/Cpp/TestCpp/Classes/controller.cpp +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -70,7 +70,7 @@ struct { { "SceneTest", [](){return new SceneTestScene();} }, { "SchedulerTest", [](){return new SchedulerTestScene(); } }, { "ShaderTest", []() { return new ShaderTestScene(); } }, - { "NewShaderTest", []() { return new ShaderTestScene2(); } }, + { "ShaderTestSprite", []() { return new ShaderTestScene2(); } }, { "SpineTest", []() { return new SpineTestScene(); } }, { "SpriteTest", [](){return new SpriteTestScene(); } }, { "TextInputTest", [](){return new TextInputTestScene(); } }, diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index b0a731cd10..c40efdcb3c 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -fe014a4c9bc5fb6471d516b0e288b0287708c53c \ No newline at end of file +9ee8407529629a345665ab3dccf235c1e7acff22 \ No newline at end of file From 31e3faaa4f7e9bc6b52fb22c1917aa576c5f3425 Mon Sep 17 00:00:00 2001 From: Nako Sung Date: Mon, 9 Sep 2013 22:38:37 +0900 Subject: [PATCH 25/37] Update AppDelegate.cpp --- samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp index 6f747004dc..8dadda36ac 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp @@ -92,7 +92,7 @@ void UpdateLayer::update(cocos2d::Object *pSender) pProgressLabel->setString(""); // update resources - getAssetsManager()->update(); + pAssetsManager->update(); isUpdateItemClicked = true; } @@ -114,7 +114,7 @@ void UpdateLayer::reset(cocos2d::Object *pSender) system(command.c_str()); #endif // Delete recorded version codes. - getAssetsManager()->deleteVersion(); + pAssetsManager->deleteVersion(); createDownloadedDir(); } From f2fc710f868a25dcc0424cb9c61c7713a3f8632b Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 10 Sep 2013 09:32:03 +0800 Subject: [PATCH 26/37] issue #2782: shadertestSprite android make file --- samples/Cpp/TestCpp/Android.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index 68106673cd..6d4374c254 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -101,6 +101,7 @@ Classes/RotateWorldTest/RotateWorldTest.cpp \ Classes/SceneTest/SceneTest.cpp \ Classes/SchedulerTest/SchedulerTest.cpp \ Classes/ShaderTest/ShaderTest.cpp \ +Classes/ShaderTest/ShaderTest2.cpp \ Classes/SpineTest/SpineTest.cpp \ Classes/SpriteTest/SpriteTest.cpp \ Classes/TextInputTest/TextInputTest.cpp \ From 5801e9118ce29c1ce2d839dcaaab481581b1add3 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 10 Sep 2013 09:38:12 +0800 Subject: [PATCH 27/37] issue #2782: remove a blank test case --- samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp | 3 +-- samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h | 7 ------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp index df59d624bc..b386ff3500 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp @@ -13,8 +13,7 @@ namespace ShaderTest2 CL(NoiseSpriteTest), CL(EdgeDetectionSpriteTest), CL(BloomSpriteTest), - CL(CelShadingSpriteTest), - CL(FlameTest3) + CL(CelShadingSpriteTest) }; static unsigned int TEST_CASE_COUNT = sizeof(ShaderTest2::createFunctions) / sizeof(ShaderTest2::createFunctions[0]); diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h index af41389ff8..99efb38240 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.h @@ -78,11 +78,4 @@ public: virtual std::string subtitle() {return "CelShadingSpriteTest";} }; -class FlameTest3 : public ShaderTestDemo2 -{ -public: - FlameTest3() {} - virtual std::string subtitle() {return "FlameTest3";} -}; - #endif \ No newline at end of file From 98fce2fa846628bbcdca365480442ecc73ccad97 Mon Sep 17 00:00:00 2001 From: zhangcheng Date: Tue, 10 Sep 2013 09:53:15 +0800 Subject: [PATCH 28/37] 1. update Samples on develop branch. --- samples/Cpp/TestCpp/Classes/AppDelegate.cpp | 1 - .../ArmatureScene.cpp | 0 .../ArmatureScene.h | 17 --- .../ComponentsTestScene.cpp | 0 .../ComponentsTestScene.h | 0 .../EnemyController.cpp | 0 .../EnemyController.h | 0 .../GameOverScene.cpp | 0 .../GameOverScene.h | 0 .../PlayerController.cpp | 0 .../PlayerController.h | 0 .../ProjectileController.cpp | 0 .../ProjectileController.h | 0 .../SceneController.cpp | 0 .../SceneController.h | 0 .../CocoStudioSceneTest/SceneEditorTest.cpp | 111 ++++++++++++++++++ .../CocoStudioSceneTest/SceneEditorTest.h | 38 ++++++ .../Classes/ExtensionsTest/ExtensionsTest.cpp | 20 ++-- samples/Cpp/TestCpp/proj.emscripten/Makefile | 15 +-- samples/Cpp/TestCpp/proj.linux/Makefile | 15 +-- samples/Cpp/TestCpp/proj.nacl/Makefile | 15 +-- .../Cpp/TestCpp/proj.win32/TestCpp.vcxproj | 30 ++--- .../proj.win32/TestCpp.vcxproj.filters | 105 +++++++++-------- 23 files changed, 258 insertions(+), 109 deletions(-) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ArmatureTest => CocoStudioArmatureTest}/ArmatureScene.cpp (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ArmatureTest => CocoStudioArmatureTest}/ArmatureScene.h (84%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/ComponentsTestScene.cpp (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/ComponentsTestScene.h (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/EnemyController.cpp (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/EnemyController.h (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/GameOverScene.cpp (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/GameOverScene.h (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/PlayerController.cpp (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/PlayerController.h (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/ProjectileController.cpp (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/ProjectileController.h (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/SceneController.cpp (100%) rename samples/Cpp/TestCpp/Classes/ExtensionsTest/{ComponentsTest => CocoStudioComponentsTest}/SceneController.h (100%) create mode 100644 samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp create mode 100644 samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h diff --git a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp index 44c236d682..5b226d028b 100644 --- a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp @@ -4,7 +4,6 @@ #include "controller.h" #include "SimpleAudioEngine.h" #include "cocos-ext.h" -#include "CCArmature/utils/CCArmatureDataManager.h" USING_NS_CC; using namespace CocosDenshion; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h similarity index 84% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.h rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index 8115958e0f..2022432ac3 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -6,23 +6,6 @@ #include "../../VisibleRect.h" #include "../../testBasic.h" -#include "CCArmature/CCArmature.h" -#include "CCArmature/CCBone.h" -#include "CCArmature/animation/CCArmatureAnimation.h" -#include "CCArmature/datas/CCDatas.h" -#include "CCArmature/display/CCBatchNode.h" -#include "CCArmature/display/CCDecorativeDisplay.h" -#include "CCArmature/display/CCDisplayManager.h" -#include "CCArmature/display/CCSkin.h" -#include "CCArmature/physics/CCColliderDetector.h" -#include "CCArmature/physics/CCPhysicsWorld.h" -#include "CCArmature/utils/CCArmatureDataManager.h" -#include "CCArmature/utils/CCConstValue.h" -#include "CCArmature/utils/CCDataReaderHelper.h" -#include "CCArmature/utils/CCTweenFunction.h" -#include "CCArmature/external_tool/sigslot.h" - - class ArmatureTestScene : public TestScene { public: diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.h similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.h rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.h diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.h similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.h rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.h diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.h similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/GameOverScene.h rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.h diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.h similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.h rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.h diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.h similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.h rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.h diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.cpp rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.h similarity index 100% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/SceneController.h rename to samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.h diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp new file mode 100644 index 0000000000..29e5ae1917 --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -0,0 +1,111 @@ + +#include "cocos-ext.h" +#include "../ExtensionsTest.h" +#include "SceneEditorTest.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +SceneEditorTestLayer::~SceneEditorTestLayer() +{ + +} + +SceneEditorTestLayer::SceneEditorTestLayer() +{ + m_pCurNode = NULL; +} + +Scene* SceneEditorTestLayer::scene() +{ + Scene * scene = NULL; + do + { + // 'scene' is an autorelease object + scene = Scene::create(); + CC_BREAK_IF(! scene); + + // 'layer' is an autorelease object + SceneEditorTestLayer *layer = SceneEditorTestLayer::create(); + CC_BREAK_IF(! layer); + + // add layer as a child to scene + scene->addChild(layer); + } while (0); + + // return the scene + return scene; +} + +// on "init" you need to initialize your instance +bool SceneEditorTestLayer::init() +{ + bool bRet = false; + do + { + CC_BREAK_IF(! LayerColor::initWithColor( ccc4(0,0,0,255) ) ); + + Node *root = createGameScene(); + CC_BREAK_IF(!root); + this->addChild(root, 0, 1); + + bRet = true; + } while (0); + + return bRet; +} + +cocos2d::CCNode* SceneEditorTestLayer::createGameScene() +{ + Node *pNode = SceneReader::sharedSceneReader()->createNodeWithSceneFile("scenetest/FishJoy2.json"); + if (pNode == NULL) + { + return NULL; + } + m_pCurNode = pNode; + + //fishes + /*cocos2d::extension::armature::Armature *pBlowFish = getFish(10008, "blowFish"); + cocos2d::extension::armature::Armature *pButterFlyFish = getFish(10009, "butterFlyFish"); + pBlowFish->getAnimation()->playByIndex(0); + pButterFlyFish->getAnimation()->playByIndex(0);*/ + + CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(SceneEditorTestLayer::toExtensionsMainLayer)); + itemBack->setColor(ccc3(255, 255, 255)); + itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + CCMenu *menuBack = CCMenu::create(itemBack, NULL); + menuBack->setPosition(CCPointZero); + menuBack->setZOrder(4); + + pNode->addChild(menuBack); + + //ui action + //cocos2d::extension::UIActionManager::shareManager()->PlayActionByName("startMenu_1.json","Animation1"); + + return pNode; +} + +void SceneEditorTestLayer::toExtensionsMainLayer(cocos2d::CCObject *sender) +{ + + ExtensionsTestScene *pScene = new ExtensionsTestScene(); + pScene->runThisTest(); + pScene->release(); +} + + +void runSceneEditorTestLayer() +{ + CCScene *pScene = SceneEditorTestLayer::scene(); + CCDirector::sharedDirector()->replaceScene(pScene); +} + +cocos2d::extension::armature::Armature* SceneEditorTestLayer::getFish(int nTag, const char *pszName) +{ + if (m_pCurNode == NULL) + { + return NULL; + } + ComRender *pFishRender = (ComRender*)(m_pCurNode->getChildByTag(nTag)->getComponent(pszName)); + return (cocos2d::extension::armature::Armature *)(pFishRender->getNode()); +} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h new file mode 100644 index 0000000000..e7435bb00b --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h @@ -0,0 +1,38 @@ +#ifndef __SCENEEDITORTESTSCENE_H__ +#define __SCENEEDITORTESTSCENE_H__ + +#include "cocos2d.h" +#include "cocos-ext.h" + +void runSceneEditorTestLayer(); + +class SceneEditorTestLayer : public cocos2d::LayerColor +{ +public: + SceneEditorTestLayer(); + ~SceneEditorTestLayer(); + + // Here's a difference. Method 'init' in cocos2d-x returns bool, + // instead of returning 'id' in cocos2d-iphone + virtual bool init(); + + // there's no 'id' in cpp, so we recommand to return the exactly class pointer + static cocos2d::Scene* scene(); + + // implement the "static node()" method manually + CREATE_FUNC(SceneEditorTestLayer); + + // init scene + cocos2d::Node* createGameScene(); + + //back to Extensions Main Layer + void toExtensionsMainLayer(cocos2d::Object *sender); + + //get Fish based on Tag and name of Compoent + cocos2d::extension::armature::Armature* getFish(int nTag, const char *pszName); + +private: + cocos2d::CCNode *m_pCurNode; +}; + +#endif // __HELLOWORLD_SCENE_H__ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp index d1f0e9c7ae..ac8edcf030 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -7,8 +7,10 @@ #include "NetworkTest/HttpClientTest.h" #endif #include "TableViewTest/TableViewTestScene.h" -#include "ComponentsTest/ComponentsTestScene.h" -#include "ArmatureTest/ArmatureScene.h" + +#include "CocoStudioArmatureTest/ArmatureScene.h" +#include "CocoStudioComponentsTest/ComponentsTestScene.h" +#include "CocoStudioSceneTest/SceneEditorTest.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "NetworkTest/WebSocketTest.h" @@ -71,13 +73,15 @@ static struct { #endif { "TableViewTest", [](Object *sender){ runTableViewTest();} }, - { "CommponentTest", [](Object *sender) { runComponentsTestLayerTest(); } - }, - { "ArmatureTest", [](Object *sender) { ArmatureTestScene *scene = new ArmatureTestScene(); - scene->runThisTest(); - scene->release(); - } + { "CocoStudioArmatureTest", [](Object *sender) { ArmatureTestScene *scene = new ArmatureTestScene(); + scene->runThisTest(); + scene->release(); + } + }, + { "CocoStudioComponentsTest", [](Object *sender) { runComponentsTestLayerTest(); } }, + { "CocoStudioSceneTest", [](Object *sender) { runSceneEditorTestLayer(); } + } }; static const int g_maxTests = sizeof(g_extensionsTests) / sizeof(g_extensionsTests[0]); diff --git a/samples/Cpp/TestCpp/proj.emscripten/Makefile b/samples/Cpp/TestCpp/proj.emscripten/Makefile index 7673cd7ee5..b00db6ff17 100644 --- a/samples/Cpp/TestCpp/proj.emscripten/Makefile +++ b/samples/Cpp/TestCpp/proj.emscripten/Makefile @@ -49,13 +49,14 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/ExtensionsTest/ExtensionsTest.cpp \ ../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ ../Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ - ../Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp \ + ../Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp \ ../Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ ../Classes/FontTest/FontTest.cpp \ ../Classes/IntervalTest/IntervalTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.linux/Makefile b/samples/Cpp/TestCpp/proj.linux/Makefile index e3b33bb427..b1c7a88984 100644 --- a/samples/Cpp/TestCpp/proj.linux/Makefile +++ b/samples/Cpp/TestCpp/proj.linux/Makefile @@ -52,13 +52,14 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/ExtensionsTest/ExtensionsTest.cpp \ ../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ ../Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ - ../Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp \ + ../Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp \ ../Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ ../Classes/FontTest/FontTest.cpp \ ../Classes/IntervalTest/IntervalTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.nacl/Makefile b/samples/Cpp/TestCpp/proj.nacl/Makefile index 5b08010027..b1dab9b36a 100644 --- a/samples/Cpp/TestCpp/proj.nacl/Makefile +++ b/samples/Cpp/TestCpp/proj.nacl/Makefile @@ -55,13 +55,14 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp \ ../Classes/ExtensionsTest/ExtensionsTest.cpp \ ../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ - ../Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ - ../Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp \ + ../Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp \ + ../Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp \ ../Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ ../Classes/FileUtilsTest/FileUtilsTest.cpp \ ../Classes/FontTest/FontTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj index d954e1eb21..0370125b1b 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj @@ -137,15 +137,16 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O - - - - - - - + + + + + + + + @@ -246,17 +247,18 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O - - - - - - - + + + + + + + + diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters index 0580a13014..0c1718b5c9 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters @@ -226,15 +226,18 @@ {81ec2355-7efd-49e0-b6cb-b1bba23fbbc8} - - {f0a099b9-0cf3-4217-a311-8d2f84e503c9} - - - {285cdfb8-5749-4969-ae31-99ec25f15e6e} - {3d73aa04-d66e-43d3-921f-b867a753c113} + + {a6e7d28e-46a3-46c4-9735-b39e96f776f0} + + + {e0b48846-7f17-4abe-80a7-93cc7bf8b4a1} + + + {70cc5629-4a9a-494d-b126-6043d311031a} + @@ -525,27 +528,6 @@ Classes - - Classes\ExtensionsTest\ArmatureTest - - - Classes\ExtensionsTest\ComponentsTest - - - Classes\ExtensionsTest\ComponentsTest - - - Classes\ExtensionsTest\ComponentsTest - - - Classes\ExtensionsTest\ComponentsTest - - - Classes\ExtensionsTest\ComponentsTest - - - Classes\ExtensionsTest\ComponentsTest - Classes\ExtensionsTest\Scale9SpriteTest @@ -558,6 +540,30 @@ Classes\PerformanceTest + + Classes\ExtensionsTest\CocoStudioArmatureTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioSceneTest + @@ -1028,27 +1034,6 @@ Classes - - Classes\ExtensionsTest\ArmatureTest - - - Classes\ExtensionsTest\ComponentsTest - - - Classes\ExtensionsTest\ComponentsTest - - - Classes\ExtensionsTest\ComponentsTest - - - Classes\ExtensionsTest\ComponentsTest - - - Classes\ExtensionsTest\ComponentsTest - - - Classes\ExtensionsTest\ComponentsTest - Classes\ExtensionsTest\Scale9SpriteTest @@ -1058,5 +1043,29 @@ Classes\LabelTest + + Classes\ExtensionsTest\CocoStudioArmatureTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioComponentsTest + + + Classes\ExtensionsTest\CocoStudioSceneTest + \ No newline at end of file From 410125feba1987a3d251e8cf5e1662982ff38318 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 10 Sep 2013 10:06:06 +0800 Subject: [PATCH 29/37] [skip ci] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 2448e5be13..6d767e6f5c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -560,6 +560,7 @@ Developers: Nako Sung (nakosung) Fixing a bug that wrong logic when pass an empty std::vector to WebSocket::init. Exposing cc.RemoveSelf to JS. + exposed AssetsManager to javascript and added multiple-assetsManager support dotsquid Fixed the crash caused by improper deletion of VBOs and VAO in ParticleSystemQuad. From 54c5e63916231be6db443e7d857bdf3976de3a15 Mon Sep 17 00:00:00 2001 From: CocosRobot Date: Tue, 10 Sep 2013 02:07:54 +0000 Subject: [PATCH 30/37] [AUTO] : updating submodule reference to latest autogenerated bindings --- scripting/auto-generated | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripting/auto-generated b/scripting/auto-generated index e57e43aaf1..d94972074f 160000 --- a/scripting/auto-generated +++ b/scripting/auto-generated @@ -1 +1 @@ -Subproject commit e57e43aaf1aea16ecefad50de1c7db8c401468a5 +Subproject commit d94972074fcba0d2595b974d52d721e1eaee5da5 From 2912260b3a026cbb278fcd047e3d78100d7cab93 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 10 Sep 2013 11:00:57 +0800 Subject: [PATCH 31/37] issue #2782: shadertestSprite linux and windows version --- samples/Cpp/TestCpp/proj.linux/Makefile | 1 + samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj | 2 ++ samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/samples/Cpp/TestCpp/proj.linux/Makefile b/samples/Cpp/TestCpp/proj.linux/Makefile index e3b33bb427..8dd200ca1d 100644 --- a/samples/Cpp/TestCpp/proj.linux/Makefile +++ b/samples/Cpp/TestCpp/proj.linux/Makefile @@ -85,6 +85,7 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/SceneTest/SceneTest.cpp \ ../Classes/SchedulerTest/SchedulerTest.cpp \ ../Classes/ShaderTest/ShaderTest.cpp \ + ../Classes/ShaderTest/ShaderTest2.cpp \ ../Classes/SpriteTest/SpriteTest.cpp \ ../Classes/TextInputTest/TextInputTest.cpp \ ../Classes/Texture2dTest/Texture2dTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj index d954e1eb21..3bea274854 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj @@ -158,6 +158,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + @@ -268,6 +269,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters index 0580a13014..7c817c403b 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters @@ -558,6 +558,9 @@ Classes\PerformanceTest + + Classes\ShaderTest + @@ -1058,5 +1061,8 @@ Classes\LabelTest + + Classes\ShaderTest + \ No newline at end of file From 669de88e73645450c2b11e8891ae5afef7e83bd2 Mon Sep 17 00:00:00 2001 From: chengstory Date: Tue, 10 Sep 2013 11:02:50 +0800 Subject: [PATCH 32/37] 1. remove any unused functions. --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos2dx/support/component/CCComponent.cpp | 5 + cocos2dx/support/component/CCComponent.h | 1 + extensions/CocoStudio/Json/DictionaryHelper.h | 24 +- .../CocoStudio/Reader/CCSSceneReader.cpp | 34 +- extensions/CocoStudio/Reader/CCSSceneReader.h | 2 +- .../extensions.xcodeproj/project.pbxproj | 547 ++++++++---------- .../CocoStudioSceneTest/SceneEditorTest.cpp | 45 +- .../CocoStudioSceneTest/SceneEditorTest.h | 2 +- .../project.pbxproj.REMOVED.git-id | 2 +- 10 files changed, 319 insertions(+), 345 deletions(-) diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index dd6e2cc334..7cd9b186ae 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -0bd142a09d7aacd3dbff8f23c7a14966430e9c01 \ No newline at end of file +cee239faffacb79c42a315cc01d4bce887435f5b \ No newline at end of file diff --git a/cocos2dx/support/component/CCComponent.cpp b/cocos2dx/support/component/CCComponent.cpp index 2026a8a329..e0bfd75031 100644 --- a/cocos2dx/support/component/CCComponent.cpp +++ b/cocos2dx/support/component/CCComponent.cpp @@ -77,6 +77,11 @@ const char* Component::getName() const return _name.c_str(); } +void Component::setName(const char *pName) +{ + _name.assign(pName); +} + Node* Component::getOwner() const { return _owner; diff --git a/cocos2dx/support/component/CCComponent.h b/cocos2dx/support/component/CCComponent.h index f452d6df6a..7f059e4f48 100644 --- a/cocos2dx/support/component/CCComponent.h +++ b/cocos2dx/support/component/CCComponent.h @@ -46,6 +46,7 @@ public: static Component* create(void); const char* getName() const; + void setName(const char *pName); void setOwner(Node *pOwner); Node* getOwner() const; diff --git a/extensions/CocoStudio/Json/DictionaryHelper.h b/extensions/CocoStudio/Json/DictionaryHelper.h index e63e3173e2..a5570ef11a 100644 --- a/extensions/CocoStudio/Json/DictionaryHelper.h +++ b/extensions/CocoStudio/Json/DictionaryHelper.h @@ -40,18 +40,18 @@ public: ~DictionaryHelper(); static DictionaryHelper* shareHelper(); static void purgeDictionaryHelper(); - cocos2d::CCDictionary* getSubDictionary(cocos2d::CCDictionary* root,const char* key); - int getIntValue(cocos2d::CCDictionary* root,const char* key); - float getFloatValue(cocos2d::CCDictionary* root,const char* key); - const char* getStringValue(cocos2d::CCDictionary* root,const char* key); - bool getBooleanValue(cocos2d::CCDictionary* root,const char* key); - cocos2d::CCArray* getArrayValue(cocos2d::CCDictionary* root,const char* key); - cocos2d::CCObject* checkObjectExist(cocos2d::CCDictionary* root,const char* key); - int objectToIntValue(cocos2d::CCObject* obj); - float objectToFloatValue(cocos2d::CCObject* obj); - const char* objectToStringValue(cocos2d::CCObject* obj); - bool objectToBooleanValue(cocos2d::CCObject* obj); - cocos2d::CCArray* objectToCCArray(cocos2d::CCObject* obj); + cocos2d::Dictionary* getSubDictionary(cocos2d::Dictionary* root,const char* key); + int getIntValue(cocos2d::Dictionary* root,const char* key); + float getFloatValue(cocos2d::Dictionary* root,const char* key); + const char* getStringValue(cocos2d::Dictionary* root,const char* key); + bool getBooleanValue(cocos2d::Dictionary* root,const char* key); + cocos2d::Array* getArrayValue(cocos2d::Dictionary* root,const char* key); + cocos2d::Object* checkObjectExist(cocos2d::Dictionary* root,const char* key); + int objectToIntValue(cocos2d::Object* obj); + float objectToFloatValue(cocos2d::Object* obj); + const char* objectToStringValue(cocos2d::Object* obj); + bool objectToBooleanValue(cocos2d::Object* obj); + cocos2d::Array* objectToCCArray(cocos2d::Object* obj); cs::JsonDictionary* getSubDictionary_json(cs::JsonDictionary* root,const char* key); int getIntValue_json(cs::JsonDictionary* root,const char* key); diff --git a/extensions/CocoStudio/Reader/CCSSceneReader.cpp b/extensions/CocoStudio/Reader/CCSSceneReader.cpp index e4abe0e35d..00f6f2e932 100644 --- a/extensions/CocoStudio/Reader/CCSSceneReader.cpp +++ b/extensions/CocoStudio/Reader/CCSSceneReader.cpp @@ -53,9 +53,9 @@ NS_CC_EXT_BEGIN if (std::string::npos != strFileName.find_last_of('/')) { strFileName = strFileName.substr(0, strFileName.find_last_of('/') + 1); - cocos2d::CCFileUtils::sharedFileUtils()->addSearchPath(strFileName.c_str()); + cocos2d::CCFileUtils::getInstance()->addSearchPath(strFileName.c_str()); } - pData = (char*)(cocos2d::CCFileUtils::sharedFileUtils()->getFileData(pszFileName, "r", &size)); + pData = (char*)(cocos2d::CCFileUtils::getInstance()->getFileData(pszFileName, "r", &size)); CC_BREAK_IF(pData == NULL || strcmp(pData, "") == 0); cs::JsonDictionary *jsonDict = new cs::JsonDictionary(); jsonDict->initWithDescription(pData); @@ -107,12 +107,12 @@ NS_CC_EXT_BEGIN const char *plistFile = fileData->getItemStringValue("plistFile"); if (file != NULL) { - pPath.append(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(file)); + pPath.append(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file)); } if (plistFile != NULL) { - pPlistFile.append(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(plistFile)); + pPlistFile.append(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(plistFile)); } CC_SAFE_DELETE(fileData); } @@ -138,7 +138,7 @@ NS_CC_EXT_BEGIN continue; } pngFile.replace(pos, pngFile.length(), ".png"); - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(pPlistFile.c_str(), pngFile.c_str()); + CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(pPlistFile.c_str(), pngFile.c_str()); pSprite = Sprite::createWithSpriteFrameName(pPath.c_str()); } else @@ -192,7 +192,7 @@ NS_CC_EXT_BEGIN } else { - CCLog("unknown resourcetype on CCParticleSystemQuad!"); + CCLOG("unknown resourcetype on CCParticleSystemQuad!"); } pParticle->setPosition(0, 0); @@ -218,12 +218,12 @@ NS_CC_EXT_BEGIN file_path = reDir.substr(0, pos+1); } unsigned long size = 0; - const char *des = (char*)(cocos2d::FileUtils::sharedFileUtils()->getFileData(pPath.c_str(),"r" , &size)); + const char *des = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(),"r" , &size)); cs::JsonDictionary *jsonDict = new cs::JsonDictionary(); jsonDict->initWithDescription(des); if(NULL == des || strcmp(des, "") == 0) { - CCLog("read json file[%s] error!\n", pPath.c_str()); + CCLOG("read json file[%s] error!\n", pPath.c_str()); } int childrenCount = DICTOOL->getArrayCount_json(jsonDict, "armature_data"); @@ -237,8 +237,8 @@ NS_CC_EXT_BEGIN std::string plistpath; plistpath += file_path; plistpath.append(plist); - cocos2d::CCDictionary *root = CCDictionary::createWithContentsOfFile(plistpath.c_str()); - CCDictionary* metadata = DICTOOL->getSubDictionary(root, "metadata"); + cocos2d::Dictionary *root = Dictionary::createWithContentsOfFile(plistpath.c_str()); + Dictionary* metadata = DICTOOL->getSubDictionary(root, "metadata"); const char* textureFileName = DICTOOL->getStringValue(metadata, "textureFileName"); std::string textupath; @@ -269,10 +269,10 @@ NS_CC_EXT_BEGIN } else if(comName != NULL && strcmp(comName, "CCComAudio") == 0) { - CCComAudio *pAudio = NULL; + ComAudio *pAudio = NULL; if (nResType == 0) { - pAudio = CCComAudio::create(); + pAudio = ComAudio::create(); } else { @@ -289,7 +289,7 @@ NS_CC_EXT_BEGIN pAttribute = ComAttribute::create(); unsigned long size = 0; const char* pData = 0; - pData = (char*)(cocos2d::CCFileUtils::sharedFileUtils()->getFileData(pPath.c_str(), "r", &size)); + pData = (char*)(cocos2d::FileUtils::getInstance()->getFileData(pPath.c_str(), "r", &size)); if(pData != NULL && strcmp(pData, "") != 0) { pAttribute->getDict()->initWithDescription(pData); @@ -297,7 +297,7 @@ NS_CC_EXT_BEGIN } else { - CCLog("unknown resourcetype on CCComAttribute!"); + CCLOG("unknown resourcetype on CCComAttribute!"); continue; } gb->addComponent(pAttribute); @@ -307,7 +307,7 @@ NS_CC_EXT_BEGIN ComAudio *pAudio = NULL; if (nResType == 0) { - pAudio = CCComAudio::create(); + pAudio = ComAudio::create(); } else { @@ -359,7 +359,7 @@ NS_CC_EXT_BEGIN { int x = dict->getItemIntValue("x", 0); int y = dict->getItemIntValue("y", 0); - node->setPosition(ccp(x, y)); + node->setPosition(Point(x, y)); bool bVisible = (bool)(dict->getItemIntValue("visible", 1)); node->setVisible(bVisible); @@ -379,7 +379,7 @@ NS_CC_EXT_BEGIN node->setRotation(fRotationZ); } - SceneReader* SceneReader::sharedSceneReader() + SceneReader* SceneReader::getInstance() { if (s_sharedReader == NULL) { diff --git a/extensions/CocoStudio/Reader/CCSSceneReader.h b/extensions/CocoStudio/Reader/CCSSceneReader.h index 0595509cf0..2beda9bab1 100644 --- a/extensions/CocoStudio/Reader/CCSSceneReader.h +++ b/extensions/CocoStudio/Reader/CCSSceneReader.h @@ -38,7 +38,7 @@ NS_CC_EXT_BEGIN ~SceneReader(void); public: - static SceneReader* sharedSceneReader(); + static SceneReader* getInstance(); void purgeSceneReader(); static const char* sceneReaderVersion(); cocos2d::Node* createNodeWithSceneFile(const char *pszFileName); diff --git a/extensions/proj.ios/extensions.xcodeproj/project.pbxproj b/extensions/proj.ios/extensions.xcodeproj/project.pbxproj index 416d3b308b..27b4f0923e 100644 --- a/extensions/proj.ios/extensions.xcodeproj/project.pbxproj +++ b/extensions/proj.ios/extensions.xcodeproj/project.pbxproj @@ -9,32 +9,6 @@ /* Begin PBXBuildFile section */ 1A0C0A7E1777F79700838530 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A0C0A7D1777F79700838530 /* Foundation.framework */; }; 1A0C0CEA1777F9CD00838530 /* AssetsManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0BF01777F9CD00838530 /* AssetsManager.cpp */; }; - 1A0C0CEB1777F9CD00838530 /* CCArmatureAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0BF41777F9CD00838530 /* CCArmatureAnimation.cpp */; }; - 1A0C0CEC1777F9CD00838530 /* CCProcessBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0BF61777F9CD00838530 /* CCProcessBase.cpp */; }; - 1A0C0CED1777F9CD00838530 /* CCTween.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0BF81777F9CD00838530 /* CCTween.cpp */; }; - 1A0C0CEE1777F9CD00838530 /* CCArmature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0BFA1777F9CD00838530 /* CCArmature.cpp */; }; - 1A0C0CEF1777F9CD00838530 /* CCBone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0BFC1777F9CD00838530 /* CCBone.cpp */; }; - 1A0C0CF01777F9CD00838530 /* CCDatas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0BFF1777F9CD00838530 /* CCDatas.cpp */; }; - 1A0C0CF11777F9CD00838530 /* CCBatchNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C021777F9CD00838530 /* CCBatchNode.cpp */; }; - 1A0C0CF21777F9CD00838530 /* CCDecorativeDisplay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C041777F9CD00838530 /* CCDecorativeDisplay.cpp */; }; - 1A0C0CF31777F9CD00838530 /* CCDisplayFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C061777F9CD00838530 /* CCDisplayFactory.cpp */; }; - 1A0C0CF41777F9CD00838530 /* CCDisplayManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C081777F9CD00838530 /* CCDisplayManager.cpp */; }; - 1A0C0CF51777F9CD00838530 /* CCShaderNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C0A1777F9CD00838530 /* CCShaderNode.cpp */; }; - 1A0C0CF61777F9CD00838530 /* CCSkin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C0C1777F9CD00838530 /* CCSkin.cpp */; }; - 1A0C0CF71777F9CD00838530 /* CCTexture2DMutable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C0F1777F9CD00838530 /* CCTexture2DMutable.cpp */; }; - 1A0C0CF81777F9CD00838530 /* GLES-Render.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C111777F9CD00838530 /* GLES-Render.cpp */; }; - 1A0C0CF91777F9CD00838530 /* CSContentJsonDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C141777F9CD00838530 /* CSContentJsonDictionary.cpp */; }; - 1A0C0CFA1777F9CD00838530 /* json_reader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C1F1777F9CD00838530 /* json_reader.cpp */; }; - 1A0C0CFB1777F9CD00838530 /* json_value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C211777F9CD00838530 /* json_value.cpp */; }; - 1A0C0CFC1777F9CD00838530 /* json_writer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C231777F9CD00838530 /* json_writer.cpp */; }; - 1A0C0CFD1777F9CD00838530 /* CCColliderDetector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C2A1777F9CD00838530 /* CCColliderDetector.cpp */; }; - 1A0C0CFE1777F9CD00838530 /* CCPhysicsWorld.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C2C1777F9CD00838530 /* CCPhysicsWorld.cpp */; }; - 1A0C0CFF1777F9CD00838530 /* CCArmatureDataManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C2F1777F9CD00838530 /* CCArmatureDataManager.cpp */; }; - 1A0C0D001777F9CD00838530 /* CCDataReaderHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C331777F9CD00838530 /* CCDataReaderHelper.cpp */; }; - 1A0C0D011777F9CD00838530 /* CCSpriteFrameCacheHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C351777F9CD00838530 /* CCSpriteFrameCacheHelper.cpp */; }; - 1A0C0D021777F9CD00838530 /* CCTransformHelp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C371777F9CD00838530 /* CCTransformHelp.cpp */; }; - 1A0C0D031777F9CD00838530 /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C391777F9CD00838530 /* CCTweenFunction.cpp */; }; - 1A0C0D041777F9CD00838530 /* CCUtilMath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C3B1777F9CD00838530 /* CCUtilMath.cpp */; }; 1A0C0D051777F9CD00838530 /* CCBAnimationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C3E1777F9CD00838530 /* CCBAnimationManager.cpp */; }; 1A0C0D061777F9CD00838530 /* CCBFileLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C401777F9CD00838530 /* CCBFileLoader.cpp */; }; 1A0C0D071777F9CD00838530 /* CCBKeyframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C421777F9CD00838530 /* CCBKeyframe.cpp */; }; @@ -58,10 +32,6 @@ 1A0C0D191777F9CD00838530 /* CCScale9SpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C6A1777F9CD00838530 /* CCScale9SpriteLoader.cpp */; }; 1A0C0D1A1777F9CD00838530 /* CCScrollViewLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C6C1777F9CD00838530 /* CCScrollViewLoader.cpp */; }; 1A0C0D1B1777F9CD00838530 /* CCSpriteLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C6E1777F9CD00838530 /* CCSpriteLoader.cpp */; }; - 1A0C0D1C1777F9CD00838530 /* CCComAttribute.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C721777F9CD00838530 /* CCComAttribute.cpp */; }; - 1A0C0D1D1777F9CD00838530 /* CCComAudio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C741777F9CD00838530 /* CCComAudio.cpp */; }; - 1A0C0D1E1777F9CD00838530 /* CCComController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C761777F9CD00838530 /* CCComController.cpp */; }; - 1A0C0D1F1777F9CD00838530 /* CCInputDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C781777F9CD00838530 /* CCInputDelegate.cpp */; }; 1A0C0D201777F9CD00838530 /* CCControl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C7D1777F9CD00838530 /* CCControl.cpp */; }; 1A0C0D211777F9CD00838530 /* CCControlButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C7F1777F9CD00838530 /* CCControlButton.cpp */; }; 1A0C0D221777F9CD00838530 /* CCControlColourPicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0C811777F9CD00838530 /* CCControlColourPicker.cpp */; }; @@ -134,72 +104,6 @@ 1A0C0A8B1777F7DD00838530 /* extensions-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "extensions-Prefix.pch"; sourceTree = ""; }; 1A0C0BF01777F9CD00838530 /* AssetsManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AssetsManager.cpp; sourceTree = ""; }; 1A0C0BF11777F9CD00838530 /* AssetsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AssetsManager.h; sourceTree = ""; }; - 1A0C0BF41777F9CD00838530 /* CCArmatureAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmatureAnimation.cpp; sourceTree = ""; }; - 1A0C0BF51777F9CD00838530 /* CCArmatureAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArmatureAnimation.h; sourceTree = ""; }; - 1A0C0BF61777F9CD00838530 /* CCProcessBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCProcessBase.cpp; sourceTree = ""; }; - 1A0C0BF71777F9CD00838530 /* CCProcessBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCProcessBase.h; sourceTree = ""; }; - 1A0C0BF81777F9CD00838530 /* CCTween.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTween.cpp; sourceTree = ""; }; - 1A0C0BF91777F9CD00838530 /* CCTween.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTween.h; sourceTree = ""; }; - 1A0C0BFA1777F9CD00838530 /* CCArmature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmature.cpp; sourceTree = ""; }; - 1A0C0BFB1777F9CD00838530 /* CCArmature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArmature.h; sourceTree = ""; }; - 1A0C0BFC1777F9CD00838530 /* CCBone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBone.cpp; sourceTree = ""; }; - 1A0C0BFD1777F9CD00838530 /* CCBone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBone.h; sourceTree = ""; }; - 1A0C0BFF1777F9CD00838530 /* CCDatas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDatas.cpp; sourceTree = ""; }; - 1A0C0C001777F9CD00838530 /* CCDatas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDatas.h; sourceTree = ""; }; - 1A0C0C021777F9CD00838530 /* CCBatchNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBatchNode.cpp; sourceTree = ""; }; - 1A0C0C031777F9CD00838530 /* CCBatchNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBatchNode.h; sourceTree = ""; }; - 1A0C0C041777F9CD00838530 /* CCDecorativeDisplay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDecorativeDisplay.cpp; sourceTree = ""; }; - 1A0C0C051777F9CD00838530 /* CCDecorativeDisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDecorativeDisplay.h; sourceTree = ""; }; - 1A0C0C061777F9CD00838530 /* CCDisplayFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDisplayFactory.cpp; sourceTree = ""; }; - 1A0C0C071777F9CD00838530 /* CCDisplayFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDisplayFactory.h; sourceTree = ""; }; - 1A0C0C081777F9CD00838530 /* CCDisplayManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDisplayManager.cpp; sourceTree = ""; }; - 1A0C0C091777F9CD00838530 /* CCDisplayManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDisplayManager.h; sourceTree = ""; }; - 1A0C0C0A1777F9CD00838530 /* CCShaderNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCShaderNode.cpp; sourceTree = ""; }; - 1A0C0C0B1777F9CD00838530 /* CCShaderNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCShaderNode.h; sourceTree = ""; }; - 1A0C0C0C1777F9CD00838530 /* CCSkin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSkin.cpp; sourceTree = ""; }; - 1A0C0C0D1777F9CD00838530 /* CCSkin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSkin.h; sourceTree = ""; }; - 1A0C0C0F1777F9CD00838530 /* CCTexture2DMutable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTexture2DMutable.cpp; sourceTree = ""; }; - 1A0C0C101777F9CD00838530 /* CCTexture2DMutable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTexture2DMutable.h; sourceTree = ""; }; - 1A0C0C111777F9CD00838530 /* GLES-Render.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "GLES-Render.cpp"; sourceTree = ""; }; - 1A0C0C121777F9CD00838530 /* GLES-Render.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GLES-Render.h"; sourceTree = ""; }; - 1A0C0C141777F9CD00838530 /* CSContentJsonDictionary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSContentJsonDictionary.cpp; sourceTree = ""; }; - 1A0C0C151777F9CD00838530 /* CSContentJsonDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSContentJsonDictionary.h; sourceTree = ""; }; - 1A0C0C171777F9CD00838530 /* autolink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = autolink.h; sourceTree = ""; }; - 1A0C0C181777F9CD00838530 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = ""; }; - 1A0C0C191777F9CD00838530 /* features.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = features.h; sourceTree = ""; }; - 1A0C0C1A1777F9CD00838530 /* forwards.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = forwards.h; sourceTree = ""; }; - 1A0C0C1B1777F9CD00838530 /* json_batchallocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json_batchallocator.h; sourceTree = ""; }; - 1A0C0C1C1777F9CD00838530 /* json_internalarray.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = json_internalarray.inl; sourceTree = ""; }; - 1A0C0C1D1777F9CD00838530 /* json_internalmap.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = json_internalmap.inl; sourceTree = ""; }; - 1A0C0C1E1777F9CD00838530 /* json_lib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json_lib.h; sourceTree = ""; }; - 1A0C0C1F1777F9CD00838530 /* json_reader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = json_reader.cpp; sourceTree = ""; }; - 1A0C0C201777F9CD00838530 /* json_tool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json_tool.h; sourceTree = ""; }; - 1A0C0C211777F9CD00838530 /* json_value.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = json_value.cpp; sourceTree = ""; }; - 1A0C0C221777F9CD00838530 /* json_valueiterator.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = json_valueiterator.inl; sourceTree = ""; }; - 1A0C0C231777F9CD00838530 /* json_writer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = json_writer.cpp; sourceTree = ""; }; - 1A0C0C241777F9CD00838530 /* reader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reader.h; sourceTree = ""; }; - 1A0C0C251777F9CD00838530 /* sconscript */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = sconscript; sourceTree = ""; }; - 1A0C0C261777F9CD00838530 /* value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = value.h; sourceTree = ""; }; - 1A0C0C271777F9CD00838530 /* writer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = writer.h; sourceTree = ""; }; - 1A0C0C281777F9CD00838530 /* sigslot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sigslot.h; sourceTree = ""; }; - 1A0C0C2A1777F9CD00838530 /* CCColliderDetector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCColliderDetector.cpp; sourceTree = ""; }; - 1A0C0C2B1777F9CD00838530 /* CCColliderDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCColliderDetector.h; sourceTree = ""; }; - 1A0C0C2C1777F9CD00838530 /* CCPhysicsWorld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsWorld.cpp; sourceTree = ""; }; - 1A0C0C2D1777F9CD00838530 /* CCPhysicsWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCPhysicsWorld.h; sourceTree = ""; }; - 1A0C0C2F1777F9CD00838530 /* CCArmatureDataManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmatureDataManager.cpp; sourceTree = ""; }; - 1A0C0C301777F9CD00838530 /* CCArmatureDataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArmatureDataManager.h; sourceTree = ""; }; - 1A0C0C311777F9CD00838530 /* CCArmatureDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCArmatureDefine.h; sourceTree = ""; }; - 1A0C0C321777F9CD00838530 /* CCConstValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCConstValue.h; sourceTree = ""; }; - 1A0C0C331777F9CD00838530 /* CCDataReaderHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCDataReaderHelper.cpp; sourceTree = ""; }; - 1A0C0C341777F9CD00838530 /* CCDataReaderHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDataReaderHelper.h; sourceTree = ""; }; - 1A0C0C351777F9CD00838530 /* CCSpriteFrameCacheHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteFrameCacheHelper.cpp; sourceTree = ""; }; - 1A0C0C361777F9CD00838530 /* CCSpriteFrameCacheHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteFrameCacheHelper.h; sourceTree = ""; }; - 1A0C0C371777F9CD00838530 /* CCTransformHelp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTransformHelp.cpp; sourceTree = ""; }; - 1A0C0C381777F9CD00838530 /* CCTransformHelp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTransformHelp.h; sourceTree = ""; }; - 1A0C0C391777F9CD00838530 /* CCTweenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = ""; }; - 1A0C0C3A1777F9CD00838530 /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = ""; }; - 1A0C0C3B1777F9CD00838530 /* CCUtilMath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCUtilMath.cpp; sourceTree = ""; }; - 1A0C0C3C1777F9CD00838530 /* CCUtilMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCUtilMath.h; sourceTree = ""; }; 1A0C0C3E1777F9CD00838530 /* CCBAnimationManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBAnimationManager.cpp; sourceTree = ""; }; 1A0C0C3F1777F9CD00838530 /* CCBAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBAnimationManager.h; sourceTree = ""; }; 1A0C0C401777F9CD00838530 /* CCBFileLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBFileLoader.cpp; sourceTree = ""; }; @@ -251,14 +155,6 @@ 1A0C0C6E1777F9CD00838530 /* CCSpriteLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteLoader.cpp; sourceTree = ""; }; 1A0C0C6F1777F9CD00838530 /* CCSpriteLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSpriteLoader.h; sourceTree = ""; }; 1A0C0C701777F9CD00838530 /* cocos-ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "cocos-ext.h"; path = "../cocos-ext.h"; sourceTree = ""; }; - 1A0C0C721777F9CD00838530 /* CCComAttribute.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComAttribute.cpp; sourceTree = ""; }; - 1A0C0C731777F9CD00838530 /* CCComAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComAttribute.h; sourceTree = ""; }; - 1A0C0C741777F9CD00838530 /* CCComAudio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComAudio.cpp; sourceTree = ""; }; - 1A0C0C751777F9CD00838530 /* CCComAudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComAudio.h; sourceTree = ""; }; - 1A0C0C761777F9CD00838530 /* CCComController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComController.cpp; sourceTree = ""; }; - 1A0C0C771777F9CD00838530 /* CCComController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComController.h; sourceTree = ""; }; - 1A0C0C781777F9CD00838530 /* CCInputDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCInputDelegate.cpp; sourceTree = ""; }; - 1A0C0C791777F9CD00838530 /* CCInputDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCInputDelegate.h; sourceTree = ""; }; 1A0C0C7A1777F9CD00838530 /* ExtensionMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExtensionMacros.h; path = ../ExtensionMacros.h; sourceTree = ""; }; 1A0C0C7D1777F9CD00838530 /* CCControl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCControl.cpp; sourceTree = ""; }; 1A0C0C7E1777F9CD00838530 /* CCControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCControl.h; sourceTree = ""; }; @@ -366,6 +262,86 @@ 1A0C0D551777FAAD00838530 /* libwebsockets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libwebsockets.h; sourceTree = ""; }; 1A0C0D571777FAAD00838530 /* libwebsockets.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebsockets.a; sourceTree = ""; }; 1A0C0D591777FB1300838530 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../../cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = ""; }; + 37B6EE8B17DEB3B0001BE102 /* CCArmatureAnimation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmatureAnimation.cpp; sourceTree = ""; }; + 37B6EE8C17DEB3B0001BE102 /* CCArmatureAnimation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCArmatureAnimation.h; sourceTree = ""; }; + 37B6EE8D17DEB3B0001BE102 /* CCProcessBase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCProcessBase.cpp; sourceTree = ""; }; + 37B6EE8E17DEB3B0001BE102 /* CCProcessBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCProcessBase.h; sourceTree = ""; }; + 37B6EE8F17DEB3B0001BE102 /* CCTween.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCTween.cpp; sourceTree = ""; }; + 37B6EE9017DEB3B0001BE102 /* CCTween.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCTween.h; sourceTree = ""; }; + 37B6EE9117DEB3B0001BE102 /* CCArmature.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmature.cpp; sourceTree = ""; }; + 37B6EE9217DEB3B0001BE102 /* CCArmature.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCArmature.h; sourceTree = ""; }; + 37B6EE9317DEB3B0001BE102 /* CCBone.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCBone.cpp; sourceTree = ""; }; + 37B6EE9417DEB3B0001BE102 /* CCBone.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCBone.h; sourceTree = ""; }; + 37B6EE9617DEB3B0001BE102 /* CCDatas.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCDatas.cpp; sourceTree = ""; }; + 37B6EE9717DEB3B0001BE102 /* CCDatas.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCDatas.h; sourceTree = ""; }; + 37B6EE9917DEB3B0001BE102 /* CCBatchNode.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCBatchNode.cpp; sourceTree = ""; }; + 37B6EE9A17DEB3B0001BE102 /* CCBatchNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCBatchNode.h; sourceTree = ""; }; + 37B6EE9B17DEB3B0001BE102 /* CCDecorativeDisplay.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCDecorativeDisplay.cpp; sourceTree = ""; }; + 37B6EE9C17DEB3B0001BE102 /* CCDecorativeDisplay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCDecorativeDisplay.h; sourceTree = ""; }; + 37B6EE9D17DEB3B0001BE102 /* CCDisplayFactory.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCDisplayFactory.cpp; sourceTree = ""; }; + 37B6EE9E17DEB3B0001BE102 /* CCDisplayFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCDisplayFactory.h; sourceTree = ""; }; + 37B6EE9F17DEB3B0001BE102 /* CCDisplayManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCDisplayManager.cpp; sourceTree = ""; }; + 37B6EEA017DEB3B0001BE102 /* CCDisplayManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCDisplayManager.h; sourceTree = ""; }; + 37B6EEA117DEB3B0001BE102 /* CCShaderNode.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCShaderNode.cpp; sourceTree = ""; }; + 37B6EEA217DEB3B0001BE102 /* CCShaderNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCShaderNode.h; sourceTree = ""; }; + 37B6EEA317DEB3B0001BE102 /* CCSkin.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCSkin.cpp; sourceTree = ""; }; + 37B6EEA417DEB3B0001BE102 /* CCSkin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCSkin.h; sourceTree = ""; }; + 37B6EEA617DEB3B0001BE102 /* CCTexture2DMutable.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCTexture2DMutable.cpp; sourceTree = ""; }; + 37B6EEA717DEB3B0001BE102 /* CCTexture2DMutable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCTexture2DMutable.h; sourceTree = ""; }; + 37B6EEA817DEB3B0001BE102 /* GLES-Render.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "GLES-Render.cpp"; sourceTree = ""; }; + 37B6EEA917DEB3B0001BE102 /* GLES-Render.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GLES-Render.h"; sourceTree = ""; }; + 37B6EEAA17DEB3B0001BE102 /* sigslot.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sigslot.h; sourceTree = ""; }; + 37B6EEAC17DEB3B0001BE102 /* CCColliderDetector.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCColliderDetector.cpp; sourceTree = ""; }; + 37B6EEAD17DEB3B0001BE102 /* CCColliderDetector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCColliderDetector.h; sourceTree = ""; }; + 37B6EEAE17DEB3B0001BE102 /* CCPhysicsWorld.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCPhysicsWorld.cpp; sourceTree = ""; }; + 37B6EEAF17DEB3B0001BE102 /* CCPhysicsWorld.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCPhysicsWorld.h; sourceTree = ""; }; + 37B6EEB117DEB3B0001BE102 /* CCArmatureDataManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCArmatureDataManager.cpp; sourceTree = ""; }; + 37B6EEB217DEB3B0001BE102 /* CCArmatureDataManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCArmatureDataManager.h; sourceTree = ""; }; + 37B6EEB317DEB3B0001BE102 /* CCArmatureDefine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCArmatureDefine.h; sourceTree = ""; }; + 37B6EEB417DEB3B0001BE102 /* CCConstValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCConstValue.h; sourceTree = ""; }; + 37B6EEB517DEB3B0001BE102 /* CCDataReaderHelper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCDataReaderHelper.cpp; sourceTree = ""; }; + 37B6EEB617DEB3B0001BE102 /* CCDataReaderHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCDataReaderHelper.h; sourceTree = ""; }; + 37B6EEB717DEB3B0001BE102 /* CCSpriteFrameCacheHelper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCSpriteFrameCacheHelper.cpp; sourceTree = ""; }; + 37B6EEB817DEB3B0001BE102 /* CCSpriteFrameCacheHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCSpriteFrameCacheHelper.h; sourceTree = ""; }; + 37B6EEB917DEB3B0001BE102 /* CCTransformHelp.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCTransformHelp.cpp; sourceTree = ""; }; + 37B6EEBA17DEB3B0001BE102 /* CCTransformHelp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCTransformHelp.h; sourceTree = ""; }; + 37B6EEBB17DEB3B0001BE102 /* CCTweenFunction.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = ""; }; + 37B6EEBC17DEB3B0001BE102 /* CCTweenFunction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = ""; }; + 37B6EEBD17DEB3B0001BE102 /* CCUtilMath.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCUtilMath.cpp; sourceTree = ""; }; + 37B6EEBE17DEB3B0001BE102 /* CCUtilMath.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCUtilMath.h; sourceTree = ""; }; + 37B6EEC017DEB3B0001BE102 /* CCComAttribute.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCComAttribute.cpp; sourceTree = ""; }; + 37B6EEC117DEB3B0001BE102 /* CCComAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCComAttribute.h; sourceTree = ""; }; + 37B6EEC217DEB3B0001BE102 /* CCComAudio.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCComAudio.cpp; sourceTree = ""; }; + 37B6EEC317DEB3B0001BE102 /* CCComAudio.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCComAudio.h; sourceTree = ""; }; + 37B6EEC417DEB3B0001BE102 /* CCComController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCComController.cpp; sourceTree = ""; }; + 37B6EEC517DEB3B0001BE102 /* CCComController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCComController.h; sourceTree = ""; }; + 37B6EEC617DEB3B0001BE102 /* CCComRender.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCComRender.cpp; sourceTree = ""; }; + 37B6EEC717DEB3B0001BE102 /* CCComRender.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCComRender.h; sourceTree = ""; }; + 37B6EEC817DEB3B0001BE102 /* CCInputDelegate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCInputDelegate.cpp; sourceTree = ""; }; + 37B6EEC917DEB3B0001BE102 /* CCInputDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCInputDelegate.h; sourceTree = ""; }; + 37B6EECB17DEB3B0001BE102 /* CSContentJsonDictionary.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSContentJsonDictionary.cpp; sourceTree = ""; }; + 37B6EECC17DEB3B0001BE102 /* CSContentJsonDictionary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSContentJsonDictionary.h; sourceTree = ""; }; + 37B6EECD17DEB3B0001BE102 /* DictionaryHelper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DictionaryHelper.cpp; sourceTree = ""; }; + 37B6EECE17DEB3B0001BE102 /* DictionaryHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DictionaryHelper.h; sourceTree = ""; }; + 37B6EED017DEB3B0001BE102 /* autolink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = autolink.h; sourceTree = ""; }; + 37B6EED117DEB3B0001BE102 /* config.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = ""; }; + 37B6EED217DEB3B0001BE102 /* features.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = features.h; sourceTree = ""; }; + 37B6EED317DEB3B0001BE102 /* forwards.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = forwards.h; sourceTree = ""; }; + 37B6EED417DEB3B0001BE102 /* json_batchallocator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = json_batchallocator.h; sourceTree = ""; }; + 37B6EED517DEB3B0001BE102 /* json_internalarray.inl */ = {isa = PBXFileReference; lastKnownFileType = text; path = json_internalarray.inl; sourceTree = ""; }; + 37B6EED617DEB3B0001BE102 /* json_internalmap.inl */ = {isa = PBXFileReference; lastKnownFileType = text; path = json_internalmap.inl; sourceTree = ""; }; + 37B6EED717DEB3B0001BE102 /* json_lib.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = json_lib.h; sourceTree = ""; }; + 37B6EED817DEB3B0001BE102 /* json_reader.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = json_reader.cpp; sourceTree = ""; }; + 37B6EED917DEB3B0001BE102 /* json_tool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = json_tool.h; sourceTree = ""; }; + 37B6EEDA17DEB3B0001BE102 /* json_value.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = json_value.cpp; sourceTree = ""; }; + 37B6EEDB17DEB3B0001BE102 /* json_valueiterator.inl */ = {isa = PBXFileReference; lastKnownFileType = text; path = json_valueiterator.inl; sourceTree = ""; }; + 37B6EEDC17DEB3B0001BE102 /* json_writer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = json_writer.cpp; sourceTree = ""; }; + 37B6EEDD17DEB3B0001BE102 /* reader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = reader.h; sourceTree = ""; }; + 37B6EEDE17DEB3B0001BE102 /* sconscript */ = {isa = PBXFileReference; lastKnownFileType = text; path = sconscript; sourceTree = ""; }; + 37B6EEDF17DEB3B0001BE102 /* value.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = value.h; sourceTree = ""; }; + 37B6EEE017DEB3B0001BE102 /* writer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = writer.h; sourceTree = ""; }; + 37B6EEE217DEB3B0001BE102 /* CCSSceneReader.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CCSSceneReader.cpp; sourceTree = ""; }; + 37B6EEE317DEB3B0001BE102 /* CCSSceneReader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCSSceneReader.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -385,11 +361,10 @@ 1A0C0A711777F79700838530 = { isa = PBXGroup; children = ( + 37B6EE8817DEB3B0001BE102 /* CocoStudio */, 1A0C0BEF1777F9CD00838530 /* AssetsManager */, - 1A0C0BF21777F9CD00838530 /* CCArmature */, 1A0C0C3D1777F9CD00838530 /* CCBReader */, 1A0C0C701777F9CD00838530 /* cocos-ext.h */, - 1A0C0C711777F9CD00838530 /* Components */, 1A0C0C7A1777F9CD00838530 /* ExtensionMacros.h */, 1A0C0C7B1777F9CD00838530 /* GUI */, 1A0C0CAE1777F9CD00838530 /* LocalStorage */, @@ -430,144 +405,6 @@ path = ../AssetsManager; sourceTree = ""; }; - 1A0C0BF21777F9CD00838530 /* CCArmature */ = { - isa = PBXGroup; - children = ( - 1A0C0BF31777F9CD00838530 /* animation */, - 1A0C0BFA1777F9CD00838530 /* CCArmature.cpp */, - 1A0C0BFB1777F9CD00838530 /* CCArmature.h */, - 1A0C0BFC1777F9CD00838530 /* CCBone.cpp */, - 1A0C0BFD1777F9CD00838530 /* CCBone.h */, - 1A0C0BFE1777F9CD00838530 /* datas */, - 1A0C0C011777F9CD00838530 /* display */, - 1A0C0C0E1777F9CD00838530 /* external_tool */, - 1A0C0C291777F9CD00838530 /* physics */, - 1A0C0C2E1777F9CD00838530 /* utils */, - ); - name = CCArmature; - path = ../CCArmature; - sourceTree = ""; - }; - 1A0C0BF31777F9CD00838530 /* animation */ = { - isa = PBXGroup; - children = ( - 1A0C0BF41777F9CD00838530 /* CCArmatureAnimation.cpp */, - 1A0C0BF51777F9CD00838530 /* CCArmatureAnimation.h */, - 1A0C0BF61777F9CD00838530 /* CCProcessBase.cpp */, - 1A0C0BF71777F9CD00838530 /* CCProcessBase.h */, - 1A0C0BF81777F9CD00838530 /* CCTween.cpp */, - 1A0C0BF91777F9CD00838530 /* CCTween.h */, - ); - path = animation; - sourceTree = ""; - }; - 1A0C0BFE1777F9CD00838530 /* datas */ = { - isa = PBXGroup; - children = ( - 1A0C0BFF1777F9CD00838530 /* CCDatas.cpp */, - 1A0C0C001777F9CD00838530 /* CCDatas.h */, - ); - path = datas; - sourceTree = ""; - }; - 1A0C0C011777F9CD00838530 /* display */ = { - isa = PBXGroup; - children = ( - 1A0C0C021777F9CD00838530 /* CCBatchNode.cpp */, - 1A0C0C031777F9CD00838530 /* CCBatchNode.h */, - 1A0C0C041777F9CD00838530 /* CCDecorativeDisplay.cpp */, - 1A0C0C051777F9CD00838530 /* CCDecorativeDisplay.h */, - 1A0C0C061777F9CD00838530 /* CCDisplayFactory.cpp */, - 1A0C0C071777F9CD00838530 /* CCDisplayFactory.h */, - 1A0C0C081777F9CD00838530 /* CCDisplayManager.cpp */, - 1A0C0C091777F9CD00838530 /* CCDisplayManager.h */, - 1A0C0C0A1777F9CD00838530 /* CCShaderNode.cpp */, - 1A0C0C0B1777F9CD00838530 /* CCShaderNode.h */, - 1A0C0C0C1777F9CD00838530 /* CCSkin.cpp */, - 1A0C0C0D1777F9CD00838530 /* CCSkin.h */, - ); - path = display; - sourceTree = ""; - }; - 1A0C0C0E1777F9CD00838530 /* external_tool */ = { - isa = PBXGroup; - children = ( - 1A0C0C0F1777F9CD00838530 /* CCTexture2DMutable.cpp */, - 1A0C0C101777F9CD00838530 /* CCTexture2DMutable.h */, - 1A0C0C111777F9CD00838530 /* GLES-Render.cpp */, - 1A0C0C121777F9CD00838530 /* GLES-Render.h */, - 1A0C0C131777F9CD00838530 /* Json */, - 1A0C0C281777F9CD00838530 /* sigslot.h */, - ); - path = external_tool; - sourceTree = ""; - }; - 1A0C0C131777F9CD00838530 /* Json */ = { - isa = PBXGroup; - children = ( - 1A0C0C141777F9CD00838530 /* CSContentJsonDictionary.cpp */, - 1A0C0C151777F9CD00838530 /* CSContentJsonDictionary.h */, - 1A0C0C161777F9CD00838530 /* lib_json */, - ); - path = Json; - sourceTree = ""; - }; - 1A0C0C161777F9CD00838530 /* lib_json */ = { - isa = PBXGroup; - children = ( - 1A0C0C171777F9CD00838530 /* autolink.h */, - 1A0C0C181777F9CD00838530 /* config.h */, - 1A0C0C191777F9CD00838530 /* features.h */, - 1A0C0C1A1777F9CD00838530 /* forwards.h */, - 1A0C0C1B1777F9CD00838530 /* json_batchallocator.h */, - 1A0C0C1C1777F9CD00838530 /* json_internalarray.inl */, - 1A0C0C1D1777F9CD00838530 /* json_internalmap.inl */, - 1A0C0C1E1777F9CD00838530 /* json_lib.h */, - 1A0C0C1F1777F9CD00838530 /* json_reader.cpp */, - 1A0C0C201777F9CD00838530 /* json_tool.h */, - 1A0C0C211777F9CD00838530 /* json_value.cpp */, - 1A0C0C221777F9CD00838530 /* json_valueiterator.inl */, - 1A0C0C231777F9CD00838530 /* json_writer.cpp */, - 1A0C0C241777F9CD00838530 /* reader.h */, - 1A0C0C251777F9CD00838530 /* sconscript */, - 1A0C0C261777F9CD00838530 /* value.h */, - 1A0C0C271777F9CD00838530 /* writer.h */, - ); - path = lib_json; - sourceTree = ""; - }; - 1A0C0C291777F9CD00838530 /* physics */ = { - isa = PBXGroup; - children = ( - 1A0C0C2A1777F9CD00838530 /* CCColliderDetector.cpp */, - 1A0C0C2B1777F9CD00838530 /* CCColliderDetector.h */, - 1A0C0C2C1777F9CD00838530 /* CCPhysicsWorld.cpp */, - 1A0C0C2D1777F9CD00838530 /* CCPhysicsWorld.h */, - ); - path = physics; - sourceTree = ""; - }; - 1A0C0C2E1777F9CD00838530 /* utils */ = { - isa = PBXGroup; - children = ( - 1A0C0C2F1777F9CD00838530 /* CCArmatureDataManager.cpp */, - 1A0C0C301777F9CD00838530 /* CCArmatureDataManager.h */, - 1A0C0C311777F9CD00838530 /* CCArmatureDefine.h */, - 1A0C0C321777F9CD00838530 /* CCConstValue.h */, - 1A0C0C331777F9CD00838530 /* CCDataReaderHelper.cpp */, - 1A0C0C341777F9CD00838530 /* CCDataReaderHelper.h */, - 1A0C0C351777F9CD00838530 /* CCSpriteFrameCacheHelper.cpp */, - 1A0C0C361777F9CD00838530 /* CCSpriteFrameCacheHelper.h */, - 1A0C0C371777F9CD00838530 /* CCTransformHelp.cpp */, - 1A0C0C381777F9CD00838530 /* CCTransformHelp.h */, - 1A0C0C391777F9CD00838530 /* CCTweenFunction.cpp */, - 1A0C0C3A1777F9CD00838530 /* CCTweenFunction.h */, - 1A0C0C3B1777F9CD00838530 /* CCUtilMath.cpp */, - 1A0C0C3C1777F9CD00838530 /* CCUtilMath.h */, - ); - path = utils; - sourceTree = ""; - }; 1A0C0C3D1777F9CD00838530 /* CCBReader */ = { isa = PBXGroup; children = ( @@ -626,22 +463,6 @@ path = ../CCBReader; sourceTree = ""; }; - 1A0C0C711777F9CD00838530 /* Components */ = { - isa = PBXGroup; - children = ( - 1A0C0C721777F9CD00838530 /* CCComAttribute.cpp */, - 1A0C0C731777F9CD00838530 /* CCComAttribute.h */, - 1A0C0C741777F9CD00838530 /* CCComAudio.cpp */, - 1A0C0C751777F9CD00838530 /* CCComAudio.h */, - 1A0C0C761777F9CD00838530 /* CCComController.cpp */, - 1A0C0C771777F9CD00838530 /* CCComController.h */, - 1A0C0C781777F9CD00838530 /* CCInputDelegate.cpp */, - 1A0C0C791777F9CD00838530 /* CCInputDelegate.h */, - ); - name = Components; - path = ../Components; - sourceTree = ""; - }; 1A0C0C7B1777F9CD00838530 /* GUI */ = { isa = PBXGroup; children = ( @@ -843,6 +664,182 @@ path = lib; sourceTree = ""; }; + 37B6EE8817DEB3B0001BE102 /* CocoStudio */ = { + isa = PBXGroup; + children = ( + 37B6EE8917DEB3B0001BE102 /* Armature */, + 37B6EEBF17DEB3B0001BE102 /* Components */, + 37B6EECA17DEB3B0001BE102 /* Json */, + 37B6EEE117DEB3B0001BE102 /* Reader */, + ); + name = CocoStudio; + path = ../CocoStudio; + sourceTree = ""; + }; + 37B6EE8917DEB3B0001BE102 /* Armature */ = { + isa = PBXGroup; + children = ( + 37B6EE8A17DEB3B0001BE102 /* animation */, + 37B6EE9117DEB3B0001BE102 /* CCArmature.cpp */, + 37B6EE9217DEB3B0001BE102 /* CCArmature.h */, + 37B6EE9317DEB3B0001BE102 /* CCBone.cpp */, + 37B6EE9417DEB3B0001BE102 /* CCBone.h */, + 37B6EE9517DEB3B0001BE102 /* datas */, + 37B6EE9817DEB3B0001BE102 /* display */, + 37B6EEA517DEB3B0001BE102 /* external_tool */, + 37B6EEAB17DEB3B0001BE102 /* physics */, + 37B6EEB017DEB3B0001BE102 /* utils */, + ); + path = Armature; + sourceTree = ""; + }; + 37B6EE8A17DEB3B0001BE102 /* animation */ = { + isa = PBXGroup; + children = ( + 37B6EE8B17DEB3B0001BE102 /* CCArmatureAnimation.cpp */, + 37B6EE8C17DEB3B0001BE102 /* CCArmatureAnimation.h */, + 37B6EE8D17DEB3B0001BE102 /* CCProcessBase.cpp */, + 37B6EE8E17DEB3B0001BE102 /* CCProcessBase.h */, + 37B6EE8F17DEB3B0001BE102 /* CCTween.cpp */, + 37B6EE9017DEB3B0001BE102 /* CCTween.h */, + ); + path = animation; + sourceTree = ""; + }; + 37B6EE9517DEB3B0001BE102 /* datas */ = { + isa = PBXGroup; + children = ( + 37B6EE9617DEB3B0001BE102 /* CCDatas.cpp */, + 37B6EE9717DEB3B0001BE102 /* CCDatas.h */, + ); + path = datas; + sourceTree = ""; + }; + 37B6EE9817DEB3B0001BE102 /* display */ = { + isa = PBXGroup; + children = ( + 37B6EE9917DEB3B0001BE102 /* CCBatchNode.cpp */, + 37B6EE9A17DEB3B0001BE102 /* CCBatchNode.h */, + 37B6EE9B17DEB3B0001BE102 /* CCDecorativeDisplay.cpp */, + 37B6EE9C17DEB3B0001BE102 /* CCDecorativeDisplay.h */, + 37B6EE9D17DEB3B0001BE102 /* CCDisplayFactory.cpp */, + 37B6EE9E17DEB3B0001BE102 /* CCDisplayFactory.h */, + 37B6EE9F17DEB3B0001BE102 /* CCDisplayManager.cpp */, + 37B6EEA017DEB3B0001BE102 /* CCDisplayManager.h */, + 37B6EEA117DEB3B0001BE102 /* CCShaderNode.cpp */, + 37B6EEA217DEB3B0001BE102 /* CCShaderNode.h */, + 37B6EEA317DEB3B0001BE102 /* CCSkin.cpp */, + 37B6EEA417DEB3B0001BE102 /* CCSkin.h */, + ); + path = display; + sourceTree = ""; + }; + 37B6EEA517DEB3B0001BE102 /* external_tool */ = { + isa = PBXGroup; + children = ( + 37B6EEA617DEB3B0001BE102 /* CCTexture2DMutable.cpp */, + 37B6EEA717DEB3B0001BE102 /* CCTexture2DMutable.h */, + 37B6EEA817DEB3B0001BE102 /* GLES-Render.cpp */, + 37B6EEA917DEB3B0001BE102 /* GLES-Render.h */, + 37B6EEAA17DEB3B0001BE102 /* sigslot.h */, + ); + path = external_tool; + sourceTree = ""; + }; + 37B6EEAB17DEB3B0001BE102 /* physics */ = { + isa = PBXGroup; + children = ( + 37B6EEAC17DEB3B0001BE102 /* CCColliderDetector.cpp */, + 37B6EEAD17DEB3B0001BE102 /* CCColliderDetector.h */, + 37B6EEAE17DEB3B0001BE102 /* CCPhysicsWorld.cpp */, + 37B6EEAF17DEB3B0001BE102 /* CCPhysicsWorld.h */, + ); + path = physics; + sourceTree = ""; + }; + 37B6EEB017DEB3B0001BE102 /* utils */ = { + isa = PBXGroup; + children = ( + 37B6EEB117DEB3B0001BE102 /* CCArmatureDataManager.cpp */, + 37B6EEB217DEB3B0001BE102 /* CCArmatureDataManager.h */, + 37B6EEB317DEB3B0001BE102 /* CCArmatureDefine.h */, + 37B6EEB417DEB3B0001BE102 /* CCConstValue.h */, + 37B6EEB517DEB3B0001BE102 /* CCDataReaderHelper.cpp */, + 37B6EEB617DEB3B0001BE102 /* CCDataReaderHelper.h */, + 37B6EEB717DEB3B0001BE102 /* CCSpriteFrameCacheHelper.cpp */, + 37B6EEB817DEB3B0001BE102 /* CCSpriteFrameCacheHelper.h */, + 37B6EEB917DEB3B0001BE102 /* CCTransformHelp.cpp */, + 37B6EEBA17DEB3B0001BE102 /* CCTransformHelp.h */, + 37B6EEBB17DEB3B0001BE102 /* CCTweenFunction.cpp */, + 37B6EEBC17DEB3B0001BE102 /* CCTweenFunction.h */, + 37B6EEBD17DEB3B0001BE102 /* CCUtilMath.cpp */, + 37B6EEBE17DEB3B0001BE102 /* CCUtilMath.h */, + ); + path = utils; + sourceTree = ""; + }; + 37B6EEBF17DEB3B0001BE102 /* Components */ = { + isa = PBXGroup; + children = ( + 37B6EEC017DEB3B0001BE102 /* CCComAttribute.cpp */, + 37B6EEC117DEB3B0001BE102 /* CCComAttribute.h */, + 37B6EEC217DEB3B0001BE102 /* CCComAudio.cpp */, + 37B6EEC317DEB3B0001BE102 /* CCComAudio.h */, + 37B6EEC417DEB3B0001BE102 /* CCComController.cpp */, + 37B6EEC517DEB3B0001BE102 /* CCComController.h */, + 37B6EEC617DEB3B0001BE102 /* CCComRender.cpp */, + 37B6EEC717DEB3B0001BE102 /* CCComRender.h */, + 37B6EEC817DEB3B0001BE102 /* CCInputDelegate.cpp */, + 37B6EEC917DEB3B0001BE102 /* CCInputDelegate.h */, + ); + path = Components; + sourceTree = ""; + }; + 37B6EECA17DEB3B0001BE102 /* Json */ = { + isa = PBXGroup; + children = ( + 37B6EECB17DEB3B0001BE102 /* CSContentJsonDictionary.cpp */, + 37B6EECC17DEB3B0001BE102 /* CSContentJsonDictionary.h */, + 37B6EECD17DEB3B0001BE102 /* DictionaryHelper.cpp */, + 37B6EECE17DEB3B0001BE102 /* DictionaryHelper.h */, + 37B6EECF17DEB3B0001BE102 /* lib_json */, + ); + path = Json; + sourceTree = ""; + }; + 37B6EECF17DEB3B0001BE102 /* lib_json */ = { + isa = PBXGroup; + children = ( + 37B6EED017DEB3B0001BE102 /* autolink.h */, + 37B6EED117DEB3B0001BE102 /* config.h */, + 37B6EED217DEB3B0001BE102 /* features.h */, + 37B6EED317DEB3B0001BE102 /* forwards.h */, + 37B6EED417DEB3B0001BE102 /* json_batchallocator.h */, + 37B6EED517DEB3B0001BE102 /* json_internalarray.inl */, + 37B6EED617DEB3B0001BE102 /* json_internalmap.inl */, + 37B6EED717DEB3B0001BE102 /* json_lib.h */, + 37B6EED817DEB3B0001BE102 /* json_reader.cpp */, + 37B6EED917DEB3B0001BE102 /* json_tool.h */, + 37B6EEDA17DEB3B0001BE102 /* json_value.cpp */, + 37B6EEDB17DEB3B0001BE102 /* json_valueiterator.inl */, + 37B6EEDC17DEB3B0001BE102 /* json_writer.cpp */, + 37B6EEDD17DEB3B0001BE102 /* reader.h */, + 37B6EEDE17DEB3B0001BE102 /* sconscript */, + 37B6EEDF17DEB3B0001BE102 /* value.h */, + 37B6EEE017DEB3B0001BE102 /* writer.h */, + ); + path = lib_json; + sourceTree = ""; + }; + 37B6EEE117DEB3B0001BE102 /* Reader */ = { + isa = PBXGroup; + children = ( + 37B6EEE217DEB3B0001BE102 /* CCSSceneReader.cpp */, + 37B6EEE317DEB3B0001BE102 /* CCSSceneReader.h */, + ); + path = Reader; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -894,32 +891,6 @@ buildActionMask = 2147483647; files = ( 1A0C0CEA1777F9CD00838530 /* AssetsManager.cpp in Sources */, - 1A0C0CEB1777F9CD00838530 /* CCArmatureAnimation.cpp in Sources */, - 1A0C0CEC1777F9CD00838530 /* CCProcessBase.cpp in Sources */, - 1A0C0CED1777F9CD00838530 /* CCTween.cpp in Sources */, - 1A0C0CEE1777F9CD00838530 /* CCArmature.cpp in Sources */, - 1A0C0CEF1777F9CD00838530 /* CCBone.cpp in Sources */, - 1A0C0CF01777F9CD00838530 /* CCDatas.cpp in Sources */, - 1A0C0CF11777F9CD00838530 /* CCBatchNode.cpp in Sources */, - 1A0C0CF21777F9CD00838530 /* CCDecorativeDisplay.cpp in Sources */, - 1A0C0CF31777F9CD00838530 /* CCDisplayFactory.cpp in Sources */, - 1A0C0CF41777F9CD00838530 /* CCDisplayManager.cpp in Sources */, - 1A0C0CF51777F9CD00838530 /* CCShaderNode.cpp in Sources */, - 1A0C0CF61777F9CD00838530 /* CCSkin.cpp in Sources */, - 1A0C0CF71777F9CD00838530 /* CCTexture2DMutable.cpp in Sources */, - 1A0C0CF81777F9CD00838530 /* GLES-Render.cpp in Sources */, - 1A0C0CF91777F9CD00838530 /* CSContentJsonDictionary.cpp in Sources */, - 1A0C0CFA1777F9CD00838530 /* json_reader.cpp in Sources */, - 1A0C0CFB1777F9CD00838530 /* json_value.cpp in Sources */, - 1A0C0CFC1777F9CD00838530 /* json_writer.cpp in Sources */, - 1A0C0CFD1777F9CD00838530 /* CCColliderDetector.cpp in Sources */, - 1A0C0CFE1777F9CD00838530 /* CCPhysicsWorld.cpp in Sources */, - 1A0C0CFF1777F9CD00838530 /* CCArmatureDataManager.cpp in Sources */, - 1A0C0D001777F9CD00838530 /* CCDataReaderHelper.cpp in Sources */, - 1A0C0D011777F9CD00838530 /* CCSpriteFrameCacheHelper.cpp in Sources */, - 1A0C0D021777F9CD00838530 /* CCTransformHelp.cpp in Sources */, - 1A0C0D031777F9CD00838530 /* CCTweenFunction.cpp in Sources */, - 1A0C0D041777F9CD00838530 /* CCUtilMath.cpp in Sources */, 1A0C0D051777F9CD00838530 /* CCBAnimationManager.cpp in Sources */, 1A0C0D061777F9CD00838530 /* CCBFileLoader.cpp in Sources */, 1A0C0D071777F9CD00838530 /* CCBKeyframe.cpp in Sources */, @@ -943,10 +914,6 @@ 1A0C0D191777F9CD00838530 /* CCScale9SpriteLoader.cpp in Sources */, 1A0C0D1A1777F9CD00838530 /* CCScrollViewLoader.cpp in Sources */, 1A0C0D1B1777F9CD00838530 /* CCSpriteLoader.cpp in Sources */, - 1A0C0D1C1777F9CD00838530 /* CCComAttribute.cpp in Sources */, - 1A0C0D1D1777F9CD00838530 /* CCComAudio.cpp in Sources */, - 1A0C0D1E1777F9CD00838530 /* CCComController.cpp in Sources */, - 1A0C0D1F1777F9CD00838530 /* CCInputDelegate.cpp in Sources */, 1A0C0D201777F9CD00838530 /* CCControl.cpp in Sources */, 1A0C0D211777F9CD00838530 /* CCControlButton.cpp in Sources */, 1A0C0D221777F9CD00838530 /* CCControlColourPicker.cpp in Sources */, diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index 29e5ae1917..3478a4ae68 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -13,7 +13,7 @@ SceneEditorTestLayer::~SceneEditorTestLayer() SceneEditorTestLayer::SceneEditorTestLayer() { - m_pCurNode = NULL; + _curNode = NULL; } Scene* SceneEditorTestLayer::scene() @@ -43,7 +43,7 @@ bool SceneEditorTestLayer::init() bool bRet = false; do { - CC_BREAK_IF(! LayerColor::initWithColor( ccc4(0,0,0,255) ) ); + CC_BREAK_IF(! LayerColor::initWithColor(Color4B(0,0,0,255))); Node *root = createGameScene(); CC_BREAK_IF(!root); @@ -55,26 +55,26 @@ bool SceneEditorTestLayer::init() return bRet; } -cocos2d::CCNode* SceneEditorTestLayer::createGameScene() +cocos2d::Node* SceneEditorTestLayer::createGameScene() { - Node *pNode = SceneReader::sharedSceneReader()->createNodeWithSceneFile("scenetest/FishJoy2.json"); + Node *pNode = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/FishJoy2.json"); if (pNode == NULL) { return NULL; } - m_pCurNode = pNode; + _curNode = pNode; //fishes /*cocos2d::extension::armature::Armature *pBlowFish = getFish(10008, "blowFish"); cocos2d::extension::armature::Armature *pButterFlyFish = getFish(10009, "butterFlyFish"); pBlowFish->getAnimation()->playByIndex(0); pButterFlyFish->getAnimation()->playByIndex(0);*/ - - CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(SceneEditorTestLayer::toExtensionsMainLayer)); - itemBack->setColor(ccc3(255, 255, 255)); - itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - CCMenu *menuBack = CCMenu::create(itemBack, NULL); - menuBack->setPosition(CCPointZero); + + MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(SceneEditorTestLayer::toExtensionsMainLayer, this)); + itemBack->setColor(Color3B(255, 255, 255)); + itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); + Menu *menuBack = Menu::create(itemBack, NULL); + menuBack->setPosition(Point(0.0f, 0.0f)); menuBack->setZOrder(4); pNode->addChild(menuBack); @@ -85,27 +85,28 @@ cocos2d::CCNode* SceneEditorTestLayer::createGameScene() return pNode; } -void SceneEditorTestLayer::toExtensionsMainLayer(cocos2d::CCObject *sender) +void SceneEditorTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) { - + ComAudio *pBackMusic = (ComAudio*)(_curNode->getComponent("CCBackgroundAudio")); + pBackMusic->stopBackgroundMusic(); ExtensionsTestScene *pScene = new ExtensionsTestScene(); pScene->runThisTest(); pScene->release(); -} +} -void runSceneEditorTestLayer() -{ - CCScene *pScene = SceneEditorTestLayer::scene(); - CCDirector::sharedDirector()->replaceScene(pScene); -} - cocos2d::extension::armature::Armature* SceneEditorTestLayer::getFish(int nTag, const char *pszName) { - if (m_pCurNode == NULL) + if (_curNode == NULL) { return NULL; } - ComRender *pFishRender = (ComRender*)(m_pCurNode->getChildByTag(nTag)->getComponent(pszName)); + ComRender *pFishRender = (ComRender*)(_curNode->getChildByTag(nTag)->getComponent(pszName)); return (cocos2d::extension::armature::Armature *)(pFishRender->getNode()); } + +void runSceneEditorTestLayer() +{ + Scene *pScene = SceneEditorTestLayer::scene(); + Director::getInstance()->replaceScene(pScene); +} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h index e7435bb00b..783e320cbd 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h @@ -32,7 +32,7 @@ public: cocos2d::extension::armature::Armature* getFish(int nTag, const char *pszName); private: - cocos2d::CCNode *m_pCurNode; + cocos2d::Node *_curNode; }; #endif // __HELLOWORLD_SCENE_H__ diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index b07637b853..36232b4a67 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -a8dca053b75a8f2c203c97fd709636caa3b5c3ad \ No newline at end of file +31e7d97ef047e37760172c75d2346bed591c821a \ No newline at end of file From 100228b4ae0baf04ea97b4a131e33b0a854f7eb1 Mon Sep 17 00:00:00 2001 From: chengstory Date: Tue, 10 Sep 2013 11:21:18 +0800 Subject: [PATCH 33/37] 1. fixes failed to build on linux. --- extensions/Android.mk | 1 - extensions/proj.linux/Makefile | 61 ++++++++++++++++++---------------- extensions/proj.nacl/Makefile | 61 ++++++++++++++++++---------------- 3 files changed, 64 insertions(+), 59 deletions(-) diff --git a/extensions/Android.mk b/extensions/Android.mk index 6d07ce4349..2008859962 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -8,7 +8,6 @@ LOCAL_MODULE_FILENAME := libextension LOCAL_SRC_FILES := \ CCDeprecated-ext.cpp \ AssetsManager/AssetsManager.cpp \ - CCBReader/CCBAnimationManager.cpp \ CCBReader/CCBFileLoader.cpp \ CCBReader/CCBKeyframe.cpp \ diff --git a/extensions/proj.linux/Makefile b/extensions/proj.linux/Makefile index a882d33953..54a0d8c3f6 100644 --- a/extensions/proj.linux/Makefile +++ b/extensions/proj.linux/Makefile @@ -57,6 +57,38 @@ SOURCES = ../CCBReader/CCBFileLoader.cpp \ ../network/HttpClient.cpp \ ../physics_nodes/CCPhysicsDebugNode.cpp \ ../physics_nodes/CCPhysicsSprite.cpp \ +../CocoStudio/Armature/CCArmature.cpp \ +../CocoStudio/Armature/CCBone.cpp \ +../CocoStudio/Armature/animation/CCArmatureAnimation.cpp \ +../CocoStudio/Armature/animation/CCProcessBase.cpp \ +../CocoStudio/Armature/animation/CCTween.cpp \ +../CocoStudio/Armature/datas/CCDatas.cpp \ +../CocoStudio/Armature/display/CCBatchNode.cpp \ +../CocoStudio/Armature/display/CCDecorativeDisplay.cpp \ +../CocoStudio/Armature/display/CCDisplayFactory.cpp \ +../CocoStudio/Armature/display/CCDisplayManager.cpp \ +../CocoStudio/Armature/display/CCSkin.cpp \ +../CocoStudio/Armature/external_tool/CCTexture2DMutable.cpp \ +../CocoStudio/Armature/external_tool/GLES-Render.cpp \ +../CocoStudio/Armature/physics/CCColliderDetector.cpp \ +../CocoStudio/Armature/physics/CCPhysicsWorld.cpp \ +../CocoStudio/Armature/utils/CCArmatureDataManager.cpp \ +../CocoStudio/Armature/utils/CCDataReaderHelper.cpp \ +../CocoStudio/Armature/utils/CCSpriteFrameCacheHelper.cpp \ +../CocoStudio/Armature/utils/CCTransformHelp.cpp \ +../CocoStudio/Armature/utils/CCTweenFunction.cpp \ +../CocoStudio/Armature/utils/CCUtilMath.cpp \ +../CocoStudio/Components/CCComAttribute.cpp \ +../CocoStudio/Components/CCComAudio.cpp \ +../CocoStudio/Components/CCComController.cpp \ +../CocoStudio/Components/CCComRender.cpp \ +../CocoStudio/Components/CCInputDelegate.cpp \ +../CocoStudio/Json/CSContentJsonDictionary.cpp \ +../CocoStudio/Json/DictionaryHelper.cpp \ +../CocoStudio/Json/lib_json/json_value.cpp \ +../CocoStudio/Json/lib_json/json_reader.cpp \ +../CocoStudio/Json/lib_json/json_writer.cpp \ +../CocoStudio/Reader/CCSSceneReader.cpp \ ../spine/Animation.cpp \ ../spine/AnimationState.cpp \ ../spine/AnimationStateData.cpp \ @@ -78,35 +110,6 @@ SOURCES = ../CCBReader/CCBFileLoader.cpp \ ../spine/spine-cocos2dx.cpp \ ../spine/CCSkeleton.cpp \ ../spine/CCSkeletonAnimation.cpp \ -../CCArmature/CCArmature.cpp \ -../CCArmature/CCBone.cpp \ -../CCArmature/animation/CCArmatureAnimation.cpp \ -../CCArmature/animation/CCProcessBase.cpp \ -../CCArmature/animation/CCTween.cpp \ -../CCArmature/datas/CCDatas.cpp \ -../CCArmature/display/CCBatchNode.cpp \ -../CCArmature/display/CCDecorativeDisplay.cpp \ -../CCArmature/display/CCDisplayFactory.cpp \ -../CCArmature/display/CCDisplayManager.cpp \ -../CCArmature/display/CCShaderNode.cpp \ -../CCArmature/display/CCSkin.cpp \ -../CCArmature/external_tool/GLES-Render.cpp \ -../CCArmature/external_tool/Json/CSContentJsonDictionary.cpp \ -../CCArmature/external_tool/Json/lib_json/json_value.cpp \ -../CCArmature/external_tool/Json/lib_json/json_reader.cpp \ -../CCArmature/external_tool/Json/lib_json/json_writer.cpp \ -../CCArmature/physics/CCColliderDetector.cpp \ -../CCArmature/physics/CCPhysicsWorld.cpp \ -../CCArmature/utils/CCArmatureDataManager.cpp \ -../CCArmature/utils/CCDataReaderHelper.cpp \ -../CCArmature/utils/CCSpriteFrameCacheHelper.cpp \ -../CCArmature/utils/CCTransformHelp.cpp \ -../CCArmature/utils/CCTweenFunction.cpp \ -../CCArmature/utils/CCUtilMath.cpp \ -../Components/CCComAttribute.cpp \ -../Components/CCComAudio.cpp \ -../Components/CCComController.cpp \ -../Components/CCInputDelegate.cpp \ ../CCDeprecated-ext.cpp include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk diff --git a/extensions/proj.nacl/Makefile b/extensions/proj.nacl/Makefile index dd87d3f805..985a1372d2 100644 --- a/extensions/proj.nacl/Makefile +++ b/extensions/proj.nacl/Makefile @@ -41,6 +41,38 @@ EXTENSIONS_SOURCES = ../CCBReader/CCBFileLoader.cpp \ ../GUI/CCEditBox/CCEditBoxImplNone.cpp \ ../physics_nodes/CCPhysicsDebugNode.cpp \ ../physics_nodes/CCPhysicsSprite.cpp \ +../CocoStudio/Armature/CCArmature.cpp \ +../CocoStudio/Armature/CCBone.cpp \ +../CocoStudio/Armature/animation/CCArmatureAnimation.cpp \ +../CocoStudio/Armature/animation/CCProcessBase.cpp \ +../CocoStudio/Armature/animation/CCTween.cpp \ +../CocoStudio/Armature/datas/CCDatas.cpp \ +../CocoStudio/Armature/display/CCBatchNode.cpp \ +../CocoStudio/Armature/display/CCDecorativeDisplay.cpp \ +../CocoStudio/Armature/display/CCDisplayFactory.cpp \ +../CocoStudio/Armature/display/CCDisplayManager.cpp \ +../CocoStudio/Armature/display/CCSkin.cpp \ +../CocoStudio/Armature/external_tool/CCTexture2DMutable.cpp \ +../CocoStudio/Armature/external_tool/GLES-Render.cpp \ +../CocoStudio/Armature/physics/CCColliderDetector.cpp \ +../CocoStudio/Armature/physics/CCPhysicsWorld.cpp \ +../CocoStudio/Armature/utils/CCArmatureDataManager.cpp \ +../CocoStudio/Armature/utils/CCDataReaderHelper.cpp \ +../CocoStudio/Armature/utils/CCSpriteFrameCacheHelper.cpp \ +../CocoStudio/Armature/utils/CCTransformHelp.cpp \ +../CocoStudio/Armature/utils/CCTweenFunction.cpp \ +../CocoStudio/Armature/utils/CCUtilMath.cpp \ +../CocoStudio/Components/CCComAttribute.cpp \ +../CocoStudio/Components/CCComAudio.cpp \ +../CocoStudio/Components/CCComController.cpp \ +../CocoStudio/Components/CCComRender.cpp \ +../CocoStudio/Components/CCInputDelegate.cpp \ +../CocoStudio/Json/CSContentJsonDictionary.cpp \ +../CocoStudio/Json/DictionaryHelper.cpp \ +../CocoStudio/Json/lib_json/json_value.cpp \ +../CocoStudio/Json/lib_json/json_reader.cpp \ +../CocoStudio/Json/lib_json/json_writer.cpp \ +../CocoStudio/Reader/CCSSceneReader.cpp \ ../spine/Animation.cpp \ ../spine/AnimationState.cpp \ ../spine/AnimationStateData.cpp \ @@ -62,35 +94,6 @@ EXTENSIONS_SOURCES = ../CCBReader/CCBFileLoader.cpp \ ../spine/spine-cocos2dx.cpp \ ../spine/CCSkeleton.cpp \ ../spine/CCSkeletonAnimation.cpp \ -../CCArmature/CCArmature.cpp \ -../CCArmature/CCBone.cpp \ -../CCArmature/animation/CCArmatureAnimation.cpp \ -../CCArmature/animation/CCProcessBase.cpp \ -../CCArmature/animation/CCTween.cpp \ -../CCArmature/datas/CCDatas.cpp \ -../CCArmature/display/CCBatchNode.cpp \ -../CCArmature/display/CCDecorativeDisplay.cpp \ -../CCArmature/display/CCDisplayFactory.cpp \ -../CCArmature/display/CCDisplayManager.cpp \ -../CCArmature/display/CCShaderNode.cpp \ -../CCArmature/display/CCSkin.cpp \ -../CCArmature/external_tool/GLES-Render.cpp \ -../CCArmature/external_tool/Json/CSContentJsonDictionary.cpp \ -../CCArmature/external_tool/Json/lib_json/json_value.cpp \ -../CCArmature/external_tool/Json/lib_json/json_reader.cpp \ -../CCArmature/external_tool/Json/lib_json/json_writer.cpp \ -../CCArmature/physics/CCColliderDetector.cpp \ -../CCArmature/physics/CCPhysicsWorld.cpp \ -../CCArmature/utils/CCArmatureDataManager.cpp \ -../CCArmature/utils/CCDataReaderHelper.cpp \ -../CCArmature/utils/CCSpriteFrameCacheHelper.cpp \ -../CCArmature/utils/CCTransformHelp.cpp \ -../CCArmature/utils/CCTweenFunction.cpp \ -../CCArmature/utils/CCUtilMath.cpp \ -../Components/CCComAttribute.cpp \ -../Components/CCComAudio.cpp \ -../Components/CCComController.cpp \ -../Components/CCInputDelegate.cpp \ ../CCDprecated-ext.cpp all: From 8e35e7cc273885fef432bb6926512b08cc12a4d2 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 10 Sep 2013 11:45:38 +0800 Subject: [PATCH 34/37] issue #2782: shadertestSprite change test case textures and add normal sprite for comparison --- .../Classes/ShaderTest/ShaderTest2.cpp | 35 ++++++++++++++----- .../Resources/Images/stone.png.REMOVED.git-id | 1 + 2 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 samples/Cpp/TestCpp/Resources/Images/stone.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp index b386ff3500..694a5b9065 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp @@ -469,8 +469,11 @@ GreyScaleSpriteTest::GreyScaleSpriteTest() { auto s = Director::getInstance()->getWinSize(); GreyScaleSprite* sprite = GreyScaleSprite::createSprite("Images/powered.png"); - sprite->setPosition(Point(s.width/2, s.height/2)); + sprite->setPosition(Point(s.width * 0.75, s.height/2)); + auto sprite2 = Sprite::create("Images/powered.png"); + sprite2->setPosition(Point(s.width * 0.25, s.height/2)); addChild(sprite); + addChild(sprite2); } } @@ -481,9 +484,11 @@ BlurSpriteTest::BlurSpriteTest() { auto s = Director::getInstance()->getWinSize(); BlurSprite* sprite = BlurSprite::createSprite("Images/powered.png"); - sprite->setPosition(Point(s.width/2, s.height/2)); - sprite->setBlurSize(1.5); + sprite->setPosition(Point(s.width * 0.75, s.height/2)); + auto sprite2 = Sprite::create("Images/powered.png"); + sprite2->setPosition(Point(s.width * 0.25, s.height/2)); addChild(sprite); + addChild(sprite2); } } @@ -494,8 +499,11 @@ NoiseSpriteTest::NoiseSpriteTest() { auto s = Director::getInstance()->getWinSize(); NoiseSprite* sprite = NoiseSprite::createSprite("Images/powered.png"); - sprite->setPosition(Point(s.width/2, s.height/2)); + sprite->setPosition(Point(s.width * 0.75, s.height/2)); + auto sprite2 = Sprite::create("Images/powered.png"); + sprite2->setPosition(Point(s.width * 0.25, s.height/2)); addChild(sprite); + addChild(sprite2); } } @@ -505,8 +513,11 @@ EdgeDetectionSpriteTest::EdgeDetectionSpriteTest() { auto s = Director::getInstance()->getWinSize(); EdgeDetectionSprite* sprite = EdgeDetectionSprite::createSprite("Images/powered.png"); - sprite->setPosition(Point(s.width/2, s.height/2)); + sprite->setPosition(Point(s.width * 0.75, s.height/2)); + auto sprite2 = Sprite::create("Images/powered.png"); + sprite2->setPosition(Point(s.width * 0.25, s.height/2)); addChild(sprite); + addChild(sprite2); } } @@ -515,9 +526,12 @@ BloomSpriteTest::BloomSpriteTest() if (ShaderTestDemo2::init()) { auto s = Director::getInstance()->getWinSize(); - BloomSprite* sprite = BloomSprite::createSprite("Images/powered.png"); - sprite->setPosition(Point(s.width/2, s.height/2)); + BloomSprite* sprite = BloomSprite::createSprite("Images/stone.png"); + sprite->setPosition(Point(s.width * 0.75, s.height/2)); + auto sprite2 = Sprite::create("Images/stone.png"); + sprite2->setPosition(Point(s.width * 0.25, s.height/2)); addChild(sprite); + addChild(sprite2); } } @@ -526,8 +540,11 @@ CelShadingSpriteTest::CelShadingSpriteTest() if (ShaderTestDemo2::init()) { auto s = Director::getInstance()->getWinSize(); - CelShadingSprite* sprite = CelShadingSprite::createSprite("Images/powered.png"); - sprite->setPosition(Point(s.width/2, s.height/2)); + CelShadingSprite* sprite = CelShadingSprite::createSprite("Images/stone.png"); + sprite->setPosition(Point(s.width * 0.75, s.height/2)); + auto sprite2 = Sprite::create("Images/stone.png"); + sprite2->setPosition(Point(s.width * 0.25, s.height/2)); addChild(sprite); + addChild(sprite2); } } diff --git a/samples/Cpp/TestCpp/Resources/Images/stone.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/Images/stone.png.REMOVED.git-id new file mode 100644 index 0000000000..eadaf4c7a1 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/Images/stone.png.REMOVED.git-id @@ -0,0 +1 @@ +b42f9d96ee0eba96dc53ef311c3b9b273f4456b8 \ No newline at end of file From 8b509c456f11d52212d2ed8e045fe9471787c48a Mon Sep 17 00:00:00 2001 From: chengstory Date: Tue, 10 Sep 2013 11:47:02 +0800 Subject: [PATCH 35/37] 1. add shadernode.cpp to linux, nacl mk files. --- extensions/Android.mk | 1 + extensions/proj.nacl/Makefile | 1 + 2 files changed, 2 insertions(+) diff --git a/extensions/Android.mk b/extensions/Android.mk index 2008859962..ec80e14408 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -69,6 +69,7 @@ CocoStudio/Armature/display/CCBatchNode.cpp \ CocoStudio/Armature/display/CCDecorativeDisplay.cpp \ CocoStudio/Armature/display/CCDisplayFactory.cpp \ CocoStudio/Armature/display/CCDisplayManager.cpp \ +CocoStudio/Armature/display/CCShaderNode.cpp \ CocoStudio/Armature/display/CCSkin.cpp \ CocoStudio/Armature/external_tool/CCTexture2DMutable.cpp \ CocoStudio/Armature/external_tool/GLES-Render.cpp \ diff --git a/extensions/proj.nacl/Makefile b/extensions/proj.nacl/Makefile index 985a1372d2..7e99f3eaca 100644 --- a/extensions/proj.nacl/Makefile +++ b/extensions/proj.nacl/Makefile @@ -51,6 +51,7 @@ EXTENSIONS_SOURCES = ../CCBReader/CCBFileLoader.cpp \ ../CocoStudio/Armature/display/CCDecorativeDisplay.cpp \ ../CocoStudio/Armature/display/CCDisplayFactory.cpp \ ../CocoStudio/Armature/display/CCDisplayManager.cpp \ +../CocoStudio/Armature/display/CCShaderNode.cpp \ ../CocoStudio/Armature/display/CCSkin.cpp \ ../CocoStudio/Armature/external_tool/CCTexture2DMutable.cpp \ ../CocoStudio/Armature/external_tool/GLES-Render.cpp \ From 9bf6ab1e165d472ea84eb81e950bcadc573aab2a Mon Sep 17 00:00:00 2001 From: chengstory Date: Tue, 10 Sep 2013 11:50:08 +0800 Subject: [PATCH 36/37] 1. fixes error of 34 line in android.mk. --- extensions/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/Android.mk b/extensions/Android.mk index ec80e14408..b0c6196ec7 100644 --- a/extensions/Android.mk +++ b/extensions/Android.mk @@ -30,7 +30,7 @@ CCBReader/CCNodeLoaderLibrary.cpp \ CCBReader/CCParticleSystemQuadLoader.cpp \ CCBReader/CCScale9SpriteLoader.cpp \ CCBReader/CCScrollViewLoader.cpp \ -CCBReader/CCSpriteLoader.cpp +CCBReader/CCSpriteLoader.cpp \ GUI/CCControlExtension/CCControl.cpp \ GUI/CCControlExtension/CCControlButton.cpp \ GUI/CCControlExtension/CCControlColourPicker.cpp \ From e04a47b807c144222643b0ba54b90f981ab50e32 Mon Sep 17 00:00:00 2001 From: chengstory Date: Tue, 10 Sep 2013 13:08:05 +0800 Subject: [PATCH 37/37] 1. update mkfile. --- extensions/proj.linux/Makefile | 1 + samples/Cpp/TestCpp/Android.mk | 17 +++++++++-------- samples/Cpp/TestCpp/proj.nacl/Makefile | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/extensions/proj.linux/Makefile b/extensions/proj.linux/Makefile index 54a0d8c3f6..9194c047cd 100644 --- a/extensions/proj.linux/Makefile +++ b/extensions/proj.linux/Makefile @@ -67,6 +67,7 @@ SOURCES = ../CCBReader/CCBFileLoader.cpp \ ../CocoStudio/Armature/display/CCDecorativeDisplay.cpp \ ../CocoStudio/Armature/display/CCDisplayFactory.cpp \ ../CocoStudio/Armature/display/CCDisplayManager.cpp \ +../CocoStudio/Armature/display/CCShaderNode.cpp \ ../CocoStudio/Armature/display/CCSkin.cpp \ ../CocoStudio/Armature/external_tool/CCTexture2DMutable.cpp \ ../CocoStudio/Armature/external_tool/GLES-Render.cpp \ diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index 68106673cd..d1c7c20529 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -44,8 +44,6 @@ Classes/DataVisitorTest/DataVisitorTest.cpp \ Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp \ Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp \ Classes/EffectsTest/EffectsTest.cpp \ -Classes/ExtensionsTest/ExtensionsTest.cpp \ -Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp \ Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp \ Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \ @@ -53,12 +51,6 @@ Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \ Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \ Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp \ -Classes/ExtensionsTest/ComponentsTest/ComponentsTestScene.cpp \ -Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp \ -Classes/ExtensionsTest/ComponentsTest/GameOverScene.cpp \ -Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp \ -Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp \ -Classes/ExtensionsTest/ComponentsTest/SceneController.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp \ Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp \ @@ -75,6 +67,15 @@ Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp \ Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp \ +Classes/ExtensionsTest/ExtensionsTest.cpp \ +Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp \ +Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp \ +Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp \ +Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp \ +Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp \ +Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp \ +Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp \ +Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp \ Classes/FileUtilsTest/FileUtilsTest.cpp \ Classes/FontTest/FontTest.cpp \ Classes/IntervalTest/IntervalTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.nacl/Makefile b/samples/Cpp/TestCpp/proj.nacl/Makefile index b1dab9b36a..4051d67ed7 100644 --- a/samples/Cpp/TestCpp/proj.nacl/Makefile +++ b/samples/Cpp/TestCpp/proj.nacl/Makefile @@ -54,7 +54,7 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp \ ../Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp \ ../Classes/ExtensionsTest/ExtensionsTest.cpp \ - ../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ + ../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ ../Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp \ ../Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp \ ../Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp \