From 3f667fac857232a643e47534ce08174cce9b85ac Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Thu, 16 Oct 2014 10:28:52 +0800 Subject: [PATCH] Update the related AssetsManagerEx files and related project configure --- build/cocos2d_tests.xcodeproj/project.pbxproj | 24 +++++++ cocos/platform/CCFileUtils.cpp | 42 ++++++------ .../lua-bindings/manual/CCLuaEngine.cpp | 66 +++++++++---------- .../lua-bindings/manual/CCLuaEngine.h | 2 +- .../manual/cocos2d/LuaScriptHandlerMgr.h | 6 +- .../lua_cocos2dx_extension_manual.cpp | 44 ++++++------- .../extension/lua_cocos2dx_extension_manual.h | 10 +++ .../script/cocos2d/Cocos2dConstants.lua | 33 ---------- .../script/extension/ExtensionConstants.lua | 10 +++ extensions/assets-manager/Downloader.cpp | 24 +++---- .../proj.win32/lua-tests.win32.vcxproj | 4 +- .../lua-tests.win32.vcxproj.filters | 8 +-- .../AssetsManagerExTest.lua | 6 +- .../AssetsManagerModule.lua} | 0 tests/lua-tests/src/mainMenu.lua | 2 + tools/tolua/cocos2dx_extension.ini | 4 +- 16 files changed, 147 insertions(+), 138 deletions(-) rename tests/lua-tests/src/{AssetsManagerExTest/AssetsManagerExModule.lua => AssetsManagerTest/AssetsManagerModule.lua} (100%) diff --git a/build/cocos2d_tests.xcodeproj/project.pbxproj b/build/cocos2d_tests.xcodeproj/project.pbxproj index 93e6da9abb..c39bcff326 100644 --- a/build/cocos2d_tests.xcodeproj/project.pbxproj +++ b/build/cocos2d_tests.xcodeproj/project.pbxproj @@ -50,6 +50,11 @@ 15AECE0F195C1FDD00907DB0 /* cocosvideo.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 3EA0FB5D191B92F100B170C8 /* cocosvideo.mp4 */; }; 15AECE25195D467D00907DB0 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EA0FB65191B933000B170C8 /* MediaPlayer.framework */; }; 15B0870D195AD52000D6F62B /* ActionTimeline in Resources */ = {isa = PBXBuildFile; fileRef = 38FA2E75194AECF800FF2BE4 /* ActionTimeline */; }; + 15B3709319EE5D1000ABE682 /* Manifests in Resources */ = {isa = PBXBuildFile; fileRef = 15B3709219EE5D1000ABE682 /* Manifests */; }; + 15B3709419EE5D1000ABE682 /* Manifests in Resources */ = {isa = PBXBuildFile; fileRef = 15B3709219EE5D1000ABE682 /* Manifests */; }; + 15B3709819EE5DBA00ABE682 /* AssetsManagerExTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B3709619EE5DBA00ABE682 /* AssetsManagerExTest.cpp */; }; + 15B3709919EE5DBA00ABE682 /* AssetsManagerExTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15B3709619EE5DBA00ABE682 /* AssetsManagerExTest.cpp */; }; + 15B3709A19EE5EED00ABE682 /* Manifests in Resources */ = {isa = PBXBuildFile; fileRef = 15B3709219EE5D1000ABE682 /* Manifests */; }; 15C64825165F3934007D4F18 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64824165F3934007D4F18 /* OpenGL.framework */; }; 15C64827165F394E007D4F18 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64826165F394E007D4F18 /* QuartzCore.framework */; }; 15C64829165F396B007D4F18 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15C64828165F396B007D4F18 /* OpenAL.framework */; }; @@ -998,6 +1003,9 @@ 15427B77198B843300DC375D /* lua_module_register.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_module_register.h; sourceTree = ""; }; 15427B7B198B880100DC375D /* lua_cocos2dx_controller_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lua_cocos2dx_controller_manual.cpp; path = "../../../../cocos/scripting/lua-bindings/manual/controller/lua_cocos2dx_controller_manual.cpp"; sourceTree = ""; }; 15427B7C198B880100DC375D /* lua_cocos2dx_controller_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = lua_cocos2dx_controller_manual.hpp; path = "../../../../cocos/scripting/lua-bindings/manual/controller/lua_cocos2dx_controller_manual.hpp"; sourceTree = ""; }; + 15B3709219EE5D1000ABE682 /* Manifests */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Manifests; path = "../tests/cpp-tests/Resources/Manifests"; sourceTree = ""; }; + 15B3709619EE5DBA00ABE682 /* AssetsManagerExTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AssetsManagerExTest.cpp; sourceTree = ""; }; + 15B3709719EE5DBA00ABE682 /* AssetsManagerExTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AssetsManagerExTest.h; sourceTree = ""; }; 15C64822165F391E007D4F18 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; 15C64824165F3934007D4F18 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework; sourceTree = DEVELOPER_DIR; }; 15C64826165F394E007D4F18 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; }; @@ -2978,6 +2986,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 15B3709519EE5DBA00ABE682 /* AssetsManagerExTest */ = { + isa = PBXGroup; + children = ( + 15B3709619EE5DBA00ABE682 /* AssetsManagerExTest.cpp */, + 15B3709719EE5DBA00ABE682 /* AssetsManagerExTest.h */, + ); + path = AssetsManagerExTest; + sourceTree = ""; + }; 15CBA087196EE66D005877BB /* lua-game-controller-test */ = { isa = PBXGroup; children = ( @@ -5540,6 +5557,7 @@ 1AC359B418CECF0B00F37B72 /* ExtensionsTest */ = { isa = PBXGroup; children = ( + 15B3709519EE5DBA00ABE682 /* AssetsManagerExTest */, 38FA2E70194AEBE100FF2BE4 /* CocoStudioActionTimelineTest */, 1AC359B518CECF0B00F37B72 /* CocosBuilderTest */, 1AC359DC18CECF0B00F37B72 /* CocoStudioArmatureTest */, @@ -6222,6 +6240,7 @@ 1AC35CA818CED83500F37B72 /* Resources */ = { isa = PBXGroup; children = ( + 15B3709219EE5D1000ABE682 /* Manifests */, 3E2BDB0019C5E5D40055CDCD /* background.wav */, 3E2BDAD119BEA3E20055CDCD /* audio */, 38FA2E75194AECF800FF2BE4 /* ActionTimeline */, @@ -7349,6 +7368,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 15B3709A19EE5EED00ABE682 /* Manifests in Resources */, 15AECE0F195C1FDD00907DB0 /* cocosvideo.mp4 in Resources */, 15B0870D195AD52000D6F62B /* ActionTimeline in Resources */, 15E66FC8192D957100C20A52 /* Sprite3DTest in Resources */, @@ -7407,6 +7427,7 @@ 1AC35CFA18CED84500F37B72 /* Misc in Resources */, 38FA2E76194AECF800FF2BE4 /* ActionTimeline in Resources */, 1AC35D0418CED84500F37B72 /* Shaders in Resources */, + 15B3709319EE5D1000ABE682 /* Manifests in Resources */, 3E2F27BA19CFF52300E7C490 /* audio in Resources */, 1AC35CD818CED84500F37B72 /* CocosBuilderExample.ccbresourcelog in Resources */, B2507B6B192589AF00FA4972 /* Shaders3D in Resources */, @@ -7486,6 +7507,7 @@ 3E2BDAD219BEA3E20055CDCD /* audio in Resources */, C08689C318D370C90093E810 /* background.caf in Resources */, 1AC35C9518CECF1400F37B72 /* Icon-72.png in Resources */, + 15B3709419EE5D1000ABE682 /* Manifests in Resources */, 1AC35D0B18CED84500F37B72 /* zwoptex in Resources */, 1AC35CF518CED84500F37B72 /* Images in Resources */, 1AC35C9118CECF1400F37B72 /* Icon-40.png in Resources */, @@ -7859,6 +7881,7 @@ 1AC35C4B18CECF0C00F37B72 /* ShaderTest2.cpp in Sources */, 38FA2E73194AEBE100FF2BE4 /* ActionTimelineTestScene.cpp in Sources */, 1AC35C6518CECF0C00F37B72 /* UnitTest.cpp in Sources */, + 15B3709819EE5DBA00ABE682 /* AssetsManagerExTest.cpp in Sources */, 29080DC9191B595E0066F8DF /* UISceneManager_Editor.cpp in Sources */, 1AC35B3F18CECF0C00F37B72 /* Bug-458.cpp in Sources */, 3E2F27B919CFF4AF00E7C490 /* NewAudioEngineTest.cpp in Sources */, @@ -8003,6 +8026,7 @@ 1AC35B7C18CECF0C00F37B72 /* GameOverScene.cpp in Sources */, 1AC35BF418CECF0C00F37B72 /* ExtensionsTest.cpp in Sources */, 1AC35B3618CECF0C00F37B72 /* TestEntries.cpp in Sources */, + 15B3709919EE5DBA00ABE682 /* AssetsManagerExTest.cpp in Sources */, 1AC35B2E18CECF0C00F37B72 /* Box2dTest.cpp in Sources */, 29080DCA191B595E0066F8DF /* UISceneManager_Editor.cpp in Sources */, 1AC35C1218CECF0C00F37B72 /* LabelTestNew.cpp in Sources */, diff --git a/cocos/platform/CCFileUtils.cpp b/cocos/platform/CCFileUtils.cpp index 6a96b6fcd6..e137e32df8 100644 --- a/cocos/platform/CCFileUtils.cpp +++ b/cocos/platform/CCFileUtils.cpp @@ -1236,35 +1236,35 @@ bool FileUtils::removeFile(const std::string &path) bool FileUtils::renameFile(const std::string &path, const std::string &oldname, const std::string &name) { CCASSERT(!path.empty(), "Invalid path"); + std::string oldPath = path + oldname; + std::string newPath = path + name; // Rename a file #if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) - std::string oldPath = path + oldname; - std::string newPath = path + name; - if (rename(oldPath.c_str(), newPath.c_str()) != 0) + int errorCode = rename(oldPath.c_str(), newPath.c_str()); + + if (0 != errorCode) { - CCLOGERROR("Fail to rename file %s to %s !", oldPath.c_str(), newPath.c_str()); + CCLOGERROR("Fail to rename file %s to %s !Error code is %d", oldPath.c_str(), newPath.c_str(), errorCode); return false; } return true; #else - std::string command = "cmd /c ren "; - std::string win32path = path; - int len = win32path.length(); - for (int i = 0; i < len; ++i) - { - if (win32path[i] == '/') - { - win32path[i] = '\\'; - } - } - // Path may include space. - command += win32path + oldname + " " + name; - - if (WinExec(command.c_str(), SW_HIDE) > 31) - return true; - else - return false; + std::regex pat("\/"); + std::string _old = std::regex_replace(oldPath, pat, "\\"); + std::string _new = std::regex_replace(newPath, pat, "\\"); + + if(FileUtils::getInstance()->isFileExist(_new)) + { + DeleteFileA(_new.c_str()); + } + + MoveFileA(_old.c_str(), _new.c_str()); + + if(0 == GetLastError()) + return true; + else + return false; #endif } diff --git a/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp b/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp index 0aa393ec92..6a114d5b40 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp +++ b/cocos/scripting/lua-bindings/manual/CCLuaEngine.cpp @@ -770,11 +770,11 @@ int LuaEngine::handleEvent(ScriptHandlerMgr::HandlerType type,void* data) return handleTableViewEvent(type, data); } break; - case ScriptHandlerMgr::HandlerType::ASSETSMANAGEREX_PROGRESS: - case ScriptHandlerMgr::HandlerType::ASSETSMANAGEREX_ERROR: - case ScriptHandlerMgr::HandlerType::ASSETSMANAGEREX_SUCCESS: + case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS: + case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR: + case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS: { - return handleAssetsManagerExEvent(type, data); + return handleAssetsManagerEvent(type, data); } break; case ScriptHandlerMgr::HandlerType::ARMATURE_EVENT: @@ -947,7 +947,7 @@ int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType handlerType,vo return ret; } -int LuaEngine::handleAssetsManagerExEvent(ScriptHandlerMgr::HandlerType type,void* data) +int LuaEngine::handleAssetsManagerEvent(ScriptHandlerMgr::HandlerType type,void* data) { if (nullptr == data) return 0; @@ -956,35 +956,35 @@ int LuaEngine::handleAssetsManagerExEvent(ScriptHandlerMgr::HandlerType type,voi if (nullptr == eventData->nativeObject || nullptr == eventData->value) return 0; -// LuaAssetsManagerEventData* assetsManagerData = static_cast(eventData->value); -// -// int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, type); -// -// if (0 == handler) -// return 0; -// -// int ret = 0; -// switch (type) -// { -// case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS: -// case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR: -// { -// _stack->pushInt(assetsManagerData->value); -// ret = _stack->executeFunctionByHandler(handler, 1); -// } -// break; -// -// case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS: -// { -// ret = _stack->executeFunctionByHandler(handler, 0); -// } -// break; -// -// default: -// break; -// } + LuaAssetsManagerEventData* assetsManagerData = static_cast(eventData->value); - return 0; + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, type); + + if (0 == handler) + return 0; + + int ret = 0; + switch (type) + { + case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS: + case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR: + { + _stack->pushInt(assetsManagerData->value); + ret = _stack->executeFunctionByHandler(handler, 1); + } + break; + + case ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS: + { + ret = _stack->executeFunctionByHandler(handler, 0); + } + break; + + default: + break; + } + + return ret; } int LuaEngine::handleArmatureWrapper(ScriptHandlerMgr::HandlerType type,void* data) diff --git a/cocos/scripting/lua-bindings/manual/CCLuaEngine.h b/cocos/scripting/lua-bindings/manual/CCLuaEngine.h index f56f7704b6..10e4277960 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaEngine.h +++ b/cocos/scripting/lua-bindings/manual/CCLuaEngine.h @@ -146,7 +146,7 @@ private: int handleTouchesEvent(void* data); int handlerControlEvent(void* data); int handleEvenCustom(void* data); - int handleAssetsManagerExEvent(ScriptHandlerMgr::HandlerType type,void* data); + int handleAssetsManagerEvent(ScriptHandlerMgr::HandlerType type,void* data); int handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data); int handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data, int numResults, const std::function& func); int handleArmatureWrapper(ScriptHandlerMgr::HandlerType type,void* data); diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/LuaScriptHandlerMgr.h b/cocos/scripting/lua-bindings/manual/cocos2d/LuaScriptHandlerMgr.h index 7f334efa9b..27c1473adb 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/LuaScriptHandlerMgr.h +++ b/cocos/scripting/lua-bindings/manual/cocos2d/LuaScriptHandlerMgr.h @@ -126,9 +126,9 @@ public: XMLHTTPREQUEST_READY_STATE_CHANGE, - ASSETSMANAGEREX_PROGRESS, - ASSETSMANAGEREX_SUCCESS, - ASSETSMANAGEREX_ERROR, + ASSETSMANAGER_PROGRESS, + ASSETSMANAGER_SUCCESS, + ASSETSMANAGER_ERROR, STUDIO_EVENT_LISTENER, ARMATURE_EVENT, diff --git a/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp index 9d8a6a7829..ad1d6af94c 100644 --- a/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp @@ -366,35 +366,35 @@ public: virtual void onProgress(int percent) override { -// int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS); -// if (0 != handler) -// { -// LuaAssetsManagerEventData eventData(percent); -// BasicScriptData data((void*)this,&eventData); -// LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGEREX_PROGRESS, (void*)&data); -// } + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS); + if (0 != handler) + { + LuaAssetsManagerEventData eventData(percent); + BasicScriptData data((void*)this,&eventData); + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS, (void*)&data); + } } virtual void onSuccess() override { -// int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS); -// if (0 != handler) -// { -// LuaAssetsManagerEventData eventData; -// BasicScriptData data((void*)this,&eventData); -// LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGEREX_SUCCESS, (void*)&data); -// } + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS); + if (0 != handler) + { + LuaAssetsManagerEventData eventData; + BasicScriptData data((void*)this,&eventData); + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_SUCCESS, (void*)&data); + } } virtual void onError(AssetsManager::ErrorCode errorCode) override { -// int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR); -// if (0 != handler) -// { -// LuaAssetsManagerEventData eventData((int)errorCode); -// BasicScriptData data((void*)this,&eventData); -// LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGEREX_ERROR, (void*)&data); -// } + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR); + if (0 != handler) + { + LuaAssetsManagerEventData eventData((int)errorCode); + BasicScriptData data((void*)this,&eventData); + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR, (void*)&data); + } } }; @@ -445,7 +445,7 @@ static int lua_cocos2dx_AssetsManager_setDelegate(lua_State* L) } LUA_FUNCTION handler = toluafix_ref_function(L, 2, 0); - ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::ASSETSMANAGEREX_PROGRESS); + ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)delegate, handler, handlerType); return 0; diff --git a/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.h b/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.h index 9144cdb868..fc88b2626f 100644 --- a/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.h +++ b/cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.h @@ -35,6 +35,16 @@ extern "C" { TOLUA_API int register_all_cocos2dx_extension_manual(lua_State* tolua_S); TOLUA_API int register_extension_module(lua_State* tolua_S); +struct LuaAssetsManagerEventData +{ + int value; + + LuaAssetsManagerEventData(int _value = 0):value(_value) + { + } +}; + + struct LuaTableViewEventData { void* value; diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua index a318a1d448..8064ac2a6c 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua @@ -208,39 +208,6 @@ cc.NODE_ON_ENTER_TRANSITION_DID_FINISH = 2 cc.NODE_ON_EXIT_TRANSITION_DID_START = 3 cc.NODE_ON_CLEAN_UP = 4 -cc.CONTROL_STEPPER_PART_MINUS = 0 -cc.CONTROL_STEPPER_PART_PLUS = 1 -cc.CONTROL_STEPPER_PART_NONE = 2 - -cc.TABLEVIEW_FILL_TOPDOWN = 0 -cc.TABLEVIEW_FILL_BOTTOMUP = 1 - -cc.WEBSOCKET_OPEN = 0 -cc.WEBSOCKET_MESSAGE = 1 -cc.WEBSOCKET_CLOSE = 2 -cc.WEBSOCKET_ERROR = 3 - -cc.WEBSOCKET_STATE_CONNECTING = 0 -cc.WEBSOCKET_STATE_OPEN = 1 -cc.WEBSOCKET_STATE_CLOSING = 2 -cc.WEBSOCKET_STATE_CLOSED = 3 - - -cc.XMLHTTPREQUEST_RESPONSE_STRING = 0 -cc.XMLHTTPREQUEST_RESPONSE_ARRAY_BUFFER = 1 -cc.XMLHTTPREQUEST_RESPONSE_BLOB = 2 -cc.XMLHTTPREQUEST_RESPONSE_DOCUMENT = 3 -cc.XMLHTTPREQUEST_RESPONSE_JSON = 4 - -cc.ASSETSMANAGEREX_CREATE_FILE = 0 -cc.ASSETSMANAGEREX_NETWORK = 1 -cc.ASSETSMANAGEREX_NO_NEW_VERSION = 2 -cc.ASSETSMANAGEREX_UNCOMPRESS = 3 - -cc.ASSETSMANAGEREX_PROTOCOL_PROGRESS = 0 -cc.ASSETSMANAGEREX_PROTOCOL_SUCCESS = 1 -cc.ASSETSMANAGEREX_PROTOCOL_ERROR = 2 - cc.Handler = cc.Handler or {} cc.Handler.NODE = 0 cc.Handler.MENU_CLICKED = 1 diff --git a/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua b/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua index 1aa9634c54..4bd74ba274 100644 --- a/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua +++ b/cocos/scripting/lua-bindings/script/extension/ExtensionConstants.lua @@ -57,3 +57,13 @@ cc.KEYBOARD_RETURNTYPE_DONE = 1 cc.KEYBOARD_RETURNTYPE_SEND = 2 cc.KEYBOARD_RETURNTYPE_SEARCH = 3 cc.KEYBOARD_RETURNTYPE_GO = 4 + +cc.ASSETSMANAGER_CREATE_FILE = 0 +cc.ASSETSMANAGER_NETWORK = 1 +cc.ASSETSMANAGER_NO_NEW_VERSION = 2 +cc.ASSETSMANAGER_UNCOMPRESS = 3 + +cc.ASSETSMANAGER_PROTOCOL_PROGRESS = 0 +cc.ASSETSMANAGER_PROTOCOL_SUCCESS = 1 +cc.ASSETSMANAGER_PROTOCOL_ERROR = 2 + diff --git a/extensions/assets-manager/Downloader.cpp b/extensions/assets-manager/Downloader.cpp index 2b5bb638f2..7e8ef08c4a 100644 --- a/extensions/assets-manager/Downloader.cpp +++ b/extensions/assets-manager/Downloader.cpp @@ -447,20 +447,20 @@ void Downloader::download(const std::string &srcUrl, const std::string &customId if (res == CURLE_OK) { _fileUtils->renameFile(data.path, data.name + TEMP_EXT, data.name); - } - - Director::getInstance()->getScheduler()->performFunctionInCocosThread([=]{ - if (!ptr.expired()) - { - std::shared_ptr downloader = ptr.lock(); - - auto successCB = downloader->getSuccessCallback(); - if (successCB != nullptr) + + Director::getInstance()->getScheduler()->performFunctionInCocosThread([=]{ + if (!ptr.expired()) { - successCB(data.url, data.path + data.name, data.customId); + std::shared_ptr downloader = ptr.lock(); + + auto successCB = downloader->getSuccessCallback(); + if (successCB != nullptr) + { + successCB(data.url, data.path + data.name, data.customId); + } } - } - }); + }); + } } void Downloader::batchDownloadAsync(const DownloadUnits &units, const std::string &batchId/* = ""*/) diff --git a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj index b574995047..6b8cc38035 100644 --- a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj +++ b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj @@ -70,7 +70,7 @@ - $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) Level3 @@ -121,7 +121,7 @@ xcopy "$(ProjectDir)..\..\..\cpp-tests\Resources" "$(ProjectDir)..\..\res" /e /Y - $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) Level3 diff --git a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.filters b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.filters index 36d208c119..2427487eb2 100644 --- a/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.filters +++ b/tests/lua-tests/project/proj.win32/lua-tests.win32.vcxproj.filters @@ -15,15 +15,13 @@ win32 - - Classes - Classes Classes + @@ -32,11 +30,9 @@ win32 - - Classes - Classes + \ No newline at end of file diff --git a/tests/lua-tests/src/AssetsManagerExTest/AssetsManagerExTest.lua b/tests/lua-tests/src/AssetsManagerExTest/AssetsManagerExTest.lua index 8e61ed38da..8e3c523c42 100644 --- a/tests/lua-tests/src/AssetsManagerExTest/AssetsManagerExTest.lua +++ b/tests/lua-tests/src/AssetsManagerExTest/AssetsManagerExTest.lua @@ -57,7 +57,7 @@ function AMTestScene1.create() local progress = cc.Label:createWithTTF(ttfConfig, "0%", cc.VERTICAL_TEXT_ALIGNMENT_CENTER) progress:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y + 50)) layer:addChild(progress) - am = cc.AssetsManagerEx:create("Manifests/AMTestScene1/project.manifest", "LuaTests/AssetsManagerExTest/scene1") + am = cc.AssetsManagerEx:create("Manifests/AMTestScene1/project.manifest", cc.FileUtils:getInstance():getWritablePath() .. "LuaTests/AssetsManagerExTest/scene1") am:retain() if not am:getLocalManifest():isLoaded() then @@ -154,7 +154,7 @@ function AMTestScene2.create() progress:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y + 50)) layer:addChild(progress) - am = cc.AssetsManagerEx:create("Manifests/AMTestScene2/project.manifest", "LuaTests/AssetsManagerExTest/scene2") + am = cc.AssetsManagerEx:create("Manifests/AMTestScene2/project.manifest", cc.FileUtils:getInstance():getWritablePath() .. "LuaTests/AssetsManagerExTest/scene2") am:retain() if not am:getLocalManifest():isLoaded() then @@ -250,7 +250,7 @@ function AMTestScene3.create() progress:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y + 50)) layer:addChild(progress) - am = cc.AssetsManagerEx:create("Manifests/AMTestScene3/project.manifest", "LuaTests/AssetsManagerExTest/scene3") + am = cc.AssetsManagerEx:create("Manifests/AMTestScene3/project.manifest", cc.FileUtils:getInstance():getWritablePath() .. "LuaTests/AssetsManagerExTest/scene3") am:retain() if not am:getLocalManifest():isLoaded() then diff --git a/tests/lua-tests/src/AssetsManagerExTest/AssetsManagerExModule.lua b/tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua similarity index 100% rename from tests/lua-tests/src/AssetsManagerExTest/AssetsManagerExModule.lua rename to tests/lua-tests/src/AssetsManagerTest/AssetsManagerModule.lua diff --git a/tests/lua-tests/src/mainMenu.lua b/tests/lua-tests/src/mainMenu.lua index 9f76196f5b..31ba5cd10d 100644 --- a/tests/lua-tests/src/mainMenu.lua +++ b/tests/lua-tests/src/mainMenu.lua @@ -8,6 +8,7 @@ require "ActionsEaseTest/ActionsEaseTest" require "ActionsProgressTest/ActionsProgressTest" require "ActionsTest/ActionsTest" require "AssetsManagerTest/AssetsManagerTest" +require "AssetsManagerExTest/AssetsManagerExTest" require "BillBoardTest/BillBoardTest" require "BugsTest/BugsTest" require "ByteCodeEncryptTest/ByteCodeEncryptTest" @@ -72,6 +73,7 @@ local _allTests = { { isSupported = true, name = "ActionsProgressTest" , create_func = ProgressActionsTest }, { isSupported = true, name = "ActionsTest" , create_func = ActionsTest }, { isSupported = true, name = "AssetsManagerTest" , create_func = AssetsManagerTestMain }, + { isSupported = true, name = "AssetsManagerExTest" , create_func = AssetsManagerExTestMain }, { isSupported = audioEndineSupported, name = "AudioEngineTest", create_func = AudioEngineTest}, { isSupported = false, name = "Box2dTest" , create_func= Box2dTestMain }, { isSupported = false, name = "Box2dTestBed" , create_func= Box2dTestBedMain }, diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index 0d2b78a5d2..94cc61fea6 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -27,7 +27,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 = Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ AssetsManagerEx Manifest EventAssetsManager EventListenerAssetsManager +classes = Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ AssetsManager AssetsManagerEx Manifest EventAssetsManagerEx EventListenerAssetsManagerEx # 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 @@ -46,7 +46,7 @@ skip = .*Delegate::[*], ScrollView::[(g|s)etDelegate$], TableView::[create (g|s)etDataSource$ (g|s)etDelegate], Manifest::[getAssets getAsset], - EventListenerAssetsManager::[create] + EventListenerAssetsManagerEx::[create] rename_functions =