From c61e45103caf84757cf686421af6fc617b8ff7d4 Mon Sep 17 00:00:00 2001 From: Arnold <40414978+PatriceJiang@users.noreply.github.com> Date: Mon, 8 Oct 2018 10:42:24 +0800 Subject: [PATCH] LUA: cc.downloader binding (#19078) --- cocos/scripting/lua-bindings/CMakeLists.txt | 2 + .../network/lua_cocos2dx_network_manual.cpp | 2 + .../manual/network/lua_downloader.cpp | 347 ++++++++++++++++++ .../manual/network/lua_downloader.h | 39 ++ .../lua-bindings/proj.android/Android.mk | 1 + .../project.pbxproj | 16 + .../proj.win32/libluacocos2d.vcxproj | 3 + .../proj.win32/libluacocos2d.vcxproj.filters | 6 + templates/cocos2dx_files.json | 6 +- 9 files changed, 420 insertions(+), 2 deletions(-) create mode 100644 cocos/scripting/lua-bindings/manual/network/lua_downloader.cpp create mode 100644 cocos/scripting/lua-bindings/manual/network/lua_downloader.h diff --git a/cocos/scripting/lua-bindings/CMakeLists.txt b/cocos/scripting/lua-bindings/CMakeLists.txt index 4467dc00f6..1128bf93ed 100644 --- a/cocos/scripting/lua-bindings/CMakeLists.txt +++ b/cocos/scripting/lua-bindings/CMakeLists.txt @@ -17,6 +17,7 @@ set(lua_bindings_manual_headers manual/network/lua_xml_http_request.h manual/network/Lua_web_socket.h manual/network/lua_extensions.h + manual/network/lua_downloader.h manual/audioengine/lua_cocos2dx_audioengine_manual.h manual/Lua-BindingsExport.h manual/tolua_fix.h @@ -67,6 +68,7 @@ set(lua_bindings_manual_files manual/network/lua_cocos2dx_network_manual.cpp manual/network/Lua_web_socket.cpp manual/network/lua_xml_http_request.cpp + manual/network/lua_downloader.cpp manual/spine/lua_cocos2dx_spine_manual.cpp manual/spine/LuaSkeletonAnimation.cpp manual/ui/lua_cocos2dx_experimental_video_manual.cpp diff --git a/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp b/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp index 286263ae6a..16854f5320 100644 --- a/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp @@ -33,6 +33,7 @@ extern "C" { #endif #include "scripting/lua-bindings/manual/network/lua_xml_http_request.h" +#include "scripting/lua-bindings/manual/network/lua_downloader.h" #include "scripting/lua-bindings/manual/CCLuaEngine.h" @@ -51,6 +52,7 @@ int register_network_module(lua_State* L) #endif register_xml_http_request(L); + register_downloader(L); } lua_pop(L, 1); diff --git a/cocos/scripting/lua-bindings/manual/network/lua_downloader.cpp b/cocos/scripting/lua-bindings/manual/network/lua_downloader.cpp new file mode 100644 index 0000000000..e987d20484 --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/network/lua_downloader.cpp @@ -0,0 +1,347 @@ +/**************************************************************************** +Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + +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 "lua_downloader.h" + +#include "network/CCDownloader.h" +#include "lua_extensions.h" +#include + +#include +#include +#include + +using namespace cocos2d; +using namespace cocos2d::network; + +static int get_field_int(lua_State *L, const char *field, int def) +{ + int ret = def; + lua_pushstring(L, field); + lua_gettable(L, -2); + if (lua_isnil(L, -1)) + { + //luaL_error(L, "get_field_int: field '%s' no exists.", field); + return ret; + } + ret = (int)lua_tointeger(L, -1); + lua_pop(L, 1); + return ret; +} + +static std::string get_field_string(lua_State *L, const char *field, const char *def) +{ + std::string ret = def; + lua_pushstring(L, field); + lua_gettable(L, -2); + if (lua_isnil(L, -1)) + { + //luaL_error(L, "get_field_string: field '%s' no exists.", field); + return ret; + } + ret = std::string(lua_tostring(L, -1)); + lua_pop(L, 1); + return ret; +} + +static void set_field_string(lua_State *L, const char *field, const char *value) +{ + lua_pushstring(L, field); + lua_pushstring(L, value); + lua_settable(L, -3); +} + +static Downloader *checkDownloader(lua_State *L) { + void *ud = luaL_checkudata(L, 1, "cc.Downloader"); + luaL_argcheck(L, ud != NULL, 1, "`Downloader' expected"); + return (Downloader *)ud; +} + +static void pushTaskTable(lua_State *L, const DownloadTask &task) +{ + lua_newtable(L); + set_field_string(L, "identifier", task.identifier.c_str()); + set_field_string(L, "requestURL", task.requestURL.c_str()); + set_field_string(L, "storagePath", task.storagePath.c_str()); +} + + +static void saveCallback(lua_State *L, void *addr, const char *callbackName) +{ + //stack [fn] + lua_pushlightuserdata(L, (void*)addr); //stack fn, ud + lua_gettable(L, LUA_REGISTRYINDEX); //stack fn, callbacks_tb + lua_pushstring(L, callbackName); //stack fn, callbacks_tb, callbackName + lua_pushvalue(L, -3); //stack fn, callbacks_tb, callbackName, fn + lua_settable(L, -3); //stack fn, callbacks_tb + lua_pop(L, 2); //stack +} + +static int getCallback(lua_State *L, void *addr, const char *callbackName) +{ + //stack [] + lua_pushlightuserdata(L, (void*)addr); //stack ud + lua_gettable(L, LUA_REGISTRYINDEX); //stack callbacks_tb + lua_pushstring(L, callbackName); //stack callbacks_tb, callbackName + lua_gettable(L, -2); //stack callbacks_tb, callbackfn + lua_remove(L, -2); //stack callbackfn + return lua_isfunction(L, -1) ? 1 : 0; +} + +static int lua_downloader_new(lua_State *L) +{ + Downloader *downloader = nullptr; + int argc = lua_gettop(L) - 1; + if (argc >= 1) { + //parse DownloaderHints + if (!lua_istable(L, -1)) { + luaL_error(L, "cc.Downloader.new: first argument should be table if set"); + return 0; + } + DownloaderHints hints; + hints.countOfMaxProcessingTasks = get_field_int(L, "countOfMaxProcessingTasks", 6); + hints.timeoutInSeconds = get_field_int(L, "timeoutInSeconds", 45); + hints.tempFileNameSuffix = get_field_string(L, "tempFileNameSuffix", ".tmp"); + + auto ptr = lua_newuserdata(L, sizeof(Downloader)); + downloader = new (ptr) Downloader(hints); + } + else + { + auto ptr = lua_newuserdata(L, sizeof(Downloader)); + downloader = new (ptr) Downloader(); + } + + luaL_getmetatable(L, "cc.Downloader"); + lua_setmetatable(L, -2); + + //register callback table + lua_pushlightuserdata(L, (void*)downloader); + lua_newtable(L); + lua_settable(L, LUA_REGISTRYINDEX); + + return 1; +} + + +static int lua_downloader_createDownloadDataTask(lua_State *L) +{ + Downloader *d = checkDownloader(L); + int argc = lua_gettop(L) - 1; + std::string url = ""; + std::string identifier = ""; + + if (argc == 0) + { + luaL_error(L, "cc.Downloader.createDownloadDataTask parameter error"); + return 0; + } + + if (argc >= 1) url = lua_tostring(L, 2); + if (argc >= 2) identifier = lua_tostring(L, 3); + auto tsk = d->createDownloadDataTask(url, identifier); + + pushTaskTable(L, *tsk); + return 1; +} + +static int lua_downloader_createDownloadFileTask(lua_State *L) +{ + int argc = lua_gettop(L) - 1; + Downloader *d = checkDownloader(L); + std::string url = ""; + std::string storagePath = ""; + std::string identifier = ""; + + if (argc < 2) + { + luaL_error(L, "cc.Downloader.createDownloadFileTask parameter error!"); + return 0; + } + + url = lua_tostring(L, 2); + storagePath = lua_tostring(L, 3); + if (argc > 2) identifier = lua_tostring(L, 4); + + auto tsk = d->createDownloadFileTask(url, storagePath, identifier); + + pushTaskTable(L, *tsk); + return 1; +} +static int lua_downloader_setOnFileTaskSuccess(lua_State *L) +{ + int argc = lua_gettop(L) - 1; + Downloader *d = checkDownloader(L); + if (argc != 1) { + luaL_error(L, "cc.Downloader.setOnFileTaskSuccess parameter error!"); + return 0; + } + luaL_argcheck(L, lua_isfunction(L, 2), 2, "should be a function"); + saveCallback(L, d, "setOnFileTaskSuccess"); + + d->setOnFileTaskSuccess([d, L](const DownloadTask &task) { + int ret = getCallback(L, d, "setOnFileTaskSuccess"); //stack callbackfn + if (ret) + { + pushTaskTable(L, task); //stack callbackfn, task + if (lua_pcall(L, 1, 0, 0) != 0) + { + lua_pop(L, 1); // remove callback or nil + luaL_error(L, "cc.Downloader.setOnFileTaskSuccess invoke callback error!"); + return; + } + } + else { + lua_pop(L, 1); // remove callback or nil + } + }); + + return 0; +} +static int lua_downloader_setOnTaskProgress(lua_State *L) +{ + Downloader *d = checkDownloader(L); + int argc = lua_gettop(L) - 1; + if (argc != 1) { + luaL_error(L, "cc.Downloader.setOnTaskProgress parameter error!"); + return 0; + } + luaL_argcheck(L, lua_isfunction(L, 2), 2, "should be a function"); + saveCallback(L, d, "setOnTaskProgress"); + + d->setOnTaskProgress([d, L](const DownloadTask &task, + int64_t bytesReceived, + int64_t totalBytesReceived, + int64_t totalBytesExpected) { + int ret = getCallback(L, d, "setOnTaskProgress"); //stack callbackfn + if (ret) + { + pushTaskTable(L, task); //stack callbackfn, task + lua_pushnumber(L, bytesReceived); + lua_pushnumber(L, totalBytesReceived); + lua_pushnumber(L, totalBytesExpected); + if (lua_pcall(L, 4, 0, 0) != 0) + { + lua_pop(L, 1); // remove callback or nil + luaL_error(L, "cc.Downloader.setOnTaskProgress invoke callback error!"); + return; + } + } + else { + lua_pop(L, 1); // remove callback or nil + } + }); + + return 0; +} +static int lua_downloader_setOnTaskError(lua_State *L) +{ + Downloader *d = checkDownloader(L); + int argc = lua_gettop(L) - 1; + if (argc != 1) { + luaL_error(L, "cc.Downloader.setOnTaskError parameter error!"); + return 0; + } + luaL_argcheck(L, lua_isfunction(L, 2), 2, "should be a function"); + saveCallback(L, d, "setOnTaskError"); + + d->setOnTaskError([d, L](const DownloadTask &task, + int errorCode, + int errorCodeInternal, + const std::string& errorSt) { + int ret = getCallback(L, d, "setOnTaskError"); //stack callbackfn + if (ret) + { + pushTaskTable(L, task); //stack callbackfn, task + lua_pushnumber(L, errorCode); + lua_pushnumber(L, errorCodeInternal); + lua_pushstring(L, errorSt.c_str()); + if (lua_pcall(L, 4, 0, 0) != 0) + { + lua_pop(L, 1); // remove callback or nil + luaL_error(L, "cc.Downloader.setOnTaskError invoke callback error!"); + return; + } + } + else { + lua_pop(L, 1); // remove callback or nil + } + }); + + return 0; +} + + +static int lua_downloader_cleanup(lua_State *L) +{ + Downloader *d = checkDownloader(L); + + //std::cout << "cc.Downloader __gc" << std::endl; + + //remove callback table + lua_pushlightuserdata(L, (void*)d); + lua_pushnil(L); + lua_settable(L, LUA_REGISTRYINDEX); + return 0; +} + +static int lua_downloader_tostring(lua_State *L) +{ + lua_pushstring(L, "[cc.Downloader]"); + return 1; +} + +static const struct luaL_reg downloaderStaticFns[] = { + { "new", lua_downloader_new }, + /* + * cocos2d::Downloader is not a subclass of cocos2d::Ref, + * `create()` is not provided. + */ + //{ "create", lua_downloader_new }, + { nullptr, nullptr } + }; + + +static const struct luaL_reg downloaderMemberFns[] = { + { "createDownloadDataTask", lua_downloader_createDownloadDataTask }, + { "createDownloadFileTask", lua_downloader_createDownloadFileTask }, + { "setOnFileTaskSuccess", lua_downloader_setOnFileTaskSuccess }, + { "setOnTaskProgress", lua_downloader_setOnTaskProgress }, + { "setOnTaskError", lua_downloader_setOnTaskError }, + { "__gc", lua_downloader_cleanup }, + { "__tostring", lua_downloader_tostring }, + { nullptr, nullptr } +}; + +int register_downloader(lua_State* L) +{ + luaL_newmetatable(L, "cc.Downloader"); + lua_pushstring(L, "__index"); + lua_pushvalue(L, -2); /* pushes the metatable */ + lua_settable(L, -3); /* metatable.__index = metatable */ + + luaL_openlib(L, nullptr, downloaderMemberFns, 0); + luaL_openlib(L, "cc.Downloader", downloaderStaticFns, 0); + return 1; +} + diff --git a/cocos/scripting/lua-bindings/manual/network/lua_downloader.h b/cocos/scripting/lua-bindings/manual/network/lua_downloader.h new file mode 100644 index 0000000000..853ab0ff34 --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/network/lua_downloader.h @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. + + 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. + ****************************************************************************/ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#include "lua.h" +#include "lualib.h" +#include "lauxlib.h" +//#include "lua.hpp" +#ifdef __cplusplus +} +#endif + +TOLUA_API int register_downloader(lua_State* L); \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/proj.android/Android.mk b/cocos/scripting/lua-bindings/proj.android/Android.mk index ce838cdf0a..2ef2b81e1d 100644 --- a/cocos/scripting/lua-bindings/proj.android/Android.mk +++ b/cocos/scripting/lua-bindings/proj.android/Android.mk @@ -79,6 +79,7 @@ LOCAL_SRC_FILES += ../manual/cocosdenshion/lua_cocos2dx_cocosdenshion_manual.cpp #network LOCAL_SRC_FILES += ../manual/network/lua_cocos2dx_network_manual.cpp \ ../manual/network/lua_extensions.c \ + ../manual/network/lua_downloader.cpp \ ../manual/network/Lua_web_socket.cpp \ ../manual/network/lua_xml_http_request.cpp \ ../../../../external/lua/luasocket/auxiliar.c \ diff --git a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj index 0db21ad682..4d40a4e945 100644 --- a/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj +++ b/cocos/scripting/lua-bindings/proj.ios_mac/cocos2d_lua_bindings.xcodeproj/project.pbxproj @@ -436,6 +436,12 @@ BA0CBB5F1BB0756F00003364 /* CCComponentLua.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA0CBB5C1BB0756F00003364 /* CCComponentLua.cpp */; }; BA0CBB601BB0756F00003364 /* CCComponentLua.h in Headers */ = {isa = PBXBuildFile; fileRef = BA0CBB5D1BB0756F00003364 /* CCComponentLua.h */; }; BA0CBB611BB0756F00003364 /* CCComponentLua.h in Headers */ = {isa = PBXBuildFile; fileRef = BA0CBB5D1BB0756F00003364 /* CCComponentLua.h */; }; + ED1AA90B215DF5F3004ABA9F /* lua_downloader.h in Headers */ = {isa = PBXBuildFile; fileRef = ED1AA909215DF5F3004ABA9F /* lua_downloader.h */; }; + ED1AA90C215DF5F3004ABA9F /* lua_downloader.h in Headers */ = {isa = PBXBuildFile; fileRef = ED1AA909215DF5F3004ABA9F /* lua_downloader.h */; }; + ED1AA90D215DF5F3004ABA9F /* lua_downloader.h in Headers */ = {isa = PBXBuildFile; fileRef = ED1AA909215DF5F3004ABA9F /* lua_downloader.h */; }; + ED1AA90E215DF5F3004ABA9F /* lua_downloader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED1AA90A215DF5F3004ABA9F /* lua_downloader.cpp */; }; + ED1AA90F215DF5F3004ABA9F /* lua_downloader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED1AA90A215DF5F3004ABA9F /* lua_downloader.cpp */; }; + ED1AA910215DF5F3004ABA9F /* lua_downloader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED1AA90A215DF5F3004ABA9F /* lua_downloader.cpp */; }; F4FE0D5719ECD00100B8B12B /* luasocket_scripts.c in Sources */ = {isa = PBXBuildFile; fileRef = F4FE0D5519ECD00100B8B12B /* luasocket_scripts.c */; }; F4FE0D5819ECD00100B8B12B /* luasocket_scripts.c in Sources */ = {isa = PBXBuildFile; fileRef = F4FE0D5519ECD00100B8B12B /* luasocket_scripts.c */; }; F4FE0D5919ECD00100B8B12B /* luasocket_scripts.h in Headers */ = {isa = PBXBuildFile; fileRef = F4FE0D5619ECD00100B8B12B /* luasocket_scripts.h */; }; @@ -601,6 +607,8 @@ BA0CBB5C1BB0756F00003364 /* CCComponentLua.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCComponentLua.cpp; sourceTree = ""; }; BA0CBB5D1BB0756F00003364 /* CCComponentLua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCComponentLua.h; sourceTree = ""; }; C0D9BAFA1974D30000EC35BB /* liblua.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua.a; path = ../../../../external/lua/lua/prebuilt/ios/liblua.a; sourceTree = ""; }; + ED1AA909215DF5F3004ABA9F /* lua_downloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_downloader.h; sourceTree = ""; }; + ED1AA90A215DF5F3004ABA9F /* lua_downloader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_downloader.cpp; sourceTree = ""; }; F4FE0D5519ECD00100B8B12B /* luasocket_scripts.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = luasocket_scripts.c; sourceTree = ""; }; F4FE0D5619ECD00100B8B12B /* luasocket_scripts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = luasocket_scripts.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -736,6 +744,8 @@ 15C1BD001986526C00A46ACC /* network */ = { isa = PBXGroup; children = ( + ED1AA90A215DF5F3004ABA9F /* lua_downloader.cpp */, + ED1AA909215DF5F3004ABA9F /* lua_downloader.h */, 15EFA694198B668C000C57D3 /* lua_cocos2dx_network_manual.cpp */, 15EFA695198B668C000C57D3 /* lua_cocos2dx_network_manual.h */, 15C1BD011986526C00A46ACC /* lua_extensions.c */, @@ -1028,6 +1038,7 @@ 155C7DF819A71C4400F08B25 /* lua_cocos2dx_cocosdenshion_manual.h in Headers */, 15415AAF19A71A53004F1E71 /* except.h in Headers */, 150906F319D556D1002C4D97 /* lua_cocos2dx_audioengine_manual.h in Headers */, + ED1AA90B215DF5F3004ABA9F /* lua_downloader.h in Headers */, 155C7E0419A71C6D00F08B25 /* lua_cocos2dx_cocosbuilder_manual.h in Headers */, 15415ACB19A71A53004F1E71 /* socket.h in Headers */, 15415ADF19A71A53004F1E71 /* usocket.h in Headers */, @@ -1103,6 +1114,7 @@ 15EFA64C198B3320000C57D3 /* tolua++.h in Headers */, 155C7DF919A71C4500F08B25 /* lua_cocos2dx_cocosdenshion_manual.h in Headers */, 15415AB019A71A53004F1E71 /* except.h in Headers */, + ED1AA90C215DF5F3004ABA9F /* lua_downloader.h in Headers */, 3E2BDB0B19C5E6100055CDCD /* lua_cocos2dx_audioengine_manual.h in Headers */, 155C7E0519A71C6F00F08B25 /* lua_cocos2dx_cocosbuilder_manual.h in Headers */, 15415ACC19A71A53004F1E71 /* socket.h in Headers */, @@ -1178,6 +1190,7 @@ 507B43201C31FA0C0067B53E /* tolua++.h in Headers */, 507B43211C31FA0C0067B53E /* lua_cocos2dx_cocosdenshion_manual.h in Headers */, 507B43221C31FA0C0067B53E /* except.h in Headers */, + ED1AA90D215DF5F3004ABA9F /* lua_downloader.h in Headers */, 507B43231C31FA0C0067B53E /* lua_cocos2dx_audioengine_manual.h in Headers */, 507B43241C31FA0C0067B53E /* lua_cocos2dx_cocosbuilder_manual.h in Headers */, 507B43251C31FA0C0067B53E /* socket.h in Headers */, @@ -1331,6 +1344,7 @@ ADD1C0D51C196B9500733781 /* lua_module_register.cpp in Sources */, 15415AD519A71A53004F1E71 /* udp.c in Sources */, 150983D01B1C0554007F3818 /* lua_cocos2dx_navmesh_auto.cpp in Sources */, + ED1AA90E215DF5F3004ABA9F /* lua_downloader.cpp in Sources */, 15415ADD19A71A53004F1E71 /* usocket.c in Sources */, 15AC69DC1987710400D17520 /* tolua_push.c in Sources */, 15AC69DD1987710400D17520 /* tolua_to.c in Sources */, @@ -1465,6 +1479,7 @@ 15EFA629198B31FB000C57D3 /* lua_cocos2dx_physics_manual.cpp in Sources */, 15EFA62A198B31FB000C57D3 /* LuaScriptHandlerMgr.cpp in Sources */, 15EFA617198B2E2B000C57D3 /* lua_cocos2dx_experimental_auto.cpp in Sources */, + ED1AA90F215DF5F3004ABA9F /* lua_downloader.cpp in Sources */, 15EFA618198B2E2B000C57D3 /* lua_cocos2dx_auto.cpp in Sources */, 15EFA619198B2E2B000C57D3 /* lua_cocos2dx_physics_auto.cpp in Sources */, 15415AB219A71A53004F1E71 /* inet.c in Sources */, @@ -1548,6 +1563,7 @@ 507B43011C31FA0C0067B53E /* lua_cocos2dx_physics_manual.cpp in Sources */, 507B43021C31FA0C0067B53E /* LuaScriptHandlerMgr.cpp in Sources */, 507B43031C31FA0C0067B53E /* lua_cocos2dx_experimental_auto.cpp in Sources */, + ED1AA910215DF5F3004ABA9F /* lua_downloader.cpp in Sources */, 507B43041C31FA0C0067B53E /* lua_cocos2dx_auto.cpp in Sources */, 507B43051C31FA0C0067B53E /* lua_cocos2dx_physics_auto.cpp in Sources */, 507B43061C31FA0C0067B53E /* inet.c in Sources */, diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj index e494677f9b..462c1092e4 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj @@ -74,6 +74,7 @@ + @@ -152,6 +153,7 @@ + @@ -284,6 +286,7 @@ $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) + $(IncludePath) diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters index 508c67e4d2..685905bb1b 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters @@ -300,6 +300,9 @@ manual + + manual\network + @@ -530,6 +533,9 @@ manual + + manual\network + diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 894b52ad26..bd22e2f8bf 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -5,7 +5,7 @@ "CHANGELOG", "CMakeLists.txt", "CONTRIBUTING.md", - "README.md", + "README.md", "build/android-build.py", "build/cocos2d-win32.sln", "build/cocos2d_libs.xcodeproj/project.pbxproj", @@ -5006,7 +5006,7 @@ "tools/tojs/cocos2dx_spine.ini", "tools/tojs/cocos2dx_studio.ini", "tools/tojs/cocos2dx_ui.ini", - "tools/tojs/genbindings.py", + "tools/tojs/genbindings.py", "tools/tojs/userconf.ini" ], "lua": [ @@ -5569,6 +5569,8 @@ "cocos/scripting/lua-bindings/manual/network/Lua_web_socket.h", "cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.cpp", "cocos/scripting/lua-bindings/manual/network/lua_cocos2dx_network_manual.h", + "cocos/scripting/lua-bindings/manual/network/lua_downloader.cpp", + "cocos/scripting/lua-bindings/manual/network/lua_downloader.h", "cocos/scripting/lua-bindings/manual/network/lua_extensions.c", "cocos/scripting/lua-bindings/manual/network/lua_extensions.h", "cocos/scripting/lua-bindings/manual/network/lua_xml_http_request.cpp",