From 9811d6efcfa8f1d529172a36b6a572104e594e99 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Wed, 25 Nov 2015 21:52:44 +0800 Subject: [PATCH] Combine studio change for LuaBinding, jsb and simulator --- .../js-bindings/manual/js-BindingsExport.h | 30 +++++++++++++++++ .../js-bindings/manual/js_module_register.cpp | 10 +++--- .../js-bindings/manual/js_module_register.h | 12 +++++++ .../proj.win32/libjscocos2d.vcxproj | 9 +++-- .../proj.win32/libjscocos2d.vcxproj.filters | 21 ++++++++---- .../lua-bindings/manual/Lua-BindingsExport.h | 33 +++++++++++++++++++ .../manual/lua_module_register.cpp | 8 ++--- .../lua-bindings/manual/lua_module_register.h | 10 ++++++ .../proj.win32/libluacocos2d.vcxproj | 9 +++-- .../proj.win32/libluacocos2d.vcxproj.filters | 9 +++++ .../Classes/ide-support/RuntimeJsImpl.cpp | 9 ++--- .../Classes/ide-support/RuntimeLuaImpl.cpp | 2 -- .../runtime-src/proj.win32/simulator.vcxproj | 12 +++---- tools/simulator/libsimulator/lib/AppEvent.h | 3 +- tools/simulator/libsimulator/lib/AppLang.h | 3 +- tools/simulator/libsimulator/lib/DeviceEx.h | 3 +- .../lib/PlayerMenuServiceProtocol.h | 3 +- .../libsimulator/lib/PlayerProtocol.h | 3 +- .../lib/ProjectConfig/ProjectConfig.h | 3 +- .../lib/ProjectConfig/SimulatorConfig.h | 3 +- .../libsimulator/lib/SimulatorExport.h | 30 +++++++++++++++++ .../lib/platform/win32/PlayerMenuServiceWin.h | 5 +-- .../lib/platform/win32/PlayerWin.h | 3 +- .../libsimulator/lib/runtime/ConfigParser.h | 4 ++- .../lib/runtime/ConsoleCommand.cpp | 6 ++-- .../libsimulator/lib/runtime/FileServer.cpp | 2 +- .../libsimulator/lib/runtime/FileServer.h | 3 +- .../libsimulator/lib/runtime/Runtime.cpp | 24 ++++++++++++-- .../libsimulator/lib/runtime/Runtime.h | 7 ++-- .../lib/runtime/RuntimeProtocol.h | 3 +- .../libsimulator/lib/runtime/Widget_mac.h | 12 +++++++ .../libsimulator/lib/runtime/Widget_mac.mm | 20 +++++++++++ .../proj.win32/libsimulator.vcxproj | 4 +-- 33 files changed, 261 insertions(+), 57 deletions(-) create mode 100644 cocos/scripting/js-bindings/manual/js-BindingsExport.h rename tools/simulator/frameworks/runtime-src/Classes/js_module_register.h => cocos/scripting/js-bindings/manual/js_module_register.cpp (94%) create mode 100644 cocos/scripting/js-bindings/manual/js_module_register.h create mode 100644 cocos/scripting/lua-bindings/manual/Lua-BindingsExport.h rename tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h => cocos/scripting/lua-bindings/manual/lua_module_register.cpp (78%) mode change 100755 => 100644 create mode 100644 cocos/scripting/lua-bindings/manual/lua_module_register.h create mode 100644 tools/simulator/libsimulator/lib/SimulatorExport.h create mode 100644 tools/simulator/libsimulator/lib/runtime/Widget_mac.h create mode 100644 tools/simulator/libsimulator/lib/runtime/Widget_mac.mm diff --git a/cocos/scripting/js-bindings/manual/js-BindingsExport.h b/cocos/scripting/js-bindings/manual/js-BindingsExport.h new file mode 100644 index 0000000000..2d90b05f42 --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js-BindingsExport.h @@ -0,0 +1,30 @@ +#pragma once + +#if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8) + #ifdef __MINGW32__ + #include + #endif + + #if defined(_USRJSSTATIC) + #define CC_JS_DLL + #else + #if defined(_USRJSDLL) + #define CC_JS_DLL __declspec(dllexport) + #else /* use a DLL library */ + #define CC_JS_DLL __declspec(dllimport) + #endif + #endif + + /* Define NULL pointer value */ + #ifndef NULL + #ifdef __cplusplus + #define NULL 0 + #else + #define NULL ((void *)0) + #endif + #endif +#elif defined(_SHARED_) + #define CC_JS_DLL __attribute__((visibility("default"))) +#else + #define CC_JS_DLL +#endif diff --git a/tools/simulator/frameworks/runtime-src/Classes/js_module_register.h b/cocos/scripting/js-bindings/manual/js_module_register.cpp similarity index 94% rename from tools/simulator/frameworks/runtime-src/Classes/js_module_register.h rename to cocos/scripting/js-bindings/manual/js_module_register.cpp index 6222802506..c6739babf5 100644 --- a/tools/simulator/frameworks/runtime-src/Classes/js_module_register.h +++ b/cocos/scripting/js-bindings/manual/js_module_register.cpp @@ -1,7 +1,5 @@ -#ifndef __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ -#define __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ +#include "js_module_register.h" -#include "scripting/js-bindings/manual/ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_ui_auto.hpp" #include "jsb_cocos2dx_studio_auto.hpp" @@ -121,5 +119,7 @@ int js_module_register() return 1; } -#endif // __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ - +JSObject* get_jsb_cocos2d_FileUtils_prototype() +{ + return jsb_cocos2d_FileUtils_prototype; +} diff --git a/cocos/scripting/js-bindings/manual/js_module_register.h b/cocos/scripting/js-bindings/manual/js_module_register.h new file mode 100644 index 0000000000..aa06bd0cbe --- /dev/null +++ b/cocos/scripting/js-bindings/manual/js_module_register.h @@ -0,0 +1,12 @@ +#ifndef __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ +#define __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ + +#include "scripting/js-bindings/manual/ScriptingCore.h" +#include "js-BindingsExport.h" + +CC_JS_DLL int js_module_register(); + +CC_JS_DLL JSObject* get_jsb_cocos2d_FileUtils_prototype(); + +#endif // __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__ + diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj index c342f62443..5f59970d93 100644 --- a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj @@ -40,6 +40,7 @@ + @@ -78,6 +79,7 @@ + @@ -87,6 +89,7 @@ + @@ -160,7 +163,7 @@ Level3 Disabled - WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WINDOWS;_DEBUG;_LIB;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_USRJSSTATIC;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\navmesh;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) true @@ -186,7 +189,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" MinSpace true true - WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_USRJSSTATIC;%(PreprocessorDefinitions) $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\navmesh;$(EngineRoot)cocos\storage;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\audio\include;$(EngineRoot)extensions;$(EngineRoot)external;$(ProjectDir)..\auto;$(ProjectDir)..\manual;$(ProjectDir)..\manual\cocostudio;$(ProjectDir)..\manual\navmesh;$(ProjectDir)..\manual\spine;$(ProjectDir)..\..\..\..\external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) 4068;4101;4800;4251;4244;4099;4083;4700;%(DisableSpecificWarnings) true @@ -208,4 +211,4 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\spidermonkey\prebuilt\win32\*.*" - + \ No newline at end of file diff --git a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters index 84a0a0277f..056bf08ba1 100644 --- a/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters +++ b/cocos/scripting/js-bindings/proj.win32/libjscocos2d.vcxproj.filters @@ -113,9 +113,6 @@ manual\cocostudio - - manual\component - manual\extension @@ -167,6 +164,12 @@ manual\navmesh + + manual + + + manual + @@ -253,9 +256,6 @@ manual\cocostudio - - manual\component - manual\extension @@ -310,5 +310,14 @@ manual\navmesh + + auto + + + manual + + + manual + \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/manual/Lua-BindingsExport.h b/cocos/scripting/lua-bindings/manual/Lua-BindingsExport.h new file mode 100644 index 0000000000..1650c27b14 --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/Lua-BindingsExport.h @@ -0,0 +1,33 @@ +#ifndef __LUABINDINGEXPROT_H__ +#define __LUABINDINGEXPROT_H__ + +#if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8) + #ifdef __MINGW32__ + #include + #endif + + #if defined(_USRLUASTATIC) + #define CC_LUA_DLL + #else + #if defined(_USRLUADLL) + #define CC_LUA_DLL __declspec(dllexport) + #else /* use a DLL library */ + #define CC_LUA_DLL __declspec(dllimport) + #endif + #endif + + /* Define NULL pointer value */ + #ifndef NULL + #ifdef __cplusplus + #define NULL 0 + #else + #define NULL ((void *)0) + #endif + #endif +#elif defined(_SHARED_) + #define CC_LUA_DLL __attribute__((visibility("default"))) +#else + #define CC_LUA_DLL +#endif + +#endif /* __CCEXTENSIONEXPORT_H__*/ \ No newline at end of file diff --git a/tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h b/cocos/scripting/lua-bindings/manual/lua_module_register.cpp old mode 100755 new mode 100644 similarity index 78% rename from tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h rename to cocos/scripting/lua-bindings/manual/lua_module_register.cpp index 8b11795f75..05e14e2818 --- a/tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h +++ b/cocos/scripting/lua-bindings/manual/lua_module_register.cpp @@ -1,5 +1,4 @@ -#ifndef __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ -#define __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ +#include "lua_module_register.h" #include "cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h" #include "network/lua_cocos2dx_network_manual.h" @@ -13,7 +12,8 @@ #include "physics3d/lua_cocos2dx_physics3d_manual.h" #include "navmesh/lua_cocos2dx_navmesh_manual.h" -static int lua_module_register(lua_State* L) + +int lua_module_register(lua_State* L) { //Dont' change the module register order unless you know what your are doing register_cocosdenshion_module(L); @@ -34,5 +34,3 @@ static int lua_module_register(lua_State* L) return 1; } -#endif // __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ - diff --git a/cocos/scripting/lua-bindings/manual/lua_module_register.h b/cocos/scripting/lua-bindings/manual/lua_module_register.h new file mode 100644 index 0000000000..97cbdacd6d --- /dev/null +++ b/cocos/scripting/lua-bindings/manual/lua_module_register.h @@ -0,0 +1,10 @@ +#ifndef __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ +#define __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ + +#include "lua.h" +#include "Lua-bindingsExport.h" + +CC_LUA_DLL int lua_module_register(lua_State* L); + +#endif // __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__ + diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj index ea9bda518b..8860c1f41d 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj @@ -70,6 +70,7 @@ + @@ -145,7 +146,9 @@ + + @@ -282,7 +285,7 @@ Disabled $(EngineRoot);$(EngineRoot)cocos\2d;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\navmesh;$(EngineRoot)external;$(EngineRoot)external\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)cocos\scripting\lua-bindings\manual\navmesh;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_USRLUASTATIC;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL @@ -314,7 +317,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ MinSpace true $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)cocos\scripting\lua-bindings\manual\navmesh;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\physics3d;$(EngineRoot)cocos\navmesh;$(EngineRoot)external;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_USRLUASTATIC;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -344,4 +347,4 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ - + \ No newline at end of file diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters index d8b6ddec28..508c67e4d2 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj.filters @@ -297,6 +297,9 @@ manual\navmesh + + manual + @@ -521,6 +524,12 @@ manual\navmesh + + manual + + + manual + diff --git a/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp b/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp index 5d9d636d29..02209c6511 100644 --- a/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp +++ b/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp @@ -15,6 +15,7 @@ #include "runtime/FileServer.h" // js +#include "scripting/js-bindings/manual/ScriptingCore.h" #include "js_module_register.h" @@ -146,10 +147,10 @@ void register_FileUtils(JSContext *cx, JS::HandleObject global) } else { ns.set(nsval.toObjectOrNull()); } - - JS::RootedObject proto(cx, jsb_cocos2d_FileUtils_prototype); - JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); - JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JSObject* fileUtils = get_jsb_cocos2d_FileUtils_prototype(); + JS::RootedObject proto(cx, fileUtils); + JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); + JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE); } RuntimeJsImpl* RuntimeJsImpl::create() diff --git a/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeLuaImpl.cpp b/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeLuaImpl.cpp index 0a43b2265e..0167380df4 100644 --- a/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeLuaImpl.cpp +++ b/tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeLuaImpl.cpp @@ -20,8 +20,6 @@ #include "runtime/ConfigParser.h" #include "runtime/FileServer.h" -extern std::string g_projectPath; // Runtime.cpp - USING_NS_CC; using namespace std; diff --git a/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj b/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj index 96b2231170..6afdd8a643 100644 --- a/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj +++ b/tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj @@ -1,4 +1,4 @@ - + @@ -21,7 +21,7 @@ Unicode v110 v120 - v140 + v140 v140_xp @@ -30,7 +30,7 @@ Unicode v110 v120 - v140 + v140 v140_xp @@ -76,7 +76,7 @@ ProgramDatabase EnableFastChecks Disabled - WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions) + WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_USRLUASTATIC;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) 4267;4251;4244;%(DisableSpecificWarnings) true $(IntDir)vc$(PlatformToolsetVersion).pdb @@ -141,7 +141,7 @@ xcopy /Y /Q "$(OutDir)lang" "$(ProjectDir)..\..\..\runtime\win32" MultiThreadedDLL Sync ProgramDatabase - COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGSNDEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions) + COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGSNDEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_USRLUASTATIC;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) 4267;4251;4244;%(DisableSpecificWarnings) true $(IntDir)vc$(PlatformToolsetVersion).pdb @@ -244,4 +244,4 @@ xcopy /Y /Q "$(OutDir)lang" "$(ProjectDir)..\..\..\runtime\win32" - + \ No newline at end of file diff --git a/tools/simulator/libsimulator/lib/AppEvent.h b/tools/simulator/libsimulator/lib/AppEvent.h index 0810ac5769..f284313ee8 100644 --- a/tools/simulator/libsimulator/lib/AppEvent.h +++ b/tools/simulator/libsimulator/lib/AppEvent.h @@ -15,6 +15,7 @@ #include "json/filestream.h" #include "json/stringbuffer.h" #include "json/writer.h" +#include "SimulatorExport.h" enum { @@ -25,7 +26,7 @@ enum #define kAppEventDropName "APP.EVENT.DROP" #define kAppEventName "APP.EVENT" -class AppEvent : public cocos2d::EventCustom +class CC_LIBSIM_DLL AppEvent : public cocos2d::EventCustom { public: /** Constructor */ diff --git a/tools/simulator/libsimulator/lib/AppLang.h b/tools/simulator/libsimulator/lib/AppLang.h index 8fc1c4f801..8884c9eaae 100644 --- a/tools/simulator/libsimulator/lib/AppLang.h +++ b/tools/simulator/libsimulator/lib/AppLang.h @@ -11,8 +11,9 @@ #include "json/document.h" #include "DeviceEx.h" +#include "SimulatorExport.h" -class AppLang +class CC_LIBSIM_DLL AppLang { public: static AppLang* getInstance(); diff --git a/tools/simulator/libsimulator/lib/DeviceEx.h b/tools/simulator/libsimulator/lib/DeviceEx.h index 7a168ef93f..d7a139bbb4 100644 --- a/tools/simulator/libsimulator/lib/DeviceEx.h +++ b/tools/simulator/libsimulator/lib/DeviceEx.h @@ -2,10 +2,11 @@ #include #include "PlayerMacros.h" +#include "SimulatorExport.h" PLAYER_NS_BEGIN -class DeviceEx +class CC_LIBSIM_DLL DeviceEx { public: static DeviceEx *getInstance(); diff --git a/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h b/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h index dae521824b..8f2e443427 100644 --- a/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h +++ b/tools/simulator/libsimulator/lib/PlayerMenuServiceProtocol.h @@ -7,6 +7,7 @@ #include "cocos2d.h" #include "PlayerMacros.h" #include "PlayerServiceProtocol.h" +#include "SimulatorExport.h" PLAYER_NS_BEGIN @@ -15,7 +16,7 @@ PLAYER_NS_BEGIN #define kPlayerCtrlModifyKey "ctrl" #define kPlayerAltModifyKey "alt" -class PlayerMenuItem : public cocos2d::Ref +class CC_LIBSIM_DLL PlayerMenuItem : public cocos2d::Ref { public: virtual ~PlayerMenuItem(); diff --git a/tools/simulator/libsimulator/lib/PlayerProtocol.h b/tools/simulator/libsimulator/lib/PlayerProtocol.h index 2c21eb6b37..e5a20c0b7e 100644 --- a/tools/simulator/libsimulator/lib/PlayerProtocol.h +++ b/tools/simulator/libsimulator/lib/PlayerProtocol.h @@ -12,10 +12,11 @@ #include "PlayerTaskServiceProtocol.h" #include "ProjectConfig/ProjectConfig.h" +#include "SimulatorExport.h" PLAYER_NS_BEGIN -class PlayerProtocol +class CC_LIBSIM_DLL PlayerProtocol { public: virtual ~PlayerProtocol(); diff --git a/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h b/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h index 0f2d0a10b8..75244ab4cb 100644 --- a/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h +++ b/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h @@ -8,6 +8,7 @@ using namespace std; #include "cocos2d.h" +#include "SimulatorExport.h" #define kCCRuntimeDebuggerNone 0 #define kCCRuntimeDebuggerLDT 1 @@ -37,7 +38,7 @@ using namespace std; #define kProjectConfigUploadPort 6020 #define kProjectConfigDebugPort 5086 -class ProjectConfig +class CC_LIBSIM_DLL ProjectConfig { public: ProjectConfig(); diff --git a/tools/simulator/libsimulator/lib/ProjectConfig/SimulatorConfig.h b/tools/simulator/libsimulator/lib/ProjectConfig/SimulatorConfig.h index e8306272f4..d1d0343f09 100644 --- a/tools/simulator/libsimulator/lib/ProjectConfig/SimulatorConfig.h +++ b/tools/simulator/libsimulator/lib/ProjectConfig/SimulatorConfig.h @@ -8,6 +8,7 @@ using namespace std; #include "cocos2d.h" +#include "SimulatorExport.h" #if defined(_WINDOWS) #define DIRECTORY_SEPARATOR "\\" @@ -33,7 +34,7 @@ typedef struct _SimulatorScreenSize { typedef vector ScreenSizeArray; typedef ScreenSizeArray::iterator ScreenSizeArrayIterator; -class SimulatorConfig +class CC_LIBSIM_DLL SimulatorConfig { public: static SimulatorConfig *getInstance(); diff --git a/tools/simulator/libsimulator/lib/SimulatorExport.h b/tools/simulator/libsimulator/lib/SimulatorExport.h new file mode 100644 index 0000000000..d71d12d824 --- /dev/null +++ b/tools/simulator/libsimulator/lib/SimulatorExport.h @@ -0,0 +1,30 @@ +#pragma once + +#if (defined(WIN32) && defined(_WINDOWS)) || defined(WINRT) || defined(WP8) + #ifdef __MINGW32__ + #include + #endif + + #if defined(_USRLIBSIMSTATIC) + #define CC_LIBSIM_DLL + #else + #if defined(_USRLIBSIMDLL) + #define CC_LIBSIM_DLL __declspec(dllexport) + #else /* use a DLL library */ + #define CC_LIBSIM_DLL __declspec(dllimport) + #endif + #endif + + /* Define NULL pointer value */ + #ifndef NULL + #ifdef __cplusplus + #define NULL 0 + #else + #define NULL ((void *)0) + #endif + #endif +#elif defined(_SHARED_) + #define CC_LIBSIM_DLL __attribute__((visibility("default"))) +#else + #define CC_LIBSIM_DLL +#endif diff --git a/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h b/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h index 3d0c13a9ac..d50b8fbb81 100644 --- a/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h +++ b/tools/simulator/libsimulator/lib/platform/win32/PlayerMenuServiceWin.h @@ -8,10 +8,11 @@ #include "cocos2d.h" #include "stdafx.h" #include "PlayerMenuServiceProtocol.h" +#include "SimulatorExport.h" PLAYER_NS_BEGIN -class PlayerMenuItemWin : public PlayerMenuItem +class CC_LIBSIM_DLL PlayerMenuItemWin : public PlayerMenuItem { public: static PlayerMenuItemWin *create(const std::string &menuId, const std::string &title); @@ -34,7 +35,7 @@ protected: friend class PlayerMenuServiceWin; }; -class PlayerMenuServiceWin : public PlayerMenuServiceProtocol +class CC_LIBSIM_DLL PlayerMenuServiceWin : public PlayerMenuServiceProtocol { public: PlayerMenuServiceWin(HWND hwnd); diff --git a/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h b/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h index ab934147ba..58a06b9dd6 100644 --- a/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h +++ b/tools/simulator/libsimulator/lib/platform/win32/PlayerWin.h @@ -9,10 +9,11 @@ #include "PlayerFileDialogServiceWin.h" #include "PlayerEditBoxServiceWin.h" #include "PlayerTaskServiceWin.h" +#include "SimulatorExport.h" PLAYER_NS_BEGIN -class PlayerWin : public PlayerProtocol, public cocos2d::Ref +class CC_LIBSIM_DLL PlayerWin : public PlayerProtocol, public cocos2d::Ref { public: static PlayerWin *createWithHwnd(HWND hWnd); diff --git a/tools/simulator/libsimulator/lib/runtime/ConfigParser.h b/tools/simulator/libsimulator/lib/runtime/ConfigParser.h index 20ad87649f..cbddf3ac94 100644 --- a/tools/simulator/libsimulator/lib/runtime/ConfigParser.h +++ b/tools/simulator/libsimulator/lib/runtime/ConfigParser.h @@ -7,13 +7,15 @@ #include "json/document.h" #include "ProjectConfig/SimulatorConfig.h" #include "ProjectConfig/ProjectConfig.h" +#include "SimulatorExport.h" + using namespace std; USING_NS_CC; #define CONFIG_FILE "config.json" typedef vector ScreenSizeArray; -class ConfigParser +class CC_LIBSIM_DLL ConfigParser { public: static ConfigParser *getInstance(void); diff --git a/tools/simulator/libsimulator/lib/runtime/ConsoleCommand.cpp b/tools/simulator/libsimulator/lib/runtime/ConsoleCommand.cpp index 7ee8a1fde8..3798703eed 100644 --- a/tools/simulator/libsimulator/lib/runtime/ConsoleCommand.cpp +++ b/tools/simulator/libsimulator/lib/runtime/ConsoleCommand.cpp @@ -211,8 +211,10 @@ void ConsoleCommand::onSendCommand(int fd, const std::string &args) } else if(strcmp(strcmd.c_str(), "shutdownapp") == 0) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - extern void shutDownApp(); - shutDownApp(); +#include + auto glview = dynamic_cast (Director::getInstance()->getOpenGLView()); + HWND hWnd = glview->getWin32Window(); + ::SendMessage(hWnd, WM_CLOSE, NULL, NULL); #else exit(0); #endif diff --git a/tools/simulator/libsimulator/lib/runtime/FileServer.cpp b/tools/simulator/libsimulator/lib/runtime/FileServer.cpp index 0c037341b3..b450589d8b 100644 --- a/tools/simulator/libsimulator/lib/runtime/FileServer.cpp +++ b/tools/simulator/libsimulator/lib/runtime/FileServer.cpp @@ -257,7 +257,7 @@ _responseEndThread(false) _writePath = FileUtils::getInstance()->getWritablePath(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) - std::string getCurAppName(void); +#include "Widget_mac.h" _writePath += getCurAppName(); _writePath += "/"; #endif diff --git a/tools/simulator/libsimulator/lib/runtime/FileServer.h b/tools/simulator/libsimulator/lib/runtime/FileServer.h index 026c068f8f..655c9b19b7 100644 --- a/tools/simulator/libsimulator/lib/runtime/FileServer.h +++ b/tools/simulator/libsimulator/lib/runtime/FileServer.h @@ -32,6 +32,7 @@ THE SOFTWARE. #include "json/writer.h" #include "Protos.pb.h" #include +#include "SimulatorExport.h" // header files for socket #ifdef _WIN32 @@ -53,7 +54,7 @@ THE SOFTWARE. #include #endif -class FileServer +class CC_LIBSIM_DLL FileServer { static FileServer *s_sharedFileServer; public: diff --git a/tools/simulator/libsimulator/lib/runtime/Runtime.cpp b/tools/simulator/libsimulator/lib/runtime/Runtime.cpp index bfff76b9f7..427e12bfdc 100644 --- a/tools/simulator/libsimulator/lib/runtime/Runtime.cpp +++ b/tools/simulator/libsimulator/lib/runtime/Runtime.cpp @@ -190,10 +190,28 @@ void RuntimeEngine::setProjectPath(const std::string &workPath) if (workPath.empty()) { - extern std::string getCurAppPath(); - std::string appPath = getCurAppPath(); + std::string appPath = std::string(""); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - appPath.append("/../../"); + TCHAR szAppDir[MAX_PATH] = { 0 }; + if (GetModuleFileName(NULL, szAppDir, MAX_PATH)) + { + int nEnd = 0; + for (int i = 0; szAppDir[i]; i++) + { + if (szAppDir[i] == '\\') + nEnd = i; + } + szAppDir[nEnd] = 0; + int iLen = 2 * wcslen(szAppDir); + char* chRtn = new char[iLen + 1]; + wcstombs(chRtn, szAppDir, iLen + 1); + std::string strPath = chRtn; + delete[] chRtn; + chRtn = NULL; + char fuldir[MAX_PATH] = { 0 }; + _fullpath(fuldir, strPath.c_str(), MAX_PATH); + appPath = fuldir; + } #elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) appPath.append("/../../../"); #endif diff --git a/tools/simulator/libsimulator/lib/runtime/Runtime.h b/tools/simulator/libsimulator/lib/runtime/Runtime.h index d3e0a0822a..a2607fb1de 100644 --- a/tools/simulator/libsimulator/lib/runtime/Runtime.h +++ b/tools/simulator/libsimulator/lib/runtime/Runtime.h @@ -28,14 +28,17 @@ THE SOFTWARE. #include #include #include +#include "SimulatorExport.h" void recvBuf(int fd, char *pbuf, unsigned long bufsize); void sendBuf(int fd, const char *pbuf, unsigned long bufsize); -std::string& replaceAll(std::string& str, const std::string& old_value, const std::string& new_value); +CC_LIBSIM_DLL extern std::string g_projectPath; -std::string getIPAddress(); +CC_LIBSIM_DLL std::string& replaceAll(std::string& str, const std::string& old_value, const std::string& new_value); + +CC_LIBSIM_DLL std::string getIPAddress(); const char* getRuntimeVersion(); diff --git a/tools/simulator/libsimulator/lib/runtime/RuntimeProtocol.h b/tools/simulator/libsimulator/lib/runtime/RuntimeProtocol.h index fe5f1771ba..84b935591f 100644 --- a/tools/simulator/libsimulator/lib/runtime/RuntimeProtocol.h +++ b/tools/simulator/libsimulator/lib/runtime/RuntimeProtocol.h @@ -9,8 +9,9 @@ #include #include "json/document.h" +#include "SimulatorExport.h" -class RuntimeProtocol +class CC_LIBSIM_DLL RuntimeProtocol { public: virtual void end(); diff --git a/tools/simulator/libsimulator/lib/runtime/Widget_mac.h b/tools/simulator/libsimulator/lib/runtime/Widget_mac.h new file mode 100644 index 0000000000..79bd4e7542 --- /dev/null +++ b/tools/simulator/libsimulator/lib/runtime/Widget_mac.h @@ -0,0 +1,12 @@ +// +// Widget_mac.h +// Simulator +// +// + +#ifndef libsimulator_studio_Widget_mac_h +#define libsimulator_studio_Widget_mac_h + +std::string getCurAppName(void); + +#endif diff --git a/tools/simulator/libsimulator/lib/runtime/Widget_mac.mm b/tools/simulator/libsimulator/lib/runtime/Widget_mac.mm new file mode 100644 index 0000000000..49e73074fd --- /dev/null +++ b/tools/simulator/libsimulator/lib/runtime/Widget_mac.mm @@ -0,0 +1,20 @@ +// +// Widget_mac.cpp +// Simulator +// +// + +#include +#include "Widget_mac.h" + +using namespace std; + +std::string getCurAppName(void) +{ + string appName = [[[NSProcessInfo processInfo] processName] UTF8String]; + size_t found = appName.find(" "); + if (found!=std::string::npos) + appName = appName.substr(0,found); + + return appName; +} diff --git a/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj b/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj index fe88156831..2163b5ba7b 100644 --- a/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj +++ b/tools/simulator/libsimulator/proj.win32/libsimulator.vcxproj @@ -60,7 +60,7 @@ NotUsing Level3 Disabled - WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions);_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS + WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;%(PreprocessorDefinitions);_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;_USRLIBSIMSTATIC $(ProjectDir);$(ProjectDir)..\lib\protobuf-lite;$(ProjectDir)..\lib;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) @@ -84,7 +84,7 @@ MinSpace true true - COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions);_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS + COCOS2D_DEBUG=1;WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;GLFW_EXPOSE_NATIVE_WIN32;GLFW_EXPOSE_NATIVE_WGL;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) true $(ProjectDir);$(ProjectDir)..\lib\protobuf-lite;$(ProjectDir)..\lib;$(EngineRoot)external\win32-specific\zlib\include;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\lua\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\curl\include\win32;$(EngineRoot)extensions;$(EngineRoot);%(AdditionalIncludeDirectories) CompileAsCpp