From d5237d637de740a70f4bdb367488fec04e737bd6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 29 Jan 2013 00:42:21 +0800 Subject: [PATCH 1/3] Absolute path check for blackberry. --- cocos2dx/platform/android/CCFileUtils.cpp | 2 +- cocos2dx/platform/blackberry/CCFileUtils.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/android/CCFileUtils.cpp b/cocos2dx/platform/android/CCFileUtils.cpp index f9e74f910b..2dab20479d 100644 --- a/cocos2dx/platform/android/CCFileUtils.cpp +++ b/cocos2dx/platform/android/CCFileUtils.cpp @@ -92,7 +92,7 @@ std::string CCFileUtils::fullPathForFilename(const char* pszFileName) // 2) Files not in APK, e.g. /data/data/org.cocos2dx.hellocpp/cache/path/path/file.png, or /sdcard/path/path/file.png. // So these two situations need to be checked on Android. std::string strFileName = pszFileName; - if (pszFileName[0] == '/' || strFileName.find("assets/") == 0) + if (pszFileName[0] == '/' || strFileName.find(m_strDefaultResRootPath) == 0) { CCLOG("Return absolute path( %s ) directly.", pszFileName); return pszFileName; diff --git a/cocos2dx/platform/blackberry/CCFileUtils.cpp b/cocos2dx/platform/blackberry/CCFileUtils.cpp index 5ead518587..a6807d2388 100644 --- a/cocos2dx/platform/blackberry/CCFileUtils.cpp +++ b/cocos2dx/platform/blackberry/CCFileUtils.cpp @@ -104,8 +104,9 @@ std::string CCFileUtils::fullPathForFilename(const char* pszFileName) CCAssert(pszFileName != NULL, "CCFileUtils: Invalid path"); // Return directly if it's absolute path. - if (pszFileName[0] == '/') + if (pszFileName[0] == '/' || strFileName.find(m_strDefaultResRootPath) == 0) { + CCLOG("Return absolute path( %s ) directly.", pszFileName); return pszFileName; } From 2694cb150bc564372c7f86e7e51e2b99199ce3b9 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 29 Jan 2013 09:56:38 +0800 Subject: [PATCH 2/3] CCFileUtils::s|gSearchPath -> CCFileUtils::s\gSearchPaths. --- cocos2dx/platform/CCFileUtils.h | 8 ++++---- cocos2dx/platform/CCFileUtilsCommon_cpp.h | 2 +- cocos2dx/platform/android/CCFileUtils.cpp | 6 +++--- cocos2dx/platform/blackberry/CCApplication.cpp | 4 ++-- cocos2dx/platform/blackberry/CCApplication.h | 4 ++-- cocos2dx/platform/blackberry/CCFileUtils.cpp | 6 +++--- cocos2dx/platform/ios/CCFileUtils.mm | 4 ++-- cocos2dx/platform/linux/CCApplication.cpp | 4 ++-- cocos2dx/platform/linux/CCApplication.h | 4 ++-- cocos2dx/platform/linux/CCFileUtils.cpp | 6 +++--- cocos2dx/platform/mac/CCApplication.h | 4 ++-- cocos2dx/platform/mac/CCApplication.mm | 4 ++-- cocos2dx/platform/mac/CCFileUtils.mm | 4 ++-- cocos2dx/platform/marmalade/CCFileUtils.cpp | 6 +++--- cocos2dx/platform/win32/CCApplication.cpp | 4 ++-- cocos2dx/platform/win32/CCApplication.h | 4 ++-- cocos2dx/platform/win32/CCFileUtils.cpp | 6 +++--- samples/Cpp/HelloCpp/Classes/AppDelegate.cpp | 2 +- samples/Cpp/TestCpp/Classes/AppDelegate.cpp | 2 +- .../TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp | 12 ++++++------ .../Javascript/CocosDragonJS/Classes/AppDelegate.cpp | 2 +- .../Javascript/CocosPlayer/Classes/AppDelegate.cpp | 4 ++-- .../Javascript/CrystalCraze/Classes/AppDelegate.cpp | 2 +- scripting/javascript/bindings/cocos2d_specifics.cpp | 12 ++++++------ tools/tojs/cocos2dx-win32.ini | 2 +- tools/tojs/cocos2dx.ini | 2 +- 26 files changed, 60 insertions(+), 60 deletions(-) diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index c2ab30e910..2ef1841ce7 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -177,7 +177,7 @@ public: /** @brief Set the resource directory; we will find resources relative to this directory. @param pszDirectoryName Relative path to root. - @deprecated Please use setSearchPath instead. + @deprecated Please use setSearchPaths instead. */ CC_DEPRECATED_ATTRIBUTE void setResourceDirectory(const char *pszDirectoryName); @@ -206,17 +206,17 @@ public: * @param searchPaths * @since v2.1 */ - void setSearchPath(const std::vector& searchPaths); + void setSearchPaths(const std::vector& searchPaths); /** * Gets the array of search paths. * */ - const std::vector& getSearchPath(); + const std::vector& getSearchPaths(); /** * Gets the resource directory - * @deprecated Please use getSearchPath() instead. + * @deprecated Please use getSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE const char* getResourceDirectory(); diff --git a/cocos2dx/platform/CCFileUtilsCommon_cpp.h b/cocos2dx/platform/CCFileUtilsCommon_cpp.h index 7c9fcb9867..1a3ed5d11e 100644 --- a/cocos2dx/platform/CCFileUtilsCommon_cpp.h +++ b/cocos2dx/platform/CCFileUtilsCommon_cpp.h @@ -410,7 +410,7 @@ const std::vector& CCFileUtils::getSearchResolutionsOrder() return m_searchResolutionsOrderArray; } -const std::vector& CCFileUtils::getSearchPath() +const std::vector& CCFileUtils::getSearchPaths() { return m_searchPathArray; } diff --git a/cocos2dx/platform/android/CCFileUtils.cpp b/cocos2dx/platform/android/CCFileUtils.cpp index 2dab20479d..e49f269a00 100644 --- a/cocos2dx/platform/android/CCFileUtils.cpp +++ b/cocos2dx/platform/android/CCFileUtils.cpp @@ -241,12 +241,12 @@ void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory) { if (pszResourceDirectory == NULL) return; m_obDirectory = pszResourceDirectory; - std::vector searchPaths = this->getSearchPath();; + std::vector searchPaths = this->getSearchPaths();; searchPaths.insert(searchPaths.begin(), pszResourceDirectory); - this->setSearchPath(searchPaths); + this->setSearchPaths(searchPaths); } -void CCFileUtils::setSearchPath(const std::vector& searchPaths) +void CCFileUtils::setSearchPaths(const std::vector& searchPaths) { bool bExistDefaultRootPath = false; diff --git a/cocos2dx/platform/blackberry/CCApplication.cpp b/cocos2dx/platform/blackberry/CCApplication.cpp index 0466b55015..ed07456776 100644 --- a/cocos2dx/platform/blackberry/CCApplication.cpp +++ b/cocos2dx/platform/blackberry/CCApplication.cpp @@ -88,9 +88,9 @@ void CCApplication::setResourceRootPath(const std::string& rootResDir) m_resourceRootPath += '/'; } CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils(); - std::vector searchPaths = pFileUtils->getSearchPath(); + std::vector searchPaths = pFileUtils->getSearchPaths(); searchPaths.insert(searchPaths.begin(), m_resourceRootPath); - pFileUtils->setSearchPath(searchPaths); + pFileUtils->setSearchPaths(searchPaths); } const std::string& CCApplication::getResourceRootPath(void) diff --git a/cocos2dx/platform/blackberry/CCApplication.h b/cocos2dx/platform/blackberry/CCApplication.h index 56054e5613..fac0c15414 100644 --- a/cocos2dx/platform/blackberry/CCApplication.h +++ b/cocos2dx/platform/blackberry/CCApplication.h @@ -65,13 +65,13 @@ public: /** * Sets the Resource root path. - * @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead. + * @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir); /** * Gets the Resource root path. - * @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead. + * @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void); diff --git a/cocos2dx/platform/blackberry/CCFileUtils.cpp b/cocos2dx/platform/blackberry/CCFileUtils.cpp index a6807d2388..8275ed3ba5 100644 --- a/cocos2dx/platform/blackberry/CCFileUtils.cpp +++ b/cocos2dx/platform/blackberry/CCFileUtils.cpp @@ -205,12 +205,12 @@ void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory) { if (pszResourceDirectory == NULL) return; m_obDirectory = pszResourceDirectory; - std::vector searchPaths = this->getSearchPath();; + std::vector searchPaths = this->getSearchPaths();; searchPaths.insert(searchPaths.begin(), pszResourceDirectory); - this->setSearchPath(searchPaths); + this->setSearchPaths(searchPaths); } -void CCFileUtils::setSearchPath(const std::vector& searchPaths) +void CCFileUtils::setSearchPaths(const std::vector& searchPaths) { bool bExistDefaultRootPath = false; diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index e1f237e4fd..b6392b2a30 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -205,7 +205,7 @@ const std::vector& CCFileUtils::getSearchResolutionsOrder() return m_searchResolutionsOrderArray; } -void CCFileUtils::setSearchPath(const std::vector& searchPaths) +void CCFileUtils::setSearchPaths(const std::vector& searchPaths) { bool bExistDefault = false; m_searchPathArray.clear(); @@ -223,7 +223,7 @@ void CCFileUtils::setSearchPath(const std::vector& searchPaths) } } -const std::vector& CCFileUtils::getSearchPath() +const std::vector& CCFileUtils::getSearchPaths() { return m_searchPathArray; } diff --git a/cocos2dx/platform/linux/CCApplication.cpp b/cocos2dx/platform/linux/CCApplication.cpp index 54ce509111..241fd143fe 100644 --- a/cocos2dx/platform/linux/CCApplication.cpp +++ b/cocos2dx/platform/linux/CCApplication.cpp @@ -74,9 +74,9 @@ void CCApplication::setResourceRootPath(const std::string& rootResDir) m_resourceRootPath += '/'; } CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils(); - std::vector searchPaths = pFileUtils->getSearchPath(); + std::vector searchPaths = pFileUtils->getSearchPaths(); searchPaths.insert(searchPaths.begin(), m_resourceRootPath); - pFileUtils->setSearchPath(searchPaths); + pFileUtils->setSearchPaths(searchPaths); } const std::string& CCApplication::getResourceRootPath(void) diff --git a/cocos2dx/platform/linux/CCApplication.h b/cocos2dx/platform/linux/CCApplication.h index 24f5a7ebea..c68fa01c86 100644 --- a/cocos2dx/platform/linux/CCApplication.h +++ b/cocos2dx/platform/linux/CCApplication.h @@ -43,13 +43,13 @@ public: /** * Sets the Resource root path. - * @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead. + * @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir); /** * Gets the Resource root path. - * @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead. + * @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void); diff --git a/cocos2dx/platform/linux/CCFileUtils.cpp b/cocos2dx/platform/linux/CCFileUtils.cpp index dc26729c19..ea07324e3b 100644 --- a/cocos2dx/platform/linux/CCFileUtils.cpp +++ b/cocos2dx/platform/linux/CCFileUtils.cpp @@ -199,12 +199,12 @@ void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory) { if (pszResourceDirectory == NULL) return; m_obDirectory = pszResourceDirectory; - std::vector searchPaths = this->getSearchPath();; + std::vector searchPaths = this->getSearchPaths();; searchPaths.insert(searchPaths.begin(), pszResourceDirectory); - this->setSearchPath(searchPaths); + this->setSearchPaths(searchPaths); } -void CCFileUtils::setSearchPath(const std::vector& searchPaths) +void CCFileUtils::setSearchPaths(const std::vector& searchPaths) { bool bExistDefaultRootPath = false; diff --git a/cocos2dx/platform/mac/CCApplication.h b/cocos2dx/platform/mac/CCApplication.h index 1e901319c6..b2c39e5649 100755 --- a/cocos2dx/platform/mac/CCApplication.h +++ b/cocos2dx/platform/mac/CCApplication.h @@ -71,13 +71,13 @@ public: /** * Sets the Resource root path. - * @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead. + * @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir); /** * Gets the Resource root path. - * @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead. + * @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void); diff --git a/cocos2dx/platform/mac/CCApplication.mm b/cocos2dx/platform/mac/CCApplication.mm index 70954aa3ac..ead2e66386 100755 --- a/cocos2dx/platform/mac/CCApplication.mm +++ b/cocos2dx/platform/mac/CCApplication.mm @@ -131,9 +131,9 @@ void CCApplication::setResourceRootPath(const std::string& rootResDir) m_resourceRootPath += '/'; } CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils(); - std::vector searchPaths = pFileUtils->getSearchPath(); + std::vector searchPaths = pFileUtils->getSearchPaths(); searchPaths.insert(searchPaths.begin(), m_resourceRootPath); - pFileUtils->setSearchPath(searchPaths); + pFileUtils->setSearchPaths(searchPaths); } const std::string& CCApplication::getResourceRootPath(void) diff --git a/cocos2dx/platform/mac/CCFileUtils.mm b/cocos2dx/platform/mac/CCFileUtils.mm index 3310da1fc8..17d77bef78 100755 --- a/cocos2dx/platform/mac/CCFileUtils.mm +++ b/cocos2dx/platform/mac/CCFileUtils.mm @@ -207,7 +207,7 @@ const std::vector& CCFileUtils::getSearchResolutionsOrder() return m_searchResolutionsOrderArray; } -void CCFileUtils::setSearchPath(const std::vector& searchPaths) +void CCFileUtils::setSearchPaths(const std::vector& searchPaths) { bool bExistDefault = false; m_searchPathArray.clear(); @@ -225,7 +225,7 @@ void CCFileUtils::setSearchPath(const std::vector& searchPaths) } } -const std::vector& CCFileUtils::getSearchPath() +const std::vector& CCFileUtils::getSearchPaths() { return m_searchPathArray; } diff --git a/cocos2dx/platform/marmalade/CCFileUtils.cpp b/cocos2dx/platform/marmalade/CCFileUtils.cpp index e9c49808b9..10621aa962 100644 --- a/cocos2dx/platform/marmalade/CCFileUtils.cpp +++ b/cocos2dx/platform/marmalade/CCFileUtils.cpp @@ -196,12 +196,12 @@ void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory) { if (pszResourceDirectory == NULL) return; m_obDirectory = pszResourceDirectory; - std::vector searchPaths = this->getSearchPath();; + std::vector searchPaths = this->getSearchPaths();; searchPaths.insert(searchPaths.begin(), pszResourceDirectory); - this->setSearchPath(searchPaths); + this->setSearchPaths(searchPaths); } -void CCFileUtils::setSearchPath(const std::vector& searchPaths) +void CCFileUtils::setSearchPaths(const std::vector& searchPaths) { bool bExistDefaultRootPath = false; diff --git a/cocos2dx/platform/win32/CCApplication.cpp b/cocos2dx/platform/win32/CCApplication.cpp index 70e0b6a01a..98c9dde41a 100644 --- a/cocos2dx/platform/win32/CCApplication.cpp +++ b/cocos2dx/platform/win32/CCApplication.cpp @@ -164,9 +164,9 @@ void CCApplication::setResourceRootPath(const std::string& rootResDir) m_resourceRootPath += '/'; } CCFileUtils* pFileUtils = CCFileUtils::sharedFileUtils(); - std::vector searchPaths = pFileUtils->getSearchPath(); + std::vector searchPaths = pFileUtils->getSearchPaths(); searchPaths.insert(searchPaths.begin(), m_resourceRootPath); - pFileUtils->setSearchPath(searchPaths); + pFileUtils->setSearchPaths(searchPaths); } const std::string& CCApplication::getResourceRootPath(void) diff --git a/cocos2dx/platform/win32/CCApplication.h b/cocos2dx/platform/win32/CCApplication.h index 1e957942c3..41398eab29 100644 --- a/cocos2dx/platform/win32/CCApplication.h +++ b/cocos2dx/platform/win32/CCApplication.h @@ -38,13 +38,13 @@ public: /** * Sets the Resource root path. - * @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPath() instead. + * @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string& rootResDir); /** * Gets the Resource root path. - * @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPath() instead. + * @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPaths() instead. */ CC_DEPRECATED_ATTRIBUTE const std::string& getResourceRootPath(void); diff --git a/cocos2dx/platform/win32/CCFileUtils.cpp b/cocos2dx/platform/win32/CCFileUtils.cpp index 7c8bf869cb..538b1ad712 100644 --- a/cocos2dx/platform/win32/CCFileUtils.cpp +++ b/cocos2dx/platform/win32/CCFileUtils.cpp @@ -210,12 +210,12 @@ void CCFileUtils::setResourceDirectory(const char* pszResourceDirectory) { if (pszResourceDirectory == NULL) return; m_obDirectory = pszResourceDirectory; - std::vector searchPaths = this->getSearchPath();; + std::vector searchPaths = this->getSearchPaths();; searchPaths.insert(searchPaths.begin(), pszResourceDirectory); - this->setSearchPath(searchPaths); + this->setSearchPaths(searchPaths); } -void CCFileUtils::setSearchPath(const std::vector& searchPaths) +void CCFileUtils::setSearchPaths(const std::vector& searchPaths) { bool bExistDefaultRootPath = false; diff --git a/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp b/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp index cb7b67ac20..6c99e7819e 100644 --- a/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp @@ -59,7 +59,7 @@ bool AppDelegate::applicationDidFinishLaunching() { } // set searching path - CCFileUtils::sharedFileUtils()->setSearchPath(searchPath); + CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath); // turn on display FPS pDirector->setDisplayStats(true); diff --git a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp index 2717727d92..b4d665bf5d 100644 --- a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp @@ -32,7 +32,7 @@ bool AppDelegate::applicationDidFinishLaunching() CCSize resourceSize = CCSizeMake(960, 640); std::vector searchPaths; searchPaths.push_back("hd"); - pFileUtils->setSearchPath(searchPaths); + pFileUtils->setSearchPaths(searchPaths); pDirector->setContentScaleFactor(resourceSize.height/designSize.height); } diff --git a/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp b/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp index 17b485d27d..54576cb7ea 100644 --- a/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp @@ -138,10 +138,10 @@ void TestResolutionDirectories::onEnter() string ret; sharedFileUtils->purgeCachedEntries(); - m_defaultSearchPathArray = sharedFileUtils->getSearchPath(); + m_defaultSearchPathArray = sharedFileUtils->getSearchPaths(); vector searchPaths = m_defaultSearchPathArray; searchPaths.insert(searchPaths.begin(), "Misc"); - sharedFileUtils->setSearchPath(searchPaths); + sharedFileUtils->setSearchPaths(searchPaths); m_defaultResolutionsOrderArray = sharedFileUtils->getSearchResolutionsOrder(); vector resolutionsOrder = m_defaultResolutionsOrderArray; @@ -167,7 +167,7 @@ void TestResolutionDirectories::onExit() CCFileUtils *sharedFileUtils = CCFileUtils::sharedFileUtils(); // reset search path - sharedFileUtils->setSearchPath(m_defaultSearchPathArray); + sharedFileUtils->setSearchPaths(m_defaultSearchPathArray); sharedFileUtils->setSearchResolutionsOrder(m_defaultResolutionsOrderArray); FileUtilsDemo::onExit(); } @@ -192,7 +192,7 @@ void TestSearchPath::onEnter() string ret; sharedFileUtils->purgeCachedEntries(); - m_defaultSearchPathArray = sharedFileUtils->getSearchPath(); + m_defaultSearchPathArray = sharedFileUtils->getSearchPaths(); vector searchPaths = m_defaultSearchPathArray; string writablePath = sharedFileUtils->getWriteablePath(); string fileName = writablePath+"external.txt"; @@ -208,7 +208,7 @@ void TestSearchPath::onEnter() searchPaths.insert(searchPaths.begin(), writablePath); searchPaths.insert(searchPaths.begin()+1, "Misc/searchpath1"); searchPaths.insert(searchPaths.begin()+2, "Misc/searchpath2"); - sharedFileUtils->setSearchPath(searchPaths); + sharedFileUtils->setSearchPaths(searchPaths); m_defaultResolutionsOrderArray = sharedFileUtils->getSearchResolutionsOrder(); vector resolutionsOrder = m_defaultResolutionsOrderArray; @@ -242,7 +242,7 @@ void TestSearchPath::onExit() CCFileUtils *sharedFileUtils = CCFileUtils::sharedFileUtils(); // reset search path - sharedFileUtils->setSearchPath(m_defaultSearchPathArray); + sharedFileUtils->setSearchPaths(m_defaultSearchPathArray); sharedFileUtils->setSearchResolutionsOrder(m_defaultResolutionsOrderArray); FileUtilsDemo::onExit(); } diff --git a/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp b/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp index 53b1ab1fa9..6fff2c7a28 100644 --- a/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp +++ b/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp @@ -56,7 +56,7 @@ bool AppDelegate::applicationDidFinishLaunching() searchPath.push_back("resources-iphonehd"); } - CCFileUtils::sharedFileUtils()->setSearchPath(searchPath); + CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath); pDirector->setContentScaleFactor(resourceSize.height/designSize.height); diff --git a/samples/Javascript/CocosPlayer/Classes/AppDelegate.cpp b/samples/Javascript/CocosPlayer/Classes/AppDelegate.cpp index 1bd726bcad..84cbddfa87 100644 --- a/samples/Javascript/CocosPlayer/Classes/AppDelegate.cpp +++ b/samples/Javascript/CocosPlayer/Classes/AppDelegate.cpp @@ -100,9 +100,9 @@ bool AppDelegate::applicationDidFinishLaunching() CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder); - std::vector searchPaths = pFileUtils->getSearchPath(); + std::vector searchPaths = pFileUtils->getSearchPaths(); searchPaths.insert(searchPaths.begin(), pFileUtils->getWriteablePath()); - pFileUtils->setSearchPath(searchPaths); + pFileUtils->setSearchPaths(searchPaths); PlayerStatus::setDeviceResolution(res); // turn on display FPS diff --git a/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp b/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp index d06bb3b626..4aca55568c 100644 --- a/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp +++ b/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp @@ -41,7 +41,7 @@ bool AppDelegate::applicationDidFinishLaunching() if (platform == kTargetIphone || platform == kTargetIpad) { searchPaths.push_back("Published-iOS"); // Resources/Published-iOS - CCFileUtils::sharedFileUtils()->setSearchPath(searchPaths); + CCFileUtils::sharedFileUtils()->setSearchPaths(searchPaths); if (screenSize.height > 480) { diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp b/scripting/javascript/bindings/cocos2d_specifics.cpp index 2e931c8547..985b4ef1f8 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp @@ -2567,7 +2567,7 @@ JSBool js_cocos2dx_CCFileUtils_setSearchResolutionsOrder(JSContext *cx, uint32_t return JS_FALSE; } -JSBool js_cocos2dx_CCFileUtils_setSearchPath(JSContext *cx, uint32_t argc, jsval *vp) +JSBool js_cocos2dx_CCFileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); JSBool ok = JS_TRUE; @@ -2580,14 +2580,14 @@ JSBool js_cocos2dx_CCFileUtils_setSearchPath(JSContext *cx, uint32_t argc, jsval std::vector arg0; ok &= jsval_to_string_vector(cx, argv[0], arg0); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - cobj->setSearchPath(arg0); + cobj->setSearchPaths(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } -JSBool js_cocos2dx_CCFileUtils_getSearchPath(JSContext *cx, uint32_t argc, jsval *vp) +JSBool js_cocos2dx_CCFileUtils_getSearchPaths(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); @@ -2595,7 +2595,7 @@ JSBool js_cocos2dx_CCFileUtils_getSearchPath(JSContext *cx, uint32_t argc, jsval JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 0) { - std::vector ret = cobj->getSearchPath(); + std::vector ret = cobj->getSearchPaths(); jsval jsret; jsret = string_vector_to_jsval(cx, ret); JS_SET_RVAL(cx, vp, jsret); @@ -2675,8 +2675,8 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) JS_DefineFunction(cx, js_cocos2dx_CCMenu_prototype, "alignItemsInColumns", js_cocos2dx_CCMenu_alignItemsInColumns, 1, JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_PERMANENT); JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "setSearchResolutionsOrder", js_cocos2dx_CCFileUtils_setSearchResolutionsOrder, 1, JSPROP_PERMANENT | JSPROP_SHARED); - JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "setSearchPath", js_cocos2dx_CCFileUtils_setSearchPath, 1, JSPROP_PERMANENT | JSPROP_SHARED); - JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "getSearchPath", js_cocos2dx_CCFileUtils_getSearchPath, 0, JSPROP_PERMANENT | JSPROP_SHARED); + JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "setSearchPaths", js_cocos2dx_CCFileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_SHARED); + JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "getSearchPaths", js_cocos2dx_CCFileUtils_getSearchPaths, 0, JSPROP_PERMANENT | JSPROP_SHARED); JS_DefineFunction(cx, js_cocos2dx_CCFileUtils_prototype, "getSearchResolutionsOrder", js_cocos2dx_CCFileUtils_getSearchResolutionsOrder, 0, JSPROP_PERMANENT | JSPROP_SHARED); diff --git a/tools/tojs/cocos2dx-win32.ini b/tools/tojs/cocos2dx-win32.ini index 30525b132e..a384a4539f 100644 --- a/tools/tojs/cocos2dx-win32.ini +++ b/tools/tojs/cocos2dx-win32.ini @@ -96,7 +96,7 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren ^setPosition$ getGr CCTimer::[getSelector], CC.*Loader$::[*], *::[copyWith.* onEnter.* onExit.* description getObjectType .*RGB.* .*HSV.*], - CCFileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPath$] + CCFileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$] rename_functions = CCDirector::[sharedDirector=getInstance], CCSpriteFrameCache::[sharedSpriteFrameCache=getInstance addSpriteFramesWithFile=addSpriteFrames spriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY], diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 80dd68621e..5498962f1f 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -99,7 +99,7 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren ^setPosition$ getGr CCTimer::[getSelector], CC.*Loader$::[*], *::[copyWith.* onEnter.* onExit.* description getObjectType .*RGB.* .*HSV.*], - CCFileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPath$] + CCFileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$] rename_functions = CCDirector::[sharedDirector=getInstance], CCSpriteFrameCache::[sharedSpriteFrameCache=getInstance addSpriteFramesWithFile=addSpriteFrames spriteFrameByName=getSpriteFrame isFlipX=isFlippedX isFlipY=isFlippedY], From bf571ace53403afc1f423d2aa9a9886c48ba5197 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 29 Jan 2013 09:59:16 +0800 Subject: [PATCH 3/3] Updating JS Tests. --- samples/Javascript/Shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Javascript/Shared b/samples/Javascript/Shared index b744bb4009..3459984d2f 160000 --- a/samples/Javascript/Shared +++ b/samples/Javascript/Shared @@ -1 +1 @@ -Subproject commit b744bb4009bdd74d428587ba51d991294b549be4 +Subproject commit 3459984d2ff434c51be47ed51e8e24882b25a641