diff --git a/.travis.yml b/.travis.yml index 1e67e468bf..762cbcbf06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,8 @@ language: cpp env: matrix: - GEN_JSB=YES - - PLATFORM=linux DEBUG=1 + - PLATFORM=linux DEBUG=1 CC_COMPILER=gcc CXX_COMPILER=g++ + - PLATFORM=linux DEBUG=1 CC_COMPILER=clang CXX_COMPILER=clang++ # Since switching to C++11 only the ARM version of the nactive client # port currently builds. TODO(sbc): Re-enable all architectures. # Disabled travis-ci build for native client port since it doesn't support std::thread, std::mutex. @@ -23,6 +24,8 @@ env: 9lV+vgJQDRcFe7dKwtC86vk10EU7Ym2bhVmhMxi/AlmJXgavjmPVdizRT7rh X2Ry/Nb6hGRkH3WS0T3D/KG1+e7lP/TMB9bvo6/locLJ2A6Z1YI= script: +- export CC=$CC_COMPILER +- export CXX=$CXX_COMPILER - tools/travis-scripts/run-script.sh before_install: - tools/travis-scripts/before-install.sh diff --git a/AUTHORS b/AUTHORS index 4281304da3..27723850a3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -356,6 +356,7 @@ Developers: ThePickleMan Adding 'rotationIsDir' property to ParticleSystem. + DrawNode supports to draw triangle, quad bezier, cubic bezier. Jianghua (jxhgzs) Adding an additional transform for CCNode. @@ -402,6 +403,7 @@ Developers: Zecken (gelldur) Fixing a profiling compilation error in CCParticleBatchNode. Fixing linking errors for TestCPP with libcurl on linux. + Fixing a bug that crash was triggered if there is not `textureFileName`section in particle plist file. flamingo (flaming0) Null pointer check in order to prevent crashes. @@ -518,6 +520,7 @@ Developers: Correcting the type detecting order for Lua CCBProxy::getNodeTypeName. Casting variables to their own type, and print warning info if no corresponding lua callback function instead of crash. fix of WebSocket url parse error for 'ws://domain.com/websocket' pattern. + Fixed a bug that Websocket doesn't support send/receive data which larger than 4096 bytes. musikov Fixing a bug that missing precision when getting strokeColor and fontFillColor @@ -656,6 +659,7 @@ Developers: xhcnb Device::setAccelerometerEnabled needs to be invoked before adding ACC listener. + Fixed a bug that it will get wrong custom properties when use different count custom properties in CocosBuilder. bopohaa Fixed a bug that Webp test crashes. @@ -668,6 +672,7 @@ Developers: zhiqiangxu Fixed a logic error in ControlUtils::RectUnion. + Fixed an issue that there is an useless conversion in ScrollView::onTouchBegan. yinkaile (2youyouo2) Maintainer of Armature Bone Animation. @@ -688,6 +693,31 @@ Developers: SBKarr AngelCode binary file format support for LabelBMFont. + zarelaky + OpenAL context isn't destroyed correctly on mac and ios. + + kicktheken (Kenneth Chan) + Fixed a bug that the setBlendFunc method of some classes wasn't exposed to LUA. + + andyque + Fixed a bug that missing to check self assignment of Vector, Map, Value and String. + Fixed a bug that move assignment operator doesn't clear previous content bug. + Fixed the compile error of Map's getRandomObject. + + daltomi + Fixed a typo in Director class. + Removed an unnecessary boolean flag in CCFontAtlasCache.cpp. + + v1ctor + ControlSlider supports to set selected thumb sprite. + ControlButton supports to set scale ratio of touchdown state + + akof1314 + TestCpp works by using CMake and mingw on Windows. + + Pisces000221 + Corrected a few mistakes in the README file of project-creator. + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, diff --git a/CHANGELOG b/CHANGELOG index a15a536827..a16751e56c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,14 +1,32 @@ -cocos2d-x-3.0beta0 ?? 2013 +cocos2d-x-3.0final ?.? ? [All] + [FIX] Crash was triggered if there is not `textureFileName`section in particle plist file. + [FIX] ControlSlider doesn't support to set selected thumb sprite. + [FIX] ControlButton doesn't support to set scale ratio of touchdown state. + [FIX] Websocket doesn't support send/receive data which larger than 4096 bytes. + [NEW] DrawNode supports to draw triangle, quad bezier, cubic bezier. + [FIX] TestCpp works by using CMake on Windows. +cocos2d-x-3.0beta Jan.7 2014 +[All] + [NEW] New label: shadow, outline, glow support + [NEW] AngelCode binary file format support for LabelBMFont + [NEW] New spine runtime support + [NEW] Add templated containers, such as `cocos2d::Map<>` and `cocos2d::Vector<>` + [NEW] TextureCache::addImageAsync() uses std::function<> as call back + [NEW] Namespace changed: network -> cocos2d::network, gui -> cocos2d::gui + [NEW] Added more CocoStudioSceneTest samples. + [NEW] Added UnitTest for Vector, Map, Value. + [NEW] AngelCode binary file format support for LabelBMFont. + [NEW] New renderer: Scene graph and Renderer are decoupled now. [NEW] Upgrated Box2D to 2.3.0 [NEW] SChedule::performFunctionInCocosThread() [NEW] Added tga format support again. + [NEW] Adds UnitTest for Template container and Value class [FIX] A Logic error in ControlUtils::RectUnion. [FIX] Bug fixes for Armature, use Vector, Map instead of Array, Dictionary. [FIX] Used c++11 range loop(highest performance) instead of other types of loop. [FIX] Removed most hungarian notations. [FIX] Merged NodeRGBA to Node. - [NEW] New renderer support. [FIX] Potential hash collision fix. [FIX] Updates spine runtime to the latest version. [FIX] Uses `const std::string&` instead of `const char*`. @@ -17,20 +35,49 @@ cocos2d-x-3.0beta0 ?? 2013 [FIX] GUI refactoring: Removes UI prefix, Widget is inherited from Node, uses new containers(Vector, Map). [FIX] String itself is also modified in `String::componentsSeparatedByString`. [FIX] Sprites with PhysicsBody move to a wrong position when game resume from background. - [FIX] Crash if connection breaks during download using AssetManager. - [NEW] AngelCode binary file format support for LabelBMFont. + [FIX] Crash if connection breaks during download using AssetManager. + [FIX] OpenAL context isn't destroyed correctly on mac and ios. + [FIX] Useless conversion in ScrollView::onTouchBegan. + [FIX] Two memory leak fixes in EventDispatcher::removeEventListener(s). + [FIX] CCTMXMap doesn't support TMX files reference external TSX files + [FIX] Logical error in `CallFuncN::clone()` + [FIX] Child's opacity will not be changed when its parent's cascadeOpacityEnabled was set to true and opacity was changed + [FIX] Disallow copy and assign for Scene Graph + Actions objects + [FIX] XMLHttpRequest receives wrong binary array + [FIX] XMLHttpRequest.status needs to be assigned even when connection fails + [FIX] TextureCache::addImageAsync may load a image even it is loaded in GL thread + [FIX] EventCustom shouldn't use std::hash to generate unique ID, because the result is not unique + [FIX] CC_USE_PHYSICS is actually impossible to turn it off + [FIX] Crash if connection breaks during download using AssetManager + [FIX] Project_creator supports creating project at any folder and supports UI [Android] [NEW] build/android-build.sh: add supporting to generate .apk file - [FIX] XMLHttpRequest receives wrong binary array. [NEW] Bindings-generator supports to bind 'unsigned long'. + [FIX] XMLHttpRequest receives wrong binary array. [FIX] 'Test Frame Event' of TestJavascript/CocoStudioArmatureTest Crashes. [FIX] UserDefault::getDoubleForKey() doesn't pass default value to Java. +[iOS] + [FIX] Infinite loop in UserDefault's destructor [Windows] [NEW] CMake support for windows. [Bindings] - [FIX] Don't bind override functions for JSB and LuaBining since they aren't needed at all. + [NEW] Support CocoStudio v1.2 [NEW] Adds spine JS binding support. + [FIX] Don't bind override functions for JSB and LuaBining since they aren't needed at all. [FIX] The order of onEnter and onExit is wrong. + [FIX] The setBlendFunc method of some classes wasn't exposed to LUA. + [FIX] Bindings-generator doesn't support 'unsigned long' + [FIX] Potential hash collision by using typeid(T).hash_code() in JSB and LuaBinding +[Lua binding] + [NEW] New label support + [NEW] Physcis integrated support + [NEW] EventDispatcher support + [FIX] CallFuncND + auto remove lua test case have no effect + [FIX] Lua gc will cause correcsponding c++ object been released + [FIX] Some lua manual binding functions don't remove unneeded element in the lua stack + [FIX] The setBlendFunc method of some classes wasn't exposed to LUA +[Javascript binding] + [FIX] `onEnter` event is triggered after children's `onEnter` event cocos2d-x-3.0alpha1 Nov.19 2013 [all platforms] diff --git a/CMakeLists.txt b/CMakeLists.txt index 55d599f781..a5486c2b41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,15 +38,15 @@ option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) option(DEBUG_MODE "Debug or release?" ON) option(BUILD_LIBS_LUA "Build lua libraries" OFF) -option(BUILD_GUI "Build GUI library" OFF) -option(BUILD_NETWORK "Build network library" OFF) -option(BUILD_EXTENSIONS "Build extension library" OFF) -option(BUILD_EDITOR_SPINE "Build editor support for spine" OFF) -option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" OFF) -option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" OFF) +option(BUILD_GUI "Build GUI library" ON) +option(BUILD_NETWORK "Build network library" ON) +option(BUILD_EXTENSIONS "Build extension library" ON) +option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) +option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) +option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) option(BUILD_HelloCpp "Only build HelloCpp sample" ON) -option(BUILD_TestCpp "Only build TestCpp sample" OFF) +option(BUILD_TestCpp "Only build TestCpp sample" ON) option(BUILD_HelloLua "Only build HelloLua sample" OFF) option(BUILD_TestLua "Only build TestLua sample" OFF) @@ -284,4 +284,19 @@ add_subdirectory(cocos/scripting) endif(BUILD_LIBS_LUA) # build samples -add_subdirectory(samples) +if(BUILD_HelloCpp) +add_subdirectory(samples/Cpp/HelloCpp) +endif(BUILD_HelloCpp) + +if(BUILD_TestCpp) +add_subdirectory(samples/Cpp/TestCpp) +endif(BUILD_TestCpp) + +if(BUILD_HelloLua) +add_subdirectory(samples/Lua/HelloLua) +endif(BUILD_HelloLua) + +if(BUILD_TestLua) +add_subdirectory(samples/Lua/TestLua) +endif(BUILD_TestLua) + diff --git a/README.md b/README.md index c5d464e62f..ea9fa791ca 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,47 @@ How to start a new game 1. Download the code from [cocos2d download site][4] 2. Enter `tools/project-creator` - -2. Run the `create-projects.py` script +3. Run the `create-projects.py` script Example: $ cd cocos2d-x/tools/project-creator - $ ./create-multi-platform-projects.py -p mygame -k com.your_company.mygame -l cpp - $ cd ../../projects/mygame + $ ./project-creator.py -n mygame -k com.your_company.mygame -l cpp -p /home/mygame + $ cd /home/mygame + +### Build new project for android ### + + $ cd proj.android + $ ./build_native.py + +### Build new project for ios & osx ### + +* Enter *proj.ios_mac* folder, open *mygame.xcodeproj* +* Select ios or osx targets in scheme toolbar + +### Build new project for linux ### + +if you never run cocos2d-x on linux, you need to install all dependences by the +script in **cocos2d/build/install-deps-linux.sh** + + $ cd cocos2d/build + $ ./install-deps-linux.sh + $ ../.. + +Then + + $ mkdir build + $ cd build + $ cmake .. + $ make -j4 + +Run + + $ bin/mygame + +### Build new project for win32 ### + +* Enter *proj.win32*, open *mygame.sln* by vs2012 Main features @@ -57,7 +90,7 @@ Main features * Motion Streak * Render To Texture * Touch/Accelerometer on mobile devices - * Touch/Mouse/Keyboard on desktop + * Touch/Mouse/Keyboard on desktop * Sound Engine support (CocosDenshion library) based on OpenAL * Integrated Slow motion/Fast forward * Fast and compressed textures: PVR compressed and uncompressed textures, ETC1 compressed textures, and more @@ -103,8 +136,16 @@ $ cmake .. $ make ``` - You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, - you should make it to direct to a correct one. `install-deps-linux.sh` only has to be run onece. +Run Samples + +``` +$ bin/hellocpp/hellocpp +or +$ bin/testlua/testlua +``` + + You may meet building errors when building libGLFW.so. It is because libGL.so directs to an error target, + you should make it to direct to a correct one. `install-deps-linux.sh` only has to be run once. * For Windows diff --git a/build/cocos2d-win32.vc2012.sln b/build/cocos2d-win32.vc2012.sln index 28792555a1..3593a117d8 100644 --- a/build/cocos2d-win32.vc2012.sln +++ b/build/cocos2d-win32.vc2012.sln @@ -65,6 +65,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForLocalStorage EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForGui", "..\cocos\scripting\javascript\bindings\gui\libJSBindingForGui.vcxproj", "{9A844C88-97E8-4E2D-B09A-E138C67D338B}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForSpine", "..\cocos\scripting\javascript\bindings\spine\libJSBindingForSpine.vcxproj", "{E78CDC6B-F37D-48D2-AD91-1DB549497E32}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -195,6 +197,10 @@ Global {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Debug|Win32.Build.0 = Debug|Win32 {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Release|Win32.ActiveCfg = Release|Win32 {9A844C88-97E8-4E2D-B09A-E138C67D338B}.Release|Win32.Build.0 = Release|Win32 + {E78CDC6B-F37D-48D2-AD91-1DB549497E32}.Debug|Win32.ActiveCfg = Debug|Win32 + {E78CDC6B-F37D-48D2-AD91-1DB549497E32}.Debug|Win32.Build.0 = Debug|Win32 + {E78CDC6B-F37D-48D2-AD91-1DB549497E32}.Release|Win32.ActiveCfg = Release|Win32 + {E78CDC6B-F37D-48D2-AD91-1DB549497E32}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -208,6 +214,7 @@ Global {21070E58-EEC6-4E16-8B4F-6D083DF55790} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} {9A844C88-97E8-4E2D-B09A-E138C67D338B} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} + {E78CDC6B-F37D-48D2-AD91-1DB549497E32} = {10F98A57-B9A1-47DA-9FBA-12D328E72ED1} EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index a237fdc780..faa1e4571d 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -812ab716d10a52b752f0d15b2393b2b0a7c8e969 \ No newline at end of file +3d6ada05d55194dd8e4c10ed8316add7c0d8705c \ No newline at end of file diff --git a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id index 2d497c5e0b..0f53b948c7 100644 --- a/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -b83c3a0fd60d6b1b1a032495615afd77fccd5050 \ No newline at end of file +2efefc01ff97bda1498d1d4a850ea1881f751f7c \ No newline at end of file diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index 4905f4d613..303a1da40f 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -205,7 +205,6 @@ LOCAL_EXPORT_LDLIBS := -lGLESv2 \ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_freetype2_static LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static -LOCAL_WHOLE_STATIC_LIBRARIES += spine_static # define the macro to compile through support/zip_support/ioapi.c LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API @@ -218,4 +217,3 @@ include $(BUILD_STATIC_LIBRARY) $(call import-module,freetype2/prebuilt/android) $(call import-module,chipmunk) $(call import-module,2d/platform/android) -$(call import-module,editor-support/spine) diff --git a/cocos/2d/CCAction.cpp b/cocos/2d/CCAction.cpp index 3556b6e413..0ae3428605 100644 --- a/cocos/2d/CCAction.cpp +++ b/cocos/2d/CCAction.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. - +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCAction.h b/cocos/2d/CCAction.h index 1d76c43b17..dc5926fb0c 100644 --- a/cocos/2d/CCAction.h +++ b/cocos/2d/CCAction.h @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. - +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCActionCamera.cpp b/cocos/2d/CCActionCamera.cpp index 0d8ef23606..45560f7ede 100644 --- a/cocos/2d/CCActionCamera.cpp +++ b/cocos/2d/CCActionCamera.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -32,6 +33,12 @@ NS_CC_BEGIN // // CameraAction // +ActionCamera::ActionCamera() +{ + kmVec3Fill(&_center, 0, 0, 0); + kmVec3Fill(&_eye, 0, 0, FLT_EPSILON); + kmVec3Fill(&_up, 0, 1, 0); +} void ActionCamera::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); @@ -53,53 +60,39 @@ ActionCamera * ActionCamera::reverse() const void ActionCamera::restore() { - _eyeX = _eyeY = 0.0f; - _eyeZ = FLT_EPSILON; + kmVec3Fill(&_center, 0, 0, 0); + kmVec3Fill(&_eye, 0, 0, FLT_EPSILON); + kmVec3Fill(&_up, 0, 1, 0); +} - _centerX = _centerY = _centerZ = 0.0f; - - _upX = 0.0f; - _upY = 1.0f; - _upZ = 0.0f; +void ActionCamera::setEye(const kmVec3& eye) +{ + _eye = eye; + updateTransform(); } void ActionCamera::setEye(float x, float y, float z) { - _eyeX = x; - _eyeY = y; - _eyeZ = z; - + kmVec3Fill(&_eye, x, y, z); updateTransform(); } -void ActionCamera::setCenter(float centerX, float centerY, float centerZ) +void ActionCamera::setCenter(const kmVec3& center) { - _centerX = centerX; - _centerY = centerY; - _centerZ = centerZ; - + _center = center; updateTransform(); } -void ActionCamera::setUp(float upX, float upY, float upZ) +void ActionCamera::setUp(const kmVec3& up) { - _upX = upX; - _upY = upY; - _upZ = upZ; - + _up = up; updateTransform(); } void ActionCamera::updateTransform() { - kmVec3 eye, center, up; - - kmVec3Fill(&eye, _eyeX, _eyeY , _eyeZ); - kmVec3Fill(¢er, _centerX, _centerY, _centerZ); - kmVec3Fill(&up, _upX, _upY, _upZ); - kmMat4 lookupMatrix; - kmMat4LookAt(&lookupMatrix, &eye, ¢er, &up); + kmMat4LookAt(&lookupMatrix, &_eye, &_center, &_up); Point anchorPoint = _target->getAnchorPointInPoints(); @@ -198,9 +191,9 @@ void OrbitCamera::update(float dt) float za = _radZ + _radDeltaZ * dt; float xa = _radX + _radDeltaX * dt; - float i = sinf(za) * cosf(xa) * r + _centerX; - float j = sinf(za) * sinf(xa) * r + _centerY; - float k = cosf(za) * r + _centerZ; + float i = sinf(za) * cosf(xa) * r + _center.x; + float j = sinf(za) * sinf(xa) * r + _center.y; + float k = cosf(za) * r + _center.z; setEye(i,j,k); } @@ -210,9 +203,9 @@ void OrbitCamera::sphericalRadius(float *newRadius, float *zenith, float *azimut float r; // radius float s; - float x = _eyeX - _centerX; - float y = _eyeY - _centerY; - float z = _eyeZ - _centerZ; + float x = _eye.x - _center.x; + float y = _eye.y - _center.y; + float z = _eye.z - _center.z; r = sqrtf( powf(x,2) + powf(y,2) + powf(z,2)); s = sqrtf( powf(x,2) + powf(y,2)); diff --git a/cocos/2d/CCActionCamera.h b/cocos/2d/CCActionCamera.h index c4cab0c0a1..2c42590080 100644 --- a/cocos/2d/CCActionCamera.h +++ b/cocos/2d/CCActionCamera.h @@ -1,7 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy @@ -48,17 +50,7 @@ public: /** * @js ctor */ - ActionCamera() - :_centerX(0) - ,_centerY(0) - ,_centerZ(0) - ,_eyeX(0) - ,_eyeY(0) - ,_eyeZ(FLT_EPSILON) - ,_upX(0) - ,_upY(1) - ,_upZ(0) - {} + ActionCamera(); /** * @js NA * @lua NA @@ -70,23 +62,28 @@ public: virtual ActionCamera * reverse() const override; virtual ActionCamera *clone() const override; + /* sets the Eye value of the Camera */ + void setEye(const kmVec3 &eye); + void setEye(float x, float y, float z); + /* returns the Eye value of the Camera */ + const kmVec3& getEye() const { return _eye; } + /* sets the Center value of the Camera */ + void setCenter(const kmVec3 ¢er); + /* returns the Center value of the Camera */ + const kmVec3& getCenter() const { return _center; } + /* sets the Up value of the Camera */ + void setUp(const kmVec3 &up); + /* Returns the Up value of the Camera */ + const kmVec3& getUp() const { return _up; } + protected: void restore(); - void setEye(float x, float y, float z); - void setCenter(float x, float y, float z); - void setUp(float x, float y, float z); void updateTransform(); - float _centerX; - float _centerY; - float _centerZ; - float _eyeX; - float _eyeY; - float _eyeZ; - float _upX; - float _upY; - float _upZ; + kmVec3 _center; + kmVec3 _eye; + kmVec3 _up; }; /** diff --git a/cocos/2d/CCActionCatmullRom.cpp b/cocos/2d/CCActionCatmullRom.cpp index 0437eb90bf..1dcb626c73 100644 --- a/cocos/2d/CCActionCatmullRom.cpp +++ b/cocos/2d/CCActionCatmullRom.cpp @@ -1,11 +1,8 @@ /* - * Copyright (c) 2010-2012 cocos2d-x.org - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * * Copyright (c) 2008 Radu Gruian - * * Copyright (c) 2011 Vit Valentin - * + * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -134,7 +131,7 @@ void PointArray::insertControlPoint(Point &controlPoint, ssize_t index) Point PointArray::getControlPointAtIndex(ssize_t index) { - index = static_cast(MIN(_controlPoints->size()-1, MAX(index, 0))); + index = MIN(_controlPoints->size()-1, MAX(index, 0)); return *(_controlPoints->at(index)); } diff --git a/cocos/2d/CCActionCatmullRom.h b/cocos/2d/CCActionCatmullRom.h index 0c47a4137f..6ecad0c6af 100644 --- a/cocos/2d/CCActionCatmullRom.h +++ b/cocos/2d/CCActionCatmullRom.h @@ -1,10 +1,8 @@ /* - * Copyright (c) 2012 cocos2d-x.org - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * * Copyright (c) 2008 Radu Gruian - * * Copyright (c) 2011 Vit Valentin + * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCActionEase.cpp b/cocos/2d/CCActionEase.cpp index 8c7d4e38e0..2aec96013b 100644 --- a/cocos/2d/CCActionEase.cpp +++ b/cocos/2d/CCActionEase.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2009 Jason Booth +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. -http://www.cocos2d-x.org + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/cocos/2d/CCActionEase.h b/cocos/2d/CCActionEase.h index efe0c9600c..17f55abf57 100644 --- a/cocos/2d/CCActionEase.h +++ b/cocos/2d/CCActionEase.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2009 Jason Booth +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionGrid.cpp b/cocos/2d/CCActionGrid.cpp index edd96ae0da..c1aa872d06 100644 --- a/cocos/2d/CCActionGrid.cpp +++ b/cocos/2d/CCActionGrid.cpp @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2009 On-Core Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2009 On-Core - +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCActionGrid.h b/cocos/2d/CCActionGrid.h index b3981b42a8..25344eefd4 100644 --- a/cocos/2d/CCActionGrid.h +++ b/cocos/2d/CCActionGrid.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionGrid3D.cpp b/cocos/2d/CCActionGrid3D.cpp index 2f88cd6684..9cc6194e5d 100644 --- a/cocos/2d/CCActionGrid3D.cpp +++ b/cocos/2d/CCActionGrid3D.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionGrid3D.h b/cocos/2d/CCActionGrid3D.h index fbc82f4819..52311b6674 100644 --- a/cocos/2d/CCActionGrid3D.h +++ b/cocos/2d/CCActionGrid3D.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionInstant.cpp b/cocos/2d/CCActionInstant.cpp index 92e5a5dfdf..f0280d1380 100644 --- a/cocos/2d/CCActionInstant.cpp +++ b/cocos/2d/CCActionInstant.cpp @@ -1,7 +1,8 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011 Zynga Inc. + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionInstant.h b/cocos/2d/CCActionInstant.h index f518899374..11fce3aaae 100644 --- a/cocos/2d/CCActionInstant.h +++ b/cocos/2d/CCActionInstant.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2011 Zynga Inc. + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionInterval.cpp b/cocos/2d/CCActionInterval.cpp index 7d4a1e0bbb..a8a48f4081 100644 --- a/cocos/2d/CCActionInterval.cpp +++ b/cocos/2d/CCActionInterval.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2011 Zynga Inc. +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionInterval.h b/cocos/2d/CCActionInterval.h index 8fcfcda025..e88331d309 100644 --- a/cocos/2d/CCActionInterval.h +++ b/cocos/2d/CCActionInterval.h @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2011 Zynga Inc. Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2011 Ricardo Quesada -Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionManager.cpp b/cocos/2d/CCActionManager.cpp index 56841d7f71..3865280806 100644 --- a/cocos/2d/CCActionManager.cpp +++ b/cocos/2d/CCActionManager.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionManager.h b/cocos/2d/CCActionManager.h index 406fadaeb9..0a096f1421 100644 --- a/cocos/2d/CCActionManager.h +++ b/cocos/2d/CCActionManager.h @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionPageTurn3D.cpp b/cocos/2d/CCActionPageTurn3D.cpp index 1da881614d..f6691c77d1 100644 --- a/cocos/2d/CCActionPageTurn3D.cpp +++ b/cocos/2d/CCActionPageTurn3D.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ +Copyright (c) 2010-2012 cocos2d-x.org +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionPageTurn3D.h b/cocos/2d/CCActionPageTurn3D.h index 24b8863b3f..92bf724653 100644 --- a/cocos/2d/CCActionPageTurn3D.h +++ b/cocos/2d/CCActionPageTurn3D.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ - +Copyright (c) 2010-2012 cocos2d-x.org +CopyRight (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCActionProgressTimer.cpp b/cocos/2d/CCActionProgressTimer.cpp index e5fa319875..46d3cca5e8 100644 --- a/cocos/2d/CCActionProgressTimer.cpp +++ b/cocos/2d/CCActionProgressTimer.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (C) 2010 Lam Pham +Copyright (c) 2010-2012 cocos2d-x.org +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionProgressTimer.h b/cocos/2d/CCActionProgressTimer.h index bdb8ab03f9..9314d3b8db 100644 --- a/cocos/2d/CCActionProgressTimer.h +++ b/cocos/2d/CCActionProgressTimer.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (C) 2010 Lam Pham - +Copyright (c) 2010-2012 cocos2d-x.org +CopyRight (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCActionTiledGrid.cpp b/cocos/2d/CCActionTiledGrid.cpp index 973634ace8..87b227b058 100644 --- a/cocos/2d/CCActionTiledGrid.cpp +++ b/cocos/2d/CCActionTiledGrid.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 20102011 cocos2d-x.org -Copyright (c) 2009 On-Core +Copyright (c) 2009 On-Core +Copyright (c) 2010-2012 cocos2d-x.org +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionTiledGrid.h b/cocos/2d/CCActionTiledGrid.h index a12e65fb4e..35ab948faa 100644 --- a/cocos/2d/CCActionTiledGrid.h +++ b/cocos/2d/CCActionTiledGrid.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core +Copyright (c) 2010-2012 cocos2d-x.org +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCActionTween.cpp b/cocos/2d/CCActionTween.cpp index a54f562713..46a4836d68 100644 --- a/cocos/2d/CCActionTween.cpp +++ b/cocos/2d/CCActionTween.cpp @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2009 lhunath (Maarten Billemont) Copyright (c) 2010-2012 cocos2d-x.org -Copyright 2009 lhunath (Maarten Billemont) - +CopyRight (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCActionTween.h b/cocos/2d/CCActionTween.h index b5c1553f31..e4681a9037 100644 --- a/cocos/2d/CCActionTween.h +++ b/cocos/2d/CCActionTween.h @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2009 lhunath (Maarten Billemont) Copyright (c) 2010-2012 cocos2d-x.org -Copyright 2009 lhunath (Maarten Billemont) - +CopyRight (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCAnimation.cpp b/cocos/2d/CCAnimation.cpp index e79db07267..20c965a648 100644 --- a/cocos/2d/CCAnimation.cpp +++ b/cocos/2d/CCAnimation.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. - +CopyRight (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCAnimation.h b/cocos/2d/CCAnimation.h index 9dddeb6fcc..04f0fa1997 100644 --- a/cocos/2d/CCAnimation.h +++ b/cocos/2d/CCAnimation.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCAnimationCache.cpp b/cocos/2d/CCAnimationCache.cpp index 59d9144252..d16a92e8a5 100644 --- a/cocos/2d/CCAnimationCache.cpp +++ b/cocos/2d/CCAnimationCache.cpp @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -187,7 +188,7 @@ void AnimationCache::parseVersion2(const ValueMap& animations) } } -void AnimationCache::addAnimationsWithDictionary(const ValueMap& dictionary) +void AnimationCache::addAnimationsWithDictionary(const ValueMap& dictionary,const std::string& plist) { if ( dictionary.find("animations") == dictionary.end() ) { @@ -205,7 +206,8 @@ void AnimationCache::addAnimationsWithDictionary(const ValueMap& dictionary) const ValueVector& spritesheets = properties.at("spritesheets").asValueVector(); for(const auto &value : spritesheets) { - SpriteFrameCache::getInstance()->addSpriteFramesWithFile(value.asString()); + std::string path = FileUtils::getInstance()->fullPathFromRelativeFile(value.asString(),plist); + SpriteFrameCache::getInstance()->addSpriteFramesWithFile(path); } } @@ -231,7 +233,7 @@ void AnimationCache::addAnimationsWithFile(const std::string& plist) CCASSERT( !dict.empty(), "CCAnimationCache: File could not be found"); - addAnimationsWithDictionary(dict); + addAnimationsWithDictionary(dict,plist); } diff --git a/cocos/2d/CCAnimationCache.h b/cocos/2d/CCAnimationCache.h index 6e60201882..f47ff4fd14 100644 --- a/cocos/2d/CCAnimationCache.h +++ b/cocos/2d/CCAnimationCache.h @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -102,9 +103,10 @@ public: /** Adds an animation from an NSDictionary Make sure that the frames were previously loaded in the SpriteFrameCache. + @param plist The path of the relative file,it use to find the plist path for load SpriteFrames. @since v1.1 */ - void addAnimationsWithDictionary(const ValueMap& dictionary); + void addAnimationsWithDictionary(const ValueMap& dictionary,const std::string& plist); /** Adds an animation from a plist file. Make sure that the frames were previously loaded in the SpriteFrameCache. diff --git a/cocos/2d/CCAtlasNode.cpp b/cocos/2d/CCAtlasNode.cpp index fc29683d90..5e88b70832 100644 --- a/cocos/2d/CCAtlasNode.cpp +++ b/cocos/2d/CCAtlasNode.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCAtlasNode.h b/cocos/2d/CCAtlasNode.h index 71d013a907..065ae77353 100644 --- a/cocos/2d/CCAtlasNode.h +++ b/cocos/2d/CCAtlasNode.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index d1f9c236e4..cdaf6a3df5 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -1,9 +1,9 @@ /* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * cocos2d-x: http://www.cocos2d-x.org + * Copyright (c) 2012 Pierre-David Bélanger + * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * - * Copyright (c) 2012 Pierre-David Bélanger - * Copyright (c) 2012 cocos2d-x.org + * cocos2d-x: 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 @@ -217,7 +217,24 @@ void ClippingNode::visit() _beforeVisitCmd.init(0,_vertexZ); _beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this); renderer->addCommand(&_beforeVisitCmd); + if (_alphaThreshold < 1) + { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) +#else + // since glAlphaTest do not exists in OES, use a shader that writes + // pixel only if greater than an alpha threshold + GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); + // set our alphaThreshold + program->use(); + program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); + // we need to recursively apply this shader to all the nodes in the stencil node + // XXX: we should have a way to apply shader to all nodes without having to do this + setProgram(_stencil, program); + +#endif + } _stencil->visit(); _afterDrawStencilCmd.init(0,_vertexZ); @@ -380,17 +397,7 @@ void ClippingNode::onBeforeVisit() // pixel will be drawn only if greater than an alpha threshold glAlphaFunc(GL_GREATER, _alphaThreshold); #else - // since glAlphaTest do not exists in OES, use a shader that writes - // pixel only if greater than an alpha threshold - GLProgram *program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); - GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); - // set our alphaThreshold - program->use(); - program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); - // we need to recursively apply this shader to all the nodes in the stencil node - // XXX: we should have a way to apply shader to all nodes without having to do this - setProgram(_stencil, program); - + #endif } diff --git a/cocos/2d/CCClippingNode.h b/cocos/2d/CCClippingNode.h index c18379f722..5f9e0caa12 100644 --- a/cocos/2d/CCClippingNode.h +++ b/cocos/2d/CCClippingNode.h @@ -1,9 +1,9 @@ /* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * cocos2d-x: http://www.cocos2d-x.org + * Copyright (c) 2012 Pierre-David Bélanger + * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * - * Copyright (c) 2012 Pierre-David Bélanger - * Copyright (c) 2012 cocos2d-x.org + * http://www.cocos2d-x.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/cocos/2d/CCComponent.cpp b/cocos/2d/CCComponent.cpp index 4f8482367a..1d5c83a8c7 100644 --- a/cocos/2d/CCComponent.cpp +++ b/cocos/2d/CCComponent.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -54,8 +54,9 @@ void Component::update(float delta) { } -void Component::serialize(void *ar) +bool Component::serialize(void *ar) { + return true; } Component* Component::create(void) diff --git a/cocos/2d/CCComponent.h b/cocos/2d/CCComponent.h index 5631c2585f..4d5625d71f 100644 --- a/cocos/2d/CCComponent.h +++ b/cocos/2d/CCComponent.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -55,7 +55,7 @@ public: */ virtual void onExit(); virtual void update(float delta); - virtual void serialize(void* r); + virtual bool serialize(void* r); virtual bool isEnabled() const; virtual void setEnabled(bool b); static Component* create(void); diff --git a/cocos/2d/CCComponentContainer.cpp b/cocos/2d/CCComponentContainer.cpp index 905bebbe27..9cd093deeb 100644 --- a/cocos/2d/CCComponentContainer.cpp +++ b/cocos/2d/CCComponentContainer.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCComponentContainer.h b/cocos/2d/CCComponentContainer.h index d895693a86..2e02a830e6 100644 --- a/cocos/2d/CCComponentContainer.h +++ b/cocos/2d/CCComponentContainer.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCConfiguration.cpp b/cocos/2d/CCConfiguration.cpp index 07ff02933d..47a079d415 100644 --- a/cocos/2d/CCConfiguration.cpp +++ b/cocos/2d/CCConfiguration.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCConfiguration.h b/cocos/2d/CCConfiguration.h index 90387d5c38..f2a7e1052c 100644 --- a/cocos/2d/CCConfiguration.h +++ b/cocos/2d/CCConfiguration.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCDeprecated.cpp b/cocos/2d/CCDeprecated.cpp index e26d0c964d..1c4aeffef4 100644 --- a/cocos/2d/CCDeprecated.cpp +++ b/cocos/2d/CCDeprecated.cpp @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCDeprecated.h b/cocos/2d/CCDeprecated.h index b2710848bf..05c1d618ee 100644 --- a/cocos/2d/CCDeprecated.h +++ b/cocos/2d/CCDeprecated.h @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -545,7 +546,8 @@ CC_DEPRECATED_ATTRIBUTE typedef IMEDelegate CCIMEDelegate; CC_DEPRECATED_ATTRIBUTE typedef IMEKeyboardNotificationInfo CCIMEKeyboardNotificationInfo; CC_DEPRECATED_ATTRIBUTE typedef TextFieldDelegate CCTextFieldDelegate; CC_DEPRECATED_ATTRIBUTE typedef TextFieldTTF CCTextFieldTTF; -CC_DEPRECATED_ATTRIBUTE typedef NotificationCenter CCNotificationCenter; +CC_DEPRECATED_ATTRIBUTE typedef __NotificationCenter CCNotificationCenter; +CC_DEPRECATED_ATTRIBUTE typedef __NotificationCenter NotificationCenter; //CC_DEPRECATED_ATTRIBUTE typedef TargetedTouchDelegate CCTargetedTouchDelegate; //CC_DEPRECATED_ATTRIBUTE typedef StandardTouchDelegate CCStandardTouchDelegate; //CC_DEPRECATED_ATTRIBUTE typedef TouchDelegate CCTouchDelegate; diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index b0ecc02c4a..d3c53b6f3e 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -37,7 +38,6 @@ THE SOFTWARE. #include "CCArray.h" #include "CCScheduler.h" #include "ccMacros.h" -#include "CCNotificationCenter.h" #include "CCTransition.h" #include "CCTextureCache.h" #include "CCSpriteFrameCache.h" @@ -61,6 +61,7 @@ THE SOFTWARE. #include "CCEventCustom.h" #include "CCFontFreeType.h" #include "CCRenderer.h" +#include "CCConsole.h" #include "renderer/CCFrustum.h" /** Position of the FPS @@ -116,9 +117,6 @@ bool Director::init(void) _scenesStack.reserve(15); - // projection delegate if "Custom" projection is used - _projectionDelegate = nullptr; - // FPS _accumDt = 0.0f; _frameRate = 0.0f; @@ -131,16 +129,16 @@ bool Director::init(void) // paused ? _paused = false; - - // purge ? - _purgeDirecotorInNextLoop = false; - _winSizeInPoints = Size::ZERO; + // purge ? + _purgeDirectorInNextLoop = false; + + _winSizeInPoints = Size::ZERO; _openGLView = nullptr; - + _cullingFrustum = new Frustum(); - + _contentScaleFactor = 1.0f; // scheduler @@ -163,15 +161,15 @@ bool Director::init(void) //init TextureCache initTextureCache(); - // Renderer _renderer = new Renderer; + _console = new Console; // create autorelease pool PoolManager::sharedPoolManager()->push(); return true; } - + Director::~Director(void) { CCLOGINFO("deallocing Director: %p", this); @@ -179,7 +177,7 @@ Director::~Director(void) CC_SAFE_RELEASE(_FPSLabel); CC_SAFE_RELEASE(_SPFLabel); CC_SAFE_RELEASE(_drawsLabel); - + CC_SAFE_RELEASE(_runningScene); CC_SAFE_RELEASE(_notificationNode); CC_SAFE_RELEASE(_scheduler); @@ -192,6 +190,7 @@ Director::~Director(void) delete _eventProjectionChanged; delete _renderer; + delete _console; // pop the autorelease pool PoolManager::sharedPoolManager()->pop(); @@ -284,17 +283,17 @@ void Director::drawScene() } kmGLPushMatrix(); - + //construct the frustum { kmMat4 view; kmMat4 projection; kmGLGetMatrix(KM_GL_PROJECTION, &projection); kmGLGetMatrix(KM_GL_MODELVIEW, &view); - + _cullingFrustum->setupFromMatrix(view, projection); } - + // draw the scene if (_runningScene) { @@ -307,7 +306,7 @@ void Director::drawScene() { _notificationNode->visit(); } - + if (_displayStats) { showStats(); @@ -325,7 +324,7 @@ void Director::drawScene() { _openGLView->swapBuffers(); } - + if (_displayStats) { calculateMPF(); @@ -386,16 +385,16 @@ void Director::setOpenGLView(EGLView *openGLView) // set size _winSizeInPoints = _openGLView->getDesignResolutionSize(); - + createStatsLabel(); - + if (_openGLView) { setGLDefaultValues(); - } - + } + _renderer->initGLView(); - + CHECK_GL_ERROR_DEBUG(); // _touchDispatcher->setDispatchEvents(true); @@ -481,13 +480,12 @@ void Director::setProjection(Projection projection) kmGLMultMatrix(&matrixLookup); break; } - + case Projection::CUSTOM: - if (_projectionDelegate) - _projectionDelegate->updateProjection(); - + // Projection Delegate is no longer needed + // since the event "PROJECTION CHANGED" is emitted break; - + default: CCLOG("cocos2d: Director: unrecognized projection"); break; @@ -549,10 +547,10 @@ static void GLToClipTransform(kmMat4 *transformOut) { kmMat4 projection; kmGLGetMatrix(KM_GL_PROJECTION, &projection); - + kmMat4 modelview; kmGLGetMatrix(KM_GL_MODELVIEW, &modelview); - + kmMat4Multiply(transformOut, &projection, &modelview); } @@ -560,19 +558,19 @@ Point Director::convertToGL(const Point& uiPoint) { kmMat4 transform; GLToClipTransform(&transform); - + kmMat4 transformInv; kmMat4Inverse(&transformInv, &transform); - + // Calculate z=0 using -> transform*[0, 0, 0, 1]/w kmScalar zClip = transform.mat[14]/transform.mat[15]; - + Size glSize = _openGLView->getDesignResolutionSize(); kmVec3 clipCoord = {2.0f*uiPoint.x/glSize.width - 1.0f, 1.0f - 2.0f*uiPoint.y/glSize.height, zClip}; - + kmVec3 glCoord; kmVec3TransformCoord(&glCoord, &clipCoord, &transformInv); - + return Point(glCoord.x, glCoord.y); } @@ -580,12 +578,12 @@ Point Director::convertToUI(const Point& glPoint) { kmMat4 transform; GLToClipTransform(&transform); - + kmVec3 clipCoord; // Need to calculate the zero depth from the transform. kmVec3 glCoord = {glPoint.x, glPoint.y, 0.0}; kmVec3TransformCoord(&clipCoord, &glCoord, &transform); - + Size glSize = _openGLView->getDesignResolutionSize(); return Point(glSize.width*(clipCoord.x*0.5 + 0.5), glSize.height*(-clipCoord.y*0.5 + 0.5)); } @@ -606,7 +604,7 @@ Size Director::getVisibleSize() const { return _openGLView->getVisibleSize(); } - else + else { return Size::ZERO; } @@ -618,7 +616,7 @@ Point Director::getVisibleOrigin() const { return _openGLView->getVisibleOrigin(); } - else + else { return Point::ZERO; } @@ -719,7 +717,7 @@ void Director::popToSceneStackLevel(int level) void Director::end() { - _purgeDirecotorInNextLoop = true; + _purgeDirectorInNextLoop = true; } void Director::purgeDirector() @@ -768,7 +766,6 @@ void Director::purgeDirector() // cocos2d-x specific data structures UserDefault::destroyInstance(); - NotificationCenter::destroyInstance(); GL::invalidateStateCache(); @@ -949,17 +946,20 @@ void Director::createStatsLabel() */ float factor = EGLView::getInstance()->getDesignResolutionSize().height / 320.0f; - _FPSLabel = new LabelAtlas; + _FPSLabel = LabelAtlas::create(); + _FPSLabel->retain(); _FPSLabel->setIgnoreContentScaleFactor(true); _FPSLabel->initWithString("00.0", texture, 12, 32 , '.'); _FPSLabel->setScale(factor); - _SPFLabel = new LabelAtlas; + _SPFLabel = LabelAtlas::create(); + _SPFLabel->retain(); _SPFLabel->setIgnoreContentScaleFactor(true); _SPFLabel->initWithString("0.000", texture, 12, 32, '.'); _SPFLabel->setScale(factor); - _drawsLabel = new LabelAtlas; + _drawsLabel = LabelAtlas::create(); + _drawsLabel->retain(); _drawsLabel->setIgnoreContentScaleFactor(true); _drawsLabel->initWithString("000", texture, 12, 32, '.'); _drawsLabel->setScale(factor); @@ -971,11 +971,6 @@ void Director::createStatsLabel() _FPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION); } -float Director::getContentScaleFactor() const -{ - return _contentScaleFactor; -} - void Director::setContentScaleFactor(float scaleFactor) { if (scaleFactor != _contentScaleFactor) @@ -985,11 +980,6 @@ void Director::setContentScaleFactor(float scaleFactor) } } -Node* Director::getNotificationNode() -{ - return _notificationNode; -} - void Director::setNotificationNode(Node *node) { CC_SAFE_RELEASE(_notificationNode); @@ -997,16 +987,6 @@ void Director::setNotificationNode(Node *node) CC_SAFE_RETAIN(_notificationNode); } -DirectorDelegate* Director::getDelegate() const -{ - return _projectionDelegate; -} - -void Director::setDelegate(DirectorDelegate* delegate) -{ - _projectionDelegate = delegate; -} - void Director::setScheduler(Scheduler* scheduler) { if (_scheduler != scheduler) @@ -1017,11 +997,6 @@ void Director::setScheduler(Scheduler* scheduler) } } -Scheduler* Director::getScheduler() const -{ - return _scheduler; -} - void Director::setActionManager(ActionManager* actionManager) { if (_actionManager != actionManager) @@ -1032,16 +1007,6 @@ void Director::setActionManager(ActionManager* actionManager) } } -ActionManager* Director::getActionManager() const -{ - return _actionManager; -} - -EventDispatcher* Director::getEventDispatcher() const -{ - return _eventDispatcher; -} - void Director::setEventDispatcher(EventDispatcher* dispatcher) { if (_eventDispatcher != dispatcher) @@ -1052,12 +1017,6 @@ void Director::setEventDispatcher(EventDispatcher* dispatcher) } } -Renderer* Director::getRenderer() const -{ - return _renderer; -} - - /*************************************************** * implementation of DisplayLinkDirector **************************************************/ @@ -1079,9 +1038,9 @@ void DisplayLinkDirector::startAnimation() void DisplayLinkDirector::mainLoop() { - if (_purgeDirecotorInNextLoop) + if (_purgeDirectorInNextLoop) { - _purgeDirecotorInNextLoop = false; + _purgeDirectorInNextLoop = false; purgeDirector(); } else if (! _invalid) diff --git a/cocos/2d/CCDirector.h b/cocos/2d/CCDirector.h index b2204e7146..23bc8cda42 100644 --- a/cocos/2d/CCDirector.h +++ b/cocos/2d/CCDirector.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2011 Zynga Inc. + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2010-2013 cocos2d-x.org + Copyright (c) 2011 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -59,6 +60,7 @@ class EventListenerCustom; class TextureCache; class Frustum; class Renderer; +class Console; /** @brief Class that creates and handles the main Window and manages how @@ -185,21 +187,9 @@ public: Useful to hook a notification object, like Notifications (http://github.com/manucorporat/CCNotifications) @since v0.99.5 */ - Node* getNotificationNode(); + Node* getNotificationNode() const { return _notificationNode; } void setNotificationNode(Node *node); - /** Director delegate. It shall implement the DirectorDelegate protocol - @since v0.99.5 - * @js NA - * @lua NA - */ - DirectorDelegate* getDelegate() const; - /** - * @js NA - * @lua NA - */ - void setDelegate(DirectorDelegate* delegate); - // window size /** returns the size of the OpenGL view in points. @@ -339,7 +329,7 @@ public: @since v0.99.4 */ void setContentScaleFactor(float scaleFactor); - float getContentScaleFactor() const; + float getContentScaleFactor() const { return _contentScaleFactor; } /** Get the Culling Frustum @@ -350,7 +340,7 @@ public: /** Gets the Scheduler associated with this director @since v2.0 */ - Scheduler* getScheduler() const; + Scheduler* getScheduler() const { return _scheduler; } /** Sets the Scheduler associated with this director @since v2.0 @@ -360,7 +350,7 @@ public: /** Gets the ActionManager associated with this director @since v2.0 */ - ActionManager* getActionManager() const; + ActionManager* getActionManager() const { return _actionManager; } /** Sets the ActionManager associated with this director @since v2.0 @@ -370,7 +360,7 @@ public: /** Gets the EventDispatcher associated with this director @since v3.0 */ - EventDispatcher* getEventDispatcher() const; + EventDispatcher* getEventDispatcher() const { return _eventDispatcher; } /** Sets the EventDispatcher associated with this director @since v3.0 @@ -380,7 +370,12 @@ public: /** Returns the Renderer @since v3.0 */ - Renderer* getRenderer() const; + Renderer* getRenderer() const { return _renderer; } + + /** Returns the Console + @since v3.0 + */ + Console* getConsole() const { return _console; } /* Gets delta time since last tick to main loop */ float getDeltaTime() const; @@ -392,7 +387,7 @@ public: protected: void purgeDirector(); - bool _purgeDirecotorInNextLoop; // this flag will be set to true in end() + bool _purgeDirectorInNextLoop; // this flag will be set to true in end() void setNextScene(); @@ -491,10 +486,11 @@ protected: /* This object will be visited after the scene. Useful to hook a notification node */ Node *_notificationNode; - /* Projection protocol delegate */ - DirectorDelegate *_projectionDelegate; - + /* Renderer for the Director */ Renderer *_renderer; + + /* Console for the director */ + Console *_console; // EGLViewProtocol will recreate stats labels to fit visible rect friend class EGLViewProtocol; diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index ee4f218337..b920a311c2 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -1,5 +1,6 @@ /* Copyright (c) 2012 Scott Lembcke and Howling Moon Software * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,12 +24,13 @@ #include "CCDrawNode.h" #include "CCShaderCache.h" #include "CCGL.h" -#include "CCNotificationCenter.h" #include "CCEventType.h" #include "CCConfiguration.h" #include "CCCustomCommand.h" #include "CCDirector.h" #include "CCRenderer.h" +#include "CCEventListenerCustom.h" +#include "CCEventDispatcher.h" NS_CC_BEGIN @@ -124,10 +126,6 @@ DrawNode::~DrawNode() GL::bindVAO(0); _vao = 0; } - -#if CC_ENABLE_CACHE_TEXTURE_DATA - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); -#endif } DrawNode* DrawNode::create() @@ -196,10 +194,12 @@ bool DrawNode::init() #if CC_ENABLE_CACHE_TEXTURE_DATA // Need to listen the event only when not use batchnode, because it will use VBO - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(DrawNode::listenBackToForeground), - EVNET_COME_TO_FOREGROUND, - nullptr); + auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ + /** listen the event that coming to foreground on Android */ + this->init(); + }); + + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); #endif return true; @@ -456,6 +456,86 @@ void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, fl free(extrude); } +void DrawNode::drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color) +{ + unsigned int vertex_count = 2*3; + ensureCapacity(vertex_count); + + Color4B col = Color4B(color); + V2F_C4B_T2F a = {Vertex2F(p1.x, p1.y), col, Tex2F(0.0, 0.0) }; + V2F_C4B_T2F b = {Vertex2F(p2.x, p2.y), col, Tex2F(0.0, 0.0) }; + V2F_C4B_T2F c = {Vertex2F(p3.x, p3.y), col, Tex2F(0.0, 0.0) }; + + V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); + V2F_C4B_T2F_Triangle triangle = {a, b, c}; + triangles[0] = triangle; + + _bufferCount += vertex_count; + _dirty = true; +} + +void DrawNode::drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color) +{ + unsigned int vertex_count = (segments + 1) * 3; + ensureCapacity(vertex_count); + + Tex2F texCoord = Tex2F(0.0, 0.0); + Color4B col = Color4B(color); + Vertex2F vertex; + Vertex2F firstVertex = Vertex2F(from.x, from.y); + Vertex2F lastVertex = Vertex2F(to.x, to.y); + + float t = 0; + for(unsigned int i = segments + 1; i > 0; i--) + { + float x = powf(1 - t, 3) * from.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * to.x; + float y = powf(1 - t, 3) * from.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * to.y; + vertex = Vertex2F(x, y); + + V2F_C4B_T2F a = {firstVertex, col, texCoord }; + V2F_C4B_T2F b = {lastVertex, col, texCoord }; + V2F_C4B_T2F c = {vertex, col, texCoord }; + V2F_C4B_T2F_Triangle triangle = {a, b, c}; + ((V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount))[0] = triangle; + + lastVertex = vertex; + t += 1.0f / segments; + _bufferCount += 3; + } + _dirty = true; +} + +void DrawNode::drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color) +{ + unsigned int vertex_count = (segments + 1) * 3; + ensureCapacity(vertex_count); + + Tex2F texCoord = Tex2F(0.0, 0.0); + Color4B col = Color4B(color); + Vertex2F vertex; + Vertex2F firstVertex = Vertex2F(from.x, from.y); + Vertex2F lastVertex = Vertex2F(to.x, to.y); + + float t = 0; + for(unsigned int i = segments + 1; i > 0; i--) + { + float x = powf(1 - t, 2) * from.x + 2.0f * (1 - t) * t * control.x + t * t * to.x; + float y = powf(1 - t, 2) * from.y + 2.0f * (1 - t) * t * control.y + t * t * to.y; + vertex = Vertex2F(x, y); + + V2F_C4B_T2F a = {firstVertex, col, texCoord }; + V2F_C4B_T2F b = {lastVertex, col, texCoord }; + V2F_C4B_T2F c = {vertex, col, texCoord }; + V2F_C4B_T2F_Triangle triangle = {a, b, c}; + ((V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount))[0] = triangle; + + lastVertex = vertex; + t += 1.0f / segments; + _bufferCount += 3; + } + _dirty = true; +} + void DrawNode::clear() { _bufferCount = 0; @@ -472,11 +552,4 @@ void DrawNode::setBlendFunc(const BlendFunc &blendFunc) _blendFunc = blendFunc; } -/** listen the event that coming to foreground on Android - */ -void DrawNode::listenBackToForeground(Object *obj) -{ - init(); -} - NS_CC_END diff --git a/cocos/2d/CCDrawNode.h b/cocos/2d/CCDrawNode.h index e91f41e8ca..2624eeee0b 100644 --- a/cocos/2d/CCDrawNode.h +++ b/cocos/2d/CCDrawNode.h @@ -1,5 +1,6 @@ /* Copyright (c) 2012 Scott Lembcke and Howling Moon Software * Copyright (c) 2012 cocos2d-x.org + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -62,6 +63,15 @@ public: * @endcode */ void drawPolygon(Point *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor); + + /** draw a triangle with color */ + void drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color); + + /** draw a cubic bezier curve with color and number of segments */ + void drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color); + + /** draw a quadratic bezier curve with color and number of segments */ + void drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color); /** Clear the geometry in the node's buffer. */ void clear(); @@ -78,12 +88,6 @@ public: * @lua NA */ void setBlendFunc(const BlendFunc &blendFunc); - - /** listen the event that coming to foreground on Android - * @js NA - * @lua NA - */ - void listenBackToForeground(Object *obj); void onDraw(); diff --git a/cocos/2d/CCDrawingPrimitives.cpp b/cocos/2d/CCDrawingPrimitives.cpp index 16903cebe8..9a8dcfbd89 100644 --- a/cocos/2d/CCDrawingPrimitives.cpp +++ b/cocos/2d/CCDrawingPrimitives.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCDrawingPrimitives.h b/cocos/2d/CCDrawingPrimitives.h index c46c88a0ad..219cc1b7e7 100644 --- a/cocos/2d/CCDrawingPrimitives.h +++ b/cocos/2d/CCDrawingPrimitives.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEvent.cpp b/cocos/2d/CCEvent.cpp index c74beef87e..66855586b0 100644 --- a/cocos/2d/CCEvent.cpp +++ b/cocos/2d/CCEvent.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEvent.h b/cocos/2d/CCEvent.h index b067ff3ce3..c1ec2416c0 100644 --- a/cocos/2d/CCEvent.h +++ b/cocos/2d/CCEvent.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventAcceleration.cpp b/cocos/2d/CCEventAcceleration.cpp index 1a8a075d88..cb3001a369 100644 --- a/cocos/2d/CCEventAcceleration.cpp +++ b/cocos/2d/CCEventAcceleration.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventAcceleration.h b/cocos/2d/CCEventAcceleration.h index 1480ee6b0c..ce380edc45 100644 --- a/cocos/2d/CCEventAcceleration.h +++ b/cocos/2d/CCEventAcceleration.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventCustom.cpp b/cocos/2d/CCEventCustom.cpp index 65e9d4c2f5..09b5c5048a 100644 --- a/cocos/2d/CCEventCustom.cpp +++ b/cocos/2d/CCEventCustom.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventCustom.h b/cocos/2d/CCEventCustom.h index 4a7d750940..c967069151 100644 --- a/cocos/2d/CCEventCustom.h +++ b/cocos/2d/CCEventCustom.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventDispatcher.cpp b/cocos/2d/CCEventDispatcher.cpp index 151a6c267c..609b67c3cd 100644 --- a/cocos/2d/CCEventDispatcher.cpp +++ b/cocos/2d/CCEventDispatcher.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -279,11 +279,10 @@ void EventDispatcher::associateNodeAndEventListener(Node* node, EventListener* l else { listeners = new std::vector(); + _nodeListenersMap.insert(std::make_pair(node, listeners)); } listeners->push_back(listener); - - _nodeListenersMap.insert(std::make_pair(node, listeners)); } void EventDispatcher::dissociateNodeAndEventListener(Node* node, EventListener* listener) @@ -311,29 +310,7 @@ void EventDispatcher::addEventListener(EventListener* listener) { if (_inDispatch == 0) { - EventListenerVector* listenerList = nullptr; - - auto iter = _listeners.find(listener->getListenerID()); - if (iter == _listeners.end()) - { - listenerList = new EventListenerVector(); - _listeners.insert(std::make_pair(listener->getListenerID(), listenerList)); - } - else - { - listenerList = iter->second; - } - - listenerList->push_back(listener); - - if (listener->getFixedPriority() == 0) - { - setDirty(listener->getListenerID(), DirtyFlag::SCENE_GRAPH_PRIORITY); - } - else - { - setDirty(listener->getListenerID(), DirtyFlag::FIXED_PRITORY); - } + forceAddEventListener(listener); } else { @@ -343,6 +320,44 @@ void EventDispatcher::addEventListener(EventListener* listener) listener->retain(); } +void EventDispatcher::forceAddEventListener(EventListener* listener) +{ + EventListenerVector* listeners = nullptr; + EventListener::ListenerID listenerID = listener->getListenerID(); + auto itr = _listeners.find(listenerID); + if (itr == _listeners.end()) + { + + listeners = new EventListenerVector(); + _listeners.insert(std::make_pair(listenerID, listeners)); + } + else + { + listeners = itr->second; + } + + listeners->push_back(listener); + + if (listener->getFixedPriority() == 0) + { + setDirty(listenerID, DirtyFlag::SCENE_GRAPH_PRIORITY); + + auto node = listener->getSceneGraphPriority(); + CCASSERT(node != nullptr, "Invalid scene graph priority!"); + + associateNodeAndEventListener(node, listener); + + if (node->isRunning()) + { + resumeTarget(node); + } + } + else + { + setDirty(listenerID, DirtyFlag::FIXED_PRITORY); + } +} + void EventDispatcher::addEventListenerWithSceneGraphPriority(EventListener* listener, Node* node) { CCASSERT(listener && node, "Invalid parameters."); @@ -356,13 +371,6 @@ void EventDispatcher::addEventListenerWithSceneGraphPriority(EventListener* list listener->setRegistered(true); addEventListener(listener); - - associateNodeAndEventListener(node, listener); - - if (node->isRunning()) - { - resumeTarget(node); - } } void EventDispatcher::addEventListenerWithFixedPriority(EventListener* listener, int fixedPriority) @@ -462,6 +470,7 @@ void EventDispatcher::removeEventListener(EventListener* listener) { if (*iter == listener) { + listener->release(); _toAddedListeners.erase(iter); break; } @@ -872,33 +881,9 @@ void EventDispatcher::updateListeners(Event* event) if (!_toAddedListeners.empty()) { - EventListenerVector* listeners = nullptr; - for (auto& listener : _toAddedListeners) { - EventListener::ListenerID listenerID = listener->getListenerID(); - auto itr = _listeners.find(listenerID); - if (itr == _listeners.end()) - { - - listeners = new EventListenerVector(); - _listeners.insert(std::make_pair(listenerID, listeners)); - } - else - { - listeners = itr->second; - } - - listeners->push_back(listener); - - if (listener->getFixedPriority() == 0) - { - setDirty(listenerID, DirtyFlag::SCENE_GRAPH_PRIORITY); - } - else - { - setDirty(listenerID, DirtyFlag::FIXED_PRITORY); - } + forceAddEventListener(listener); } _toAddedListeners.clear(); } @@ -1070,10 +1055,11 @@ void EventDispatcher::removeEventListenersForListenerID(const EventListener::Lis } } - for(auto iter = _toAddedListeners.begin(); iter != _toAddedListeners.end();) + for (auto iter = _toAddedListeners.begin(); iter != _toAddedListeners.end();) { if ((*iter)->getListenerID() == listenerID) { + (*iter)->release(); iter = _toAddedListeners.erase(iter); } else diff --git a/cocos/2d/CCEventDispatcher.h b/cocos/2d/CCEventDispatcher.h index 41c98495bd..cb62e4711b 100644 --- a/cocos/2d/CCEventDispatcher.h +++ b/cocos/2d/CCEventDispatcher.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -155,9 +155,18 @@ protected: ssize_t _gt0Index; }; - /** Adds event listener with item */ + /** Adds an event listener with item + * @note if it is dispatching event, the added operation will be delayed to the end of current dispatch + * @see forceAddEventListener + */ void addEventListener(EventListener* listener); + /** Force adding an event listener + * @note force add an event listener which will ignore whether it's in dispatching. + * @see addEventListener + */ + void forceAddEventListener(EventListener* listener); + /** Gets event the listener list for the event listener type. */ EventListenerVector* getListeners(const EventListener::ListenerID& listenerID); diff --git a/cocos/2d/CCEventKeyboard.cpp b/cocos/2d/CCEventKeyboard.cpp index 83bf0a8d0a..2051e09cbc 100644 --- a/cocos/2d/CCEventKeyboard.cpp +++ b/cocos/2d/CCEventKeyboard.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventKeyboard.h b/cocos/2d/CCEventKeyboard.h index e0533e62fd..942e5738d6 100644 --- a/cocos/2d/CCEventKeyboard.h +++ b/cocos/2d/CCEventKeyboard.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListener.cpp b/cocos/2d/CCEventListener.cpp index b4f9fdd499..3ed1e8b730 100644 --- a/cocos/2d/CCEventListener.cpp +++ b/cocos/2d/CCEventListener.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListener.h b/cocos/2d/CCEventListener.h index ea44c83559..cf380dd50d 100644 --- a/cocos/2d/CCEventListener.h +++ b/cocos/2d/CCEventListener.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListenerAcceleration.cpp b/cocos/2d/CCEventListenerAcceleration.cpp index d4192e2a83..72defaa6e0 100644 --- a/cocos/2d/CCEventListenerAcceleration.cpp +++ b/cocos/2d/CCEventListenerAcceleration.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListenerAcceleration.h b/cocos/2d/CCEventListenerAcceleration.h index afe7fb5bba..2f290b8fb8 100644 --- a/cocos/2d/CCEventListenerAcceleration.h +++ b/cocos/2d/CCEventListenerAcceleration.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListenerCustom.cpp b/cocos/2d/CCEventListenerCustom.cpp index eda8ba36fa..aeebcd5fd4 100644 --- a/cocos/2d/CCEventListenerCustom.cpp +++ b/cocos/2d/CCEventListenerCustom.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListenerCustom.h b/cocos/2d/CCEventListenerCustom.h index 8a7fe162e1..20c4f3497e 100644 --- a/cocos/2d/CCEventListenerCustom.h +++ b/cocos/2d/CCEventListenerCustom.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListenerKeyboard.cpp b/cocos/2d/CCEventListenerKeyboard.cpp index ff31aa2ace..b5131c0c3b 100644 --- a/cocos/2d/CCEventListenerKeyboard.cpp +++ b/cocos/2d/CCEventListenerKeyboard.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListenerKeyboard.h b/cocos/2d/CCEventListenerKeyboard.h index a8b181da66..a30f517658 100644 --- a/cocos/2d/CCEventListenerKeyboard.h +++ b/cocos/2d/CCEventListenerKeyboard.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListenerMouse.cpp b/cocos/2d/CCEventListenerMouse.cpp index 63ebebd501..7dfd8d4c95 100644 --- a/cocos/2d/CCEventListenerMouse.cpp +++ b/cocos/2d/CCEventListenerMouse.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListenerMouse.h b/cocos/2d/CCEventListenerMouse.h index a9fa326b8b..8ca58db437 100644 --- a/cocos/2d/CCEventListenerMouse.h +++ b/cocos/2d/CCEventListenerMouse.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListenerTouch.cpp b/cocos/2d/CCEventListenerTouch.cpp index c453d5f84c..a9b423c5d8 100644 --- a/cocos/2d/CCEventListenerTouch.cpp +++ b/cocos/2d/CCEventListenerTouch.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventListenerTouch.h b/cocos/2d/CCEventListenerTouch.h index 5f1ddd2845..7577bbc180 100644 --- a/cocos/2d/CCEventListenerTouch.h +++ b/cocos/2d/CCEventListenerTouch.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventMouse.cpp b/cocos/2d/CCEventMouse.cpp index f9d6fcd7a8..a787c79758 100644 --- a/cocos/2d/CCEventMouse.cpp +++ b/cocos/2d/CCEventMouse.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventMouse.h b/cocos/2d/CCEventMouse.h index ee563a7abc..8da29b84fb 100644 --- a/cocos/2d/CCEventMouse.h +++ b/cocos/2d/CCEventMouse.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventTouch.cpp b/cocos/2d/CCEventTouch.cpp index 9cfa0edd8d..f380d412ad 100644 --- a/cocos/2d/CCEventTouch.cpp +++ b/cocos/2d/CCEventTouch.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventTouch.h b/cocos/2d/CCEventTouch.h index 3bc18f55ca..9a8037d494 100644 --- a/cocos/2d/CCEventTouch.h +++ b/cocos/2d/CCEventTouch.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCEventType.h b/cocos/2d/CCEventType.h index c00c62e456..bc3b8a6194 100644 --- a/cocos/2d/CCEventType.h +++ b/cocos/2d/CCEventType.h @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef __CCEVENT_TYPE_H__ #define __CCEVENT_TYPE_H__ @@ -9,7 +32,7 @@ // The application will come to foreground. // This message is used for reloading resources before come to foreground on Android. // This message is posted in main.cpp. -#define EVNET_COME_TO_FOREGROUND "event_come_to_foreground" +#define EVENT_COME_TO_FOREGROUND "event_come_to_foreground" // The application will come to background. // This message is used for doing something before coming to background, such as save RenderTexture. diff --git a/cocos/2d/CCFont.cpp b/cocos/2d/CCFont.cpp index 471346a5ad..dc363cfe02 100644 --- a/cocos/2d/CCFont.cpp +++ b/cocos/2d/CCFont.cpp @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCFont.h b/cocos/2d/CCFont.h index dfd5dd7ecc..440da0808b 100644 --- a/cocos/2d/CCFont.h +++ b/cocos/2d/CCFont.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp index a4dcb8fd19..4d35ce980d 100644 --- a/cocos/2d/CCFontAtlas.cpp +++ b/cocos/2d/CCFontAtlas.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. - + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCFontAtlas.h b/cocos/2d/CCFontAtlas.h index 044b0cdb5e..0a2d6f215b 100644 --- a/cocos/2d/CCFontAtlas.h +++ b/cocos/2d/CCFontAtlas.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCFontAtlasCache.cpp b/cocos/2d/CCFontAtlasCache.cpp index b72b76540c..ccea76b254 100644 --- a/cocos/2d/CCFontAtlasCache.cpp +++ b/cocos/2d/CCFontAtlasCache.cpp @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -103,20 +104,18 @@ std::string FontAtlasCache::generateFontName(const std::string& fontFileName, in bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas) { - if (atlas) + if (nullptr != atlas) { for( auto &item: _atlasMap ) { if ( item.second == atlas ) { - bool removeFromList = false; - if(item.second->isSingleReference()) - removeFromList = true; + if( atlas->isSingleReference() ) + { + _atlasMap.erase(item.first); + } - item.second->release(); - - if (removeFromList) - _atlasMap.erase(item.first); + atlas->release(); return true; } @@ -126,4 +125,4 @@ bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas) return false; } -NS_CC_END \ No newline at end of file +NS_CC_END diff --git a/cocos/2d/CCFontAtlasCache.h b/cocos/2d/CCFontAtlasCache.h index acbbb28ca9..bdc7dd24d1 100644 --- a/cocos/2d/CCFontAtlasCache.h +++ b/cocos/2d/CCFontAtlasCache.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCFontAtlasFactory.cpp b/cocos/2d/CCFontAtlasFactory.cpp index 8e532af2c5..c9d3ebbb3b 100644 --- a/cocos/2d/CCFontAtlasFactory.cpp +++ b/cocos/2d/CCFontAtlasFactory.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. - + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCFontAtlasFactory.h b/cocos/2d/CCFontAtlasFactory.h index b03806dccd..2a10cc8d63 100644 --- a/cocos/2d/CCFontAtlasFactory.h +++ b/cocos/2d/CCFontAtlasFactory.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCFontDefinition.cpp b/cocos/2d/CCFontDefinition.cpp index d8414dc64d..c0d8af5051 100644 --- a/cocos/2d/CCFontDefinition.cpp +++ b/cocos/2d/CCFontDefinition.cpp @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCFontDefinition.h b/cocos/2d/CCFontDefinition.h index 1f9504920c..5bec2bb098 100644 --- a/cocos/2d/CCFontDefinition.h +++ b/cocos/2d/CCFontDefinition.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCFontFNT.cpp b/cocos/2d/CCFontFNT.cpp index 7ea6609f5c..93fd5c2410 100644 --- a/cocos/2d/CCFontFNT.cpp +++ b/cocos/2d/CCFontFNT.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. - + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCFontFNT.h b/cocos/2d/CCFontFNT.h index e9c4327672..eec0bd761c 100644 --- a/cocos/2d/CCFontFNT.h +++ b/cocos/2d/CCFontFNT.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCFontFreeType.cpp b/cocos/2d/CCFontFreeType.cpp index 77a64bcfd9..60b5a11954 100644 --- a/cocos/2d/CCFontFreeType.cpp +++ b/cocos/2d/CCFontFreeType.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. - +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCFontFreeType.h b/cocos/2d/CCFontFreeType.h index 7ff7596c20..bd86c5effc 100644 --- a/cocos/2d/CCFontFreeType.h +++ b/cocos/2d/CCFontFreeType.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCGLBufferedNode.cpp b/cocos/2d/CCGLBufferedNode.cpp index 0f97908370..ec3484fcde 100644 --- a/cocos/2d/CCGLBufferedNode.cpp +++ b/cocos/2d/CCGLBufferedNode.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. - +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCGLBufferedNode.h b/cocos/2d/CCGLBufferedNode.h index 10bf825462..4cc28a4721 100644 --- a/cocos/2d/CCGLBufferedNode.h +++ b/cocos/2d/CCGLBufferedNode.h @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. - +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 0d9441cde3..fcfe4970d2 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright 2012 cocos2d-x.org Copyright 2011 Jeff Lamarche Copyright 2012 Goffredo Marocchi Copyright 2012 Ricardo Quesada +Copyright 2012 cocos2d-x.org +Copyright 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -49,6 +50,7 @@ const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR = "ShaderPositionTextu const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP = "ShaderPositionTextureColor_noMVP"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest"; const char* GLProgram::SHADER_NAME_POSITION_COLOR = "ShaderPositionColor"; +const char* GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP = "ShaderPositionColor_noMVP"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE = "ShaderPositionTexture"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR = "ShaderPositionTexture_uColor"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR = "ShaderPositionTextureA8Color"; diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index 84aaa113fa..a916caf7c7 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -1,9 +1,11 @@ /**************************************************************************** -Copyright 2012 cocos2d-x.org Copyright 2011 Jeff Lamarche Copyright 2012 Goffredo Marocchi Copyright 2012 Ricardo Quesada - +Copyright 2012 cocos2d-x.org +Copyright 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy @@ -82,6 +84,7 @@ public: static const char* SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP; static const char* SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST; static const char* SHADER_NAME_POSITION_COLOR; + static const char* SHADER_NAME_POSITION_COLOR_NO_MVP; static const char* SHADER_NAME_POSITION_TEXTURE; static const char* SHADER_NAME_POSITION_TEXTURE_U_COLOR; static const char* SHADER_NAME_POSITION_TEXTURE_A8_COLOR; diff --git a/cocos/2d/CCGrabber.cpp b/cocos/2d/CCGrabber.cpp index 4486e58712..0475cca87b 100644 --- a/cocos/2d/CCGrabber.cpp +++ b/cocos/2d/CCGrabber.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCGrabber.h b/cocos/2d/CCGrabber.h index 022e68ed0d..d3bdf1a07b 100644 --- a/cocos/2d/CCGrabber.h +++ b/cocos/2d/CCGrabber.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCGrid.cpp b/cocos/2d/CCGrid.cpp index 06da510aed..53a86e8046 100644 --- a/cocos/2d/CCGrid.cpp +++ b/cocos/2d/CCGrid.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core - +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (C) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCGrid.h b/cocos/2d/CCGrid.h index 63e49547d8..8111190818 100644 --- a/cocos/2d/CCGrid.h +++ b/cocos/2d/CCGrid.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCIMEDelegate.h b/cocos/2d/CCIMEDelegate.h index 053359abfc..d232236ceb 100644 --- a/cocos/2d/CCIMEDelegate.h +++ b/cocos/2d/CCIMEDelegate.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010 cocos2d-x.org +Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCIMEDispatcher.cpp b/cocos/2d/CCIMEDispatcher.cpp index 7bc493c988..c58f3d7d5e 100644 --- a/cocos/2d/CCIMEDispatcher.cpp +++ b/cocos/2d/CCIMEDispatcher.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - +Copyright (c) 2010 cocos2d-x.org +Copyright (C) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCIMEDispatcher.h b/cocos/2d/CCIMEDispatcher.h index ea551a4d3e..0f71c2fab6 100644 --- a/cocos/2d/CCIMEDispatcher.h +++ b/cocos/2d/CCIMEDispatcher.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - +Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index c2a512d482..d7125bcd30 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -145,7 +146,8 @@ bool Label::init() setLabelEffect(LabelEffect::NORMAL,Color3B::BLACK); else if(_useA8Shader) setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR)); - + else + setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return ret; } @@ -500,7 +502,7 @@ void Label::setFontSize(int fontSize) Node::setScale(1.0f*_fontSize/DISTANCEFIELD_ATLAS_FONTSIZE); } -void Label::draw() +void Label::onDraw() { CC_PROFILER_START("CCSpriteBatchNode - draw"); @@ -527,6 +529,13 @@ void Label::draw() CC_PROFILER_STOP("CCSpriteBatchNode - draw"); } +void Label::draw() +{ + _customCommand.init(0, _vertexZ); + _customCommand.func = CC_CALLBACK_0(Label::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(&_customCommand); +} + ///// PROTOCOL STUFF Sprite * Label::getLetter(int ID) diff --git a/cocos/2d/CCLabel.h b/cocos/2d/CCLabel.h index 29f0cecb91..ea7462ab50 100644 --- a/cocos/2d/CCLabel.h +++ b/cocos/2d/CCLabel.h @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. - + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy @@ -29,6 +30,7 @@ #include "CCSpriteBatchNode.h" #include "CCLabelTextFormatProtocol.h" #include "ccTypes.h" +#include "renderer/CCCustomCommand.h" NS_CC_BEGIN @@ -119,6 +121,7 @@ public: virtual std::string getDescription() const override; virtual void draw(void) override; + virtual void onDraw(); private: /** @@ -172,7 +175,8 @@ private: Color3B _effectColor; GLuint _uniformEffectColor; - + + CustomCommand _customCommand; }; diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index 63511eec7d..200bec0641 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -42,15 +43,30 @@ NS_CC_BEGIN //CCLabelAtlas - Creation & Init +LabelAtlas* LabelAtlas::create() +{ + LabelAtlas* ret = new LabelAtlas(); + if (ret) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + + return ret; +} + LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap) { - LabelAtlas *pRet = new LabelAtlas(); - if(pRet && pRet->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap)) + LabelAtlas* ret = new LabelAtlas(); + if(ret && ret->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap)) { - pRet->autorelease(); - return pRet; + ret->autorelease(); + return ret; } - CC_SAFE_DELETE(pRet); + CC_SAFE_DELETE(ret); return nullptr; } diff --git a/cocos/2d/CCLabelAtlas.h b/cocos/2d/CCLabelAtlas.h index 743100cdbe..47064c14c7 100644 --- a/cocos/2d/CCLabelAtlas.h +++ b/cocos/2d/CCLabelAtlas.h @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. - +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy @@ -51,23 +52,11 @@ A more flexible class is LabelBMFont. It supports variable width characters and class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol { public: - /** - * @js ctor - */ - LabelAtlas() - :_string("") - {} - /** - * @js NA - * @lua NA - */ - virtual ~LabelAtlas() - { - _string.clear(); - } - + /** creates an empty LabelAtlas, user need to call initWithString(...) later to make this object work properly **/ + static LabelAtlas* create(); + /** creates the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - static LabelAtlas * create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); + static LabelAtlas* create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); /** creates the LabelAtlas with a string and a configuration file @since v2.0 @@ -97,6 +86,15 @@ public: #endif protected: + LabelAtlas() + :_string("") + {} + + virtual ~LabelAtlas() + { + _string.clear(); + } + // string to render std::string _string; // the first char in the charmap diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index d3008ba72a..539c5dab6a 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCLabelBMFont.h b/cocos/2d/CCLabelBMFont.h index 9b3f226806..5edda128e1 100644 --- a/cocos/2d/CCLabelBMFont.h +++ b/cocos/2d/CCLabelBMFont.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -234,7 +235,7 @@ public: virtual const std::string& getString() const override; virtual void setCString(const char *label); - virtual void setAnchorPoint(const Point& var); + virtual void setAnchorPoint(const Point& var) override; virtual void updateLabel(); virtual void setAlignment(TextHAlignment alignment); virtual void setWidth(float width); diff --git a/cocos/2d/CCLabelTTF.cpp b/cocos/2d/CCLabelTTF.cpp index 52fd5ebbd4..74483aa8c1 100644 --- a/cocos/2d/CCLabelTTF.cpp +++ b/cocos/2d/CCLabelTTF.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCLabelTTF.h b/cocos/2d/CCLabelTTF.h index c9d4f9de26..aa612adb17 100644 --- a/cocos/2d/CCLabelTTF.h +++ b/cocos/2d/CCLabelTTF.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCLabelTextFormatProtocol.h b/cocos/2d/CCLabelTextFormatProtocol.h index 179849e033..bf72775a51 100644 --- a/cocos/2d/CCLabelTextFormatProtocol.h +++ b/cocos/2d/CCLabelTextFormatProtocol.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index 7967c6a80d..956c5c3bb1 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -240,10 +241,10 @@ bool LabelTextFormatter::alignText(LabelTextFormatProtocol *theLabel) continue; } int index = static_cast(i + lineLength - 1 + lineNumber); + if(currentChar == 0) + index -= 1; if (index < 0) continue; - if(currentChar == 0) - continue; LetterInfo* info = &leterInfo->at( index ); if(info->def.validDefinition == false) continue; diff --git a/cocos/2d/CCLabelTextFormatter.h b/cocos/2d/CCLabelTextFormatter.h index f8569aca40..f6a7ecdec9 100644 --- a/cocos/2d/CCLabelTextFormatter.h +++ b/cocos/2d/CCLabelTextFormatter.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCLayer.cpp b/cocos/2d/CCLayer.cpp index 46f7a2ee57..1bae6e040c 100644 --- a/cocos/2d/CCLayer.cpp +++ b/cocos/2d/CCLayer.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. - +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy @@ -512,7 +513,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h) updateColor(); setContentSize(Size(w, h)); - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_COLOR)); + setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP)); return true; } return false; @@ -567,6 +568,15 @@ void LayerColor::draw() _customCommand.init(0, _vertexZ); _customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this); Director::getInstance()->getRenderer()->addCommand(&_customCommand); + + for(int i = 0; i < 4; ++i) + { + kmVec3 pos; + pos.x = _squareVertices[i].x; pos.y = _squareVertices[i].y; pos.z = _vertexZ; + kmVec3TransformCoord(&pos, &pos, &_modelViewTransform); + _noMVPVertices[i] = Vertex3F(pos.x,pos.y,pos.z); + } + } void LayerColor::onDraw() @@ -574,18 +584,17 @@ void LayerColor::onDraw() CC_NODE_DRAW_SETUP(); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR ); - // // Attributes // #ifdef EMSCRIPTEN - setGLBufferData(_squareVertices, 4 * sizeof(Vertex2F), 0); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); + setGLBufferData(_noMVPVertices, 4 * sizeof(Vertex3F), 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _squareVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _noMVPVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors); #endif // EMSCRIPTEN @@ -932,7 +941,7 @@ void LayerMultiplex::switchToAndReleaseMe(int n) std::string LayerMultiplex::getDescription() const { - return StringUtils::format("(_children.size())); } NS_CC_END diff --git a/cocos/2d/CCLayer.h b/cocos/2d/CCLayer.h index adc938909e..988d08ba60 100644 --- a/cocos/2d/CCLayer.h +++ b/cocos/2d/CCLayer.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -36,6 +37,7 @@ THE SOFTWARE. #include "CCEventKeyboard.h" #include "renderer/CCCustomCommand.h" +#include "renderer/CCQuadCommand.h" NS_CC_BEGIN @@ -298,7 +300,7 @@ protected: Vertex2F _squareVertices[4]; Color4F _squareColors[4]; CustomCommand _customCommand; - + Vertex3F _noMVPVertices[4]; private: CC_DISALLOW_COPY_AND_ASSIGN(LayerColor); diff --git a/cocos/2d/CCMenu.cpp b/cocos/2d/CCMenu.cpp index c6d2b787eb..c6cb20c5c1 100644 --- a/cocos/2d/CCMenu.cpp +++ b/cocos/2d/CCMenu.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCMenu.h b/cocos/2d/CCMenu.h index 2d3467d5b8..8d6cd5f4e9 100644 --- a/cocos/2d/CCMenu.h +++ b/cocos/2d/CCMenu.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp index 7ec1097ee1..f137404176 100644 --- a/cocos/2d/CCMenuItem.cpp +++ b/cocos/2d/CCMenuItem.cpp @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -347,9 +348,8 @@ bool MenuItemAtlasFont::initWithString(const std::string& value, const std::stri bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback) { CCASSERT( value.size() != 0, "value length must be greater than 0"); - LabelAtlas *label = new LabelAtlas(); + LabelAtlas *label = LabelAtlas::create(); label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap); - label->autorelease(); if (MenuItemLabel::initWithLabel(label, callback)) { // do something ? diff --git a/cocos/2d/CCMenuItem.h b/cocos/2d/CCMenuItem.h index d44dd60d97..9e19b4488e 100644 --- a/cocos/2d/CCMenuItem.h +++ b/cocos/2d/CCMenuItem.h @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCMotionStreak.cpp b/cocos/2d/CCMotionStreak.cpp index a358399bf5..4e248b7ea1 100644 --- a/cocos/2d/CCMotionStreak.cpp +++ b/cocos/2d/CCMotionStreak.cpp @@ -1,6 +1,7 @@ /**************************************************************************** +Copyright (c) 2011 ForzeField Studios S.L. Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2011 ForzeField Studios S.L. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCMotionStreak.h b/cocos/2d/CCMotionStreak.h index 33ef3217d1..09daacf5f6 100644 --- a/cocos/2d/CCMotionStreak.h +++ b/cocos/2d/CCMotionStreak.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2011 ForzeField Studios S.L. +Copyright (c) 2011 ForzeField Studios S.L. +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 3698d90cff..3b7ce1c47c 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -102,7 +103,7 @@ Node::Node(void) , _anchorPointInPoints(Point::ZERO) , _anchorPoint(Point::ZERO) , _contentSize(Size::ZERO) -, _additionalTransformDirty(false) +, _useAdditionalTransform(false) , _transformDirty(true) , _inverseDirty(true) // children (lazy allocs) @@ -854,11 +855,8 @@ void Node::transform() kmMat4 transfrom4x4 = this->getNodeToParentTransform(); - // Update Z vertex manually - transfrom4x4.mat[14] = _vertexZ; - - kmGLMultMatrix( &transfrom4x4 ); + // saves the MV matrix kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewTransform); } @@ -1188,15 +1186,17 @@ const kmMat4& Node::getNodeToParentTransform() const } } - if (_additionalTransformDirty) + // vertex Z + _transform.mat[14] = _vertexZ; + + if (_useAdditionalTransform) { kmMat4Multiply(&_transform, &_transform, &_additionalTransform); - _additionalTransformDirty = false; } - + _transformDirty = false; } - + return _transform; } @@ -1210,14 +1210,14 @@ void Node::setAdditionalTransform(const AffineTransform& additionalTransform) { CGAffineToGL(additionalTransform, _additionalTransform.mat); _transformDirty = true; - _additionalTransformDirty = true; + _useAdditionalTransform = true; } void Node::setAdditionalTransform(const kmMat4& additionalTransform) { _additionalTransform = additionalTransform; _transformDirty = true; - _additionalTransformDirty = true; + _useAdditionalTransform = true; } @@ -1256,7 +1256,7 @@ kmMat4 Node::getNodeToWorldTransform() const kmMat4 t = this->getNodeToParentTransform(); for (Node *p = _parent; p != nullptr; p = p->getParent()) - kmMat4Multiply(&t, &t, &p->getNodeToParentTransform()); + kmMat4Multiply(&t, &p->getNodeToParentTransform(), &t); return t; } diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 46cac36cdb..3069fb0a84 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -1,8 +1,9 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2009 Valentin Milea - Copyright (c) 2011 Zynga Inc. +Copyright (c) 2009 Valentin Milea +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -1265,7 +1266,9 @@ public: Point convertTouchToNodeSpaceAR(Touch * touch) const; /** - * Sets the additional transform. + * Sets an additional transform matrix to the node. + * + * In order to remove it, set the Identity Matrix to the additional transform. * * @note The additional transform will be concatenated at the end of getNodeToParentTransform. * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't). @@ -1288,7 +1291,7 @@ public: spriteA->setPosition(Point(200, 200)); // Gets the spriteA's transform. - AffineTransform t = spriteA->getNodeToParentTransform(); + auto t = spriteA->getNodeToParentTransform(); // Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA. spriteB->setAdditionalTransform(t); @@ -1420,12 +1423,13 @@ protected: Size _contentSize; ///< untransformed size of the node + kmMat4 _modelViewTransform; ///< ModelView transform of the Node. + // "cache" variables are allowed to be mutable mutable kmMat4 _additionalTransform; ///< transform mutable kmMat4 _transform; ///< transform mutable kmMat4 _inverse; ///< inverse transform - kmMat4 _modelViewTransform; ///< ModelView transform of the Node. - mutable bool _additionalTransformDirty; ///< The flag to check whether the additional transform is dirty + bool _useAdditionalTransform; ///< The flag to check whether the additional transform is dirty mutable bool _transformDirty; ///< transform dirty flag mutable bool _inverseDirty; ///< inverse transform dirty flag diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index ddf5e69590..90d5647a57 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCNodeGrid.h b/cocos/2d/CCNodeGrid.h index c73ef07a76..b46a3fab72 100644 --- a/cocos/2d/CCNodeGrid.h +++ b/cocos/2d/CCNodeGrid.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCNotificationCenter.cpp b/cocos/2d/CCNotificationCenter.cpp index 9e544f1ffd..98452f82cd 100644 --- a/cocos/2d/CCNotificationCenter.cpp +++ b/cocos/2d/CCNotificationCenter.cpp @@ -1,6 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Erawppa +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy @@ -31,50 +33,50 @@ using namespace std; NS_CC_BEGIN -static NotificationCenter *s_sharedNotifCenter = nullptr; +static __NotificationCenter *s_sharedNotifCenter = nullptr; -NotificationCenter::NotificationCenter() +__NotificationCenter::__NotificationCenter() : _scriptHandler(0) { _observers = __Array::createWithCapacity(3); _observers->retain(); } -NotificationCenter::~NotificationCenter() +__NotificationCenter::~__NotificationCenter() { _observers->release(); } -NotificationCenter *NotificationCenter::getInstance() +__NotificationCenter *__NotificationCenter::getInstance() { if (!s_sharedNotifCenter) { - s_sharedNotifCenter = new NotificationCenter; + s_sharedNotifCenter = new __NotificationCenter; } return s_sharedNotifCenter; } -void NotificationCenter::destroyInstance() +void __NotificationCenter::destroyInstance() { CC_SAFE_RELEASE_NULL(s_sharedNotifCenter); } // XXX: deprecated -NotificationCenter *NotificationCenter::sharedNotificationCenter(void) +__NotificationCenter *__NotificationCenter::sharedNotificationCenter(void) { - return NotificationCenter::getInstance(); + return __NotificationCenter::getInstance(); } // XXX: deprecated -void NotificationCenter::purgeNotificationCenter(void) +void __NotificationCenter::purgeNotificationCenter(void) { - NotificationCenter::destroyInstance(); + __NotificationCenter::destroyInstance(); } // // internal functions // -bool NotificationCenter::observerExisted(Object *target, const std::string& name, Object *sender) +bool __NotificationCenter::observerExisted(Object *target, const std::string& name, Object *sender) { Object* obj = nullptr; CCARRAY_FOREACH(_observers, obj) @@ -92,7 +94,7 @@ bool NotificationCenter::observerExisted(Object *target, const std::string& name // // observer functions // -void NotificationCenter::addObserver(Object *target, +void __NotificationCenter::addObserver(Object *target, SEL_CallFuncO selector, const std::string& name, Object *sender) @@ -108,7 +110,7 @@ void NotificationCenter::addObserver(Object *target, _observers->addObject(observer); } -void NotificationCenter::removeObserver(Object *target, const std::string& name) +void __NotificationCenter::removeObserver(Object *target, const std::string& name) { Object* obj = nullptr; CCARRAY_FOREACH(_observers, obj) @@ -125,7 +127,7 @@ void NotificationCenter::removeObserver(Object *target, const std::string& name) } } -int NotificationCenter::removeAllObservers(Object *target) +int __NotificationCenter::removeAllObservers(Object *target) { Object *obj = nullptr; __Array *toRemove = __Array::create(); @@ -146,7 +148,7 @@ int NotificationCenter::removeAllObservers(Object *target) return static_cast(toRemove->count()); } -void NotificationCenter::registerScriptObserver( Object *target, int handler,const std::string& name) +void __NotificationCenter::registerScriptObserver( Object *target, int handler,const std::string& name) { if (this->observerExisted(target, name, nullptr)) @@ -161,7 +163,7 @@ void NotificationCenter::registerScriptObserver( Object *target, int handler,con _observers->addObject(observer); } -void NotificationCenter::unregisterScriptObserver(Object *target,const std::string& name) +void __NotificationCenter::unregisterScriptObserver(Object *target,const std::string& name) { Object* obj = nullptr; CCARRAY_FOREACH(_observers, obj) @@ -177,7 +179,7 @@ void NotificationCenter::unregisterScriptObserver(Object *target,const std::stri } } -void NotificationCenter::postNotification(const std::string& name, Object *sender) +void __NotificationCenter::postNotification(const std::string& name, Object *sender) { __Array* ObserversCopy = __Array::createWithCapacity(_observers->count()); ObserversCopy->addObjectsFromArray(_observers); @@ -198,12 +200,12 @@ void NotificationCenter::postNotification(const std::string& name, Object *sende } } -void NotificationCenter::postNotification(const std::string& name) +void __NotificationCenter::postNotification(const std::string& name) { this->postNotification(name,nullptr); } -int NotificationCenter::getObserverHandlerByName(const std::string& name) +int __NotificationCenter::getObserverHandlerByName(const std::string& name) { if (name.empty()) { diff --git a/cocos/2d/CCNotificationCenter.h b/cocos/2d/CCNotificationCenter.h index f2265b1518..de75060feb 100644 --- a/cocos/2d/CCNotificationCenter.h +++ b/cocos/2d/CCNotificationCenter.h @@ -1,6 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Erawppa +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy @@ -31,29 +33,29 @@ THE SOFTWARE. NS_CC_BEGIN class ScriptHandlerMgr; -class CC_DLL NotificationCenter : public Object +class CC_DLL __NotificationCenter : public Object { friend class ScriptHandlerMgr; public: - /** NotificationCenter constructor + /** __NotificationCenter constructor * @js ctor */ - NotificationCenter(); + __NotificationCenter(); - /** NotificationCenter destructor + /** __NotificationCenter destructor * @js NA * @lua NA */ - ~NotificationCenter(); + ~__NotificationCenter(); - /** Gets the single instance of NotificationCenter. */ - static NotificationCenter *getInstance(); + /** Gets the single instance of __NotificationCenter. */ + static __NotificationCenter *getInstance(); - /** Destroys the single instance of NotificationCenter. */ + /** Destroys the single instance of __NotificationCenter. */ static void destroyInstance(); /** @deprecated use getInstance() instead */ - CC_DEPRECATED_ATTRIBUTE static NotificationCenter *sharedNotificationCenter(void); + CC_DEPRECATED_ATTRIBUTE static __NotificationCenter *sharedNotificationCenter(void); /** @deprecated use destroyInstance() instead */ CC_DEPRECATED_ATTRIBUTE static void purgeNotificationCenter(void); diff --git a/cocos/2d/CCParallaxNode.cpp b/cocos/2d/CCParallaxNode.cpp index 608a60964b..a2e165ce85 100644 --- a/cocos/2d/CCParallaxNode.cpp +++ b/cocos/2d/CCParallaxNode.cpp @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCParallaxNode.h b/cocos/2d/CCParallaxNode.h index 723b467985..827c5074e3 100644 --- a/cocos/2d/CCParallaxNode.h +++ b/cocos/2d/CCParallaxNode.h @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index e58f919b92..5b78d1256f 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -1,9 +1,10 @@ /* - * Copyright (c) 2010-2012 cocos2d-x.org * Copyright (C) 2009 Matt Oswald * Copyright (c) 2009-2010 Ricardo Quesada - * Copyright (c) 2011 Zynga Inc. - * Copyright (c) 2011 Marco Tillemans + * Copyright (c) 2010-2012 cocos2d-x.org + * Copyright (c) 2011 Zynga Inc. + * Copyright (c) 2011 Marco Tillemans + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * http://www.cocos2d-x.org * diff --git a/cocos/2d/CCParticleBatchNode.h b/cocos/2d/CCParticleBatchNode.h index 4162d3b9dd..d4fd276603 100644 --- a/cocos/2d/CCParticleBatchNode.h +++ b/cocos/2d/CCParticleBatchNode.h @@ -1,9 +1,10 @@ /* - * Copyright (c) 2010-2012 cocos2d-x.org * Copyright (C) 2009 Matt Oswald * Copyright (c) 2009-2010 Ricardo Quesada - * Copyright (c) 2011 Zynga Inc. - * Copyright (c) 2011 Marco Tillemans + * Copyright (c) 2010-2012 cocos2d-x.org + * Copyright (c) 2011 Zynga Inc. + * Copyright (c) 2011 Marco Tillemans + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * http://www.cocos2d-x.org * @@ -73,22 +74,13 @@ public: /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the Texture2D class), a capacity of particles */ static ParticleBatchNode* create(const std::string& fileImage, int capacity = kParticleDefaultCapacity); - /** - * @js ctor - */ - ParticleBatchNode(); + /** * @js NA * @lua NA */ virtual ~ParticleBatchNode(); - /** initializes the particle system with Texture2D, a capacity of particles */ - bool initWithTexture(Texture2D *tex, int capacity); - - /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the Texture2D class), a capacity of particles */ - bool initWithFile(const std::string& fileImage, int capacity); - /** Inserts a child into the ParticleBatchNode */ void insertChild(ParticleSystem* system, int index); @@ -127,6 +119,18 @@ public: * @lua NA */ virtual const BlendFunc& getBlendFunc(void) const override; + +protected: + /** + * @js ctor + */ + ParticleBatchNode(); + + /** initializes the particle system with Texture2D, a capacity of particles */ + bool initWithTexture(Texture2D *tex, int capacity); + + /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the Texture2D class), a capacity of particles */ + bool initWithFile(const std::string& fileImage, int capacity); private: void updateAllAtlasIndexes(); diff --git a/cocos/2d/CCParticleExamples.cpp b/cocos/2d/CCParticleExamples.cpp index 6f7a307db3..dafe9d09ec 100644 --- a/cocos/2d/CCParticleExamples.cpp +++ b/cocos/2d/CCParticleExamples.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCParticleExamples.h b/cocos/2d/CCParticleExamples.h index 325bcd59f9..4d72dfe11c 100644 --- a/cocos/2d/CCParticleExamples.h +++ b/cocos/2d/CCParticleExamples.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCParticleSystem.cpp b/cocos/2d/CCParticleSystem.cpp index f7855ad799..f34e692792 100644 --- a/cocos/2d/CCParticleSystem.cpp +++ b/cocos/2d/CCParticleSystem.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -350,18 +351,15 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& { string textureDir = textureName.substr(0, rPos + 1); - if (dirname.size()>0 && textureDir != dirname) + if (!dirname.empty() && textureDir != dirname) { textureName = textureName.substr(rPos+1); textureName = dirname + textureName; } } - else + else if (!dirname.empty() && !textureName.empty()) { - if (dirname.size()>0) - { - textureName = dirname + textureName; - } + textureName = dirname + textureName; } Texture2D *tex = nullptr; @@ -371,7 +369,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& // set not pop-up message box when load image failed bool notify = FileUtils::getInstance()->isPopupNotify(); FileUtils::getInstance()->setPopupNotify(false); - tex = Director::getInstance()->getTextureCache()->addImage(textureName.c_str()); + tex = Director::getInstance()->getTextureCache()->addImage(textureName); // reset the value of UIImage notify FileUtils::getInstance()->setPopupNotify(notify); } @@ -408,10 +406,12 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string& image->release(); } } - if (_configName.length()>0) + + if (!_configName.empty()) { - _yCoordFlipped = dictionary["yCoordFlipped"].asInt(); + _yCoordFlipped = dictionary["yCoordFlipped"].asInt(); } + CCASSERT( this->_texture != nullptr, "CCParticleSystem: error loading the texture"); } ret = true; diff --git a/cocos/2d/CCParticleSystem.h b/cocos/2d/CCParticleSystem.h index c09dc527a6..32c362ecf3 100644 --- a/cocos/2d/CCParticleSystem.h +++ b/cocos/2d/CCParticleSystem.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCParticleSystemQuad.cpp b/cocos/2d/CCParticleSystemQuad.cpp index 30a45644e0..579db6c024 100644 --- a/cocos/2d/CCParticleSystemQuad.cpp +++ b/cocos/2d/CCParticleSystemQuad.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Leonardo Kasperavičius +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -35,7 +36,6 @@ THE SOFTWARE. #include "ccGLStateCache.h" #include "CCGLProgram.h" #include "TransformUtils.h" -#include "CCNotificationCenter.h" #include "CCEventType.h" #include "CCConfiguration.h" #include "CCRenderer.h" @@ -44,6 +44,8 @@ THE SOFTWARE. // extern #include "kazmath/GL/matrix.h" +#include "CCEventListenerCustom.h" +#include "CCEventDispatcher.h" NS_CC_BEGIN @@ -74,10 +76,8 @@ bool ParticleSystemQuad::initWithTotalParticles(int numberOfParticles) #if CC_ENABLE_CACHE_TEXTURE_DATA // Need to listen the event only when not use batchnode, because it will use VBO - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(ParticleSystemQuad::listenBackToForeground), - EVNET_COME_TO_FOREGROUND, - nullptr); + auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(ParticleSystemQuad::listenBackToForeground, this)); + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); #endif return true; @@ -106,10 +106,6 @@ ParticleSystemQuad::~ParticleSystemQuad() GL::bindVAO(0); } } - -#if CC_ENABLE_CACHE_TEXTURE_DATA - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); -#endif } // implementation ParticleSystemQuad @@ -576,7 +572,7 @@ void ParticleSystemQuad::setupVBO() CHECK_GL_ERROR_DEBUG(); } -void ParticleSystemQuad::listenBackToForeground(Object *obj) +void ParticleSystemQuad::listenBackToForeground(EventCustom* event) { if (Configuration::getInstance()->supportsShareableVAO()) { diff --git a/cocos/2d/CCParticleSystemQuad.h b/cocos/2d/CCParticleSystemQuad.h index e5f54d0837..42c338b304 100644 --- a/cocos/2d/CCParticleSystemQuad.h +++ b/cocos/2d/CCParticleSystemQuad.h @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Leonardo Kasperavičius +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -33,6 +34,7 @@ THE SOFTWARE. NS_CC_BEGIN class SpriteFrame; +class EventCustom; /** * @addtogroup particle_nodes @@ -81,14 +83,8 @@ public: * @js NA * @lua NA */ - void listenBackToForeground(Object *obj); + void listenBackToForeground(EventCustom* event); - // Overrides - /** - * @js NA - * @lua NA - */ - virtual bool initWithTotalParticles(int numberOfParticles) override; /** * @js NA * @lua NA @@ -139,6 +135,13 @@ protected: /** initializes the texture with a rectangle measured Points */ void initTexCoordsWithRect(const Rect& rect); + + // Overrides + /** + * @js NA + * @lua NA + */ + virtual bool initWithTotalParticles(int numberOfParticles) override; void setupVBOandVAO(); void setupVBO(); diff --git a/cocos/2d/CCProfiling.cpp b/cocos/2d/CCProfiling.cpp index c7d9c606e5..3f6979a951 100644 --- a/cocos/2d/CCProfiling.cpp +++ b/cocos/2d/CCProfiling.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Stuart Carnie +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCProfiling.h b/cocos/2d/CCProfiling.h index 8c122c8679..97f1a7c92d 100644 --- a/cocos/2d/CCProfiling.h +++ b/cocos/2d/CCProfiling.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Stuart Carnie +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCProgressTimer.cpp b/cocos/2d/CCProgressTimer.cpp index ee783e0e82..7d135a9016 100644 --- a/cocos/2d/CCProgressTimer.cpp +++ b/cocos/2d/CCProgressTimer.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Lam Pham +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc http://www.cocos2d-x.org @@ -227,6 +228,28 @@ Point ProgressTimer::getMidpoint() const return _midpoint; } +void ProgressTimer::setColor(const Color3B &color) +{ + _sprite->setColor(color); + updateColor(); +} + +const Color3B& ProgressTimer::getColor() const +{ + return _sprite->getColor(); +} + +void ProgressTimer::setOpacity(GLubyte opacity) +{ + _sprite->setOpacity(opacity); + updateColor(); +} + +GLubyte ProgressTimer::getOpacity() const +{ + return _sprite->getOpacity(); +} + void ProgressTimer::setMidpoint(const Point& midPoint) { _midpoint = midPoint.getClampPoint(Point::ZERO, Point(1, 1)); diff --git a/cocos/2d/CCProgressTimer.h b/cocos/2d/CCProgressTimer.h index 5ed9308e81..5ca74f5458 100644 --- a/cocos/2d/CCProgressTimer.h +++ b/cocos/2d/CCProgressTimer.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Lam Pham +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -110,8 +111,12 @@ public: inline Point getBarChangeRate() const { return _barChangeRate; } // Overrides - virtual void draw(void) override; - void setAnchorPoint(const Point& anchorPoint) override; + virtual void draw() override; + virtual void setAnchorPoint(const Point& anchorPoint) override; + virtual void setColor(const Color3B &color) override; + virtual const Color3B& getColor() const override; + virtual void setOpacity(GLubyte opacity) override; + virtual GLubyte getOpacity() const override; protected: /** diff --git a/cocos/2d/CCProtocols.h b/cocos/2d/CCProtocols.h index 54282b36f7..0e93f8328c 100644 --- a/cocos/2d/CCProtocols.h +++ b/cocos/2d/CCProtocols.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index 146c39e050..efaad582ef 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Jason Booth +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -34,7 +35,6 @@ THE SOFTWARE. #include "CCTextureCache.h" #include "platform/CCFileUtils.h" #include "CCGL.h" -#include "CCNotificationCenter.h" #include "CCEventType.h" #include "CCGrid.h" @@ -44,6 +44,8 @@ THE SOFTWARE. // extern #include "kazmath/GL/matrix.h" +#include "CCEventListenerCustom.h" +#include "CCEventDispatcher.h" NS_CC_BEGIN @@ -66,15 +68,11 @@ RenderTexture::RenderTexture() #if CC_ENABLE_CACHE_TEXTURE_DATA // Listen this event to save render texture before come to background. // Then it can be restored after coming to foreground on Android. - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(RenderTexture::listenToBackground), - EVENT_COME_TO_BACKGROUND, - nullptr); - - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(RenderTexture::listenToForeground), - EVNET_COME_TO_FOREGROUND, // this is misspelt - nullptr); + auto toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(RenderTexture::listenToBackground, this)); + _eventDispatcher->addEventListenerWithSceneGraphPriority(toBackgroundListener, this); + + auto toForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(RenderTexture::listenToForeground, this)); + _eventDispatcher->addEventListenerWithSceneGraphPriority(toForegroundListener, this); #endif } @@ -89,14 +87,9 @@ RenderTexture::~RenderTexture() glDeleteRenderbuffers(1, &_depthRenderBufffer); } CC_SAFE_DELETE(_UITextureImage); - -#if CC_ENABLE_CACHE_TEXTURE_DATA - NotificationCenter::getInstance()->removeObserver(this, EVENT_COME_TO_BACKGROUND); - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); -#endif } -void RenderTexture::listenToBackground(cocos2d::Object *obj) +void RenderTexture::listenToBackground(EventCustom *event) { #if CC_ENABLE_CACHE_TEXTURE_DATA CC_SAFE_DELETE(_UITextureImage); @@ -124,7 +117,7 @@ void RenderTexture::listenToBackground(cocos2d::Object *obj) #endif } -void RenderTexture::listenToForeground(cocos2d::Object *obj) +void RenderTexture::listenToForeground(EventCustom *event) { #if CC_ENABLE_CACHE_TEXTURE_DATA // -- regenerate frame buffer object and attach the texture @@ -506,7 +499,7 @@ void RenderTexture::onBegin() float heightRatio = size.height / texSize.height; // Adjust the orthographic projection and viewport - glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height); + glViewport(0, 0, (GLsizei)size.width, (GLsizei)size.height); kmMat4 orthoMatrix; @@ -639,6 +632,21 @@ void RenderTexture::begin() kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPushMatrix(); kmGLGetMatrix(KM_GL_MODELVIEW, &_transformMatrix); + + Director *director = Director::getInstance(); + director->setProjection(director->getProjection()); + + const Size& texSize = _texture->getContentSizeInPixels(); + + // Calculate the adjustment ratios based on the old and new projections + Size size = director->getWinSizeInPixels(); + float widthRatio = size.width / texSize.width; + float heightRatio = size.height / texSize.height; + + kmMat4 orthoMatrix; + kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio, + (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 ); + kmGLMultMatrix(&orthoMatrix); _groupCommand.init(0, _vertexZ); @@ -660,6 +668,12 @@ void RenderTexture::end() Renderer *renderer = Director::getInstance()->getRenderer(); renderer->addCommand(&_endCommand); renderer->popGroup(); + + kmGLMatrixMode(KM_GL_PROJECTION); + kmGLPopMatrix(); + + kmGLMatrixMode(KM_GL_MODELVIEW); + kmGLPopMatrix(); } NS_CC_END diff --git a/cocos/2d/CCRenderTexture.h b/cocos/2d/CCRenderTexture.h index fdf4910d4e..0d25d91002 100644 --- a/cocos/2d/CCRenderTexture.h +++ b/cocos/2d/CCRenderTexture.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Jason Booth +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -34,6 +35,8 @@ THE SOFTWARE. NS_CC_BEGIN +class EventCustom; + /** * @addtogroup textures * @{ @@ -111,12 +114,12 @@ public: /** Listen "come to background" message, and save render texture. It only has effect on Android. */ - void listenToBackground(Object *obj); + void listenToBackground(EventCustom *event); /** Listen "come to foreground" message and restore the frame buffer object It only has effect on Android. */ - void listenToForeground(Object *obj); + void listenToForeground(EventCustom *event); /** Valid flags: GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT. They can be OR'ed. Valid when "autoDraw" is true. */ inline unsigned int getClearFlags() const { return _clearFlags; }; diff --git a/cocos/2d/CCScene.cpp b/cocos/2d/CCScene.cpp index 2dcf75283c..a03a1b0fbc 100644 --- a/cocos/2d/CCScene.cpp +++ b/cocos/2d/CCScene.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCScene.h b/cocos/2d/CCScene.h index 21576a87a7..a99912b3f9 100644 --- a/cocos/2d/CCScene.h +++ b/cocos/2d/CCScene.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCScheduler.cpp b/cocos/2d/CCScheduler.cpp index 28353ec368..2495fd930e 100644 --- a/cocos/2d/CCScheduler.cpp +++ b/cocos/2d/CCScheduler.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCScheduler.h b/cocos/2d/CCScheduler.h index 3146729205..21ed5abd6d 100644 --- a/cocos/2d/CCScheduler.h +++ b/cocos/2d/CCScheduler.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCScriptSupport.cpp b/cocos/2d/CCScriptSupport.cpp index 0668b9ff6b..4857638889 100644 --- a/cocos/2d/CCScriptSupport.cpp +++ b/cocos/2d/CCScriptSupport.cpp @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCScriptSupport.h b/cocos/2d/CCScriptSupport.h index 07a01923fd..631df08d08 100644 --- a/cocos/2d/CCScriptSupport.h +++ b/cocos/2d/CCScriptSupport.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -41,7 +42,6 @@ NS_CC_BEGIN class Timer; class Layer; class MenuItem; -class NotificationCenter; class CallFunc; class Acceleration; @@ -427,6 +427,14 @@ public: * @lua NA */ virtual bool handleAssert(const char *msg) = 0; + + enum class ConfigType + { + NONE, + COCOSTUDIO + }; + /** Parse configuration file */ + virtual bool parseConfig(ConfigType type, const std::string& str) = 0; }; /** diff --git a/cocos/2d/CCShaderCache.cpp b/cocos/2d/CCShaderCache.cpp index 5c751aa843..fc06d2d985 100644 --- a/cocos/2d/CCShaderCache.cpp +++ b/cocos/2d/CCShaderCache.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -36,6 +37,7 @@ enum { kShaderType_PositionTextureColor_noMVP, kShaderType_PositionTextureColorAlphaTest, kShaderType_PositionColor, + kShaderType_PositionColor_noMVP, kShaderType_PositionTexture, kShaderType_PositionTexture_uColor, kShaderType_PositionTextureA8Color, @@ -124,6 +126,13 @@ void ShaderCache::loadDefaultShaders() loadDefaultShader(p, kShaderType_PositionColor); _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_COLOR, p) ); + // + // Position, Color shader no MVP + // + p = new GLProgram(); + loadDefaultShader(p, kShaderType_PositionColor_noMVP); + _programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP, p) ); + // // Position Texture shader // @@ -202,6 +211,12 @@ void ShaderCache::reloadDefaultShaders() p->reset(); loadDefaultShader(p, kShaderType_PositionColor); + // + // Position, Color shader no MVP + // + p = getProgram(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP); + loadDefaultShader(p, kShaderType_PositionColor_noMVP); + // // Position Texture shader // @@ -275,7 +290,7 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type) break; case kShaderType_PositionTextureColorAlphaTest: - p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag); + p->initWithVertexShaderByteArray(ccPositionTextureColor_noMVP_vert, ccPositionTextureColorAlphaTest_frag); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); @@ -288,6 +303,12 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type) p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); + break; + case kShaderType_PositionColor_noMVP: + p->initWithVertexShaderByteArray(ccPositionTextureColor_noMVP_vert ,ccPositionColor_frag); + + p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); break; case kShaderType_PositionTexture: p->initWithVertexShaderByteArray(ccPositionTexture_vert ,ccPositionTexture_frag); diff --git a/cocos/2d/CCShaderCache.h b/cocos/2d/CCShaderCache.h index ee65bc33b9..98f08dcc33 100644 --- a/cocos/2d/CCShaderCache.h +++ b/cocos/2d/CCShaderCache.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCSprite.cpp b/cocos/2d/CCSprite.cpp index 0e1f7c10aa..271f1e8db9 100644 --- a/cocos/2d/CCSprite.cpp +++ b/cocos/2d/CCSprite.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCSprite.h b/cocos/2d/CCSprite.h index 3b99769c07..0a937a64e1 100644 --- a/cocos/2d/CCSprite.h +++ b/cocos/2d/CCSprite.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -230,8 +231,8 @@ public: /** * Sets a new SpriteFrame to the Sprite. */ - virtual void setSpriteFrame(SpriteFrame* newFrame); virtual void setSpriteFrame(const std::string &spriteFrameName); + virtual void setSpriteFrame(SpriteFrame* newFrame); /** @deprecated Use `setSpriteFrame()` instead. */ CC_DEPRECATED_ATTRIBUTE virtual void setDisplayFrame(SpriteFrame *newFrame) { setSpriteFrame(newFrame); } diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 41d57735cf..3ef2e183e9 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2009 Matt Oswald +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -97,8 +98,8 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity) _children.reserve(capacity); _descendants.reserve(capacity); - - setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); + + setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP)); return true; } @@ -355,15 +356,13 @@ void SpriteBatchNode::draw() for(const auto &child: _children) child->updateTransform(); - auto shader = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP); - kmMat4 mv; kmGLGetMatrix(KM_GL_MODELVIEW, &mv); _quadCommand.init(0, _vertexZ, _textureAtlas->getTexture()->getName(), - shader, + _shaderProgram, _blendFunc, _textureAtlas->getQuads(), _textureAtlas->getTotalQuads(), @@ -378,9 +377,9 @@ void SpriteBatchNode::increaseAtlasCapacity(void) // this is likely computationally expensive ssize_t quantity = (_textureAtlas->getCapacity() + 1) * 4 / 3; - CCLOG("cocos2d: SpriteBatchNode: resizing TextureAtlas capacity from [%zd] to [%zd].", - _textureAtlas->getCapacity(), - quantity); + CCLOG("cocos2d: SpriteBatchNode: resizing TextureAtlas capacity from [%d] to [%d].", + static_cast(_textureAtlas->getCapacity()), + static_cast(quantity)); if (! _textureAtlas->resizeCapacity(quantity)) { diff --git a/cocos/2d/CCSpriteBatchNode.h b/cocos/2d/CCSpriteBatchNode.h index 28c7b382aa..fc140aa391 100644 --- a/cocos/2d/CCSpriteBatchNode.h +++ b/cocos/2d/CCSpriteBatchNode.h @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada -Copyright (C) 2009 Matt Oswald +Copyright (c) 2009 Matt Oswald +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCSpriteFrame.cpp b/cocos/2d/CCSpriteFrame.cpp index 63dce33227..611318b43e 100644 --- a/cocos/2d/CCSpriteFrame.cpp +++ b/cocos/2d/CCSpriteFrame.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2011 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCSpriteFrame.h b/cocos/2d/CCSpriteFrame.h index 7c403c33ef..05c96d7e2a 100644 --- a/cocos/2d/CCSpriteFrame.h +++ b/cocos/2d/CCSpriteFrame.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2011 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp index c607da7194..a2b289ced6 100644 --- a/cocos/2d/CCSpriteFrameCache.cpp +++ b/cocos/2d/CCSpriteFrameCache.cpp @@ -1,9 +1,10 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Jason Booth Copyright (c) 2009 Robert J Payne +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCSpriteFrameCache.h b/cocos/2d/CCSpriteFrameCache.h index d9fff83c08..df346c76bd 100644 --- a/cocos/2d/CCSpriteFrameCache.h +++ b/cocos/2d/CCSpriteFrameCache.h @@ -1,9 +1,10 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Jason Booth Copyright (c) 2009 Robert J Payne +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTMXLayer.cpp b/cocos/2d/CCTMXLayer.cpp index b38026dae8..53aec1b035 100644 --- a/cocos/2d/CCTMXLayer.cpp +++ b/cocos/2d/CCTMXLayer.cpp @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -61,14 +62,12 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la texture = Director::getInstance()->getTextureCache()->addImage(tilesetInfo->_sourceImage.c_str()); } - if (SpriteBatchNode::initWithTexture(texture, (unsigned int)capacity)) + if (SpriteBatchNode::initWithTexture(texture, static_cast(capacity))) { // layerInfo _layerName = layerInfo->_name; _layerSize = size; _tiles = layerInfo->_tiles; - _minGID = layerInfo->_minGID; - _maxGID = layerInfo->_maxGID; _opacity = layerInfo->_opacity; setProperties(layerInfo->getProperties()); _contentScaleFactor = Director::getInstance()->getContentScaleFactor(); @@ -85,7 +84,7 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la Point offset = this->calculateLayerOffset(layerInfo->_offset); this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset)); - _atlasIndexArray = ccCArrayNew((unsigned int)totalNumberOfTiles); + _atlasIndexArray = ccCArrayNew(totalNumberOfTiles); this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(Size(_layerSize.width * _mapTileSize.width, _layerSize.height * _mapTileSize.height))); @@ -100,8 +99,6 @@ bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *la TMXLayer::TMXLayer() :_layerName("") ,_opacity(0) -,_minGID(0) -,_maxGID(0) ,_vertexZvalue(0) ,_useAutomaticVertexZ(false) ,_reusedTile(nullptr) @@ -161,12 +158,12 @@ void TMXLayer::setupTiles() // Parse cocos2d properties this->parseInternalProperties(); - for (unsigned int y=0; y < _layerSize.height; y++) + for (int y=0; y < _layerSize.height; y++) { - for (unsigned int x=0; x < _layerSize.width; x++) + for (int x=0; x < _layerSize.width; x++) { - unsigned int pos = (unsigned int)(x + _layerSize.width * y); - unsigned int gid = _tiles[ pos ]; + int pos = static_cast(x + _layerSize.width * y); + int gid = _tiles[ pos ]; // gid are stored in little endian. // if host is big endian, then swap @@ -178,16 +175,9 @@ void TMXLayer::setupTiles() if (gid != 0) { this->appendTileForGID(gid, Point(x, y)); - - // Optimization: update min and max GID rendered by the layer - _minGID = MIN(gid, _minGID); - _maxGID = MAX(gid, _maxGID); } } } - - CCASSERT( _maxGID >= _tileSet->_firstGid && - _minGID >= _tileSet->_firstGid, "TMX: Only 1 tileset per layer is supported"); } // TMXLayer - Properties @@ -231,7 +221,7 @@ void TMXLayer::parseInternalProperties() } } -void TMXLayer::setupTileSprite(Sprite* sprite, Point pos, unsigned int gid) +void TMXLayer::setupTileSprite(Sprite* sprite, Point pos, int gid) { sprite->setPosition(getPositionAt(pos)); sprite->setVertexZ((float)getVertexZForPos(pos)); @@ -252,7 +242,7 @@ void TMXLayer::setupTileSprite(Sprite* sprite, Point pos, unsigned int gid) sprite->setPosition(Point(getPositionAt(pos).x + sprite->getContentSize().height/2, getPositionAt(pos).y + sprite->getContentSize().width/2 ) ); - unsigned int flag = gid & (kTMXTileHorizontalFlag | kTMXTileVerticalFlag ); + int flag = gid & (kTMXTileHorizontalFlag | kTMXTileVerticalFlag ); // handle the 4 diagonally flipped states. if (flag == kTMXTileHorizontalFlag) @@ -319,7 +309,7 @@ Sprite * TMXLayer::getTileAt(const Point& pos) CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); Sprite *tile = nullptr; - unsigned int gid = this->getTileGIDAt(pos); + int gid = this->getTileGIDAt(pos); // if GID == 0, then no tile is present if (gid) @@ -348,14 +338,14 @@ Sprite * TMXLayer::getTileAt(const Point& pos) return tile; } -unsigned int TMXLayer::getTileGIDAt(const Point& pos, ccTMXTileFlags* flags/* = nullptr*/) +int TMXLayer::getTileGIDAt(const Point& pos, ccTMXTileFlags* flags/* = nullptr*/) { CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); - int idx = (int)(pos.x + pos.y * _layerSize.width); + int idx = static_cast((pos.x + pos.y * _layerSize.width)); // Bits on the far end of the 32-bit global tile ID are used for tile flags - unsigned int tile = _tiles[idx]; + int tile = _tiles[idx]; // issue1264, flipped tiles can be changed dynamically if (flags) @@ -367,42 +357,47 @@ unsigned int TMXLayer::getTileGIDAt(const Point& pos, ccTMXTileFlags* flags/* = } // TMXLayer - adding helper methods -Sprite * TMXLayer::insertTileForGID(unsigned int gid, const Point& pos) +Sprite * TMXLayer::insertTileForGID(int gid, const Point& pos) { - Rect rect = _tileSet->rectForGID(gid); - rect = CC_RECT_PIXELS_TO_POINTS(rect); - - intptr_t z = (intptr_t)(pos.x + pos.y * _layerSize.width); - - Sprite *tile = reusedTileWithRect(rect); - - setupTileSprite(tile, pos, gid); - - // get atlas index - ssize_t indexForZ = atlasIndexForNewZ(static_cast(z)); - - // Optimization: add the quad without adding a child - this->insertQuadFromSprite(tile, indexForZ); - - // insert it into the local atlasindex array - ccCArrayInsertValueAtIndex(_atlasIndexArray, (void*)z, indexForZ); - - // update possible children - - for(const auto &child : _children) { - Sprite* sp = static_cast(child); - ssize_t ai = sp->getAtlasIndex(); - if ( ai >= indexForZ ) - { - sp->setAtlasIndex(ai+1); + if (gid != 0 && (static_cast((gid & kFlippedMask)) - _tileSet->_firstGid) >= 0) + { + Rect rect = _tileSet->rectForGID(gid); + rect = CC_RECT_PIXELS_TO_POINTS(rect); + + intptr_t z = (intptr_t)(pos.x + pos.y * _layerSize.width); + + Sprite *tile = reusedTileWithRect(rect); + + setupTileSprite(tile, pos, gid); + + // get atlas index + ssize_t indexForZ = atlasIndexForNewZ(static_cast(z)); + + // Optimization: add the quad without adding a child + this->insertQuadFromSprite(tile, indexForZ); + + // insert it into the local atlasindex array + ccCArrayInsertValueAtIndex(_atlasIndexArray, (void*)z, indexForZ); + + // update possible children + + for(const auto &child : _children) { + Sprite* sp = static_cast(child); + ssize_t ai = sp->getAtlasIndex(); + if ( ai >= indexForZ ) + { + sp->setAtlasIndex(ai+1); + } } + + _tiles[z] = gid; + return tile; } - - _tiles[z] = gid; - return tile; + + return nullptr; } -Sprite * TMXLayer::updateTileForGID(unsigned int gid, const Point& pos) +Sprite * TMXLayer::updateTileForGID(int gid, const Point& pos) { Rect rect = _tileSet->rectForGID(gid); rect = Rect(rect.origin.x / _contentScaleFactor, rect.origin.y / _contentScaleFactor, rect.size.width/ _contentScaleFactor, rect.size.height/ _contentScaleFactor); @@ -424,29 +419,34 @@ Sprite * TMXLayer::updateTileForGID(unsigned int gid, const Point& pos) // used only when parsing the map. useless after the map was parsed // since lot's of assumptions are no longer true -Sprite * TMXLayer::appendTileForGID(unsigned int gid, const Point& pos) +Sprite * TMXLayer::appendTileForGID(int gid, const Point& pos) { - Rect rect = _tileSet->rectForGID(gid); - rect = CC_RECT_PIXELS_TO_POINTS(rect); - - intptr_t z = (intptr_t)(pos.x + pos.y * _layerSize.width); - - Sprite *tile = reusedTileWithRect(rect); - - setupTileSprite(tile ,pos ,gid); - - // optimization: - // The difference between appendTileForGID and insertTileforGID is that append is faster, since - // it appends the tile at the end of the texture atlas - ssize_t indexForZ = _atlasIndexArray->num; - - // don't add it using the "standard" way. - insertQuadFromSprite(tile, indexForZ); - - // append should be after addQuadFromSprite since it modifies the quantity values - ccCArrayInsertValueAtIndex(_atlasIndexArray, (void*)z, indexForZ); - - return tile; + if (gid != 0 && (static_cast((gid & kFlippedMask)) - _tileSet->_firstGid) >= 0) + { + Rect rect = _tileSet->rectForGID(gid); + rect = CC_RECT_PIXELS_TO_POINTS(rect); + + intptr_t z = (intptr_t)(pos.x + pos.y * _layerSize.width); + + Sprite *tile = reusedTileWithRect(rect); + + setupTileSprite(tile ,pos ,gid); + + // optimization: + // The difference between appendTileForGID and insertTileforGID is that append is faster, since + // it appends the tile at the end of the texture atlas + ssize_t indexForZ = _atlasIndexArray->num; + + // don't add it using the "standard" way. + insertQuadFromSprite(tile, indexForZ); + + // append should be after addQuadFromSprite since it modifies the quantity values + ccCArrayInsertValueAtIndex(_atlasIndexArray, (void*)z, indexForZ); + + return tile; + } + + return nullptr; } // TMXLayer - atlasIndex and Z @@ -455,7 +455,7 @@ static inline int compareInts(const void * a, const void * b) return ((*(int*)a) - (*(int*)b)); } -ssize_t TMXLayer::atlasIndexForExistantZ(unsigned int z) +ssize_t TMXLayer::atlasIndexForExistantZ(int z) { int key=z; int *item = (int*)bsearch((void*)&key, (void*)&_atlasIndexArray->arr[0], _atlasIndexArray->num, sizeof(void*), compareInts); @@ -483,23 +483,23 @@ ssize_t TMXLayer::atlasIndexForNewZ(int z) } // TMXLayer - adding / remove tiles -void TMXLayer::setTileGID(unsigned int gid, const Point& pos) +void TMXLayer::setTileGID(int gid, const Point& pos) { setTileGID(gid, pos, (ccTMXTileFlags)0); } -void TMXLayer::setTileGID(unsigned int gid, const Point& pos, ccTMXTileFlags flags) +void TMXLayer::setTileGID(int gid, const Point& pos, ccTMXTileFlags flags) { CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); CCASSERT(gid == 0 || gid >= _tileSet->_firstGid, "TMXLayer: invalid gid" ); ccTMXTileFlags currentFlags; - unsigned int currentGID = getTileGIDAt(pos, ¤tFlags); + int currentGID = getTileGIDAt(pos, ¤tFlags); if (currentGID != gid || currentFlags != flags) { - unsigned gidAndFlags = gid | flags; + int gidAndFlags = gid | flags; // setting gid=0 is equal to remove the tile if (gid == 0) @@ -514,7 +514,7 @@ void TMXLayer::setTileGID(unsigned int gid, const Point& pos, ccTMXTileFlags fla // modifying an existing tile with a non-empty tile else { - unsigned int z = (unsigned int)(pos.x + pos.y * _layerSize.width); + int z = pos.x + pos.y * _layerSize.width; Sprite *sprite = static_cast(getChildByTag(z)); if (sprite) { @@ -567,11 +567,11 @@ void TMXLayer::removeTileAt(const Point& pos) CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); - unsigned int gid = getTileGIDAt(pos); + int gid = getTileGIDAt(pos); if (gid) { - unsigned int z = (unsigned int)(pos.x + pos.y * _layerSize.width); + int z = pos.x + pos.y * _layerSize.width; ssize_t atlasIndex = atlasIndexForExistantZ(z); // remove tile from GID map @@ -670,17 +670,17 @@ Point TMXLayer::getPositionForHexAt(const Point& pos) int TMXLayer::getVertexZForPos(const Point& pos) { int ret = 0; - unsigned int maxVal = 0; + int maxVal = 0; if (_useAutomaticVertexZ) { switch (_layerOrientation) { case TMXOrientationIso: - maxVal = (unsigned int)(_layerSize.width + _layerSize.height); - ret = (int)(-(maxVal - (pos.x + pos.y))); + maxVal = static_cast(_layerSize.width + _layerSize.height); + ret = static_cast(-(maxVal - (pos.x + pos.y))); break; case TMXOrientationOrtho: - ret = (int)(-(_layerSize.height-pos.y)); + ret = static_cast(-(_layerSize.height-pos.y)); break; case TMXOrientationHex: CCASSERT(0, "TMX Hexa zOrder not supported"); diff --git a/cocos/2d/CCTMXLayer.h b/cocos/2d/CCTMXLayer.h index d153f6472d..eb9b9eab75 100644 --- a/cocos/2d/CCTMXLayer.h +++ b/cocos/2d/CCTMXLayer.h @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -109,8 +110,8 @@ public: /** returns the tile gid at a given tile coordinate. It also returns the tile flags. This method requires the the tile map has not been previously released (eg. don't call [layer releaseMap]) */ - unsigned int getTileGIDAt(const Point& tileCoordinate, ccTMXTileFlags* flags = nullptr); - CC_DEPRECATED_ATTRIBUTE unsigned int tileGIDAt(const Point& tileCoordinate, ccTMXTileFlags* flags = nullptr){ + int getTileGIDAt(const Point& tileCoordinate, ccTMXTileFlags* flags = nullptr); + CC_DEPRECATED_ATTRIBUTE int tileGIDAt(const Point& tileCoordinate, ccTMXTileFlags* flags = nullptr){ return getTileGIDAt(tileCoordinate, flags); }; @@ -118,7 +119,7 @@ public: The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1. If a tile is already placed at that position, then it will be removed. */ - void setTileGID(unsigned int gid, const Point& tileCoordinate); + void setTileGID(int gid, const Point& tileCoordinate); /** sets the tile gid (gid = tile global id) at a given tile coordinate. The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor -> Tileset Mgr +1. @@ -127,7 +128,7 @@ public: Use withFlags if the tile flags need to be changed as well */ - void setTileGID(unsigned int gid, const Point& tileCoordinate, ccTMXTileFlags flags); + void setTileGID(int gid, const Point& tileCoordinate, ccTMXTileFlags flags); /** removes a tile at given tile coordinate */ void removeTileAt(const Point& tileCoordinate); @@ -158,8 +159,8 @@ public: * @js NA * @lua NA */ - inline unsigned int* getTiles() const { return _tiles; }; - inline void setTiles(unsigned int* tiles) { _tiles = tiles; }; + inline int* getTiles() const { return _tiles; }; + inline void setTiles(int* tiles) { _tiles = tiles; }; /** Tileset information for the layer */ inline TMXTilesetInfo* getTileSet() const { return _tileSet; }; @@ -170,8 +171,8 @@ public: }; /** Layer orientation, which is the same as the map orientation */ - inline unsigned int getLayerOrientation() const { return _layerOrientation; }; - inline void setLayerOrientation(unsigned int orientation) { _layerOrientation = orientation; }; + inline int getLayerOrientation() const { return _layerOrientation; }; + inline void setLayerOrientation(int orientation) { _layerOrientation = orientation; }; /** properties from the layer. They can be added using Tiled */ inline const ValueMap& getProperties() const { return _properties; }; @@ -199,18 +200,18 @@ private: Point calculateLayerOffset(const Point& offset); /* optimization methods */ - Sprite* appendTileForGID(unsigned int gid, const Point& pos); - Sprite* insertTileForGID(unsigned int gid, const Point& pos); - Sprite* updateTileForGID(unsigned int gid, const Point& pos); + Sprite* appendTileForGID(int gid, const Point& pos); + Sprite* insertTileForGID(int gid, const Point& pos); + Sprite* updateTileForGID(int gid, const Point& pos); /* The layer recognizes some special properties, like cc_vertez */ void parseInternalProperties(); - void setupTileSprite(Sprite* sprite, Point pos, unsigned int gid); + void setupTileSprite(Sprite* sprite, Point pos, int gid); Sprite* reusedTileWithRect(Rect rect); int getVertexZForPos(const Point& pos); // index - ssize_t atlasIndexForExistantZ(unsigned int z); + ssize_t atlasIndexForExistantZ(int z); ssize_t atlasIndexForNewZ(int z); protected: @@ -218,10 +219,7 @@ protected: std::string _layerName; //! TMX Layer supports opacity unsigned char _opacity; - - unsigned int _minGID; - unsigned int _maxGID; - + //! Only used when vertexZ is used int _vertexZvalue; bool _useAutomaticVertexZ; @@ -238,11 +236,11 @@ protected: /** size of the map's tile (could be different from the tile's size) */ Size _mapTileSize; /** pointer to the map of tiles */ - unsigned int* _tiles; + int* _tiles; /** Tileset information for the layer */ TMXTilesetInfo* _tileSet; /** Layer orientation, which is the same as the map orientation */ - unsigned int _layerOrientation; + int _layerOrientation; /** properties from the layer. They can be added using Tiled */ ValueMap _properties; }; diff --git a/cocos/2d/CCTMXObjectGroup.cpp b/cocos/2d/CCTMXObjectGroup.cpp index 3cc08a0473..344185fc60 100644 --- a/cocos/2d/CCTMXObjectGroup.cpp +++ b/cocos/2d/CCTMXObjectGroup.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Neophit Copyright (c) 2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTMXObjectGroup.h b/cocos/2d/CCTMXObjectGroup.h index 2064b6bd67..85f0f59272 100644 --- a/cocos/2d/CCTMXObjectGroup.h +++ b/cocos/2d/CCTMXObjectGroup.h @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Neophit Copyright (c) 2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTMXTiledMap.cpp b/cocos/2d/CCTMXTiledMap.cpp index 7df4840887..33a4b77519 100644 --- a/cocos/2d/CCTMXTiledMap.cpp +++ b/cocos/2d/CCTMXTiledMap.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -122,12 +123,12 @@ TMXTilesetInfo * TMXTiledMap::tilesetForLayer(TMXLayerInfo *layerInfo, TMXMapInf tileset = *iter; if (tileset) { - for( unsigned int y=0; y < size.height; y++ ) + for( int y=0; y < size.height; y++ ) { - for( unsigned int x=0; x < size.width; x++ ) + for( int x=0; x < size.width; x++ ) { - unsigned int pos = (unsigned int)(x + size.width * y); - unsigned int gid = layerInfo->_tiles[ pos ]; + int pos = static_cast(x + size.width * y); + int gid = layerInfo->_tiles[ pos ]; // gid are stored in little endian. // if host is big endian, then swap @@ -247,7 +248,7 @@ Value TMXTiledMap::getPropertiesForGID(int GID) const std::string TMXTiledMap::getDescription() const { - return StringUtils::format("(_children.size())); } diff --git a/cocos/2d/CCTMXTiledMap.h b/cocos/2d/CCTMXTiledMap.h index 77530cf5d3..01074dd671 100644 --- a/cocos/2d/CCTMXTiledMap.h +++ b/cocos/2d/CCTMXTiledMap.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTMXXMLParser.cpp b/cocos/2d/CCTMXXMLParser.cpp index 21ef31a986..2aac324dad 100644 --- a/cocos/2d/CCTMXXMLParser.cpp +++ b/cocos/2d/CCTMXXMLParser.cpp @@ -1,8 +1,9 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2011 Максим Аксенов +Copyright (c) 2011 Максим Аксенов Copyright (c) 2009-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -43,8 +44,6 @@ TMXLayerInfo::TMXLayerInfo() : _name("") , _tiles(nullptr) , _ownTiles(true) -, _minGID(100000) -, _maxGID(0) , _offset(Point::ZERO) { } @@ -59,7 +58,7 @@ TMXLayerInfo::~TMXLayerInfo() } } -ValueMap TMXLayerInfo::getProperties() +ValueMap& TMXLayerInfo::getProperties() { return _properties; } @@ -83,7 +82,7 @@ TMXTilesetInfo::~TMXTilesetInfo() CCLOGINFO("deallocing TMXTilesetInfo: %p", this); } -Rect TMXTilesetInfo::rectForGID(unsigned int gid) +Rect TMXTilesetInfo::rectForGID(int gid) { Rect rect; rect.size = _tileSize; @@ -141,7 +140,7 @@ void TMXMapInfo::internalInit(const std::string& tmxFileName, const std::string& _storingCharacters = false; _layerAttribs = TMXLayerAttribNone; _parentElement = TMXPropertyNone; - _currentFirstGID = 0; + _currentFirstGID = -1; } bool TMXMapInfo::initWithXML(const std::string& tmxString, const std::string& resourcePath) { @@ -160,7 +159,8 @@ TMXMapInfo::TMXMapInfo() , _tileSize(Size::ZERO) , _layerAttribs(0) , _storingCharacters(false) -, _currentFirstGID(0) +, _currentFirstGID(-1) +, _recordFirstGID(true) { } @@ -265,7 +265,12 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } externalTilesetFilename = FileUtils::getInstance()->fullPathForFilename(externalTilesetFilename.c_str()); - _currentFirstGID = (unsigned int)attributeDict["firstgid"].asInt(); + _currentFirstGID = attributeDict["firstgid"].asInt(); + if (_currentFirstGID < 0) + { + _currentFirstGID = 0; + } + _recordFirstGID = false; tmxMapInfo->parseXMLFile(externalTilesetFilename.c_str()); } @@ -273,17 +278,25 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { TMXTilesetInfo *tileset = new TMXTilesetInfo(); tileset->_name = attributeDict["name"].asString(); - if (_currentFirstGID == 0) + + if (_recordFirstGID) { - tileset->_firstGid = (unsigned int)attributeDict["firstgid"].asInt(); + // unset before, so this is tmx file. + tileset->_firstGid = attributeDict["firstgid"].asInt(); + + if (tileset->_firstGid < 0) + { + tileset->_firstGid = 0; + } } else { tileset->_firstGid = _currentFirstGID; _currentFirstGID = 0; } - tileset->_spacing = (unsigned int)attributeDict["spacing"].asInt(); - tileset->_margin = (unsigned int)attributeDict["margin"].asInt(); + + tileset->_spacing = attributeDict["spacing"].asInt(); + tileset->_margin = attributeDict["margin"].asInt(); Size s; s.width = attributeDict["tilewidth"].asFloat(); s.height = attributeDict["tileheight"].asFloat(); @@ -299,20 +312,17 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { TMXLayerInfo* layer = tmxMapInfo->getLayers().back(); Size layerSize = layer->_layerSize; - unsigned int gid = (unsigned int)attributeDict["gid"].asInt(); + int gid = attributeDict["gid"].asInt(); int tilesAmount = layerSize.width*layerSize.height; do { - // Check the gid is legal or not - CC_BREAK_IF(gid == 0); - if (tilesAmount > 1) { // Check the value is all set or not - CC_BREAK_IF(layer->_tiles[tilesAmount - 2] != 0 && layer->_tiles[tilesAmount - 1] != 0); + CC_BREAK_IF(layer->_tiles[tilesAmount - 2] != -1 && layer->_tiles[tilesAmount - 1] != -1); - int currentTileIndex = tilesAmount - layer->_tiles[tilesAmount - 1] - 1; + int currentTileIndex = tilesAmount - layer->_tiles[tilesAmount - 1] - 2; layer->_tiles[currentTileIndex] = gid; if (currentTileIndex != tilesAmount - 1) @@ -322,7 +332,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } else if(tilesAmount == 1) { - if (layer->_tiles[0] == 0) + if (layer->_tiles[0] == -1) { layer->_tiles[0] = gid; } @@ -333,7 +343,6 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { TMXTilesetInfo* info = tmxMapInfo->getTilesets().back(); tmxMapInfo->setParentGID(info->_firstGid + attributeDict["id"].asInt()); - //FIXME:XXX Why insert an empty dict? tmxMapInfo->getTileProperties()[tmxMapInfo->getParentGID()] = Value(ValueMap()); tmxMapInfo->setParentElement(TMXPropertyTile); } @@ -419,10 +428,8 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) int tilesAmount = layerSize.width*layerSize.height; int *tiles = (int *) malloc(tilesAmount*sizeof(int)); - for (int i = 0; i < tilesAmount; i++) - { - tiles[i] = 0; - } + // set all value to -1 + memset(tiles, 0xFF, tilesAmount*sizeof(int)); /* Save the special index in tiles[tilesAmount - 1]; * When we load tiles, we can do this: @@ -432,10 +439,10 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) */ if (tilesAmount > 1) { - tiles[tilesAmount - 1] = tilesAmount - 1; + tiles[tilesAmount - 1] = tilesAmount - 2; } - layer->_tiles = (unsigned int*) tiles; + layer->_tiles = tiles; } else if (encoding == "base64") { @@ -536,9 +543,9 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts) } else if ( tmxMapInfo->getParentElement() == TMXPropertyTile ) { - ValueMapIntKey& dict = tmxMapInfo->getTileProperties().at(tmxMapInfo->getParentGID()).asIntKeyMap(); + ValueMap& dict = tmxMapInfo->getTileProperties().at(tmxMapInfo->getParentGID()).asValueMap(); - int propertyName = attributeDict["name"].asInt(); + std::string propertyName = attributeDict["name"].asString(); dict[propertyName] = attributeDict["value"]; } } @@ -678,11 +685,11 @@ void TMXMapInfo::endElement(void *ctx, const char *name) return; } - layer->_tiles = (unsigned int*) deflated; + layer->_tiles = reinterpret_cast(deflated); } else { - layer->_tiles = (unsigned int*) buffer; + layer->_tiles = reinterpret_cast(buffer); } tmxMapInfo->setCurrentString(""); @@ -693,11 +700,19 @@ void TMXMapInfo::endElement(void *ctx, const char *name) Size layerSize = layer->_layerSize; int tilesAmount = layerSize.width * layerSize.height; - //reset the layer->_tiles[tilesAmount - 1] - if (tilesAmount > 1 && layer->_tiles[tilesAmount - 2] == 0) + //set all the tiles unseted to 0 + if (tilesAmount > 1 && layer->_tiles[tilesAmount - 2] == -1) + { + for (int i = tilesAmount - layer->_tiles[tilesAmount - 1] - 2; i < tilesAmount; ++i) + { + layer->_tiles[i] = 0; + } + } + else if (layer->_tiles[tilesAmount - 1] == -1) { layer->_tiles[tilesAmount - 1] = 0; } + } } @@ -721,6 +736,10 @@ void TMXMapInfo::endElement(void *ctx, const char *name) // The object element has ended tmxMapInfo->setParentElement(TMXPropertyNone); } + else if (elementName == "tileset") + { + _recordFirstGID = true; + } } void TMXMapInfo::textHandler(void *ctx, const char *ch, int len) diff --git a/cocos/2d/CCTMXXMLParser.h b/cocos/2d/CCTMXXMLParser.h index ddb2398b94..621a197734 100644 --- a/cocos/2d/CCTMXXMLParser.h +++ b/cocos/2d/CCTMXXMLParser.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -102,17 +103,15 @@ public: virtual ~TMXLayerInfo(); void setProperties(ValueMap properties); - ValueMap getProperties(); + ValueMap& getProperties(); ValueMap _properties; std::string _name; Size _layerSize; - unsigned int *_tiles; + int *_tiles; bool _visible; unsigned char _opacity; bool _ownTiles; - unsigned int _minGID; - unsigned int _maxGID; Point _offset; }; @@ -130,14 +129,14 @@ class CC_DLL TMXTilesetInfo : public Object { public: std::string _name; - unsigned int _firstGid; - Size _tileSize; - unsigned int _spacing; - unsigned int _margin; + int _firstGid; + Size _tileSize; + int _spacing; + int _margin; //! filename containing the tiles (should be spritesheet / texture atlas) std::string _sourceImage; //! size in pixels of the image - Size _imageSize; + Size _imageSize; public: /** * @js ctor @@ -148,7 +147,7 @@ public: * @lua NA */ virtual ~TMXTilesetInfo(); - Rect rectForGID(unsigned int gid); + Rect rectForGID(int gid); }; /** @brief TMXMapInfo contains the information about the map like: @@ -238,8 +237,8 @@ public: inline void setParentElement(int element) { _parentElement = element; }; /// parent GID - inline unsigned int getParentGID() const { return _parentGID; }; - inline void setParentGID(unsigned int gid) { _parentGID = gid; }; + inline int getParentGID() const { return _parentGID; }; + inline void setParentGID(int gid) { _parentGID = gid; }; /// layer attribs inline int getLayerAttribs() const { return _layerAttribs; }; @@ -296,7 +295,7 @@ protected: /// parent element int _parentElement; /// parent GID - unsigned int _parentGID; + int _parentGID; /// layer attribs int _layerAttribs; /// is storing characters? @@ -312,7 +311,8 @@ protected: std::string _currentString; //! tile properties ValueMapIntKey _tileProperties; - unsigned int _currentFirstGID; + int _currentFirstGID; + bool _recordFirstGID; }; // end of tilemap_parallax_nodes group diff --git a/cocos/2d/CCTextFieldTTF.cpp b/cocos/2d/CCTextFieldTTF.cpp index 4c26627956..b00a69bbdb 100644 --- a/cocos/2d/CCTextFieldTTF.cpp +++ b/cocos/2d/CCTextFieldTTF.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -216,7 +217,7 @@ void TextFieldTTF::deleteBackward() ++deleteLen; } - if (_delegate && _delegate->onTextFieldDeleteBackward(this, _inputText.c_str() + len - deleteLen, deleteLen)) + if (_delegate && _delegate->onTextFieldDeleteBackward(this, _inputText.c_str() + len - deleteLen, static_cast(deleteLen))) { // delegate doesn't wan't to delete backwards return; diff --git a/cocos/2d/CCTextFieldTTF.h b/cocos/2d/CCTextFieldTTF.h index 5c011b18cc..b1a69ba6b2 100644 --- a/cocos/2d/CCTextFieldTTF.h +++ b/cocos/2d/CCTextFieldTTF.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTextImage.cpp b/cocos/2d/CCTextImage.cpp index 97ab7dd8a0..d47ab768d0 100644 --- a/cocos/2d/CCTextImage.cpp +++ b/cocos/2d/CCTextImage.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. - + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/CCTextImage.h b/cocos/2d/CCTextImage.h index 3cfda7e18d..1c0da97201 100644 --- a/cocos/2d/CCTextImage.h +++ b/cocos/2d/CCTextImage.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2013 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTexture2D.cpp b/cocos/2d/CCTexture2D.cpp index 09539152a7..120ffe83d5 100644 --- a/cocos/2d/CCTexture2D.cpp +++ b/cocos/2d/CCTexture2D.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008 Apple Inc. All Rights Reserved. +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTexture2D.h b/cocos/2d/CCTexture2D.h index efd9b99abc..a2e259867e 100644 --- a/cocos/2d/CCTexture2D.h +++ b/cocos/2d/CCTexture2D.h @@ -1,6 +1,7 @@ /**************************************************************************** +Copyright (c) 2008 Apple Inc. All Rights Reserved. Copyright (c) 2010-2012 cocos2d-x.org -Copyright (C) 2008 Apple Inc. All Rights Reserved. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTextureAtlas.cpp b/cocos/2d/CCTextureAtlas.cpp index f4f6422bbe..8a9818d8fc 100644 --- a/cocos/2d/CCTextureAtlas.cpp +++ b/cocos/2d/CCTextureAtlas.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -30,7 +31,6 @@ THE SOFTWARE. #include "ccMacros.h" #include "CCGLProgram.h" #include "ccGLStateCache.h" -#include "CCNotificationCenter.h" #include "CCEventType.h" #include "CCDirector.h" #include "CCGL.h" @@ -39,6 +39,8 @@ THE SOFTWARE. #include "CCTexture2D.h" #include "CCString.h" #include +#include "CCEventDispatcher.h" +#include "CCEventListenerCustom.h" //According to some tests GL_TRIANGLE_STRIP is slower, MUCH slower. Probably I'm doing something very wrong @@ -51,6 +53,9 @@ TextureAtlas::TextureAtlas() ,_dirty(false) ,_texture(nullptr) ,_quads(nullptr) +#if CC_ENABLE_CACHE_TEXTURE_DATA + ,_backToForegroundlistener(nullptr) +#endif {} TextureAtlas::~TextureAtlas() @@ -70,7 +75,7 @@ TextureAtlas::~TextureAtlas() CC_SAFE_RELEASE(_texture); #if CC_ENABLE_CACHE_TEXTURE_DATA - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); + Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener); #endif } @@ -185,10 +190,8 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, ssize_t capacity) #if CC_ENABLE_CACHE_TEXTURE_DATA // listen the event when app go to background - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(TextureAtlas::listenBackToForeground), - EVNET_COME_TO_FOREGROUND, - nullptr); + _backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(TextureAtlas::listenBackToForeground, this)); + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1); #endif this->setupIndices(); @@ -207,7 +210,7 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, ssize_t capacity) return true; } -void TextureAtlas::listenBackToForeground(Object *obj) +void TextureAtlas::listenBackToForeground(EventCustom* event) { if (Configuration::getInstance()->supportsShareableVAO()) { @@ -224,7 +227,7 @@ void TextureAtlas::listenBackToForeground(Object *obj) std::string TextureAtlas::getDescription() const { - return StringUtils::format("", _totalQuads); + return StringUtils::format("", static_cast(_totalQuads)); } diff --git a/cocos/2d/CCTextureAtlas.h b/cocos/2d/CCTextureAtlas.h index 2862b13eb0..ba9c0047ff 100644 --- a/cocos/2d/CCTextureAtlas.h +++ b/cocos/2d/CCTextureAtlas.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -35,6 +36,8 @@ THE SOFTWARE. NS_CC_BEGIN class Texture2D; +class EventCustom; +class EventListenerCustom; /** * @addtogroup textures @@ -184,7 +187,7 @@ public: void drawQuads(); /** listen the event that coming to foreground on Android */ - void listenBackToForeground(Object *obj); + void listenBackToForeground(EventCustom* event); /** whether or not the array buffer of the VBO needs to be updated*/ inline bool isDirty(void) { return _dirty; } @@ -235,6 +238,10 @@ protected: Texture2D* _texture; /** Quads that are going to be rendered */ V3F_C4B_T2F_Quad* _quads; + +#if CC_ENABLE_CACHE_TEXTURE_DATA + EventListenerCustom* _backToForegroundlistener; +#endif }; // end of textures group diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index 83a5d7fad2..4af449c8bf 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -89,10 +90,10 @@ void TextureCache::purgeSharedTextureCache() std::string TextureCache::getDescription() const { - return StringUtils::format("", _textures.size()); + return StringUtils::format("", static_cast(_textures.size())); } -void TextureCache::addImageAsync(const std::string &path, Object *target, SEL_CallFuncO selector) +void TextureCache::addImageAsync(const std::string &path, std::function callback) { Texture2D *texture = nullptr; @@ -102,9 +103,9 @@ void TextureCache::addImageAsync(const std::string &path, Object *target, SEL_Ca if( it != _textures.end() ) texture = it->second; - if (texture != nullptr && target && selector) + if (texture != nullptr) { - (target->*selector)(texture); + callback(texture); return; } @@ -127,13 +128,8 @@ void TextureCache::addImageAsync(const std::string &path, Object *target, SEL_Ca ++_asyncRefCount; - if (target) - { - target->retain(); - } - // generate async struct - AsyncStruct *data = new AsyncStruct(fullpath, target, selector); + AsyncStruct *data = new AsyncStruct(fullpath, callback); // add async struct into queue _asyncStructQueueMutex.lock(); @@ -187,7 +183,7 @@ void TextureCache::loadImage() break; } _imageInfoMutex.unlock(); - if(infoSize > 0 && pos < infoSize) + if(infoSize == 0 || pos < infoSize) generateImage = true; } @@ -243,8 +239,6 @@ void TextureCache::addImageAsyncCallBack(float dt) AsyncStruct *asyncStruct = imageInfo->asyncStruct; Image *image = imageInfo->image; - Object *target = asyncStruct->target; - SEL_CallFuncO selector = asyncStruct->selector; const std::string& filename = asyncStruct->filename; Texture2D *texture = nullptr; @@ -272,11 +266,7 @@ void TextureCache::addImageAsyncCallBack(float dt) texture = it->second; } - if (target && selector) - { - (target->*selector)(texture); - target->release(); - } + asyncStruct->callback(texture); if(image) { image->release(); diff --git a/cocos/2d/CCTextureCache.h b/cocos/2d/CCTextureCache.h index df94ff16a9..8d55c93656 100644 --- a/cocos/2d/CCTextureCache.h +++ b/cocos/2d/CCTextureCache.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -34,6 +35,7 @@ THE SOFTWARE. #include #include #include +#include #include "CCObject.h" #include "CCTexture2D.h" @@ -104,7 +106,7 @@ public: * If the filename was not previously loaded, it will create a new Texture2D * object and it will return it. It will use the filename as a key. * Otherwise it will return a reference of a previously loaded image. - * Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr, .gif + * Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr */ Texture2D* addImage(const std::string &filepath); @@ -115,7 +117,7 @@ public: * Supported image extensions: .png, .jpg * @since v0.8 */ - virtual void addImageAsync(const std::string &filepath, Object *target, SEL_CallFuncO selector); + virtual void addImageAsync(const std::string &filepath, std::function callback); /** Returns a Texture2D object given an Image. * If the image was not previously loaded, it will create a new Texture2D object and it will return it. @@ -175,11 +177,10 @@ public: struct AsyncStruct { public: - AsyncStruct(const std::string& fn, Object *t, SEL_CallFuncO s) : filename(fn), target(t), selector(s) {} + AsyncStruct(const std::string& fn, std::function f) : filename(fn), callback(f) {} std::string filename; - Object *target; - SEL_CallFuncO selector; + std::function callback; }; protected: diff --git a/cocos/2d/CCTileMapAtlas.cpp b/cocos/2d/CCTileMapAtlas.cpp index 0956677088..17dd396116 100644 --- a/cocos/2d/CCTileMapAtlas.cpp +++ b/cocos/2d/CCTileMapAtlas.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTileMapAtlas.h b/cocos/2d/CCTileMapAtlas.h index 169be3fc88..79b561026f 100644 --- a/cocos/2d/CCTileMapAtlas.h +++ b/cocos/2d/CCTileMapAtlas.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTouch.cpp b/cocos/2d/CCTouch.cpp index c7743d7e75..20629b3ef5 100644 --- a/cocos/2d/CCTouch.cpp +++ b/cocos/2d/CCTouch.cpp @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTouch.h b/cocos/2d/CCTouch.h index 1ed19d3112..e27ac187d3 100644 --- a/cocos/2d/CCTouch.h +++ b/cocos/2d/CCTouch.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index 4213232139..ed22b68651 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTransition.h b/cocos/2d/CCTransition.h index 136dafe568..471f2f1d7b 100644 --- a/cocos/2d/CCTransition.h +++ b/cocos/2d/CCTransition.h @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index a4bc2fbe15..7ade9878a4 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTransitionPageTurn.h b/cocos/2d/CCTransitionPageTurn.h index f21598c8f2..f422ef0b82 100644 --- a/cocos/2d/CCTransitionPageTurn.h +++ b/cocos/2d/CCTransitionPageTurn.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Sindesso Pty Ltd http://www.sindesso.com/ +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTransitionProgress.cpp b/cocos/2d/CCTransitionProgress.cpp index 7e9d3bbc10..5735f1bb40 100644 --- a/cocos/2d/CCTransitionProgress.cpp +++ b/cocos/2d/CCTransitionProgress.cpp @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2009 Lam Pham Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2009 Lam Pham -Copyright (c) 2012 Ricardo Quesada +Copyright (c) 2012 Ricardo Quesada +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCTransitionProgress.h b/cocos/2d/CCTransitionProgress.h index 46685b339c..cf02cb408b 100644 --- a/cocos/2d/CCTransitionProgress.h +++ b/cocos/2d/CCTransitionProgress.h @@ -1,7 +1,8 @@ /**************************************************************************** +Copyright (c) 2009 Lam Pham Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2009 Lam Pham -Copyright (c) 2012 Ricardo Quesada +Copyright (c) 2012 Ricardo Quesada +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCUserDefault.cpp b/cocos/2d/CCUserDefault.cpp index 90e721e436..536d4c1584 100644 --- a/cocos/2d/CCUserDefault.cpp +++ b/cocos/2d/CCUserDefault.cpp @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCUserDefault.h b/cocos/2d/CCUserDefault.h index b38e705e7e..82bd6ef565 100644 --- a/cocos/2d/CCUserDefault.h +++ b/cocos/2d/CCUserDefault.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCUserDefault.mm b/cocos/2d/CCUserDefault.mm index 6193113a85..5d68077ea1 100644 --- a/cocos/2d/CCUserDefault.mm +++ b/cocos/2d/CCUserDefault.mm @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCUserDefaultAndroid.cpp b/cocos/2d/CCUserDefaultAndroid.cpp index af82d29364..639aa0e702 100644 --- a/cocos/2d/CCUserDefaultAndroid.cpp +++ b/cocos/2d/CCUserDefaultAndroid.cpp @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCVertex.cpp b/cocos/2d/CCVertex.cpp index 300b50473b..7086b4b23b 100644 --- a/cocos/2d/CCVertex.cpp +++ b/cocos/2d/CCVertex.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 ForzeField Studios S.L + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CCVertex.h b/cocos/2d/CCVertex.h index b7abd7b110..bcf2d4a0d3 100644 --- a/cocos/2d/CCVertex.h +++ b/cocos/2d/CCVertex.h @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 ForzeField Studios S.L + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 429647ca8a..88090ec7c5 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -224,7 +224,7 @@ target_link_libraries(cocos2d set_target_properties(cocos2d PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/cocos/2d/TGAlib.cpp b/cocos/2d/TGAlib.cpp index 271ec91106..d37529efb3 100644 --- a/cocos/2d/TGAlib.cpp +++ b/cocos/2d/TGAlib.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/TGAlib.h b/cocos/2d/TGAlib.h index 8388d734e7..987826dd8f 100644 --- a/cocos/2d/TGAlib.h +++ b/cocos/2d/TGAlib.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/TransformUtils.cpp b/cocos/2d/TransformUtils.cpp index 85dbfc86e5..ab3d8ff09b 100644 --- a/cocos/2d/TransformUtils.cpp +++ b/cocos/2d/TransformUtils.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Valentin Milea +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/TransformUtils.h b/cocos/2d/TransformUtils.h index 1684a66cb0..83072d7ccb 100644 --- a/cocos/2d/TransformUtils.h +++ b/cocos/2d/TransformUtils.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Valentin Milea +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/ZipUtils.cpp b/cocos/2d/ZipUtils.cpp index 6f0a4de462..79c0fac4dd 100644 --- a/cocos/2d/ZipUtils.cpp +++ b/cocos/2d/ZipUtils.cpp @@ -1,6 +1,7 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/ZipUtils.h b/cocos/2d/ZipUtils.h index cbe4400c8e..3611679248 100644 --- a/cocos/2d/ZipUtils.h +++ b/cocos/2d/ZipUtils.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/base64.cpp b/cocos/2d/base64.cpp index 4ef50c659b..04b6a8350d 100644 --- a/cocos/2d/base64.cpp +++ b/cocos/2d/base64.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/base64.h b/cocos/2d/base64.h index fd95485d9e..67149d78ed 100644 --- a/cocos/2d/base64.h +++ b/cocos/2d/base64.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/ccCArray.cpp b/cocos/2d/ccCArray.cpp index dc89fbb93e..9c43756ffd 100644 --- a/cocos/2d/ccCArray.cpp +++ b/cocos/2d/ccCArray.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2007 Scott Lembcke +Copyright (c) 2010-2012 cocos2d-x.org +CopyRight (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -72,9 +73,9 @@ void ccArrayEnsureExtraCapacity(ccArray *arr, ssize_t extra) { while (arr->max < arr->num + extra) { - CCLOG("cocos2d: ccCArray: resizing ccArray capacity from [%zd] to [%zd].", - arr->max, - arr->max*2); + CCLOG("cocos2d: ccCArray: resizing ccArray capacity from [%d] to [%d].", + static_cast(arr->max), + static_cast(arr->max*2)); ccArrayDoubleCapacity(arr); } diff --git a/cocos/2d/ccCArray.h b/cocos/2d/ccCArray.h index 08228ad0fe..f069301098 100644 --- a/cocos/2d/ccCArray.h +++ b/cocos/2d/ccCArray.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2007 Scott Lembcke +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/ccConfig.h b/cocos/2d/ccConfig.h index e411a8d658..cdaceb80a0 100644 --- a/cocos/2d/ccConfig.h +++ b/cocos/2d/ccConfig.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/ccGLStateCache.cpp b/cocos/2d/ccGLStateCache.cpp index d1cc2d1d7e..97599289d1 100644 --- a/cocos/2d/ccGLStateCache.cpp +++ b/cocos/2d/ccGLStateCache.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/ccGLStateCache.h b/cocos/2d/ccGLStateCache.h index 32bf5584be..a33f8ba59d 100644 --- a/cocos/2d/ccGLStateCache.h +++ b/cocos/2d/ccGLStateCache.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2011 Ricardo Quesada -Copyright (c) 2011 Zynga Inc. + Copyright (c) 2011 Ricardo Quesada + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011 Zynga Inc. + Copyright (C) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/ccMacros.h b/cocos/2d/ccMacros.h index 6332ae6078..e15f4907a3 100644 --- a/cocos/2d/ccMacros.h +++ b/cocos/2d/ccMacros.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -31,7 +32,7 @@ THE SOFTWARE. #define _USE_MATH_DEFINES #endif -#include "platform/CCCommon.h" +#include "CCConsole.h" #include "CCStdC.h" #ifndef CCASSERT diff --git a/cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h b/cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h index fb511ba1dd..bae95bcfea 100644 --- a/cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h +++ b/cocos/2d/ccShader_PositionTextureColor_noMVP_vert.h @@ -38,7 +38,7 @@ varying vec2 v_texCoord; \n\ \n\ void main() \n\ { \n\ - gl_Position = a_position; \n\ + gl_Position = CC_PMatrix * a_position; \n\ v_fragmentColor = a_color; \n\ v_texCoord = a_texCoord; \n\ } \n\ diff --git a/cocos/2d/ccShaders.cpp b/cocos/2d/ccShaders.cpp index 95d04a4995..38d22e1c44 100644 --- a/cocos/2d/ccShaders.cpp +++ b/cocos/2d/ccShaders.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/ccShaders.h b/cocos/2d/ccShaders.h index e086fef68d..97fc404b95 100644 --- a/cocos/2d/ccShaders.h +++ b/cocos/2d/ccShaders.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/ccTypes.cpp b/cocos/2d/ccTypes.cpp index da1430110d..b0bfefc710 100644 --- a/cocos/2d/ccTypes.cpp +++ b/cocos/2d/ccTypes.cpp @@ -1,5 +1,8 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/ccTypes.h b/cocos/2d/ccTypes.h index 7083a34d6e..98219eaddf 100644 --- a/cocos/2d/ccTypes.h +++ b/cocos/2d/ccTypes.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/ccUTF8.cpp b/cocos/2d/ccUTF8.cpp index 4d31700b85..6e70a313d5 100644 --- a/cocos/2d/ccUTF8.cpp +++ b/cocos/2d/ccUTF8.cpp @@ -3,8 +3,9 @@ * * gutf8.c - Operations on UTF-8 strings. * - * Copyright (C) 1999 Tom Tromey - * Copyright (C) 2000 Red Hat, Inc. + * Copyright (C) 1999 Tom Tromey + * Copyright (C) 2000 Red Hat, Inc. + * Copyright (c) 2013-2014 Chukong Technologies Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,6 +25,7 @@ #include "ccUTF8.h" #include "platform/CCCommon.h" +#include "CCConsole.h" NS_CC_BEGIN @@ -318,10 +320,10 @@ std::vector cc_utf16_vec_from_utf16_str(const unsigned short* st * Return value: number of bytes written **/ int -cc_unichar_to_utf8 (unsigned short c, +cc_unichar_to_utf8 (unsigned int c, char *outbuf) { - unsigned int len = 0; + int len = 0; int first; int i; @@ -335,23 +337,21 @@ cc_unichar_to_utf8 (unsigned short c, first = 0xc0; len = 2; } - // XXX FIXME - // These conditions are alwasy true. -// else if (c < 0x10000) -// { -// first = 0xe0; -// len = 3; -// } -// else if (c < 0x200000) -// { -// first = 0xf0; -// len = 4; -// } -// else if (c < 0x4000000) -// { -// first = 0xf8; -// len = 5; -// } + else if (c < 0x10000) + { + first = 0xe0; + len = 3; + } + else if (c < 0x200000) + { + first = 0xf0; + len = 4; + } + else if (c < 0x4000000) + { + first = 0xf8; + len = 5; + } else { first = 0xfc; @@ -400,7 +400,7 @@ cc_unichar_to_utf8 (unsigned short c, **/ char * cc_utf16_to_utf8 (const unsigned short *str, - long len, + int len, long *items_read, long *items_written) { @@ -411,7 +411,7 @@ cc_utf16_to_utf8 (const unsigned short *str, char *out; char *result = nullptr; int n_bytes; - unsigned short high_surrogate; + unsigned int high_surrogate; if (str == 0) return nullptr; @@ -421,7 +421,7 @@ cc_utf16_to_utf8 (const unsigned short *str, while ((len < 0 || in - str < len) && *in) { unsigned short c = *in; - unsigned short wc; + unsigned int wc; if (c >= 0xdc00 && c < 0xe000) /* low surrogate */ { @@ -454,7 +454,7 @@ cc_utf16_to_utf8 (const unsigned short *str, } /********** DIFFERENT for UTF8/UCS4 **********/ - n_bytes += UTF8_LENGTH (static_cast(wc)); + n_bytes += UTF8_LENGTH (wc); next1: in++; @@ -477,7 +477,7 @@ cc_utf16_to_utf8 (const unsigned short *str, while (out < result + n_bytes) { unsigned short c = *in; - unsigned short wc; + unsigned int wc; if (c >= 0xdc00 && c < 0xe000) /* low surrogate */ { diff --git a/cocos/2d/ccUTF8.h b/cocos/2d/ccUTF8.h index bb5b159fe7..352a4db41a 100644 --- a/cocos/2d/ccUTF8.h +++ b/cocos/2d/ccUTF8.h @@ -1,9 +1,23 @@ -// -// ccUTF8.h -// cocos2dx -// -// Created by James Chen on 2/27/13. -// +/* + * Copyright (C) 1999 Tom Tromey + * Copyright (C) 2000 Red Hat, Inc. + * Copyright (c) 2013-2014 Chukong Technologies Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ #ifndef __cocos2dx__ccUTF8__ #define __cocos2dx__ccUTF8__ @@ -80,7 +94,7 @@ CC_DLL unsigned short* cc_utf8_to_utf16(const char* str_old, int length = -1, in **/ CC_DLL char * cc_utf16_to_utf8 (const unsigned short *str, - long len, + int len, long *items_read, long *items_written); diff --git a/cocos/2d/ccUtils.cpp b/cocos/2d/ccUtils.cpp index e9d6eedf4a..3201054332 100644 --- a/cocos/2d/ccUtils.cpp +++ b/cocos/2d/ccUtils.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/ccUtils.h b/cocos/2d/ccUtils.h index 3379db33bf..a30cc72288 100644 --- a/cocos/2d/ccUtils.h +++ b/cocos/2d/ccUtils.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/cocos2d.cpp b/cocos/2d/cocos2d.cpp index 1c754fd45b..99adc6518c 100644 --- a/cocos/2d/cocos2d.cpp +++ b/cocos/2d/cocos2d.cpp @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -30,7 +31,7 @@ NS_CC_BEGIN const char* cocos2dVersion() { - return "3.0-beta0-pre"; + return "3.0-beta"; } NS_CC_END diff --git a/cocos/2d/cocos2d.h b/cocos/2d/cocos2d.h index 1dfdcba511..3476f536a5 100644 --- a/cocos/2d/cocos2d.h +++ b/cocos/2d/cocos2d.h @@ -1,7 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -111,6 +112,7 @@ THE SOFTWARE. #include "CCMotionStreak.h" #include "CCProgressTimer.h" #include "CCRenderTexture.h" +#include "CCNodeGrid.h" // particle_nodes #include "CCParticleBatchNode.h" diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index 02b11faac0..90be6eac6d 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -81,7 +81,7 @@ Level3 - EditAndContinue + OldStyle 4267;4251;4244;%(DisableSpecificWarnings) true diff --git a/cocos/2d/platform/CCApplicationProtocol.h b/cocos/2d/platform/CCApplicationProtocol.h index bd88cc0646..9042c649d0 100644 --- a/cocos/2d/platform/CCApplicationProtocol.h +++ b/cocos/2d/platform/CCApplicationProtocol.h @@ -1,3 +1,28 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + #ifndef __CC_APPLICATION_PROTOCOL_H__ #define __CC_APPLICATION_PROTOCOL_H__ diff --git a/cocos/2d/platform/CCCommon.h b/cocos/2d/platform/CCCommon.h index 75dc85e90d..fa300cd4fe 100644 --- a/cocos/2d/platform/CCCommon.h +++ b/cocos/2d/platform/CCCommon.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -34,14 +35,6 @@ NS_CC_BEGIN * @{ */ -/// The max length of CCLog message. -static const int kMaxLogLen = 16*1024; - -/** -@brief Output Debug message. -*/ -void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2); - /** * lua can not deal with ... */ diff --git a/cocos/2d/platform/CCDevice.h b/cocos/2d/platform/CCDevice.h index 65d5a3f3b7..0bea8f2000 100644 --- a/cocos/2d/platform/CCDevice.h +++ b/cocos/2d/platform/CCDevice.h @@ -1,3 +1,28 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + #ifndef __CCDEVICE_H__ #define __CCDEVICE_H__ diff --git a/cocos/2d/platform/CCEGLViewProtocol.cpp b/cocos/2d/platform/CCEGLViewProtocol.cpp index b99e1cfe65..f494ddf44d 100644 --- a/cocos/2d/platform/CCEGLViewProtocol.cpp +++ b/cocos/2d/platform/CCEGLViewProtocol.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + #include "CCEGLViewProtocol.h" #include "CCTouch.h" #include "CCDirector.h" diff --git a/cocos/2d/platform/CCEGLViewProtocol.h b/cocos/2d/platform/CCEGLViewProtocol.h index 6b74f58962..45bea52eed 100644 --- a/cocos/2d/platform/CCEGLViewProtocol.h +++ b/cocos/2d/platform/CCEGLViewProtocol.h @@ -1,3 +1,28 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + #ifndef __CCEGLVIEWPROTOCOL_H__ #define __CCEGLVIEWPROTOCOL_H__ diff --git a/cocos/2d/platform/CCFileUtils.cpp b/cocos/2d/platform/CCFileUtils.cpp index 01ae6064e0..3404675922 100644 --- a/cocos/2d/platform/CCFileUtils.cpp +++ b/cocos/2d/platform/CCFileUtils.cpp @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/CCFileUtils.h b/cocos/2d/platform/CCFileUtils.h index 03cbb3a2a1..0a29d6efe5 100644 --- a/cocos/2d/platform/CCFileUtils.h +++ b/cocos/2d/platform/CCFileUtils.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/CCImage.h b/cocos/2d/platform/CCImage.h index c89bcd3412..03de5e6eba 100644 --- a/cocos/2d/platform/CCImage.h +++ b/cocos/2d/platform/CCImage.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index 64cef42ea1..40eeca0ae7 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -375,7 +376,7 @@ namespace ////////////////////////////////////////////////////////////////////////// Image::Image() -: _data(0) +: _data(nullptr) , _dataLen(0) , _width(0) , _height(0) @@ -390,10 +391,7 @@ Image::Image() Image::~Image() { - if (_data != nullptr) - { - free(_data); - } + CC_SAFE_FREE(_data); } bool Image::initWithImageFile(const std::string& path) @@ -1538,7 +1536,7 @@ bool Image::initWithTGAData(tImageTGA* tgaData) }while(false); - if (!ret) + if (ret) { const unsigned char tgaSuffix[] = ".tga"; for(int i = 0; i < 4; ++i) @@ -1555,6 +1553,7 @@ bool Image::initWithTGAData(tImageTGA* tgaData) if (tgaData->imageData != nullptr) { free(tgaData->imageData); + _data = nullptr; } } diff --git a/cocos/2d/platform/CCSAXParser.cpp b/cocos/2d/platform/CCSAXParser.cpp index 0c5282bfe1..75dd1c0415 100644 --- a/cocos/2d/platform/CCSAXParser.cpp +++ b/cocos/2d/platform/CCSAXParser.cpp @@ -1,6 +1,6 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org http://cocos2d-x.org Copyright (c) 2010 Максим Аксенов + Copyright (c) 2010 cocos2d-x.org Copyright (c) 2013 Martell Malone Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/platform/CCSAXParser.h b/cocos/2d/platform/CCSAXParser.h index 63665f4ec7..230572e306 100644 --- a/cocos/2d/platform/CCSAXParser.h +++ b/cocos/2d/platform/CCSAXParser.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org http://cocos2d-x.org + Copyright (c) 2010 cocos2d-x.org Copyright (c) 2010 Максим Аксенов Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/2d/platform/CCThread.cpp b/cocos/2d/platform/CCThread.cpp index 0a33d2ddf6..b3e9e96c39 100644 --- a/cocos/2d/platform/CCThread.cpp +++ b/cocos/2d/platform/CCThread.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/CCThread.h b/cocos/2d/platform/CCThread.h index 7596d29c02..6f5ae244f0 100644 --- a/cocos/2d/platform/CCThread.h +++ b/cocos/2d/platform/CCThread.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/CCApplication.cpp b/cocos/2d/platform/android/CCApplication.cpp index 07c5814b3e..3c5b3191b3 100644 --- a/cocos/2d/platform/android/CCApplication.cpp +++ b/cocos/2d/platform/android/CCApplication.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "jni/JniHelper.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" #include "CCApplication.h" diff --git a/cocos/2d/platform/android/CCApplication.h b/cocos/2d/platform/android/CCApplication.h index d9b7d00f34..d3054c29d8 100644 --- a/cocos/2d/platform/android/CCApplication.h +++ b/cocos/2d/platform/android/CCApplication.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CC_APPLICATION_ANDROID_H__ #define __CC_APPLICATION_ANDROID_H__ diff --git a/cocos/2d/platform/android/CCCommon.cpp b/cocos/2d/platform/android/CCCommon.cpp index 277db4b14d..b48aff2e5c 100644 --- a/cocos/2d/platform/android/CCCommon.cpp +++ b/cocos/2d/platform/android/CCCommon.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -32,28 +33,6 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) -// XXX deprecated -void CCLog(const char * pszFormat, ...) -{ - va_list args; - va_start(args, pszFormat); - __android_log_vprint(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat, args); - va_end(args); - -} - -void log(const char * pszFormat, ...) -{ - char buf[MAX_LEN]; - - va_list args; - va_start(args, pszFormat); - vsnprintf(buf, MAX_LEN, pszFormat, args); - va_end(args); - - __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf); -} - void MessageBox(const char * pszMsg, const char * pszTitle) { showDialogJNI(pszMsg, pszTitle); diff --git a/cocos/2d/platform/android/CCDevice.cpp b/cocos/2d/platform/android/CCDevice.cpp index 2915cf6994..41c4aa1e9d 100644 --- a/cocos/2d/platform/android/CCDevice.cpp +++ b/cocos/2d/platform/android/CCDevice.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "platform/CCDevice.h" #include "jni/DPIJni.h" #include "nativeactivity.h" diff --git a/cocos/2d/platform/android/CCEGLView.cpp b/cocos/2d/platform/android/CCEGLView.cpp index c22babd3c1..e7da477e4e 100644 --- a/cocos/2d/platform/android/CCEGLView.cpp +++ b/cocos/2d/platform/android/CCEGLView.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/CCEGLView.h b/cocos/2d/platform/android/CCEGLView.h index cab0754d3e..dabb0a968d 100644 --- a/cocos/2d/platform/android/CCEGLView.h +++ b/cocos/2d/platform/android/CCEGLView.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/CCFileUtilsAndroid.cpp b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp index 061cd9b789..45f4876323 100644 --- a/cocos/2d/platform/android/CCFileUtilsAndroid.cpp +++ b/cocos/2d/platform/android/CCFileUtilsAndroid.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/CCFileUtilsAndroid.h b/cocos/2d/platform/android/CCFileUtilsAndroid.h index f7819ab8ab..2def6e2566 100644 --- a/cocos/2d/platform/android/CCFileUtilsAndroid.h +++ b/cocos/2d/platform/android/CCFileUtilsAndroid.h @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/CCGL.h b/cocos/2d/platform/android/CCGL.h index 3c3160a694..6c9a2468e0 100644 --- a/cocos/2d/platform/android/CCGL.h +++ b/cocos/2d/platform/android/CCGL.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/CCImage.cpp b/cocos/2d/platform/android/CCImage.cpp index 3a9dcc2f06..60ce678cd4 100644 --- a/cocos/2d/platform/android/CCImage.cpp +++ b/cocos/2d/platform/android/CCImage.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/CCPlatformDefine.h b/cocos/2d/platform/android/CCPlatformDefine.h index 0780791326..8d146ebc14 100644 --- a/cocos/2d/platform/android/CCPlatformDefine.h +++ b/cocos/2d/platform/android/CCPlatformDefine.h @@ -1,3 +1,28 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ diff --git a/cocos/2d/platform/android/CCStdC.h b/cocos/2d/platform/android/CCStdC.h index 475142b51a..804abebceb 100644 --- a/cocos/2d/platform/android/CCStdC.h +++ b/cocos/2d/platform/android/CCStdC.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java index ef0ba4074e..578f7120c2 100644 --- a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java index 0b1a8a32d7..afebee4260 100644 --- a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java +++ b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditBoxDialog.java @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java index 289a7a20cf..8c2fe378be 100644 --- a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java +++ b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2012 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -23,6 +24,7 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; +import android.app.Activity; import android.content.Context; import android.text.Editable; import android.text.TextWatcher; @@ -59,9 +61,11 @@ public class Cocos2dxEditText extends EditText { this.setOnEditorActionListener(this.mTextWatcher); ViewGroup.LayoutParams layout = - new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - this.setLayoutParams(layout); + + Activity activity = (Activity)context; + activity.addContentView(this, layout); } // =========================================================== @@ -84,7 +88,7 @@ public class Cocos2dxEditText extends EditText { this.removeTextChangedListener(mTextWatcher); final InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(this.getWindowToken(), 0); - Cocos2dxHelper.nativeRequestFocus(); + //Cocos2dxHelper.nativeRequestFocus(); } public void openIMEKeyboard() { @@ -96,7 +100,7 @@ public class Cocos2dxEditText extends EditText { this.addTextChangedListener(mTextWatcher); final InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT); + imm.showSoftInput(this, InputMethodManager.SHOW_FORCED); } @Override @@ -105,7 +109,7 @@ public class Cocos2dxEditText extends EditText { /* Let GlSurfaceView get focus if back key is input. */ if (keyCode == KeyEvent.KEYCODE_BACK) { - this.requestFocus(); + //Cocos2dxHelper.nativeRequestFocus(); } return true; @@ -189,7 +193,6 @@ class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListener { @Override public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) { - } @Override diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java index b809b9d5c3..e1566df16d 100644 --- a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java +++ b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010-2013 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxLocalStorage.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxLocalStorage.java index 99c9126400..d6dd3dd135 100644 --- a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxLocalStorage.java +++ b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxLocalStorage.java @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxLuaJavaBridge.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxLuaJavaBridge.java index 2dee611b29..80bfb15295 100644 --- a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxLuaJavaBridge.java +++ b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxLuaJavaBridge.java @@ -1,3 +1,26 @@ +/**************************************************************************** +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ package org.cocos2dx.lib; diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java index 2346389982..41793e24a9 100644 --- a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java +++ b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -21,6 +22,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ + package org.cocos2dx.lib; import java.io.FileInputStream; diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java index 3bac47f621..9b8239da79 100644 --- a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java +++ b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java index b7495fba90..27451abb68 100644 --- a/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java +++ b/cocos/2d/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/jni/IMEJni.cpp b/cocos/2d/platform/android/jni/IMEJni.cpp index 5cc75a8fcd..892b003739 100644 --- a/cocos/2d/platform/android/jni/IMEJni.cpp +++ b/cocos/2d/platform/android/jni/IMEJni.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2011-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/jni/IMEJni.h b/cocos/2d/platform/android/jni/IMEJni.h index 2d3dd62d87..d28850aa1d 100644 --- a/cocos/2d/platform/android/jni/IMEJni.h +++ b/cocos/2d/platform/android/jni/IMEJni.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2011-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp b/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp index 5ed0fc7279..bdd9ee815f 100644 --- a/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp +++ b/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.cpp @@ -1,10 +1,33 @@ +/**************************************************************************** +Copyright (c) 2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + #include "JniHelper.h" #include #include "CCDirector.h" #include "../CCApplication.h" #include "platform/CCFileUtils.h" -#include "CCEventType.h" -#include "CCNotificationCenter.h" #include using namespace cocos2d; diff --git a/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h b/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h index 06e8474a1e..d26b861879 100644 --- a/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h +++ b/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxBitmap.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp b/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp index bf353aca3f..3d69827626 100644 --- a/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp +++ b/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include #include #include diff --git a/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h b/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h index 3d2ebf7cc5..4d3587a73e 100644 --- a/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h +++ b/cocos/2d/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/jni/JniHelper.cpp b/cocos/2d/platform/android/jni/JniHelper.cpp index 9555643d7a..992e4ec2b8 100644 --- a/cocos/2d/platform/android/jni/JniHelper.cpp +++ b/cocos/2d/platform/android/jni/JniHelper.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/jni/JniHelper.h b/cocos/2d/platform/android/jni/JniHelper.h index 20955acf7e..3f57a85336 100644 --- a/cocos/2d/platform/android/jni/JniHelper.h +++ b/cocos/2d/platform/android/jni/JniHelper.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/android/nativeactivity.cpp b/cocos/2d/platform/android/nativeactivity.cpp index 7a0416188a..0e68cf0eb4 100644 --- a/cocos/2d/platform/android/nativeactivity.cpp +++ b/cocos/2d/platform/android/nativeactivity.cpp @@ -1,3 +1,26 @@ +/**************************************************************************** +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "nativeactivity.h" #include @@ -17,7 +40,6 @@ #include "CCDirector.h" #include "CCApplication.h" #include "CCEventType.h" -#include "CCNotificationCenter.h" #include "CCFileUtilsAndroid.h" #include "jni/JniHelper.h" @@ -28,6 +50,7 @@ #include "CCEventDispatcher.h" #include "CCEventAcceleration.h" #include "CCEventKeyboard.h" +#include "CCEventCustom.h" #include "jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" @@ -140,7 +163,8 @@ static void cocos_init(cocos_dimensions d, struct android_app* app) { cocos2d::ShaderCache::getInstance()->reloadDefaultShaders(); cocos2d::DrawPrimitives::init(); cocos2d::VolatileTextureMgr::reloadAllTextures(); - cocos2d::NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); + cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND); + cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&foregroundEvent); cocos2d::Director::getInstance()->setGLDefaultValues(); } } @@ -557,12 +581,14 @@ static void engine_handle_cmd(struct android_app* app, int32_t cmd) { break; case APP_CMD_LOST_FOCUS: - cocos2d::Application::getInstance()->applicationDidEnterBackground(); - cocos2d::NotificationCenter::getInstance()->postNotification(EVENT_COME_TO_BACKGROUND, NULL); - - // Also stop animating. - engine->animating = 0; - engine_draw_frame(engine); + { + cocos2d::Application::getInstance()->applicationDidEnterBackground(); + cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND); + cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent); + // Also stop animating. + engine->animating = 0; + engine_draw_frame(engine); + } break; } } diff --git a/cocos/2d/platform/android/nativeactivity.h b/cocos/2d/platform/android/nativeactivity.h index 677fff3adf..bc7517f3cb 100644 --- a/cocos/2d/platform/android/nativeactivity.h +++ b/cocos/2d/platform/android/nativeactivity.h @@ -1,3 +1,26 @@ +/**************************************************************************** +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __COCOSNATIVEACTIVITY_H__ #define __COCOSNATIVEACTIVITY_H__ diff --git a/cocos/2d/platform/apple/CCFileUtilsApple.h b/cocos/2d/platform/apple/CCFileUtilsApple.h index 6903d42100..c11278d185 100644 --- a/cocos/2d/platform/apple/CCFileUtilsApple.h +++ b/cocos/2d/platform/apple/CCFileUtilsApple.h @@ -1,5 +1,7 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2011 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/apple/CCFileUtilsApple.mm b/cocos/2d/platform/apple/CCFileUtilsApple.mm index e1c20aba40..9c9443e0f7 100644 --- a/cocos/2d/platform/apple/CCFileUtilsApple.mm +++ b/cocos/2d/platform/apple/CCFileUtilsApple.mm @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/apple/CCLock.cpp b/cocos/2d/platform/apple/CCLock.cpp index 312cd377bd..0a6f29bfe5 100644 --- a/cocos/2d/platform/apple/CCLock.cpp +++ b/cocos/2d/platform/apple/CCLock.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/apple/CCLock.h b/cocos/2d/platform/apple/CCLock.h index 71d67e4371..db573603bb 100644 --- a/cocos/2d/platform/apple/CCLock.h +++ b/cocos/2d/platform/apple/CCLock.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/apple/CCThread.mm b/cocos/2d/platform/apple/CCThread.mm index 1d060c5028..a69398d013 100644 --- a/cocos/2d/platform/apple/CCThread.mm +++ b/cocos/2d/platform/apple/CCThread.mm @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/ios/CCApplication.h b/cocos/2d/platform/ios/CCApplication.h index a281a4f554..843a5d5b99 100644 --- a/cocos/2d/platform/ios/CCApplication.h +++ b/cocos/2d/platform/ios/CCApplication.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/ios/CCApplication.mm b/cocos/2d/platform/ios/CCApplication.mm index c09a0aa8a9..14b07975ca 100644 --- a/cocos/2d/platform/ios/CCApplication.mm +++ b/cocos/2d/platform/ios/CCApplication.mm @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/ios/CCCommon.mm b/cocos/2d/platform/ios/CCCommon.mm index 42b0dbfba8..28d0dd0e22 100644 --- a/cocos/2d/platform/ios/CCCommon.mm +++ b/cocos/2d/platform/ios/CCCommon.mm @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -28,34 +29,11 @@ #include #import +#include "CCDirector.h" +#include "CCConsole.h" NS_CC_BEGIN -// XXX deprecated -void CCLog(const char * format, ...) -{ - printf("cocos2d: "); - char buf[kMaxLogLen+1] = {0}; - va_list ap; - va_start(ap, format); - vsnprintf(buf, kMaxLogLen, format, ap); - va_end(ap); - printf("%s", buf); - printf("\n"); -} - -void log(const char * format, ...) -{ - printf("cocos2d: "); - char buf[kMaxLogLen+1] = {0}; - va_list ap; - va_start(ap, format); - vsnprintf(buf, kMaxLogLen, format, ap); - va_end(ap); - printf("%s", buf); - printf("\n"); -} - // ios no MessageBox, use log instead void MessageBox(const char * msg, const char * title) { diff --git a/cocos/2d/platform/ios/CCDevice.mm b/cocos/2d/platform/ios/CCDevice.mm index e8610db653..a80efef136 100644 --- a/cocos/2d/platform/ios/CCDevice.mm +++ b/cocos/2d/platform/ios/CCDevice.mm @@ -1,3 +1,27 @@ +/**************************************************************************** + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "CCDevice.h" #include "ccTypes.h" #include "CCEventDispatcher.h" diff --git a/cocos/2d/platform/ios/CCDirectorCaller.h b/cocos/2d/platform/ios/CCDirectorCaller.h index f9a6ca330d..f3b4ee4c92 100644 --- a/cocos/2d/platform/ios/CCDirectorCaller.h +++ b/cocos/2d/platform/ios/CCDirectorCaller.h @@ -1,18 +1,19 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE diff --git a/cocos/2d/platform/ios/CCDirectorCaller.mm b/cocos/2d/platform/ios/CCDirectorCaller.mm index 092db285b3..957c8acff9 100644 --- a/cocos/2d/platform/ios/CCDirectorCaller.mm +++ b/cocos/2d/platform/ios/CCDirectorCaller.mm @@ -1,18 +1,19 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE diff --git a/cocos/2d/platform/ios/CCEGLView.h b/cocos/2d/platform/ios/CCEGLView.h index ef3b8ec1d0..3dce046feb 100644 --- a/cocos/2d/platform/ios/CCEGLView.h +++ b/cocos/2d/platform/ios/CCEGLView.h @@ -1,26 +1,27 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. -http://www.cocos2d-x.org + http://www.cocos2d-x.org -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + 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 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. -****************************************************************************/ + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef __CC_EGLVIEW_IPHONE_H__ #define __CC_EGLVIEW_IPHONE_H__ diff --git a/cocos/2d/platform/ios/CCEGLView.mm b/cocos/2d/platform/ios/CCEGLView.mm index 950c43fb2e..399b365e56 100644 --- a/cocos/2d/platform/ios/CCEGLView.mm +++ b/cocos/2d/platform/ios/CCEGLView.mm @@ -1,26 +1,27 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. -http://www.cocos2d-x.org + http://www.cocos2d-x.org -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + 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 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. -****************************************************************************/ + 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 "EAGLView.h" #include "CCDirectorCaller.h" #include "CCEGLView.h" diff --git a/cocos/2d/platform/ios/CCES2Renderer.h b/cocos/2d/platform/ios/CCES2Renderer.h index 755b694a69..1c25466fe4 100644 --- a/cocos/2d/platform/ios/CCES2Renderer.h +++ b/cocos/2d/platform/ios/CCES2Renderer.h @@ -1,30 +1,29 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2010 Ricardo Quesada - * Copyright (c) 2011 Zynga Inc. - * - * 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. - * - * - * File autogenerated with Xcode. Adapted for cocos2d needs. - */ +/**************************************************************************** + Copyright (c) 2010 Ricardo Quesada + Copyright (c) 2010-2012 cocos2d-x.org + Corpyight (c) 2011 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ // Only compile this code on iOS. These files should NOT be included on your Mac project. // But in case they are included, it won't be compiled. diff --git a/cocos/2d/platform/ios/CCES2Renderer.m b/cocos/2d/platform/ios/CCES2Renderer.m index 52b6d2a01d..3f3a226e82 100644 --- a/cocos/2d/platform/ios/CCES2Renderer.m +++ b/cocos/2d/platform/ios/CCES2Renderer.m @@ -1,30 +1,29 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2011 Ricardo Quesada - * Copyright (c) 2011 Zynga Inc. - * - * 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. - * - * - * File autogenerated with Xcode. Adapted for cocos2d needs. - */ +/**************************************************************************** + Copyright (c) 2010 Ricardo Quesada + Copyright (c) 2010-2012 cocos2d-x.org + Corpyight (c) 2011 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ // Only compile this code on iOS. These files should NOT be included on your Mac project. // But in case they are included, it won't be compiled. diff --git a/cocos/2d/platform/ios/CCESRenderer.h b/cocos/2d/platform/ios/CCESRenderer.h index 944be4926a..e35ea686e1 100644 --- a/cocos/2d/platform/ios/CCESRenderer.h +++ b/cocos/2d/platform/ios/CCESRenderer.h @@ -1,30 +1,29 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2010 Ricardo Quesada - * Copyright (c) 2011 Zynga Inc. - * - * 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. - * - * - * File autogenerated with Xcode. Adapted for cocos2d needs. - */ +/**************************************************************************** + Copyright (c) 2010 Ricardo Quesada + Copyright (c) 2010-2012 cocos2d-x.org + Corpyight (c) 2011 Zynga Inc. + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ // Only compile this code on iOS. These files should NOT be included on your Mac project. // But in case they are included, it won't be compiled. diff --git a/cocos/2d/platform/ios/CCGL.h b/cocos/2d/platform/ios/CCGL.h index 2dc082d729..6104a7fcfd 100644 --- a/cocos/2d/platform/ios/CCGL.h +++ b/cocos/2d/platform/ios/CCGL.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/ios/CCImage.mm b/cocos/2d/platform/ios/CCImage.mm index a2cc87dbec..5ad55ce594 100644 --- a/cocos/2d/platform/ios/CCImage.mm +++ b/cocos/2d/platform/ios/CCImage.mm @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/ios/CCPlatformDefine.h b/cocos/2d/platform/ios/CCPlatformDefine.h index 789ea77e08..02f7c89eba 100644 --- a/cocos/2d/platform/ios/CCPlatformDefine.h +++ b/cocos/2d/platform/ios/CCPlatformDefine.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ diff --git a/cocos/2d/platform/ios/CCStdC.h b/cocos/2d/platform/ios/CCStdC.h index 475142b51a..804abebceb 100644 --- a/cocos/2d/platform/ios/CCStdC.h +++ b/cocos/2d/platform/ios/CCStdC.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/ios/Simulation/AccelerometerSimulation.h b/cocos/2d/platform/ios/Simulation/AccelerometerSimulation.h index 504b101094..972843302c 100644 --- a/cocos/2d/platform/ios/Simulation/AccelerometerSimulation.h +++ b/cocos/2d/platform/ios/Simulation/AccelerometerSimulation.h @@ -1,11 +1,28 @@ -/* - * AccelerometerSimulation.h - * AccelerometerGraph - * - * Created by Otto Chrons on 9/26/08. - * Copyright 2008 Seastringo Oy. All rights reserved. - * - */ +/**************************************************************************** +Copyright (c) 2008 Otto Chrons at Seastringo Oy. +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #import // when compiling to ARM (iPhone device), hide everything and use system defaults diff --git a/cocos/2d/platform/ios/Simulation/AccelerometerSimulation.m b/cocos/2d/platform/ios/Simulation/AccelerometerSimulation.m index bcf53d67dd..0a93a263e9 100644 --- a/cocos/2d/platform/ios/Simulation/AccelerometerSimulation.m +++ b/cocos/2d/platform/ios/Simulation/AccelerometerSimulation.m @@ -1,10 +1,28 @@ -// -// AccelerometerSimulation.m -// AccelerometerGraph -// -// Created by Otto Chrons on 9/26/08. -// Copyright 2008 Seastringo Oy. All rights reserved. -// +/**************************************************************************** +Copyright (c) 2008 Otto Chrons at Seastringo Oy. +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #import "AccelerometerSimulation.h" diff --git a/cocos/2d/platform/linux/CCApplication.cpp b/cocos/2d/platform/linux/CCApplication.cpp index 0534b83208..f2efa5b7de 100644 --- a/cocos/2d/platform/linux/CCApplication.cpp +++ b/cocos/2d/platform/linux/CCApplication.cpp @@ -1,9 +1,28 @@ -/* - * Aplication_linux.cpp - * - * Created on: Aug 8, 2011 - * Author: laschweinski - */ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + #include "CCApplication.h" #include #include diff --git a/cocos/2d/platform/linux/CCApplication.h b/cocos/2d/platform/linux/CCApplication.h index 6627a8a94c..8c5c51ae60 100644 --- a/cocos/2d/platform/linux/CCApplication.h +++ b/cocos/2d/platform/linux/CCApplication.h @@ -1,9 +1,27 @@ -/* - * Aplication.h - * - * Created on: Aug 8, 2011 - * Author: laschweinski - */ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef CCAPLICATION_H_ #define CCAPLICATION_H_ diff --git a/cocos/2d/platform/linux/CCCommon.cpp b/cocos/2d/platform/linux/CCCommon.cpp index 880d626540..c48307192b 100644 --- a/cocos/2d/platform/linux/CCCommon.cpp +++ b/cocos/2d/platform/linux/CCCommon.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -23,60 +24,18 @@ THE SOFTWARE. ****************************************************************************/ #include "platform/CCCommon.h" #include "CCStdC.h" +#include "CCConsole.h" NS_CC_BEGIN -#define MAX_LEN (cocos2d::kMaxLogLen + 1) - -// XXX deprecated -void CCLog(const char * pszFormat, ...) +void MessageBox(const char * msg, const char * title) { - char szBuf[MAX_LEN]; - - va_list ap; - va_start(ap, pszFormat); - vsnprintf(szBuf, MAX_LEN, pszFormat, ap); - va_end(ap); - - // Strip any trailing newlines from log message. - size_t len = strlen(szBuf); - while (len && szBuf[len-1] == '\n') - { - szBuf[len-1] = '\0'; - len--; - } - - fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf); + log("%s: %s", title, msg); } -void log(const char * pszFormat, ...) +void LuaLog(const char * format) { - char szBuf[MAX_LEN]; - - va_list ap; - va_start(ap, pszFormat); - vsnprintf(szBuf, MAX_LEN, pszFormat, ap); - va_end(ap); - - // Strip any trailing newlines from log message. - size_t len = strlen(szBuf); - while (len && szBuf[len-1] == '\n') - { - szBuf[len-1] = '\0'; - len--; - } - - fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf); -} - -void MessageBox(const char * pszMsg, const char * pszTitle) -{ - log("%s: %s", pszTitle, pszMsg); -} - -void LuaLog(const char * pszFormat) -{ - puts(pszFormat); + puts(format); } NS_CC_END diff --git a/cocos/2d/platform/linux/CCDevice.cpp b/cocos/2d/platform/linux/CCDevice.cpp index 3b3c962413..44457cdb6e 100644 --- a/cocos/2d/platform/linux/CCDevice.cpp +++ b/cocos/2d/platform/linux/CCDevice.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "platform/CCDevice.h" #include #include diff --git a/cocos/2d/platform/linux/CCEGLView.cpp b/cocos/2d/platform/linux/CCEGLView.cpp index 360e96f101..ac410b2f74 100644 --- a/cocos/2d/platform/linux/CCEGLView.cpp +++ b/cocos/2d/platform/linux/CCEGLView.cpp @@ -1,9 +1,27 @@ -/* - * EGLViewlinux.cpp - * - * Created on: Aug 8, 2011 - * Author: laschweinski - */ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "CCEGLView.h" #include "CCGL.h" @@ -256,9 +274,12 @@ void EGLViewEventHandler::OnGLFWMouseScrollCallback(GLFWwindow* window, double x void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { - EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action || GLFW_REPEAT == action); - auto dispatcher = Director::getInstance()->getEventDispatcher(); - dispatcher->dispatchEvent(&event); + if (GLFW_REPEAT != action) + { + EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action); + auto dispatcher = Director::getInstance()->getEventDispatcher(); + dispatcher->dispatchEvent(&event); + } } void EGLViewEventHandler::OnGLFWCharCallback(GLFWwindow *window, unsigned int character) diff --git a/cocos/2d/platform/linux/CCEGLView.h b/cocos/2d/platform/linux/CCEGLView.h index ed4fc18245..ca7949f1fb 100644 --- a/cocos/2d/platform/linux/CCEGLView.h +++ b/cocos/2d/platform/linux/CCEGLView.h @@ -1,9 +1,27 @@ -/* - * EGLView.h - * - * Created on: Aug 8, 2011 - * Author: laschweinski - */ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef EGLVIEW_H_ #define EGLVIEW_H_ diff --git a/cocos/2d/platform/linux/CCFileUtilsLinux.cpp b/cocos/2d/platform/linux/CCFileUtilsLinux.cpp index dc3fb5b513..2d86c1ec87 100644 --- a/cocos/2d/platform/linux/CCFileUtilsLinux.cpp +++ b/cocos/2d/platform/linux/CCFileUtilsLinux.cpp @@ -1,9 +1,27 @@ -/* - * FileUtilsLinux.cpp - * - * Created on: Aug 9, 2011 - * Author: laschweinski - */ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "CCFileUtilsLinux.h" #include "platform/CCCommon.h" #include "ccMacros.h" diff --git a/cocos/2d/platform/linux/CCFileUtilsLinux.h b/cocos/2d/platform/linux/CCFileUtilsLinux.h index 366f8d08f5..20742b02f3 100644 --- a/cocos/2d/platform/linux/CCFileUtilsLinux.h +++ b/cocos/2d/platform/linux/CCFileUtilsLinux.h @@ -1,26 +1,27 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CC_FILEUTILS_LINUX_H__ #define __CC_FILEUTILS_LINUX_H__ diff --git a/cocos/2d/platform/linux/CCImage.cpp b/cocos/2d/platform/linux/CCImage.cpp index 551595c709..45602638b5 100644 --- a/cocos/2d/platform/linux/CCImage.cpp +++ b/cocos/2d/platform/linux/CCImage.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include #include diff --git a/cocos/2d/platform/linux/CCPlatformDefine.h b/cocos/2d/platform/linux/CCPlatformDefine.h index d427303599..5d2a56ff31 100644 --- a/cocos/2d/platform/linux/CCPlatformDefine.h +++ b/cocos/2d/platform/linux/CCPlatformDefine.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ diff --git a/cocos/2d/platform/linux/CCStdC.cpp b/cocos/2d/platform/linux/CCStdC.cpp index f0d0f8c01b..9f47e9e17a 100644 --- a/cocos/2d/platform/linux/CCStdC.cpp +++ b/cocos/2d/platform/linux/CCStdC.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/linux/CCStdC.h b/cocos/2d/platform/linux/CCStdC.h index 7fd6339bef..5f3e24e8c0 100644 --- a/cocos/2d/platform/linux/CCStdC.h +++ b/cocos/2d/platform/linux/CCStdC.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/mac/CCApplication.h b/cocos/2d/platform/mac/CCApplication.h index ed57cd4f0f..5a4c5bd8a5 100644 --- a/cocos/2d/platform/mac/CCApplication.h +++ b/cocos/2d/platform/mac/CCApplication.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/mac/CCApplication.mm b/cocos/2d/platform/mac/CCApplication.mm index 970b0e3566..0ece7367f4 100644 --- a/cocos/2d/platform/mac/CCApplication.mm +++ b/cocos/2d/platform/mac/CCApplication.mm @@ -1,26 +1,27 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #import "CCApplication.h" #import diff --git a/cocos/2d/platform/mac/CCCommon.mm b/cocos/2d/platform/mac/CCCommon.mm index a9b15874b1..52e4fb7beb 100644 --- a/cocos/2d/platform/mac/CCCommon.mm +++ b/cocos/2d/platform/mac/CCCommon.mm @@ -1,26 +1,27 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. - http://www.cocos2d-x.org +http://www.cocos2d-x.org - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: +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 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. - ****************************************************************************/ +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include #include "platform/CCCommon.h" @@ -32,36 +33,6 @@ NS_CC_BEGIN -// XXX deprecated -void CCLog(const char * format, ...) -{ - printf("Cocos2d: "); - char buf[kMaxLogLen]; - - va_list ap; - va_start(ap, format); - vsnprintf(buf, kMaxLogLen, format, ap); - va_end(ap); - printf("%s", buf); - printf("\n"); - fflush(stdout); -} - -void log(const char * format, ...) -{ - printf("Cocos2d: "); - char buf[kMaxLogLen]; - - va_list ap; - va_start(ap, format); - vsnprintf(buf, kMaxLogLen, format, ap); - va_end(ap); - printf("%s", buf); - printf("\n"); - fflush(stdout); -} - - void LuaLog(const char * format) { puts(format); diff --git a/cocos/2d/platform/mac/CCDevice.mm b/cocos/2d/platform/mac/CCDevice.mm index 0d3964e690..4814ee8768 100644 --- a/cocos/2d/platform/mac/CCDevice.mm +++ b/cocos/2d/platform/mac/CCDevice.mm @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "platform/CCDevice.h" NS_CC_BEGIN diff --git a/cocos/2d/platform/mac/CCDirectorCaller.h b/cocos/2d/platform/mac/CCDirectorCaller.h index 4d80b6e8b5..87117073cb 100644 --- a/cocos/2d/platform/mac/CCDirectorCaller.h +++ b/cocos/2d/platform/mac/CCDirectorCaller.h @@ -1,26 +1,27 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #import #import diff --git a/cocos/2d/platform/mac/CCDirectorCaller.mm b/cocos/2d/platform/mac/CCDirectorCaller.mm index af4645a7aa..f371dae133 100644 --- a/cocos/2d/platform/mac/CCDirectorCaller.mm +++ b/cocos/2d/platform/mac/CCDirectorCaller.mm @@ -1,26 +1,27 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #import #import "CCDirectorCaller.h" #import "CCDirector.h" diff --git a/cocos/2d/platform/mac/CCEGLView.h b/cocos/2d/platform/mac/CCEGLView.h index d58d70dc4b..5b72a9b66f 100644 --- a/cocos/2d/platform/mac/CCEGLView.h +++ b/cocos/2d/platform/mac/CCEGLView.h @@ -1,26 +1,27 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CC_EGLVIEW_MAC_H__ #define __CC_EGLVIEW_MAC_H__ @@ -73,6 +74,9 @@ public: /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView(); + + inline bool isRetina() { return _isRetina; }; + protected: /* * Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop. @@ -81,8 +85,8 @@ protected: private: bool _captured; bool _supportTouch; + bool _isRetina; - int _frameBufferSize[2]; float _frameZoomFactor; static EGLView* s_pEglView; public: @@ -92,6 +96,7 @@ public: GLFWwindow* getWindow() const { return _mainWindow; } private: GLFWwindow* _mainWindow; + friend class EGLViewEventHandler; }; NS_CC_END // end of namespace cocos2d diff --git a/cocos/2d/platform/mac/CCEGLView.mm b/cocos/2d/platform/mac/CCEGLView.mm index 335b513634..a3635be8ed 100644 --- a/cocos/2d/platform/mac/CCEGLView.mm +++ b/cocos/2d/platform/mac/CCEGLView.mm @@ -1,26 +1,27 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "CCEGLView.h" @@ -177,25 +178,26 @@ public: static float s_mouseX; static float s_mouseY; - static void OnGLFWError(int errorID, const char* errorDesc); - static void OnGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify); - static void OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y); - static void OnGLFWMouseScrollCallback(GLFWwindow* window, double x, double y); - static void OnGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); - static void OnGLFWCharCallback(GLFWwindow* window, unsigned int character); - static void OnGLFWWindowPosCallback(GLFWwindow* windows, int x, int y); + static void onGLFWError(int errorID, const char* errorDesc); + static void onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify); + static void onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y); + static void onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y); + static void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); + static void onGLFWCharCallback(GLFWwindow* window, unsigned int character); + static void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y); + static void onGLFWframebuffersize(GLFWwindow* window, int w, int h); }; bool EGLViewEventHandler::s_captured = false; float EGLViewEventHandler::s_mouseX = 0; float EGLViewEventHandler::s_mouseY = 0; -void EGLViewEventHandler::OnGLFWError(int errorID, const char* errorDesc) +void EGLViewEventHandler::onGLFWError(int errorID, const char* errorDesc) { CCLOGERROR("GLFWError #%d Happen, %s\n", errorID, errorDesc); } -void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify) +void EGLViewEventHandler::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify) { EGLView* eglView = EGLView::getInstance(); if(nullptr == eglView) return; @@ -239,10 +241,16 @@ void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, in } } -void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y) +void EGLViewEventHandler::onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y) { EGLView* eglView = EGLView::getInstance(); if(nullptr == eglView) return; + + if (eglView->isRetina()) { + x *= 2; + y *= 2; + } + s_mouseX = (float)x; s_mouseY = (float)y; @@ -264,7 +272,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); } -void EGLViewEventHandler::OnGLFWMouseScrollCallback(GLFWwindow* window, double x, double y) +void EGLViewEventHandler::onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y) { EGLView* eglView = EGLView::getInstance(); if(nullptr == eglView) return; @@ -276,26 +284,50 @@ void EGLViewEventHandler::OnGLFWMouseScrollCallback(GLFWwindow* window, double x Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); } -void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) +void EGLViewEventHandler::onGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { - EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action || GLFW_REPEAT == action); - auto dispatcher = Director::getInstance()->getEventDispatcher(); - dispatcher->dispatchEvent(&event); + if (GLFW_REPEAT != action) + { + EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action); + auto dispatcher = Director::getInstance()->getEventDispatcher(); + dispatcher->dispatchEvent(&event); + } } -void EGLViewEventHandler::OnGLFWCharCallback(GLFWwindow *window, unsigned int character) +void EGLViewEventHandler::onGLFWCharCallback(GLFWwindow *window, unsigned int character) { IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char*) &character, 1); } -void EGLViewEventHandler::OnGLFWWindowPosCallback(GLFWwindow *windows, int x, int y) +void EGLViewEventHandler::onGLFWWindowPosCallback(GLFWwindow *windows, int x, int y) { - if(Director::getInstance()) + Director::getInstance()->setViewport(); +} + +void EGLViewEventHandler::onGLFWframebuffersize(GLFWwindow* window, int w, int h) +{ + auto view = EGLView::getInstance(); + + float frameSizeW = view->getFrameSize().width; + float frameSizeH = view->getFrameSize().height; + float factorX = frameSizeW / w * view->getFrameZoomFactor(); + float factorY = frameSizeH / h * view->getFrameZoomFactor();; + + if (fabs(factorX - 0.5f) < FLT_EPSILON && fabs(factorY - 0.5f) < FLT_EPSILON ) { - Director::getInstance()->setViewport(); + view->_isRetina = true; + view->setFrameZoomFactor(2.0f * view->getFrameZoomFactor()); + glfwSetWindowSize(window, static_cast(frameSizeW * 0.5f * view->getFrameZoomFactor()) , static_cast(frameSizeH * 0.5f * view->getFrameZoomFactor())); + } + else if(fabs(factorX - 2.0f) < FLT_EPSILON && fabs(factorY - 2.0f) < FLT_EPSILON) + { + view->_isRetina = false; + view->setFrameZoomFactor(0.5f * view->getFrameZoomFactor()); + glfwSetWindowSize(window, static_cast(frameSizeW * view->getFrameZoomFactor()), static_cast(frameSizeH * view->getFrameZoomFactor())); } } + //end EGLViewEventHandler @@ -309,12 +341,13 @@ EGLView::EGLView() : _captured(false) , _frameZoomFactor(1.0f) , _supportTouch(false) +, _isRetina(false) , _mainWindow(nullptr) { CCASSERT(nullptr == s_pEglView, "EGLView is singleton, Should be inited only one time\n"); _viewName = "cocos2dx"; s_pEglView = this; - glfwSetErrorCallback(EGLViewEventHandler::OnGLFWError); + glfwSetErrorCallback(EGLViewEventHandler::onGLFWError); glfwInit(); } @@ -337,15 +370,25 @@ bool EGLView::init(const std::string& viewName, float width, float height, float _mainWindow = glfwCreateWindow(_screenSize.width * _frameZoomFactor, _screenSize.height * _frameZoomFactor, _viewName.c_str(), nullptr, nullptr); glfwMakeContextCurrent(_mainWindow); - glfwGetFramebufferSize(_mainWindow, &_frameBufferSize[0], &_frameBufferSize[1]); + int w, h; + glfwGetWindowSize(_mainWindow, &w, &h); + int frameBufferW, frameBufferH; + glfwGetFramebufferSize(_mainWindow, &frameBufferW, &frameBufferH); - glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack); - glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack); - glfwSetScrollCallback(_mainWindow, EGLViewEventHandler::OnGLFWMouseScrollCallback); - glfwSetCharCallback(_mainWindow, EGLViewEventHandler::OnGLFWCharCallback); - glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::OnGLFWKeyCallback); - glfwSetWindowPosCallback(_mainWindow, EGLViewEventHandler::OnGLFWWindowPosCallback); + if (frameBufferW == 2 * w && frameBufferH == 2 * h) + { + _isRetina = true; + setFrameZoomFactor(frameZoomFactor * 2); + glfwSetWindowSize(_mainWindow, width/2 * _frameZoomFactor, height/2 * _frameZoomFactor); + } + glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::onGLFWMouseCallBack); + glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::onGLFWMouseMoveCallBack); + glfwSetScrollCallback(_mainWindow, EGLViewEventHandler::onGLFWMouseScrollCallback); + glfwSetCharCallback(_mainWindow, EGLViewEventHandler::onGLFWCharCallback); + glfwSetKeyCallback(_mainWindow, EGLViewEventHandler::onGLFWKeyCallback); + glfwSetWindowPosCallback(_mainWindow, EGLViewEventHandler::onGLFWWindowPosCallback); + glfwSetFramebufferSizeCallback(_mainWindow, EGLViewEventHandler::onGLFWframebuffersize); // check OpenGL version at first const GLubyte* glVersion = glGetString(GL_VERSION); @@ -449,22 +492,18 @@ void EGLView::setFrameSize(float width, float height) void EGLView::setViewPortInPoints(float x , float y , float w , float h) { - float frameZoomFactorX = _frameBufferSize[0]/_screenSize.width; - float frameZoomFactorY = _frameBufferSize[1]/_screenSize.height; - glViewport((GLint)(x * _scaleX * frameZoomFactorX + _viewPortRect.origin.x * frameZoomFactorX), - (GLint)(y * _scaleY * frameZoomFactorY + _viewPortRect.origin.y * frameZoomFactorY), - (GLsizei)(w * _scaleX * frameZoomFactorX), - (GLsizei)(h * _scaleY * frameZoomFactorY)); + glViewport((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor), + (GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor), + (GLsizei)(w * _scaleX * _frameZoomFactor), + (GLsizei)(h * _scaleY * _frameZoomFactor)); } void EGLView::setScissorInPoints(float x , float y , float w , float h) { - float frameZoomFactorX = _frameBufferSize[0]/_screenSize.width; - float frameZoomFactorY = _frameBufferSize[1]/_screenSize.height; - glScissor((GLint)(x * _scaleX * frameZoomFactorX + _viewPortRect.origin.x * frameZoomFactorX), - (GLint)(y * _scaleY * frameZoomFactorY + _viewPortRect.origin.y * frameZoomFactorY), - (GLsizei)(w * _scaleX * frameZoomFactorX), - (GLsizei)(h * _scaleY * frameZoomFactorY)); + glScissor((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor), + (GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor), + (GLsizei)(w * _scaleX * _frameZoomFactor), + (GLsizei)(h * _scaleY * _frameZoomFactor)); } EGLView* EGLView::getInstance() diff --git a/cocos/2d/platform/mac/CCEventDispatcherMac.h b/cocos/2d/platform/mac/CCEventDispatcherMac.h index 5bf0389792..df47784455 100644 --- a/cocos/2d/platform/mac/CCEventDispatcherMac.h +++ b/cocos/2d/platform/mac/CCEventDispatcherMac.h @@ -1,27 +1,29 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2010 Ricardo Quesada - * Copyright (c) 2011 Zynga Inc. - * - * 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. - */ +/**************************************************************************** +Copyright (c) 2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ // Only compile this code on Mac. These files should not be included on your iOS project. // But in case they are included, it won't be compiled. diff --git a/cocos/2d/platform/mac/CCEventDispatcherMac.mm b/cocos/2d/platform/mac/CCEventDispatcherMac.mm index 6629ae6470..691383d36a 100644 --- a/cocos/2d/platform/mac/CCEventDispatcherMac.mm +++ b/cocos/2d/platform/mac/CCEventDispatcherMac.mm @@ -1,27 +1,29 @@ -/* - * cocos2d for iPhone: http://www.cocos2d-iphone.org - * - * Copyright (c) 2010 Ricardo Quesada - * Copyright (c) 2011 Zynga Inc. - * - * 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. - */ +/**************************************************************************** +Copyright (c) 2010 Ricardo Quesada +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2011 Zynga Inc. +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ // Only compile this code on Mac. These files should not be included on your iOS project. // But in case they are included, it won't be compiled. diff --git a/cocos/2d/platform/mac/CCGL.h b/cocos/2d/platform/mac/CCGL.h index fde4eaa434..cfdb173068 100644 --- a/cocos/2d/platform/mac/CCGL.h +++ b/cocos/2d/platform/mac/CCGL.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/mac/CCImage.mm b/cocos/2d/platform/mac/CCImage.mm index ddb5b1137c..fea424d8a6 100644 --- a/cocos/2d/platform/mac/CCImage.mm +++ b/cocos/2d/platform/mac/CCImage.mm @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/mac/CCPlatformDefine.h b/cocos/2d/platform/mac/CCPlatformDefine.h index 67a7d0ea3d..ca87ebf069 100644 --- a/cocos/2d/platform/mac/CCPlatformDefine.h +++ b/cocos/2d/platform/mac/CCPlatformDefine.h @@ -1,3 +1,28 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ diff --git a/cocos/2d/platform/mac/CCStdC.h b/cocos/2d/platform/mac/CCStdC.h index 475142b51a..804abebceb 100644 --- a/cocos/2d/platform/mac/CCStdC.h +++ b/cocos/2d/platform/mac/CCStdC.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/mac/CCWindow.h b/cocos/2d/platform/mac/CCWindow.h index 8e24b8a858..78ac008922 100644 --- a/cocos/2d/platform/mac/CCWindow.h +++ b/cocos/2d/platform/mac/CCWindow.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/mac/CCWindow.m b/cocos/2d/platform/mac/CCWindow.m index 29e4a2d309..97d442d29a 100644 --- a/cocos/2d/platform/mac/CCWindow.m +++ b/cocos/2d/platform/mac/CCWindow.m @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/mac/EAGLView.h b/cocos/2d/platform/mac/EAGLView.h index 0be91c9b09..8c8ecd477f 100644 --- a/cocos/2d/platform/mac/EAGLView.h +++ b/cocos/2d/platform/mac/EAGLView.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/mac/EAGLView.mm b/cocos/2d/platform/mac/EAGLView.mm index 8276f8e02c..68573ba99f 100644 --- a/cocos/2d/platform/mac/EAGLView.mm +++ b/cocos/2d/platform/mac/EAGLView.mm @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/win32/CCApplication.cpp b/cocos/2d/platform/win32/CCApplication.cpp index a29e842143..85fe2a4a4e 100644 --- a/cocos/2d/platform/win32/CCApplication.cpp +++ b/cocos/2d/platform/win32/CCApplication.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "CCApplication.h" #include "CCEGLView.h" #include "CCDirector.h" diff --git a/cocos/2d/platform/win32/CCApplication.h b/cocos/2d/platform/win32/CCApplication.h index 94a85d1007..bd392a4f8c 100644 --- a/cocos/2d/platform/win32/CCApplication.h +++ b/cocos/2d/platform/win32/CCApplication.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CC_APPLICATION_WIN32_H__ #define __CC_APPLICATION_WIN32_H__ diff --git a/cocos/2d/platform/win32/CCCommon.cpp b/cocos/2d/platform/win32/CCCommon.cpp index 2a66aaf49e..3aa3d6458f 100644 --- a/cocos/2d/platform/win32/CCCommon.cpp +++ b/cocos/2d/platform/win32/CCCommon.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -28,43 +29,6 @@ NS_CC_BEGIN #define MAX_LEN (cocos2d::kMaxLogLen + 1) -// XXX deprecated -void CCLog(const char * pszFormat, ...) -{ - char szBuf[MAX_LEN]; - - va_list ap; - va_start(ap, pszFormat); - vsnprintf_s(szBuf, MAX_LEN, MAX_LEN, pszFormat, ap); - va_end(ap); - - WCHAR wszBuf[MAX_LEN] = {0}; - MultiByteToWideChar(CP_UTF8, 0, szBuf, -1, wszBuf, sizeof(wszBuf)); - OutputDebugStringW(wszBuf); - OutputDebugStringA("\n"); - - WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), szBuf, sizeof(szBuf), NULL, FALSE); - printf("%s\n", szBuf); -} - -void log(const char * pszFormat, ...) -{ - char szBuf[MAX_LEN]; - - va_list ap; - va_start(ap, pszFormat); - vsnprintf_s(szBuf, MAX_LEN, MAX_LEN, pszFormat, ap); - va_end(ap); - - WCHAR wszBuf[MAX_LEN] = {0}; - MultiByteToWideChar(CP_UTF8, 0, szBuf, -1, wszBuf, sizeof(wszBuf)); - OutputDebugStringW(wszBuf); - OutputDebugStringA("\n"); - - WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), szBuf, sizeof(szBuf), NULL, FALSE); - printf("%s\n", szBuf); -} - void MessageBox(const char * pszMsg, const char * pszTitle) { MessageBoxA(NULL, pszMsg, pszTitle, MB_OK); diff --git a/cocos/2d/platform/win32/CCDevice.cpp b/cocos/2d/platform/win32/CCDevice.cpp index 163ad9a241..e934679bdc 100644 --- a/cocos/2d/platform/win32/CCDevice.cpp +++ b/cocos/2d/platform/win32/CCDevice.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "platform/CCDevice.h" #include "CCStdC.h" diff --git a/cocos/2d/platform/win32/CCEGLView.cpp b/cocos/2d/platform/win32/CCEGLView.cpp index e83eb289f2..b6a7c5e62b 100644 --- a/cocos/2d/platform/win32/CCEGLView.cpp +++ b/cocos/2d/platform/win32/CCEGLView.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -373,9 +374,12 @@ void EGLViewEventHandler::OnGLFWMouseScrollCallback(GLFWwindow* window, double x void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { - EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action || GLFW_REPEAT == action); - auto dispatcher = Director::getInstance()->getEventDispatcher(); - dispatcher->dispatchEvent(&event); + if (GLFW_REPEAT != action) + { + EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action); + auto dispatcher = Director::getInstance()->getEventDispatcher(); + dispatcher->dispatchEvent(&event); + } } void EGLViewEventHandler::OnGLFWCharCallback(GLFWwindow *window, unsigned int character) diff --git a/cocos/2d/platform/win32/CCEGLView.h b/cocos/2d/platform/win32/CCEGLView.h index 59432e27ba..17f9e4de06 100644 --- a/cocos/2d/platform/win32/CCEGLView.h +++ b/cocos/2d/platform/win32/CCEGLView.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp index 0572b95591..8f70d1ba88 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/win32/CCFileUtilsWin32.h b/cocos/2d/platform/win32/CCFileUtilsWin32.h index bfbdd5c725..d11d148f07 100644 --- a/cocos/2d/platform/win32/CCFileUtilsWin32.h +++ b/cocos/2d/platform/win32/CCFileUtilsWin32.h @@ -1,26 +1,27 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CC_FILEUTILS_WIN32_H__ #define __CC_FILEUTILS_WIN32_H__ diff --git a/cocos/2d/platform/win32/CCGL.h b/cocos/2d/platform/win32/CCGL.h index f87eac0851..4d2d0f9002 100644 --- a/cocos/2d/platform/win32/CCGL.h +++ b/cocos/2d/platform/win32/CCGL.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/win32/CCImage.cpp b/cocos/2d/platform/win32/CCImage.cpp index dd6d64742a..8cc3f508e5 100644 --- a/cocos/2d/platform/win32/CCImage.cpp +++ b/cocos/2d/platform/win32/CCImage.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/win32/CCPlatformDefine.h b/cocos/2d/platform/win32/CCPlatformDefine.h index 80447f0c73..964544860a 100644 --- a/cocos/2d/platform/win32/CCPlatformDefine.h +++ b/cocos/2d/platform/win32/CCPlatformDefine.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ diff --git a/cocos/2d/platform/win32/CCStdC.cpp b/cocos/2d/platform/win32/CCStdC.cpp index 8368194f76..15862bc0ad 100644 --- a/cocos/2d/platform/win32/CCStdC.cpp +++ b/cocos/2d/platform/win32/CCStdC.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/platform/win32/CCStdC.h b/cocos/2d/platform/win32/CCStdC.h index 027c8bf3cb..47677d29c9 100644 --- a/cocos/2d/platform/win32/CCStdC.h +++ b/cocos/2d/platform/win32/CCStdC.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -108,7 +109,22 @@ NS_CC_END #else -#include +#undef _WINSOCKAPI_ +#include + +// Conflicted with math.h isnan +#include +using std::isnan; + +inline int vsnprintf_s(char *buffer, size_t sizeOfBuffer, size_t count, + const char *format, va_list argptr) { + return vsnprintf(buffer, sizeOfBuffer, format, argptr); +} +inline errno_t strcpy_s(char *strDestination, size_t numberOfElements, + const char *strSource) { + strcpy(strDestination, strSource); + return 0; +} #endif // __MINGW32__ @@ -132,5 +148,8 @@ NS_CC_END #undef DELETE #endif +#undef min +#undef max + #endif // __CC_STD_C_H__ diff --git a/cocos/2d/renderer/CCCustomCommand.cpp b/cocos/2d/renderer/CCCustomCommand.cpp index b23c51723b..790bd13e69 100644 --- a/cocos/2d/renderer/CCCustomCommand.cpp +++ b/cocos/2d/renderer/CCCustomCommand.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCCustomCommand.h b/cocos/2d/renderer/CCCustomCommand.h index a837255594..7ff4c3e3ca 100644 --- a/cocos/2d/renderer/CCCustomCommand.h +++ b/cocos/2d/renderer/CCCustomCommand.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCFrustum.cpp b/cocos/2d/renderer/CCFrustum.cpp index 4e1468fe58..e02236e3b0 100644 --- a/cocos/2d/renderer/CCFrustum.cpp +++ b/cocos/2d/renderer/CCFrustum.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -23,7 +23,7 @@ ****************************************************************************/ #include "CCFrustum.h" -#include "platform/CCCommon.h" +#include "CCConsole.h" #include @@ -173,7 +173,7 @@ Frustum::~Frustum() { } -void Frustum::setupProjectionOrthogonal(const cocos2d::ViewTransform &view, float width, float height, float near, float far) +void Frustum::setupProjectionOrthogonal(const cocos2d::ViewTransform &view, float width, float height, float nearPlane, float farPlane) { kmVec3 cc = view.getPosition(); kmVec3 cDir = view.getDirection(); @@ -189,7 +189,7 @@ void Frustum::setupProjectionOrthogonal(const cocos2d::ViewTransform &view, floa kmVec3 point; kmVec3 normal; normal = cDir; - kmVec3Scale(&point, &cDir, near); + kmVec3Scale(&point, &cDir, nearPlane); kmVec3Add(&point, &point, &cc); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_NEAR], &point, &normal); } @@ -199,7 +199,7 @@ void Frustum::setupProjectionOrthogonal(const cocos2d::ViewTransform &view, floa kmVec3 point; kmVec3 normal; kmVec3Scale(&normal, &cDir, -1); - kmVec3Scale(&point, &cDir, far); + kmVec3Scale(&point, &cDir, farPlane); kmVec3Add(&point, &point, &cc); kmPlaneFromPointNormal(&_frustumPlanes[FrustumPlane::FRUSTUM_FAR], &point, &normal); } @@ -245,7 +245,7 @@ void Frustum::setupProjectionOrthogonal(const cocos2d::ViewTransform &view, floa } } -void Frustum::setupProjectionPerspective(const ViewTransform& view, float left, float right, float top, float bottom, float near, float far) +void Frustum::setupProjectionPerspective(const ViewTransform& view, float left, float right, float top, float bottom, float nearPlane, float farPlane) { kmVec3 cc = view.getPosition(); kmVec3 cDir = view.getDirection(); @@ -259,10 +259,10 @@ void Frustum::setupProjectionPerspective(const ViewTransform& view, float left, kmVec3 nearCenter; kmVec3 farCenter; - kmVec3Scale(&nearCenter, &cDir, near); + kmVec3Scale(&nearCenter, &cDir, nearPlane); kmVec3Add(&nearCenter, &nearCenter, &cc); - kmVec3Scale(&farCenter, &cDir, far); + kmVec3Scale(&farCenter, &cDir, farPlane); kmVec3Add(&farCenter, &farCenter, &cc); //near @@ -335,11 +335,11 @@ void Frustum::setupProjectionPerspective(const ViewTransform& view, float left, } -void Frustum::setupProjectionPerspectiveFov(const ViewTransform& view, float fov, float ratio, float near, float far) +void Frustum::setupProjectionPerspectiveFov(const ViewTransform& view, float fov, float ratio, float nearPlane, float farPlane) { - float width = 2 * near * tan(fov * 0.5); + float width = 2 * nearPlane * tan(fov * 0.5); float height = width/ratio; - setupProjectionPerspective(view, -width/2, width/2, height/2, -height/2, near, far); + setupProjectionPerspective(view, -width/2, width/2, height/2, -height/2, nearPlane, farPlane); } void Frustum::setupFromMatrix(const kmMat4 &view, const kmMat4 &projection) diff --git a/cocos/2d/renderer/CCFrustum.h b/cocos/2d/renderer/CCFrustum.h index 41f8b254ee..88772fda59 100644 --- a/cocos/2d/renderer/CCFrustum.h +++ b/cocos/2d/renderer/CCFrustum.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCGroupCommand.cpp b/cocos/2d/renderer/CCGroupCommand.cpp index 12fddd3105..8bd6f85888 100644 --- a/cocos/2d/renderer/CCGroupCommand.cpp +++ b/cocos/2d/renderer/CCGroupCommand.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCGroupCommand.h b/cocos/2d/renderer/CCGroupCommand.h index 7e2ed1abb7..7a6b6e511c 100644 --- a/cocos/2d/renderer/CCGroupCommand.h +++ b/cocos/2d/renderer/CCGroupCommand.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCMaterialManager.cpp b/cocos/2d/renderer/CCMaterialManager.cpp index 9f4e7c898c..04db21ec76 100644 --- a/cocos/2d/renderer/CCMaterialManager.cpp +++ b/cocos/2d/renderer/CCMaterialManager.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCMaterialManager.h b/cocos/2d/renderer/CCMaterialManager.h index c6033ccadf..53330855a5 100644 --- a/cocos/2d/renderer/CCMaterialManager.h +++ b/cocos/2d/renderer/CCMaterialManager.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCQuadCommand.cpp b/cocos/2d/renderer/CCQuadCommand.cpp index ff63200f4d..b69fd075d3 100644 --- a/cocos/2d/renderer/CCQuadCommand.cpp +++ b/cocos/2d/renderer/CCQuadCommand.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -58,12 +58,6 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* _capacity = quadCount; } - kmMat4 p, mvp; - kmGLGetMatrix(KM_GL_PROJECTION, &p); - - kmMat4Multiply(&mvp, &p, &mv); - - _quadCount = quadCount; memcpy(_quad, quad, sizeof(V3F_C4B_T2F_Quad) * quadCount); @@ -74,7 +68,7 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* vec1.x = q->bl.vertices.x; vec1.y = q->bl.vertices.y; vec1.z = q->bl.vertices.z; - kmVec3TransformCoord(&out1, &vec1, &mvp); + kmVec3Transform(&out1, &vec1, &mv); q->bl.vertices.x = out1.x; q->bl.vertices.y = out1.y; q->bl.vertices.z = out1.z; @@ -83,7 +77,7 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* vec2.x = q->br.vertices.x; vec2.y = q->br.vertices.y; vec2.z = q->br.vertices.z; - kmVec3TransformCoord(&out2, &vec2, &mvp); + kmVec3Transform(&out2, &vec2, &mv); q->br.vertices.x = out2.x; q->br.vertices.y = out2.y; q->br.vertices.z = out2.z; @@ -92,7 +86,7 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* vec3.x = q->tr.vertices.x; vec3.y = q->tr.vertices.y; vec3.z = q->tr.vertices.z; - kmVec3TransformCoord(&out3, &vec3, &mvp); + kmVec3Transform(&out3, &vec3, &mv); q->tr.vertices.x = out3.x; q->tr.vertices.y = out3.y; q->tr.vertices.z = out3.z; @@ -101,7 +95,7 @@ void QuadCommand::init(int viewport, int32_t depth, GLuint textureID, GLProgram* vec4.x = q->tl.vertices.x; vec4.y = q->tl.vertices.y; vec4.z = q->tl.vertices.z; - kmVec3TransformCoord(&out4, &vec4, &mvp); + kmVec3Transform(&out4, &vec4, &mv); q->tl.vertices.x = out4.x; q->tl.vertices.y = out4.y; q->tl.vertices.z = out4.z; @@ -119,9 +113,9 @@ int64_t QuadCommand::generateID() //Generate Material ID //TODO fix shader ID generation - CCASSERT(_shader->getProgram() < 64, "ShaderID is greater than 64"); + CCASSERT(_shader->getProgram() < pow(2,10), "ShaderID is greater than 2^10"); //TODO fix texture ID generation - CCASSERT(_textureID < 1024, "TextureID is greater than 1024"); + CCASSERT(_textureID < pow(2,18), "TextureID is greater than 2^18"); //TODO fix blend id generation int blendID = 0; @@ -146,9 +140,17 @@ int64_t QuadCommand::generateID() blendID = 4; } - _materialID = (int32_t)_shader->getProgram() << 28 - | (int32_t)blendID << 24 - | (int32_t)_textureID << 14; + //TODO Material ID should be part of the ID + // + // Temporal hack (later, these 32-bits should be packed in 24-bits + // + // +---------------------+-------------------+----------------------+ + // | Shader ID (10 bits) | Blend ID (4 bits) | Texture ID (18 bits) | + // +---------------------+-------------------+----------------------+ + + _materialID = (int32_t)_shader->getProgram() << 22 + | (int32_t)blendID << 18 + | (int32_t)_textureID << 0; //Generate RenderCommandID _id = (int64_t)_viewport << 61 diff --git a/cocos/2d/renderer/CCQuadCommand.h b/cocos/2d/renderer/CCQuadCommand.h index 441bb842fe..411dc4913b 100644 --- a/cocos/2d/renderer/CCQuadCommand.h +++ b/cocos/2d/renderer/CCQuadCommand.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCRenderCommand.cpp b/cocos/2d/renderer/CCRenderCommand.cpp index 0933f2dcd7..71fee4edb0 100644 --- a/cocos/2d/renderer/CCRenderCommand.cpp +++ b/cocos/2d/renderer/CCRenderCommand.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCRenderCommand.h b/cocos/2d/renderer/CCRenderCommand.h index 35d5ac4fe8..930ed1ecde 100644 --- a/cocos/2d/renderer/CCRenderCommand.h +++ b/cocos/2d/renderer/CCRenderCommand.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCRenderCommandPool.h b/cocos/2d/renderer/CCRenderCommandPool.h index 0f7f721f46..21415039f1 100644 --- a/cocos/2d/renderer/CCRenderCommandPool.h +++ b/cocos/2d/renderer/CCRenderCommandPool.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCRenderMaterial.cpp b/cocos/2d/renderer/CCRenderMaterial.cpp index da32ca0357..4b85023d49 100644 --- a/cocos/2d/renderer/CCRenderMaterial.cpp +++ b/cocos/2d/renderer/CCRenderMaterial.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCRenderMaterial.h b/cocos/2d/renderer/CCRenderMaterial.h index 796818e096..9a51225ba0 100644 --- a/cocos/2d/renderer/CCRenderMaterial.h +++ b/cocos/2d/renderer/CCRenderMaterial.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/2d/renderer/CCRenderer.cpp b/cocos/2d/renderer/CCRenderer.cpp index 8dbe93557e..1d3b8cd2b4 100644 --- a/cocos/2d/renderer/CCRenderer.cpp +++ b/cocos/2d/renderer/CCRenderer.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -29,7 +29,9 @@ #include "renderer/CCQuadCommand.h" #include "CCGroupCommand.h" #include "CCConfiguration.h" -#include "CCNotificationCenter.h" +#include "CCDirector.h" +#include "CCEventDispatcher.h" +#include "CCEventListenerCustom.h" #include "CCEventType.h" #include // for std::stable_sort @@ -45,6 +47,9 @@ Renderer::Renderer() ,_lastCommand(0) ,_numQuads(0) ,_glViewAssigned(false) +#if CC_ENABLE_CACHE_TEXTURE_DATA +,_cacheTextureListener(nullptr) +#endif { _commandGroupStack.push(DEFAULT_RENDER_QUEUE); @@ -66,18 +71,19 @@ Renderer::~Renderer() GL::bindVAO(0); } #if CC_ENABLE_CACHE_TEXTURE_DATA - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); + Director::getInstance()->getEventDispatcher()->removeEventListener(_cacheTextureListener); #endif } void Renderer::initGLView() { #if CC_ENABLE_CACHE_TEXTURE_DATA - // listen the event when app go to background - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(Renderer::onBackToForeground), - EVNET_COME_TO_FOREGROUND, - nullptr); + _cacheTextureListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ + /** listen the event that coming to foreground on Android */ + this->setupBuffer(); + }); + + Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_cacheTextureListener, -1); #endif setupIndices(); @@ -87,12 +93,6 @@ void Renderer::initGLView() _glViewAssigned = true; } -void Renderer::onBackToForeground(Object* obj) -{ - CC_UNUSED_PARAM(obj); - setupBuffer(); -} - void Renderer::setupIndices() { for( int i=0; i < VBO_SIZE; i++) diff --git a/cocos/2d/renderer/CCRenderer.h b/cocos/2d/renderer/CCRenderer.h index 7cfa3ac707..e732547130 100644 --- a/cocos/2d/renderer/CCRenderer.h +++ b/cocos/2d/renderer/CCRenderer.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -35,6 +35,8 @@ NS_CC_BEGIN +class EventListenerCustom; + typedef std::vector RenderQueue; struct RenderStackElement @@ -43,7 +45,7 @@ struct RenderStackElement size_t currentIndex; }; -class Renderer : public Object +class Renderer { public: static const int VBO_SIZE = 65536 / 6; @@ -76,8 +78,6 @@ protected: //Draw the previews queued quads and flush previous context void flush(); - void onBackToForeground(Object* obj); - std::stack _commandGroupStack; std::stack _renderStack; @@ -96,6 +96,10 @@ protected: int _numQuads; bool _glViewAssigned; + +#if CC_ENABLE_CACHE_TEXTURE_DATA + EventListenerCustom* _cacheTextureListener; +#endif }; NS_CC_END diff --git a/cocos/audio/CMakeLists.txt b/cocos/audio/CMakeLists.txt index 9ad9e99b12..c65f85fb29 100644 --- a/cocos/audio/CMakeLists.txt +++ b/cocos/audio/CMakeLists.txt @@ -42,7 +42,14 @@ target_link_libraries(audio set_target_properties(audio PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) + +elseif(WIN32) + +target_link_libraries(audio + Winmm +) + endif() diff --git a/cocos/audio/android/ccdandroidUtils.cpp b/cocos/audio/android/ccdandroidUtils.cpp index edb0bf4540..b6bba2c6fe 100644 --- a/cocos/audio/android/ccdandroidUtils.cpp +++ b/cocos/audio/android/ccdandroidUtils.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "ccdandroidUtils.h" #include "cocos2d.h" diff --git a/cocos/audio/android/ccdandroidUtils.h b/cocos/audio/android/ccdandroidUtils.h index b5a8270ac8..e5f6791ef1 100644 --- a/cocos/audio/android/ccdandroidUtils.h +++ b/cocos/audio/android/ccdandroidUtils.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CCDANDROIDUTILS_H__ #define __CCDANDROIDUTILS_H__ diff --git a/cocos/audio/android/cddSimpleAudioEngine.cpp b/cocos/audio/android/cddSimpleAudioEngine.cpp index 5eff566a3a..4d1849df41 100644 --- a/cocos/audio/android/cddSimpleAudioEngine.cpp +++ b/cocos/audio/android/cddSimpleAudioEngine.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp b/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp index a1e351d2f3..6978a8d26c 100644 --- a/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp +++ b/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + #include "cddandroidAndroidJavaEngine.h" #include "platform/android/jni/JniHelper.h" #include "ccdandroidUtils.h" diff --git a/cocos/audio/android/jni/cddandroidAndroidJavaEngine.h b/cocos/audio/android/jni/cddandroidAndroidJavaEngine.h index 451f9c148c..a6bb400ea4 100644 --- a/cocos/audio/android/jni/cddandroidAndroidJavaEngine.h +++ b/cocos/audio/android/jni/cddandroidAndroidJavaEngine.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CDDANDRIODANDROIDJAVAENGINE_H__ #define __CDDANDRIODANDROIDJAVAENGINE_H__ diff --git a/cocos/audio/android/opensl/OpenSLEngine.cpp b/cocos/audio/android/opensl/OpenSLEngine.cpp index e2c1943b7c..f3f7423273 100644 --- a/cocos/audio/android/opensl/OpenSLEngine.cpp +++ b/cocos/audio/android/opensl/OpenSLEngine.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "OpenSLEngine.h" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,"OPENSL_ENGINE.CPP", __VA_ARGS__) diff --git a/cocos/audio/android/opensl/OpenSLEngine.h b/cocos/audio/android/opensl/OpenSLEngine.h index 3f6132bf0e..d0296bde06 100644 --- a/cocos/audio/android/opensl/OpenSLEngine.h +++ b/cocos/audio/android/opensl/OpenSLEngine.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef _OPENSL_ENGINE_H_ #define _OPENSL_ENGINE_H_ diff --git a/cocos/audio/android/opensl/SimpleAudioEngineOpenSL.cpp b/cocos/audio/android/opensl/SimpleAudioEngineOpenSL.cpp index 47a89f6abb..a5b7326c91 100644 --- a/cocos/audio/android/opensl/SimpleAudioEngineOpenSL.cpp +++ b/cocos/audio/android/opensl/SimpleAudioEngineOpenSL.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "SimpleAudioEngineOpenSL.h" #include #include diff --git a/cocos/audio/android/opensl/SimpleAudioEngineOpenSL.h b/cocos/audio/android/opensl/SimpleAudioEngineOpenSL.h index 8f5059e9d7..4b0d190843 100644 --- a/cocos/audio/android/opensl/SimpleAudioEngineOpenSL.h +++ b/cocos/audio/android/opensl/SimpleAudioEngineOpenSL.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef _SIMPLE_AUDIO_ENGINE_OPENSL_H_ #define _SIMPLE_AUDIO_ENGINE_OPENSL_H_ diff --git a/cocos/audio/android/opensl/cddandroidOpenSLEngine.cpp b/cocos/audio/android/opensl/cddandroidOpenSLEngine.cpp index 4f45ad9698..37b8ca3a1b 100644 --- a/cocos/audio/android/opensl/cddandroidOpenSLEngine.cpp +++ b/cocos/audio/android/opensl/cddandroidOpenSLEngine.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "cddandroidOpenSLEngine.h" namespace CocosDenshion { diff --git a/cocos/audio/android/opensl/cddandroidOpenSLEngine.h b/cocos/audio/android/opensl/cddandroidOpenSLEngine.h index 9355cf59a0..594d503ad3 100644 --- a/cocos/audio/android/opensl/cddandroidOpenSLEngine.h +++ b/cocos/audio/android/opensl/cddandroidOpenSLEngine.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CDDANDROIDOPENSLENGINE_H__ #define __CDDANDROIDOPENSLENGINE_H__ diff --git a/cocos/audio/include/Export.h b/cocos/audio/include/Export.h index 30096064c4..86ca3b7845 100644 --- a/cocos/audio/include/Export.h +++ b/cocos/audio/include/Export.h @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __EXPORT_COMMON__ #define __EXPORT_COMMON__ diff --git a/cocos/audio/include/SimpleAudioEngine.h b/cocos/audio/include/SimpleAudioEngine.h index 29e2f2c05f..8eda5ddeb6 100644 --- a/cocos/audio/include/SimpleAudioEngine.h +++ b/cocos/audio/include/SimpleAudioEngine.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Steve Oldmeadow +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/audio/ios/CocosDenshion.m b/cocos/audio/ios/CocosDenshion.m index bc3a995766..4df6b2a472 100644 --- a/cocos/audio/ios/CocosDenshion.m +++ b/cocos/audio/ios/CocosDenshion.m @@ -258,6 +258,7 @@ static BOOL _mixerRateSet = NO; device = alcGetContextsDevice(currentContext); //Release context CDLOGINFO(@"Denshion::CDSoundEngine - destroy context."); + alcMakeContextCurrent(NULL); alcDestroyContext(currentContext); //Close device CDLOGINFO(@"Denshion::CDSoundEngine - close device."); diff --git a/cocos/audio/linux/AudioPlayer.h b/cocos/audio/linux/AudioPlayer.h index 074b230c0f..28aafdce16 100644 --- a/cocos/audio/linux/AudioPlayer.h +++ b/cocos/audio/linux/AudioPlayer.h @@ -1,9 +1,27 @@ -/* - * AudioPlayer.h - * - * Created on: Aug 18, 2011 - * Author: laschweinski - */ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef AUDIOPLAYER_H_ #define AUDIOPLAYER_H_ diff --git a/cocos/audio/linux/FmodAudioPlayer.cpp b/cocos/audio/linux/FmodAudioPlayer.cpp index ef4f5bb9d2..ffe27136a5 100644 --- a/cocos/audio/linux/FmodAudioPlayer.cpp +++ b/cocos/audio/linux/FmodAudioPlayer.cpp @@ -1,9 +1,27 @@ -/* - * FmodAudioPlayer.cpp - * - * Created on: Aug 18, 2011 - * Author: laschweinski - */ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "FmodAudioPlayer.h" #include diff --git a/cocos/audio/linux/FmodAudioPlayer.h b/cocos/audio/linux/FmodAudioPlayer.h index 4af2265425..887d67ea8a 100644 --- a/cocos/audio/linux/FmodAudioPlayer.h +++ b/cocos/audio/linux/FmodAudioPlayer.h @@ -1,9 +1,27 @@ -/* - * FmodAudioPlayer.h - * - * Created on: Aug 18, 2011 - * Author: laschweinski - */ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef FMODAUDIOPLAYER_H_ #define FMODAUDIOPLAYER_H_ diff --git a/cocos/audio/linux/SimpleAudioEngineFMOD.cpp b/cocos/audio/linux/SimpleAudioEngineFMOD.cpp index 931ccdc994..ace87437ff 100644 --- a/cocos/audio/linux/SimpleAudioEngineFMOD.cpp +++ b/cocos/audio/linux/SimpleAudioEngineFMOD.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2011 Laschweinski +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef OPENAL #include "SimpleAudioEngine.h" diff --git a/cocos/audio/mac/CocosDenshion.m b/cocos/audio/mac/CocosDenshion.m index 8e8cd9c8cc..028ea84042 100644 --- a/cocos/audio/mac/CocosDenshion.m +++ b/cocos/audio/mac/CocosDenshion.m @@ -259,6 +259,7 @@ static BOOL _mixerRateSet = NO; device = alcGetContextsDevice(currentContext); //Release context CDLOGINFO(@"Denshion::CDSoundEngine - destroy context."); + alcMakeContextCurrent(NULL); alcDestroyContext(currentContext); //Close device CDLOGINFO(@"Denshion::CDSoundEngine - close device."); diff --git a/cocos/audio/openal/SimpleAudioEngineOpenAL.cpp b/cocos/audio/openal/SimpleAudioEngineOpenAL.cpp index 01ba4e6e79..fafa8f89a8 100644 --- a/cocos/audio/openal/SimpleAudioEngineOpenAL.cpp +++ b/cocos/audio/openal/SimpleAudioEngineOpenAL.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/audio/win32/SimpleAudioEngine.cpp b/cocos/audio/win32/SimpleAudioEngine.cpp index 06245b8d5b..fed1de067f 100644 --- a/cocos/audio/win32/SimpleAudioEngine.cpp +++ b/cocos/audio/win32/SimpleAudioEngine.cpp @@ -1,3 +1,27 @@ +/**************************************************************************** +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "SimpleAudioEngine.h" #include diff --git a/cocos/base/CCAffineTransform.cpp b/cocos/base/CCAffineTransform.cpp index ff81b275d1..7d72528285 100644 --- a/cocos/base/CCAffineTransform.cpp +++ b/cocos/base/CCAffineTransform.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/CCAffineTransform.h b/cocos/base/CCAffineTransform.h index c3034bbf50..7e6445a8e8 100644 --- a/cocos/base/CCAffineTransform.h +++ b/cocos/base/CCAffineTransform.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/CCArray.cpp b/cocos/base/CCArray.cpp index 8e827878a5..eecd15fe63 100644 --- a/cocos/base/CCArray.cpp +++ b/cocos/base/CCArray.cpp @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/CCArray.h b/cocos/base/CCArray.h index 8b40329a26..0ceedadff9 100644 --- a/cocos/base/CCArray.h +++ b/cocos/base/CCArray.h @@ -1,6 +1,7 @@ /**************************************************************************** -Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/CCAutoreleasePool.cpp b/cocos/base/CCAutoreleasePool.cpp index 1dd5d403de..5e551ec3aa 100644 --- a/cocos/base/CCAutoreleasePool.cpp +++ b/cocos/base/CCAutoreleasePool.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/CCAutoreleasePool.h b/cocos/base/CCAutoreleasePool.h index 67930173e2..d6ee35349b 100644 --- a/cocos/base/CCAutoreleasePool.h +++ b/cocos/base/CCAutoreleasePool.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/CCBool.h b/cocos/base/CCBool.h index c07c7a1e9a..216d9b5656 100644 --- a/cocos/base/CCBool.h +++ b/cocos/base/CCBool.h @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/CCConsole.cpp b/cocos/base/CCConsole.cpp index e2440a49f7..69c44c4494 100644 --- a/cocos/base/CCConsole.cpp +++ b/cocos/base/CCConsole.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -31,7 +31,7 @@ #include #include -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__MINGW32__) #include #include @@ -49,6 +49,7 @@ #include "CCDirector.h" #include "CCScheduler.h" #include "CCScene.h" +#include "CCPlatformConfig.h" NS_CC_BEGIN @@ -91,44 +92,111 @@ static void printSceneGraphBoot(int fd) mydprintf(fd, "Total Nodes: %d\n", total); } +#if defined(__MINGW32__) +static const char* inet_ntop(int af, const void* src, char* dst, int cnt) +{ + struct sockaddr_in srcaddr; + + memset(&srcaddr, 0, sizeof(struct sockaddr_in)); + memcpy(&(srcaddr.sin_addr), src, sizeof(srcaddr.sin_addr)); + + srcaddr.sin_family = af; + if (WSAAddressToString((struct sockaddr*) &srcaddr, sizeof(struct sockaddr_in), 0, dst, (LPDWORD) &cnt) != 0) + { + return nullptr; + } + return dst; +} +#endif + + +// +// Free functions to log +// + +// XXX: Deprecated +void CCLog(const char * format, ...) +{ + va_list args; + va_start(args, format); + log(format, args); + va_end(args); +} + +void log(const char * format, ...) +{ + va_list args; + va_start(args, format); + log(format, args); + va_end(args); +} + +void log(const char *format, va_list args) +{ + char buf[MAX_LOG_LENGTH]; + + vsnprintf(buf, MAX_LOG_LENGTH-3, format, args); + strcat(buf, "\n"); + +#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID + __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf); + +#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 + WCHAR wszBuf[MAX_LOG_LENGTH] = {0}; + MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(wszBuf)); + OutputDebugStringW(wszBuf); + OutputDebugStringA("\n"); + + WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), buf, sizeof(buf), NULL, FALSE); + printf("%s\n", buf); + +#else + // Linux, Mac, iOS, etc + fprintf(stdout, "cocos2d: %s", buf); + fflush(stdout); +#endif + + Director::getInstance()->getConsole()->log(buf); +} + // // Console code // -Console* Console::create() -{ - auto ret = new Console; - - ret->autorelease(); - return ret; -} - Console::Console() : _listenfd(-1) , _running(false) , _endThread(false) -, _maxCommands(5) , _userCommands(nullptr) , _maxUserCommands(0) +, _sendDebugStrings(false) { // VS2012 doesn't support initializer list, so we create a new array and assign its elements to '_command'. Command commands[] = { - { "fps on", [](int fd, const char* command) { - Director *dir = Director::getInstance(); - Scheduler *sched = dir->getScheduler(); - sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, true)); - } }, - { "fps off", [](int fd, const char* command) { - Director *dir = Director::getInstance(); - Scheduler *sched = dir->getScheduler(); - sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, false)); - } }, - { "scene graph", std::bind(&Console::commandSceneGraph, this, std::placeholders::_1, std::placeholders::_2) }, - { "exit", std::bind(&Console::commandExit, this, std::placeholders::_1, std::placeholders::_2) }, - { "help", std::bind(&Console::commandHelp, this, std::placeholders::_1, std::placeholders::_2) } }; + { "debug msg on", [&](int fd, const char* command) { + _sendDebugStrings = true; + } }, + { "debug msg off", [&](int fd, const char* command) { + _sendDebugStrings = false; + } }, + { "exit", std::bind(&Console::commandExit, this, std::placeholders::_1, std::placeholders::_2) }, + { "fps on", [](int fd, const char* command) { + Director *dir = Director::getInstance(); + Scheduler *sched = dir->getScheduler(); + sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, true)); + } }, + { "fps off", [](int fd, const char* command) { + Director *dir = Director::getInstance(); + Scheduler *sched = dir->getScheduler(); + sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, false)); + } }, + { "help", std::bind(&Console::commandHelp, this, std::placeholders::_1, std::placeholders::_2) }, + { "scene graph", std::bind(&Console::commandSceneGraph, this, std::placeholders::_1, std::placeholders::_2) }, + }; - for (size_t i = 0; i < sizeof(commands)/sizeof(commands[0]) && i < sizeof(_commands)/sizeof(_commands[0]); ++i) + _maxCommands = sizeof(commands)/sizeof(commands[0]); + for (int i = 0; i < _maxCommands; ++i) { _commands[i] = commands[i]; } @@ -136,7 +204,7 @@ Console::Console() Console::~Console() { - cancel(); + stop(); } bool Console::listenOnTCP(int port) @@ -190,14 +258,14 @@ bool Console::listenOnTCP(int port) char buf[INET_ADDRSTRLEN] = ""; struct sockaddr_in *sin = (struct sockaddr_in*) res->ai_addr; if( inet_ntop(res->ai_family, &sin->sin_addr, buf, sizeof(buf)) != NULL ) - log("Console: listening on %s : %d", buf, ntohs(sin->sin_port)); + cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin_port)); else perror("inet_ntop"); } else if (res->ai_family == AF_INET6) { char buf[INET6_ADDRSTRLEN] = ""; struct sockaddr_in6 *sin = (struct sockaddr_in6*) res->ai_addr; if( inet_ntop(res->ai_family, &sin->sin6_addr, buf, sizeof(buf)) != NULL ) - log("Console: listening on %s : %d", buf, ntohs(sin->sin6_port)); + cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin6_port)); else perror("inet_ntop"); } @@ -210,14 +278,18 @@ bool Console::listenOnTCP(int port) bool Console::listenOnFileDescriptor(int fd) { - CCASSERT(!_running, "already running"); + if(_running) { + cocos2d::log("Console already started. 'stop' it before calling 'listen' again"); + return false; + } + _listenfd = fd; _thread = std::thread( std::bind( &Console::loop, this) ); return true; } -void Console::cancel() +void Console::stop() { if( _running ) { _endThread = true; @@ -296,7 +368,7 @@ bool Console::parseCommand(int fd) } } - if(!found) { + if(!found && strcmp(_buffer, "\r\n")!=0) { const char err[] = "Unknown command. Type 'help' for options\n"; write(fd, err, sizeof(err)); } @@ -360,6 +432,15 @@ void Console::addClient() } } +void Console::log(const char* buf) +{ + if( _sendDebugStrings ) { + _DebugStringsMutex.lock(); + _DebugStrings.push_back(buf); + _DebugStringsMutex.unlock(); + } +} + // // Main Loop // @@ -386,40 +467,55 @@ void Console::loop() timeout_copy = timeout; int nready = select(_maxfd+1, ©_set, NULL, NULL, &timeout_copy); - if( nready == -1 ) { - /* error ?*/ + if( nready == -1 ) + { + /* error */ if(errno != EINTR) log("Abnormal error in select()\n"); continue; - - } else if( nready == 0 ) { - /* timeout ? */ - continue; } - - // new client - if(FD_ISSET(_listenfd, ©_set)) { - addClient(); - if(--nready <= 0) - continue; + else if( nready == 0 ) + { + /* timeout. do somethig ? */ } - - // data from client - std::vector to_remove; - for(const auto &fd: _fds) { - if(FD_ISSET(fd,©_set)) { - if( ! parseCommand(fd) ) { - to_remove.push_back(fd); - } + else + { + /* new client */ + if(FD_ISSET(_listenfd, ©_set)) { + addClient(); if(--nready <= 0) - break; + continue; + } + + /* data from client */ + std::vector to_remove; + for(const auto &fd: _fds) { + if(FD_ISSET(fd,©_set)) { + if( ! parseCommand(fd) ) { + to_remove.push_back(fd); + } + if(--nready <= 0) + break; + } + } + + /* remove closed conections */ + for(int fd: to_remove) { + FD_CLR(fd, &_read_set); + _fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end()); } } - // remove closed conections - for(int fd: to_remove) { - FD_CLR(fd, &_read_set); - _fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end()); + /* Any message for the remote console ? send it! */ + if( !_DebugStrings.empty() ) { + _DebugStringsMutex.lock(); + for(const auto &str : _DebugStrings) { + for(const auto &fd : _fds) { + write(fd, str.c_str(), str.length()); + } + } + _DebugStrings.clear(); + _DebugStringsMutex.unlock(); } } diff --git a/cocos/base/CCConsole.h b/cocos/base/CCConsole.h index d401991525..eb27bcfb34 100644 --- a/cocos/base/CCConsole.h +++ b/cocos/base/CCConsole.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -26,8 +26,9 @@ #ifndef __CCCONSOLE_H__ #define __CCCONSOLE_H__ -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__MINGW32__) #include +#include //typedef SSIZE_T ssize_t; // ssize_t was redefined as int in libwebsockets.h. // Therefore, to avoid conflict, we needs the same definition. @@ -39,13 +40,26 @@ typedef int ssize_t; #include #include #include +#include +#include + +#include #include "ccMacros.h" -#include "CCObject.h" +#include "CCPlatformMacros.h" NS_CC_BEGIN +/// The max length of CCLog message. +static const int MAX_LOG_LENGTH = 16*1024; + +/** + @brief Output Debug message. + */ +void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2); +void CC_DLL log(const char * format, va_list args); + /** Console is helper class that lets the developer control the game from TCP connection. Console will spawn a new thread that will listen to a specified TCP port. Console has a basic token parser. Each token is associated with an std::function. @@ -55,17 +69,19 @@ NS_CC_BEGIN scheduler->performFunctionInCocosThread( ... ); ``` */ -class CC_DLL Console : public Object +class CC_DLL Console { public: - struct Command { const char *name; std::function callback; }; - /** creates a new instnace of the Console */ - static Console* create(); + /** Constructor */ + Console(); + + /** Destructor */ + virtual ~Console(); /** starts listening to specifed TCP port */ bool listenOnTCP(int port); @@ -73,18 +89,17 @@ public: /** starts listening to specifed file descriptor */ bool listenOnFileDescriptor(int fd); - /** cancels the Console. Cancel will be called at destruction time as well */ - void cancel(); + /** stops the Console. 'stop' will be called at destruction time as well */ + void stop(); /** sets user tokens */ void setUserCommands( Command* commands, int numberOfCommands); + /** log something in the console */ + void log(const char *buf); + protected: - Console(); - virtual ~Console(); - void loop(); - ssize_t readline(int fd); bool parseCommand(int fd); void sendPrompt(int fd); @@ -108,11 +123,17 @@ protected: char _buffer[512]; - struct Command _commands[15]; + struct Command _commands[64]; int _maxCommands; struct Command *_userCommands; int _maxUserCommands; + + // strings generated by cocos2d sent to the remote console + bool _sendDebugStrings; + std::mutex _DebugStringsMutex; + std::vector _DebugStrings; + private: CC_DISALLOW_COPY_AND_ASSIGN(Console); }; diff --git a/cocos/base/CCData.cpp b/cocos/base/CCData.cpp index 77674c853d..0e3fcd4c26 100644 --- a/cocos/base/CCData.cpp +++ b/cocos/base/CCData.cpp @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org - + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/base/CCData.h b/cocos/base/CCData.h index 7ba7431c94..ad259bc723 100644 --- a/cocos/base/CCData.h +++ b/cocos/base/CCData.h @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org - + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/cocos/base/CCDataVisitor.cpp b/cocos/base/CCDataVisitor.cpp index 27ead8fbb3..b149321649 100644 --- a/cocos/base/CCDataVisitor.cpp +++ b/cocos/base/CCDataVisitor.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/CCDataVisitor.h b/cocos/base/CCDataVisitor.h index dda87ffc36..96f004987f 100644 --- a/cocos/base/CCDataVisitor.h +++ b/cocos/base/CCDataVisitor.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/CCDictionary.cpp b/cocos/base/CCDictionary.cpp index b958ce0be7..5be01c5c29 100644 --- a/cocos/base/CCDictionary.cpp +++ b/cocos/base/CCDictionary.cpp @@ -1,6 +1,7 @@ /**************************************************************************** - Copyright (c) 2012 - 2013 cocos2d-x.org - + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,6 +27,12 @@ #include "CCString.h" #include "CCInteger.h" #include "platform/CCFileUtils.h" +#include "CCString.h" +#include "CCBool.h" +#include "CCInteger.h" +#include "CCFloat.h" +#include "CCDouble.h" +#include "CCArray.h" using namespace std; @@ -461,15 +468,97 @@ __Dictionary* __Dictionary::createWithContentsOfFile(const char *pFileName) return ret; } +static ValueMap ccdictionary_to_valuemap(__Dictionary* dict); + +static ValueVector ccarray_to_valuevector(__Array* arr) +{ + ValueVector ret; + + Object* obj; + CCARRAY_FOREACH(arr, obj) + { + Value arrElement; + + __String* strVal = nullptr; + __Dictionary* dictVal = nullptr; + __Array* arrVal = nullptr; + __Double* doubleVal = nullptr; + __Bool* boolVal = nullptr; + __Float* floatVal = nullptr; + __Integer* intVal = nullptr; + + if ((strVal = dynamic_cast<__String *>(obj))) { + arrElement = Value(strVal->getCString()); + } else if ((dictVal = dynamic_cast<__Dictionary*>(obj))) { + arrElement = ccdictionary_to_valuemap(dictVal); + } else if ((arrVal = dynamic_cast<__Array*>(obj))) { + arrElement = ccarray_to_valuevector(arrVal); + } else if ((doubleVal = dynamic_cast<__Double*>(obj))) { + arrElement = Value(doubleVal->getValue()); + } else if ((floatVal = dynamic_cast<__Float*>(obj))) { + arrElement = Value(floatVal->getValue()); + } else if ((intVal = dynamic_cast<__Integer*>(obj))) { + arrElement = Value(intVal->getValue()); + } else if ((boolVal = dynamic_cast<__Bool*>(obj))) { + arrElement = boolVal->getValue() ? Value(true) : Value(false); + } else { + CCASSERT(false, "the type isn't suppored."); + } + + ret.push_back(arrElement); + } + return ret; +} + +static ValueMap ccdictionary_to_valuemap(__Dictionary* dict) +{ + ValueMap ret; + DictElement* pElement = nullptr; + CCDICT_FOREACH(dict, pElement) + { + Object* obj = pElement->getObject(); + + __String* strVal = nullptr; + __Dictionary* dictVal = nullptr; + __Array* arrVal = nullptr; + __Double* doubleVal = nullptr; + __Bool* boolVal = nullptr; + __Float* floatVal = nullptr; + __Integer* intVal = nullptr; + + Value dictElement; + + if ((strVal = dynamic_cast<__String *>(obj))) { + dictElement = Value(strVal->getCString()); + } else if ((dictVal = dynamic_cast<__Dictionary*>(obj))) { + dictElement = ccdictionary_to_valuemap(dictVal); + } else if ((arrVal = dynamic_cast<__Array*>(obj))) { + dictElement = ccarray_to_valuevector(arrVal); + } else if ((doubleVal = dynamic_cast<__Double*>(obj))) { + dictElement = Value(doubleVal->getValue()); + } else if ((floatVal = dynamic_cast<__Float*>(obj))) { + dictElement = Value(floatVal->getValue()); + } else if ((intVal = dynamic_cast<__Integer*>(obj))) { + dictElement = Value(intVal->getValue()); + } else if ((boolVal = dynamic_cast<__Bool*>(obj))) { + dictElement = boolVal->getValue() ? Value(true) : Value(false); + } else { + CCASSERT(false, "the type isn't suppored."); + } + + const char* key = pElement->getStrKey(); + if (key && strlen(key) > 0) + { + ret[key] = dictElement; + } + } + return ret; +} + + bool __Dictionary::writeToFile(const char *fullPath) { - ValueMap dict; - DictElement* element = nullptr; - CCDICT_FOREACH(this, element) - { - dict[element->getStrKey()] = Value(static_cast<__String*>(element->getObject())->getCString()); - } - + ValueMap dict = ccdictionary_to_valuemap(this); return FileUtils::getInstance()->writeToFile(dict, fullPath); } diff --git a/cocos/base/CCDictionary.h b/cocos/base/CCDictionary.h index ef20d76e05..6be84d7e2d 100644 --- a/cocos/base/CCDictionary.h +++ b/cocos/base/CCDictionary.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2012 - 2013 cocos2d-x.org +Copyright (c) 2012 cocos2d-x.org + opyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/CCDouble.h b/cocos/base/CCDouble.h index 6ef8ae28c8..0b01eb10e5 100644 --- a/cocos/base/CCDouble.h +++ b/cocos/base/CCDouble.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCFloat.h b/cocos/base/CCFloat.h index 6591638cd2..1c2c5e3e74 100644 --- a/cocos/base/CCFloat.h +++ b/cocos/base/CCFloat.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCGeometry.cpp b/cocos/base/CCGeometry.cpp index fe5086cba9..4be119ff6b 100644 --- a/cocos/base/CCGeometry.cpp +++ b/cocos/base/CCGeometry.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCGeometry.h b/cocos/base/CCGeometry.h index f1a080fdc5..4f43ddda4b 100644 --- a/cocos/base/CCGeometry.h +++ b/cocos/base/CCGeometry.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCInteger.h b/cocos/base/CCInteger.h index 56b6468dd4..f7a7b953ee 100644 --- a/cocos/base/CCInteger.h +++ b/cocos/base/CCInteger.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCMap.h b/cocos/base/CCMap.h index 44c7846076..450b39bc2e 100644 --- a/cocos/base/CCMap.h +++ b/cocos/base/CCMap.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2012 - 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org @@ -283,7 +283,9 @@ public: if (!_data.empty()) { ssize_t randIdx = rand() % _data.size(); - return (_data.begin() + randIdx)->second; + const_iterator randIter = _data.begin(); + std::advance(randIter , randIdx); + return randIter->second; } return nullptr; } @@ -316,18 +318,23 @@ public: /** Copy assignment operator */ Map& operator= ( const Map& other ) { - CCLOGINFO("In the copy assignment operator of Map!"); - clear(); - _data = other._data; - addRefForAllObjects(); + if (this != &other) { + CCLOGINFO("In the copy assignment operator of Map!"); + clear(); + _data = other._data; + addRefForAllObjects(); + } return *this; } /** Move assignment operator */ Map& operator= ( Map&& other ) { - CCLOGINFO("In the move assignment operator of Map!"); - _data = std::move(other._data); + if (this != &other) { + CCLOGINFO("In the move assignment operator of Map!"); + clear(); + _data = std::move(other._data); + } return *this; } diff --git a/cocos/base/CCNS.cpp b/cocos/base/CCNS.cpp index d9732d03ea..11b92516c5 100644 --- a/cocos/base/CCNS.cpp +++ b/cocos/base/CCNS.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCNS.h b/cocos/base/CCNS.h index c078e45225..663df74076 100644 --- a/cocos/base/CCNS.h +++ b/cocos/base/CCNS.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCObject.cpp b/cocos/base/CCObject.cpp index 75d01c5937..09dc4399f6 100644 --- a/cocos/base/CCObject.cpp +++ b/cocos/base/CCObject.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCObject.h b/cocos/base/CCObject.h index dc1a6adfd2..2280508856 100644 --- a/cocos/base/CCObject.h +++ b/cocos/base/CCObject.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org @@ -27,6 +28,7 @@ THE SOFTWARE. #include "CCDataVisitor.h" #include "ccMacros.h" +#include "CCConsole.h" #ifdef EMSCRIPTEN #include diff --git a/cocos/base/CCPlatformConfig.h b/cocos/base/CCPlatformConfig.h index 3a74498d1a..7d171b8d8b 100644 --- a/cocos/base/CCPlatformConfig.h +++ b/cocos/base/CCPlatformConfig.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCPlatformMacros.h b/cocos/base/CCPlatformMacros.h index 7fbfa542c8..426d898420 100644 --- a/cocos/base/CCPlatformMacros.h +++ b/cocos/base/CCPlatformMacros.h @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCSet.cpp b/cocos/base/CCSet.cpp index b3e565c6f4..baca990f36 100644 --- a/cocos/base/CCSet.cpp +++ b/cocos/base/CCSet.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCSet.h b/cocos/base/CCSet.h index 89ef7d0ac4..266946df6b 100644 --- a/cocos/base/CCSet.h +++ b/cocos/base/CCSet.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCString.cpp b/cocos/base/CCString.cpp index a8643372a0..a6dfcf1e0d 100644 --- a/cocos/base/CCString.cpp +++ b/cocos/base/CCString.cpp @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org @@ -58,7 +59,9 @@ __String::~__String() __String& __String::operator= (const __String& other) { - _string = other._string; + if (this != &other) { + _string = other._string; + } return *this; } diff --git a/cocos/base/CCString.h b/cocos/base/CCString.h index a3f4fd94ba..2b9778d559 100644 --- a/cocos/base/CCString.h +++ b/cocos/base/CCString.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/CCValue.cpp b/cocos/base/CCValue.cpp index ac63402a50..6aabf25c6e 100644 --- a/cocos/base/CCValue.cpp +++ b/cocos/base/CCValue.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org @@ -178,89 +178,93 @@ Value::~Value() Value& Value::operator= (const Value& other) { - switch (other._type) { - case Type::BYTE: - _baseData.byteVal = other._baseData.byteVal; - break; - case Type::INTEGER: - _baseData.intVal = other._baseData.intVal; - break; - case Type::FLOAT: - _baseData.floatVal = other._baseData.floatVal; - break; - case Type::DOUBLE: - _baseData.doubleVal = other._baseData.doubleVal; - break; - case Type::BOOLEAN: - _baseData.boolVal = other._baseData.boolVal; - break; - case Type::STRING: - _strData = other._strData; - break; - case Type::VECTOR: - if (_vectorData == nullptr) - _vectorData = new ValueVector(); - *_vectorData = *other._vectorData; - break; - case Type::MAP: - if (_mapData == nullptr) - _mapData = new ValueMap(); - *_mapData = *other._mapData; - break; - case Type::INT_KEY_MAP: - if (_intKeyMapData == nullptr) - _intKeyMapData = new ValueMapIntKey(); - *_intKeyMapData = *other._intKeyMapData; - break; - default: - break; + if (this != &other) { + switch (other._type) { + case Type::BYTE: + _baseData.byteVal = other._baseData.byteVal; + break; + case Type::INTEGER: + _baseData.intVal = other._baseData.intVal; + break; + case Type::FLOAT: + _baseData.floatVal = other._baseData.floatVal; + break; + case Type::DOUBLE: + _baseData.doubleVal = other._baseData.doubleVal; + break; + case Type::BOOLEAN: + _baseData.boolVal = other._baseData.boolVal; + break; + case Type::STRING: + _strData = other._strData; + break; + case Type::VECTOR: + if (_vectorData == nullptr) + _vectorData = new ValueVector(); + *_vectorData = *other._vectorData; + break; + case Type::MAP: + if (_mapData == nullptr) + _mapData = new ValueMap(); + *_mapData = *other._mapData; + break; + case Type::INT_KEY_MAP: + if (_intKeyMapData == nullptr) + _intKeyMapData = new ValueMapIntKey(); + *_intKeyMapData = *other._intKeyMapData; + break; + default: + break; + } + _type = other._type; } - _type = other._type; return *this; } Value& Value::operator= (Value&& other) { - switch (other._type) { - case Type::BYTE: - _baseData.byteVal = other._baseData.byteVal; - break; - case Type::INTEGER: - _baseData.intVal = other._baseData.intVal; - break; - case Type::FLOAT: - _baseData.floatVal = other._baseData.floatVal; - break; - case Type::DOUBLE: - _baseData.doubleVal = other._baseData.doubleVal; - break; - case Type::BOOLEAN: - _baseData.boolVal = other._baseData.boolVal; - break; - case Type::STRING: - _strData = other._strData; - break; - case Type::VECTOR: - CC_SAFE_DELETE(_vectorData); - _vectorData = other._vectorData; - break; - case Type::MAP: - CC_SAFE_DELETE(_mapData); - _mapData = other._mapData; - break; - case Type::INT_KEY_MAP: - CC_SAFE_DELETE(_intKeyMapData); - _intKeyMapData = other._intKeyMapData; - break; - default: - break; + if (this != &other) { + switch (other._type) { + case Type::BYTE: + _baseData.byteVal = other._baseData.byteVal; + break; + case Type::INTEGER: + _baseData.intVal = other._baseData.intVal; + break; + case Type::FLOAT: + _baseData.floatVal = other._baseData.floatVal; + break; + case Type::DOUBLE: + _baseData.doubleVal = other._baseData.doubleVal; + break; + case Type::BOOLEAN: + _baseData.boolVal = other._baseData.boolVal; + break; + case Type::STRING: + _strData = other._strData; + break; + case Type::VECTOR: + CC_SAFE_DELETE(_vectorData); + _vectorData = other._vectorData; + break; + case Type::MAP: + CC_SAFE_DELETE(_mapData); + _mapData = other._mapData; + break; + case Type::INT_KEY_MAP: + CC_SAFE_DELETE(_intKeyMapData); + _intKeyMapData = other._intKeyMapData; + break; + default: + break; + } + _type = other._type; + + other._vectorData = nullptr; + other._mapData = nullptr; + other._intKeyMapData = nullptr; + other._type = Type::NONE; } - _type = other._type; - - other._vectorData = nullptr; - other._mapData = nullptr; - other._intKeyMapData = nullptr; - other._type = Type::NONE; return *this; } @@ -590,6 +594,51 @@ std::string Value::asString() const return ret.str(); } +ValueVector& Value::asValueVector() +{ + if (nullptr == _vectorData) + _vectorData = new ValueVector(); + return *_vectorData; +} + +const ValueVector& Value::asValueVector() const +{ + static const ValueVector EMPTY_VALUEVECTOR; + if (nullptr == _vectorData) + return EMPTY_VALUEVECTOR; + return *_vectorData; +} + +ValueMap& Value::asValueMap() +{ + if (nullptr == _mapData) + _mapData = new ValueMap(); + return *_mapData; +} + +const ValueMap& Value::asValueMap() const +{ + static const ValueMap EMPTY_VALUEMAP; + if (nullptr == _mapData) + return EMPTY_VALUEMAP; + return *_mapData; +} + +ValueMapIntKey& Value::asIntKeyMap() +{ + if (nullptr == _intKeyMapData) + _intKeyMapData = new ValueMapIntKey(); + return *_intKeyMapData; +} + +const ValueMapIntKey& Value::asIntKeyMap() const +{ + static const ValueMapIntKey EMPTY_VALUEMAP_INT_KEY; + if (nullptr == _intKeyMapData) + return EMPTY_VALUEMAP_INT_KEY; + return *_intKeyMapData; +} + static std::string getTabs(int depth) { std::string tabWidth; diff --git a/cocos/base/CCValue.h b/cocos/base/CCValue.h index 4aa0a8daa2..c710a64cb7 100644 --- a/cocos/base/CCValue.h +++ b/cocos/base/CCValue.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org @@ -94,14 +94,14 @@ public: bool asBool() const; std::string asString() const; - inline ValueVector& asValueVector() { return *_vectorData; } - inline const ValueVector& asValueVector() const { return *_vectorData; } + ValueVector& asValueVector(); + const ValueVector& asValueVector() const; - inline ValueMap& asValueMap() { return *_mapData; } - inline const ValueMap& asValueMap() const { return *_mapData; } + ValueMap& asValueMap(); + const ValueMap& asValueMap() const; - inline ValueMapIntKey& asIntKeyMap() { return *_intKeyMapData; } - inline const ValueMapIntKey& asIntKeyMap() const { return *_intKeyMapData; } + ValueMapIntKey& asIntKeyMap(); + const ValueMapIntKey& asIntKeyMap() const; inline bool isNull() const { return _type == Type::NONE; } diff --git a/cocos/base/CCVector.h b/cocos/base/CCVector.h index 5fd07e4dc7..128f5951b3 100644 --- a/cocos/base/CCVector.h +++ b/cocos/base/CCVector.h @@ -1,6 +1,7 @@ /**************************************************************************** Copyright (c) 2010 ForzeField Studios S.L. http://forzefield.com -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org @@ -107,18 +108,23 @@ public: /** Copy assignment operator */ Vector& operator=(const Vector& other) { - CCLOGINFO("In the copy assignment operator!"); - clear(); - _data = other._data; - addRefForAllObjects(); + if (this != &other) { + CCLOGINFO("In the copy assignment operator!"); + clear(); + _data = other._data; + addRefForAllObjects(); + } return *this; } /** Move assignment operator */ Vector& operator=(Vector&& other) { - CCLOGINFO("In the move assignment operator!"); - _data = std::move(other._data); + if (this != &other) { + CCLOGINFO("In the move assignment operator!"); + clear(); + _data = std::move(other._data); + } return *this; } @@ -335,7 +341,7 @@ public: * @return An iterator pointing to the new location of the element that followed the last element erased by the function call. * This is the container end if the operation erased the last element in the sequence. */ - iterator erase(const_iterator first, const_iterator last) + iterator erase(iterator first, iterator last) { for (auto iter = first; iter != last; ++iter) { diff --git a/cocos/base/CMakeLists.txt b/cocos/base/CMakeLists.txt index 06d3e582c1..bc7240fa45 100644 --- a/cocos/base/CMakeLists.txt +++ b/cocos/base/CMakeLists.txt @@ -21,9 +21,15 @@ add_library(cocosbase STATIC ${COCOS_BASE_SRC} ) +if(WIN32) +target_link_libraries(cocosbase + Ws2_32 +) +endif() + set_target_properties(cocosbase PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/cocos/base/atitc.cpp b/cocos/base/atitc.cpp index e93cb801b2..d098b084bf 100644 --- a/cocos/base/atitc.cpp +++ b/cocos/base/atitc.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/atitc.h b/cocos/base/atitc.h index 72bfd32a8c..1f1ad7a8ef 100644 --- a/cocos/base/atitc.h +++ b/cocos/base/atitc.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/base/s3tc.cpp b/cocos/base/s3tc.cpp index 2995849603..067c00aa11 100644 --- a/cocos/base/s3tc.cpp +++ b/cocos/base/s3tc.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/base/s3tc.h b/cocos/base/s3tc.h index a3cf233257..e6573d9849 100644 --- a/cocos/base/s3tc.h +++ b/cocos/base/s3tc.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp index fa8905546b..b96a8c2ba5 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.cpp @@ -501,7 +501,7 @@ void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node } else if (propName == "displayFrame") { - static_cast(pNode)->setDisplayFrame(static_cast(obj)); + static_cast(pNode)->setSpriteFrame(static_cast(obj)); } else if (propName == "color") { @@ -1002,7 +1002,7 @@ CCBSetSpriteFrame* CCBSetSpriteFrame::reverse() const void CCBSetSpriteFrame::update(float time) { - ((Sprite*)_target)->setDisplayFrame(_spriteFrame); + static_cast(_target)->setSpriteFrame(_spriteFrame); } diff --git a/cocos/editor-support/cocosbuilder/CCSpriteLoader.cpp b/cocos/editor-support/cocosbuilder/CCSpriteLoader.cpp index 34a2e7f549..0194ffd6b2 100644 --- a/cocos/editor-support/cocosbuilder/CCSpriteLoader.cpp +++ b/cocos/editor-support/cocosbuilder/CCSpriteLoader.cpp @@ -13,7 +13,7 @@ namespace cocosbuilder { void SpriteLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * ccbReader) { if(strcmp(pPropertyName, PROPERTY_DISPLAYFRAME) == 0) { if(pSpriteFrame != NULL) { - ((Sprite *)pNode)->setDisplayFrame(pSpriteFrame); + ((Sprite *)pNode)->setSpriteFrame(pSpriteFrame); } else { CCLOG("ERROR: SpriteFrame NULL"); } diff --git a/cocos/editor-support/cocosbuilder/CMakeLists.txt b/cocos/editor-support/cocosbuilder/CMakeLists.txt index 179f9eb387..6d41d29579 100644 --- a/cocos/editor-support/cocosbuilder/CMakeLists.txt +++ b/cocos/editor-support/cocosbuilder/CMakeLists.txt @@ -33,7 +33,7 @@ add_library(cocosbuilder STATIC set_target_properties(cocosbuilder PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj b/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj index 98571622cf..f9bebc27e3 100644 --- a/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj +++ b/cocos/editor-support/cocosbuilder/proj.win32/libCocosBuilder.vcxproj @@ -63,6 +63,7 @@ true 4267;4251;4244;%(DisableSpecificWarnings) false + OldStyle true diff --git a/cocos/editor-support/cocostudio/CCActionEaseEx.cpp b/cocos/editor-support/cocostudio/CCActionEaseEx.cpp index 1f6881248a..c5d11eb1e1 100644 --- a/cocos/editor-support/cocostudio/CCActionEaseEx.cpp +++ b/cocos/editor-support/cocostudio/CCActionEaseEx.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -196,7 +196,7 @@ EaseQuadraticActionInOut* EaseQuadraticActionInOut::clone() const void EaseQuadraticActionInOut::update(float time) { float resultTime = time; - time = time*0.5f; + time = time*2; if (time < 1) { resultTime = time * time * 0.5f; @@ -331,7 +331,7 @@ EaseQuarticActionInOut* EaseQuarticActionInOut::clone() const void EaseQuarticActionInOut::update(float time) { - float tempTime = time * 0.5f; + float tempTime = time * 2; if (tempTime < 1) tempTime = powf(tempTime,4.0f) * 0.5f; else @@ -464,7 +464,7 @@ EaseQuinticActionInOut* EaseQuinticActionInOut::clone() const void EaseQuinticActionInOut::update(float time) { - float tempTime = time * 0.5f; + float tempTime = time * 2; if (tempTime < 1) tempTime = powf(tempTime,5.0f) * 0.5f; else @@ -597,13 +597,13 @@ EaseCircleActionInOut* EaseCircleActionInOut::clone() const void EaseCircleActionInOut::update(float time) { - float tempTime = time * 0.5f; + float tempTime = time * 2; if (tempTime < 1) tempTime = (1- sqrt(1 - powf(tempTime,2.0f))) * 0.5f; else { tempTime -= 2; - tempTime = (1+ sqrt(1 - powf(tempTime,2.0f))); + tempTime = (1+ sqrt(1 - powf(tempTime,2.0f))) * 0.5f; } _inner->update(time); @@ -688,6 +688,7 @@ EaseCubicActionOut* EaseCubicActionOut::clone() const void EaseCubicActionOut::update(float time) { + time -= 1; _inner->update(1+powf(time,3.0f)); } @@ -729,7 +730,7 @@ EaseCubicActionInOut* EaseCubicActionInOut::clone() const void EaseCubicActionInOut::update(float time) { - float tempTime = time * 0.5f; + float tempTime = time * 2; if (tempTime < 1) tempTime = powf(tempTime,3.0f) * 0.5f; else diff --git a/cocos/editor-support/cocostudio/CCActionEaseEx.h b/cocos/editor-support/cocostudio/CCActionEaseEx.h index e56923870c..0350d4d590 100644 --- a/cocos/editor-support/cocostudio/CCActionEaseEx.h +++ b/cocos/editor-support/cocostudio/CCActionEaseEx.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCActionFrame.cpp b/cocos/editor-support/cocostudio/CCActionFrame.cpp index 0dcade248d..b35bb272f7 100644 --- a/cocos/editor-support/cocostudio/CCActionFrame.cpp +++ b/cocos/editor-support/cocostudio/CCActionFrame.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -182,23 +182,17 @@ ActionInterval* ActionFrame::getEasingAction(ActionInterval* action) break; case FrameEaseType::ELASTIC_EASEIN: { - EaseElasticIn* cAction = EaseElasticIn::create(action); - cAction->setPeriod(_Parameter[0]); - return cAction; + return EaseElasticIn::create(action); } break; case FrameEaseType::ELASTIC_EASEOUT: { - EaseElasticOut* cAction = EaseElasticOut::create(action); - cAction->setPeriod(_Parameter[0]); - return cAction; + return EaseElasticOut::create(action); } break; case FrameEaseType::ELASTIC_EASEINOUT: { - EaseElasticInOut* cAction = EaseElasticInOut::create(action); - cAction->setPeriod(_Parameter[0]); - return cAction; + return EaseElasticInOut::create(action); } break; case FrameEaseType::BACK_EASEIN: diff --git a/cocos/editor-support/cocostudio/CCActionFrame.h b/cocos/editor-support/cocostudio/CCActionFrame.h index 031990aeb4..5b152f4eb3 100644 --- a/cocos/editor-support/cocostudio/CCActionFrame.h +++ b/cocos/editor-support/cocostudio/CCActionFrame.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCActionFrameEasing.cpp b/cocos/editor-support/cocostudio/CCActionFrameEasing.cpp index 25067811b1..b4a6fe9940 100644 --- a/cocos/editor-support/cocostudio/CCActionFrameEasing.cpp +++ b/cocos/editor-support/cocostudio/CCActionFrameEasing.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCActionFrameEasing.h b/cocos/editor-support/cocostudio/CCActionFrameEasing.h index b067949a76..65c9ad3a05 100644 --- a/cocos/editor-support/cocostudio/CCActionFrameEasing.h +++ b/cocos/editor-support/cocostudio/CCActionFrameEasing.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp index 30fc24841f..e0bfad1a31 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.h b/cocos/editor-support/cocostudio/CCActionManagerEx.h index 281acd13fe..e24c48d436 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.h +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index 1caacb0f05..b8dbd7162c 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -64,6 +64,7 @@ ActionNode::~ActionNode() for (auto object : _frameArray) { object->clear(); + CC_SAFE_DELETE(object); } _frameArray.clear(); } @@ -100,7 +101,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic,Object* root) actionFrame->setFrameIndex(frameInex); actionFrame->setScaleX(scaleX); actionFrame->setScaleY(scaleY); - auto cActionArray = _frameArray.at((int)kKeyframeMove); + auto cActionArray = _frameArray.at((int)kKeyframeScale); cActionArray->pushBack(actionFrame); } @@ -112,7 +113,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic,Object* root) actionFrame->autorelease(); actionFrame->setFrameIndex(frameInex); actionFrame->setRotation(rotation); - auto cActionArray = _frameArray.at((int)kKeyframeMove); + auto cActionArray = _frameArray.at((int)kKeyframeRotate); cActionArray->pushBack(actionFrame); } @@ -124,7 +125,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic,Object* root) actionFrame->autorelease(); actionFrame->setFrameIndex(frameInex); actionFrame->setOpacity(opacity); - auto cActionArray = _frameArray.at((int)kKeyframeMove); + auto cActionArray = _frameArray.at((int)kKeyframeTint); cActionArray->pushBack(actionFrame); } @@ -138,7 +139,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic,Object* root) actionFrame->autorelease(); actionFrame->setFrameIndex(frameInex); actionFrame->setColor(Color3B(colorR,colorG,colorB)); - auto cActionArray = _frameArray.at((int)kKeyframeMove); + auto cActionArray = _frameArray.at((int)kKeyframeFade); cActionArray->pushBack(actionFrame); } } @@ -153,7 +154,7 @@ void ActionNode::initActionNodeFromRoot(Object* root) Widget* rootWidget = dynamic_cast(root); if (rootWidget != nullptr) { - Widget* widget = UIHelper::seekActionWidgetByActionTag(rootWidget, getActionTag()); + Widget* widget = Helper::seekActionWidgetByActionTag(rootWidget, getActionTag()); if (widget != nullptr) { setObject(widget); diff --git a/cocos/editor-support/cocostudio/CCActionNode.h b/cocos/editor-support/cocostudio/CCActionNode.h index ba7ef8c828..42e4d0e4ee 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.h +++ b/cocos/editor-support/cocostudio/CCActionNode.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCActionObject.cpp b/cocos/editor-support/cocostudio/CCActionObject.cpp index 8ccafdf0b6..eeba39d121 100644 --- a/cocos/editor-support/cocostudio/CCActionObject.cpp +++ b/cocos/editor-support/cocostudio/CCActionObject.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCActionObject.h b/cocos/editor-support/cocostudio/CCActionObject.h index 086a947f0c..8d33a2017f 100644 --- a/cocos/editor-support/cocostudio/CCActionObject.h +++ b/cocos/editor-support/cocostudio/CCActionObject.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 9f0e909e25..decc3cc0c2 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -101,7 +101,7 @@ Armature::~Armature(void) bool Armature::init() { - return init(nullptr); + return init(""); } @@ -155,7 +155,7 @@ bool Armature::init(const std::string& name) CC_BREAK_IF(!frameData); bone->getTweenData()->copy(frameData); - bone->changeDisplayByIndex(frameData->displayIndex, false); + bone->changeDisplayWithIndex(frameData->displayIndex, false); } while (0); } @@ -222,7 +222,7 @@ Bone *Armature::createBone(const std::string& boneName) } bone->setBoneData(boneData); - bone->getDisplayManager()->changeDisplayByIndex(-1, false); + bone->getDisplayManager()->changeDisplayWithIndex(-1, false); return bone; } diff --git a/cocos/editor-support/cocostudio/CCArmature.h b/cocos/editor-support/cocostudio/CCArmature.h index f601c057f7..e63e77d87e 100644 --- a/cocos/editor-support/cocostudio/CCArmature.h +++ b/cocos/editor-support/cocostudio/CCArmature.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp index fb7ff59299..70296710f4 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -236,7 +236,7 @@ void ArmatureAnimation::play(const std::string& animationName, int durationTo, if(!bone->isIgnoreMovementBoneData()) { //! this bone is not include in this movement, so hide it - bone->getDisplayManager()->changeDisplayByIndex(-1, false); + bone->getDisplayManager()->changeDisplayWithIndex(-1, false); tween->stop(); } @@ -328,7 +328,7 @@ void ArmatureAnimation::gotoAndPause(int frameIndex) pause(); } -long ArmatureAnimation::getMovementCount() const +ssize_t ArmatureAnimation::getMovementCount() const { return _animationData->getMovementCount(); } diff --git a/cocos/editor-support/cocostudio/CCArmatureAnimation.h b/cocos/editor-support/cocostudio/CCArmatureAnimation.h index f135501cb1..96a07950d8 100644 --- a/cocos/editor-support/cocostudio/CCArmatureAnimation.h +++ b/cocos/editor-support/cocostudio/CCArmatureAnimation.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -170,7 +170,7 @@ public: /** * Get movement count */ - long getMovementCount() const; + ssize_t getMovementCount() const; void update(float dt); diff --git a/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp b/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp index 8ff4b503c3..0848ab6226 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureDataManager.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCArmatureDataManager.h b/cocos/editor-support/cocostudio/CCArmatureDataManager.h index 5ca512a19a..f621a6c6bf 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDataManager.h +++ b/cocos/editor-support/cocostudio/CCArmatureDataManager.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCArmatureDefine.cpp b/cocos/editor-support/cocostudio/CCArmatureDefine.cpp index 3873a918ba..987711eb70 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDefine.cpp +++ b/cocos/editor-support/cocostudio/CCArmatureDefine.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCArmatureDefine.h b/cocos/editor-support/cocostudio/CCArmatureDefine.h index e2c8894cf8..934b7bc43d 100644 --- a/cocos/editor-support/cocostudio/CCArmatureDefine.h +++ b/cocos/editor-support/cocostudio/CCArmatureDefine.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCBatchNode.cpp b/cocos/editor-support/cocostudio/CCBatchNode.cpp index 449aee1bb5..45dcade7d6 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.cpp +++ b/cocos/editor-support/cocostudio/CCBatchNode.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCBatchNode.h b/cocos/editor-support/cocostudio/CCBatchNode.h index feff9c868d..1de8a963a2 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.h +++ b/cocos/editor-support/cocostudio/CCBatchNode.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCBone.cpp b/cocos/editor-support/cocostudio/CCBone.cpp index a6b46b3bef..4bd7883a43 100644 --- a/cocos/editor-support/cocostudio/CCBone.cpp +++ b/cocos/editor-support/cocostudio/CCBone.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -418,13 +418,22 @@ void Bone::removeDisplay(int index) void Bone::changeDisplayByIndex(int index, bool force) { - _displayManager->changeDisplayByIndex(index, force); + changeDisplayWithIndex(index, force); } - -void Bone::changeDisplayByName(const std::string& name, bool force) +void Bone::changeDisplayByName(const std::string &name, bool force) { - _displayManager->changeDisplayByName(name, force); + changeDisplayWithName(name, force); +} + +void Bone::changeDisplayWithIndex(int index, bool force) +{ + _displayManager->changeDisplayWithIndex(index, force); +} + +void Bone::changeDisplayWithName(const std::string& name, bool force) +{ + _displayManager->changeDisplayWithName(name, force); } ColliderDetector* Bone::getColliderDetector() const diff --git a/cocos/editor-support/cocostudio/CCBone.h b/cocos/editor-support/cocostudio/CCBone.h index 6d469eb965..db153a1da5 100644 --- a/cocos/editor-support/cocostudio/CCBone.h +++ b/cocos/editor-support/cocostudio/CCBone.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -91,8 +91,11 @@ public: void removeDisplay(int index); - void changeDisplayByIndex(int index, bool force); - void changeDisplayByName(const std::string& name, bool force); + CC_DEPRECATED_ATTRIBUTE void changeDisplayByIndex(int index, bool force); + CC_DEPRECATED_ATTRIBUTE void changeDisplayByName(const std::string& name, bool force); + + void changeDisplayWithIndex(int index, bool force); + void changeDisplayWithName(const std::string& name, bool force); /** * Add a child to this bone, and it will let this child call setParent(Bone *parent) function to set self to it's parent diff --git a/cocos/editor-support/cocostudio/CCColliderDetector.cpp b/cocos/editor-support/cocostudio/CCColliderDetector.cpp index 69883544b3..838b2a97be 100644 --- a/cocos/editor-support/cocostudio/CCColliderDetector.cpp +++ b/cocos/editor-support/cocostudio/CCColliderDetector.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCColliderDetector.h b/cocos/editor-support/cocostudio/CCColliderDetector.h index f7c4e73d2a..9619ed4f29 100644 --- a/cocos/editor-support/cocostudio/CCColliderDetector.h +++ b/cocos/editor-support/cocostudio/CCColliderDetector.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCComAttribute.cpp b/cocos/editor-support/cocostudio/CCComAttribute.cpp index 10186cb768..b2fe13fbfd 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.cpp +++ b/cocos/editor-support/cocostudio/CCComAttribute.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -23,13 +23,15 @@ THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCComAttribute.h" + using namespace cocos2d; namespace cocostudio { +IMPLEMENT_CLASS_COMPONENT_INFO(ComAttribute) ComAttribute::ComAttribute(void) { - _name = "ComAttribute"; + _name = "CCComAttribute"; } ComAttribute::~ComAttribute(void) @@ -64,42 +66,65 @@ void ComAttribute::setString(const std::string& key, const std::string& value) int ComAttribute::getInt(const std::string& key, int def) const { - if (_dict.find(key) == _dict.end()) + if (_dict.find(key) != _dict.end()) + { + const cocos2d::Value& v = _dict.at(key); + return v.asInt(); + } + + if (!DICTOOL->checkObjectExist_json(_doc, key.c_str())) { return def; } - const cocos2d::Value& v = _dict.at(key); - return v.asInt(); + + return DICTOOL->getIntValue_json(_doc, key.c_str()); } float ComAttribute::getFloat(const std::string& key, float def) const { - if (_dict.find(key) == _dict.end()) + if (_dict.find(key) != _dict.end()) + { + const cocos2d::Value& v = _dict.at(key); + return v.asFloat(); + } + + if (!DICTOOL->checkObjectExist_json(_doc, key.c_str())) { return def; } - const cocos2d::Value& v = _dict.at(key); - return v.asFloat(); + return DICTOOL->getFloatValue_json(_doc, key.c_str()); } bool ComAttribute::getBool(const std::string& key, bool def) const { - if (_dict.find(key) == _dict.end()) + if (_dict.find(key) != _dict.end()) + { + const cocos2d::Value& v = _dict.at(key); + return v.asBool(); + } + + if (!DICTOOL->checkObjectExist_json(_doc, key.c_str())) { return def; } - const cocos2d::Value& v = _dict.at(key); - return v.asBool(); + + return DICTOOL->getBooleanValue_json(_doc, key.c_str()); } std::string ComAttribute::getString(const std::string& key, const std::string& def) const { - if (_dict.find(key) == _dict.end()) + if (_dict.find(key) != _dict.end()) + { + const cocos2d::Value& v = _dict.at(key); + return v.asString(); + } + + if (!DICTOOL->checkObjectExist_json(_doc, key.c_str())) { return def; } - const cocos2d::Value& v = _dict.at(key); - return v.asString(); + + return DICTOOL->getStringValue_json(_doc, key.c_str()); } ComAttribute* ComAttribute::create(void) @@ -116,5 +141,52 @@ ComAttribute* ComAttribute::create(void) return pRet; } +bool ComAttribute::serialize(void* r) +{ + bool bRet = false; + do + { + CC_BREAK_IF(r == nullptr); + rapidjson::Value *v = (rapidjson::Value *)r; + const char *className = DICTOOL->getStringValue_json(*v, "classname"); + CC_BREAK_IF(className == nullptr); + const char *comName = DICTOOL->getStringValue_json(*v, "name"); + if (comName != nullptr) + { + setName(comName); + } + else + { + setName(className); + } + const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData"); + CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData)); + const char *file = DICTOOL->getStringValue_json(fileData, "path"); + CC_BREAK_IF(file == nullptr); + std::string filePath; + if (file != nullptr) + { + filePath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file)); + } + int resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1); + CC_BREAK_IF(resType != 0); + parse(filePath.c_str()); + bRet = true; + } while (0); + + return bRet; +} + +bool ComAttribute::parse(const std::string &jsonFile) +{ + bool ret = false; + do { + std::string contentStr = FileUtils::getInstance()->getStringFromFile(jsonFile); + _doc.Parse<0>(contentStr.c_str()); + CC_BREAK_IF(_doc.HasParseError()); + ret = true; + } while (0); + return ret; +} } diff --git a/cocos/editor-support/cocostudio/CCComAttribute.h b/cocos/editor-support/cocostudio/CCComAttribute.h index 008c047208..3919d6ca56 100644 --- a/cocos/editor-support/cocostudio/CCComAttribute.h +++ b/cocos/editor-support/cocostudio/CCComAttribute.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -25,14 +25,13 @@ THE SOFTWARE. #ifndef __CC_EXTENTIONS_CCCOMATTRIBUTE_H__ #define __CC_EXTENTIONS_CCCOMATTRIBUTE_H__ -#include "cocos2d.h" -#include -#include "cocostudio/DictionaryHelper.h" +#include "CCComBase.h" namespace cocostudio { class ComAttribute : public cocos2d::Component { + DECLARE_CLASS_COMPONENT_INFO protected: /** * @js ctor @@ -45,20 +44,22 @@ protected: virtual ~ComAttribute(void); public: - virtual bool init(); - static ComAttribute* create(void); - - void setInt(const std::string& key, int value); - void setFloat(const std::string& key, float value); - void setBool(const std::string& key, bool value); - void setString(const std::string& key, const std::string& value); - - int getInt(const std::string& key, int def = 0) const; - float getFloat(const std::string& key, float def = 0.0f) const; - bool getBool(const std::string& key, bool def = false) const; - std::string getString(const std::string& key, const std::string& def = "") const; + static ComAttribute* create(void); + virtual bool init() override; + virtual bool serialize(void* r) override; + + void setInt(const std::string& key, int value); + void setFloat(const std::string& key, float value); + void setBool(const std::string& key, bool value); + void setString(const std::string& key, const std::string& value); + int getInt(const std::string& key, int def = 0) const; + float getFloat(const std::string& key, float def = 0.0f) const; + bool getBool(const std::string& key, bool def = false) const; + std::string getString(const std::string& key, const std::string& def = "") const; + bool parse(const std::string &jsonFile); private: cocos2d::ValueMap _dict; + rapidjson::Document _doc; }; } diff --git a/cocos/editor-support/cocostudio/CCComAudio.cpp b/cocos/editor-support/cocostudio/CCComAudio.cpp index c8112bc4c7..e232d07569 100644 --- a/cocos/editor-support/cocostudio/CCComAudio.cpp +++ b/cocos/editor-support/cocostudio/CCComAudio.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -27,11 +27,12 @@ THE SOFTWARE. namespace cocostudio { +IMPLEMENT_CLASS_COMPONENT_INFO(ComAudio) ComAudio::ComAudio(void) : _filePath("") , _loop(false) { - _name = "Audio"; + _name = "CCComAudio"; } ComAudio::~ComAudio(void) @@ -64,6 +65,57 @@ void ComAudio::setEnabled(bool b) _enabled = b; } + +bool ComAudio::serialize(void* r) +{ + bool bRet = false; + do + { + CC_BREAK_IF(r == nullptr); + rapidjson::Value *v = (rapidjson::Value *)r; + const char *className = DICTOOL->getStringValue_json(*v, "classname"); + CC_BREAK_IF(className == nullptr); + const char *comName = DICTOOL->getStringValue_json(*v, "name"); + if (comName != nullptr) + { + setName(comName); + } + else + { + setName(className); + } + const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData"); + CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData)); + const char *file = DICTOOL->getStringValue_json(fileData, "path"); + CC_BREAK_IF(file == nullptr); + std::string filePath; + if (file != nullptr) + { + filePath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file)); + } + int resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1); + CC_BREAK_IF(resType != 0); + if (strcmp(className, "CCBackgroundAudio") == 0) + { + preloadBackgroundMusic(filePath.c_str()); + bool loop = DICTOOL->getIntValue_json(*v, "loop") != 0? true:false; + setLoop(loop); + playBackgroundMusic(filePath.c_str(), loop); + } + else if(strcmp(className, "CCComAudio") == 0) + { + preloadEffect(filePath.c_str()); + } + else + { + CC_BREAK_IF(true); + } + bRet = true; + } while (0); + + return bRet; +} + ComAudio* ComAudio::create(void) { ComAudio * pRet = new ComAudio(); @@ -90,9 +142,9 @@ void ComAudio::preloadBackgroundMusic(const char* pszFilePath) setLoop(false); } -void ComAudio::playBackgroundMusic(const char* pszFilePath, bool bLoop) +void ComAudio::playBackgroundMusic(const char* pszFilePath, bool loop) { - CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic(pszFilePath, bLoop); + CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic(pszFilePath, loop); } @@ -161,9 +213,9 @@ void ComAudio::setEffectsVolume(float volume) CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(volume); } -unsigned int ComAudio::playEffect(const char* pszFilePath, bool bLoop) +unsigned int ComAudio::playEffect(const char* pszFilePath, bool loop) { - return CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(pszFilePath, bLoop); + return CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(pszFilePath, loop); } unsigned int ComAudio::playEffect(const char* pszFilePath) @@ -223,9 +275,9 @@ void ComAudio::setFile(const char* pszFilePath) _filePath.assign(pszFilePath); } -void ComAudio::setLoop(bool bLoop) +void ComAudio::setLoop(bool loop) { - _loop = bLoop; + _loop = loop; } const char* ComAudio::getFile() diff --git a/cocos/editor-support/cocostudio/CCComAudio.h b/cocos/editor-support/cocostudio/CCComAudio.h index 94abd103aa..4bbb97bb47 100644 --- a/cocos/editor-support/cocostudio/CCComAudio.h +++ b/cocos/editor-support/cocostudio/CCComAudio.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -25,12 +25,14 @@ THE SOFTWARE. #ifndef __CC_EXTENTIONS_CCCOMAUDIO_H__ #define __CC_EXTENTIONS_CCCOMAUDIO_H__ -#include "cocos2d.h" +#include "CCComBase.h" namespace cocostudio { class ComAudio : public cocos2d::Component { + + DECLARE_CLASS_COMPONENT_INFO protected: /** * @js ctor @@ -43,19 +45,20 @@ protected: virtual ~ComAudio(void); public: - virtual bool init(); + virtual bool init() override; /** * @js NA * @lua NA */ - virtual void onEnter(); + virtual void onEnter() override; /** * @js NA * @lua NA */ - virtual void onExit(); - virtual bool isEnabled() const; - virtual void setEnabled(bool b); + virtual void onExit() override; + virtual bool isEnabled() const override; + virtual void setEnabled(bool b) override; + virtual bool serialize(void* r) override; static ComAudio* create(void); diff --git a/cocos/editor-support/cocostudio/CCComBase.h b/cocos/editor-support/cocostudio/CCComBase.h new file mode 100644 index 0000000000..59dfccbe7f --- /dev/null +++ b/cocos/editor-support/cocostudio/CCComBase.h @@ -0,0 +1,50 @@ +/**************************************************************************** +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#ifndef __CC_EXTENTIONS_CCCOMBASE_H__ +#define __CC_EXTENTIONS_CCCOMBASE_H__ + +#include "cocos2d.h" +#include "ObjectFactory.h" +#include "DictionaryHelper.h" +#include + + +#define DECLARE_CLASS_COMPONENT_INFO \ + public: \ + static cocostudio::ObjectFactory::TInfo Type; \ + static cocos2d::Object* createInstance(void); \ + +#define IMPLEMENT_CLASS_COMPONENT_INFO(className) \ + cocos2d::Object* className::createInstance(void) \ + { \ + return className::create(); \ + } \ + cocostudio::ObjectFactory::TInfo className::Type(#className, &className::createInstance); \ + +#define CREATE_CLASS_COMPONENT_INFO(className) \ + cocostudio::ObjectFactory::TInfo(#className, &className::createInstance) + + +#endif diff --git a/cocos/editor-support/cocostudio/CCComController.cpp b/cocos/editor-support/cocostudio/CCComController.cpp index bf57a8724a..0cba200351 100644 --- a/cocos/editor-support/cocostudio/CCComController.cpp +++ b/cocos/editor-support/cocostudio/CCComController.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -26,9 +26,10 @@ THE SOFTWARE. namespace cocostudio { +IMPLEMENT_CLASS_COMPONENT_INFO(ComController) ComController::ComController(void) { - _name = "Constoller"; + _name = "CCComController"; } ComController::~ComController(void) diff --git a/cocos/editor-support/cocostudio/CCComController.h b/cocos/editor-support/cocostudio/CCComController.h index d1778b84e6..d68b25559c 100644 --- a/cocos/editor-support/cocostudio/CCComController.h +++ b/cocos/editor-support/cocostudio/CCComController.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -25,13 +25,15 @@ THE SOFTWARE. #ifndef __CC_EXTENTIONS_CCCOMCONTROLLER_H__ #define __CC_EXTENTIONS_CCCOMCONTROLLER_H__ -#include "cocos2d.h" +#include "CCComBase.h" #include "cocostudio/CCInputDelegate.h" namespace cocostudio { class ComController : public cocos2d::Component, public InputDelegate { + + DECLARE_CLASS_COMPONENT_INFO public: /** * @js ctor @@ -44,12 +46,12 @@ public: * @lua NA */ virtual ~ComController(void); - virtual bool init(); + virtual bool init() override; /** * @js NA * @lua NA */ - virtual void onEnter(); + virtual void onEnter() override; /** * @js NA * @lua NA diff --git a/cocos/editor-support/cocostudio/CCComRender.cpp b/cocos/editor-support/cocostudio/CCComRender.cpp index 76e549761c..e143e44fdf 100644 --- a/cocos/editor-support/cocostudio/CCComRender.cpp +++ b/cocos/editor-support/cocostudio/CCComRender.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -23,13 +23,17 @@ THE SOFTWARE. ****************************************************************************/ #include "cocostudio/CCComRender.h" +#include "cocostudio/CocoStudio.h" + +using namespace cocos2d; namespace cocostudio { +IMPLEMENT_CLASS_COMPONENT_INFO(ComRender) ComRender::ComRender(void) : _render(nullptr) { - + _name = "CCComRender"; } @@ -41,12 +45,12 @@ ComRender::ComRender(cocos2d::Node *node, const char *comName) ComRender::~ComRender(void) { - _render = NULL; + _render = nullptr; } void ComRender::onEnter() { - if (_owner != NULL) + if (_owner != nullptr) { _owner->addChild(_render); } @@ -54,7 +58,7 @@ void ComRender::onEnter() void ComRender::onExit() { - _render = NULL; + _render = nullptr; } cocos2d::Node* ComRender::getNode() @@ -62,18 +66,164 @@ cocos2d::Node* ComRender::getNode() return _render; } -ComRender* ComRender::create(cocos2d::Node *pNode, const char *comName) +void ComRender::setNode(cocos2d::Node *node) { - ComRender * pRet = new ComRender(pNode, comName); - if (pRet != NULL && pRet->init()) + _render = node; +} + + +bool ComRender::serialize(void* r) +{ + bool bRet = false; + do + { + CC_BREAK_IF(r == nullptr); + rapidjson::Value *v = (rapidjson::Value *)r; + const char *className = DICTOOL->getStringValue_json(*v, "classname"); + CC_BREAK_IF(className == nullptr); + const char *comName = DICTOOL->getStringValue_json(*v, "name"); + if (comName != nullptr) + { + setName(comName); + } + else + { + setName(className); + } + const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData"); + CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData)); + const char *file = DICTOOL->getStringValue_json(fileData, "path"); + const char *plist = DICTOOL->getStringValue_json(fileData, "plistFile"); + CC_BREAK_IF(file == nullptr && plist == nullptr); + std::string filePath; + std::string plistPath; + if (file != nullptr) + { + filePath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(file)); + } + if (plist != nullptr) + { + plistPath.assign(cocos2d::CCFileUtils::getInstance()->fullPathForFilename(plist)); + } + int resType = DICTOOL->getIntValue_json(fileData, "resourceType", -1); + if (resType == 0) + { + if (strcmp(className, "CCSprite") == 0 && filePath.find(".png") != std::string::npos) + { + _render = Sprite::create(filePath.c_str()); + } + else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != std::string::npos) + { + _render = TMXTiledMap::create(filePath.c_str()); + } + else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != std::string::npos) + { + _render = ParticleSystemQuad::create(filePath.c_str()); + _render->setPosition(Point(0.0f, 0.0f)); + } + else if(strcmp(className, "CCArmature") == 0) + { + std::string reDir = filePath; + std::string file_path = ""; + size_t pos = reDir.find_last_of('/'); + if (pos != std::string::npos) + { + file_path = reDir.substr(0, pos+1); + } + rapidjson::Document doc; + if(!readJson(filePath.c_str(), doc)) + { + log("read json file[%s] error!\n", filePath.c_str()); + continue; + } + const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0); + const char *name = DICTOOL->getStringValue_json(subData, "name"); + ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str()); + Armature *pAr = Armature::create(name); + _render = pAr; + const char *actionName = DICTOOL->getStringValue_json(*v, "selectedactionname"); + if (actionName != nullptr && pAr->getAnimation() != nullptr) + { + pAr->getAnimation()->play(actionName); + } + } + else if(strcmp(className, "GUIComponent") == 0) + { + cocos2d::gui::Widget* widget = GUIReader::getInstance()->widgetFromJsonFile(filePath.c_str()); + _render = widget; + } + else + { + CC_BREAK_IF(true); + } + } + else if (resType == 1) + { + if (strcmp(className, "CCSprite") == 0) + { + std::string strPngFile = plistPath; + std::string::size_type pos = strPngFile.find(".plist"); + if (pos == strPngFile.npos) + { + continue; + } + strPngFile.replace(pos, strPngFile.length(), ".png"); + SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath.c_str(), strPngFile.c_str()); + _render = Sprite::createWithSpriteFrameName(filePath.c_str()); + } + else + { + CC_BREAK_IF(true); + } + } + else + { + CC_BREAK_IF(true); + } + bRet = true; + } while (0); + + return bRet; +} + +ComRender* ComRender::create(void) +{ + ComRender * ret = new ComRender(); + if (ret != nullptr && ret->init()) { - pRet->autorelease(); + ret->autorelease(); } else { - CC_SAFE_DELETE(pRet); + CC_SAFE_DELETE(ret); } - return pRet; + return ret; +} + +ComRender* ComRender::create(cocos2d::Node *node, const char *comName) +{ + ComRender * ret = new ComRender(node, comName); + if (ret != nullptr && ret->init()) + { + ret->autorelease(); + } + else + { + CC_SAFE_DELETE(ret); + } + return ret; +} + +bool ComRender::readJson(const std::string &fileName, rapidjson::Document &doc) +{ + bool ret = false; + do { + std::string contentStr = FileUtils::getInstance()->getStringFromFile(fileName); + doc.Parse<0>(contentStr.c_str()); + CC_BREAK_IF(doc.HasParseError()); + ret = true; + } while (0); + return ret; } } diff --git a/cocos/editor-support/cocostudio/CCComRender.h b/cocos/editor-support/cocostudio/CCComRender.h index d35973314c..b2b94f3305 100644 --- a/cocos/editor-support/cocostudio/CCComRender.h +++ b/cocos/editor-support/cocostudio/CCComRender.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -22,15 +22,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __CC_EXTENTIONS_CCCOMNODE_H__ -#define __CC_EXTENTIONS_CCCOMNODE_H__ +#ifndef __CC_EXTENTIONS_CCCOMRENDER_H__ +#define __CC_EXTENTIONS_CCCOMRENDER_H__ -#include "cocos2d.h" +#include "CCComBase.h" namespace cocostudio { class ComRender : public cocos2d::Component { + DECLARE_CLASS_COMPONENT_INFO protected: /** * @js ctor @@ -48,15 +49,20 @@ public: * @js NA * @lua NA */ - virtual void onEnter(); + virtual void onEnter() override; /** * @js NA * @lua NA */ - virtual void onExit(); - cocos2d::Node* getNode(); + virtual void onExit() override; + virtual bool serialize(void* r) override; + virtual cocos2d::Node* getNode(); + virtual void setNode(cocos2d::Node *node); - static ComRender* create(cocos2d::Node *pNode, const char *comName); + static ComRender* create(void); + static ComRender* create(cocos2d::Node *node, const char *comName); +private: + bool readJson(const std::string &fileName, rapidjson::Document &doc); private: cocos2d::Node *_render; diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp index e401172c7c..452f25d9b8 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDataReaderHelper.h b/cocos/editor-support/cocostudio/CCDataReaderHelper.h index 88804e7ddb..03ed25133b 100644 --- a/cocos/editor-support/cocostudio/CCDataReaderHelper.h +++ b/cocos/editor-support/cocostudio/CCDataReaderHelper.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDatas.cpp b/cocos/editor-support/cocostudio/CCDatas.cpp index 9fefedf1d1..17d2a60b9a 100644 --- a/cocos/editor-support/cocostudio/CCDatas.cpp +++ b/cocos/editor-support/cocostudio/CCDatas.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDatas.h b/cocos/editor-support/cocostudio/CCDatas.h index 22eaabbc22..42ac9ae2f6 100644 --- a/cocos/editor-support/cocostudio/CCDatas.h +++ b/cocos/editor-support/cocostudio/CCDatas.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDecorativeDisplay.cpp b/cocos/editor-support/cocostudio/CCDecorativeDisplay.cpp index 73efa5443c..1d4c899dea 100644 --- a/cocos/editor-support/cocostudio/CCDecorativeDisplay.cpp +++ b/cocos/editor-support/cocostudio/CCDecorativeDisplay.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDecorativeDisplay.h b/cocos/editor-support/cocostudio/CCDecorativeDisplay.h index eee97e9019..1d6dcbe979 100644 --- a/cocos/editor-support/cocostudio/CCDecorativeDisplay.h +++ b/cocos/editor-support/cocostudio/CCDecorativeDisplay.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp index a1e2df89d1..20f826cb2b 100644 --- a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDisplayFactory.h b/cocos/editor-support/cocostudio/CCDisplayFactory.h index 3f6fdd3ff0..3c94dc8d3b 100644 --- a/cocos/editor-support/cocostudio/CCDisplayFactory.h +++ b/cocos/editor-support/cocostudio/CCDisplayFactory.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.cpp b/cocos/editor-support/cocostudio/CCDisplayManager.cpp index aa59698679..c2ce242a47 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayManager.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -108,7 +108,7 @@ void DisplayManager::addDisplay(DisplayData *displayData, int index) if(index == _displayIndex) { _displayIndex = -1; - changeDisplayByIndex(index, false); + changeDisplayWithIndex(index, false); } } @@ -193,7 +193,7 @@ void DisplayManager::addDisplay(Node *display, int index) if(index == _displayIndex) { _displayIndex = -1; - changeDisplayByIndex(index, false); + changeDisplayWithIndex(index, false); } } @@ -213,7 +213,7 @@ const cocos2d::Vector& DisplayManager::getDecorativeDisplayL return _decoDisplayList; } -void DisplayManager::changeDisplayByIndex(int index, bool force) +void DisplayManager::changeDisplayWithIndex(int index, bool force) { CCASSERT( index < (int)_decoDisplayList.size(), "the _index value is out of range"); @@ -243,13 +243,13 @@ void DisplayManager::changeDisplayByIndex(int index, bool force) setCurrentDecorativeDisplay(decoDisplay); } -void CCDisplayManager::changeDisplayByName(const std::string& name, bool force) +void CCDisplayManager::changeDisplayWithName(const std::string& name, bool force) { for (int i = 0; i<_decoDisplayList.size(); i++) { if (_decoDisplayList.at(i)->getDisplayData()->displayName == name) { - changeDisplayByIndex(i, force); + changeDisplayWithIndex(i, force); break; } } diff --git a/cocos/editor-support/cocostudio/CCDisplayManager.h b/cocos/editor-support/cocostudio/CCDisplayManager.h index 75ba93b455..39b89e45af 100644 --- a/cocos/editor-support/cocostudio/CCDisplayManager.h +++ b/cocos/editor-support/cocostudio/CCDisplayManager.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -74,6 +74,12 @@ public: const cocos2d::Vector& getDecorativeDisplayList() const; + /* + * @deprecated, please use changeDisplayWithIndex and changeDisplayWithName + */ + CC_DEPRECATED_ATTRIBUTE void changeDisplayByIndex(int index, bool force); + CC_DEPRECATED_ATTRIBUTE void changeDisplayByName(const std::string& name, bool force); + /** * Change display by index. You can just use this method to change display in the display list. * The display list is just used for this bone, and it is the displays you may use in every frame. @@ -83,9 +89,8 @@ public: * @param index The index of the display you want to change * @param force If true, then force change display to specified display, or current display will set to display index edit in the flash every key frame. */ - void changeDisplayByIndex(int index, bool force); - - void changeDisplayByName(const std::string& name, bool force); + void changeDisplayWithIndex(int index, bool force); + void changeDisplayWithName(const std::string& name, bool force); cocos2d::Node *getDisplayRenderNode() const; DisplayType getDisplayRenderNodeType() const; diff --git a/cocos/editor-support/cocostudio/CCInputDelegate.cpp b/cocos/editor-support/cocostudio/CCInputDelegate.cpp index 03ac5030a7..3f3d94745e 100644 --- a/cocos/editor-support/cocostudio/CCInputDelegate.cpp +++ b/cocos/editor-support/cocostudio/CCInputDelegate.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCInputDelegate.h b/cocos/editor-support/cocostudio/CCInputDelegate.h index c41490a03f..81cd4c9218 100644 --- a/cocos/editor-support/cocostudio/CCInputDelegate.h +++ b/cocos/editor-support/cocostudio/CCInputDelegate.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -80,19 +80,19 @@ public: /** * @js NA */ - CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesBegan(cocos2d::Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} + CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesBegan(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ - CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesMoved(cocos2d::Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} + CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesMoved(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ - CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesEnded(cocos2d::Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} + CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesEnded(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ - CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesCancelled(cocos2d::Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} + CC_DEPRECATED_ATTRIBUTE virtual void ccTouchesCancelled(cocos2d::__Set *pTouches, cocos2d::Event *pEvent) final {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} /** * @js NA */ diff --git a/cocos/editor-support/cocostudio/CCProcessBase.cpp b/cocos/editor-support/cocostudio/CCProcessBase.cpp index b55585c047..137b804d58 100644 --- a/cocos/editor-support/cocostudio/CCProcessBase.cpp +++ b/cocos/editor-support/cocostudio/CCProcessBase.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCProcessBase.h b/cocos/editor-support/cocostudio/CCProcessBase.h index cb7db59a71..693a7ea2f8 100644 --- a/cocos/editor-support/cocostudio/CCProcessBase.h +++ b/cocos/editor-support/cocostudio/CCProcessBase.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -22,7 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #ifndef __CCPROCESSBASE_H__ #define __CCPROCESSBASE_H__ diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.cpp b/cocos/editor-support/cocostudio/CCSGUIReader.cpp index b1b830b86c..349bba5dfe 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.cpp +++ b/cocos/editor-support/cocostudio/CCSGUIReader.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "cocostudio/CCSGUIReader.h" #include "gui/CocosGUI.h" #include "cocostudio/CCActionManagerEx.h" @@ -44,7 +44,7 @@ GUIReader::~GUIReader() { } -GUIReader* GUIReader::shareReader() +GUIReader* GUIReader::getInstance() { if (!sharedReader) { @@ -53,7 +53,7 @@ GUIReader* GUIReader::shareReader() return sharedReader; } -void GUIReader::purgeGUIReader() +void GUIReader::destroyInstance() { CC_SAFE_DELETE(sharedReader); } @@ -171,13 +171,13 @@ Widget* WidgetPropertiesReader0250::createWidget(const rapidjson::Value& data, c float fileDesignWidth = DICTOOL->getFloatValue_json(data, "designWidth"); float fileDesignHeight = DICTOOL->getFloatValue_json(data, "designHeight"); if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { - printf("Read design size error!\n"); + CCLOGERROR("Read design size error!\n"); Size winSize = Director::getInstance()->getWinSize(); - GUIReader::shareReader()->storeFileDesignSize(fileName, winSize); + GUIReader::getInstance()->storeFileDesignSize(fileName, winSize); } else { - GUIReader::shareReader()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight)); + GUIReader::getInstance()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight)); } const rapidjson::Value& widgetTree = DICTOOL->getSubDictionary_json(data, "widgetTree"); Widget* widget = widgetFromJsonDictionary(widgetTree); @@ -218,12 +218,12 @@ Widget* WidgetPropertiesReader0250::widgetFromJsonDictionary(const rapidjson::Va } else if (classname && strcmp(classname, "Label") == 0) { - widget = cocos2d::gui::Label::create(); + widget = cocos2d::gui::Text::create(); setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "LabelAtlas") == 0) { - widget = cocos2d::gui::LabelAtlas::create(); + widget = cocos2d::gui::TextAtlas::create(); setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "LoadingBar") == 0) @@ -236,7 +236,7 @@ Widget* WidgetPropertiesReader0250::widgetFromJsonDictionary(const rapidjson::Va } else if (classname && strcmp(classname, "TextArea") == 0) { - widget = cocos2d::gui::Label::create(); + widget = cocos2d::gui::Text::create(); setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextButton") == 0) @@ -266,7 +266,7 @@ Widget* WidgetPropertiesReader0250::widgetFromJsonDictionary(const rapidjson::Va } else if (classname && strcmp(classname, "LabelBMFont") == 0) { - widget = cocos2d::gui::LabelBMFont::create(); + widget = cocos2d::gui::TextBMFont::create(); setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "DragPanel") == 0) @@ -543,7 +543,7 @@ void WidgetPropertiesReader0250::setPropsForImageViewFromJsonDictionary(Widget*w void WidgetPropertiesReader0250::setPropsForLabelFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); - cocos2d::gui::Label* label = static_cast(widget); + cocos2d::gui::Text* label = static_cast(widget); bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable"); label->setTouchScaleChangeEnabled(touchScaleChangeAble); const char* text = DICTOOL->getStringValue_json(options, "text"); @@ -581,7 +581,7 @@ void WidgetPropertiesReader0250::setPropsForLabelFromJsonDictionary(Widget*widge void WidgetPropertiesReader0250::setPropsForLabelAtlasFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); - cocos2d::gui::LabelAtlas* labelAtlas = static_cast(widget); + cocos2d::gui::TextAtlas* labelAtlas = static_cast(widget); bool sv = DICTOOL->checkObjectExist_json(options, "stringValue"); bool cmf = DICTOOL->checkObjectExist_json(options, "charMapFile"); bool iw = DICTOOL->checkObjectExist_json(options, "itemWidth"); @@ -837,7 +837,7 @@ void WidgetPropertiesReader0250::setPropsForLabelBMFontFromJsonDictionary(Widget setPropsForWidgetFromJsonDictionary(widget, options); - cocos2d::gui::LabelBMFont* labelBMFont = static_cast(widget); + cocos2d::gui::TextBMFont* labelBMFont = static_cast(widget); std::string tp_c = m_strFilePath; const char* cmf_tp = nullptr; @@ -870,13 +870,13 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c float fileDesignWidth = DICTOOL->getFloatValue_json(data, "designWidth"); float fileDesignHeight = DICTOOL->getFloatValue_json(data, "designHeight"); if (fileDesignWidth <= 0 || fileDesignHeight <= 0) { - printf("Read design size error!\n"); + CCLOGERROR("Read design size error!\n"); Size winSize = Director::getInstance()->getWinSize(); - GUIReader::shareReader()->storeFileDesignSize(fileName, winSize); + GUIReader::getInstance()->storeFileDesignSize(fileName, winSize); } else { - GUIReader::shareReader()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight)); + GUIReader::getInstance()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight)); } const rapidjson::Value& widgetTree = DICTOOL->getSubDictionary_json(data, "widgetTree"); Widget* widget = widgetFromJsonDictionary(widgetTree); @@ -917,12 +917,12 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va } else if (classname && strcmp(classname, "Label") == 0) { - widget = cocos2d::gui::Label::create(); + widget = cocos2d::gui::Text::create(); setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "LabelAtlas") == 0) { - widget = cocos2d::gui::LabelAtlas::create(); + widget = cocos2d::gui::TextAtlas::create(); setPropsForLabelAtlasFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "LoadingBar") == 0) @@ -935,7 +935,7 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va } else if (classname && strcmp(classname, "TextArea") == 0) { - widget = cocos2d::gui::Label::create(); + widget = cocos2d::gui::Text::create(); setPropsForLabelFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "TextButton") == 0) @@ -965,7 +965,7 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va } else if (classname && strcmp(classname, "LabelBMFont") == 0) { - widget = cocos2d::gui::LabelBMFont::create(); + widget = cocos2d::gui::TextBMFont::create(); setPropsForLabelBMFontFromJsonDictionary(widget, uiOptions); } else if (classname && strcmp(classname, "DragPanel") == 0) @@ -1434,7 +1434,7 @@ void WidgetPropertiesReader0300::setPropsForImageViewFromJsonDictionary(Widget*w void WidgetPropertiesReader0300::setPropsForLabelFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); - cocos2d::gui::Label* label = static_cast(widget); + cocos2d::gui::Text* label = static_cast(widget); bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable"); label->setTouchScaleChangeEnabled(touchScaleChangeAble); const char* text = DICTOOL->getStringValue_json(options, "text"); @@ -1472,7 +1472,7 @@ void WidgetPropertiesReader0300::setPropsForLabelFromJsonDictionary(Widget*widge void WidgetPropertiesReader0300::setPropsForLabelAtlasFromJsonDictionary(Widget*widget,const rapidjson::Value& options) { setPropsForWidgetFromJsonDictionary(widget, options); - cocos2d::gui::LabelAtlas* labelAtlas = static_cast(widget); + cocos2d::gui::TextAtlas* labelAtlas = static_cast(widget); bool sv = DICTOOL->checkObjectExist_json(options, "stringValue"); bool cmf = DICTOOL->checkObjectExist_json(options, "charMapFile"); bool iw = DICTOOL->checkObjectExist_json(options, "itemWidth"); @@ -1850,7 +1850,7 @@ void WidgetPropertiesReader0300::setPropsForLabelBMFontFromJsonDictionary(Widget { setPropsForWidgetFromJsonDictionary(widget, options); - cocos2d::gui::LabelBMFont* labelBMFont = static_cast(widget); + cocos2d::gui::TextBMFont* labelBMFont = static_cast(widget); const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, "fileNameData"); int cmfType = DICTOOL->getIntValue_json(cmftDic, "resourceType"); diff --git a/cocos/editor-support/cocostudio/CCSGUIReader.h b/cocos/editor-support/cocostudio/CCSGUIReader.h index d9c9526a53..e44e390a97 100644 --- a/cocos/editor-support/cocostudio/CCSGUIReader.h +++ b/cocos/editor-support/cocostudio/CCSGUIReader.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CCSGUIREADER_H__ #define __CCSGUIREADER_H__ @@ -31,27 +31,15 @@ namespace cocostudio { #define kCCSVersion 1.0 + class GUIReader : public cocos2d::Object { public: - /** - * @js ctor - */ - GUIReader(); - /** - * @js NA - * @lua NA - */ - ~GUIReader(); - /** - * @js getInstance - * @lua getInstance - */ - static GUIReader* shareReader(); - /** - * @js purge - */ - static void purgeGUIReader(); + CC_DEPRECATED_ATTRIBUTE static GUIReader* shareReader() { return GUIReader::getInstance(); }; + CC_DEPRECATED_ATTRIBUTE static void purgeGUIReader() { GUIReader::destroyInstance(); }; + + static GUIReader* getInstance(); + static void destroyInstance(); cocos2d::gui::Widget* widgetFromJsonFile(const char* fileName); int getVersionInteger(const char* str); @@ -63,7 +51,11 @@ public: * @js NA */ const cocos2d::Size getFileDesignSize(const char* fileName) const; + protected: + GUIReader(); + ~GUIReader(); + std::string m_strFilePath; cocos2d::ValueMap _fileDesignSizes; diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.cpp b/cocos/editor-support/cocostudio/CCSSceneReader.cpp index 5b65a2f7d8..12b18604ff 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.cpp +++ b/cocos/editor-support/cocostudio/CCSSceneReader.cpp @@ -1,455 +1,234 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "cocostudio/CocoStudio.h" #include "gui/CocosGUI.h" +#include "SimpleAudioEngine.h" +#include "ObjectFactory.h" using namespace cocos2d; using namespace gui; namespace cocostudio { - SceneReader* SceneReader::s_sharedReader = nullptr; +SceneReader* SceneReader::s_sharedReader = nullptr; - SceneReader::SceneReader() - : _pListener(NULL) - , _pfnSelector(NULL) - , _pNode(NULL) - { - } +SceneReader::SceneReader() +: _fnSelector(nullptr) +, _node(nullptr) +{ + ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAttribute)); + ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComRender)); + ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAudio)); + ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComController)); +} - SceneReader::~SceneReader() - { - } +SceneReader::~SceneReader() +{ +} - const char* SceneReader::sceneReaderVersion() - { - return "1.0.0.0"; - } +const char* SceneReader::sceneReaderVersion() +{ + return "1.0.0.0"; +} - cocos2d::Node* SceneReader::createNodeWithSceneFile(const char* pszFileName) - { - rapidjson::Document jsonDict; - do { - CC_BREAK_IF(!readJson(pszFileName, jsonDict)); - _pNode = createObject(jsonDict, NULL); - TriggerMng::getInstance()->parse(jsonDict); - } while (0); - - return _pNode; - } - - bool SceneReader::readJson(const char *pszFileName, rapidjson::Document &doc) - { - bool bRet = false; - do { - CC_BREAK_IF(pszFileName == NULL); - std::string jsonpath = CCFileUtils::getInstance()->fullPathForFilename(pszFileName); - std::string contentStr = FileUtils::getInstance()->getStringFromFile(jsonpath); - doc.Parse<0>(contentStr.c_str()); - CC_BREAK_IF(doc.HasParseError()); - bRet = true; - } while (0); - return bRet; - } - - Node* SceneReader::nodeByTag(Node *pParent, int nTag) - { - if (pParent == NULL) - { - return NULL; - } - Node *_retNode = NULL; - Vector& Children = pParent->getChildren(); - Vector::iterator iter = Children.begin(); - while (iter != Children.end()) - { - Node* pNode = *iter; - if(pNode != NULL && pNode->getTag() == nTag) - { - _retNode = pNode; - break; - } - else - { - _retNode = nodeByTag(pNode, nTag); - if (_retNode != NULL) - { - break; - } - - } - ++iter; - } - return _retNode; - } - - - Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* parent) - { - const char *className = DICTOOL->getStringValue_json(dict, "classname"); - if(strcmp(className, "CCNode") == 0) - { - Node* gb = nullptr; - if(nullptr == parent) - { - gb = Node::create(); - } - else - { - gb = Node::create(); - parent->addChild(gb); - } - - setPropertyFromJsonDict(dict, gb); +cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName) +{ + rapidjson::Document jsonDict; + do { + CC_BREAK_IF(!readJson(fileName, jsonDict)); + _node = createObject(jsonDict, nullptr); + TriggerMng::getInstance()->parse(jsonDict); + } while (0); - int count = DICTOOL->getArrayCount_json(dict, "components"); - for (int i = 0; i < count; i++) - { - const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(dict, "components", i); - if (!DICTOOL->checkObjectExist_json(subDict)) - { - break; - } - const char *comName = DICTOOL->getStringValue_json(subDict, "classname"); - const char *pComName = DICTOOL->getStringValue_json(subDict, "name"); - - const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(subDict, "fileData"); - std::string pPath; - std::string pPlistFile; - int nResType = 0; - if (DICTOOL->checkObjectExist_json(fileData)) - { - const char *file = DICTOOL->getStringValue_json(fileData, "path"); - nResType = DICTOOL->getIntValue_json(fileData, "resourceType", - 1); - const char *plistFile = DICTOOL->getStringValue_json(fileData, "plistFile"); - if (file != nullptr) - { - pPath.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(file)); - } + return _node; +} - if (plistFile != nullptr) - { - pPlistFile.append(cocos2d::FileUtils::getInstance()->fullPathForFilename(plistFile)); - } - - if (file == nullptr && plistFile == nullptr) - { - continue; - } - } - else - { - continue; - } +bool SceneReader::readJson(const std::string &fileName, rapidjson::Document &doc) +{ + bool bRet = false; + do { + std::string jsonpath = FileUtils::getInstance()->fullPathForFilename(fileName); + std::string contentStr = FileUtils::getInstance()->getStringFromFile(jsonpath); + doc.Parse<0>(contentStr.c_str()); + CC_BREAK_IF(doc.HasParseError()); + bRet = true; + } while (0); + return bRet; +} - if (comName != nullptr && strcmp(comName, "CCSprite") == 0) - { - cocos2d::Sprite *pSprite = nullptr; - - if (nResType == 0) - { - if (pPath.find(".png") == pPath.npos) - { - continue; - } - pSprite = Sprite::create(pPath.c_str()); - } - else if (nResType == 1) - { - std::string pngFile = pPlistFile; - std::string::size_type pos = pngFile.find(".plist"); - if (pos == pPath.npos) - { - continue; - } - pngFile.replace(pos, pngFile.length(), ".png"); - CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(pPlistFile.c_str(), pngFile.c_str()); - pSprite = Sprite::createWithSpriteFrameName(pPath.c_str()); - } - else - { - continue; - } - - ComRender *pRender = ComRender::create(pSprite, "CCSprite"); - if (pComName != nullptr) - { - pRender->setName(pComName); - } - - gb->addComponent(pRender); - if (_pListener && _pfnSelector) - { - (_pListener->*_pfnSelector)(pSprite, (void*)(&subDict)); - } - } - else if(comName != nullptr && strcmp(comName, "CCTMXTiledMap") == 0) - { - cocos2d::TMXTiledMap *pTmx = nullptr; - if (nResType == 0) - { - if (pPath.find(".tmx") == pPath.npos) - { - continue; - } - pTmx = TMXTiledMap::create(pPath.c_str()); - } - else - { - continue; - } - - ComRender *pRender = ComRender::create(pTmx, "CCTMXTiledMap"); - if (pComName != nullptr) - { - pRender->setName(pComName); - } - gb->addComponent(pRender); - if (_pListener && _pfnSelector) - { - (_pListener->*_pfnSelector)(pTmx, (void*)(&subDict)); - } - } - else if(comName != nullptr && strcmp(comName, "CCParticleSystemQuad") == 0) - { - std::string::size_type pos = pPath.find(".plist"); - if (pos == pPath.npos) - { - continue; - } - - cocos2d::ParticleSystemQuad *pParticle = nullptr; - if (nResType == 0) - { - pParticle = ParticleSystemQuad::create(pPath.c_str()); - } - else - { - CCLOG("unknown resourcetype on CCParticleSystemQuad!"); - } - - pParticle->setPosition(0, 0); - ComRender *pRender = ComRender::create(pParticle, "CCParticleSystemQuad"); - if (pComName != nullptr) - { - pRender->setName(pComName); - } - gb->addComponent(pRender); - if (_pListener && _pfnSelector) - { - (_pListener->*_pfnSelector)(pParticle, (void*)(&subDict)); - } - } - else if(comName != nullptr && strcmp(comName, "CCArmature") == 0) - { - if (nResType != 0) - { - continue; - } - std::string reDir = pPath; - std::string file_path = ""; - size_t pos = reDir.find_last_of('/'); - if (pos != std::string::npos) - { - file_path = reDir.substr(0, pos+1); - } - - rapidjson::Document jsonDict; - if(!readJson(pPath.c_str(), jsonDict)) - { - log("read json file[%s] error!\n", pPath.c_str()); - continue; - } - - const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(jsonDict, "armature_data", 0); - const char *name = DICTOOL->getStringValue_json(subData, "name"); - - ArmatureDataManager::getInstance()->addArmatureFileInfo(pPath.c_str()); - - Armature *pAr = Armature::create(name); - ComRender *pRender = ComRender::create(pAr, "CCArmature"); - if (pComName != nullptr) - { - pRender->setName(pComName); - } - gb->addComponent(pRender); - - const char *actionName = DICTOOL->getStringValue_json(subDict, "selectedactionname"); - if (actionName != nullptr && pAr->getAnimation() != nullptr) - { - pAr->getAnimation()->play(actionName); - } - if (_pListener && _pfnSelector) - { - (_pListener->*_pfnSelector)(pAr, (void*)(&subDict)); - } - } - else if(comName != nullptr && strcmp(comName, "CCComAudio") == 0) - { - ComAudio *pAudio = nullptr; - if (nResType == 0) - { - pAudio = ComAudio::create(); - } - else - { - continue; - } - pAudio->preloadEffect(pPath.c_str()); - gb->addComponent(pAudio); - if (_pListener && _pfnSelector) - { - (_pListener->*_pfnSelector)(pAudio, (void*)(&subDict)); - } - } - else if(comName != nullptr && strcmp(comName, "CCComAttribute") == 0) - { - ComAttribute *pAttribute = nullptr; - if (nResType == 0) - { - pAttribute = ComAttribute::create(); - } - else - { - CCLOG("unknown resourcetype on CCComAttribute!"); - continue; - } - gb->addComponent(pAttribute); - if (_pListener && _pfnSelector) - { - (_pListener->*_pfnSelector)(pAttribute, (void*)(&subDict)); - } - } - else if (comName != nullptr && strcmp(comName, "CCBackgroundAudio") == 0) - { - ComAudio *pAudio = nullptr; - if (nResType == 0) - { - pAudio = ComAudio::create(); - } - else - { - continue; - } - pAudio->preloadBackgroundMusic(pPath.c_str()); - pAudio->setFile(pPath.c_str()); - const bool bLoop = (DICTOOL->getIntValue_json(subDict, "loop") != 0); - pAudio->setLoop(bLoop); - gb->addComponent(pAudio); - pAudio->playBackgroundMusic(pPath.c_str(), bLoop); - } - else if(comName != nullptr && strcmp(comName, "GUIComponent") == 0) - { - Widget* widget= GUIReader::shareReader()->widgetFromJsonFile(pPath.c_str()); - ComRender *pRender = ComRender::create(widget, "GUIComponent"); - if (pComName != nullptr) - { - pRender->setName(pComName); - } - gb->addComponent(pRender); - if (_pListener && _pfnSelector) - { - (_pListener->*_pfnSelector)(widget, (void*)(&subDict)); - } - } - } - - int length = DICTOOL->getArrayCount_json(dict, "gameobjects"); - for (int i = 0; i < length; ++i) - { - const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(dict, "gameobjects", i); - if (!DICTOOL->checkObjectExist_json(subDict)) - { - break; - } - createObject(subDict, gb); - } - - return gb; - } - +Node* SceneReader::nodeByTag(Node *parent, int tag) +{ + if (parent == nullptr) + { return nullptr; } - - void SceneReader::setTarget(Object *rec, SEL_CallFuncOD selector) - { - _pListener = rec; - _pfnSelector = selector; - } - - Node* SceneReader::getNodeByTag(int nTag) - { - if (_pNode == NULL) - { - return NULL; - } - if (_pNode->getTag() == nTag) - { - return _pNode; - } - return nodeByTag(_pNode, nTag); - } - - void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d::Node *node) + Node *_retNode = nullptr; + Vector& Children = parent->getChildren(); + Vector::iterator iter = Children.begin(); + while (iter != Children.end()) { - float x = DICTOOL->getFloatValue_json(root, "x"); - float y = DICTOOL->getFloatValue_json(root, "y"); - node->setPosition(Point(x, y)); - - const bool bVisible = (DICTOOL->getIntValue_json(root, "visible", 1) != 0); - node->setVisible(bVisible); - - int nTag = DICTOOL->getIntValue_json(root, "objecttag", -1); - node->setTag(nTag); - - int nZorder = DICTOOL->getIntValue_json(root, "zorder"); - node->setZOrder(nZorder); - - float fScaleX = DICTOOL->getFloatValue_json(root, "scalex", 1.0); - float fScaleY = DICTOOL->getFloatValue_json(root, "scaley", 1.0); - node->setScaleX(fScaleX); - node->setScaleY(fScaleY); - - float fRotationZ = DICTOOL->getFloatValue_json(root, "rotation"); - node->setRotation(fRotationZ); - } - - SceneReader* SceneReader::getInstance() - { - if (s_sharedReader == nullptr) + Node* pNode = *iter; + if(pNode != nullptr && pNode->getTag() == tag) { - s_sharedReader = new SceneReader(); + _retNode = pNode; + break; } - return s_sharedReader; - } + else + { + _retNode = nodeByTag(pNode, tag); + if (_retNode != nullptr) + { + break; + } - void SceneReader::destroyInstance() - { - DictionaryHelper::destroyInstance(); - TriggerMng::destroyInstance(); - CC_SAFE_DELETE(s_sharedReader); + } + ++iter; } + return _retNode; +} + + +Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* parent) +{ + const char *className = DICTOOL->getStringValue_json(dict, "classname"); + if(strcmp(className, "CCNode") == 0) + { + Node* gb = nullptr; + if(nullptr == parent) + { + gb = Node::create(); + } + else + { + gb = Node::create(); + parent->addChild(gb); + } + + setPropertyFromJsonDict(dict, gb); + + int count = DICTOOL->getArrayCount_json(dict, "components"); + for (int i = 0; i < count; i++) + { + const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(dict, "components", i); + if (!DICTOOL->checkObjectExist_json(subDict)) + { + break; + } + const char *comName = DICTOOL->getStringValue_json(subDict, "classname"); + Component *com = ObjectFactory::getInstance()->createComponent(comName); + if (com != NULL) + { + if (com->serialize((void*)(&subDict))) + { + gb->addComponent(com); + } + else + { + CC_SAFE_RELEASE_NULL(com); + } + } + if(_fnSelector != nullptr) + { + _fnSelector(com, (void*)(&subDict)); + } + } + + int length = DICTOOL->getArrayCount_json(dict, "gameobjects"); + for (int i = 0; i < length; ++i) + { + const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(dict, "gameobjects", i); + if (!DICTOOL->checkObjectExist_json(subDict)) + { + break; + } + createObject(subDict, gb); + } + + return gb; + } + + return nullptr; +} + +void SceneReader::setTarget(const std::function& selector) +{ + _fnSelector = selector; +} + +Node* SceneReader::getNodeByTag(int nTag) +{ + if (_node == nullptr) + { + return nullptr; + } + if (_node->getTag() == nTag) + { + return _node; + } + return nodeByTag(_node, nTag); +} + +void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d::Node *node) +{ + float x = DICTOOL->getFloatValue_json(root, "x"); + float y = DICTOOL->getFloatValue_json(root, "y"); + node->setPosition(Point(x, y)); + + const bool bVisible = (DICTOOL->getIntValue_json(root, "visible", 1) != 0); + node->setVisible(bVisible); + + int nTag = DICTOOL->getIntValue_json(root, "objecttag", -1); + node->setTag(nTag); + + int nZorder = DICTOOL->getIntValue_json(root, "zorder"); + node->setZOrder(nZorder); + + float fScaleX = DICTOOL->getFloatValue_json(root, "scalex", 1.0); + float fScaleY = DICTOOL->getFloatValue_json(root, "scaley", 1.0); + node->setScaleX(fScaleX); + node->setScaleY(fScaleY); + + float fRotationZ = DICTOOL->getFloatValue_json(root, "rotation"); + node->setRotation(fRotationZ); +} + +SceneReader* SceneReader::getInstance() +{ + if (s_sharedReader == nullptr) + { + s_sharedReader = new SceneReader(); + } + return s_sharedReader; +} + +void SceneReader::destroyInstance() +{ + DictionaryHelper::destroyInstance(); + TriggerMng::destroyInstance(); + CocosDenshion::SimpleAudioEngine::end(); + CC_SAFE_DELETE(s_sharedReader); +} } diff --git a/cocos/editor-support/cocostudio/CCSSceneReader.h b/cocos/editor-support/cocostudio/CCSSceneReader.h index 46a9c5f1ff..6b72b82574 100644 --- a/cocos/editor-support/cocostudio/CCSSceneReader.h +++ b/cocos/editor-support/cocostudio/CCSSceneReader.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __CCSSCENEREADER_H__ #define __CCSSCENEREADER_H__ @@ -31,22 +31,8 @@ namespace cocostudio { -typedef void (cocos2d::Object::*SEL_CallFuncOD)(cocos2d::Object*, void*); -#define callfuncOD_selector(_SELECTOR) (SEL_CallFuncOD)(&_SELECTOR) - class SceneReader { -public: - /** - * @js ctor - */ - SceneReader(void); - /** - * @js NA - * @lua NA - */ - virtual ~SceneReader(void); - public: static SceneReader* getInstance(); /** @@ -55,19 +41,22 @@ public: */ static void destroyInstance(); static const char* sceneReaderVersion(); - cocos2d::Node* createNodeWithSceneFile(const char *pszFileName); - void setTarget(cocos2d::Object *rec, SEL_CallFuncOD selector); + cocos2d::Node* createNodeWithSceneFile(const std::string &fileName); + void setTarget(const std::function& selector); cocos2d::Node* getNodeByTag(int nTag); + private: + SceneReader(void); + virtual ~SceneReader(void); + cocos2d::Node* createObject(const rapidjson::Value& dict, cocos2d::Node* parent); void setPropertyFromJsonDict(const rapidjson::Value& dict, cocos2d::Node *node); - bool readJson(const char *pszFileName, rapidjson::Document &doc); - cocos2d::Node* nodeByTag(cocos2d::Node *pParent, int nTag); + bool readJson(const std::string &fileName, rapidjson::Document& doc); + cocos2d::Node* nodeByTag(cocos2d::Node *parent, int tag); private: static SceneReader* s_sharedReader; - cocos2d::Object* _pListener; - SEL_CallFuncOD _pfnSelector; - cocos2d::Node* _pNode; + std::function _fnSelector; + cocos2d::Node* _node; }; diff --git a/cocos/editor-support/cocostudio/CCSkin.cpp b/cocos/editor-support/cocostudio/CCSkin.cpp index 0f41b9f6f9..94ba291e2b 100644 --- a/cocos/editor-support/cocostudio/CCSkin.cpp +++ b/cocos/editor-support/cocostudio/CCSkin.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCSkin.h b/cocos/editor-support/cocostudio/CCSkin.h index 42ba994189..e0f255e70d 100644 --- a/cocos/editor-support/cocostudio/CCSkin.h +++ b/cocos/editor-support/cocostudio/CCSkin.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp index fb1cf6065b..c5399ba479 100644 --- a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp +++ b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h index 89c20f6833..75797c1aa2 100644 --- a/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h +++ b/cocos/editor-support/cocostudio/CCSpriteFrameCacheHelper.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCTransformHelp.cpp b/cocos/editor-support/cocostudio/CCTransformHelp.cpp index bc81478d17..6979285cff 100644 --- a/cocos/editor-support/cocostudio/CCTransformHelp.cpp +++ b/cocos/editor-support/cocostudio/CCTransformHelp.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCTransformHelp.h b/cocos/editor-support/cocostudio/CCTransformHelp.h index 57b57fad9c..3dedccbebe 100644 --- a/cocos/editor-support/cocostudio/CCTransformHelp.h +++ b/cocos/editor-support/cocostudio/CCTransformHelp.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCTween.cpp b/cocos/editor-support/cocostudio/CCTween.cpp index ccd5a74eeb..8d4aaccf72 100644 --- a/cocos/editor-support/cocostudio/CCTween.cpp +++ b/cocos/editor-support/cocostudio/CCTween.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -330,7 +330,7 @@ void Tween::arriveKeyFrame(FrameData *keyFrameData) if (!displayManager->isForceChangeDisplay()) { - displayManager->changeDisplayByIndex(displayIndex, false); + displayManager->changeDisplayWithIndex(displayIndex, false); } //! Update bone zorder, bone's zorder is determined by frame zorder and bone zorder diff --git a/cocos/editor-support/cocostudio/CCTween.h b/cocos/editor-support/cocostudio/CCTween.h index 9a6357059f..8153d21e0d 100644 --- a/cocos/editor-support/cocostudio/CCTween.h +++ b/cocos/editor-support/cocostudio/CCTween.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCTweenFunction.cpp b/cocos/editor-support/cocostudio/CCTweenFunction.cpp index 808e314c7e..853a3f46e1 100644 --- a/cocos/editor-support/cocostudio/CCTweenFunction.cpp +++ b/cocos/editor-support/cocostudio/CCTweenFunction.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCTweenFunction.h b/cocos/editor-support/cocostudio/CCTweenFunction.h index d845636244..f5d5aac1eb 100644 --- a/cocos/editor-support/cocostudio/CCTweenFunction.h +++ b/cocos/editor-support/cocostudio/CCTweenFunction.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCUtilMath.cpp b/cocos/editor-support/cocostudio/CCUtilMath.cpp index 0714958857..ec78117792 100644 --- a/cocos/editor-support/cocostudio/CCUtilMath.cpp +++ b/cocos/editor-support/cocostudio/CCUtilMath.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CCUtilMath.h b/cocos/editor-support/cocostudio/CCUtilMath.h index 20541a8c80..b10690d620 100644 --- a/cocos/editor-support/cocostudio/CCUtilMath.h +++ b/cocos/editor-support/cocostudio/CCUtilMath.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/CMakeLists.txt b/cocos/editor-support/cocostudio/CMakeLists.txt index 7db63eac1a..a6f86af9e5 100644 --- a/cocos/editor-support/cocostudio/CMakeLists.txt +++ b/cocos/editor-support/cocostudio/CMakeLists.txt @@ -51,7 +51,7 @@ target_link_libraries(cocostudio set_target_properties(cocostudio PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/cocos/editor-support/cocostudio/CocoStudio.h b/cocos/editor-support/cocostudio/CocoStudio.h index caf7fbf00d..9f1875957d 100644 --- a/cocos/editor-support/cocostudio/CocoStudio.h +++ b/cocos/editor-support/cocostudio/CocoStudio.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __EDITOR_SUPPORT_COCOSTUDIO_H__ #define __EDITOR_SUPPORT_COCOSTUDIO_H__ @@ -49,6 +49,7 @@ #include "cocostudio/CCTransformHelp.h" #include "cocostudio/CCTweenFunction.h" #include "cocostudio/CCUtilMath.h" +#include "cocostudio/CCComBase.h" #include "cocostudio/CCComAttribute.h" #include "cocostudio/CCComAudio.h" #include "cocostudio/CCComController.h" diff --git a/cocos/editor-support/cocostudio/DictionaryHelper.cpp b/cocos/editor-support/cocostudio/DictionaryHelper.cpp index 9151f52123..0c46694e7b 100644 --- a/cocos/editor-support/cocostudio/DictionaryHelper.cpp +++ b/cocos/editor-support/cocostudio/DictionaryHelper.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "cocostudio/DictionaryHelper.h" diff --git a/cocos/editor-support/cocostudio/DictionaryHelper.h b/cocos/editor-support/cocostudio/DictionaryHelper.h index b8da590829..58f58455f5 100644 --- a/cocos/editor-support/cocostudio/DictionaryHelper.h +++ b/cocos/editor-support/cocostudio/DictionaryHelper.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __DICTIONARYHELPER_H__ #define __DICTIONARYHELPER_H__ diff --git a/cocos/editor-support/cocostudio/ObjectFactory.cpp b/cocos/editor-support/cocostudio/ObjectFactory.cpp index 17015867e2..b74fee8859 100644 --- a/cocos/editor-support/cocostudio/ObjectFactory.cpp +++ b/cocos/editor-support/cocostudio/ObjectFactory.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -87,7 +87,7 @@ void ObjectFactory::destroyInstance() CC_SAFE_DELETE(_sharedFactory); } -Object* ObjectFactory::createObject(const char *name) +Object* ObjectFactory::createObject(const std::string &name) { Object *o = nullptr; do @@ -100,6 +100,45 @@ Object* ObjectFactory::createObject(const char *name) return o; } +Component* ObjectFactory::createComponent(const std::string &name) +{ + std::string comName; + if (name == "CCSprite" || name == "CCTMXTiledMap" || name == "CCParticleSystemQuad" || name == "CCArmature" || name == "GUIComponent") + { + comName = "ComRender"; + } + else if (name == "CCComAudio" || name == "CCBackgroundAudio") + { + comName = "ComAudio"; + } + else if (name == "CCComController") + { + comName = "ComController"; + } + else if (name == "CCComAttribute") + { + comName = "ComAttribute"; + } + else if (name == "CCScene") + { + comName = "Scene"; + } + else + { + CCASSERT(false, "Unregistered Component!"); + } + Object *o = NULL; + do + { + const TInfo t = _typeMap[comName]; + CC_BREAK_IF(t._fun == NULL); + o = t._fun(); + } while (0); + + return (Component*)o; + +} + void ObjectFactory::registerType(const TInfo &t) { _typeMap.insert(std::make_pair(t._class, t)); diff --git a/cocos/editor-support/cocostudio/ObjectFactory.h b/cocos/editor-support/cocostudio/ObjectFactory.h index 3cdec3cd6d..94be620b56 100644 --- a/cocos/editor-support/cocostudio/ObjectFactory.h +++ b/cocos/editor-support/cocostudio/ObjectFactory.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -26,7 +26,6 @@ THE SOFTWARE. #define __TRIGGERFACTORY_H__ #include "cocos2d.h" -#include "CocoStudio.h" #include #include @@ -50,7 +49,8 @@ public: static ObjectFactory* getInstance(); static void destroyInstance(); - cocos2d::Object* createObject(const char *name); + cocos2d::Object* createObject(const std::string &name); + cocos2d::Component* createComponent(const std::string &name); void registerType(const TInfo &t); void removeAll(); diff --git a/cocos/editor-support/cocostudio/TriggerBase.cpp b/cocos/editor-support/cocostudio/TriggerBase.cpp index 59cff85905..9d7f424bcb 100644 --- a/cocos/editor-support/cocostudio/TriggerBase.cpp +++ b/cocos/editor-support/cocostudio/TriggerBase.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/editor-support/cocostudio/TriggerBase.h b/cocos/editor-support/cocostudio/TriggerBase.h index 1558ff7b8a..f90d8028b2 100644 --- a/cocos/editor-support/cocostudio/TriggerBase.h +++ b/cocos/editor-support/cocostudio/TriggerBase.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -27,8 +27,8 @@ THE SOFTWARE. #include "cocos2d.h" #include "cocostudio/CocoStudio.h" -#include "TriggerObj.h" #include "ObjectFactory.h" +#include "TriggerObj.h" #include "TriggerMng.h" diff --git a/cocos/editor-support/cocostudio/TriggerMng.cpp b/cocos/editor-support/cocostudio/TriggerMng.cpp index a81d6abb74..bc0d4580c2 100644 --- a/cocos/editor-support/cocostudio/TriggerMng.cpp +++ b/cocos/editor-support/cocostudio/TriggerMng.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -23,6 +23,9 @@ THE SOFTWARE. ****************************************************************************/ #include "TriggerMng.h" +#include "json/filestream.h" +#include "json/prettywriter.h" +#include "json/stringbuffer.h" using namespace cocos2d; @@ -67,23 +70,38 @@ void TriggerMng::destroyInstance() void TriggerMng::parse(const rapidjson::Value &root) { CCLOG("%s", triggerMngVersion()); - do { - int count = DICTOOL->getArrayCount_json(root, "Triggers"); - for (int i = 0; i < count; ++i) - { - const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(root, "Triggers", i); - TriggerObj *obj = TriggerObj::create(); - obj->serialize(subDict); - auto &vInt = obj->getEvents(); - for (const auto& e : vInt) - { - add((unsigned int)e, obj); - } - - _triggerObjs.insert(std::pair(obj->getId(), obj)); - } - - } while (0); + int count = DICTOOL->getArrayCount_json(root, "Triggers"); + ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine(); + bool useBindings = engine != nullptr; + + if (useBindings) + { + if (count > 0) + { + const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(root, "Triggers"); + rapidjson::StringBuffer buffer; + rapidjson::Writer writer(buffer); + subDict.Accept(writer); + + engine->parseConfig(ScriptEngineProtocol::ConfigType::COCOSTUDIO, buffer.GetString()); + } + } + else + { + for (int i = 0; i < count; ++i) + { + const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(root, "Triggers", i); + TriggerObj *obj = TriggerObj::create(); + obj->serialize(subDict); + auto &vInt = obj->getEvents(); + for (const auto& e : vInt) + { + add((unsigned int)e, obj); + } + + _triggerObjs.insert(std::pair(obj->getId(), obj)); + } + } } cocos2d::Vector* TriggerMng::get(unsigned int event) const @@ -233,14 +251,14 @@ void TriggerMng::addArmatureMovementCallBack(Armature *pAr, Object *pTarget, SEL { amd = new ArmatureMovementDispatcher(); pAr->getAnimation()->setMovementEventCallFunc(CC_CALLBACK_0(ArmatureMovementDispatcher::animationEvent, amd, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - amd->addAnnimationEventCallBack(pTarget, mecf); + amd->addAnimationEventCallBack(pTarget, mecf); _movementDispatches->insert(std::make_pair(pAr, amd)); } else { amd = iter->second; - amd->addAnnimationEventCallBack(pTarget, mecf); + amd->addAnimationEventCallBack(pTarget, mecf); } } @@ -313,7 +331,7 @@ ArmatureMovementDispatcher::~ArmatureMovementDispatcher(void) } } - void ArmatureMovementDispatcher::addAnnimationEventCallBack(Object *pTarget, SEL_MovementEventCallFunc mecf) + void ArmatureMovementDispatcher::addAnimationEventCallBack(Object *pTarget, SEL_MovementEventCallFunc mecf) { _mapEventAnimation->insert(std::make_pair(pTarget, mecf)); } diff --git a/cocos/editor-support/cocostudio/TriggerMng.h b/cocos/editor-support/cocostudio/TriggerMng.h index a0a9d1dfcc..3f84d3810b 100644 --- a/cocos/editor-support/cocostudio/TriggerMng.h +++ b/cocos/editor-support/cocostudio/TriggerMng.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -21,7 +21,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - #ifndef __TRIGGERMNG_H__ #define __TRIGGERMNG_H__ @@ -38,7 +37,7 @@ public: ArmatureMovementDispatcher(void); ~ArmatureMovementDispatcher(void); public: - void addAnnimationEventCallBack(cocos2d::Object*pTarget, SEL_MovementEventCallFunc mecf); + void addAnimationEventCallBack(cocos2d::Object*pTarget, SEL_MovementEventCallFunc mecf); void removeAnnimationEventCallBack(cocos2d::Object*pTarget, SEL_MovementEventCallFunc mecf); void animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID); diff --git a/cocos/editor-support/cocostudio/TriggerObj.cpp b/cocos/editor-support/cocostudio/TriggerObj.cpp index 196fd02db2..83d7bdcfbc 100644 --- a/cocos/editor-support/cocostudio/TriggerObj.cpp +++ b/cocos/editor-support/cocostudio/TriggerObj.cpp @@ -1,5 +1,5 @@ - /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +/**************************************************************************** +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -81,7 +81,7 @@ void BaseTriggerAction::removeAll() TriggerObj::TriggerObj(void) :_id(UINT_MAX) -,_bEnable(true) +,_enabled(true) { _vInt.clear(); } @@ -112,28 +112,29 @@ TriggerObj* TriggerObj::create() bool TriggerObj::detect() { - if (!_bEnable || _cons.size() == 0) + if (!_enabled || _cons.empty()) { return true; } - bool bRet = true; + + bool ret = true; - for(auto con : _cons) + for (const auto& con : _cons) { - bRet = bRet && con->detect(); + ret = ret && con->detect(); } - return bRet; + return ret; } void TriggerObj::done() { - if (!_bEnable || _acts.size() == 0) + if (!_enabled || _acts.empty()) { return; } - for(auto act : _acts) + for (const auto& act : _acts) { act->done(); } @@ -141,11 +142,12 @@ void TriggerObj::done() void TriggerObj::removeAll() { - for(auto con : _cons) + for (const auto& con : _cons) { con->removeAll(); } - for(auto act : _acts) + + for (const auto& act : _acts) { act->removeAll(); } @@ -167,7 +169,13 @@ void TriggerObj::serialize(const rapidjson::Value &val) continue; } BaseTriggerCondition *con = dynamic_cast(ObjectFactory::getInstance()->createObject(classname)); - CCAssert(con != nullptr, "class named classname can not implement!"); + if(con == nullptr) + { + CCLOG("class %s can not be implemented!", classname); + CCASSERT(con != nullptr, ""); + } + + CCASSERT(con != nullptr, ""); con->serialize(subDict); con->init(); con->autorelease(); @@ -184,7 +192,11 @@ void TriggerObj::serialize(const rapidjson::Value &val) continue; } BaseTriggerAction *act = dynamic_cast(ObjectFactory::getInstance()->createObject(classname)); - CCAssert(act != nullptr, "class named classname can not implement!"); + if(act == nullptr) + { + CCLOG("class %s can not be implemented!", classname); + CCASSERT(act != nullptr, ""); + } act->serialize(subDict); act->init(); act->autorelease(); @@ -209,9 +221,9 @@ unsigned int TriggerObj::getId() return _id; } -void TriggerObj::setEnable(bool bEnable) +void TriggerObj::setEnabled(bool enabled) { - _bEnable = bEnable; + _enabled = enabled; } std::vector& TriggerObj::getEvents() diff --git a/cocos/editor-support/cocostudio/TriggerObj.h b/cocos/editor-support/cocostudio/TriggerObj.h index 4c29b60021..55d98ca504 100644 --- a/cocos/editor-support/cocostudio/TriggerObj.h +++ b/cocos/editor-support/cocostudio/TriggerObj.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2013 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -70,14 +70,14 @@ public: virtual void removeAll(); virtual void serialize(const rapidjson::Value &val); unsigned int getId(); - void setEnable(bool bEnable); + void setEnabled(bool enabled); std::vector& getEvents(); private: cocos2d::Vector _cons; cocos2d::Vector _acts; unsigned int _id; - bool _bEnable; + bool _enabled; std::vector _vInt; }; diff --git a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj index 2947e0396d..f572d6f892 100644 --- a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj +++ b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj @@ -75,6 +75,7 @@ + @@ -151,6 +152,7 @@ true 4267;4251;4244;%(DisableSpecificWarnings) false + OldStyle true diff --git a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters index 626355b8d3..bf17c59cbb 100644 --- a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters +++ b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters @@ -296,5 +296,8 @@ trigger + + components + \ No newline at end of file diff --git a/cocos/editor-support/spine/CCSkeleton.cpp b/cocos/editor-support/spine/CCSkeleton.cpp index 77e2243b7d..9051679a98 100644 --- a/cocos/editor-support/spine/CCSkeleton.cpp +++ b/cocos/editor-support/spine/CCSkeleton.cpp @@ -126,7 +126,22 @@ void Skeleton::update (float deltaTime) { spSkeleton_update(skeleton, deltaTime * timeScale); } -void Skeleton::draw () { +void Skeleton::draw() +{ + kmGLMatrixMode(KM_GL_MODELVIEW); + kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix); + + _customCommand.init(0, _vertexZ); + _customCommand.func = CC_CALLBACK_0(Skeleton::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(&_customCommand); +} + +void Skeleton::onDraw () +{ + kmGLMatrixMode(KM_GL_MODELVIEW); + kmGLPushMatrix(); + kmGLLoadMatrix(&_oldTransMatrix); + CC_NODE_DRAW_SETUP(); GL::blendFunc(blendFunc.src, blendFunc.dst); @@ -220,6 +235,9 @@ void Skeleton::draw () { if (i == 0) DrawPrimitives::setDrawColor4B(0, 255, 0, 255); } } + + kmGLMatrixMode(KM_GL_MODELVIEW); + kmGLPopMatrix(); } TextureAtlas* Skeleton::getTextureAtlas (spRegionAttachment* regionAttachment) const { diff --git a/cocos/editor-support/spine/CCSkeleton.h b/cocos/editor-support/spine/CCSkeleton.h index ab4270be0d..f1cffffea6 100644 --- a/cocos/editor-support/spine/CCSkeleton.h +++ b/cocos/editor-support/spine/CCSkeleton.h @@ -64,6 +64,7 @@ public: virtual void update (float deltaTime) override; virtual void draw() override; + void onDraw(); virtual cocos2d::Rect getBoundingBox () const override; // --- Convenience methods for common Skeleton_* functions. @@ -103,6 +104,10 @@ private: void initialize (); // Util function that setting blend-function by nextRenderedTexture's premultiplied flag void setFittedBlendingFunc(cocos2d::TextureAtlas * nextRenderedTexture); + + cocos2d::CustomCommand _customCommand; + + kmMat4 _oldTransMatrix; }; } diff --git a/cocos/editor-support/spine/CMakeLists.txt b/cocos/editor-support/spine/CMakeLists.txt index 613cdb9786..c3d96e8b61 100644 --- a/cocos/editor-support/spine/CMakeLists.txt +++ b/cocos/editor-support/spine/CMakeLists.txt @@ -42,7 +42,7 @@ add_library(spine STATIC set_target_properties(spine PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/cocos/gui/Android.mk b/cocos/gui/Android.mk index f2fad8d7b3..b74d7316bf 100644 --- a/cocos/gui/Android.mk +++ b/cocos/gui/Android.mk @@ -18,9 +18,9 @@ UIScrollView.cpp \ UIButton.cpp \ UICheckBox.cpp \ UIImageView.cpp \ -UILabel.cpp \ -UILabelAtlas.cpp \ -UILabelBMFont.cpp \ +UIText.cpp \ +UITextAtlas.cpp \ +UITextBMFont.cpp \ UILoadingBar.cpp \ UISlider.cpp \ UITextField.cpp diff --git a/cocos/gui/CMakeLists.txt b/cocos/gui/CMakeLists.txt index 8154f3c757..c6a9905072 100644 --- a/cocos/gui/CMakeLists.txt +++ b/cocos/gui/CMakeLists.txt @@ -11,9 +11,9 @@ set(GUI_SRC UIButton.cpp UICheckBox.cpp UIImageView.cpp - UILabel.cpp - UILabelAtlas.cpp - UILabelBMFont.cpp + UIText.cpp + UITextAtlas.cpp + UITextBMFont.cpp UILoadingBar.cpp UISlider.cpp UITextField.cpp @@ -25,6 +25,6 @@ add_library(gui STATIC set_target_properties(gui PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/cocos/gui/CocosGUI.cpp b/cocos/gui/CocosGUI.cpp index 2612e72454..3aef3982eb 100644 --- a/cocos/gui/CocosGUI.cpp +++ b/cocos/gui/CocosGUI.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/CocosGUI.h" diff --git a/cocos/gui/CocosGUI.h b/cocos/gui/CocosGUI.h index 5258625986..3f81214d5e 100644 --- a/cocos/gui/CocosGUI.h +++ b/cocos/gui/CocosGUI.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __COCOSGUI_H__ #define __COCOSGUI_H__ @@ -31,14 +31,14 @@ #include "gui/UIButton.h" #include "gui/UICheckBox.h" #include "gui/UIImageView.h" -#include "gui/UILabel.h" -#include "gui/UILabelAtlas.h" +#include "gui/UIText.h" +#include "gui/UITextAtlas.h" #include "gui/UILoadingBar.h" #include "gui/UIScrollView.h" #include "gui/UIListView.h" #include "gui/UISlider.h" #include "gui/UITextField.h" -#include "gui/UILabelBMFont.h" +#include "gui/UITextBMFont.h" #include "gui/UIPageView.h" #include "gui/UIHelper.h" diff --git a/cocos/gui/UIButton.cpp b/cocos/gui/UIButton.cpp index 206203a014..5a6a2dc54f 100644 --- a/cocos/gui/UIButton.cpp +++ b/cocos/gui/UIButton.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UIButton.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" @@ -29,10 +29,10 @@ NS_CC_BEGIN namespace gui { -#define NORMALRENDERERZ (0) -#define PRESSEDRENDERERZ (0) -#define DISABLEDRENDERERZ (0) -#define TITLERENDERERZ (1) +static const int NORMAL_RENDERER_Z = (-2); +static const int PRESSED_RENDERER_Z = (-2); +static const int DISABLED_RENDERER_Z = (-2); +static const int TITLE_RENDERER_Z = (-1); Button::Button(): _buttonNormalRenderer(nullptr), @@ -54,7 +54,14 @@ _normalTextureSize(_size), _pressedTextureSize(_size), _disabledTextureSize(_size), _pressedActionEnabled(false), -_titleColor(Color3B::WHITE) +_titleColor(Color3B::WHITE), +_normalTextureScaleXInSize(1.0f), +_normalTextureScaleYInSize(1.0f), +_pressedTextureScaleXInSize(1.0f), +_pressedTextureScaleYInSize(1.0f), +_normalTextureLoaded(false), +_pressedTextureLoaded(false), +_disabledTextureLoaded(false) { } @@ -90,10 +97,11 @@ void Button::initRenderer() _buttonClickedRenderer = Sprite::create(); _buttonDisableRenderer = Sprite::create(); _titleRenderer = LabelTTF::create(); - Node::addChild(_buttonNormalRenderer, NORMALRENDERERZ, -1); - Node::addChild(_buttonClickedRenderer, PRESSEDRENDERERZ, -1); - Node::addChild(_buttonDisableRenderer, DISABLEDRENDERERZ, -1); - Node::addChild(_titleRenderer, TITLERENDERERZ, -1); + + Node::addChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1); + Node::addChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1); + Node::addChild(_buttonDisableRenderer, DISABLED_RENDERER_Z, -1); + Node::addChild(_titleRenderer, TITLE_RENDERER_Z, -1); } void Button::setScale9Enabled(bool able) @@ -104,11 +112,9 @@ void Button::setScale9Enabled(bool able) } _brightStyle = BRIGHT_NONE; _scale9Enabled = able; - Node::removeChild(_buttonNormalRenderer); Node::removeChild(_buttonClickedRenderer); Node::removeChild(_buttonDisableRenderer); - _buttonNormalRenderer = nullptr; _buttonClickedRenderer = nullptr; _buttonDisableRenderer = nullptr; @@ -128,9 +134,9 @@ void Button::setScale9Enabled(bool able) loadTextureNormal(_normalFileName.c_str(), _normalTexType); loadTexturePressed(_clickedFileName.c_str(), _pressedTexType); loadTextureDisabled(_disabledFileName.c_str(), _disabledTexType); - Node::addChild(_buttonNormalRenderer, NORMALRENDERERZ, -1); - Node::addChild(_buttonClickedRenderer, PRESSEDRENDERERZ, -1); - Node::addChild(_buttonDisableRenderer, DISABLEDRENDERERZ, -1); + Node::addChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1); + Node::addChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1); + Node::addChild(_buttonDisableRenderer, DISABLED_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; @@ -207,6 +213,7 @@ void Button::loadTextureNormal(const char* normal,TextureResType texType) updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); normalTextureScaleChangedWithSize(); + _normalTextureLoaded = true; } void Button::loadTexturePressed(const char* selected,TextureResType texType) @@ -253,6 +260,7 @@ void Button::loadTexturePressed(const char* selected,TextureResType texType) updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); pressedTextureScaleChangedWithSize(); + _pressedTextureLoaded = true; } void Button::loadTextureDisabled(const char* disabled,TextureResType texType) @@ -299,6 +307,7 @@ void Button::loadTextureDisabled(const char* disabled,TextureResType texType) updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); disabledTextureScaleChangedWithSize(); + _disabledTextureLoaded = true; } void Button::setCapInsets(const Rect &capInsets) @@ -343,36 +352,49 @@ void Button::onPressStateChangedToNormal() _buttonNormalRenderer->setVisible(true); _buttonClickedRenderer->setVisible(false); _buttonDisableRenderer->setVisible(false); - if (_pressedActionEnabled) + if (_pressedTextureLoaded) + { + if (_pressedActionEnabled) + { + _buttonNormalRenderer->stopAllActions(); + _buttonClickedRenderer->stopAllActions(); + Action *zoomAction = ScaleTo::create(0.05f, _normalTextureScaleXInSize, _normalTextureScaleYInSize); + _buttonNormalRenderer->runAction(zoomAction); + _buttonClickedRenderer->setScale(_pressedTextureScaleXInSize, _pressedTextureScaleYInSize); + } + } + else { _buttonNormalRenderer->stopAllActions(); - _buttonClickedRenderer->stopAllActions(); - _buttonDisableRenderer->stopAllActions(); - Action *zoomAction = ScaleTo::create(0.05f, 1.0f); - Action *zoomAction1 = ScaleTo::create(0.05f, 1.0f); - Action *zoomAction2 = ScaleTo::create(0.05f, 1.0f); + Action *zoomAction = ScaleTo::create(0.05f, _normalTextureScaleXInSize, _normalTextureScaleYInSize); _buttonNormalRenderer->runAction(zoomAction); - _buttonClickedRenderer->runAction(zoomAction1); - _buttonDisableRenderer->runAction(zoomAction2); } } void Button::onPressStateChangedToPressed() { - _buttonNormalRenderer->setVisible(false); - _buttonClickedRenderer->setVisible(true); - _buttonDisableRenderer->setVisible(false); - if (_pressedActionEnabled) + if (_pressedTextureLoaded) { + _buttonNormalRenderer->setVisible(false); + _buttonClickedRenderer->setVisible(true); + _buttonDisableRenderer->setVisible(false); + if (_pressedActionEnabled) + { + _buttonNormalRenderer->stopAllActions(); + _buttonClickedRenderer->stopAllActions(); + Action *zoomAction = ScaleTo::create(0.05f, _pressedTextureScaleXInSize + 0.1f, _pressedTextureScaleYInSize + 0.1f); + _buttonClickedRenderer->runAction(zoomAction); + _buttonNormalRenderer->setScale(_pressedTextureScaleXInSize + 0.1f, _pressedTextureScaleYInSize + 0.1f); + } + } + else + { + _buttonNormalRenderer->setVisible(true); + _buttonClickedRenderer->setVisible(true); + _buttonDisableRenderer->setVisible(false); _buttonNormalRenderer->stopAllActions(); - _buttonClickedRenderer->stopAllActions(); - _buttonDisableRenderer->stopAllActions(); - Action *zoomAction = ScaleTo::create(0.05f, 1.1f); - Action *zoomAction1 = ScaleTo::create(0.05f, 1.1f); - Action *zoomAction2 = ScaleTo::create(0.05f, 1.1f); + Action *zoomAction = ScaleTo::create(0.05f, _pressedTextureScaleXInSize + 0.1f, _pressedTextureScaleYInSize + 0.1f); _buttonNormalRenderer->runAction(zoomAction); - _buttonClickedRenderer->runAction(zoomAction1); - _buttonDisableRenderer->runAction(zoomAction2); } } @@ -381,6 +403,8 @@ void Button::onPressStateChangedToDisabled() _buttonNormalRenderer->setVisible(false); _buttonClickedRenderer->setVisible(false); _buttonDisableRenderer->setVisible(true); + _buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize); + _buttonClickedRenderer->setScale(_pressedTextureScaleXInSize, _pressedTextureScaleYInSize); } void Button::setFlipX(bool flipX) @@ -474,6 +498,7 @@ void Button::normalTextureScaleChangedWithSize() if (!_scale9Enabled) { _buttonNormalRenderer->setScale(1.0f); + _normalTextureScaleXInSize = _normalTextureScaleYInSize = 1.0f; _size = _normalTextureSize; } } @@ -482,6 +507,7 @@ void Button::normalTextureScaleChangedWithSize() if (_scale9Enabled) { static_cast(_buttonNormalRenderer)->setPreferredSize(_size); + _normalTextureScaleXInSize = _normalTextureScaleYInSize = 1.0f; } else { @@ -495,6 +521,8 @@ void Button::normalTextureScaleChangedWithSize() float scaleY = _size.height / textureSize.height; _buttonNormalRenderer->setScaleX(scaleX); _buttonNormalRenderer->setScaleY(scaleY); + _normalTextureScaleXInSize = scaleX; + _normalTextureScaleYInSize = scaleY; } } } @@ -506,6 +534,7 @@ void Button::pressedTextureScaleChangedWithSize() if (!_scale9Enabled) { _buttonClickedRenderer->setScale(1.0f); + _pressedTextureScaleXInSize = _pressedTextureScaleYInSize = 1.0f; } } else @@ -513,6 +542,7 @@ void Button::pressedTextureScaleChangedWithSize() if (_scale9Enabled) { static_cast(_buttonClickedRenderer)->setPreferredSize(_size); + _pressedTextureScaleXInSize = _pressedTextureScaleYInSize = 1.0f; } else { @@ -526,6 +556,8 @@ void Button::pressedTextureScaleChangedWithSize() float scaleY = _size.height / _pressedTextureSize.height; _buttonClickedRenderer->setScaleX(scaleX); _buttonClickedRenderer->setScaleY(scaleY); + _pressedTextureScaleXInSize = scaleX; + _pressedTextureScaleYInSize = scaleY; } } } diff --git a/cocos/gui/UIButton.h b/cocos/gui/UIButton.h index a74600df2b..c2f7bf30a4 100644 --- a/cocos/gui/UIButton.h +++ b/cocos/gui/UIButton.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UIBUTTON_H__ #define __UIBUTTON_H__ @@ -216,6 +216,13 @@ protected: Size _disabledTextureSize; bool _pressedActionEnabled; Color3B _titleColor; + float _normalTextureScaleXInSize; + float _normalTextureScaleYInSize; + float _pressedTextureScaleXInSize; + float _pressedTextureScaleYInSize; + bool _normalTextureLoaded; + bool _pressedTextureLoaded; + bool _disabledTextureLoaded; }; } diff --git a/cocos/gui/UICheckBox.cpp b/cocos/gui/UICheckBox.cpp index 27d447bc74..f37baf2b0b 100644 --- a/cocos/gui/UICheckBox.cpp +++ b/cocos/gui/UICheckBox.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UICheckBox.h" @@ -28,11 +28,11 @@ NS_CC_BEGIN namespace gui { -#define BACKGROUNDBOXRENDERERZ (-1) -#define BACKGROUNDSELECTEDBOXRENDERERZ (-1) -#define FRONTCROSSRENDERERZ (-1) -#define BACKGROUNDBOXDISABLEDRENDERERZ (-1) -#define FRONTCROSSDISABLEDRENDERERZ (-1) +static const int BACKGROUNDBOX_RENDERER_Z = (-1); +static const int BACKGROUNDSELECTEDBOX_RENDERER_Z = (-1); +static const int FRONTCROSS_RENDERER_Z = (-1); +static const int BACKGROUNDBOXDISABLED_RENDERER_Z = (-1); +static const int FRONTCROSSDISABLED_RENDERER_Z = (-1); CheckBox::CheckBox(): _backGroundBoxRenderer(nullptr), @@ -92,11 +92,11 @@ void CheckBox::initRenderer() _backGroundBoxDisabledRenderer = Sprite::create(); _frontCrossDisabledRenderer = Sprite::create(); - Node::addChild(_backGroundBoxRenderer, BACKGROUNDBOXRENDERERZ, -1); - Node::addChild(_backGroundSelectedBoxRenderer, BACKGROUNDSELECTEDBOXRENDERERZ, -1); - Node::addChild(_frontCrossRenderer, FRONTCROSSRENDERERZ, -1); - Node::addChild(_backGroundBoxDisabledRenderer, BACKGROUNDBOXDISABLEDRENDERERZ, -1); - Node::addChild(_frontCrossDisabledRenderer, FRONTCROSSDISABLEDRENDERERZ, -1); + Node::addChild(_backGroundBoxRenderer, BACKGROUNDBOX_RENDERER_Z, -1); + Node::addChild(_backGroundSelectedBoxRenderer, BACKGROUNDSELECTEDBOX_RENDERER_Z, -1); + Node::addChild(_frontCrossRenderer, FRONTCROSS_RENDERER_Z, -1); + Node::addChild(_backGroundBoxDisabledRenderer, BACKGROUNDBOXDISABLED_RENDERER_Z, -1); + Node::addChild(_frontCrossDisabledRenderer, FRONTCROSSDISABLED_RENDERER_Z, -1); } void CheckBox::loadTextures(const char *backGround, const char *backGroundSelected, const char *cross,const char* backGroundDisabled,const char* frontCrossDisabled,TextureResType texType) diff --git a/cocos/gui/UICheckBox.h b/cocos/gui/UICheckBox.h index 6796a3f710..c332c003a7 100644 --- a/cocos/gui/UICheckBox.h +++ b/cocos/gui/UICheckBox.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UICHECKBOX_H__ #define __UICHECKBOX_H__ diff --git a/cocos/gui/UIHelper.cpp b/cocos/gui/UIHelper.cpp index c8692d5a49..f16a230e2c 100644 --- a/cocos/gui/UIHelper.cpp +++ b/cocos/gui/UIHelper.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "CocosGUI.h" @@ -28,7 +28,7 @@ NS_CC_BEGIN namespace gui { -Widget* UIHelper::seekWidgetByTag(Widget* root, int tag) +Widget* Helper::seekWidgetByTag(Widget* root, int tag) { if (!root) { @@ -52,7 +52,7 @@ Widget* UIHelper::seekWidgetByTag(Widget* root, int tag) return nullptr; } -Widget* UIHelper::seekWidgetByName(Widget* root, const char *name) +Widget* Helper::seekWidgetByName(Widget* root, const char *name) { if (!root) { @@ -75,7 +75,7 @@ Widget* UIHelper::seekWidgetByName(Widget* root, const char *name) return nullptr; } -Widget* UIHelper::seekWidgetByRelativeName(Widget *root, const char *name) +Widget* Helper::seekWidgetByRelativeName(Widget *root, const char *name) { if (!root) { @@ -95,7 +95,7 @@ Widget* UIHelper::seekWidgetByRelativeName(Widget *root, const char *name) } /*temp action*/ -Widget* UIHelper::seekActionWidgetByActionTag(Widget* root, int tag) +Widget* Helper::seekActionWidgetByActionTag(Widget* root, int tag) { if (!root) { diff --git a/cocos/gui/UIHelper.h b/cocos/gui/UIHelper.h index 723570d844..fb0e0413a4 100644 --- a/cocos/gui/UIHelper.h +++ b/cocos/gui/UIHelper.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UIHELPER_H__ #define __UIHELPER_H__ @@ -33,7 +33,7 @@ namespace gui { * @js NA * @lua NA */ -class UIHelper +class Helper { public: /** diff --git a/cocos/gui/UIImageView.cpp b/cocos/gui/UIImageView.cpp index c228c5a513..a77dee73e0 100644 --- a/cocos/gui/UIImageView.cpp +++ b/cocos/gui/UIImageView.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UIImageView.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" @@ -33,7 +33,7 @@ namespace gui { #define STATIC_CAST_CCSPRITE static_cast(_imageRenderer) #define STATIC_CAST_SCALE9SPRITE static_cast(_imageRenderer) -#define IMAGERENDERERZ (-1) +static const int IMAGE_RENDERER_Z = (-1); ImageView::ImageView(): _scale9Enabled(false), @@ -67,7 +67,7 @@ ImageView* ImageView::create() void ImageView::initRenderer() { _imageRenderer = Sprite::create(); - Node::addChild(_imageRenderer, IMAGERENDERERZ, -1); + Node::addChild(_imageRenderer, IMAGE_RENDERER_Z, -1); } void ImageView::loadTexture(const char *fileName, TextureResType texType) @@ -193,7 +193,7 @@ void ImageView::setScale9Enabled(bool able) _imageRenderer = Sprite::create(); } loadTexture(_textureFile.c_str(),_imageTexType); - Node::addChild(_imageRenderer, IMAGERENDERERZ, -1); + Node::addChild(_imageRenderer, IMAGE_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; diff --git a/cocos/gui/UIImageView.h b/cocos/gui/UIImageView.h index ba0f56594d..df373a67a9 100644 --- a/cocos/gui/UIImageView.h +++ b/cocos/gui/UIImageView.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UIIMAGEVIEW_H__ #define __UIIMAGEVIEW_H__ diff --git a/cocos/gui/UILabelAtlas.cpp b/cocos/gui/UILabelAtlas.cpp deleted file mode 100644 index f558e31995..0000000000 --- a/cocos/gui/UILabelAtlas.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "gui/UILabelAtlas.h" - -NS_CC_BEGIN - -namespace gui { - -#define LABELATLASRENDERERZ (-1) - - -UICCLabelAtlas::UICCLabelAtlas() -{ - -} - -UICCLabelAtlas::~UICCLabelAtlas() -{ - -} - -UICCLabelAtlas* UICCLabelAtlas::create() -{ - UICCLabelAtlas *pRet = new UICCLabelAtlas(); - if(pRet) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - - return nullptr; -} - -void UICCLabelAtlas::setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) -{ - initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap); -} - -void UICCLabelAtlas::setProperty(const std::string& string, Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) -{ - initWithString(string, texture, itemWidth, itemHeight, startCharMap); -} - -void UICCLabelAtlas::draw() -{ - if (!_textureAtlas) - { - return; - } - - AtlasNode::draw(); -} - - - -LabelAtlas::LabelAtlas(): -_labelAtlasRenderer(nullptr), -_stringValue(""), -_charMapFileName(""), -_itemWidth(0), -_itemHeight(0), -_startCharMap("") -{ - -} - -LabelAtlas::~LabelAtlas() -{ - -} - -LabelAtlas* LabelAtlas::create() -{ - LabelAtlas* widget = new LabelAtlas(); - if (widget && widget->init()) - { - widget->autorelease(); - return widget; - } - CC_SAFE_DELETE(widget); - return nullptr; -} - -void LabelAtlas::initRenderer() -{ - _labelAtlasRenderer = UICCLabelAtlas::create(); - Node::addChild(_labelAtlasRenderer, LABELATLASRENDERERZ, -1); -} - -void LabelAtlas::setProperty(const std::string& stringValue, const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap) -{ - _stringValue = stringValue; - _charMapFileName = charMapFile; - _itemWidth = itemWidth; - _itemHeight = itemHeight; - _startCharMap = startCharMap; - _labelAtlasRenderer->setProperty(stringValue, charMapFile, itemWidth, itemHeight, (int)(startCharMap[0])); - updateAnchorPoint(); - labelAtlasScaleChangedWithSize(); -} - -void LabelAtlas::setStringValue(const std::string& value) -{ - _stringValue = value; - _labelAtlasRenderer->setString(value); - labelAtlasScaleChangedWithSize(); -} - -const std::string& LabelAtlas::getStringValue() const -{ - return _labelAtlasRenderer->getString(); -} - -void LabelAtlas::setAnchorPoint(const Point &pt) -{ - Widget::setAnchorPoint(pt); - _labelAtlasRenderer->setAnchorPoint(Point(pt.x, pt.y)); -} - -void LabelAtlas::onSizeChanged() -{ - Widget::onSizeChanged(); - labelAtlasScaleChangedWithSize(); -} - -const Size& LabelAtlas::getContentSize() const -{ - return _labelAtlasRenderer->getContentSize(); -} - -Node* LabelAtlas::getVirtualRenderer() -{ - return _labelAtlasRenderer; -} - -void LabelAtlas::labelAtlasScaleChangedWithSize() -{ - if (_ignoreSize) - { - _labelAtlasRenderer->setScale(1.0f); - _size = _labelAtlasRenderer->getContentSize(); - } - else - { - Size textureSize = _labelAtlasRenderer->getContentSize(); - if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) - { - _labelAtlasRenderer->setScale(1.0f); - return; - } - float scaleX = _size.width / textureSize.width; - float scaleY = _size.height / textureSize.height; - _labelAtlasRenderer->setScaleX(scaleX); - _labelAtlasRenderer->setScaleY(scaleY); - } -} - -std::string LabelAtlas::getDescription() const -{ - return "LabelAtlas"; -} - -Widget* LabelAtlas::createCloneInstance() -{ - return LabelAtlas::create(); -} - -void LabelAtlas::copySpecialProperties(Widget *widget) -{ - LabelAtlas* labelAtlas = dynamic_cast(widget); - if (labelAtlas) - { - setProperty(labelAtlas->_stringValue, labelAtlas->_charMapFileName, labelAtlas->_itemWidth, labelAtlas->_itemHeight, labelAtlas->_startCharMap); - } -} - -} -NS_CC_END \ No newline at end of file diff --git a/cocos/gui/UILabelAtlas.h b/cocos/gui/UILabelAtlas.h deleted file mode 100644 index 3c88e6d395..0000000000 --- a/cocos/gui/UILabelAtlas.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __UILABELATLAS_H__ -#define __UILABELATLAS_H__ - -#include "gui/UIWidget.h" - -NS_CC_BEGIN - -namespace gui { - -/** - * @js NA - * @lua NA - */ -class UICCLabelAtlas : public LabelAtlas -{ -public: - /** - * Default constructor - */ - UICCLabelAtlas(); - - /** - * Default destructor - */ - virtual ~UICCLabelAtlas(); - - /** - * Allocates and initializes. - */ - static UICCLabelAtlas* create(); - void setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); - void setProperty(const std::string& string, Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); - virtual void draw(void) override; -}; -/** - * @js NA - * @lua NA - */ -class LabelAtlas : public Widget -{ -public: - /** - * Default constructor - */ - LabelAtlas(); - - /** - * Default destructor - */ - virtual ~LabelAtlas(); - - /** - * Allocates and initializes. - */ - static LabelAtlas* create(); - - /** initializes the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - void setProperty(const std::string& stringValue,const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap); - - //set string value for labelatlas. - void setStringValue(const std::string& value); - - //get string value for labelatlas. - const std::string& getStringValue() const; - - //override "setAnchorPoint" method of widget. - virtual void setAnchorPoint(const Point &pt) override; - - //override "getContentSize" method of widget. - virtual const Size& getContentSize() const override; - - //override "getVirtualRenderer" method of widget. - virtual Node* getVirtualRenderer() override; - - /** - * Returns the "class name" of widget. - */ - virtual std::string getDescription() const override; - -protected: - virtual void initRenderer() override; - virtual void onSizeChanged() override; - void labelAtlasScaleChangedWithSize(); - virtual Widget* createCloneInstance() override; - virtual void copySpecialProperties(Widget* model) override; -protected: - UICCLabelAtlas* _labelAtlasRenderer; - std::string _stringValue; - std::string _charMapFileName; - int _itemWidth; - int _itemHeight; - std::string _startCharMap; -}; - -} -NS_CC_END - -#endif /* defined(__CocoGUI__LabelAtlas__) */ diff --git a/cocos/gui/UILabelBMFont.cpp b/cocos/gui/UILabelBMFont.cpp deleted file mode 100644 index 64d93c0bb2..0000000000 --- a/cocos/gui/UILabelBMFont.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "gui/UILabelBMFont.h" - -NS_CC_BEGIN - -namespace gui { - -#define LABELBMFONTRENDERERZ (-1) - -LabelBMFont::LabelBMFont(): -_labelBMFontRenderer(nullptr), -_fntFileHasInit(false), -_fntFileName(""), -_stringValue("") -{ -} - -LabelBMFont::~LabelBMFont() -{ - -} - -LabelBMFont* LabelBMFont::create() -{ - LabelBMFont* widget = new LabelBMFont(); - if (widget && widget->init()) - { - widget->autorelease(); - return widget; - } - CC_SAFE_DELETE(widget); - return nullptr; -} - -void LabelBMFont::initRenderer() -{ - _labelBMFontRenderer = cocos2d::LabelBMFont::create(); - Node::addChild(_labelBMFontRenderer, LABELBMFONTRENDERERZ, -1); -} - -void LabelBMFont::setFntFile(const char *fileName) -{ - if (!fileName || strcmp(fileName, "") == 0) - { - return; - } - _fntFileName = fileName; - _labelBMFontRenderer->initWithString("", fileName); - updateAnchorPoint(); - labelBMFontScaleChangedWithSize(); - _fntFileHasInit = true; - setText(_stringValue.c_str()); -} - -void LabelBMFont::setText(const char* value) -{ - if (!value) - { - return; - } - _stringValue = value; - if (!_fntFileHasInit) - { - return; - } - _labelBMFontRenderer->setString(value); - labelBMFontScaleChangedWithSize(); -} - -const char* LabelBMFont::getStringValue() -{ - return _stringValue.c_str(); -} - -void LabelBMFont::setAnchorPoint(const Point &pt) -{ - Widget::setAnchorPoint(pt); - _labelBMFontRenderer->setAnchorPoint(pt); -} - -void LabelBMFont::onSizeChanged() -{ - Widget::onSizeChanged(); - labelBMFontScaleChangedWithSize(); -} - -const Size& LabelBMFont::getContentSize() const -{ - return _labelBMFontRenderer->getContentSize(); -} - -Node* LabelBMFont::getVirtualRenderer() -{ - return _labelBMFontRenderer; -} - -void LabelBMFont::labelBMFontScaleChangedWithSize() -{ - if (_ignoreSize) - { - _labelBMFontRenderer->setScale(1.0f); - _size = _labelBMFontRenderer->getContentSize(); - } - else - { - Size textureSize = _labelBMFontRenderer->getContentSize(); - if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) - { - _labelBMFontRenderer->setScale(1.0f); - return; - } - float scaleX = _size.width / textureSize.width; - float scaleY = _size.height / textureSize.height; - _labelBMFontRenderer->setScaleX(scaleX); - _labelBMFontRenderer->setScaleY(scaleY); - } -} - -std::string LabelBMFont::getDescription() const -{ - return "LabelBMFont"; -} - -Widget* LabelBMFont::createCloneInstance() -{ - return LabelBMFont::create(); -} - -void LabelBMFont::copySpecialProperties(Widget *widget) -{ - LabelBMFont* labelBMFont = dynamic_cast(widget); - if (labelBMFont) - { - setFntFile(labelBMFont->_fntFileName.c_str()); - setText(labelBMFont->_stringValue.c_str()); - } -} - -} - -NS_CC_END \ No newline at end of file diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 9d511283a8..e4c9c1f66f 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -1,39 +1,48 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UILayout.h" #include "gui/UIHelper.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" +#include "kazmath/GL/matrix.h" +#include "CCGLProgram.h" +#include "CCShaderCache.h" +#include "CCDirector.h" +#include "CCDrawingPrimitives.h" +#include "CCRenderer.h" +#include "CCGroupCommand.h" +#include "CCCustomCommand.h" NS_CC_BEGIN namespace gui { -#define BACKGROUNDIMAGEZ (-1) -#define BCAKGROUNDCOLORRENDERERZ (-2) +static const int BACKGROUNDIMAGE_Z = (-1); +static const int BCAKGROUNDCOLORRENDERER_Z = (-2); static GLint g_sStencilBits = -1; +static GLint s_layer = -1; Layout::Layout(): _clippingEnabled(false), @@ -54,17 +63,47 @@ _backGroundImageTextureSize(Size::ZERO), _layoutType(LAYOUT_ABSOLUTE), _clippingType(LAYOUT_CLIPPING_STENCIL), _clippingStencil(nullptr), -_handleScissor(false), _scissorRectDirty(false), _clippingRect(Rect::ZERO), _clippingParent(nullptr), -_doLayoutDirty(true) +_doLayoutDirty(true), +_currentStencilEnabled(GL_FALSE), +_currentStencilWriteMask(~0), +_currentStencilFunc(GL_ALWAYS), +_currentStencilRef(0), +_currentStencilValueMask(~0), +_currentStencilFail(GL_KEEP), +_currentStencilPassDepthFail(GL_KEEP), +_currentStencilPassDepthPass(GL_KEEP), +_currentDepthWriteMask(GL_TRUE), +_currentAlphaTestEnabled(GL_FALSE), +_currentAlphaTestFunc(GL_ALWAYS), +_currentAlphaTestRef(1) { _widgetType = WidgetTypeContainer; } Layout::~Layout() { + CC_SAFE_RELEASE(_clippingStencil); +} + +void Layout::onEnter() +{ + Widget::onEnter(); + if (_clippingStencil) + { + _clippingStencil->onEnter(); + } +} + +void Layout::onExit() +{ + Widget::onExit(); + if (_clippingStencil) + { + _clippingStencil->onExit(); + } } Layout* Layout::create() @@ -117,6 +156,17 @@ bool Layout::isClippingEnabled() return _clippingEnabled; } +bool Layout::hitTest(const Point &pt) +{ + Point nsp = convertToNodeSpace(pt); + Rect bb = Rect(0.0f, 0.0f, _size.width, _size.height); + if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height) + { + return true; + } + return false; +} + void Layout::visit() { if (!_enabled) @@ -151,104 +201,150 @@ void Layout::sortAllChildren() void Layout::stencilClippingVisit() { - if (!_clippingStencil || !_clippingStencil->isVisible()) - { - Node::visit(); + if(!_visible) return; - } - if (g_sStencilBits < 1) + + kmGLPushMatrix(); + transform(); + //Add group command + + Renderer* renderer = Director::getInstance()->getRenderer(); + + _groupCommand.init(0,_vertexZ); + renderer->addCommand(&_groupCommand); + + renderer->pushGroup(_groupCommand.getRenderQueueID()); + + _beforeVisitCmdStencil.init(0,_vertexZ); + _beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this); + renderer->addCommand(&_beforeVisitCmdStencil); + + _clippingStencil->visit(); + + _afterDrawStencilCmd.init(0,_vertexZ); + _afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this); + renderer->addCommand(&_afterDrawStencilCmd); + + int i = 0; + + if(!_children.empty()) { - Node::visit(); - return; - } - static GLint layer = -1; - if (layer + 1 == g_sStencilBits) - { - static bool once = true; - if (once) + sortAllChildren(); + // draw children zOrder < 0 + for( ; i < _children.size(); i++ ) { - char warning[200] = {0}; - snprintf(warning, sizeof(warning), "Nesting more than %d stencils is not supported. Everything will be drawn without stencil for this node and its childs.", g_sStencilBits); - CCLOG("%s", warning); + auto node = _children.at(i); - once = false; + if ( node && node->getZOrder() < 0 ) + node->visit(); + else + break; } - Node::visit(); - return; + // self draw + this->draw(); + + for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) + (*it)->visit(); } - layer++; - GLint mask_layer = 0x1 << layer; + else + { + this->draw(); + } + + _afterVisitCmdStencil.init(0,_vertexZ); + _afterVisitCmdStencil.func = CC_CALLBACK_0(Layout::onAfterVisitStencil, this); + renderer->addCommand(&_afterVisitCmdStencil); + + renderer->popGroup(); + + kmGLPopMatrix(); +} + +void Layout::onBeforeVisitStencil() +{ + s_layer++; + GLint mask_layer = 0x1 << s_layer; GLint mask_layer_l = mask_layer - 1; - GLint mask_layer_le = mask_layer | mask_layer_l; - GLboolean currentStencilEnabled = GL_FALSE; - GLuint currentStencilWriteMask = ~0; - GLenum currentStencilFunc = GL_ALWAYS; - GLint currentStencilRef = 0; - GLuint currentStencilValueMask = ~0; - GLenum currentStencilFail = GL_KEEP; - GLenum currentStencilPassDepthFail = GL_KEEP; - GLenum currentStencilPassDepthPass = GL_KEEP; - currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); - glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)¤tStencilWriteMask); - glGetIntegerv(GL_STENCIL_FUNC, (GLint *)¤tStencilFunc); - glGetIntegerv(GL_STENCIL_REF, ¤tStencilRef); - glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)¤tStencilValueMask); - glGetIntegerv(GL_STENCIL_FAIL, (GLint *)¤tStencilFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)¤tStencilPassDepthFail); - glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)¤tStencilPassDepthPass); + _mask_layer_le = mask_layer | mask_layer_l; + _currentStencilEnabled = glIsEnabled(GL_STENCIL_TEST); + glGetIntegerv(GL_STENCIL_WRITEMASK, (GLint *)&_currentStencilWriteMask); + glGetIntegerv(GL_STENCIL_FUNC, (GLint *)&_currentStencilFunc); + glGetIntegerv(GL_STENCIL_REF, &_currentStencilRef); + glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint *)&_currentStencilValueMask); + glGetIntegerv(GL_STENCIL_FAIL, (GLint *)&_currentStencilFail); + glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, (GLint *)&_currentStencilPassDepthFail); + glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, (GLint *)&_currentStencilPassDepthPass); + glEnable(GL_STENCIL_TEST); CHECK_GL_ERROR_DEBUG(); glStencilMask(mask_layer); - GLboolean currentDepthWriteMask = GL_TRUE; - glGetBooleanv(GL_DEPTH_WRITEMASK, ¤tDepthWriteMask); + glGetBooleanv(GL_DEPTH_WRITEMASK, &_currentDepthWriteMask); glDepthMask(GL_FALSE); glStencilFunc(GL_NEVER, mask_layer, mask_layer); glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPushMatrix(); kmGLLoadIdentity(); + kmGLMatrixMode(KM_GL_PROJECTION); kmGLPushMatrix(); kmGLLoadIdentity(); + DrawPrimitives::drawSolidRect(Point(-1,-1), Point(1,1), Color4F(1, 1, 1, 1)); + kmGLMatrixMode(KM_GL_PROJECTION); kmGLPopMatrix(); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLPopMatrix(); glStencilFunc(GL_NEVER, mask_layer, mask_layer); glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); +} - kmGLPushMatrix(); - transform(); - _clippingStencil->visit(); - kmGLPopMatrix(); - glDepthMask(currentDepthWriteMask); - glStencilFunc(GL_EQUAL, mask_layer_le, mask_layer_le); +void Layout::onAfterDrawStencil() +{ + glDepthMask(_currentDepthWriteMask); + glStencilFunc(GL_EQUAL, _mask_layer_le, _mask_layer_le); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - Node::visit(); - glStencilFunc(currentStencilFunc, currentStencilRef, currentStencilValueMask); - glStencilOp(currentStencilFail, currentStencilPassDepthFail, currentStencilPassDepthPass); - glStencilMask(currentStencilWriteMask); - if (!currentStencilEnabled) +} + + +void Layout::onAfterVisitStencil() +{ + glStencilFunc(_currentStencilFunc, _currentStencilRef, _currentStencilValueMask); + glStencilOp(_currentStencilFail, _currentStencilPassDepthFail, _currentStencilPassDepthPass); + glStencilMask(_currentStencilWriteMask); + if (!_currentStencilEnabled) { glDisable(GL_STENCIL_TEST); } - layer--; + s_layer--; +} + +void Layout::onBeforeVisitScissor() +{ + Rect clippingRect = getClippingRect(); + glEnable(GL_SCISSOR_TEST); + EGLView::getInstance()->setScissorInPoints(clippingRect.origin.x, clippingRect.origin.y, clippingRect.size.width, clippingRect.size.height); +} + +void Layout::onAfterVisitScissor() +{ + glDisable(GL_SCISSOR_TEST); } void Layout::scissorClippingVisit() { - Rect clippingRect = getClippingRect(); - if (_handleScissor) - { - glEnable(GL_SCISSOR_TEST); - } - EGLView::getInstance()->setScissorInPoints(clippingRect.origin.x, clippingRect.origin.y, clippingRect.size.width, clippingRect.size.height); + Renderer* renderer = Director::getInstance()->getRenderer(); + + _beforeVisitCmdScissor.init(0, _vertexZ); + _beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this); + renderer->addCommand(&_beforeVisitCmdScissor); + Node::visit(); - if (_handleScissor) - { - glDisable(GL_SCISSOR_TEST); - } + + _afterVisitCmdScissor.init(0, _vertexZ); + _afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this); + renderer->addCommand(&_afterVisitCmdScissor); } void Layout::setClippingEnabled(bool able) @@ -263,15 +359,30 @@ void Layout::setClippingEnabled(bool able) case LAYOUT_CLIPPING_STENCIL: if (able) { - glGetIntegerv(GL_STENCIL_BITS, &g_sStencilBits); + static bool once = true; + if (once) + { + glGetIntegerv(GL_STENCIL_BITS, &g_sStencilBits); + if (g_sStencilBits <= 0) + { + CCLOG("Stencil buffer is not enabled."); + } + once = false; + } _clippingStencil = DrawNode::create(); - _clippingStencil->onEnter(); + if (_running) + { + _clippingStencil->onEnter(); + } _clippingStencil->retain(); setStencilClippingSize(_size); } else { - _clippingStencil->onExit(); + if (_running) + { + _clippingStencil->onExit(); + } _clippingStencil->release(); _clippingStencil = nullptr; } @@ -310,9 +421,8 @@ void Layout::setStencilClippingSize(const Size &size) const Rect& Layout::getClippingRect() { - _handleScissor = true; Point worldPos = convertToWorldSpace(Point::ZERO); - AffineTransform t = nodeToWorldTransform(); + AffineTransform t = getNodeToWorldAffineTransform(); float scissorWidth = _size.width*t.a; float scissorHeight = _size.height*t.d; Rect parentClippingRect; @@ -329,11 +439,6 @@ const Rect& Layout::getClippingRect() { _clippingParent = parent; firstClippingParentFounded = true; - } - - if (parent->_clippingType == LAYOUT_CLIPPING_SCISSOR) - { - _handleScissor = false; break; } } @@ -396,6 +501,7 @@ const Rect& Layout::getClippingRect() void Layout::onSizeChanged() { Widget::onSizeChanged(); + setContentSize(_size); setStencilClippingSize(_size); _doLayoutDirty = true; if (_backGroundImage) @@ -428,12 +534,12 @@ void Layout::setBackGroundImageScale9Enabled(bool able) if (_backGroundScale9Enabled) { _backGroundImage = extension::Scale9Sprite::create(); - Node::addChild(_backGroundImage, BACKGROUNDIMAGEZ, -1); + Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } else { _backGroundImage = Sprite::create(); - Node::addChild(_backGroundImage, BACKGROUNDIMAGEZ, -1); + Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } setBackGroundImage(_backGroundImageFileName.c_str(),_bgImageTexType); setBackGroundImageCapInsets(_backGroundImageCapInsets); @@ -546,14 +652,14 @@ void Layout::addBackGroundImage() { _backGroundImage = extension::Scale9Sprite::create(); _backGroundImage->setZOrder(-1); - Node::addChild(_backGroundImage, BACKGROUNDIMAGEZ, -1); + Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); static_cast(_backGroundImage)->setPreferredSize(_size); } else { _backGroundImage = Sprite::create(); _backGroundImage->setZOrder(-1); - Node::addChild(_backGroundImage, BACKGROUNDIMAGEZ, -1); + Node::addChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); } _backGroundImage->setPosition(Point(_size.width/2.0f, _size.height/2.0f)); } @@ -617,7 +723,7 @@ void Layout::setBackGroundColorType(LayoutBackGroundColorType type) _colorRender->setContentSize(_size); _colorRender->setOpacity(_cOpacity); _colorRender->setColor(_cColor); - Node::addChild(_colorRender, BACKGROUNDIMAGEZ, -1); + Node::addChild(_colorRender, BCAKGROUNDCOLORRENDERER_Z, -1); break; case LAYOUT_COLOR_GRADIENT: _gradientRender = LayerGradient::create(); @@ -626,7 +732,7 @@ void Layout::setBackGroundColorType(LayoutBackGroundColorType type) _gradientRender->setStartColor(_gStartColor); _gradientRender->setEndColor(_gEndColor); _gradientRender->setVector(_alongVector); - Node::addChild(_gradientRender, BACKGROUNDIMAGEZ, -1); + Node::addChild(_gradientRender, BCAKGROUNDCOLORRENDERER_Z, -1); break; default: break; @@ -833,7 +939,7 @@ void Layout::doLayout() float finalPosY = 0.0f; if (relativeName && strcmp(relativeName, "")) { - relativeWidget = UIHelper::seekWidgetByRelativeName(this, relativeName); + relativeWidget = Helper::seekWidgetByRelativeName(this, relativeName); if (relativeWidget) { relativeWidgetLP = dynamic_cast(relativeWidget->getLayoutParameter(LAYOUT_PARAMETER_RELATIVE)); diff --git a/cocos/gui/UILayout.h b/cocos/gui/UILayout.h index 0feff5447e..fffb6aaad1 100644 --- a/cocos/gui/UILayout.h +++ b/cocos/gui/UILayout.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __LAYOUT_H__ #define __LAYOUT_H__ @@ -214,6 +214,11 @@ public: virtual void sortAllChildren() override; void requestDoLayout(); + + virtual void onEnter() override; + virtual void onExit() override; + + virtual bool hitTest(const Point &pt); protected: //override "init" method of widget. virtual bool init() override; @@ -235,6 +240,14 @@ protected: void setStencilClippingSize(const Size& size); const Rect& getClippingRect(); virtual void doLayout(); + + //clipping + void onBeforeVisitStencil(); + void onAfterDrawStencil(); + void onAfterVisitStencil(); + + void onBeforeVisitScissor(); + void onAfterVisitScissor(); protected: bool _clippingEnabled; @@ -256,11 +269,35 @@ protected: LayoutType _layoutType; LayoutClippingType _clippingType; DrawNode* _clippingStencil; - bool _handleScissor; bool _scissorRectDirty; Rect _clippingRect; Layout* _clippingParent; bool _doLayoutDirty; + + //clipping + + GLboolean _currentStencilEnabled; + GLuint _currentStencilWriteMask; + GLenum _currentStencilFunc; + GLint _currentStencilRef; + GLuint _currentStencilValueMask; + GLenum _currentStencilFail; + GLenum _currentStencilPassDepthFail; + GLenum _currentStencilPassDepthPass; + GLboolean _currentDepthWriteMask; + + GLboolean _currentAlphaTestEnabled; + GLenum _currentAlphaTestFunc; + GLclampf _currentAlphaTestRef; + + GLint _mask_layer_le; + + GroupCommand _groupCommand; + CustomCommand _beforeVisitCmdStencil; + CustomCommand _afterDrawStencilCmd; + CustomCommand _afterVisitCmdStencil; + CustomCommand _beforeVisitCmdScissor; + CustomCommand _afterVisitCmdScissor; }; } diff --git a/cocos/gui/UILayoutDefine.cpp b/cocos/gui/UILayoutDefine.cpp index e1de93008b..88de5a8fe8 100644 --- a/cocos/gui/UILayoutDefine.cpp +++ b/cocos/gui/UILayoutDefine.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "UILayoutDefine.h" NS_CC_BEGIN diff --git a/cocos/gui/UILayoutDefine.h b/cocos/gui/UILayoutDefine.h index 595071623d..1fee726968 100644 --- a/cocos/gui/UILayoutDefine.h +++ b/cocos/gui/UILayoutDefine.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UILAYOUTDEFINE_H__ #define __UILAYOUTDEFINE_H__ diff --git a/cocos/gui/UILayoutParameter.cpp b/cocos/gui/UILayoutParameter.cpp index 7941763909..d0a98f4d0d 100644 --- a/cocos/gui/UILayoutParameter.cpp +++ b/cocos/gui/UILayoutParameter.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UILayoutParameter.h" #include "gui/UILayout.h" diff --git a/cocos/gui/UILayoutParameter.h b/cocos/gui/UILayoutParameter.h index fa16172573..9065a16176 100644 --- a/cocos/gui/UILayoutParameter.h +++ b/cocos/gui/UILayoutParameter.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __LAYOUTPARMETER_H__ #define __LAYOUTPARMETER_H__ diff --git a/cocos/gui/UIListView.cpp b/cocos/gui/UIListView.cpp index cb44091cec..ba6a567aef 100644 --- a/cocos/gui/UIListView.cpp +++ b/cocos/gui/UIListView.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UIListView.h" #include "gui/UIHelper.h" diff --git a/cocos/gui/UIListView.h b/cocos/gui/UIListView.h index 059240f64b..2a6b2df848 100644 --- a/cocos/gui/UIListView.h +++ b/cocos/gui/UIListView.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UILISTVIEW_H__ diff --git a/cocos/gui/UILoadingBar.cpp b/cocos/gui/UILoadingBar.cpp index aec388a8c0..b561c3fd7c 100644 --- a/cocos/gui/UILoadingBar.cpp +++ b/cocos/gui/UILoadingBar.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UILoadingBar.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" @@ -29,7 +29,7 @@ NS_CC_BEGIN namespace gui { -#define BARRENDERERZ (-1) +static const int BAR_RENDERER_Z = (-1); LoadingBar::LoadingBar(): _barType(LoadingBarTypeLeft), @@ -65,7 +65,7 @@ LoadingBar* LoadingBar::create() void LoadingBar::initRenderer() { _barRenderer = Sprite::create(); - Node::addChild(_barRenderer, BARRENDERERZ, -1); + Node::addChild(_barRenderer, BAR_RENDERER_Z, -1); _barRenderer->setAnchorPoint(Point(0.0,0.5)); } @@ -182,7 +182,7 @@ void LoadingBar::setScale9Enabled(bool enabled) _barRenderer = Sprite::create(); } loadTexture(_textureFile.c_str(),_renderBarTexType); - Node::addChild(_barRenderer, BARRENDERERZ, -1); + Node::addChild(_barRenderer, BAR_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; diff --git a/cocos/gui/UILoadingBar.h b/cocos/gui/UILoadingBar.h index 85a3854d04..b0305951d5 100644 --- a/cocos/gui/UILoadingBar.h +++ b/cocos/gui/UILoadingBar.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UILOADINGBAR_H__ #define __UILOADINGBAR_H__ diff --git a/cocos/gui/UIPageView.cpp b/cocos/gui/UIPageView.cpp index bc83c7a7aa..cc265a7f89 100644 --- a/cocos/gui/UIPageView.cpp +++ b/cocos/gui/UIPageView.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UIPageView.h" @@ -66,13 +66,18 @@ PageView* PageView::create() CC_SAFE_DELETE(widget); return nullptr; } + +void PageView::onEnter() +{ + Layout::onEnter(); + scheduleUpdate(); +} bool PageView::init() { if (Layout::init()) { setClippingEnabled(true); - setUpdateEnabled(true); setTouchEnabled(true); return true; } @@ -96,7 +101,7 @@ void PageView::addWidgetToPage(Widget *widget, ssize_t pageIdx, bool forceCreate { if (pageIdx > pageCount) { - CCLOG("pageIdx is %zd, it will be added as page id [%zd]",pageIdx,pageCount); + CCLOG("pageIdx is %d, it will be added as page id [%d]",static_cast(pageIdx),static_cast(pageCount)); } Layout* newPage = createPage(); newPage->addChild(widget); @@ -392,11 +397,6 @@ void PageView::onTouchMoved(Touch *touch, Event *unusedEvent) widgetParent->checkChildInfo(1,this,_touchMovePos); } moveEvent(); - if (!hitTest(_touchMovePos)) - { - setFocused(false); - onTouchEnded(touch, unusedEvent); - } } void PageView::onTouchEnded(Touch *touch, Event *unusedEvent) @@ -558,6 +558,7 @@ void PageView::interceptTouchEvent(int handleState, Widget *sender, const Point break; case 3: + handleReleaseLogic(touchPoint); break; } } diff --git a/cocos/gui/UIPageView.h b/cocos/gui/UIPageView.h index 40eb1fdc62..4b4a890199 100644 --- a/cocos/gui/UIPageView.h +++ b/cocos/gui/UIPageView.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UIPAGEVIEW_H__ #define __UIPAGEVIEW_H__ @@ -159,6 +159,8 @@ public: */ virtual std::string getDescription() const override; + virtual void onEnter() override; + protected: virtual void addChild(Node * child) override; virtual void addChild(Node * child, int zOrder) override; diff --git a/cocos/gui/UIScrollInterface.h b/cocos/gui/UIScrollInterface.h index 96b91e7267..14923fed9f 100644 --- a/cocos/gui/UIScrollInterface.h +++ b/cocos/gui/UIScrollInterface.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UISCROLLDELEGATE_H__ #define __UISCROLLDELEGATE_H__ diff --git a/cocos/gui/UIScrollView.cpp b/cocos/gui/UIScrollView.cpp index 436cb52ea7..8bb23aae8d 100644 --- a/cocos/gui/UIScrollView.cpp +++ b/cocos/gui/UIScrollView.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UIScrollView.h" @@ -28,7 +28,7 @@ NS_CC_BEGIN namespace gui { -#define AUTOSCROLLMAXSPEED 1000.0f +static const float AUTOSCROLLMAXSPEED = 1000.0f; const Point SCROLLDIR_UP = Point(0.0f, 1.0f); const Point SCROLLDIR_DOWN = Point(0.0f, -1.0f); @@ -93,12 +93,17 @@ ScrollView* ScrollView::create() CC_SAFE_DELETE(widget); return nullptr; } + +void ScrollView::onEnter() +{ + Layout::onEnter(); + scheduleUpdate(); +} bool ScrollView::init() { if (Layout::init()) { - setUpdateEnabled(true); setTouchEnabled(true); setClippingEnabled(true); _innerContainer->setTouchEnabled(false); @@ -1452,11 +1457,6 @@ void ScrollView::onTouchCancelled(Touch *touch, Event *unusedEvent) handleReleaseLogic(touch->getLocation()); } -void ScrollView::onTouchLongClicked(const Point &touchPoint) -{ - -} - void ScrollView::update(float dt) { if (_autoScroll) diff --git a/cocos/gui/UIScrollView.h b/cocos/gui/UIScrollView.h index 6075a02adf..ae49fa02ea 100644 --- a/cocos/gui/UIScrollView.h +++ b/cocos/gui/UIScrollView.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UISCROLLVIEW_H__ #define __UISCROLLVIEW_H__ @@ -279,9 +279,6 @@ public: virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override; virtual void onTouchCancelled(Touch *touch, Event *unusedEvent) override; - //override "onTouchLongClicked" method of widget. - virtual void onTouchLongClicked(const Point &touchPoint) override; - virtual void update(float dt) override; void setBounceEnabled(bool enabled); @@ -314,6 +311,8 @@ public: * Returns the "class name" of widget. */ virtual std::string getDescription() const override; + + virtual void onEnter() override; protected: virtual bool init() override; virtual void initRenderer() override; diff --git a/cocos/gui/UISlider.cpp b/cocos/gui/UISlider.cpp index 30fc583524..d138def5a3 100644 --- a/cocos/gui/UISlider.cpp +++ b/cocos/gui/UISlider.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UISlider.h" #include "extensions/GUI/CCControlExtension/CCScale9Sprite.h" @@ -29,9 +29,9 @@ NS_CC_BEGIN namespace gui { -#define BASEBARRENDERERZ (-2) -#define PROGRESSBARRENDERERZ (-2) -#define SLIDBALLRENDERERZ (-1) +static const int BASEBAR_RENDERER_Z = (-2); +static const int PROGRESSBAR_RENDERER_Z = (-2); +static const int SLIDBALL_RENDERER_Z = (-1); Slider::Slider(): _barRenderer(nullptr), @@ -85,8 +85,8 @@ void Slider::initRenderer() _barRenderer = Sprite::create(); _progressBarRenderer = Sprite::create(); _progressBarRenderer->setAnchorPoint(Point(0.0f, 0.5f)); - Node::addChild(_barRenderer, BASEBARRENDERERZ, -1); - Node::addChild(_progressBarRenderer, PROGRESSBARRENDERERZ, -1); + Node::addChild(_barRenderer, BASEBAR_RENDERER_Z, -1); + Node::addChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1); _slidBallNormalRenderer = Sprite::create(); _slidBallPressedRenderer = Sprite::create(); _slidBallPressedRenderer->setVisible(false); @@ -96,7 +96,7 @@ void Slider::initRenderer() _slidBallRenderer->addChild(_slidBallNormalRenderer); _slidBallRenderer->addChild(_slidBallPressedRenderer); _slidBallRenderer->addChild(_slidBallDisabledRenderer); - Node::addChild(_slidBallRenderer, SLIDBALLRENDERERZ, -1); + Node::addChild(_slidBallRenderer, SLIDBALL_RENDERER_Z, -1); } void Slider::loadBarTexture(const char* fileName, TextureResType texType) @@ -201,8 +201,8 @@ void Slider::setScale9Enabled(bool able) } loadBarTexture(_textureFile.c_str(), _barTexType); loadProgressBarTexture(_progressBarTextureFile.c_str(), _progressBarTexType); - Node::addChild(_barRenderer, BASEBARRENDERERZ, -1); - Node::addChild(_progressBarRenderer, PROGRESSBARRENDERERZ, -1); + Node::addChild(_barRenderer, BASEBAR_RENDERER_Z, -1); + Node::addChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1); if (_scale9Enabled) { bool ignoreBefore = _ignoreSize; diff --git a/cocos/gui/UISlider.h b/cocos/gui/UISlider.h index f79b3e9efe..bc952ede15 100644 --- a/cocos/gui/UISlider.h +++ b/cocos/gui/UISlider.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UISLIDER_H__ #define __UISLIDER_H__ diff --git a/cocos/gui/UILabel.cpp b/cocos/gui/UIText.cpp similarity index 51% rename from cocos/gui/UILabel.cpp rename to cocos/gui/UIText.cpp index 7cb64733c0..1899d7439a 100644 --- a/cocos/gui/UILabel.cpp +++ b/cocos/gui/UIText.cpp @@ -1,36 +1,36 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. -#include "gui/UILabel.h" +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 "gui/UIText.h" NS_CC_BEGIN namespace gui { -#define LABELRENDERERZ (-1) +static const int LABEL_RENDERER_Z = (-1); -Label::Label(): +Text::Text(): _touchScaleChangeEnabled(false), _normalScaleValueX(1.0f), _normalScaleValueY(1.0f), @@ -41,14 +41,14 @@ _labelRenderer(nullptr) { } -Label::~Label() +Text::~Text() { } -Label* Label::create() +Text* Text::create() { - Label* widget = new Label(); + Text* widget = new Text(); if (widget && widget->init()) { widget->autorelease(); @@ -58,7 +58,7 @@ Label* Label::create() return nullptr; } -bool Label::init() +bool Text::init() { if (Widget::init()) { @@ -67,13 +67,13 @@ bool Label::init() return false; } -void Label::initRenderer() +void Text::initRenderer() { _labelRenderer = LabelTTF::create(); - Node::addChild(_labelRenderer, LABELRENDERERZ, -1); + Node::addChild(_labelRenderer, LABEL_RENDERER_Z, -1); } -void Label::setText(const std::string& text) +void Text::setText(const std::string& text) { if (text.size()==0) return; @@ -82,79 +82,77 @@ void Label::setText(const std::string& text) labelScaleChangedWithSize(); } -const std::string& Label::getStringValue() +const std::string& Text::getStringValue() { return _labelRenderer->getString(); } -size_t Label::getStringLength() +ssize_t Text::getStringLength() { return _labelRenderer->getString().size(); } -void Label::setFontSize(int size) +void Text::setFontSize(int size) { _fontSize = size; _labelRenderer->setFontSize(size); labelScaleChangedWithSize(); } -void Label::setFontName(const std::string& name) +void Text::setFontName(const std::string& name) { _fontName = name; _labelRenderer->setFontName(name); labelScaleChangedWithSize(); } -void Label::setTextAreaSize(const Size &size) +void Text::setTextAreaSize(const Size &size) { _labelRenderer->setDimensions(size); labelScaleChangedWithSize(); } -void Label::setTextHorizontalAlignment(TextHAlignment alignment) +void Text::setTextHorizontalAlignment(TextHAlignment alignment) { _labelRenderer->setHorizontalAlignment(alignment); labelScaleChangedWithSize(); } -void Label::setTextVerticalAlignment(TextVAlignment alignment) +void Text::setTextVerticalAlignment(TextVAlignment alignment) { _labelRenderer->setVerticalAlignment(alignment); labelScaleChangedWithSize(); } -void Label::setTouchScaleChangeEnabled(bool enable) +void Text::setTouchScaleChangeEnabled(bool enable) { _touchScaleChangeEnabled = enable; _normalScaleValueX = getScaleX(); _normalScaleValueY = getScaleY(); } -void Label::setScale(float fScale) +void Text::setScale(float fScale) { Widget::setScale(fScale); _normalScaleValueX = _normalScaleValueY = fScale; } -void Label::setScaleX(float fScaleX) +void Text::setScaleX(float fScaleX) { Widget::setScaleX(fScaleX); - _normalScaleValueX = fScaleX; } -void Label::setScaleY(float fScaleY) +void Text::setScaleY(float fScaleY) { Widget::setScaleY(fScaleY); - _normalScaleValueY = fScaleY; } -bool Label::isTouchScaleChangeEnabled() +bool Text::isTouchScaleChangeEnabled() { return _touchScaleChangeEnabled; } -void Label::onPressStateChangedToNormal() +void Text::onPressStateChangedToNormal() { if (!_touchScaleChangeEnabled) { @@ -163,69 +161,71 @@ void Label::onPressStateChangedToNormal() clickScale(_normalScaleValueX, _normalScaleValueY); } -void Label::onPressStateChangedToPressed() +void Text::onPressStateChangedToPressed() { if (!_touchScaleChangeEnabled) { return; } + _normalScaleValueX = getScaleX(); + _normalScaleValueY = getScaleY(); clickScale(_normalScaleValueX + _onSelectedScaleOffset, _normalScaleValueY + _onSelectedScaleOffset); } -void Label::onPressStateChangedToDisabled() +void Text::onPressStateChangedToDisabled() { } -void Label::clickScale(float scaleX, float scaleY) +void Text::clickScale(float scaleX, float scaleY) { setScaleX(scaleX); setScaleY(scaleY); } -void Label::setFlipX(bool flipX) +void Text::setFlipX(bool flipX) { _labelRenderer->setFlippedX(flipX); } -void Label::setFlipY(bool flipY) +void Text::setFlipY(bool flipY) { _labelRenderer->setFlippedY(flipY); } -bool Label::isFlipX() +bool Text::isFlipX() { return _labelRenderer->isFlippedX(); } -bool Label::isFlipY() +bool Text::isFlipY() { return _labelRenderer->isFlippedY(); } -void Label::setAnchorPoint(const Point &pt) +void Text::setAnchorPoint(const Point &pt) { Widget::setAnchorPoint(pt); _labelRenderer->setAnchorPoint(pt); } -void Label::onSizeChanged() +void Text::onSizeChanged() { Widget::onSizeChanged(); labelScaleChangedWithSize(); } -const Size& Label::getContentSize() const +const Size& Text::getContentSize() const { return _labelRenderer->getContentSize(); } -Node* Label::getVirtualRenderer() +Node* Text::getVirtualRenderer() { return _labelRenderer; } -void Label::labelScaleChangedWithSize() +void Text::labelScaleChangedWithSize() { if (_ignoreSize) { @@ -248,25 +248,28 @@ void Label::labelScaleChangedWithSize() } -std::string Label::getDescription() const +std::string Text::getDescription() const { return "Label"; } -Widget* Label::createCloneInstance() +Widget* Text::createCloneInstance() { - return Label::create(); + return Text::create(); } -void Label::copySpecialProperties(Widget *widget) +void Text::copySpecialProperties(Widget *widget) { - Label* label = dynamic_cast(widget); + Text* label = dynamic_cast(widget); if (label) { setFontName(label->_fontName.c_str()); setFontSize(label->_labelRenderer->getFontSize()); setText(label->getStringValue()); setTouchScaleChangeEnabled(label->_touchScaleChangeEnabled); + setTextHorizontalAlignment(label->_labelRenderer->getHorizontalAlignment()); + setTextVerticalAlignment(label->_labelRenderer->getVerticalAlignment()); + setTextAreaSize(label->_labelRenderer->getDimensions()); } } diff --git a/cocos/gui/UILabel.h b/cocos/gui/UIText.h similarity index 75% rename from cocos/gui/UILabel.h rename to cocos/gui/UIText.h index 26773234dc..e41b01d321 100644 --- a/cocos/gui/UILabel.h +++ b/cocos/gui/UIText.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UILABEL_H__ #define __UILABEL_H__ @@ -35,23 +35,23 @@ namespace gui { * @js NA * @lua NA */ -class Label : public Widget +class Text : public Widget { public: /** * Default constructor */ - Label(); + Text(); /** * Default destructor */ - virtual ~Label(); + virtual ~Text(); /** * Allocates and initializes. */ - static Label* create(); + static Text* create(); /** * Changes the string value of label. @@ -72,7 +72,7 @@ public: * * @return string length. */ - size_t getStringLength(); + ssize_t getStringLength(); /** * Sets the font size of label. diff --git a/cocos/gui/UITextAtlas.cpp b/cocos/gui/UITextAtlas.cpp new file mode 100644 index 0000000000..7d1eed08c2 --- /dev/null +++ b/cocos/gui/UITextAtlas.cpp @@ -0,0 +1,154 @@ +/**************************************************************************** +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#include "gui/UITextAtlas.h" + +NS_CC_BEGIN + +namespace gui { + +static const int LABELATLAS_RENDERER_Z = (-1); + +TextAtlas::TextAtlas(): +_labelAtlasRenderer(nullptr), +_stringValue(""), +_charMapFileName(""), +_itemWidth(0), +_itemHeight(0), +_startCharMap("") +{ +} + +TextAtlas::~TextAtlas() +{ + +} + +TextAtlas* TextAtlas::create() +{ + TextAtlas* widget = new TextAtlas(); + if (widget && widget->init()) + { + widget->autorelease(); + return widget; + } + CC_SAFE_DELETE(widget); + return nullptr; +} + +void TextAtlas::initRenderer() +{ + _labelAtlasRenderer = LabelAtlas::create(); + Node::addChild(_labelAtlasRenderer, LABELATLAS_RENDERER_Z, -1); +} + +void TextAtlas::setProperty(const std::string& stringValue, const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap) +{ + _stringValue = stringValue; + _charMapFileName = charMapFile; + _itemWidth = itemWidth; + _itemHeight = itemHeight; + _startCharMap = startCharMap; + _labelAtlasRenderer->initWithString(stringValue, charMapFile, itemWidth, itemHeight, (int)(startCharMap[0])); + updateAnchorPoint(); + labelAtlasScaleChangedWithSize(); +} + +void TextAtlas::setStringValue(const std::string& value) +{ + _stringValue = value; + _labelAtlasRenderer->setString(value); + labelAtlasScaleChangedWithSize(); +} + +const std::string& TextAtlas::getStringValue() const +{ + return _labelAtlasRenderer->getString(); +} + +void TextAtlas::setAnchorPoint(const Point &pt) +{ + Widget::setAnchorPoint(pt); + _labelAtlasRenderer->setAnchorPoint(Point(pt.x, pt.y)); +} + +void TextAtlas::onSizeChanged() +{ + Widget::onSizeChanged(); + labelAtlasScaleChangedWithSize(); +} + +const Size& TextAtlas::getContentSize() const +{ + return _labelAtlasRenderer->getContentSize(); +} + +Node* TextAtlas::getVirtualRenderer() +{ + return _labelAtlasRenderer; +} + +void TextAtlas::labelAtlasScaleChangedWithSize() +{ + if (_ignoreSize) + { + _labelAtlasRenderer->setScale(1.0f); + _size = _labelAtlasRenderer->getContentSize(); + } + else + { + Size textureSize = _labelAtlasRenderer->getContentSize(); + if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) + { + _labelAtlasRenderer->setScale(1.0f); + return; + } + float scaleX = _size.width / textureSize.width; + float scaleY = _size.height / textureSize.height; + _labelAtlasRenderer->setScaleX(scaleX); + _labelAtlasRenderer->setScaleY(scaleY); + } +} + +std::string TextAtlas::getDescription() const +{ + return "TextAtlas"; +} + +Widget* TextAtlas::createCloneInstance() +{ + return TextAtlas::create(); +} + +void TextAtlas::copySpecialProperties(Widget *widget) +{ + TextAtlas* labelAtlas = dynamic_cast(widget); + if (labelAtlas) + { + setProperty(labelAtlas->_stringValue, labelAtlas->_charMapFileName, labelAtlas->_itemWidth, labelAtlas->_itemHeight, labelAtlas->_startCharMap); + } +} + +} +NS_CC_END \ No newline at end of file diff --git a/cocos/gui/UITextAtlas.h b/cocos/gui/UITextAtlas.h new file mode 100644 index 0000000000..99933fcb2e --- /dev/null +++ b/cocos/gui/UITextAtlas.h @@ -0,0 +1,97 @@ +/**************************************************************************** +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#ifndef __UILABELATLAS_H__ +#define __UILABELATLAS_H__ + +#include "gui/UIWidget.h" + +NS_CC_BEGIN + +namespace gui { + +/** + * @js NA + * @lua NA + */ +class TextAtlas : public Widget +{ +public: + /** + * Default constructor + */ + TextAtlas(); + + /** + * Default destructor + */ + virtual ~TextAtlas(); + + /** + * Allocates and initializes. + */ + static TextAtlas* create(); + + /** initializes the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ + void setProperty(const std::string& stringValue,const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap); + + //set string value for labelatlas. + void setStringValue(const std::string& value); + + //get string value for labelatlas. + const std::string& getStringValue() const; + + //override "setAnchorPoint" method of widget. + virtual void setAnchorPoint(const Point &pt) override; + + //override "getContentSize" method of widget. + virtual const Size& getContentSize() const override; + + //override "getVirtualRenderer" method of widget. + virtual Node* getVirtualRenderer() override; + + /** + * Returns the "class name" of widget. + */ + virtual std::string getDescription() const override; + +protected: + virtual void initRenderer() override; + virtual void onSizeChanged() override; + void labelAtlasScaleChangedWithSize(); + virtual Widget* createCloneInstance() override; + virtual void copySpecialProperties(Widget* model) override; +protected: + LabelAtlas* _labelAtlasRenderer; + std::string _stringValue; + std::string _charMapFileName; + int _itemWidth; + int _itemHeight; + std::string _startCharMap; +}; + +} +NS_CC_END + +#endif /* defined(__CocoGUI__LabelAtlas__) */ diff --git a/cocos/gui/UITextBMFont.cpp b/cocos/gui/UITextBMFont.cpp new file mode 100644 index 0000000000..a72bfc9458 --- /dev/null +++ b/cocos/gui/UITextBMFont.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ + +#include "gui/UITextBMFont.h" + +NS_CC_BEGIN + +namespace gui { + +static const int LABELBMFONT_RENDERER_Z = (-1); + +TextBMFont::TextBMFont(): +_labelBMFontRenderer(nullptr), +_fntFileHasInit(false), +_fntFileName(""), +_stringValue("") +{ +} + +TextBMFont::~TextBMFont() +{ + +} + +TextBMFont* TextBMFont::create() +{ + TextBMFont* widget = new TextBMFont(); + if (widget && widget->init()) + { + widget->autorelease(); + return widget; + } + CC_SAFE_DELETE(widget); + return nullptr; +} + +void TextBMFont::initRenderer() +{ + _labelBMFontRenderer = cocos2d::LabelBMFont::create(); + Node::addChild(_labelBMFontRenderer, LABELBMFONT_RENDERER_Z, -1); +} + +void TextBMFont::setFntFile(const char *fileName) +{ + if (!fileName || strcmp(fileName, "") == 0) + { + return; + } + _fntFileName = fileName; + _labelBMFontRenderer->initWithString("", fileName); + updateAnchorPoint(); + labelBMFontScaleChangedWithSize(); + _fntFileHasInit = true; + setText(_stringValue.c_str()); +} + +void TextBMFont::setText(const char* value) +{ + if (!value) + { + return; + } + _stringValue = value; + if (!_fntFileHasInit) + { + return; + } + _labelBMFontRenderer->setString(value); + labelBMFontScaleChangedWithSize(); +} + +const char* TextBMFont::getStringValue() +{ + return _stringValue.c_str(); +} + +void TextBMFont::setAnchorPoint(const Point &pt) +{ + Widget::setAnchorPoint(pt); + _labelBMFontRenderer->setAnchorPoint(pt); +} + +void TextBMFont::onSizeChanged() +{ + Widget::onSizeChanged(); + labelBMFontScaleChangedWithSize(); +} + +const Size& TextBMFont::getContentSize() const +{ + return _labelBMFontRenderer->getContentSize(); +} + +Node* TextBMFont::getVirtualRenderer() +{ + return _labelBMFontRenderer; +} + +void TextBMFont::labelBMFontScaleChangedWithSize() +{ + if (_ignoreSize) + { + _labelBMFontRenderer->setScale(1.0f); + _size = _labelBMFontRenderer->getContentSize(); + } + else + { + Size textureSize = _labelBMFontRenderer->getContentSize(); + if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) + { + _labelBMFontRenderer->setScale(1.0f); + return; + } + float scaleX = _size.width / textureSize.width; + float scaleY = _size.height / textureSize.height; + _labelBMFontRenderer->setScaleX(scaleX); + _labelBMFontRenderer->setScaleY(scaleY); + } +} + +std::string TextBMFont::getDescription() const +{ + return "TextBMFont"; +} + +Widget* TextBMFont::createCloneInstance() +{ + return TextBMFont::create(); +} + +void TextBMFont::copySpecialProperties(Widget *widget) +{ + TextBMFont* labelBMFont = dynamic_cast(widget); + if (labelBMFont) + { + setFntFile(labelBMFont->_fntFileName.c_str()); + setText(labelBMFont->_stringValue.c_str()); + } +} + +} + +NS_CC_END \ No newline at end of file diff --git a/cocos/gui/UILabelBMFont.h b/cocos/gui/UITextBMFont.h similarity index 52% rename from cocos/gui/UILabelBMFont.h rename to cocos/gui/UITextBMFont.h index 5bfb276ead..2a5f729623 100644 --- a/cocos/gui/UILabelBMFont.h +++ b/cocos/gui/UITextBMFont.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UILABELBMFONT_H__ #define __UILABELBMFONT_H__ @@ -35,23 +35,23 @@ namespace gui { * @js NA * @lua NA */ -class LabelBMFont : public Widget +class TextBMFont : public Widget { public: /** * Default constructor */ - LabelBMFont(); + TextBMFont(); /** * Default destructor */ - virtual ~LabelBMFont(); + virtual ~TextBMFont(); /** * Allocates and initializes. */ - static LabelBMFont* create(); + static TextBMFont* create(); /** init a bitmap font atlas with an initial string and the FNT file */ void setFntFile(const char* fileName); diff --git a/cocos/gui/UITextField.cpp b/cocos/gui/UITextField.cpp index a9cc8571f8..c463293006 100644 --- a/cocos/gui/UITextField.cpp +++ b/cocos/gui/UITextField.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UITextField.h" @@ -269,7 +269,7 @@ bool UICCTextField::getDeleteBackward() return _deleteBackward; } -#define TEXTFIELDRENDERERZ (-1) +static const int TEXTFIELD_RENDERER_Z = (-1); TextField::TextField(): @@ -300,21 +300,17 @@ TextField* TextField::create() CC_SAFE_DELETE(widget); return nullptr; } - -bool TextField::init() + +void TextField::onEnter() { - if (Widget::init()) - { - setUpdateEnabled(true); - return true; - } - return false; + Widget::onEnter(); + scheduleUpdate(); } void TextField::initRenderer() { _textFieldRenderer = UICCTextField::create("input words here", "Thonburi", 20); - Node::addChild(_textFieldRenderer, TEXTFIELDRENDERERZ, -1); + Node::addChild(_textFieldRenderer, TEXTFIELD_RENDERER_Z, -1); } void TextField::setTouchSize(const Size &size) @@ -326,10 +322,21 @@ void TextField::setTouchSize(const Size &size) void TextField::setText(const std::string& text) { - if (text.size()==0) - return; - - _textFieldRenderer->setString(text); + std::string strText(text); + if (isMaxLengthEnabled()) + { + strText = strText.substr(0, getMaxLength()); + } + const char* content = strText.c_str(); + if (isPasswordEnabled()) + { + _textFieldRenderer->setPasswordText(content); + _textFieldRenderer->insertText(content, static_cast(strlen(content))); + } + else + { + _textFieldRenderer->setString(content); + } textfieldRendererScaleChangedWithSize(); } diff --git a/cocos/gui/UITextField.h b/cocos/gui/UITextField.h index 8a00135062..1f01103592 100644 --- a/cocos/gui/UITextField.h +++ b/cocos/gui/UITextField.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UITEXTFIELD_H__ #define __UITEXTFIELD_H__ @@ -47,10 +47,10 @@ public: static UICCTextField* create(const char *placeholder, const char *fontName, float fontSize); // CCTextFieldDelegate - virtual bool onTextFieldAttachWithIME(TextFieldTTF *pSender); - virtual bool onTextFieldDetachWithIME(TextFieldTTF * pSender); - virtual bool onTextFieldInsertText(TextFieldTTF * pSender, const char * text, int nLen); - virtual bool onTextFieldDeleteBackward(TextFieldTTF * pSender, const char * delText, int nLen); + virtual bool onTextFieldAttachWithIME(TextFieldTTF *pSender) override; + virtual bool onTextFieldDetachWithIME(TextFieldTTF * pSender) override; + virtual bool onTextFieldInsertText(TextFieldTTF * pSender, const char * text, int nLen) override; + virtual bool onTextFieldDeleteBackward(TextFieldTTF * pSender, const char * delText, int nLen) override; void insertText(const char* text, int len); void deleteBackward(); @@ -107,8 +107,6 @@ public: TextField(); virtual ~TextField(); static TextField* create(); - virtual bool init() override; - virtual void initRenderer() override; void setTouchSize(const Size &size); void setText(const std::string& text); void setPlaceHolder(const std::string& value); @@ -145,8 +143,10 @@ public: virtual const Size& getContentSize() const override; virtual Node* getVirtualRenderer() override; void attachWithIME(); + virtual void onEnter() override; protected: // event + virtual void initRenderer() override; void attachWithIMEEvent(); void detachWithIMEEvent(); void insertTextEvent(); diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index 11a5c1dbf7..e28f4d8db0 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #include "gui/UIWidget.h" #include "gui/UILayout.h" @@ -37,7 +37,6 @@ _touchEnabled(false), _touchPassedEnabled(false), _focus(false), _brightStyle(BRIGHT_NONE), -_updateEnabled(false), _touchStartPos(Point::ZERO), _touchMovePos(Point::ZERO), _touchEndPos(Point::ZERO), @@ -66,7 +65,8 @@ Widget::~Widget() _touchEventListener = nullptr; _touchEventSelector = nullptr; _widgetChildren.clear(); - CC_SAFE_RELEASE(_touchListener); + setTouchEnabled(false); + _nodes.clear(); } Widget* Widget::create() @@ -104,6 +104,7 @@ void Widget::onEnter() void Widget::onExit() { + unscheduleUpdate(); Node::onExit(); } @@ -127,7 +128,7 @@ void Widget::addChild(Node * child, int zOrder) void Widget::addChild(Node* child, int zOrder, int tag) { - CCASSERT(dynamic_cast(child) != NULL, "Widget only supports Widgets as children"); + CCASSERT(dynamic_cast(child) != nullptr, "Widget only supports Widgets as children"); Node::addChild(child, zOrder, tag); _widgetChildren.pushBack(child); } @@ -197,7 +198,7 @@ void Widget::removeChildByTag(int tag, bool cleanup) Node *child = getChildByTag(tag); - if (child == NULL) + if (child == nullptr) { CCLOG("cocos2d: removeChildByTag(tag = %d): child not found!", tag); } @@ -251,6 +252,75 @@ Widget* Widget::getChildByName(const char *name) } return nullptr; } + +void Widget::addNode(Node* node) +{ + addNode(node, node->getZOrder(), node->getTag()); +} + +void Widget::addNode(Node * node, int zOrder) +{ + addNode(node, zOrder, node->getTag()); +} + +void Widget::addNode(Node* node, int zOrder, int tag) +{ + CCAssert(dynamic_cast(node) == nullptr, "Widget only supports Nodes as renderer"); + Node::addChild(node, zOrder, tag); + _nodes.pushBack(node); +} + +Node* Widget::getNodeByTag(int tag) +{ + CCAssert( tag != Node::INVALID_TAG, "Invalid tag"); + + for (auto& node : _nodes) + { + if(node && node->getTag() == tag) + return node; + } + return nullptr; +} + +Vector& Widget::getNodes() +{ + return _nodes; +} + +void Widget::removeNode(Node* node) +{ + Node::removeChild(node); + _nodes.eraseObject(node); +} + +void Widget::removeNodeByTag(int tag) +{ + CCAssert( tag != Node::INVALID_TAG, "Invalid tag"); + + Node *node = this->getNodeByTag(tag); + + if (node == nullptr) + { + CCLOG("cocos2d: removeNodeByTag(tag = %d): child not found!", tag); + } + else + { + this->removeNode(node); + } +} + +void Widget::removeAllNodes() +{ + for (auto& node : _nodes) + { + if (node) + { + Node::removeChild(node); + } + } + _nodes.clear(); +} + void Widget::initRenderer() { @@ -553,28 +623,6 @@ bool Widget::isTouchEnabled() const return _touchEnabled; } -void Widget::setUpdateEnabled(bool enable) -{ - if (enable == _updateEnabled) - { - return; - } - _updateEnabled = enable; - if (enable) - { - scheduleUpdate(); - } - else - { - unscheduleUpdate(); - } -} - -bool Widget::isUpdateEnabled() -{ - return _updateEnabled; -} - bool Widget::isFocused() const { return _focus; @@ -660,11 +708,15 @@ void Widget::didNotSelectSelf() bool Widget::onTouchBegan(Touch *touch, Event *unusedEvent) { - _touchStartPos = touch->getLocation(); - _hitted = isEnabled() - & isTouchEnabled() - & hitTest(_touchStartPos) - & clippingParentAreaContainPoint(_touchStartPos); + _hitted = false; + if (isEnabled() && isTouchEnabled()) + { + _touchStartPos = touch->getLocation(); + if(hitTest(_touchStartPos) && clippingParentAreaContainPoint(_touchStartPos)) + { + _hitted = true; + } + } if (!_hitted) { return false; @@ -717,11 +769,6 @@ void Widget::onTouchCancelled(Touch *touch, Event *unusedEvent) cancelUpEvent(); } -void Widget::onTouchLongClicked(const Point &touchPoint) -{ - longClickEvent(); -} - void Widget::pushDownEvent() { if (_touchEventListener && _touchEventSelector) @@ -754,11 +801,6 @@ void Widget::cancelUpEvent() } } -void Widget::longClickEvent() -{ - -} - void Widget::addTouchEventListener(Object *target, SEL_TouchEvent selector) { _touchEventListener = target; @@ -999,7 +1041,6 @@ void Widget::copyProperties(Widget *widget) setTouchEnabled(widget->isTouchEnabled()); _touchPassedEnabled = false; setZOrder(widget->getZOrder()); - setUpdateEnabled(widget->isUpdateEnabled()); setTag(widget->getTag()); setName(widget->getName()); setActionTag(widget->getActionTag()); diff --git a/cocos/gui/UIWidget.h b/cocos/gui/UIWidget.h index 379fc04003..d07bc4bee8 100644 --- a/cocos/gui/UIWidget.h +++ b/cocos/gui/UIWidget.h @@ -1,26 +1,26 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ +Copyright (c) 2013-2014 Chukong Technologies Inc. + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************/ #ifndef __UIWIDGET_H__ #define __UIWIDGET_H__ @@ -315,7 +315,23 @@ public: */ virtual Widget* getChildByName(const char* name); - virtual void visit(); + virtual void addNode(Node* node); + + virtual void addNode(Node * node, int zOrder); + + virtual void addNode(Node* node, int zOrder, int tag); + + virtual Node * getNodeByTag(int tag); + + virtual Vector& getNodes(); + + virtual void removeNode(Node* node); + + virtual void removeNodeByTag(int tag); + + virtual void removeAllNodes(); + + virtual void visit() override; /** * Sets the touch event target/selector of the menu item @@ -333,7 +349,7 @@ public: * * @param position The position (x,y) of the widget in OpenGL coordinates */ - void setPosition(const Point &pos); + virtual void setPosition(const Point &pos) override; /** * Changes the position (x,y) of the widget in OpenGL coordinates @@ -534,14 +550,7 @@ public: virtual void onTouchMoved(Touch *touch, Event *unusedEvent); virtual void onTouchEnded(Touch *touch, Event *unusedEvent); virtual void onTouchCancelled(Touch *touch, Event *unusedEvent); - - /** - * A call back function called when widget is selected, and on touch long clicked. - * - * @param touch point - */ - virtual void onTouchLongClicked(const Point &touchPoint); - + /** * Sets a LayoutParameter to widget. * @@ -594,16 +603,6 @@ public: */ virtual Node* getVirtualRenderer(); - /** - * Schedules the "update" method. - */ - void setUpdateEnabled(bool enable); - - /** - * is the "update" method scheduled. - */ - bool isUpdateEnabled(); - /** * Gets the content size of widget. * @@ -618,8 +617,8 @@ public: Widget* clone(); - virtual void onEnter(); - virtual void onExit(); + virtual void onEnter() override; + virtual void onExit() override; void updateSizeAndPosition(); @@ -648,7 +647,6 @@ protected: void moveEvent(); void releaseUpEvent(); void cancelUpEvent(); - void longClickEvent(); void updateAnchorPoint(); void copyProperties(Widget* model); virtual Widget* createCloneInstance(); @@ -662,7 +660,6 @@ protected: bool _touchPassedEnabled; ///< is the touch event should be passed bool _focus; ///< is the widget on focus BrightStyle _brightStyle; ///< bright style - bool _updateEnabled; ///< is "update" method scheduled Point _touchStartPos; ///< touch began point Point _touchMovePos; ///< touch moved point Point _touchEndPos; ///< touch ended point @@ -684,6 +681,7 @@ protected: EventListenerTouchOneByOne* _touchListener; Map _layoutParameterDictionary; Vector _widgetChildren; + Vector _nodes; }; } diff --git a/cocos/gui/proj.win32/libGUI.vcxproj b/cocos/gui/proj.win32/libGUI.vcxproj index caf83df195..8d40d2cca4 100644 --- a/cocos/gui/proj.win32/libGUI.vcxproj +++ b/cocos/gui/proj.win32/libGUI.vcxproj @@ -16,9 +16,6 @@ - - - @@ -28,6 +25,9 @@ + + + @@ -37,9 +37,6 @@ - - - @@ -48,6 +45,9 @@ + + + @@ -104,6 +104,7 @@ true 4267;4251;4244;%(DisableSpecificWarnings) false + OldStyle true diff --git a/cocos/gui/proj.win32/libGUI.vcxproj.filters b/cocos/gui/proj.win32/libGUI.vcxproj.filters index 148977b79d..038a4925ef 100644 --- a/cocos/gui/proj.win32/libGUI.vcxproj.filters +++ b/cocos/gui/proj.win32/libGUI.vcxproj.filters @@ -39,15 +39,6 @@ UIWidgets - - UIWidgets - - - UIWidgets - - - UIWidgets - UIWidgets @@ -75,6 +66,15 @@ Layouts + + UIWidgets + + + UIWidgets + + + UIWidgets + @@ -95,15 +95,6 @@ UIWidgets - - UIWidgets - - - UIWidgets - - - UIWidgets - UIWidgets @@ -131,5 +122,14 @@ Layouts + + UIWidgets + + + UIWidgets + + + UIWidgets + \ No newline at end of file diff --git a/cocos/math/kazmath/CMakeLists.txt b/cocos/math/kazmath/CMakeLists.txt index 208b4a97c2..184bb1bc2d 100644 --- a/cocos/math/kazmath/CMakeLists.txt +++ b/cocos/math/kazmath/CMakeLists.txt @@ -1,23 +1,23 @@ SET(KAZMATH_SOURCES - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/mat4.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/mat3.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/plane.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/vec4.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/quaternion.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/vec2.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/vec3.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/utility.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/aabb.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/ray2.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/GL/mat4stack.c - ${CMAKE_SOURCE_DIR}/cocos/math/kazmath/src/GL/matrix.c + mat4.c + mat3.c + plane.c + vec4.c + quaternion.c + vec2.c + vec3.c + utility.c + aabb.c + ray2.c + GL/mat4stack.c + GL/matrix.c ) ADD_SUBDIRECTORY(src) set_target_properties(kazmath PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/cocos/network/CMakeLists.txt b/cocos/network/CMakeLists.txt index f2deb9b365..e57b04ccf9 100644 --- a/cocos/network/CMakeLists.txt +++ b/cocos/network/CMakeLists.txt @@ -1,6 +1,16 @@ +if(WIN32) + set(PLATFORM_SRC + WebSocket.cpp + ) + set(PLATFORM_LINK + websockets + ) +endif() + set(NETWORK_SRC HttpClient.cpp SocketIO.cpp + ${PLATFORM_SRC} ) add_library(network STATIC @@ -9,15 +19,12 @@ add_library(network STATIC target_link_libraries(network curl - ldap - lber - idn - rtmp + ${PLATFORM_LINK} ) set_target_properties(network PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/cocos/network/HttpClient.cpp b/cocos/network/HttpClient.cpp index 3fc6f2bb90..cc19b72524 100644 --- a/cocos/network/HttpClient.cpp +++ b/cocos/network/HttpClient.cpp @@ -1,6 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2012 greathqy + Copyright (c) 2012 greathqy + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -32,7 +33,7 @@ #include "platform/CCFileUtils.h" -using namespace cocos2d; +NS_CC_BEGIN namespace network { @@ -52,7 +53,7 @@ static bool s_need_quit = false; static Vector* s_requestQueue = nullptr; static Vector* s_responseQueue = nullptr; -static HttpClient *s_pHttpClient = NULL; // pointer to singleton +static HttpClient *s_pHttpClient = nullptr; // pointer to singleton static char s_errorBuffer[CURL_ERROR_SIZE] = {0}; @@ -97,7 +98,7 @@ static int processDeleteTask(HttpRequest *request, write_callback callback, void // Worker thread void HttpClient::networkThread() { - HttpRequest *request = NULL; + HttpRequest *request = nullptr; auto scheduler = Director::getInstance()->getScheduler(); @@ -109,7 +110,7 @@ void HttpClient::networkThread() } // step 1: send http request if the requestQueue isn't empty - request = NULL; + request = nullptr; s_requestQueueMutex.lock(); @@ -123,7 +124,7 @@ void HttpClient::networkThread() s_requestQueueMutex.unlock(); - if (NULL == request) + if (nullptr == request) { // Wait for http request tasks from main thread std::unique_lock lk(s_SleepMutex); @@ -263,7 +264,7 @@ class CURLRaii public: CURLRaii() : _curl(curl_easy_init()) - , _headers(NULL) + , _headers(nullptr) { } @@ -387,7 +388,7 @@ static int processDeleteTask(HttpRequest *request, write_callback callback, void // HttpClient implementation HttpClient* HttpClient::getInstance() { - if (s_pHttpClient == NULL) { + if (s_pHttpClient == nullptr) { s_pHttpClient = new HttpClient(); } @@ -396,8 +397,7 @@ HttpClient* HttpClient::getInstance() void HttpClient::destroyInstance() { - CCASSERT(s_pHttpClient, ""); - s_pHttpClient->release(); + CC_SAFE_DELETE(s_pHttpClient); } void HttpClient::enableCookies(const char* cookieFile) { @@ -419,17 +419,17 @@ HttpClient::~HttpClient() { s_need_quit = true; - if (s_requestQueue != NULL) { + if (s_requestQueue != nullptr) { s_SleepCondition.notify_one(); } - s_pHttpClient = NULL; + s_pHttpClient = nullptr; } //Lazy create semaphore & mutex & thread bool HttpClient::lazyInitThreadSemphore() { - if (s_requestQueue != NULL) { + if (s_requestQueue != nullptr) { return true; } else { @@ -473,7 +473,7 @@ void HttpClient::dispatchResponseCallbacks() { // log("CCHttpClient::dispatchResponseCallbacks is running"); - HttpResponse* response = NULL; + HttpResponse* response = nullptr; s_responseQueueMutex.lock(); @@ -502,4 +502,6 @@ void HttpClient::dispatchResponseCallbacks() } +NS_CC_END + diff --git a/cocos/network/HttpClient.h b/cocos/network/HttpClient.h index 1304f4b168..74f498e942 100644 --- a/cocos/network/HttpClient.h +++ b/cocos/network/HttpClient.h @@ -1,6 +1,7 @@ /**************************************************************************** - Copyright (c) 2010-2012 cocos2d-x.org - Copyright (c) 2012 greathqy + Copyright (c) 2012 greathqy + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -32,6 +33,8 @@ #include "network/HttpResponse.h" #include "network/HttpClient.h" +NS_CC_BEGIN + namespace network { /** @@ -43,7 +46,7 @@ namespace network { /** @brief Singleton that handles asynchrounous http requests * Once the request completed, a callback will issued in main thread when it provided during make request */ -class HttpClient : public cocos2d::Object +class HttpClient { public: /** Return the shared instance **/ @@ -106,8 +109,6 @@ private: private: int _timeoutForConnect; int _timeoutForRead; - - // std::string reqId; }; // end of Network group @@ -115,4 +116,6 @@ private: } +NS_CC_END + #endif //__CCHTTPREQUEST_H__ diff --git a/cocos/network/HttpRequest.h b/cocos/network/HttpRequest.h index 7264daeba3..50d660bca3 100644 --- a/cocos/network/HttpRequest.h +++ b/cocos/network/HttpRequest.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -27,12 +28,14 @@ #include "cocos2d.h" +NS_CC_BEGIN + namespace network { class HttpClient; class HttpResponse; typedef void (cocos2d::Object::*SEL_HttpResponse)(HttpClient* client, HttpResponse* response); -#define httpresponse_selector(_SELECTOR) (network::SEL_HttpResponse)(&_SELECTOR) +#define httpresponse_selector(_SELECTOR) (cocos2d::network::SEL_HttpResponse)(&_SELECTOR) /** @brief defines the object which users must packed for HttpClient::send(HttpRequest*) method. @@ -231,4 +234,6 @@ protected: } +NS_CC_END + #endif //__HTTP_REQUEST_H__ diff --git a/cocos/network/HttpResponse.h b/cocos/network/HttpResponse.h index 9f4bd10028..764ddde120 100644 --- a/cocos/network/HttpResponse.h +++ b/cocos/network/HttpResponse.h @@ -1,5 +1,6 @@ /**************************************************************************** Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -28,6 +29,8 @@ #include "cocos2d.h" #include "network/HttpRequest.h" +NS_CC_BEGIN + namespace network { /** @@ -179,4 +182,6 @@ protected: } +NS_CC_END + #endif //__HTTP_RESPONSE_H__ diff --git a/cocos/network/SocketIO.cpp b/cocos/network/SocketIO.cpp index 74bfbafa1a..c38ed4c70d 100644 --- a/cocos/network/SocketIO.cpp +++ b/cocos/network/SocketIO.cpp @@ -1,6 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2013 cocos2d-x.org - Copyright (c) 2013 Chris Hannon + Copyright (c) 2013 Chris Hannon + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -32,7 +32,7 @@ #include "HttpClient.h" #include -using namespace cocos2d; +NS_CC_BEGIN namespace network { @@ -687,4 +687,6 @@ void SocketIO::removeSocket(const std::string& uri) _sockets.erase(uri); } -} \ No newline at end of file +} + +NS_CC_END diff --git a/cocos/network/SocketIO.h b/cocos/network/SocketIO.h index 0e79f41984..599a6c4cd0 100644 --- a/cocos/network/SocketIO.h +++ b/cocos/network/SocketIO.h @@ -1,6 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2013 cocos2d-x.org Copyright (c) 2013 Chris Hannon http://www.channon.us + Copyright (c) 2013-2014 Chukong Technologies Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -61,6 +61,8 @@ in the onClose method the pointer should be set to NULL or used to connect to a #include "cocos2d.h" +NS_CC_BEGIN + namespace network { //forward declarations @@ -185,4 +187,6 @@ public: } +NS_CC_END + #endif /* defined(__CC_JSB_SOCKETIO_H__) */ diff --git a/cocos/network/WebSocket.cpp b/cocos/network/WebSocket.cpp index 2e91b54bc0..5e17487567 100644 --- a/cocos/network/WebSocket.cpp +++ b/cocos/network/WebSocket.cpp @@ -1,6 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2013 cocos2d-x.org - Copyright (c) 2013 James Chen + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -37,14 +37,16 @@ #include "libwebsockets.h" -using namespace cocos2d; +#define WS_WRITE_BUFFER_SIZE 2048 + +NS_CC_BEGIN namespace network { class WsMessage { public: - WsMessage() : what(0), obj(NULL){} + WsMessage() : what(0), obj(nullptr){} unsigned int what; // message type void* obj; }; @@ -52,7 +54,7 @@ public: /** * @brief Websocket thread helper, it's used for sending message between UI thread and websocket thread. */ -class WsThreadHelper : public cocos2d::Object +class WsThreadHelper : public Object { public: WsThreadHelper(); @@ -112,7 +114,7 @@ public: // Implementation of WsThreadHelper WsThreadHelper::WsThreadHelper() : _subThreadInstance(nullptr) -, _ws(NULL) +, _ws(nullptr) , _needQuit(false) { _UIWsMessageQueue = new std::list(); @@ -181,7 +183,7 @@ void WsThreadHelper::joinSubThread() void WsThreadHelper::update(float dt) { - WsMessage *msg = NULL; + WsMessage *msg = nullptr; // Returns quickly if no message std::lock_guard lk(_UIWsMessageQueueMutex); @@ -221,6 +223,9 @@ WebSocket::WebSocket() , _delegate(nullptr) , _SSLConnection(0) , _wsProtocols(nullptr) +, _pendingFrameDataLen(0) +, _currentDataLen(0) +, _currentData(nullptr) { } @@ -238,7 +243,7 @@ WebSocket::~WebSocket() bool WebSocket::init(const Delegate& delegate, const std::string& url, - const std::vector* protocols/* = NULL*/) + const std::vector* protocols/* = nullptr*/) { bool ret = false; bool useSSL = false; @@ -497,12 +502,13 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, case LWS_CALLBACK_CLIENT_WRITEABLE: { + std::lock_guard lk(_wsHelper->_subThreadWsMessageQueueMutex); std::list::iterator iter = _wsHelper->_subThreadWsMessageQueue->begin(); int bytesWrite = 0; - for (; iter != _wsHelper->_subThreadWsMessageQueue->end(); ++iter) + for (; iter != _wsHelper->_subThreadWsMessageQueue->end();) { WsMessage* subThreadMsg = *iter; @@ -511,44 +517,64 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, { Data* data = (Data*)subThreadMsg->obj; - unsigned char* buf = new unsigned char[LWS_SEND_BUFFER_PRE_PADDING - + data->len + LWS_SEND_BUFFER_POST_PADDING]; + const size_t c_bufferSize = WS_WRITE_BUFFER_SIZE; + + size_t remaining = data->len - data->issued; + size_t n = std::min(remaining, c_bufferSize ); + CCLOG("[websocket:send] total: %d, sent: %d, remaining: %d, buffer size: %d", data->len, data->issued, remaining, n); + + unsigned char* buf = new unsigned char[LWS_SEND_BUFFER_PRE_PADDING + n + LWS_SEND_BUFFER_POST_PADDING]; + + memcpy((char*)&buf[LWS_SEND_BUFFER_PRE_PADDING], data->bytes + data->issued, n); - memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, data->len); - memcpy((char*)&buf[LWS_SEND_BUFFER_PRE_PADDING], data->bytes, data->len); + int writeProtocol; - enum libwebsocket_write_protocol writeProtocol; - - if (WS_MSG_TO_SUBTRHEAD_SENDING_STRING == subThreadMsg->what) - { - writeProtocol = LWS_WRITE_TEXT; + if (data->issued == 0) { + if (WS_MSG_TO_SUBTRHEAD_SENDING_STRING == subThreadMsg->what) + { + writeProtocol = LWS_WRITE_TEXT; + } + else + { + writeProtocol = LWS_WRITE_BINARY; + } + + // If we have more than 1 fragment + if (data->len > c_bufferSize) + writeProtocol |= LWS_WRITE_NO_FIN; + } else { + // we are in the middle of fragments + writeProtocol = LWS_WRITE_CONTINUATION; + // and if not in the last fragment + if (remaining != n) + writeProtocol |= LWS_WRITE_NO_FIN; } - else - { - writeProtocol = LWS_WRITE_BINARY; - } - - bytesWrite = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], data->len, writeProtocol); - + + bytesWrite = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], n, (libwebsocket_write_protocol)writeProtocol); + CCLOG("[websocket:send] bytesWrite => %d", bytesWrite); + + // Buffer overrun? if (bytesWrite < 0) { - CCLOGERROR("%s", "libwebsocket_write error..."); + break; } - if (bytesWrite < data->len) + // Do we have another fragments to send? + else if (remaining != n) { - CCLOGERROR("Partial write LWS_CALLBACK_CLIENT_WRITEABLE\n"); + data->issued += n; + break; + } + // Safely done! + else + { + CC_SAFE_DELETE_ARRAY(data->bytes); + CC_SAFE_DELETE(data); + CC_SAFE_DELETE_ARRAY(buf); + _wsHelper->_subThreadWsMessageQueue->erase(iter++); + CC_SAFE_DELETE(subThreadMsg); } - - CC_SAFE_DELETE_ARRAY(data->bytes); - CC_SAFE_DELETE(data); - CC_SAFE_DELETE_ARRAY(buf); } - - CC_SAFE_DELETE(subThreadMsg); } - - _wsHelper->_subThreadWsMessageQueue->clear(); - /* get notified as soon as we can write again */ @@ -577,32 +603,64 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, { if (in && len > 0) { - WsMessage* msg = new WsMessage(); - msg->what = WS_MSG_TO_UITHREAD_MESSAGE; - - char* bytes = NULL; - Data* data = new Data(); - - if (lws_frame_is_binary(wsi)) + // Accumulate the data (increasing the buffer as we go) + if (_currentDataLen == 0) { - - bytes = new char[len]; - data->isBinary = true; + _currentData = new char[len]; + memcpy (_currentData, in, len); + _currentDataLen = len; } else { - bytes = new char[len+1]; - bytes[len] = '\0'; - data->isBinary = false; + char *new_data = new char [_currentDataLen + len]; + memcpy (new_data, _currentData, _currentDataLen); + memcpy (new_data + _currentDataLen, in, len); + CC_SAFE_DELETE_ARRAY(_currentData); + _currentData = new_data; + _currentDataLen = _currentDataLen + len; } - memcpy(bytes, in, len); + _pendingFrameDataLen = libwebsockets_remaining_packet_payload (wsi); + + if (_pendingFrameDataLen > 0) + { + //CCLOG("%ld bytes of pending data to receive, consider increasing the libwebsocket rx_buffer_size value.", _pendingFrameDataLen); + } - data->bytes = bytes; - data->len = len; - msg->obj = (void*)data; - - _wsHelper->sendMessageToUIThread(msg); + // If no more data pending, send it to the client thread + if (_pendingFrameDataLen == 0) + { + WsMessage* msg = new WsMessage(); + msg->what = WS_MSG_TO_UITHREAD_MESSAGE; + + char* bytes = nullptr; + Data* data = new Data(); + + if (lws_frame_is_binary(wsi)) + { + + bytes = new char[_currentDataLen]; + data->isBinary = true; + } + else + { + bytes = new char[_currentDataLen+1]; + bytes[_currentDataLen] = '\0'; + data->isBinary = false; + } + + memcpy(bytes, _currentData, _currentDataLen); + + data->bytes = bytes; + data->len = _currentDataLen; + msg->obj = (void*)data; + + CC_SAFE_DELETE_ARRAY(_currentData); + _currentData = nullptr; + _currentDataLen = 0; + + _wsHelper->sendMessageToUIThread(msg); + } } } break; @@ -648,3 +706,5 @@ void WebSocket::onUIThreadReceiveMessage(WsMessage* msg) } } + +NS_CC_END diff --git a/cocos/network/WebSocket.h b/cocos/network/WebSocket.h index 9a354d47a4..738abf2c2f 100644 --- a/cocos/network/WebSocket.h +++ b/cocos/network/WebSocket.h @@ -1,6 +1,6 @@ /**************************************************************************** - Copyright (c) 2010-2013 cocos2d-x.org - Copyright (c) 2013 James Chen + Copyright (c) 2010-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -37,6 +37,8 @@ struct libwebsocket; struct libwebsocket_context; struct libwebsocket_protocols; +NS_CC_BEGIN + namespace network { class WsThreadHelper; @@ -60,9 +62,9 @@ public: */ struct Data { - Data():bytes(NULL), len(0), isBinary(false){} + Data():bytes(nullptr), len(0), issued(0), isBinary(false){} char* bytes; - ssize_t len; + ssize_t len, issued; bool isBinary; }; @@ -110,7 +112,7 @@ public: */ bool init(const Delegate& delegate, const std::string& url, - const std::vector* protocols = NULL); + const std::vector* protocols = nullptr); /** * @brief Sends string data to websocket server. @@ -151,6 +153,10 @@ private: unsigned int _port; std::string _path; + size_t _pendingFrameDataLen; + unsigned int _currentDataLen; + char *_currentData; + friend class WsThreadHelper; WsThreadHelper* _wsHelper; @@ -163,4 +169,6 @@ private: } +NS_CC_END + #endif /* defined(__CC_JSB_WEBSOCKET_H__) */ diff --git a/cocos/physics/CCPhysicsBody.cpp b/cocos/physics/CCPhysicsBody.cpp index c626389290..240f9833ba 100644 --- a/cocos/physics/CCPhysicsBody.cpp +++ b/cocos/physics/CCPhysicsBody.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/physics/CCPhysicsBody.h b/cocos/physics/CCPhysicsBody.h index a843732ad9..52ba0f527d 100644 --- a/cocos/physics/CCPhysicsBody.h +++ b/cocos/physics/CCPhysicsBody.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/physics/CCPhysicsContact.cpp b/cocos/physics/CCPhysicsContact.cpp index c04b295f46..86e7cec08f 100644 --- a/cocos/physics/CCPhysicsContact.cpp +++ b/cocos/physics/CCPhysicsContact.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/physics/CCPhysicsContact.h b/cocos/physics/CCPhysicsContact.h index 552ab81e63..987e5daf47 100644 --- a/cocos/physics/CCPhysicsContact.h +++ b/cocos/physics/CCPhysicsContact.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/physics/CCPhysicsJoint.cpp b/cocos/physics/CCPhysicsJoint.cpp index 2d5cddd7ab..2509c5c7a6 100644 --- a/cocos/physics/CCPhysicsJoint.cpp +++ b/cocos/physics/CCPhysicsJoint.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/physics/CCPhysicsJoint.h b/cocos/physics/CCPhysicsJoint.h index b5e80e1c42..e2a2d5a9a9 100644 --- a/cocos/physics/CCPhysicsJoint.h +++ b/cocos/physics/CCPhysicsJoint.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/physics/CCPhysicsShape.cpp b/cocos/physics/CCPhysicsShape.cpp index 543bbf0333..f0e9abeb7d 100644 --- a/cocos/physics/CCPhysicsShape.cpp +++ b/cocos/physics/CCPhysicsShape.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -229,7 +229,7 @@ void PhysicsShape::setFriction(float friction) } -Point* PhysicsShape::recenterPoints(Point* points, int count, const Point& center) +void PhysicsShape::recenterPoints(Point* points, int count, const Point& center) { cpVect* cpvs = new cpVect[count]; cpRecenterPoly(count, PhysicsHelper::points2cpvs(points, cpvs, count)); @@ -243,8 +243,6 @@ Point* PhysicsShape::recenterPoints(Point* points, int count, const Point& cente points[i] += center; } } - - return points; } Point PhysicsShape::getPolyonCenter(const Point* points, int count) @@ -655,6 +653,15 @@ bool PhysicsShapeEdgeBox::init(const Size& size, const PhysicsMaterial& material return false; } +void PhysicsShapeEdgeBox::getPoints(cocos2d::Point *outPoints) const +{ + int i = 0; + for(auto shape : _info->getShapes()) + { + outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a); + } +} + // PhysicsShapeEdgeBox PhysicsShapeEdgePolygon* PhysicsShapeEdgePolygon::create(const Point* points, int count, const PhysicsMaterial& material/* = MaterialDefault*/, float border/* = 1*/) { @@ -712,6 +719,15 @@ Point PhysicsShapeEdgePolygon::getCenter() return _center; } +void PhysicsShapeEdgePolygon::getPoints(cocos2d::Point *outPoints) const +{ + int i = 0; + for(auto shape : _info->getShapes()) + { + outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a); + } +} + int PhysicsShapeEdgePolygon::getPointsCount() const { return static_cast(_info->getShapes().size() + 1); @@ -773,6 +789,17 @@ Point PhysicsShapeEdgeChain::getCenter() return _center; } +void PhysicsShapeEdgeChain::getPoints(Point* outPoints) const +{ + int i = 0; + for(auto shape : _info->getShapes()) + { + outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)shape)->a); + } + + outPoints[i++] = PhysicsHelper::cpv2point(((cpSegmentShape*)_info->getShapes().back())->a); +} + int PhysicsShapeEdgeChain::getPointsCount() const { return static_cast(_info->getShapes().size() + 1); diff --git a/cocos/physics/CCPhysicsShape.h b/cocos/physics/CCPhysicsShape.h index 1146b2d291..6863e47377 100644 --- a/cocos/physics/CCPhysicsShape.h +++ b/cocos/physics/CCPhysicsShape.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -114,7 +114,7 @@ public: bool containsPoint(const Point& point) const; /** move the points to the center */ - static Point* recenterPoints(Point* points, int count, const Point& center = Point::ZERO); + static void recenterPoints(Point* points, int count, const Point& center = Point::ZERO); /** get center of the polyon points */ static Point getPolyonCenter(const Point* points, int count); @@ -212,6 +212,7 @@ public: virtual float calculateDefaultMoment() override; void getPoints(Point* outPoints) const; + int getPointsCount() const { return 4; } Size getSize() const; virtual Point getOffset() override { return _offset; } @@ -282,8 +283,8 @@ class PhysicsShapeEdgeBox : public PhysicsShape public: static PhysicsShapeEdgeBox* create(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 0, const Point& offset = Point::ZERO); virtual Point getOffset() override { return _offset; } - void getPoints(const Point* outPoints) const; - int getPointsCount() const; + void getPoints(Point* outPoints) const; + int getPointsCount() const { return 4; } protected: bool init(const Size& size, const PhysicsMaterial& material = PHYSICSSHAPE_MATERIAL_DEFAULT, float border = 1, const Point& offset = Point::ZERO); diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index ebb12e4ec2..f57679c7e4 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index 6991071679..bca81f35b4 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/physics/CMakeLists.txt b/cocos/physics/CMakeLists.txt index ef81f5ec6b..2810dcb5f4 100644 --- a/cocos/physics/CMakeLists.txt +++ b/cocos/physics/CMakeLists.txt @@ -1,13 +1,13 @@ set(COCOS_PHYSICS_SRC - ${CMAKE_SOURCE_DIR}/cocos/physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp - ${CMAKE_SOURCE_DIR}/cocos/physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp - ${CMAKE_SOURCE_DIR}/cocos/physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp - ${CMAKE_SOURCE_DIR}/cocos/physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp - ${CMAKE_SOURCE_DIR}/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp - ${CMAKE_SOURCE_DIR}/cocos/physics/CCPhysicsBody.cpp - ${CMAKE_SOURCE_DIR}/cocos/physics/CCPhysicsContact.cpp - ${CMAKE_SOURCE_DIR}/cocos/physics/CCPhysicsShape.cpp - ${CMAKE_SOURCE_DIR}/cocos/physics/CCPhysicsJoint.cpp - ${CMAKE_SOURCE_DIR}/cocos/physics/CCPhysicsWorld.cpp + ../physics/chipmunk/CCPhysicsContactInfo_chipmunk.cpp + ../physics/chipmunk/CCPhysicsJointInfo_chipmunk.cpp + ../physics/chipmunk/CCPhysicsShapeInfo_chipmunk.cpp + ../physics/chipmunk/CCPhysicsBodyInfo_chipmunk.cpp + ../physics/chipmunk/CCPhysicsWorldInfo_chipmunk.cpp + ../physics/CCPhysicsBody.cpp + ../physics/CCPhysicsContact.cpp + ../physics/CCPhysicsShape.cpp + ../physics/CCPhysicsJoint.cpp + ../physics/CCPhysicsWorld.cpp ) diff --git a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h b/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h index b6de1dea20..4f1ab9cba1 100644 --- a/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h +++ b/cocos/physics/chipmunk/CCPhysicsWorldInfo_chipmunk.h @@ -49,7 +49,7 @@ public: void addJoint(PhysicsJointInfo& joint); void removeJoint(PhysicsJointInfo& joint); void setGravity(const Vect& gravity); - inline bool isLocked() { return static_cast(_space->locked_private); } + inline bool isLocked() { return 0 == _space->locked_private ? false : true; } inline void step(float delta) { cpSpaceStep(_space, delta); } private: diff --git a/cocos/scripting/CMakeLists.txt b/cocos/scripting/CMakeLists.txt index 09a2afed02..7f09f95726 100644 --- a/cocos/scripting/CMakeLists.txt +++ b/cocos/scripting/CMakeLists.txt @@ -2,7 +2,9 @@ set(LUABINDING_SRC auto-generated/lua-bindings/lua_cocos2dx_auto.cpp auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp + auto-generated/lua-bindings/lua_cocos2dx_gui_auto.cpp auto-generated/lua-bindings/lua_cocos2dx_spine_auto.cpp + auto-generated/lua-bindings/lua_cocos2dx_physics_auto.cpp lua/bindings/tolua_fix.c lua/bindings/CCLuaBridge.cpp lua/bindings/CCLuaEngine.cpp @@ -16,7 +18,9 @@ set(LUABINDING_SRC lua/bindings/lua_cocos2dx_manual.cpp lua/bindings/lua_cocos2dx_extension_manual.cpp lua/bindings/lua_cocos2dx_coco_studio_manual.cpp + lua/bindings/lua_cocos2dx_gui_manual.cpp lua/bindings/lua_cocos2dx_spine_manual.cpp + lua/bindings/lua_cocos2dx_physics_manual.cpp lua/bindings/lua_cocos2dx_deprecated.cpp lua/bindings/lua_xml_http_request.cpp lua/bindings/LuaSkeletonAnimation.cpp @@ -46,6 +50,6 @@ target_link_libraries(luabinding set_target_properties(luabinding PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/cocos/scripting/javascript/bindings/Android.mk b/cocos/scripting/javascript/bindings/Android.mk index 287a9a469b..1e80132687 100644 --- a/cocos/scripting/javascript/bindings/Android.mk +++ b/cocos/scripting/javascript/bindings/Android.mk @@ -14,8 +14,7 @@ LOCAL_SRC_FILES := ScriptingCore.cpp \ jsb_opengl_functions.cpp \ jsb_opengl_manual.cpp \ jsb_opengl_registration.cpp \ - ../../auto-generated/js-bindings/jsb_cocos2dx_auto.cpp \ - ../../auto-generated/js-bindings/jsb_cocos2dx_spine_auto.cpp + ../../auto-generated/js-bindings/jsb_cocos2dx_auto.cpp LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.cpp b/cocos/scripting/javascript/bindings/ScriptingCore.cpp index bdbf4978e0..6510b90167 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.cpp +++ b/cocos/scripting/javascript/bindings/ScriptingCore.cpp @@ -54,6 +54,8 @@ #define BYTE_CODE_FILE_EXT ".jsc" +using namespace cocos2d; + static std::string inData; static std::string outData; static std::vector g_queue; @@ -198,12 +200,12 @@ void js_log(const char *format, ...) { if (_js_log_buf == NULL) { - _js_log_buf = (char *)calloc(sizeof(char), kMaxLogLen+1); - _js_log_buf[kMaxLogLen] = '\0'; + _js_log_buf = (char *)calloc(sizeof(char), MAX_LOG_LENGTH+1); + _js_log_buf[MAX_LOG_LENGTH] = '\0'; } va_list vl; va_start(vl, format); - int len = vsnprintf(_js_log_buf, kMaxLogLen, format, vl); + int len = vsnprintf(_js_log_buf, MAX_LOG_LENGTH, format, vl); va_end(vl); if (len > 0) { @@ -1160,6 +1162,14 @@ int ScriptingCore::sendEvent(ScriptEvent* evt) return 0; } +bool ScriptingCore::parseConfig(ConfigType type, const std::string &str) +{ + jsval args[2]; + args[0] = int32_to_jsval(_cx, static_cast(type)); + args[1] = std_string_to_jsval(_cx, str); + return (JS_TRUE == executeFunctionWithOwner(OBJECT_TO_JSVAL(_global), "__onParseConfig", 2, args)); +} + #pragma mark - Debug void SimpleRunLoop::update(float dt) diff --git a/cocos/scripting/javascript/bindings/ScriptingCore.h b/cocos/scripting/javascript/bindings/ScriptingCore.h index f393824a02..fcf08fef99 100644 --- a/cocos/scripting/javascript/bindings/ScriptingCore.h +++ b/cocos/scripting/javascript/bindings/ScriptingCore.h @@ -21,20 +21,18 @@ void js_log(const char *format, ...); -using namespace cocos2d; - typedef void (*sc_register_sth)(JSContext* cx, JSObject* global); void registerDefaultClasses(JSContext* cx, JSObject* global); -class SimpleRunLoop : public Object +class SimpleRunLoop : public cocos2d::Object { public: void update(float d); }; -class ScriptingCore : public ScriptEngineProtocol +class ScriptingCore : public cocos2d::ScriptEngineProtocol { JSRuntime *_rt; JSContext *_cx; @@ -54,13 +52,13 @@ public: return pInstance; }; - virtual ccScriptType getScriptType() { return kScriptTypeJavascript; }; + virtual cocos2d::ccScriptType getScriptType() { return cocos2d::kScriptTypeJavascript; }; /** @brief Remove Object from lua state @param object to remove */ - virtual void removeScriptObjectByObject(Object* pObj); + virtual void removeScriptObjectByObject(cocos2d::Object* pObj); /** @brief Execute script code contained in the given string. @@ -87,11 +85,13 @@ public: */ virtual int executeGlobalFunction(const char* functionName) { return 0; } - virtual int sendEvent(ScriptEvent* message) override; + virtual int sendEvent(cocos2d::ScriptEvent* message) override; + + virtual bool parseConfig(ConfigType type, const std::string& str) override; virtual bool handleAssert(const char *msg) { return false; } - bool executeFunctionWithObjectData(Node *self, const char *name, JSObject *obj); + bool executeFunctionWithObjectData(cocos2d::Node *self, const char *name, JSObject *obj); JSBool executeFunctionWithOwner(jsval owner, const char *name, uint32_t argc = 0, jsval* vp = NULL, jsval* retVal = NULL); void executeJSFunctionWithThisObj(jsval thisObj, jsval callback, uint32_t argc = 0, jsval* vp = NULL, jsval* retVal = NULL); @@ -140,12 +140,12 @@ public: static void removeAllRoots(JSContext *cx); - int executeCustomTouchEvent(EventTouch::EventCode eventType, - Touch *pTouch, JSObject *obj, jsval &retval); - int executeCustomTouchEvent(EventTouch::EventCode eventType, - Touch *pTouch, JSObject *obj); - int executeCustomTouchesEvent(EventTouch::EventCode eventType, - const std::vector& touches, JSObject *obj); + int executeCustomTouchEvent(cocos2d::EventTouch::EventCode eventType, + cocos2d::Touch *pTouch, JSObject *obj, jsval &retval); + int executeCustomTouchEvent(cocos2d::EventTouch::EventCode eventType, + cocos2d::Touch *pTouch, JSObject *obj); + int executeCustomTouchesEvent(cocos2d::EventTouch::EventCode eventType, + const std::vector& touches, JSObject *obj); /** * @return the global context */ diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 2a85f14455..a33c70d7bd 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -f6783c2706a67552d6f361fa099b647158bc79ba \ No newline at end of file +16af4ad046f4db00af7a229d89c406054d8616c3 \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp b/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp index 044689a70f..e43b3804dd 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.hpp @@ -11,20 +11,20 @@ class JSScheduleWrapper; // It will prove that i'm right. :) typedef struct jsScheduleFunc_proxy { JSObject* jsfuncObj; - Array* targets; + cocos2d::Array* targets; UT_hash_handle hh; } schedFunc_proxy_t; typedef struct jsScheduleTarget_proxy { JSObject* jsTargetObj; - Array* targets; + cocos2d::Array* targets; UT_hash_handle hh; } schedTarget_proxy_t; typedef struct jsCallFuncTarget_proxy { void * ptr; - Array *obj; + cocos2d::Array *obj; UT_hash_handle hh; } callfuncTarget_proxy_t; @@ -93,7 +93,7 @@ jsval anonEvaluate(JSContext *cx, JSObject *thisObj, const char* string); void register_cocos2dx_js_extensions(JSContext* cx, JSObject* obj); -class JSCallbackWrapper: public Object { +class JSCallbackWrapper: public cocos2d::Object { public: JSCallbackWrapper(); virtual ~JSCallbackWrapper(); @@ -118,9 +118,9 @@ public: virtual ~JSScheduleWrapper(); static void setTargetForSchedule(jsval sched, JSScheduleWrapper *target); - static Array * getTargetForSchedule(jsval sched); + static cocos2d::Array * getTargetForSchedule(jsval sched); static void setTargetForJSObject(JSObject* jsTargetObj, JSScheduleWrapper *target); - static Array * getTargetForJSObject(JSObject* jsTargetObj); + static cocos2d::Array * getTargetForJSObject(JSObject* jsTargetObj); // Remove all targets. static void removeAllTargets(); @@ -157,7 +157,7 @@ protected: }; -class JSTouchDelegate: public Object +class JSTouchDelegate: public cocos2d::Object { public: JSTouchDelegate(); @@ -178,16 +178,16 @@ public: // So this function need to be binded. void unregisterTouchDelegate(); - bool onTouchBegan(Touch *touch, Event *event); - void onTouchMoved(Touch *touch, Event *event); - void onTouchEnded(Touch *touch, Event *event); - void onTouchCancelled(Touch *touch, Event *event); + bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event); + void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event); + void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event); + void onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *event); // optional - void onTouchesBegan(const std::vector& touches, Event *event); - void onTouchesMoved(const std::vector& touches, Event *event); - void onTouchesEnded(const std::vector& touches, Event *event); - void onTouchesCancelled(const std::vector& touches, Event *event); + void onTouchesBegan(const std::vector& touches, cocos2d::Event *event); + void onTouchesMoved(const std::vector& touches, cocos2d::Event *event); + void onTouchesEnded(const std::vector& touches, cocos2d::Event *event); + void onTouchesCancelled(const std::vector& touches, cocos2d::Event *event); private: JSObject* _obj; @@ -195,8 +195,8 @@ private: typedef std::pair TouchDelegatePair; static TouchDelegateMap sTouchDelegateMap; bool _needUnroot; - EventListenerTouchOneByOne* _touchListenerOneByOne; - EventListenerTouchAllAtOnce* _touchListenerAllAtOnce; + cocos2d::EventListenerTouchOneByOne* _touchListenerOneByOne; + cocos2d::EventListenerTouchAllAtOnce* _touchListenerAllAtOnce; }; diff --git a/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp b/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp index 183da6c04b..b50022aba9 100644 --- a/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp +++ b/cocos/scripting/javascript/bindings/cocostudio/jsb_cocos2dx_studio_manual.cpp @@ -16,8 +16,8 @@ public: virtual void setJSCallbackThis(jsval thisObj); - void movementCallbackFunc(cocostudio::Armature * pArmature, cocostudio::MovementEventType pMovementEventType, const char *pMovementId); - void frameCallbackFunc(cocostudio::Bone *pBone, const char *frameEventName, int originFrameIndex, int currentFrameIndex); + void movementCallbackFunc(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID); + void frameCallbackFunc(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex); void addArmatureFileInfoAsyncCallbackFunc(float percent); private: @@ -54,18 +54,18 @@ void JSArmatureWrapper::setJSCallbackThis(jsval _jsThisObj) } } -void JSArmatureWrapper::movementCallbackFunc(cocostudio::Armature *pArmature, cocostudio::MovementEventType pMovementEventType, const char *pMovementId) +void JSArmatureWrapper::movementCallbackFunc(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID) { JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); - js_proxy_t *proxy = js_get_or_create_proxy(cx, pArmature); + js_proxy_t *proxy = js_get_or_create_proxy(cx, armature); jsval retval; if (_jsCallback != JSVAL_VOID) { - int movementEventType = (int)pMovementEventType; + int movementEventType = (int)movementType; jsval movementVal = INT_TO_JSVAL(movementEventType); - jsval idVal = c_string_to_jsval(cx, pMovementId); + jsval idVal = std_string_to_jsval(cx, movementID); jsval valArr[3]; valArr[0] = OBJECT_TO_JSVAL(proxy->obj); @@ -100,17 +100,17 @@ void JSArmatureWrapper::addArmatureFileInfoAsyncCallbackFunc(float percent) } -void JSArmatureWrapper::frameCallbackFunc(cocostudio::Bone *pBone, const char *frameEventName, int originFrameIndex, int currentFrameIndex) +void JSArmatureWrapper::frameCallbackFunc(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex) { JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET JSContext *cx = ScriptingCore::getInstance()->getGlobalContext(); JSObject *thisObj = JSVAL_IS_VOID(_jsThisObj) ? NULL : JSVAL_TO_OBJECT(_jsThisObj); - js_proxy_t *proxy = js_get_or_create_proxy(cx, pBone); + js_proxy_t *proxy = js_get_or_create_proxy(cx, bone); jsval retval; if (_jsCallback != JSVAL_VOID) { - jsval nameVal = c_string_to_jsval(cx, frameEventName); + jsval nameVal = std_string_to_jsval(cx, evt); jsval originIndexVal = INT_TO_JSVAL(originFrameIndex); jsval currentIndexVal = INT_TO_JSVAL(currentFrameIndex); @@ -144,8 +144,8 @@ static JSBool js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(JSContext * tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); - cobj->setMovementEventCallFunc(tmpObj, movementEvent_selector(JSArmatureWrapper::movementCallbackFunc)); - + cobj->setMovementEventCallFunc(CC_CALLBACK_0(JSArmatureWrapper::movementCallbackFunc, tmpObj, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + return JS_TRUE; } JS_ReportError(cx, "Invalid number of arguments"); @@ -169,7 +169,7 @@ static JSBool js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(JSContext *cx, tmpObj->setJSCallbackFunc(argv[0]); tmpObj->setJSCallbackThis(argv[1]); - cobj->setFrameEventCallFunc(tmpObj, frameEvent_selector(JSArmatureWrapper::frameCallbackFunc)); + cobj->setFrameEventCallFunc(CC_CALLBACK_0(JSArmatureWrapper::frameCallbackFunc, tmpObj, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); return JS_TRUE; } @@ -227,11 +227,49 @@ static JSBool jsb_Animation_addArmatureFileInfoAsyncCallFunc(JSContext *cx, uint return JS_FALSE; } +JSBool js_cocos2dx_studio_ColliderBody_getCalculatedVertexList(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocostudio::ColliderBody* cobj = (cocostudio::ColliderBody *)(proxy ? proxy->ptr : nullptr); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 0) { + const std::vector& ret = cobj->getCalculatedVertexList(); + JSObject *jsretArr = JS_NewArrayObject(cx, 0, nullptr); + jsval jsret; + //CCObject* obj; + int i = 0; + for(std::vector::const_iterator it = ret.begin(); it != ret.end(); it++) + { + const cocos2d::Point& point = *it; + JSObject *tmp = JS_NewObject(cx, NULL, NULL, NULL); + if (!tmp) break; + JSBool ok = JS_DefineProperty(cx, tmp, "x", DOUBLE_TO_JSVAL(point.x), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && + JS_DefineProperty(cx, tmp, "y", DOUBLE_TO_JSVAL(point.y), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + jsval jsTmp = OBJECT_TO_JSVAL(tmp); + if(!ok || !JS_SetElement(cx, jsretArr, i, &jsTmp)) + { + break; + } + ++i; + } + jsret = OBJECT_TO_JSVAL(jsretArr); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return JS_FALSE; +} + extern JSObject* jsb_cocostudio_ArmatureAnimation_prototype; extern JSObject* jsb_cocostudio_ArmatureDataManager_prototype; +extern JSObject* jsb_cocostudio_ColliderBody_prototype; void register_all_cocos2dx_studio_manual(JSContext* cx, JSObject* global) { + JS_DefineFunction(cx, jsb_cocostudio_ColliderBody_prototype, "getCalculatedVertexList", js_cocos2dx_studio_ColliderBody_getCalculatedVertexList, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_cocostudio_ArmatureAnimation_prototype, "setMovementEventCallFunc", js_cocos2dx_ArmatureAnimation_setMovementEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_cocostudio_ArmatureAnimation_prototype, "setFrameEventCallFunc", js_cocos2dx_ArmatureAnimation_setFrameEventCallFunc, 2, JSPROP_ENUMERATE | JSPROP_PERMANENT); diff --git a/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp index 6deed71add..e98e062ad6 100644 --- a/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/javascript/bindings/extension/jsb_cocos2dx_extension_manual.cpp @@ -33,7 +33,7 @@ public: } } - virtual void scrollViewDidScroll(ScrollView* view) + virtual void scrollViewDidScroll(ScrollView* view) override { js_proxy_t * p = jsb_get_native_proxy(view); if (!p) return; @@ -42,7 +42,7 @@ public: ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "scrollViewDidScroll", 1, &arg, NULL); } - virtual void scrollViewDidZoom(ScrollView* view) + virtual void scrollViewDidZoom(ScrollView* view) override { js_proxy_t * p = jsb_get_native_proxy(view); if (!p) return; @@ -119,32 +119,32 @@ public: } } - virtual void scrollViewDidScroll(ScrollView* view) + virtual void scrollViewDidScroll(ScrollView* view) override { callJSDelegate(view, "scrollViewDidScroll"); } - virtual void scrollViewDidZoom(ScrollView* view) + virtual void scrollViewDidZoom(ScrollView* view) override { callJSDelegate(view, "scrollViewDidZoom"); } - virtual void tableCellTouched(TableView* table, TableViewCell* cell) + virtual void tableCellTouched(TableView* table, TableViewCell* cell) override { callJSDelegate(table, cell, "tableCellTouched"); } - virtual void tableCellHighlight(TableView* table, TableViewCell* cell) + virtual void tableCellHighlight(TableView* table, TableViewCell* cell) override { callJSDelegate(table, cell, "tableCellHighlight"); } - virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) + virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) override { callJSDelegate(table, cell, "tableCellUnhighlight"); } - virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) + virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) override { callJSDelegate(table, cell, "tableCellWillRecycle"); } @@ -248,7 +248,7 @@ public: } } - virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) + virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) override { jsval ret; bool ok = callJSDelegate(table, idx, "tableCellSizeForIndex", ret); @@ -268,7 +268,7 @@ public: } - virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) + virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) override { jsval ret; bool ok = callJSDelegate(table, idx, "tableCellAtIndex", ret); @@ -288,7 +288,7 @@ public: return NULL; } - virtual ssize_t numberOfCellsInTableView(TableView *table) + virtual ssize_t numberOfCellsInTableView(TableView *table) override { jsval ret; bool ok = callJSDelegate(table, "numberOfCellsInTableView", ret); @@ -508,7 +508,7 @@ public: } } - virtual void editBoxEditingDidBegin(EditBox* editBox) + virtual void editBoxEditingDidBegin(EditBox* editBox) override { js_proxy_t * p = jsb_get_native_proxy(editBox); if (!p) return; @@ -517,7 +517,7 @@ public: ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidBegin", 1, &arg, NULL); } - virtual void editBoxEditingDidEnd(EditBox* editBox) + virtual void editBoxEditingDidEnd(EditBox* editBox) override { js_proxy_t * p = jsb_get_native_proxy(editBox); if (!p) return; @@ -526,7 +526,7 @@ public: ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxEditingDidEnd", 1, &arg, NULL); } - virtual void editBoxTextChanged(EditBox* editBox, const std::string& text) + virtual void editBoxTextChanged(EditBox* editBox, const std::string& text) override { js_proxy_t * p = jsb_get_native_proxy(editBox); if (!p) return; @@ -539,7 +539,7 @@ public: ScriptingCore::getInstance()->executeFunctionWithOwner(OBJECT_TO_JSVAL(_JSDelegate), "editBoxTextChanged", 2, dataVal, NULL); } - virtual void editBoxReturn(EditBox* editBox) + virtual void editBoxReturn(EditBox* editBox) override { js_proxy_t * p = jsb_get_native_proxy(editBox); if (!p) return; diff --git a/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp b/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp index 1e1f3a0aa5..e0832bc2ba 100644 --- a/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp +++ b/cocos/scripting/javascript/bindings/gui/jsb_cocos2dx_gui_manual.cpp @@ -9,7 +9,8 @@ #include "cocos2d_specifics.hpp" #include "gui/CocosGUI.h" -using namespace gui; +using namespace cocos2d; +using namespace cocos2d::gui; class JSStudioEventListenerWrapper: public JSCallbackWrapper { public: diff --git a/cocos/scripting/javascript/bindings/js_manual_conversions.cpp b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp index fe3c22d985..5a9bc016ba 100644 --- a/cocos/scripting/javascript/bindings/js_manual_conversions.cpp +++ b/cocos/scripting/javascript/bindings/js_manual_conversions.cpp @@ -1197,9 +1197,13 @@ JSBool jsval_to_ccvaluevector(JSContext* cx, jsval v, cocos2d::ValueVector* ret) return JS_TRUE; } -JSBool jsval_to_ssize( JSContext *cx, jsval vp, ssize_t* ret) +JSBool jsval_to_ssize( JSContext *cx, jsval vp, ssize_t* size) { - return jsval_to_long(cx, vp, reinterpret_cast(ret)); + JSBool ret = JS_FALSE; + int32_t sizeInt32 = 0; + ret = jsval_to_int32(cx, vp, &sizeInt32); + *size = sizeInt32; + return ret; } JSBool jsval_to_std_vector_string( JSContext *cx, jsval vp, std::vector* ret) @@ -1270,7 +1274,7 @@ JSBool jsval_to_std_vector_int( JSContext *cx, jsval vp, std::vector* ret) // native --> jsval -jsval ccarray_to_jsval(JSContext* cx, Array *arr) +jsval ccarray_to_jsval(JSContext* cx, __Array *arr) { JSObject *jsretArr = JS_NewArrayObject(cx, 0, NULL); @@ -1286,27 +1290,27 @@ jsval ccarray_to_jsval(JSContext* cx, Array *arr) arrElement = OBJECT_TO_JSVAL(jsproxy->obj); } else { - String* strVal = NULL; - Dictionary* dictVal = NULL; - Array* arrVal = NULL; - Double* doubleVal = NULL; - Bool* boolVal = NULL; - Float* floatVal = NULL; - Integer* intVal = NULL; + __String* strVal = NULL; + __Dictionary* dictVal = NULL; + __Array* arrVal = NULL; + __Double* doubleVal = NULL; + __Bool* boolVal = NULL; + __Float* floatVal = NULL; + __Integer* intVal = NULL; - if ((strVal = dynamic_cast(obj))) { + if ((strVal = dynamic_cast(obj))) { arrElement = c_string_to_jsval(cx, strVal->getCString()); - } else if ((dictVal = dynamic_cast(obj))) { + } else if ((dictVal = dynamic_cast(obj))) { arrElement = ccdictionary_to_jsval(cx, dictVal); - } else if ((arrVal = dynamic_cast(obj))) { + } else if ((arrVal = dynamic_cast(obj))) { arrElement = ccarray_to_jsval(cx, arrVal); - } else if ((doubleVal = dynamic_cast(obj))) { + } else if ((doubleVal = dynamic_cast<__Double*>(obj))) { arrElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); - } else if ((floatVal = dynamic_cast(obj))) { + } else if ((floatVal = dynamic_cast<__Float*>(obj))) { arrElement = DOUBLE_TO_JSVAL(floatVal->getValue()); - } else if ((intVal = dynamic_cast(obj))) { + } else if ((intVal = dynamic_cast<__Integer*>(obj))) { arrElement = INT_TO_JSVAL(intVal->getValue()); - } else if ((boolVal = dynamic_cast(obj))) { + } else if ((boolVal = dynamic_cast<__Bool*>(obj))) { arrElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); } else { CCASSERT(false, "the type isn't suppored."); @@ -1320,7 +1324,7 @@ jsval ccarray_to_jsval(JSContext* cx, Array *arr) return OBJECT_TO_JSVAL(jsretArr); } -jsval ccdictionary_to_jsval(JSContext* cx, Dictionary* dict) +jsval ccdictionary_to_jsval(JSContext* cx, __Dictionary* dict) { JSObject* jsRet = JS_NewObject(cx, NULL, NULL, NULL); DictElement* pElement = NULL; @@ -1334,27 +1338,27 @@ jsval ccdictionary_to_jsval(JSContext* cx, Dictionary* dict) dictElement = OBJECT_TO_JSVAL(jsproxy->obj); } else { - String* strVal = NULL; - Dictionary* dictVal = NULL; - Array* arrVal = NULL; - Double* doubleVal = NULL; - Bool* boolVal = NULL; - Float* floatVal = NULL; - Integer* intVal = NULL; + __String* strVal = NULL; + __Dictionary* dictVal = NULL; + __Array* arrVal = NULL; + __Double* doubleVal = NULL; + __Bool* boolVal = NULL; + __Float* floatVal = NULL; + __Integer* intVal = NULL; - if ((strVal = dynamic_cast(obj))) { + if ((strVal = dynamic_cast(obj))) { dictElement = c_string_to_jsval(cx, strVal->getCString()); - } else if ((dictVal = dynamic_cast(obj))) { + } else if ((dictVal = dynamic_cast<__Dictionary*>(obj))) { dictElement = ccdictionary_to_jsval(cx, dictVal); - } else if ((arrVal = dynamic_cast(obj))) { + } else if ((arrVal = dynamic_cast<__Array*>(obj))) { dictElement = ccarray_to_jsval(cx, arrVal); - } else if ((doubleVal = dynamic_cast(obj))) { + } else if ((doubleVal = dynamic_cast<__Double*>(obj))) { dictElement = DOUBLE_TO_JSVAL(doubleVal->getValue()); - } else if ((floatVal = dynamic_cast(obj))) { + } else if ((floatVal = dynamic_cast<__Float*>(obj))) { dictElement = DOUBLE_TO_JSVAL(floatVal->getValue()); - } else if ((intVal = dynamic_cast(obj))) { + } else if ((intVal = dynamic_cast<__Integer*>(obj))) { dictElement = INT_TO_JSVAL(intVal->getValue()); - } else if ((boolVal = dynamic_cast(obj))) { + } else if ((boolVal = dynamic_cast<__Bool*>(obj))) { dictElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE); } else { CCASSERT(false, "the type isn't suppored."); @@ -1369,7 +1373,7 @@ jsval ccdictionary_to_jsval(JSContext* cx, Dictionary* dict) return OBJECT_TO_JSVAL(jsRet); } -JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, Dictionary** ret) +JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, __Dictionary** ret) { if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) { @@ -1384,7 +1388,7 @@ JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, Dictionary** ret) } JSObject* it = JS_NewPropertyIterator(cx, tmp); - Dictionary* dict = NULL; + __Dictionary* dict = NULL; while (true) { @@ -1404,7 +1408,7 @@ JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, Dictionary** ret) JSStringWrapper keyWrapper(JSVAL_TO_STRING(key), cx); if (!dict) { - dict = Dictionary::create(); + dict = __Dictionary::create(); } JS::RootedValue value(cx); @@ -1423,7 +1427,7 @@ JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, Dictionary** ret) } else if (!JS_IsArrayObject(cx, tmp)){ // It's a normal js object. - Dictionary* dictVal = NULL; + __Dictionary* dictVal = NULL; JSBool ok = jsval_to_ccdictionary(cx, value, &dictVal); if (ok) { dict->setObject(dictVal, keyWrapper.get()); @@ -1431,7 +1435,7 @@ JSBool jsval_to_ccdictionary(JSContext* cx, jsval v, Dictionary** ret) } else { // It's a js array object. - Array* arrVal = NULL; + __Array* arrVal = NULL; JSBool ok = jsval_to_ccarray(cx, value, &arrVal); if (ok) { dict->setObject(arrVal, keyWrapper.get()); @@ -2192,5 +2196,6 @@ jsval ccvaluevector_to_jsval(JSContext* cx, const cocos2d::ValueVector& v) jsval ssize_to_jsval(JSContext *cx, ssize_t v) { - return long_to_jsval(cx, v); + CCASSERT(v < INT_MAX, "The size should not bigger than 32 bit (int32_t)."); + return int32_to_jsval(cx, static_cast(v)); } diff --git a/cocos/scripting/javascript/bindings/js_manual_conversions.h b/cocos/scripting/javascript/bindings/js_manual_conversions.h index 751cd995ee..4820c13bea 100644 --- a/cocos/scripting/javascript/bindings/js_manual_conversions.h +++ b/cocos/scripting/javascript/bindings/js_manual_conversions.h @@ -224,8 +224,8 @@ jsval ccsize_to_jsval(JSContext* cx, const cocos2d::Size& v); jsval cccolor4b_to_jsval(JSContext* cx, const cocos2d::Color4B& v); jsval cccolor4f_to_jsval(JSContext* cx, const cocos2d::Color4F& v); jsval cccolor3b_to_jsval(JSContext* cx, const cocos2d::Color3B& v); -jsval ccdictionary_to_jsval(JSContext* cx, cocos2d::Dictionary *dict); -jsval ccarray_to_jsval(JSContext* cx, cocos2d::Array *arr); +jsval ccdictionary_to_jsval(JSContext* cx, cocos2d::__Dictionary *dict); +jsval ccarray_to_jsval(JSContext* cx, cocos2d::__Array *arr); jsval ccacceleration_to_jsval(JSContext* cx, const cocos2d::Acceleration& v); jsval ccaffinetransform_to_jsval(JSContext* cx, const cocos2d::AffineTransform& t); jsval FontDefinition_to_jsval(JSContext* cx, const cocos2d::FontDefinition& t); diff --git a/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp index 71657fe7e5..6581d93205 100644 --- a/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp +++ b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.cpp @@ -167,22 +167,20 @@ void MinXmlHttpRequest::_setHttpRequestHeader() * @param sender Object which initialized callback * @param respone Response object */ -void MinXmlHttpRequest::handle_requestResponse(network::HttpClient *sender, network::HttpResponse *response) +void MinXmlHttpRequest::handle_requestResponse(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response) { if (0 != strlen(response->getHttpRequest()->getTag())) { CCLOG("%s completed", response->getHttpRequest()->getTag()); } - int statusCode = response->getResponseCode(); - char statusString[64] = {}; - sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag()); + long statusCode = response->getResponseCode(); + char statusString[64] = {0}; + sprintf(statusString, "HTTP Status Code: %ld, tag = %s", statusCode, response->getHttpRequest()->getTag()); if (!response->isSucceed()) { - CCLOG("response failed"); - CCLOG("error buffer: %s", response->getErrorBuffer()); - return; + CCLOG("Response failed, error buffer: %s", response->getErrorBuffer()); } // set header @@ -207,7 +205,7 @@ void MinXmlHttpRequest::handle_requestResponse(network::HttpClient *sender, netw _status = 200; _readyState = DONE; - _dataSize = buffer->size(); + _dataSize = static_cast(buffer->size()); CC_SAFE_FREE(_data); _data = (char*) malloc(_dataSize + 1); _data[_dataSize] = '\0'; @@ -247,7 +245,7 @@ void MinXmlHttpRequest::handle_requestResponse(network::HttpClient *sender, netw void MinXmlHttpRequest::_sendRequest(JSContext *cx) { _httpRequest->setResponseCallback(this, httpresponse_selector(MinXmlHttpRequest::handle_requestResponse)); - network::HttpClient::getInstance()->send(_httpRequest); + cocos2d::network::HttpClient::getInstance()->send(_httpRequest); _httpRequest->release(); } @@ -264,7 +262,7 @@ MinXmlHttpRequest::MinXmlHttpRequest() _requestHeader.clear(); _withCredentialsValue = true; _cx = ScriptingCore::getInstance()->getGlobalContext(); - _httpRequest = new network::HttpRequest(); + _httpRequest = new cocos2d::network::HttpRequest(); } /** @@ -546,17 +544,23 @@ JS_BINDED_PROP_SET_IMPL(MinXmlHttpRequest, withCredentials) */ JS_BINDED_PROP_GET_IMPL(MinXmlHttpRequest, responseText) { - jsval strVal = std_string_to_jsval(cx, _data); - - if (strVal != JSVAL_NULL) + if (_data) { - vp.set(strVal); - //JS_ReportError(cx, "Result: %s", data.str().c_str()); - return JS_TRUE; - } else { - JS_ReportError(cx, "Error trying to create JSString from data"); - return JS_FALSE; + jsval strVal = std_string_to_jsval(cx, _data); + + if (strVal != JSVAL_NULL) + { + vp.set(strVal); + return JS_TRUE; + } } + + CCLOGERROR("ResponseText was empty, probably there is a network error!"); + + // Return an empty string + vp.set(std_string_to_jsval(cx, "")); + + return JS_TRUE; } /** @@ -627,11 +631,11 @@ JS_BINDED_FUNC_IMPL(MinXmlHttpRequest, open) if (_meth.compare("post") == 0 || _meth.compare("POST") == 0) { - _httpRequest->setRequestType(network::HttpRequest::Type::POST); + _httpRequest->setRequestType(cocos2d::network::HttpRequest::Type::POST); } else { - _httpRequest->setRequestType(network::HttpRequest::Type::GET); + _httpRequest->setRequestType(cocos2d::network::HttpRequest::Type::GET); } _httpRequest->setUrl(_url.c_str()); diff --git a/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h index e5e26c41b1..b04633e842 100644 --- a/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h +++ b/cocos/scripting/javascript/bindings/network/XMLHTTPRequest.h @@ -80,7 +80,7 @@ public: JS_BINDED_FUNC(MinXmlHttpRequest, setRequestHeader); JS_BINDED_FUNC(MinXmlHttpRequest, overrideMimeType); - void handle_requestResponse(network::HttpClient *sender, network::HttpResponse *response); + void handle_requestResponse(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response); private: @@ -102,7 +102,7 @@ private: ResponseType _responseType; unsigned _timeout; bool _isAsync; - network::HttpRequest* _httpRequest; + cocos2d::network::HttpRequest* _httpRequest; bool _isNetwork; bool _withCredentialsValue; std::unordered_map _httpHeader; diff --git a/cocos/scripting/javascript/bindings/network/jsb_websocket.cpp b/cocos/scripting/javascript/bindings/network/jsb_websocket.cpp index ae3b1c64ce..4eb0c29ad1 100644 --- a/cocos/scripting/javascript/bindings/network/jsb_websocket.cpp +++ b/cocos/scripting/javascript/bindings/network/jsb_websocket.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. #include "ScriptingCore.h" #include "cocos2d_specifics.hpp" -using namespace network; +using namespace cocos2d::network; /* [Constructor(in DOMString url, in optional DOMString protocols)] diff --git a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj index e959aa34a6..a4cbbd4d50 100644 --- a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj +++ b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj @@ -12,7 +12,6 @@ - @@ -24,7 +23,6 @@ - diff --git a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters index 13bcceb35b..85bb2eccd3 100644 --- a/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters +++ b/cocos/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj.filters @@ -41,9 +41,6 @@ generated - - generated - @@ -82,9 +79,6 @@ generated - - generated - diff --git a/cocos/scripting/javascript/bindings/spine/Android.mk b/cocos/scripting/javascript/bindings/spine/Android.mk new file mode 100644 index 0000000000..033e557db2 --- /dev/null +++ b/cocos/scripting/javascript/bindings/spine/Android.mk @@ -0,0 +1,29 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := jsb_spine_static + +LOCAL_MODULE_FILENAME := libcocos2dxjsbspine + +LOCAL_SRC_FILES := ../../../auto-generated/js-bindings/jsb_cocos2dx_spine_auto.cpp + + +LOCAL_CFLAGS := -DCOCOS2D_JAVASCRIPT + +LOCAL_EXPORT_CFLAGS := -DCOCOS2D_JAVASCRIPT + +LOCAL_C_INCLUDES := $(LOCAL_PATH) \ + $(LOCAL_PATH)/../../../../editor-support/spine + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) + +LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jsb_static +LOCAL_WHOLE_STATIC_LIBRARIES += spine_static + +include $(BUILD_STATIC_LIBRARY) + +$(call import-module,spidermonkey/prebuilt/android) +$(call import-module,scripting/javascript/bindings) +$(call import-module,editor-support/spine) diff --git a/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj b/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj new file mode 100644 index 0000000000..13f9b1c4c1 --- /dev/null +++ b/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj @@ -0,0 +1,117 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + {E78CDC6B-F37D-48D2-AD91-1DB549497E32} + Win32Proj + libJSBindingForSpine + + + + StaticLibrary + true + Unicode + v100 + v110 + v110_xp + + + StaticLibrary + false + Unicode + v100 + v110 + v110_xp + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + $(SolutionDir)$(Configuration).win32\ + + + $(Configuration).win32\ + + + + + + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;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) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + false + OldStyle + + + Windows + true + + + + + + + + + Level3 + + + MaxSpeed + 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) + $(ProjectDir)..;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\scripting\auto-generated\js-bindings;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)cocos\audio\include;%(AdditionalIncludeDirectories) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) + true + + + Windows + true + true + true + + + + + + + + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj.filters b/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj.filters new file mode 100644 index 0000000000..5f6eb93a21 --- /dev/null +++ b/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj.filters @@ -0,0 +1,28 @@ + + + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + + + generated + + + + + generated + + + + + generated + + + \ No newline at end of file diff --git a/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj.user b/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj.user new file mode 100644 index 0000000000..3f03091124 --- /dev/null +++ b/cocos/scripting/javascript/bindings/spine/libJSBindingForSpine.vcxproj.user @@ -0,0 +1,6 @@ + + + + false + + \ No newline at end of file diff --git a/cocos/scripting/javascript/script/jsb_cocos2d.js b/cocos/scripting/javascript/script/jsb_cocos2d.js index 5021ed2bf4..3237113d99 100644 --- a/cocos/scripting/javascript/script/jsb_cocos2d.js +++ b/cocos/scripting/javascript/script/jsb_cocos2d.js @@ -142,8 +142,34 @@ cc.log = cc._cocosplayerLog || cc.log || log; // cc.c3b = function( r, g, b ) { - return {r:r, g:g, b:b }; + switch (arguments.length) { + case 0: + return {r:0, g:0, b:0 }; + case 1: + if (r && r instanceof cc.c3b) { + return {r:r.r, g:r.g, b:r.b }; + } else { + return {r:0, g:0, b:0 }; + } + case 3: + return {r:r, g:g, b:b }; + default: + throw "unknown argument type"; + break; + } }; + +cc.integerToColor3B = function (intValue) { + intValue = intValue || 0; + + var offset = 0xff; + var retColor = {r:0, g:0, b:0 }; + retColor.r = intValue & (offset); + retColor.g = (intValue >> 8) & offset; + retColor.b = (intValue >> 16) & offset; + return retColor; +}; + cc._c3b = function( r, g, b ) { cc._reuse_color3b.r = r; @@ -152,6 +178,46 @@ cc._c3b = function( r, g, b ) return cc._reuse_color3b; }; +cc.c3BEqual = function(color1, color2){ + return color1.r === color2.r && color1.g === color2.g && color1.b === color2.b; +}; + +cc.white = function () { + return cc.c3b(255, 255, 255); +}; + +cc.yellow = function () { + return cc.c3b(255, 255, 0); +}; + +cc.blue = function () { + return cc.c3b(0, 0, 255); +}; + +cc.green = function () { + return cc.c3b(0, 255, 0); +}; + +cc.red = function () { + return cc.c3b(255, 0, 0); +}; + +cc.magenta = function () { + return cc.c3b(255, 0, 255); +}; + +cc.black = function () { + return cc.c3b(0, 0, 0); +}; + +cc.orange = function () { + return cc.c3b(255, 127, 0); +}; + +cc.gray = function () { + return cc.c3b(166, 166, 166); +}; + // // Color 4B // @@ -193,6 +259,22 @@ cc.c4f = function( r, g, b, a ) return {r:r, g:g, b:b, a:a }; }; +cc.c4FFromccc3B = function (c) { + return cc.c4f(c.r / 255.0, c.g / 255.0, c.b / 255.0, 1.0); +}; + +cc.c4FFromccc4B = function (c) { + return cc.c4f(c.r / 255.0, c.g / 255.0, c.b / 255.0, c.a / 255.0); +}; + +cc.c4BFromccc4F = function (c) { + return cc.c4f(0 | (c.r * 255), 0 | (c.g * 255), 0 | (c.b * 255), 0 | (c.a * 255)); +}; + +cc.c4FEqual = function (a, b) { + return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a; +}; + // // Point // @@ -568,8 +650,12 @@ cc.Class.extend = function (prop) { // The dummy class constructor function Class() { // All construction is actually done in the init method - if (!initializing && this.ctor) - this.ctor.apply(this, arguments); + if (!initializing) { + if (!this.ctor) + cc.log("No ctor function found, please set `classes_need_extend` section at `ini` file as `tools/tojs/cocos2dx.ini`"); + else + this.ctor.apply(this, arguments); + } } // Populate our constructed prototype object @@ -613,4 +699,122 @@ cc.Loader.preload = function (resources, selector, target) { return this._instance; }; -cc.LoaderScene = cc.Loader; \ No newline at end of file +cc.LoaderScene = cc.Loader; + +var ConfigType = { + NONE: 0, + COCOSTUDIO: 1 +}; + +var __onParseConfig = function(type, str) { + if (type === ConfigType.COCOSTUDIO) { + ccs.TriggerMng.getInstance().parse(JSON.parse(str)); + } +}; + +cc.VisibleRect = { + _topLeft:cc.p(0,0), + _topRight:cc.p(0,0), + _top:cc.p(0,0), + _bottomLeft:cc.p(0,0), + _bottomRight:cc.p(0,0), + _bottom:cc.p(0,0), + _center:cc.p(0,0), + _left:cc.p(0,0), + _right:cc.p(0,0), + _width:0, + _height:0, + _isInitialized: false, + init:function(){ + var director = cc.Director.getInstance(); + var origin = director.getVisibleOrigin(); + var size = director.getVisibleSize(); + + this._width = size.width; + this._height = size.height; + + var x = origin.x; + var y = origin.y; + var w = this._width; + var h = this._height; + + var left = origin.x; + var right = origin.x + size.width; + var middle = origin.x + size.width/2; + + //top + this._top.y = this._topLeft.y = this._topRight.y = y + h; + this._topLeft.x = left; + this._top.x = middle; + this._topRight.x = right; + + //bottom + + this._bottom.y = this._bottomRight.y = this._bottomLeft.y = y; + this._bottomLeft.x = left + this._bottom.x = middle; + this._bottomRight.x = right; + + //center + this._right.y = this._left.y = this._center.y = y + h/2; + this._center.x = middle; + + //left + this._left.x = left; + + //right + this._right.x = right; + }, + + lazyInit: function(){ + if (!this._isInitialized) { + this.init(); + this._isInitialized = true; + } + }, + getWidth:function(){ + this.lazyInit(); + return this._width; + }, + getHeight:function(){ + this.lazyInit(); + return this._height; + }, + topLeft:function(){ + this.lazyInit(); + return this._topLeft; + }, + topRight:function(){ + this.lazyInit(); + return this._topRight; + }, + top:function(){ + this.lazyInit(); + return this._top; + }, + bottomLeft:function(){ + this.lazyInit(); + return this._bottomLeft; + }, + bottomRight:function(){ + this.lazyInit(); + return this._bottomRight; + }, + bottom:function(){ + this.lazyInit(); + return this._bottom; + }, + center:function(){ + this.lazyInit(); + return this._center; + }, + left:function(){ + this.lazyInit(); + return this._left; + }, + right:function(){ + this.lazyInit(); + return this._right; + } +}; + diff --git a/cocos/scripting/javascript/script/jsb_cocos2d_gui.js b/cocos/scripting/javascript/script/jsb_cocos2d_gui.js index 7c607082b4..c9cc826a75 100644 --- a/cocos/scripting/javascript/script/jsb_cocos2d_gui.js +++ b/cocos/scripting/javascript/script/jsb_cocos2d_gui.js @@ -4,73 +4,73 @@ // This helper file should be required after jsb_cocos2d.js // -var ccs = ccs || {}; +var ccui = ccui || {}; -ccs.BrightStyle = { +ccui.BrightStyle = { none: -1, normal: 0, highlight: 1 }; -ccs.WidgetType = { +ccui.WidgetType = { widget: 0, //control container: 1 //container }; -ccs.TextureResType = { +ccui.TextureResType = { local: 0, plist: 1 }; -ccs.TouchEventType = { +ccui.TouchEventType = { began: 0, moved: 1, ended: 2, canceled: 3 }; -ccs.SizeType = { +ccui.SizeType = { absolute: 0, percent: 1 }; -ccs.PositionType = { +ccui.PositionType = { absolute: 0, percent: 1 }; -ccs.CheckBoxEventType = { +ccui.CheckBoxEventType = { selected: 0, unselected: 1 }; -ccs.TextFiledEventType = { +ccui.TextFiledEventType = { attach_with_me: 0, detach_with_ime: 1, insert_text: 2, delete_backward: 3 }; -ccs.LayoutBackGroundColorType = { +ccui.LayoutBackGroundColorType = { none: 0, solid: 1, gradient: 2 }; -ccs.LayoutType = { +ccui.LayoutType = { absolute: 0, linearVertical: 1, linearHorizontal: 2, relative: 3 }; -ccs.UILayoutParameterType = { +ccui.LayoutParameterType = { none: 0, linear: 1, relative: 2 }; -ccs.UILinearGravity = { +ccui.LinearGravity = { none: 0, left: 1, top: 2, @@ -80,7 +80,7 @@ ccs.UILinearGravity = { centerHorizontal: 6 }; -ccs.UIRelativeAlign = { +ccui.RelativeAlign = { alignNone: 0, alignParentTopLeft: 1, alignParentTopCenterHorizontal: 2, @@ -105,18 +105,18 @@ ccs.UIRelativeAlign = { locationBelowRightAlign: 21 }; -ccs.SliderEventType = {percent_changed: 0}; +ccui.SliderEventType = {percent_changed: 0}; -ccs.LoadingBarType = { left: 0, right: 1}; +ccui.LoadingBarType = { left: 0, right: 1}; -ccs.ScrollViewDir = { +ccui.ScrollViewDir = { none: 0, vertical: 1, horizontal: 2, both: 3 }; -ccs.ScrollviewEventType = { +ccui.ScrollviewEventType = { scrollToTop: 0, scrollToBottom: 1, scrollToLeft: 2, @@ -128,30 +128,30 @@ ccs.ScrollviewEventType = { bounceRight: 8 }; -ccs.ListViewEventType = { +ccui.ListViewEventType = { init_child: 0, update_child: 1 }; -ccs.PageViewEventType = { +ccui.ListViewGravity = { + left: 0, + right: 1, + centerHorizontal: 2, + top: 3, + bottom: 4, + centerVertical: 5 +}; + +ccui.PageViewEventType = { turning: 0 }; -ccs.PVTouchDir = { +ccui.PVTouchDir = { touchLeft: 0, touchRight: 1 }; -ccs.UIPanel = ccs.UILayout; -ccs.UITextArea = ccs.UILabel; -ccs.UIContainerWidget = ccs.UILayout; -ccs.UITextButton = ccs.UIButton; -ccs.UINodeContainer = ccs.UIWidget; -ccs.PanelColorType = ccs.LayoutBackGroundColorType; - -ccs.UILayout = ccs.Layout; - -ccs.UIMargin = cc.Class.extend({ +ccui.Margin = cc.Class.extend({ left: 0, top: 0, right: 0, diff --git a/cocos/scripting/javascript/script/jsb_cocos2d_studio.js b/cocos/scripting/javascript/script/jsb_cocos2d_studio.js index fadd914f00..a866f85e7b 100644 --- a/cocos/scripting/javascript/script/jsb_cocos2d_studio.js +++ b/cocos/scripting/javascript/script/jsb_cocos2d_studio.js @@ -6,6 +6,8 @@ var ccs = ccs || {}; +ccs.Class = ccs.Class || cc.Class || {}; + //movement event type ccs.MovementEventType = { start: 0, @@ -25,3 +27,420 @@ if(ccs.Armature){ ccs.ComController.extend = cc.Class.extend; ccs.Armature.extend = cc.Class.extend; } + + +ccs.sendEvent = function (event) { + var triggerObjArr = ccs.TriggerMng.getInstance().get(event); + if (triggerObjArr == null) { + return; + } + for (var i = 0; i < triggerObjArr.length; i++) { + var triObj = triggerObjArr[i]; + if (triObj != null && triObj.detect()) { + triObj.done(); + } + } +}; + + +ccs.ObjectFactory = ccs.Class.extend({ + _typeMap: null, + ctor: function () { + this._typeMap = {}; + }, + destroyInstance: function () { + this._sharedFactory = null; + }, + + createObject: function (className) { + var o = null; + var t = this._typeMap[className]; + if (t) { + o = new t._fun(); + } + return o; + }, + + registerType: function (t) { + this._typeMap[t._className] = t; + } +}); + +ccs.ObjectFactory._sharedFactory = null; + +ccs.ObjectFactory.getInstance = function () { + if (!this._sharedFactory) { + this._sharedFactory = new ccs.ObjectFactory(); + } + return this._sharedFactory; +}; + +ccs.TInfo = ccs.Class.extend({ + _className: "", + _fun: null, + /** + * + * @param {String|ccs.TInfo}c + * @param {Function}f + */ + ctor: function (c, f) { + if (f) { + this._className = c; + this._fun = f; + }else{ + this._className = c._className; + this._fun = c._fun; + } + ccs.ObjectFactory.getInstance().registerType(this); + } +}); + +ccs.registerTriggerClass = function(className, createFunc) { + new ccs.TInfo(className, createFunc); +} + +ccs.BaseTriggerCondition = ccs.Class.extend({ + init: function () { + return true; + }, + + detect: function () { + return true; + }, + + serialize: function (jsonVal) { + }, + + removeAll: function () { + } +}); +ccs.BaseTriggerAction = ccs.Class.extend({ + + init: function () { + return true; + }, + + done: function () { + + }, + + serialize: function (jsonVal) { + }, + + removeAll: function () { + } +}); + +ccs.TriggerObj = ccs.Class.extend({ + _cons: null, + _acts: null, + _id: 0, + _enable: true, + _vInt: null, + + ctor: function () { + this._id = 0; + this._enable = true; + }, + + init: function () { + this._cons = []; + this._acts = []; + this._vInt = []; + return true; + }, + + detect: function () { + if (!this._enable || this._cons.length == 0) { + return true; + } + var ret = true; + var obj = null; + for (var i = 0; i < this._cons.length; i++) { + obj = this._cons[i]; + if (obj && obj.detect) { + ret = ret && obj.detect(); + } + } + return ret; + }, + + done: function () { + if (!this._enable || this._acts.length == 0) { + return; + } + var obj; + for (var i = 0; i < this._acts.length; i++) { + obj = this._acts[i]; + if (obj && obj.done) { + obj.done(); + } + } + }, + + removeAll: function () { + var obj = null; + for (var i = 0; i < this._cons.length; i++) { + obj = this._cons[i]; + if (obj) + obj.removeAll(); + } + this._cons = []; + for (var i = 0; i < this._acts.length; i++) { + obj = this._acts[i]; + if (obj) + obj.removeAll(); + } + this._acts = []; + }, + + serialize: function (jsonVal) { + this._id = jsonVal["id"] || 0; + var conditions = jsonVal["conditions"] || []; + for (var i = 0; i < conditions.length; i++) { + var subDict = conditions[i]; + var classname = subDict["classname"]; + if (!classname) { + continue; + } + var con = ccs.ObjectFactory.getInstance().createObject(classname); + if (!con) { + cc.log("class named classname(" + classname + ") can not implement!"); + } + + con.serialize(subDict); + con.init(); + this._cons.push(con); + } + + var actions = jsonVal["actions"] || []; + for (var i = 0; i < actions.length; i++) { + var subDict = actions[i]; + var classname = subDict["classname"]; + if (!classname) { + continue; + } + var act = ccs.ObjectFactory.getInstance().createObject(classname); + if (!act) { + cc.log("class named classname(" + classname + ") can not implement!"); + } + + act.serialize(subDict); + act.init(); + this._acts.push(act); + } + + var events = jsonVal["events"] || []; + for (var i = 0; i < events.length; i++) { + var subDict = events[i]; + var event = subDict["id"]; + if (event < 0) { + continue; + } + this._vInt.push(event); + } + }, + + getId: function () { + return this._id; + }, + + setEnable: function (enable) { + this._enable = enable; + }, + + getEvents: function () { + return this._vInt; + } +}); + +ccs.TriggerObj.create = function() { + var ret = new ccs.TriggerObj(); + if (ret.init()) + return ret; + return null; +} + +ccs.TriggerMng = ccs.Class.extend({ + _eventTriggers: null, + _triggerObjs: null, + _movementDispatches: null, + ctor: function () { + this._eventTriggers = {}; + this._triggerObjs = {}; + this._movementDispatches = []; + }, + + destroyInstance: function () { + this.removeAll(); + this._instance = null; + }, + + parse: function (root) { + var triggers = root;//["Triggers"]; + for (var i = 0; i < triggers.length; ++i) { + var subDict = triggers[i]; + var triggerObj = ccs.TriggerObj.create(); + triggerObj.serialize(subDict); + var events = triggerObj.getEvents(); + for (var j = 0; j < events.length; j++) { + var event = events[j]; + this.add(event, triggerObj); + } + this._triggerObjs[triggerObj.getId()] = triggerObj; + } + }, + + get: function (event) { + return this._eventTriggers[event]; + }, + + getTriggerObj: function (id) { + return this._triggerObjs[id]; + }, + + add: function (event, triggerObj) { + var eventTriggers = this._eventTriggers[event]; + if (!eventTriggers) { + eventTriggers = []; + } + if (!cc.ArrayContainsObject(eventTriggers, triggerObj)) { + eventTriggers.push(triggerObj); + this._eventTriggers[event] = eventTriggers; + } + }, + + removeAll: function () { + for (var key in this._eventTriggers) { + var triObjArr = this._eventTriggers[key]; + for (var j = 0; j < triObjArr.length; j++) { + var obj = triObjArr[j]; + obj.removeAll(); + } + } + this._eventTriggers = {}; + }, + + remove: function (event, Obj) { + if (Obj) { + return this._removeObj(event, Obj); + } + var bRet = false; + do + { + var triObjects = this._eventTriggers[event]; + if (!triObjects) break; + for (var i = 0; i < triObjects.length; i++) { + var triObject = triObjects[i]; + if (triObject) { + triObject.removeAll(); + } + } + delete this._eventTriggers[event]; + bRet = true; + } while (0); + return bRet; + }, + + _removeObj: function (event, Obj) { + var bRet = false; + do + { + var triObjects = this._eventTriggers[event]; + if (!triObjects) break; + for (var i = 0; i < triObjects.length; i++) { + var triObject = triObjects[i]; + if (triObject && triObject == Obj) { + triObject.removeAll(); + triObjects.splice(i, 1); + break; + } + } + bRet = true; + } while (0); + return bRet; + }, + + removeTriggerObj: function (id) { + var obj = this.getTriggerObj(id); + if (!obj) { + return false; + } + var events = obj.getEvents(); + for (var i = 0; i < events.length; i++) { + var event = events[i]; + this.remove(event, obj); + } + return true; + }, + isEmpty: function () { + return !this._eventTriggers || this._eventTriggers.length <= 0; + }, + + addArmatureMovementCallBack: function (armature, callFunc, target) { + if (armature == null || target == null || callFunc == null) { + return; + } + var locAmd, hasADD = false; + for (var i = 0; i < this._movementDispatches.length; i++) { + locAmd = this._movementDispatches[i]; + if (locAmd && locAmd[0] == armature) { + locAmd.addAnimationEventCallBack(callFunc, target); + hasADD = true; + } + } + if (!hasADD) { + var newAmd = new ccs.ArmatureMovementDispatcher(); + armature.getAnimation().setMovementEventCallFunc(newAmd.animationEvent, newAmd); + newAmd.addAnimationEventCallBack(callFunc, target); + this._movementDispatches.push([armature, newAmd]); + } + }, + + removeArmatureMovementCallBack: function (armature, target, callFunc) { + if (armature == null || target == null || callFunc == null) { + return; + } + var locAmd; + for (var i = 0; i < this._movementDispatches.length; i++) { + locAmd = this._movementDispatches[i]; + if (locAmd && locAmd[0] == armature) { + locAmd.removeAnimationEventCallBack(callFunc, target); + } + } + }, + + removeArmatureAllMovementCallBack: function (armature) { + if (armature == null) { + return; + } + var locAmd; + for (var i = 0; i < this._movementDispatches.length; i++) { + locAmd = this._movementDispatches[i]; + if (locAmd && locAmd[0] == armature) { + this._movementDispatches.splice(i, 1); + break; + } + } + }, + + removeAllArmatureMovementCallBack: function () { + this._movementDispatches = []; + } +}); + +ccs.TriggerMng.triggerMngVersion = function () { + return "1.2.0.0"; +}; +ccs.TriggerMng._instance = null; +ccs.TriggerMng.getInstance = function () { + if (null == this._instance) { + this._instance = new ccs.TriggerMng(); + } + return this._instance; +}; + + + + + diff --git a/cocos/scripting/lua/bindings/Android.mk b/cocos/scripting/lua/bindings/Android.mk index 694c1de755..fa92938dd4 100644 --- a/cocos/scripting/lua/bindings/Android.mk +++ b/cocos/scripting/lua/bindings/Android.mk @@ -19,11 +19,15 @@ LOCAL_SRC_FILES := CCLuaBridge.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_auto.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_extension_auto.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_studio_auto.cpp \ + ../../auto-generated/lua-bindings/lua_cocos2dx_gui_auto.cpp \ ../../auto-generated/lua-bindings/lua_cocos2dx_spine_auto.cpp \ + ../../auto-generated/lua-bindings/lua_cocos2dx_physics_auto.cpp \ lua_cocos2dx_manual.cpp \ lua_cocos2dx_extension_manual.cpp \ lua_cocos2dx_coco_studio_manual.cpp \ + lua_cocos2dx_gui_manual.cpp \ lua_cocos2dx_spine_manual.cpp \ + lua_cocos2dx_physics_manual.cpp \ lua_cocos2dx_deprecated.cpp \ lua_xml_http_request.cpp \ platform/android/CCLuaJavaBridge.cpp \ diff --git a/cocos/scripting/lua/bindings/CCLuaBridge.cpp b/cocos/scripting/lua/bindings/CCLuaBridge.cpp index c915636448..50aaca89e5 100644 --- a/cocos/scripting/lua/bindings/CCLuaBridge.cpp +++ b/cocos/scripting/lua/bindings/CCLuaBridge.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2011 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/scripting/lua/bindings/CCLuaBridge.h b/cocos/scripting/lua/bindings/CCLuaBridge.h index e23f47b406..0b5ba061c5 100644 --- a/cocos/scripting/lua/bindings/CCLuaBridge.h +++ b/cocos/scripting/lua/bindings/CCLuaBridge.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2011 cocos2d-x.org + Copyright (c) 2013 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/scripting/lua/bindings/CCLuaEngine.cpp b/cocos/scripting/lua/bindings/CCLuaEngine.cpp index a8141d143b..a05fa8f54d 100644 --- a/cocos/scripting/lua/bindings/CCLuaEngine.cpp +++ b/cocos/scripting/lua/bindings/CCLuaEngine.cpp @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2011 cocos2d-x.org + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -32,6 +33,7 @@ #include "lua_cocos2dx_manual.hpp" #include "lua_cocos2dx_extension_manual.h" #include "lua_cocos2dx_coco_studio_manual.hpp" +#include "lua_cocos2dx_gui_manual.hpp" NS_CC_BEGIN @@ -186,6 +188,22 @@ int LuaEngine::reallocateScriptHandler(int nHandler) return nRet; } +bool LuaEngine::parseConfig(ConfigType type, const std::string& str) +{ + lua_getglobal(_stack->getLuaState(), "__onParseConfig"); + if (!lua_isfunction(_stack->getLuaState(), -1)) + { + CCLOG("[LUA ERROR] name '%s' does not represent a Lua function", "__onParseConfig"); + lua_pop(_stack->getLuaState(), 1); + return false; + } + + _stack->pushInt((int)type); + _stack->pushString(str.c_str()); + + return _stack->executeFunction(2); +} + int LuaEngine::sendEvent(ScriptEvent* evt) { if (NULL == evt) @@ -841,101 +859,14 @@ int LuaEngine::handleEvent(ScriptHandlerMgr::HandlerType type, void* data, int n int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType type,void* data) { - if (nullptr == data) - return 0; - - BasicScriptData* eventData = static_cast(data); - if (nullptr == eventData->nativeObject || nullptr == eventData->value) - return 0; - - LuaTableViewEventData* tableViewData = static_cast(eventData->value); - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, type); - - if (0 == handler) - return 0; - - Object* obj = static_cast(eventData->nativeObject); - if (nullptr == obj) - return 0; - - int ret = 0; - switch (type) - { - case ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL: - case ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM: - { - toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"TableView"); - ret = _stack->executeFunctionByHandler(handler, 1); - } - break; - case ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED: - case ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT: - case ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT: - case ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE: - { - Object* cellObject = static_cast(tableViewData->value); - if (nullptr == cellObject) { - break; - } - toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"TableView"); - toluafix_pushusertype_ccobject(_stack->getLuaState(), cellObject->_ID, &(cellObject->_luaID), (void*)(cellObject),"TableViewCell"); - ret = _stack->executeFunctionByHandler(handler, 2); - } - break; - default: - break; - } - - return ret; + CCASSERT(0, "TableView is not bound yet"); + return 0; } int LuaEngine::handleTableViewEvent(ScriptHandlerMgr::HandlerType handlerType,void* data, int numResults, const std::function& func) { - if (nullptr == data || numResults <= 0) - return 0; - - BasicScriptData* eventData = static_cast(data); - if (nullptr == eventData->nativeObject || nullptr == eventData->value) - return 0; - - LuaTableViewEventData* tableViewData = static_cast(eventData->value); - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)eventData->nativeObject, handlerType); - - if (0 == handler) - return 0; - - Object* obj = static_cast(eventData->nativeObject); - if (nullptr == obj) - return 0; - - int ret = 0; - switch (handlerType) - { - case ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX: - { - toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"TableView"); - _stack->pushLong(*((ssize_t*)tableViewData->value)); - ret = _stack->executeFunction(handler, 2, 2, func); - } - break; - case ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX: - { - toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"TableView"); - _stack->pushLong(*((ssize_t*)tableViewData->value)); - ret = _stack->executeFunction(handler, 2, 1, func); - } - break; - case ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS: - { - toluafix_pushusertype_ccobject(_stack->getLuaState(), obj->_ID, &(obj->_luaID), (void*)(obj),"TableView"); - ret = _stack->executeFunction(handler, 1, 1, func); - } - break; - default: - break; - } - - return ret; + CCASSERT(0, "TableView is not bound yet"); + return 0; } int LuaEngine::handleAssetsManagerEvent(ScriptHandlerMgr::HandlerType type,void* data) diff --git a/cocos/scripting/lua/bindings/CCLuaEngine.h b/cocos/scripting/lua/bindings/CCLuaEngine.h index 10ac6a0dff..e3f4ff9bef 100644 --- a/cocos/scripting/lua/bindings/CCLuaEngine.h +++ b/cocos/scripting/lua/bindings/CCLuaEngine.h @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2011 cocos2d-x.org + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -116,7 +117,8 @@ public: virtual bool handleAssert(const char *msg); - virtual int sendEvent(ScriptEvent* message); + virtual bool parseConfig(ConfigType type, const std::string& str) override; + virtual int sendEvent(ScriptEvent* message) override; virtual int handleEvent(ScriptHandlerMgr::HandlerType type,void* data); virtual int handleEvent(ScriptHandlerMgr::HandlerType type, void* data, int numResults, const std::function& func); private: diff --git a/cocos/scripting/lua/bindings/CCLuaStack.cpp b/cocos/scripting/lua/bindings/CCLuaStack.cpp index 82e4e28dd3..7215e6afac 100644 --- a/cocos/scripting/lua/bindings/CCLuaStack.cpp +++ b/cocos/scripting/lua/bindings/CCLuaStack.cpp @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2011 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -58,6 +59,10 @@ extern "C" { #include "lua_cocos2dx_coco_studio_manual.hpp" #include "lua_cocos2dx_spine_auto.hpp" #include "lua_cocos2dx_spine_manual.hpp" +#include "lua_cocos2dx_physics_auto.hpp" +#include "lua_cocos2dx_physics_manual.hpp" +#include "lua_cocos2dx_gui_auto.hpp" +#include "lua_cocos2dx_gui_manual.hpp" namespace { int lua_print(lua_State * luastate) @@ -148,14 +153,20 @@ bool LuaStack::init(void) register_cocos2dx_extension_CCBProxy(_state); register_cocos2dx_event_releated(_state); tolua_opengl_open(_state); + register_all_cocos2dx_gui(_state); register_all_cocos2dx_studio(_state); register_all_cocos2dx_manual(_state); register_all_cocos2dx_extension_manual(_state); register_all_cocos2dx_manual_deprecated(_state); register_all_cocos2dx_coco_studio_manual(_state); + register_all_cocos2dx_gui_manual(_state); register_all_cocos2dx_spine(_state); register_all_cocos2dx_spine_manual(_state); register_glnode_manual(_state); +#if CC_USE_PHYSICS + register_all_cocos2dx_physics(_state); + register_all_cocos2dx_physics_manual(_state); +#endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) LuaObjcBridge::luaopen_luaoc(_state); #endif diff --git a/cocos/scripting/lua/bindings/CCLuaStack.h b/cocos/scripting/lua/bindings/CCLuaStack.h index e48d7bb9d3..ed31c48b91 100644 --- a/cocos/scripting/lua/bindings/CCLuaStack.h +++ b/cocos/scripting/lua/bindings/CCLuaStack.h @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2011 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/scripting/lua/bindings/CCLuaValue.cpp b/cocos/scripting/lua/bindings/CCLuaValue.cpp index dcb80c527b..584f17a6a8 100644 --- a/cocos/scripting/lua/bindings/CCLuaValue.cpp +++ b/cocos/scripting/lua/bindings/CCLuaValue.cpp @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2011 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/scripting/lua/bindings/CCLuaValue.h b/cocos/scripting/lua/bindings/CCLuaValue.h index 08cdc2544f..eefc0c85c4 100644 --- a/cocos/scripting/lua/bindings/CCLuaValue.h +++ b/cocos/scripting/lua/bindings/CCLuaValue.h @@ -1,5 +1,6 @@ /**************************************************************************** - Copyright (c) 2011 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.cpp b/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.cpp index 13c9c26e34..6409c99f61 100644 --- a/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.cpp +++ b/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.cpp @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2011 cocos2d-x.org + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.h b/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.h index 75db7d0fdc..e251bac27b 100644 --- a/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.h +++ b/cocos/scripting/lua/bindings/Cocos2dxLuaLoader.h @@ -1,5 +1,6 @@ /**************************************************************************** -Copyright (c) 2011 cocos2d-x.org +Copyright (c) 2011-2012 cocos2d-x.org +Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index 84c013968c..c04df69ce3 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2011 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -307,6 +307,43 @@ bool luaval_to_point(lua_State* L,int lo,Point* outValue) return ok; } +bool luaval_to_physics_material(lua_State* L,int lo,PhysicsMaterial* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; + + tolua_Error tolua_err; + if (!tolua_istable(L, lo, 0, &tolua_err) ) + { +#if COCOS2D_DEBUG >=1 + luaval_to_native_err(L,"#ferror:",&tolua_err); +#endif + ok = false; + } + + + if (ok) + { + lua_pushstring(L, "density"); + lua_gettable(L, lo); + outValue->density = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + lua_pop(L, 1); + + lua_pushstring(L, "restitution"); + lua_gettable(L, lo); + outValue->restitution = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + lua_pop(L, 1); + + lua_pushstring(L, "friction"); + lua_gettable(L, lo); + outValue->friction = lua_isnil(L, -1) ? 0 : lua_tonumber(L, -1); + lua_pop(L, 1); + } + return ok; +} + bool luaval_to_ssize(lua_State* L,int lo, ssize_t* outValue) { return luaval_to_long(L, lo, reinterpret_cast(outValue)); @@ -1502,6 +1539,19 @@ bool luaval_to_std_vector_int(lua_State* L, int lo, std::vector* ret) return ok; } +void points_to_luaval(lua_State* L,const Point* pt, int count) +{ + if (NULL == L) + return; + lua_newtable(L); + for (int i = 1; i <= count; ++i) + { + lua_pushnumber(L, i); + point_to_luaval(L, pt[i-1]); + lua_rawset(L, -3); + } +} + void point_to_luaval(lua_State* L,const Point& pt) { if (NULL == L) @@ -1515,6 +1565,72 @@ void point_to_luaval(lua_State* L,const Point& pt) lua_rawset(L, -3); /* table[key] = value, L: table */ } +void physics_material_to_luaval(lua_State* L,const PhysicsMaterial& pm) +{ + if (NULL == L) + return; + lua_newtable(L); /* L: table */ + lua_pushstring(L, "density"); /* L: table key */ + lua_pushnumber(L, (lua_Number) pm.density); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "restitution"); /* L: table key */ + lua_pushnumber(L, (lua_Number) pm.restitution); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ + lua_pushstring(L, "friction"); /* L: table key */ + lua_pushnumber(L, (lua_Number) pm.friction); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ +} + +void physics_raycastinfo_to_luaval(lua_State* L, const PhysicsRayCastInfo& info) +{ + if (NULL == L) + return; + + lua_newtable(L); /* L: table */ + + lua_pushstring(L, "shape"); /* L: table key */ + PhysicsShape* shape = info.shape; + if (shape == nullptr) + { + lua_pushnil(L); + }else + { + std::string hashName = typeid(*shape).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsShape"; + } + + int ID = (int)(shape->_ID); + int* luaID = &(shape->_luaID); + toluafix_pushusertype_ccobject(L, ID, luaID, (void*)shape,className.c_str()); + } + lua_rawset(L, -3); /* table[key] = value, L: table */ + + lua_pushstring(L, "start"); /* L: table key */ + point_to_luaval(L, info.start); + lua_rawset(L, -3); /* table[key] = value, L: table */ + + lua_pushstring(L, "end"); /* L: table key */ + point_to_luaval(L, info.end); + lua_rawset(L, -3); /* table[key] = value, L: table */ + + lua_pushstring(L, "contact"); /* L: table key */ + point_to_luaval(L, info.contact); + lua_rawset(L, -3); /* table[key] = value, L: table */ + + lua_pushstring(L, "normal"); /* L: table key */ + point_to_luaval(L, info.normal); + lua_rawset(L, -3); /* table[key] = value, L: table */ + + lua_pushstring(L, "fraction"); /* L: table key */ + lua_pushnumber(L, (lua_Number) info.fraction); /* L: table key value*/ + lua_rawset(L, -3); /* table[key] = value, L: table */ +} + void size_to_luaval(lua_State* L,const Size& sz) { if (NULL == L) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.h b/cocos/scripting/lua/bindings/LuaBasicConversions.h index ed46e80a29..20e4f79d73 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.h +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.h @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef __COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ #define __COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ @@ -41,6 +64,7 @@ extern bool luaval_to_rect(lua_State* L,int lo,Rect* outValue); extern bool luaval_to_color3b(lua_State* L,int lo,Color3B* outValue); extern bool luaval_to_color4b(lua_State* L,int lo,Color4B* outValue); extern bool luaval_to_color4f(lua_State* L,int lo,Color4F* outValue); +extern bool luaval_to_physics_material(lua_State* L,int lo, cocos2d::PhysicsMaterial* outValue); extern bool luaval_to_affinetransform(lua_State* L,int lo, AffineTransform* outValue); extern bool luaval_to_fontdefinition(lua_State* L, int lo, FontDefinition* outValue ); extern bool luaval_to_array(lua_State* L,int lo, Array** outValue); @@ -172,11 +196,14 @@ extern bool luaval_to_ccvaluevector(lua_State* L, int lo, cocos2d::ValueVector* // from native extern void point_to_luaval(lua_State* L,const Point& pt); +extern void points_to_luaval(lua_State* L,const Point* pt, int count); extern void size_to_luaval(lua_State* L,const Size& sz); extern void rect_to_luaval(lua_State* L,const Rect& rt); extern void color3b_to_luaval(lua_State* L,const Color3B& cc); extern void color4b_to_luaval(lua_State* L,const Color4B& cc); extern void color4f_to_luaval(lua_State* L,const Color4F& cc); +extern void physics_material_to_luaval(lua_State* L,const PhysicsMaterial& pm); +extern void physics_raycastinfo_to_luaval(lua_State* L, const PhysicsRayCastInfo& info); extern void affinetransform_to_luaval(lua_State* L,const AffineTransform& inValue); extern void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue); extern void array_to_luaval(lua_State* L,Array* inValue); diff --git a/cocos/scripting/lua/bindings/LuaOpengl.cpp.REMOVED.git-id b/cocos/scripting/lua/bindings/LuaOpengl.cpp.REMOVED.git-id index 3271e22a11..42910a1d92 100644 --- a/cocos/scripting/lua/bindings/LuaOpengl.cpp.REMOVED.git-id +++ b/cocos/scripting/lua/bindings/LuaOpengl.cpp.REMOVED.git-id @@ -1 +1 @@ -9104cc5ff14c7548ea6924a2785400db7526c1e1 \ No newline at end of file +bcec27eb626dbcf63b810cce7f0f48b2d02c2158 \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/LuaOpengl.h b/cocos/scripting/lua/bindings/LuaOpengl.h index fa8f3780f6..d4691677ae 100644 --- a/cocos/scripting/lua/bindings/LuaOpengl.h +++ b/cocos/scripting/lua/bindings/LuaOpengl.h @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef __LUA_OPENGL_H__ #define __LUA_OPENGL_H__ diff --git a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.cpp b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.cpp index 6ed20bf4ba..81317d65d7 100644 --- a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.cpp +++ b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.cpp @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifdef __cplusplus extern "C" { #endif diff --git a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h index 5079dca704..d1cb5d3a57 100644 --- a/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h +++ b/cocos/scripting/lua/bindings/LuaScriptHandlerMgr.h @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef __LUA_SCRIPT_HANDLER_MGR_H__ #define __LUA_SCRIPT_HANDLER_MGR_H__ diff --git a/cocos/scripting/lua/bindings/LuaSkeletonAnimation.cpp b/cocos/scripting/lua/bindings/LuaSkeletonAnimation.cpp index c06d633f68..92cc7699bd 100644 --- a/cocos/scripting/lua/bindings/LuaSkeletonAnimation.cpp +++ b/cocos/scripting/lua/bindings/LuaSkeletonAnimation.cpp @@ -1,9 +1,27 @@ -/* - * LuaSkeletonAnimation.cpp - * - * Created on: 2013?11?21? - * Author: edwardzhou - */ + /**************************************************************************** + Copyright (c) 2013 Edward Zhou + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "LuaSkeletonAnimation.h" #include "cocos2d.h" diff --git a/cocos/scripting/lua/bindings/LuaSkeletonAnimation.h b/cocos/scripting/lua/bindings/LuaSkeletonAnimation.h index b1f570be8f..7872ad7cbb 100644 --- a/cocos/scripting/lua/bindings/LuaSkeletonAnimation.h +++ b/cocos/scripting/lua/bindings/LuaSkeletonAnimation.h @@ -1,9 +1,27 @@ -/* - * LuaSkeletonAnimation.h - * - * Created on: 2013?11?21? - * Author: edwardzhou - */ + /**************************************************************************** + Copyright (c) 2013 Edward Zhou + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef LUASKELETONANIMATION_H_ #define LUASKELETONANIMATION_H_ diff --git a/cocos/scripting/lua/bindings/Lua_web_socket.cpp b/cocos/scripting/lua/bindings/Lua_web_socket.cpp index a541001ec8..4d3b8ae715 100644 --- a/cocos/scripting/lua/bindings/Lua_web_socket.cpp +++ b/cocos/scripting/lua/bindings/Lua_web_socket.cpp @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) @@ -79,18 +102,22 @@ void LuaWebSocket::onMessage(WebSocket* ws, const WebSocket::Data& data) LuaWebSocket* luaWs = dynamic_cast(ws); if (NULL != luaWs) { if (data.isBinary) { - int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); - if (0 != nHandler) { - SendBinaryMessageToLua(nHandler, (const unsigned char*)data.bytes, data.len); + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); + if (0 != handler) { + SendBinaryMessageToLua(handler, (const unsigned char*)data.bytes, data.len); } } else{ - int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); - if (0 != nHandler) { - CommonScriptData commonData(nHandler,data.bytes); - ScriptEvent event(kCommonEvent,(void*)&commonData); - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); + if (0 != handler) + { + LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); + if (nullptr != stack) + { + stack->pushString(data.bytes,data.len); + stack->executeFunctionByHandler(handler, 1); + } } } } diff --git a/cocos/scripting/lua/bindings/Lua_web_socket.h b/cocos/scripting/lua/bindings/Lua_web_socket.h index 98c9c73130..5431209d12 100644 --- a/cocos/scripting/lua/bindings/Lua_web_socket.h +++ b/cocos/scripting/lua/bindings/Lua_web_socket.h @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef __LUA_WEB_SOCKET_H__ #define __LUA_WEB_SOCKET_H__ @@ -12,7 +35,7 @@ extern "C" { #endif #include "network/WebSocket.h" -class LuaWebSocket: public network::WebSocket,public network::WebSocket::Delegate +class LuaWebSocket: public cocos2d::network::WebSocket,public cocos2d::network::WebSocket::Delegate { public: virtual ~LuaWebSocket(); diff --git a/cocos/scripting/lua/bindings/liblua.vcxproj b/cocos/scripting/lua/bindings/liblua.vcxproj index 5006e34a8e..c7fcc70043 100644 --- a/cocos/scripting/lua/bindings/liblua.vcxproj +++ b/cocos/scripting/lua/bindings/liblua.vcxproj @@ -76,7 +76,7 @@ Level3 - EditAndContinue + OldStyle 4800;4267;4251;4244;%(DisableSpecificWarnings) true @@ -131,6 +131,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ + + @@ -146,7 +148,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ + + @@ -161,6 +165,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ + + @@ -176,7 +182,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ + + @@ -185,6 +193,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ + + diff --git a/cocos/scripting/lua/bindings/liblua.vcxproj.filters b/cocos/scripting/lua/bindings/liblua.vcxproj.filters index 5f7bbe6fb6..57c0335ab0 100644 --- a/cocos/scripting/lua/bindings/liblua.vcxproj.filters +++ b/cocos/scripting/lua/bindings/liblua.vcxproj.filters @@ -99,6 +99,18 @@ cocos2dx_support + + cocos2dx_support\generated + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support\generated + @@ -185,6 +197,18 @@ cocos2dx_support + + cocos2dx_support\generated + + + cocos2dx_support + + + cocos2dx_support + + + cocos2dx_support\generated + @@ -196,5 +220,11 @@ cocos2dx_support\generated + + cocos2dx_support\generated + + + cocos2dx_support\generated + \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp index 1f665a016a..5120f1d966 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "lua_cocos2dx_coco_studio_manual.hpp" #ifdef __cplusplus @@ -12,619 +35,17 @@ extern "C" { #include "LuaBasicConversions.h" #include "LuaScriptHandlerMgr.h" #include "CCLuaValue.h" -#include "CocosGUI.h" #include "CocoStudio.h" #include "CCLuaEngine.h" -using namespace gui; using namespace cocostudio; -class LuaCocoStudioEventListener:public Object -{ -public: - LuaCocoStudioEventListener(); - virtual ~LuaCocoStudioEventListener(); - - static LuaCocoStudioEventListener* create(); - - virtual void eventCallbackFunc(Object* sender,int eventType); -}; - -LuaCocoStudioEventListener::LuaCocoStudioEventListener() -{ - -} - -LuaCocoStudioEventListener::~LuaCocoStudioEventListener() -{ - -} - -LuaCocoStudioEventListener* LuaCocoStudioEventListener::create() -{ - LuaCocoStudioEventListener* listener = new LuaCocoStudioEventListener(); - if (nullptr == listener) - return nullptr; - - listener->autorelease(); - - return listener; -} - -void LuaCocoStudioEventListener::eventCallbackFunc(Object* sender,int eventType) -{ - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - if (0 != handler) - { - LuaStudioEventListenerData eventData(sender,eventType); - BasicScriptData data(this,(void*)&eventData); - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER, (void*)&data); - } -} - -static int lua_cocos2dx_Widget_addTouchEventListener(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - Widget* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"Widget",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Widget_addTouchEventListener'\n", NULL); - return 0; - } -#endif - - argc = lua_gettop(L) - 1; - - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - self->setUserObject(listener); - self->addTouchEventListener(listener, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addTouchEventListener' function of Widget has wrong number of arguments: %d, was expecting %d\n", argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addTouchEventListener'.",&tolua_err); - return 0; -#endif -} - -static void extendWidget(lua_State* L) -{ - lua_pushstring(L, "Widget"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addTouchEventListener", lua_cocos2dx_Widget_addTouchEventListener); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_CheckBox_addEventListenerCheckBox(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - CheckBox* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"CheckBox",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_CheckBox_addEventListenerCheckBox'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - self->setUserObject(listener); - self->addEventListenerCheckBox(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerCheckBox' function of CheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerCheckBox'.",&tolua_err); - return 0; -#endif -} - - -static void extendCheckBox(lua_State* L) -{ - lua_pushstring(L, "CheckBox"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerCheckBox", lua_cocos2dx_CheckBox_addEventListenerCheckBox); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_Slider_addEventListenerSlider(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - Slider* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"Slider",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Slider_addEventListenerSlider'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - self->setUserObject(listener); - self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerSlider' function of Slider has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerSlider'.",&tolua_err); - return 0; -#endif -} - -static void extendSlider(lua_State* L) -{ - lua_pushstring(L, "Slider"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerSlider", lua_cocos2dx_Slider_addEventListenerSlider); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_TextField_addEventListenerTextField(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - TextField* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"TextField",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TextField_addEventListenerTextField'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - self->setUserObject(listener); - self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerTextField' function of TextField has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerTextField'.",&tolua_err); - return 0; -#endif -} - -static void extendTextField(lua_State* L) -{ - lua_pushstring(L, "TextField"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerTextField", lua_cocos2dx_TextField_addEventListenerTextField); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_PageView_addEventListenerPageView(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - PageView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"PageView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_PageView_addEventListenerPageView'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); - if (nullptr == listener) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - self->setUserObject(listener); - self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerPageView' function of PageView has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerPageView'.",&tolua_err); - return 0; -#endif -} - -static void extendPageView(lua_State* L) -{ - lua_pushstring(L, "PageView"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerPageView", lua_cocos2dx_PageView_addEventListenerPageView); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_ListView_addEventListenerListView(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - ListView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"ListView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ListView_addEventListenerListView'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) - { - goto tolua_lerror; - } -#endif - LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); - if (nullptr == listern) - { - tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); - return 0; - } - - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); - - self->setUserObject(listern); - self->addEventListenerListView(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); - - return 0; - } - - CCLOG("'addEventListenerListView' function of ListView has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'addEventListenerListView'.",&tolua_err); - return 0; -#endif -} - -static void extendListView(lua_State* L) -{ - lua_pushstring(L, "ListView"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "addEventListenerListView", lua_cocos2dx_ListView_addEventListenerListView); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_LayoutParameter_setMargin(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - LayoutParameter* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"LayoutParameter",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_setMargin'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!tolua_istable(L, 2, 0, &tolua_err)) - { - goto tolua_lerror; - } -#endif - - Margin margin; - lua_pushstring(L, "left"); - lua_gettable(L,2); - margin.left = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushstring(L, "top"); - lua_gettable(L,2); - margin.top = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushstring(L, "right"); - lua_gettable(L,2); - margin.right = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); - lua_pop(L,1); - - lua_pushstring(L, "bottom"); - lua_gettable(L,2); - margin.bottom = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); - lua_pop(L,1); - - self->setMargin(margin); - return 0; - } - - CCLOG("'setMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 1); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'setMargin'.",&tolua_err); - return 0; -#endif -} - -static int lua_cocos2dx_LayoutParameter_getMargin(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - LayoutParameter* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"LayoutParameter",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_getMargin'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - - if (0 == argc) - { - Margin margin = self->getMargin(); - - lua_newtable(L); - - lua_pushstring(L, "left"); - lua_pushnumber(L, (lua_Number) margin.left); - lua_rawset(L, -3); - - lua_pushstring(L, "top"); - lua_pushnumber(L, (lua_Number) margin.top); - lua_rawset(L, -3); - - lua_pushstring(L, "right"); - lua_pushnumber(L, (lua_Number) margin.right); - lua_rawset(L, -3); - - lua_pushstring(L, "bottom"); - lua_pushnumber(L, (lua_Number) margin.bottom); - lua_rawset(L, -3); - - return 1; - } - - CCLOG("'getMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 0); - - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'getMargin'.",&tolua_err); - return 0; -#endif -} - -static void extendLayoutParameter(lua_State* L) -{ - lua_pushstring(L, "LayoutParameter"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "setMargin", lua_cocos2dx_LayoutParameter_setMargin); - tolua_function(L, "getMargin", lua_cocos2dx_LayoutParameter_getMargin); - } - lua_pop(L, 1); -} - class LuaArmatureWrapper:public Object { public: LuaArmatureWrapper(); virtual ~LuaArmatureWrapper(); - virtual void movementEventCallback(Armature* armature, MovementEventType type,const char* movementID); - virtual void frameEventCallback(Bone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex); virtual void addArmatureFileInfoAsyncCallback(float percent); }; @@ -638,41 +59,6 @@ LuaArmatureWrapper::~LuaArmatureWrapper() } -void LuaArmatureWrapper::movementEventCallback(Armature* armature, MovementEventType type,const char* movementID) -{ - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); - - if (0 != handler) - { - std::string strMovementID = movementID; - LuaArmatureMovementEventData movementData(armature,(int)type, strMovementID); - - LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT , (void*)&movementData); - - BasicScriptData data(this,(void*)&wrapperData); - - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); - } -} - -void LuaArmatureWrapper::frameEventCallback(Bone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex) -{ - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); - - if (0 != handler) - { - std::string strFrameEventName(frameEventName); - - LuaArmatureFrameEventData frameData(bone,strFrameEventName,orginFrameIndex,currentFrameIndex); - - LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT , (void*)&frameData); - - BasicScriptData data(this,(void*)&wrapperData); - - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); - } -} - void LuaArmatureWrapper::addArmatureFileInfoAsyncCallback(float percent) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); @@ -724,11 +110,25 @@ static int lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(lua_State* L) LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); + Vector vec; + vec.pushBack(wrapper); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); - - self->setUserObject(wrapper); - self->setMovementEventCallFunc(wrapper, movementEvent_selector(LuaArmatureWrapper::movementEventCallback)); - + + self->setMovementEventCallFunc([=](Armature *armature, MovementEventType movementType, const std::string& movementID){ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)vec.at(0), ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + if (0 != handler) + { + std::string strMovementID = movementID; + LuaArmatureMovementEventData movementData(armature,(int)movementType, strMovementID); + + LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT , (void*)&movementData); + + BasicScriptData data((void*)vec.at(0),(void*)&wrapperData); + + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); + } + }); return 0; } @@ -780,10 +180,27 @@ static int lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(lua_State* L) LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + Vector vec; + vec.pushBack(wrapper); - self->setUserObject(wrapper); - self->setFrameEventCallFunc(wrapper, frameEvent_selector(LuaArmatureWrapper::frameEventCallback)); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + self->setFrameEventCallFunc([=](Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex){ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)vec.at(0), ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + if (0 != handler) + { + std::string strFrameEventName(frameEventName); + + LuaArmatureFrameEventData frameData(bone,frameEventName,originFrameIndex,currentFrameIndex); + + LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT , (void*)&frameData); + + BasicScriptData data((void*)vec.at(0),(void*)&wrapperData); + + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); + } + }); return 0; } @@ -901,19 +318,110 @@ static void extendArmatureDataManager(lua_State* L) lua_pop(L, 1); } +static int lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + cocostudio::Bone* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"Bone",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_isboolean(L, 2, 0, &tolua_err)) + goto tolua_lerror; +#endif + bool ignore = (bool)tolua_toboolean(L, 2, 0); + self->setIgnoreMovementBoneData(ignore); + return 0; + } + + CCLOG("'setIgnoreMovementBoneData' function of Bone has wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'setIgnoreMovementBoneData'.",&tolua_err); + return 0; +#endif +} + +static int lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + cocostudio::Bone* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"Bone",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (0 == argc) + { + tolua_pushboolean(L, self->getIgnoreMovementBoneData()); + return 1; + } + + CCLOG("'getIgnoreMovementBoneData' function of Bone has wrong number of arguments: %d, was expecting %d\n", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'getIgnoreMovementBoneData'.",&tolua_err); + return 0; +#endif +} + +static void extendBone(lua_State* L) +{ + lua_pushstring(L, "Bone"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "setIgnoreMovementBoneData", lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData); + tolua_function(L, "getIgnoreMovementBoneData", lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData); + } + lua_pop(L, 1); +} + int register_all_cocos2dx_coco_studio_manual(lua_State* L) { if (nullptr == L) return 0; - extendWidget(L); - extendCheckBox(L); - extendSlider(L); - extendTextField(L); - extendPageView(L); - extendListView(L); - extendLayoutParameter(L); extendArmatureAnimation(L); extendArmatureDataManager(L); + extendBone(L); return 0; } \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp index 75c7a40e17..fcbdb8b7b1 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.hpp @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H #define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_COCO_STUDIO_MANUAL_H @@ -13,16 +36,6 @@ extern "C" { TOLUA_API int register_all_cocos2dx_coco_studio_manual(lua_State* L); -struct LuaStudioEventListenerData -{ - cocos2d::Object* objTarget; - int eventType; - - LuaStudioEventListenerData(cocos2d::Object* _objTarget, int _eventType):objTarget(_objTarget),eventType(_eventType) - { - } -}; - struct LuaArmatureWrapperEventData { enum class LuaArmatureWrapperEventType diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp index bad4c5d654..0d6d053810 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.cpp @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "lua_cocos2dx_deprecated.h" #ifdef __cplusplus diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.h b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.h index 62bea3bf27..7db6757ee2 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.h +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_deprecated.h @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_DEPRECATED_H #define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_DEPRECATED_H diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp index 68ca441fd6..88b4693c01 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.cpp @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "lua_cocos2dx_extension_manual.h" #ifdef __cplusplus @@ -19,202 +42,6 @@ USING_NS_CC; USING_NS_CC_EXT; using namespace cocostudio; -class LuaScrollViewDelegate:public Object, public ScrollViewDelegate -{ -public: - virtual ~LuaScrollViewDelegate() - {} - - virtual void scrollViewDidScroll(ScrollView* view) - { - if (nullptr != view) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); - if (0 != handler) - { - CommonScriptData data(handler,""); - ScriptEvent event(kCommonEvent,(void*)&data); - LuaEngine::getInstance()->sendEvent(&event); - } - - } - } - - virtual void scrollViewDidZoom(ScrollView* view) - { - if (nullptr != view) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM); - if (0 != handler) - { - CommonScriptData data(handler,""); - ScriptEvent event(kCommonEvent,(void*)&data); - LuaEngine::getInstance()->sendEvent(&event); - } - } - } -}; - -static int tolua_cocos2dx_ScrollView_setDelegate(lua_State* tolua_S) -{ - if (nullptr == tolua_S) - return 0; - - int argc = 0; - ScrollView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"ScrollView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = (ScrollView*) tolua_tousertype(tolua_S,1,0); -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) - { - tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_ScrollView_setDelegate'\n", nullptr); - return 0; - } -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (0 == argc) - { - LuaScrollViewDelegate* delegate = new LuaScrollViewDelegate(); - if (nullptr == delegate) - return 0; - - self->setUserObject(delegate); - self->setDelegate(delegate); - - delegate->release(); - - return 0; - } - - CCLOG("'setDelegate' function of ScrollView wrong number of arguments: %d, was expecting %d\n", argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'setDelegate'.",&tolua_err); - return 0; -#endif -} - -static int tolua_cocos2d_ScrollView_registerScriptHandler(lua_State* tolua_S) -{ - if (NULL == tolua_S) - return 0; - - int argc = 0; - ScrollView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"ScrollView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(tolua_S,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_ScrollView_registerScriptHandler'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(tolua_S) - 1; - if (2 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isnumber(tolua_S, 3, 0, &tolua_err) ) - { - goto tolua_lerror; - } -#endif - LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); - ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(tolua_S,3,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType); - return 0; - } - - CCLOG("'registerScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err); - return 0; -#endif -} - -static int tolua_cocos2d_ScrollView_unregisterScriptHandler(lua_State* tolua_S) -{ - if (NULL == tolua_S) - return 0; - - int argc = 0; - ScrollView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(tolua_S,1,"ScrollView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(tolua_S,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2d_ScrollView_unregisterScriptHandler'\n", NULL); - return 0; - } -#endif - - argc = lua_gettop(tolua_S) - 1; - - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err)) - goto tolua_lerror; -#endif - ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(tolua_S,2,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); - ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType); - return 0; - } - - CCLOG("'unregisterScriptHandler' function of ScrollView has wrong number of arguments: %d, was expecting %d\n", argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); - return 0; -#endif -} - -static void extendScrollView(lua_State* tolua_S) -{ - lua_pushstring(tolua_S, "ScrollView"); - lua_rawget(tolua_S, LUA_REGISTRYINDEX); - if (lua_istable(tolua_S,-1)) - { - lua_pushstring(tolua_S,"setDelegate"); - lua_pushcfunction(tolua_S,tolua_cocos2dx_ScrollView_setDelegate ); - lua_rawset(tolua_S,-3); - lua_pushstring(tolua_S,"registerScriptHandler"); - lua_pushcfunction(tolua_S,tolua_cocos2d_ScrollView_registerScriptHandler ); - lua_rawset(tolua_S,-3); - lua_pushstring(tolua_S,"unregisterScriptHandler"); - lua_pushcfunction(tolua_S,tolua_cocos2d_ScrollView_unregisterScriptHandler ); - lua_rawset(tolua_S,-3); - } - lua_pop(tolua_S, 1); -} - static int tolua_cocos2d_Control_registerControlEventHandler(lua_State* tolua_S) { if (NULL == tolua_S) @@ -859,570 +686,6 @@ static void extendCCBAnimationManager(lua_State* tolua_S) lua_pop(tolua_S, 1); } -#define KEY_TABLEVIEW_DATA_SOURCE "TableViewDataSource" -#define KEY_TABLEVIEW_DELEGATE "TableViewDelegate" - -class LUA_TableViewDelegate:public Object, public TableViewDelegate -{ -public: - LUA_TableViewDelegate(){} - - virtual ~LUA_TableViewDelegate(){} - - - virtual void scrollViewDidScroll(ScrollView* view) - { - if (nullptr != view) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); - if (0 != handler) - { - LuaTableViewEventData eventData; - BasicScriptData data(view,&eventData); - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL, (void*)&data); - } - } - } - - virtual void scrollViewDidZoom(ScrollView* view) - { - if (nullptr != view) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)view, ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM); - if (0 != handler) - { - LuaTableViewEventData eventData; - BasicScriptData data(view,&eventData); - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::SCROLLVIEW_ZOOM, (void*)&data); - } - } - } - - virtual void tableCellTouched(TableView* table, TableViewCell* cell) - { - if (nullptr != table && nullptr != cell) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED); - if (0 != handler) - { - LuaTableViewEventData eventData(cell); - BasicScriptData data(table,&eventData); - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_TOUCHED,(void*)&data); - } - } - } - - virtual void tableCellHighlight(TableView* table, TableViewCell* cell) - { - if (nullptr != table && nullptr != cell) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT); - if (0 != handler) - { - LuaTableViewEventData eventData(cell); - BasicScriptData data(table,&eventData); - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_HIGHLIGHT,(void*)&data); - } - } - } - - virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) - { - if (nullptr != table && nullptr != cell) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT); - if (0 != handler) - { - LuaTableViewEventData eventData(cell); - BasicScriptData data(table,&eventData); - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT,(void*)&data); - } - } - } - - virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) - { - if (nullptr != table && nullptr != cell) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE); - if (0 != handler) - { - LuaTableViewEventData eventData(cell); - BasicScriptData data(table,&eventData); - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE,(void*)&data); - } - } - } -}; - -static int lua_cocos2dx_TableView_setDelegate(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - TableView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"TableView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = (TableView*) tolua_tousertype(L,1,0); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) - { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TableView_setDelegate'\n", nullptr); - return 0; - } -#endif - - argc = lua_gettop(L) - 1; - - if (0 == argc) - { - LUA_TableViewDelegate* delegate = new LUA_TableViewDelegate(); - if (nullptr == delegate) - return 0; - - Dictionary* userDict = static_cast(self->getUserObject()); - if (nullptr == userDict) - { - userDict = new Dictionary(); - if (NULL == userDict) - return 0; - - self->setUserObject(userDict); - userDict->release(); - } - - userDict->setObject(delegate, KEY_TABLEVIEW_DELEGATE); - self->setDelegate(delegate); - delegate->release(); - - return 0; - } - - CCLOG("'setDelegate' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'setDelegate'.",&tolua_err); - return 0; -#endif -} - -class LUA_TableViewDataSource:public Object,public TableViewDataSource -{ -public: - LUA_TableViewDataSource(){} - virtual ~LUA_TableViewDataSource(){} - - virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) - { - if (nullptr != table ) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX); - if (0 != handler) - { - LuaTableViewEventData eventData(&idx); - BasicScriptData data(table,&eventData); - float width = 0.0; - float height = 0.0; - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX, (void*)&data,2,[&](lua_State* L,int numReturn){ - CCASSERT(numReturn == 2, "tableCellSizeForIndex return count error"); - ValueVector vec; - width = (float)tolua_tonumber(L, -1, 0); - lua_pop(L, 1); - height = (float)tolua_tonumber(L, -1, 0); - lua_pop(L, 1); - }); - - return Size(width, height); - } - } - - return Size::ZERO; - } - - virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) - { - if (nullptr != table ) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX); - if (0 != handler) - { - LuaTableViewEventData eventData(&idx); - BasicScriptData data(table,&eventData); - TableViewCell* viewCell = nullptr; - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX, (void*)&data, 1, [&](lua_State* L, int numReturn){ - CCASSERT(numReturn == 1, "tableCellAtIndex return count error"); - viewCell = static_cast(tolua_tousertype(L, -1, nullptr)); - lua_pop(L, 1); - }); - - return viewCell; - } - } - - return NULL; - } - - virtual ssize_t numberOfCellsInTableView(TableView *table) - { - if (nullptr != table ) - { - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS); - if (0 != handler) - { - LuaTableViewEventData eventData; - BasicScriptData data(table,&eventData); - ssize_t counts = 0; - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLEVIEW_NUMS_OF_CELLS, (void*)&data,1, [&](lua_State* L, int numReturn){ - CCASSERT(numReturn == 1, "numberOfCellsInTableView return count error"); - counts = (ssize_t)tolua_tonumber(L, -1, 0); - lua_pop(L, 1); - }); - return counts; - } - } - return 0; - } -}; - -static int lua_cocos2dx_TableView_setDataSource(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - TableView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"TableView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = (TableView*) tolua_tousertype(L,1,0); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) - { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TableView_setDataSource'\n", nullptr); - return 0; - } -#endif - - argc = lua_gettop(L) - 1; - - if (0 == argc) - { - LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource(); - if (nullptr == dataSource) - return 0; - - Dictionary* userDict = static_cast(self->getUserObject()); - if (nullptr == userDict) - { - userDict = new Dictionary(); - if (NULL == userDict) - return 0; - - self->setUserObject(userDict); - userDict->release(); - } - - userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE); - - self->setDataSource(dataSource); - - dataSource->release(); - - return 0; - } - - CCLOG("'setDataSource' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'setDataSource'.",&tolua_err); - return 0; -#endif -} - -static int lua_cocos2dx_TableView_create(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - bool ok = true; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertable(L,1,"TableView",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(L) - 1; - - if (2 == argc || 1 == argc) - { - LUA_TableViewDataSource* dataSource = new LUA_TableViewDataSource(); - Size size; - ok &= luaval_to_size(L, 2, &size); - - TableView* ret = nullptr; - - if (1 == argc) - { - ret = TableView::create(dataSource, size); - } - else - { -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertype(L,3,"Node",0,&tolua_err)) goto tolua_lerror; -#endif - Node* node = static_cast(tolua_tousertype(L, 3, nullptr)); - ret = TableView::create(dataSource, size, node); - } - - if (nullptr == ret) - return 0; - - ret->reloadData(); - - Dictionary* userDict = new Dictionary(); - userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE); - ret->setUserObject(userDict); - userDict->release(); - - dataSource->release(); - - - int nID = (int)ret->_ID; - int* pLuaID = &ret->_luaID; - toluafix_pushusertype_ccobject(L, nID, pLuaID, (void*)ret,"TableView"); - - return 1; - } - CCLOG("'create' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 1); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'create'.",&tolua_err); - return 0; -#endif -} - -static int lua_cocos2d_TableView_registerScriptHandler(lua_State* L) -{ - if (NULL == L) - return 0; - - int argc = 0; - TableView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"TableView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'tolua_cocos2d_TableView_registerScriptHandler'\n", NULL); - return 0; - } -#endif - argc = lua_gettop(L) - 1; - if (2 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) || - !tolua_isnumber(L, 3, 0, &tolua_err) ) - { - goto tolua_lerror; - } -#endif - LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); - ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,3,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); - - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType); - return 0; - } - - CCLOG("'registerScriptHandler' function of TableView has wrong number of arguments: %d, was expecting %d\n", argc, 2); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'registerScriptHandler'.",&tolua_err); - return 0; -#endif -} - -static int lua_cocos2d_TableView_unregisterScriptHandler(lua_State* L) -{ - if (NULL == L) - return 0; - - int argc = 0; - TableView* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"TableView",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2d_TableView_unregisterScriptHandler'\n", NULL); - return 0; - } -#endif - - argc = lua_gettop(L) - 1; - - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!tolua_isnumber(L, 2, 0, &tolua_err)) - goto tolua_lerror; -#endif - ScriptHandlerMgr::HandlerType handlerType = (ScriptHandlerMgr::HandlerType) ((int)tolua_tonumber(L,2,0) + (int)ScriptHandlerMgr::HandlerType::SCROLLVIEW_SCROLL); - ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType); - return 0; - } - - CCLOG("'unregisterScriptHandler' function of TableView has wrong number of arguments: %d, was expecting %d\n", argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'unregisterScriptHandler'.",&tolua_err); - return 0; -#endif -} - -static void extendTableView(lua_State* L) -{ - lua_pushstring(L, "TableView"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "setDelegate", lua_cocos2dx_TableView_setDelegate); - tolua_function(L, "setDataSource", lua_cocos2dx_TableView_setDataSource); - tolua_function(L, "create", lua_cocos2dx_TableView_create); - tolua_function(L, "registerScriptHandler", lua_cocos2d_TableView_registerScriptHandler); - tolua_function(L, "unregisterScriptHandler", lua_cocos2d_TableView_unregisterScriptHandler); - } - lua_pop(L, 1); -} - -static int lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - cocostudio::Bone* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"Bone",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData'\n", NULL); - return 0; - } -#endif - - argc = lua_gettop(L) - 1; - - if (1 == argc) - { -#if COCOS2D_DEBUG >= 1 - if (!tolua_isboolean(L, 2, 0, &tolua_err)) - goto tolua_lerror; -#endif - bool ignore = (bool)tolua_toboolean(L, 2, 0); - self->setIgnoreMovementBoneData(ignore); - return 0; - } - - CCLOG("'setIgnoreMovementBoneData' function of Bone has wrong number of arguments: %d, was expecting %d\n", argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'setIgnoreMovementBoneData'.",&tolua_err); - return 0; -#endif -} - -static int lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData(lua_State* L) -{ - if (nullptr == L) - return 0; - - int argc = 0; - cocostudio::Bone* self = nullptr; - -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; - if (!tolua_isusertype(L,1,"Bone",0,&tolua_err)) goto tolua_lerror; -#endif - - self = static_cast(tolua_tousertype(L,1,0)); - -#if COCOS2D_DEBUG >= 1 - if (nullptr == self) { - tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData'\n", NULL); - return 0; - } -#endif - - argc = lua_gettop(L) - 1; - - if (0 == argc) - { - tolua_pushboolean(L, self->getIgnoreMovementBoneData()); - return 1; - } - - CCLOG("'getIgnoreMovementBoneData' function of Bone has wrong number of arguments: %d, was expecting %d\n", argc, 0); - return 0; - -#if COCOS2D_DEBUG >= 1 -tolua_lerror: - tolua_error(L,"#ferror in function 'getIgnoreMovementBoneData'.",&tolua_err); - return 0; -#endif -} - -static void extendBone(lua_State* L) -{ - lua_pushstring(L, "Bone"); - lua_rawget(L, LUA_REGISTRYINDEX); - if (lua_istable(L,-1)) - { - tolua_function(L, "setIgnoreMovementBoneData", lua_cocos2dx_extension_Bone_setIgnoreMovementBoneData); - tolua_function(L, "getIgnoreMovementBoneData", lua_cocos2dx_extension_Bone_getIgnoreMovementBoneData); - } - lua_pop(L, 1); -} - class LuaAssetsManagerDelegateProtocol:public Object, public AssetsManagerDelegateProtocol { public: @@ -1539,13 +802,10 @@ static void extendAssetsManager(lua_State* L) int register_all_cocos2dx_extension_manual(lua_State* tolua_S) { - extendScrollView(tolua_S); extendControl(tolua_S); extendEditBox(tolua_S); extendCCBReader(tolua_S); extendCCBAnimationManager(tolua_S); - extendTableView(tolua_S); - extendBone(tolua_S); extendAssetsManager(tolua_S); return 0; } diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.h b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.h index 39ebdaa7a2..1a76eaf316 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.h +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_extension_manual.h @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_EXTENSION_MANUAL_H #define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_LUA_COCOS2DX_EXTENSION_MANUAL_H @@ -14,17 +37,6 @@ extern "C" { TOLUA_API int register_all_cocos2dx_extension_manual(lua_State* tolua_S); TOLUA_API int register_cocos2dx_extension_CCBProxy(lua_State* tolua_S); -struct LuaTableViewEventData -{ - void* value; - - // Constructor - LuaTableViewEventData(void* _value = nullptr) - :value(_value) - { - } -}; - struct LuaAssetsManagerEventData { int value; diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp new file mode 100644 index 0000000000..ec8a23ccd8 --- /dev/null +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.cpp @@ -0,0 +1,654 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#include "lua_cocos2dx_gui_manual.hpp" + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua_fix.h" +#ifdef __cplusplus +} +#endif + +#include "cocos2d.h" +#include "LuaBasicConversions.h" +#include "LuaScriptHandlerMgr.h" +#include "CCLuaValue.h" +#include "CocosGUI.h" +#include "CCLuaEngine.h" + +using namespace gui; + +class LuaCocoStudioEventListener:public Object +{ +public: + LuaCocoStudioEventListener(); + virtual ~LuaCocoStudioEventListener(); + + static LuaCocoStudioEventListener* create(); + + virtual void eventCallbackFunc(Object* sender,int eventType); +}; + +LuaCocoStudioEventListener::LuaCocoStudioEventListener() +{ + +} + +LuaCocoStudioEventListener::~LuaCocoStudioEventListener() +{ + +} + +LuaCocoStudioEventListener* LuaCocoStudioEventListener::create() +{ + LuaCocoStudioEventListener* listener = new LuaCocoStudioEventListener(); + if (nullptr == listener) + return nullptr; + + listener->autorelease(); + + return listener; +} + +void LuaCocoStudioEventListener::eventCallbackFunc(Object* sender,int eventType) +{ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); + + if (0 != handler) + { + LuaStudioEventListenerData eventData(sender,eventType); + BasicScriptData data(this,(void*)&eventData); + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER, (void*)&data); + } +} + +static int lua_cocos2dx_Widget_addTouchEventListener(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + Widget* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"Widget",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Widget_addTouchEventListener'\n", NULL); + return 0; + } +#endif + + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); + + self->setUserObject(listener); + self->addTouchEventListener(listener, toucheventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addTouchEventListener' function of Widget has wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addTouchEventListener'.",&tolua_err); + return 0; +#endif +} + +static void extendWidget(lua_State* L) +{ + lua_pushstring(L, "Widget"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addTouchEventListener", lua_cocos2dx_Widget_addTouchEventListener); + } + lua_pop(L, 1); +} + +static int lua_cocos2dx_CheckBox_addEventListenerCheckBox(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + CheckBox* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"CheckBox",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_CheckBox_addEventListenerCheckBox'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); + + self->setUserObject(listener); + self->addEventListenerCheckBox(listener, checkboxselectedeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addEventListenerCheckBox' function of CheckBox has wrong number of arguments: %d, was expecting %d\n", argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListenerCheckBox'.",&tolua_err); + return 0; +#endif +} + + +static void extendCheckBox(lua_State* L) +{ + lua_pushstring(L, "CheckBox"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListenerCheckBox", lua_cocos2dx_CheckBox_addEventListenerCheckBox); + } + lua_pop(L, 1); +} + +static int lua_cocos2dx_Slider_addEventListenerSlider(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + Slider* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"Slider",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_Slider_addEventListenerSlider'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); + + self->setUserObject(listener); + self->addEventListenerSlider(listener, sliderpercentchangedselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addEventListenerSlider' function of Slider has wrong number of arguments: %d, was expecting %d\n", argc, 1); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListenerSlider'.",&tolua_err); + return 0; +#endif +} + +static void extendSlider(lua_State* L) +{ + lua_pushstring(L, "Slider"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListenerSlider", lua_cocos2dx_Slider_addEventListenerSlider); + } + lua_pop(L, 1); +} + +static int lua_cocos2dx_TextField_addEventListenerTextField(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + TextField* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"TextField",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TextField_addEventListenerTextField'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); + + self->setUserObject(listener); + self->addEventListenerTextField(listener, textfieldeventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addEventListenerTextField' function of TextField has wrong number of arguments: %d, was expecting %d\n", argc, 1); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListenerTextField'.",&tolua_err); + return 0; +#endif +} + +static void extendTextField(lua_State* L) +{ + lua_pushstring(L, "TextField"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListenerTextField", lua_cocos2dx_TextField_addEventListenerTextField); + } + lua_pop(L, 1); +} + +static int lua_cocos2dx_PageView_addEventListenerPageView(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + PageView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"PageView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_PageView_addEventListenerPageView'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err) ) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listener = LuaCocoStudioEventListener::create(); + if (nullptr == listener) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listener, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); + + self->setUserObject(listener); + self->addEventListenerPageView(listener, pagevieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addEventListenerPageView' function of PageView has wrong number of arguments: %d, was expecting %d\n", argc, 1); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListenerPageView'.",&tolua_err); + return 0; +#endif +} + +static void extendPageView(lua_State* L) +{ + lua_pushstring(L, "PageView"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListenerPageView", lua_cocos2dx_PageView_addEventListenerPageView); + } + lua_pop(L, 1); +} + +static int lua_cocos2dx_ListView_addEventListenerListView(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + ListView* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"ListView",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_ListView_addEventListenerListView'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err)) + { + goto tolua_lerror; + } +#endif + LuaCocoStudioEventListener* listern = LuaCocoStudioEventListener::create(); + if (nullptr == listern) + { + tolua_error(L,"LuaCocoStudioEventListener create fail\n", NULL); + return 0; + } + + LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0)); + + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)listern, handler, ScriptHandlerMgr::HandlerType::STUDIO_EVENT_LISTENER); + + self->setUserObject(listern); + self->addEventListenerListView(listern, listvieweventselector(LuaCocoStudioEventListener::eventCallbackFunc)); + + return 0; + } + + CCLOG("'addEventListenerListView' function of ListView has wrong number of arguments: %d, was expecting %d\n", argc, 1); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'addEventListenerListView'.",&tolua_err); + return 0; +#endif +} + +static void extendListView(lua_State* L) +{ + lua_pushstring(L, "ListView"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "addEventListenerListView", lua_cocos2dx_ListView_addEventListenerListView); + } + lua_pop(L, 1); +} + +static int lua_cocos2dx_LayoutParameter_setMargin(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + LayoutParameter* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"LayoutParameter",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_setMargin'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + + if (1 == argc) + { +#if COCOS2D_DEBUG >= 1 + if (!tolua_istable(L, 2, 0, &tolua_err)) + { + goto tolua_lerror; + } +#endif + + Margin margin; + lua_pushstring(L, "left"); + lua_gettable(L,2); + margin.left = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "top"); + lua_gettable(L,2); + margin.top = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "right"); + lua_gettable(L,2); + margin.right = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + lua_pushstring(L, "bottom"); + lua_gettable(L,2); + margin.bottom = lua_isnil(L,-1) ? 0 : lua_tonumber(L,-1); + lua_pop(L,1); + + self->setMargin(margin); + return 0; + } + + CCLOG("'setMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 1); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'setMargin'.",&tolua_err); + return 0; +#endif +} + +static int lua_cocos2dx_LayoutParameter_getMargin(lua_State* L) +{ + if (nullptr == L) + return 0; + + int argc = 0; + LayoutParameter* self = nullptr; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; + if (!tolua_isusertype(L,1,"LayoutParameter",0,&tolua_err)) goto tolua_lerror; +#endif + + self = static_cast(tolua_tousertype(L,1,0)); + +#if COCOS2D_DEBUG >= 1 + if (nullptr == self) { + tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_LayoutParameter_getMargin'\n", NULL); + return 0; + } +#endif + argc = lua_gettop(L) - 1; + + if (0 == argc) + { + Margin margin = self->getMargin(); + + lua_newtable(L); + + lua_pushstring(L, "left"); + lua_pushnumber(L, (lua_Number) margin.left); + lua_rawset(L, -3); + + lua_pushstring(L, "top"); + lua_pushnumber(L, (lua_Number) margin.top); + lua_rawset(L, -3); + + lua_pushstring(L, "right"); + lua_pushnumber(L, (lua_Number) margin.right); + lua_rawset(L, -3); + + lua_pushstring(L, "bottom"); + lua_pushnumber(L, (lua_Number) margin.bottom); + lua_rawset(L, -3); + + return 1; + } + + CCLOG("'getMargin' function of LayoutParameter has wrong number of arguments: %d, was expecting %d\n", argc, 0); + + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'getMargin'.",&tolua_err); + return 0; +#endif +} + +static void extendLayoutParameter(lua_State* L) +{ + lua_pushstring(L, "LayoutParameter"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "setMargin", lua_cocos2dx_LayoutParameter_setMargin); + tolua_function(L, "getMargin", lua_cocos2dx_LayoutParameter_getMargin); + } + lua_pop(L, 1); +} + +int register_all_cocos2dx_gui_manual(lua_State* L) +{ + if (nullptr == L) + return 0; + extendWidget(L); + extendCheckBox(L); + extendSlider(L); + extendTextField(L); + extendPageView(L); + extendListView(L); + extendLayoutParameter(L); + + return 0; +} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPotentiometerTest/UIPotentiometerTest.h b/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.hpp similarity index 66% rename from samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPotentiometerTest/UIPotentiometerTest.h rename to cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.hpp index c4f7b329d2..d18581a291 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPotentiometerTest/UIPotentiometerTest.h +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_gui_manual.hpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. http://www.cocos2d-x.org @@ -21,25 +21,28 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_GUI_MANUAL_H +#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_GUI_MANUAL_H -#ifndef __TestCpp__UIPotentiometerTest__ -#define __TestCpp__UIPotentiometerTest__ +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif -#include "../UIScene.h" +#include "CCObject.h" -class UIPotentiometerTest : public UIScene +TOLUA_API int register_all_cocos2dx_gui_manual(lua_State* L); + +struct LuaStudioEventListenerData { -public: - UIPotentiometerTest(); - ~UIPotentiometerTest(); - bool init(); - void valueChangedEvent(Object* pSender, PotentiometerEventType type); + cocos2d::Object* objTarget; + int eventType; - -protected: - UI_SCENE_CREATE_FUNC(UIPotentiometerTest) - gui::Label* _displayValueLabel; + LuaStudioEventListenerData(cocos2d::Object* _objTarget, int _eventType):objTarget(_objTarget),eventType(_eventType) + { + } }; - - -#endif /* defined(__TestCpp__UIPotentiometerTest__) */ +#endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_GUI_MANUAL_H diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id b/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id index 368292552d..e3c65441d6 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_manual.cpp.REMOVED.git-id @@ -1 +1 @@ -c3e1d45b75519a265427c1b2479e2bf43305fc1d \ No newline at end of file +f916840e52bdfd7e7283cb9c70ebfaf1c23b9301 \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_manual.hpp b/cocos/scripting/lua/bindings/lua_cocos2dx_manual.hpp index 4e4a67eea9..d8dae90200 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_manual.hpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_manual.hpp @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_MANUAL_H #define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_MANUAL_H diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp new file mode 100644 index 0000000000..0d11f0f9b4 --- /dev/null +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.cpp @@ -0,0 +1,1270 @@ +#include "lua_cocos2dx_manual.hpp" + +#if CC_USE_PHYSICS + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua_fix.h" +#ifdef __cplusplus +} +#endif + +#include "LuaBasicConversions.h" +#include "CCLuaValue.h" +#include "CCLuaEngine.h" + +#ifndef CC_SAFE_FREE +#define CC_SAFE_FREE(p) { if(p) free(p); p = nullptr; } +#endif + +int lua_cocos2dx_physics_PhysicsBody_getJoints(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsBody* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsBody*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsBody_getJoints'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + do { + + if(!ok) + return 0; + auto& ret = cobj->getJoints(); + + lua_newtable(tolua_S); + + if (ret.empty()) + return 1; + + auto iter = ret.begin(); + int indexTable = 1; + for (; iter != ret.end(); ++iter) + { + if (nullptr == *iter) + continue; + + std::string hashName = typeid(*iter).name(); + auto name = g_luaType.find(hashName); + std::string className = ""; + if(name != g_luaType.end()){ + className = name->second.c_str(); + } else { + className = "PhysicsJoint"; + } + + lua_pushnumber(tolua_S, (lua_Number)indexTable); + tolua_pushusertype(tolua_S,(void*)(*iter), className.c_str()); + lua_rawset(tolua_S, -3); + ++indexTable; + } + } while (0); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getJoints",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_getJoints'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsWorld* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getScene'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + cocos2d::Scene& ret = cobj->getScene(); + do { + + std::string hashName = typeid(ret).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "Scene"; + } + + int ID = (int)(ret._ID); + int* luaID = &(ret._luaID); + toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)(&ret),className.c_str()); + + }while (0); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScene",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getScene'.",&tolua_err); +#endif + + return 0; +} + + +int lua_cocos2dx_physics_PhysicsWorld_rayCast(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsWorld* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_rayCast'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 3) + { + std::function arg0; + cocos2d::Point arg1; + cocos2d::Point arg2; + LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0); + do { + arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, const cocos2d::PhysicsRayCastInfo &info, void * data) -> bool + { + std::string hashName = typeid(&world).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsWorld"; + } + + tolua_pushusertype(tolua_S, (void*)(&world), className.c_str()); + physics_raycastinfo_to_luaval(tolua_S, info); + return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); + }; + } while(0); + + ok &= luaval_to_point(tolua_S, 3, &arg1); + ok &= luaval_to_point(tolua_S, 4, &arg2); + if(!ok) + return 0; + cobj->rayCast(arg0, arg1, arg2, nullptr); + toluafix_remove_function_by_refid(tolua_S, handler); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "rayCast",argc, 4); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_rayCast'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_physics_PhysicsWorld_queryRect(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsWorld* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_queryRect'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + std::function arg0; + cocos2d::Rect arg1; + LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0); + do { + arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool + { + std::string hashName = typeid(&world).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsWorld"; + } + + tolua_pushusertype(tolua_S, (void*)(&world), className.c_str()); + + hashName = typeid(&shape).name(); + iter = g_luaType.find(hashName); + className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsShape"; + } + toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), className.c_str()); + return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); + }; + } while(0); + + ok &= luaval_to_rect(tolua_S, 3, &arg1); + if(!ok) + return 0; + cobj->queryRect(arg0, arg1, nullptr); + toluafix_remove_function_by_refid(tolua_S, handler); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "queryRect",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_queryRect'.",&tolua_err); +#endif + + return 0; +} + + +int lua_cocos2dx_physics_PhysicsWorld_queryPoint(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsWorld* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"PhysicsWorld",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_queryPoint'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 2) + { + std::function arg0; + cocos2d::Point arg1; + LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0); + do { + arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, cocos2d::PhysicsShape &shape, void * data) -> bool + { + std::string hashName = typeid(&world).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsWorld"; + } + + tolua_pushusertype(tolua_S, (void*)(&world), className.c_str()); + + hashName = typeid(&shape).name(); + iter = g_luaType.find(hashName); + className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsShape"; + } + toluafix_pushusertype_ccobject(tolua_S, shape._ID, &shape._luaID, (void*)(&shape), className.c_str()); + return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2); + }; + assert(false); + } while(0) + ; + ok &= luaval_to_point(tolua_S, 3, &arg1); + if(!ok) + return 0; + cobj->queryPoint(arg0, arg1, nullptr); + toluafix_remove_function_by_refid(tolua_S, handler); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "queryPoint",argc, 3); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_queryPoint'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_physics_PhysicsBody_createPolygon(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + cocos2d::Point* arg0 = nullptr; + int arg1 = 0; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1); + CC_SAFE_FREE(arg0); + do { + if (NULL != ret){ + std::string hashName = typeid(*ret).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsBody"; + } + cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + if (NULL != dynObject) { + int ID = ret ? (int)(dynObject->_ID) : -1; + int* luaID = ret ? &(dynObject->_luaID) : NULL; + toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); + } else { + tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); + }} else { + lua_pushnil(tolua_S); + } + } while (0); + return 1; + } + if (argc == 2) + { + cocos2d::Point* arg0; + int arg1 = 0; + cocos2d::PhysicsMaterial arg2; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + ok &= luaval_to_physics_material(tolua_S, 3, &arg2); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1, arg2); + CC_SAFE_FREE(arg0); + do { + if (NULL != ret){ + std::string hashName = typeid(*ret).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsBody"; + } + cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + if (NULL != dynObject) { + int ID = ret ? (int)(dynObject->_ID) : -1; + int* luaID = ret ? &(dynObject->_luaID) : NULL; + toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); + } else { + tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); + }} else { + lua_pushnil(tolua_S); + } + } while (0); + return 1; + } + if (argc == 3) + { + cocos2d::Point* arg0; + int arg1 = 0; + cocos2d::PhysicsMaterial arg2; + cocos2d::Point arg3; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + ok &= luaval_to_physics_material(tolua_S, 3, &arg2); + ok &= luaval_to_point(tolua_S, 4, &arg3); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createPolygon(arg0, arg1, arg2, arg3); + CC_SAFE_FREE(arg0); + do { + if (NULL != ret){ + std::string hashName = typeid(*ret).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsBody"; + } + cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + if (NULL != dynObject) { + int ID = ret ? (int)(dynObject->_ID) : -1; + int* luaID = ret ? &(dynObject->_luaID) : NULL; + toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); + } else { + tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); + }} else { + lua_pushnil(tolua_S); + } + } while (0); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createPolygon",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_createPolygon'.",&tolua_err); +#endif + return 0; +} + +int lua_cocos2dx_physics_PhysicsBody_createEdgePolygon(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + cocos2d::Point* arg0; + int arg1; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1); + CC_SAFE_FREE(arg0); + do { + if (NULL != ret){ + std::string hashName = typeid(*ret).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsBody"; + } + cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + if (NULL != dynObject) { + int ID = ret ? (int)(dynObject->_ID) : -1; + int* luaID = ret ? &(dynObject->_luaID) : NULL; + toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); + } else { + tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); + }} else { + lua_pushnil(tolua_S); + } + } while (0); + return 1; + } + if (argc == 2) + { + cocos2d::Point* arg0; + int arg1; + cocos2d::PhysicsMaterial arg2; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + ok &= luaval_to_physics_material(tolua_S, 3, &arg2); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1, arg2); + CC_SAFE_FREE(arg0); + do { + if (NULL != ret){ + std::string hashName = typeid(*ret).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsBody"; + } + cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + if (NULL != dynObject) { + int ID = ret ? (int)(dynObject->_ID) : -1; + int* luaID = ret ? &(dynObject->_luaID) : NULL; + toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); + } else { + tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); + }} else { + lua_pushnil(tolua_S); + } + } while (0); + return 1; + } + if (argc == 3) + { + cocos2d::Point* arg0; + int arg1; + cocos2d::PhysicsMaterial arg2; + double arg3; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + ok &= luaval_to_physics_material(tolua_S, 3, &arg2); + ok &= luaval_to_number(tolua_S, 4,&arg3); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgePolygon(arg0, arg1, arg2, arg3); + CC_SAFE_FREE(arg0); + do { + if (NULL != ret){ + std::string hashName = typeid(*ret).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsBody"; + } + cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + if (NULL != dynObject) { + int ID = ret ? (int)(dynObject->_ID) : -1; + int* luaID = ret ? &(dynObject->_luaID) : NULL; + toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); + } else { + tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); + }} else { + lua_pushnil(tolua_S); + } + } while (0); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgePolygon",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_createEdgePolygon'.",&tolua_err); +#endif + return 0; +} + +int lua_cocos2dx_physics_PhysicsBody_createEdgeChain(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"PhysicsBody",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + cocos2d::Point* arg0; + int arg1; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1); + CC_SAFE_FREE(arg0); + do { + if (NULL != ret){ + std::string hashName = typeid(*ret).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsBody"; + } + cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + if (NULL != dynObject) { + int ID = ret ? (int)(dynObject->_ID) : -1; + int* luaID = ret ? &(dynObject->_luaID) : NULL; + toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); + } else { + tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); + }} else { + lua_pushnil(tolua_S); + } + } while (0); + return 1; + } + if (argc == 2) + { + cocos2d::Point* arg0; + int arg1; + cocos2d::PhysicsMaterial arg2; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + ok &= luaval_to_physics_material(tolua_S, 3, &arg2); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1, arg2); + CC_SAFE_FREE(arg0); + do { + if (NULL != ret){ + std::string hashName = typeid(*ret).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsBody"; + } + cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + if (NULL != dynObject) { + int ID = ret ? (int)(dynObject->_ID) : -1; + int* luaID = ret ? &(dynObject->_luaID) : NULL; + toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); + } else { + tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); + }} else { + lua_pushnil(tolua_S); + } + } while (0); + return 1; + } + if (argc == 3) + { + cocos2d::Point* arg0; + int arg1; + cocos2d::PhysicsMaterial arg2; + double arg3; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + ok &= luaval_to_physics_material(tolua_S, 3, &arg2); + ok &= luaval_to_number(tolua_S, 4,&arg3); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsBody* ret = cocos2d::PhysicsBody::createEdgeChain(arg0, arg1, arg2, arg3); + CC_SAFE_FREE(arg0); + do { + if (NULL != ret){ + std::string hashName = typeid(*ret).name(); + auto iter = g_luaType.find(hashName); + std::string className = ""; + if(iter != g_luaType.end()){ + className = iter->second.c_str(); + } else { + className = "PhysicsBody"; + } + cocos2d::Object *dynObject = dynamic_cast((cocos2d::PhysicsBody*)ret); + if (NULL != dynObject) { + int ID = ret ? (int)(dynObject->_ID) : -1; + int* luaID = ret ? &(dynObject->_luaID) : NULL; + toluafix_pushusertype_ccobject(tolua_S,ID, luaID, (void*)ret,className.c_str()); + } else { + tolua_pushusertype(tolua_S,(void*)ret,className.c_str()); + }} else { + lua_pushnil(tolua_S); + } + } while (0); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "createEdgeChain",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsBody_createEdgeChain'.",&tolua_err); +#endif + return 0; +} + +int lua_cocos2dx_physics_PhysicsShape_recenterPoints(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"PhysicsShape",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + cocos2d::Point* arg0; + int arg1 = 0; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsShape::recenterPoints(arg0, arg1); + points_to_luaval(tolua_S, arg0, arg1); + CC_SAFE_FREE(arg0); + + return 0; + } + if (argc == 2) + { + cocos2d::Point* arg0; + int arg1 = 0; + cocos2d::Point arg2; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + ok &= luaval_to_point(tolua_S, 3, &arg2); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::PhysicsShape::recenterPoints(arg0, arg1, arg2); + points_to_luaval(tolua_S, arg0, arg1); + CC_SAFE_FREE(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "recenterPoints",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_recenterPoints'.",&tolua_err); +#endif + return 0; +} + +int lua_cocos2dx_physics_PhysicsShape_getPolyonCenter(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"PhysicsShape",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + cocos2d::Point* arg0; + int arg1 = 0; + do { + ok = luaval_to_array_of_Point(tolua_S, 2, &arg0, &arg1); + if (nullptr == arg0){ + LUA_PRECONDITION( arg0, "Invalid Native Object"); + }} while (0); + ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1); + if(!ok) + { + CC_SAFE_FREE(arg0); + return 0; + } + cocos2d::Point ret = cocos2d::PhysicsShape::getPolyonCenter(arg0, arg1); + CC_SAFE_FREE(arg0); + point_to_luaval(tolua_S, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getPolyonCenter",argc, 2); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShape_getPolyonCenter'.",&tolua_err); +#endif + return 0; +} + +int lua_cocos2dx_physics_PhysicsShapeBox_getPoints(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsShapeBox* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"PhysicsShapeBox",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsShapeBox*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeBox_getPoints'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + cocos2d::Point arg0[4]; + cobj->getPoints(arg0); + points_to_luaval(tolua_S, arg0, 4); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeBox_getPoints'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_physics_PhysicsShapePolygon_getPoints(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsShapePolygon* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"PhysicsShapePolygon",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsShapePolygon*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapePolygon_getPoints'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + int count = cobj->getPointsCount(); + cocos2d::Point* arg0 = new cocos2d::Point[count]; + cobj->getPoints(arg0); + points_to_luaval(tolua_S, arg0, count); + CC_SAFE_FREE(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapePolygon_getPoints'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsShapeEdgeBox* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"PhysicsShapeEdgeBox",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsShapeEdgeBox*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + int count = cobj->getPointsCount(); + cocos2d::Point* arg0 = new cocos2d::Point[count]; + cobj->getPoints(arg0); + points_to_luaval(tolua_S, arg0, count); + CC_SAFE_FREE(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsShapeEdgePolygon* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"PhysicsShapeEdgePolygon",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsShapeEdgePolygon*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + int count = cobj->getPointsCount(); + cocos2d::Point* arg0 = new cocos2d::Point[count]; + cobj->getPoints(arg0); + points_to_luaval(tolua_S, arg0, count); + CC_SAFE_FREE(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints'.",&tolua_err); +#endif + + return 0; +} + +int lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::PhysicsShapeEdgeChain* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"PhysicsShapeEdgeChain",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::PhysicsShapeEdgeChain*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + int count = cobj->getPointsCount(); + cocos2d::Point* arg0 = new cocos2d::Point[count]; + cobj->getPoints(arg0); + points_to_luaval(tolua_S, arg0, count); + CC_SAFE_FREE(arg0); + return 0; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPoints",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints'.",&tolua_err); +#endif + + return 0; +} + +int register_all_cocos2dx_physics_manual(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "PhysicsBody"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getJoints"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsBody_getJoints ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"createPolygon"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsBody_createPolygon ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"createEdgeChain"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsBody_createEdgeChain ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"createEdgePolygon"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsBody_createEdgePolygon ); + lua_rawset(tolua_S,-3); + } + lua_pop(tolua_S, 1); + + lua_pushstring(tolua_S, "PhysicsShape"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"recenterPoints"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShape_recenterPoints ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"getPolyonCenter"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShape_getPolyonCenter ); + lua_rawset(tolua_S,-3); + } + lua_pop(tolua_S, 1); + + lua_pushstring(tolua_S, "PhysicsShapeBox"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getPoints"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShapeBox_getPoints ); + lua_rawset(tolua_S,-3); + } + lua_pop(tolua_S, 1); + + lua_pushstring(tolua_S, "PhysicsShapeEdgeBox"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getPoints"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShapeEdgeBox_getPoints ); + lua_rawset(tolua_S,-3); + } + lua_pop(tolua_S, 1); + + lua_pushstring(tolua_S, "PhysicsShapePolygon"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getPoints"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShapePolygon_getPoints ); + lua_rawset(tolua_S,-3); + } + lua_pop(tolua_S, 1); + + lua_pushstring(tolua_S, "PhysicsShapeEdgePolygon"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getPoints"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShapeEdgePolygon_getPoints ); + lua_rawset(tolua_S,-3); + } + lua_pop(tolua_S, 1); + + lua_pushstring(tolua_S, "PhysicsShapeEdgeChain"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getPoints"); + lua_pushcfunction(tolua_S,lua_cocos2dx_physics_PhysicsShapeEdgeChain_getPoints); + lua_rawset(tolua_S,-3); + } + lua_pop(tolua_S, 1); + + lua_pushstring(tolua_S, "PhysicsWorld"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getScene"); + lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_getScene ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"queryPoint"); + lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_queryPoint ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"queryRect"); + lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_queryRect ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S,"rayCast"); + lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_rayCast ); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S, "DEBUGDRAW_NONE"); + lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_NONE); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S, "DEBUGDRAW_SHAPE"); + lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_SHAPE); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S, "DEBUGDRAW_JOINT"); + lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_JOINT); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S, "DEBUGDRAW_CONTACT"); + lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_CONTACT); + lua_rawset(tolua_S,-3); + lua_pushstring(tolua_S, "DEBUGDRAW_ALL"); + lua_pushnumber(tolua_S, PhysicsWorld::DEBUGDRAW_ALL); + lua_rawset(tolua_S,-3); + } + + lua_pop(tolua_S, 1); + + tolua_constant(tolua_S, "PHYSICS_INFINITY", PHYSICS_INFINITY); + + return 0; +} + +#endif \ No newline at end of file diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.hpp b/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.hpp new file mode 100644 index 0000000000..bc9f32b165 --- /dev/null +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_physics_manual.hpp @@ -0,0 +1,21 @@ +#ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_PHYSICS_MANUAL_H +#define COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_PHYSICS_MANUAL_H + +#if CC_USE_PHYSICS + +#ifdef __cplusplus +extern "C" { +#endif +#include "tolua++.h" +#ifdef __cplusplus +} +#endif + +#include "cocos2d.h" +#include "LuaScriptHandlerMgr.h" + +int register_all_cocos2dx_physics_manual(lua_State* tolua_S); + +#endif // CC_USE_PHYSICS + +#endif // #ifndef COCOS2DX_SCRIPT_LUA_COCOS2DX_SUPPORT_GENERATED_LUA_COCOS2DX_PHYSICS_MANUAL_H diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.cpp index 79480afcb3..593dd3f0a3 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.cpp @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "lua_cocos2dx_spine_manual.hpp" #ifdef __cplusplus diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.hpp b/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.hpp index 75ce975ab9..85797a1a83 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.hpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_spine_manual.hpp @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_SPINE_MANUAL_H #define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_SPINE_MANUAL_H diff --git a/cocos/scripting/lua/bindings/lua_xml_http_request.cpp b/cocos/scripting/lua/bindings/lua_xml_http_request.cpp index 945b36a16a..9a7b124ee9 100644 --- a/cocos/scripting/lua/bindings/lua_xml_http_request.cpp +++ b/cocos/scripting/lua/bindings/lua_xml_http_request.cpp @@ -1,4 +1,26 @@ - +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #include "lua_xml_http_request.h" extern "C" diff --git a/cocos/scripting/lua/bindings/lua_xml_http_request.h b/cocos/scripting/lua/bindings/lua_xml_http_request.h index 900ec6db35..8d0ae45394 100644 --- a/cocos/scripting/lua/bindings/lua_xml_http_request.h +++ b/cocos/scripting/lua/bindings/lua_xml_http_request.h @@ -1,3 +1,26 @@ +/**************************************************************************** + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ #ifndef __COCOS_SCRIPTING_LUA_BINDINGS_LUA_XML_HTTP_REQUEST_H__ #define __COCOS_SCRIPTING_LUA_BINDINGS_LUA_XML_HTTP_REQUEST_H__ @@ -34,7 +57,7 @@ public: LuaMinXmlHttpRequest(); ~LuaMinXmlHttpRequest(); - void handle_requestResponse(network::HttpClient *sender, network::HttpResponse *response); + void handle_requestResponse(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response); inline void setResponseType(ResponseType type) { _responseType = type; } inline ResponseType getResponseType() {return _responseType; } @@ -48,7 +71,7 @@ public: inline void setReadyState(int readyState) { _readyState = readyState; } inline int getReadyState() { return _readyState ;} - inline network::HttpRequest* getHttpRequest() { return _httpRequest; } + inline cocos2d::network::HttpRequest* getHttpRequest() { return _httpRequest; } inline int getStatus() { return _status; } inline std::string getStatusText() { return _statusText ;} @@ -88,7 +111,7 @@ private: ResponseType _responseType; unsigned _timeout; bool _isAsync; - network::HttpRequest* _httpRequest; + cocos2d::network::HttpRequest* _httpRequest; bool _isNetwork; bool _withCredentialsValue; std::map _httpHeader; diff --git a/cocos/scripting/lua/script/CocoStudio.lua b/cocos/scripting/lua/script/CocoStudio.lua new file mode 100644 index 0000000000..33cda6970c --- /dev/null +++ b/cocos/scripting/lua/script/CocoStudio.lua @@ -0,0 +1,373 @@ +require "json" +require "extern" + +ccs = ccs or {} + +function ccs.sendTriggerEvent(event) + local triggerObjArr = ccs.TriggerMng.getInstance():get(event) + + if nil == triggerObjArr then + return + end + + for i = 1, table.getn(triggerObjArr) do + local triObj = triggerObjArr[i] + if nil ~= triObj and triObj.detect then + triObj:done() + end + end +end + +function ccs.registerTriggerClass(className, createFunc) + ccs.TInfo.new(className,createFunc) +end + +ccs.TInfo = class("TInfo") +ccs.TInfo._className = "" +ccs.TInfo._fun = nil + +function ccs.TInfo:ctor(c,f) + -- @param {String|ccs.TInfo}c + -- @param {Function}f + if nil ~= f then + self._className = c + self._fun = f + else + self._className = c._className + self._fun = c._fun + end + + ccs.ObjectFactory.getInstance():registerType(self) +end + +ccs.ObjectFactory = class("ObjectFactory") +ccs.ObjectFactory._typeMap = nil +ccs.ObjectFactory._instance = nil + +function ccs.ObjectFactory:ctor() + self._typeMap = {} +end + +function ccs.ObjectFactory.getInstance() + if nil == ccs.ObjectFactory._instance then + ccs.ObjectFactory._instance = ccs.ObjectFactory.new() + end + + return ccs.ObjectFactory._instance +end + +function ccs.ObjectFactory.destroyInstance() + ccs.ObjectFactory._instance = nil +end + +function ccs.ObjectFactory:createObject(classname) + local obj = nil + local t = self._typeMap[classname] + if nil ~= t then + obj = t._fun() + end + + return obj +end + +function ccs.ObjectFactory:registerType(t) + self._typeMap[t._className] = t +end + +ccs.TriggerObj = class("TriggerObj") +ccs.TriggerObj._cons = {} +ccs.TriggerObj._acts = {} +ccs.TriggerObj._enable = false +ccs.TriggerObj._id = 0 +ccs.TriggerObj._vInt = {} + +function ccs.TriggerObj.extend(target) + local t = tolua.getpeer(target) + if not t then + t = {} + tolua.setpeer(target, t) + end + setmetatable(t, TriggerObj) + return target +end + +function ccs.TriggerObj:ctor() + self:init() +end + +function ccs.TriggerObj:init() + self._id = 0 + self._enable = true + self._cons = {} + self._acts = {} + self._vInt = {} +end + +function ccs.TriggerObj:detect() + if (not self._enable) or (table.getn(self._cons) == 0) then + return true + end + + local ret = true + local obj = nil + for i = 1 , table.getn(self._cons) do + obj = self._cons[i] + if nil ~= obj and obj.detect then + ret = ret and obj:detect() + end + end + return ret +end + +function ccs.TriggerObj:done() + if (not self._enable) or (table.getn(self._acts) == 0) then + return + end + + local obj = nil + for i = 1, table.getn(self._acts) do + obj = self._acts[i] + if nil ~= obj and obj.done then + obj:done() + end + end +end + +function ccs.TriggerObj:removeAll() + local obj = nil + for i=1, table.getn(self._cons) do + obj = self._cons[i] + if nil ~= obj then + obj:removeAll() + end + end + self._cons = {} + + for i=1, table.getn(self._acts) do + obj = self._acts[i] + if nil ~= obj then + obj:removeAll() + end + end + self._acts = {} +end + +function ccs.TriggerObj:serialize(jsonValue) + self._id = jsonValue["id"] + local count = 0 + + --condition + local cons = jsonValue["conditions"] + if nil ~= cons then + count = table.getn(cons) + for i = 1, count do + local subDict = cons[i] + local className = subDict["classname"] + if nil ~= className then + local obj = ObjectFactory.getInstance():createObject(className) + assert(nil ~= obj, string.format("class named %s can not implement!",className)) + obj:serialize(subDict) + obj:init() + table.insert(self._cons, obj) + end + end + end + + local actions = jsonValue["actions"] + if nil ~= actions then + count = table.getn(actions) + for i = 1,count do + local subAction = actions[i] + local className = subAction["classname"] + if nil ~= className then + local act = ccs.ObjectFactory.getInstance():createObject(className) + assert(nil ~= act ,string.format("class named %s can not implement!",className)) + act:serialize(subAction) + act:init() + table.insert(self._acts,act) + end + end + end + + local events = jsonValue["events"] + if nil ~= events then + count = table.getn(events) + for i = 1, count do + local subEveent = events[i] + local eventID = subEveent["id"] + if eventID >= 0 then + table.insert(self._vInt,eventID) + end + end + end +end + +function ccs.TriggerObj:getId() + return self._id +end + +function ccs.TriggerObj:setEnable(enable) + self._enable = enable +end + +function ccs.TriggerObj:getEvents() + return self._vInt +end + +ccs.TriggerMng = class("TriggerMng") +ccs.TriggerMng._eventTriggers = nil +ccs.TriggerMng._triggerObjs = nil +ccs.TriggerMng._movementDispatches = nil +ccs.TriggerMng._instance = nil + +function ccs.TriggerMng:ctor() + self._triggerObjs = {} + self._movementDispatches = {} + self._eventTriggers = {} +end + +function ccs.TriggerMng.getInstance() + if ccs.TriggerMng._instance == nil then + ccs.TriggerMng._instance = ccs.TriggerMng.new() + end + + return ccs.TriggerMng._instance +end + +function ccs.TriggerMng.destroyInstance() + if ccs.TriggerMng._instance ~= nil then + ccs.TriggerMng._instance:removeAll() + ccs.TriggerMng._instance = nil + end +end + +function ccs.TriggerMng:triggerMngVersion() + return "1.0.0.0" +end + +function ccs.TriggerMng:parse(jsonStr) + local parseTable = json.decode(jsonStr,1) + if nil == parseTable then + return + end + + local count = table.getn(parseTable) + for i = 1, count do + local subDict = parseTable[i] + local triggerObj = ccs.TriggerObj.new() + triggerObj:serialize(subDict) + local events = triggerObj:getEvents() + for j = 1, table.getn(events) do + local event = events[j] + self:add(event, triggerObj) + end + + self._triggerObjs[triggerObj:getId()] = triggerObj + end +end + +function ccs.TriggerMng:get(event) + return self._eventTriggers[event] +end + +function ccs.TriggerMng:getTriggerObj(id) + return self._triggerObjs[id] +end + +function ccs.TriggerMng:add(event,triggerObj) + local eventTriggers = self._eventTriggers[event] + if nil == eventTriggers then + eventTriggers = {} + end + + local exist = false + for i = 1, table.getn(eventTriggers) do + if eventTriggers[i] == triggers then + exist = true + break + end + end + + if not exist then + table.insert(eventTriggers,triggerObj) + self._eventTriggers[event] = eventTriggers + end +end + +function ccs.TriggerMng:removeAll( ) + for k in pairs(self._eventTriggers) do + local triObjArr = self._eventTriggers[k] + for j = 1, table.getn(triObjArr) do + local obj = triObjArr[j] + obj:removeAll() + end + end + self._eventTriggers = {} +end + +function ccs.TriggerMng:remove(event, obj) + + if nil ~= obj then + return self:removeObjByEvent(event, obj) + end + + assert(event >= 0,"event must be larger than 0") + if nil == self._eventTriggers then + return false + end + + local triObjects = self._eventTriggers[event] + if nil == triObjects then + return false + end + + for i = 1, table.getn(triObjects) do + local triObject = triggers[i] + if nil ~= triObject then + triObject:remvoeAll() + end + end + + self._eventTriggers[event] = nil + return true +end + +function ccs.TriggerMng:removeObjByEvent(event, obj) + assert(event >= 0,"event must be larger than 0") + if nil == self._eventTriggers then + return false + end + + local triObjects = self._eventTriggers[event] + if nil == triObjects then + return false + end + + for i = 1,table.getn(triObjects) do + local triObject = triObjects[i] + if nil ~= triObject and triObject == obj then + triObject:remvoeAll() + table.remove(triObjects, i) + return true + end + end +end + +function ccs.TriggerMng:removeTriggerObj(id) + local obj = self.getTriggerObj(id) + + if nil == obj then + return false + end + + local events = obj:getEvents() + for i = 1, table.getn(events) do + self:remove(events[i],obj) + end + + return true +end + +function ccs.TriggerMng:isEmpty() + return (not (nil == self._eventTriggers)) or table.getn(self._eventTriggers) <= 0 +end diff --git a/cocos/scripting/lua/script/Cocos2d.lua b/cocos/scripting/lua/script/Cocos2d.lua index 1445a271fe..1628b920e6 100644 --- a/cocos/scripting/lua/script/Cocos2d.lua +++ b/cocos/scripting/lua/script/Cocos2d.lua @@ -1,3 +1,5 @@ +require "CocoStudio" + cc = cc or {} cc.DIRECTOR_PROJECTION_2D = 0 @@ -141,7 +143,7 @@ function cc.pUnrotate(pt1, pt2) end --Calculates the square length of pt function cc.pLengthSQ(pt) - return cc.pDot(pt) + return cc.pDot(pt,pt) end --Calculates the square distance between pt1 and pt2 function cc.pDistanceSQ(pt1,pt2) @@ -360,3 +362,20 @@ end function cc.AnimationFrameData( _texCoords, _delay, _size) return { texCoords = _texCoords, delay = _delay, size = _size } end + +--PhysicsMaterial +function cc.PhysicsMaterial(_density, _restitution, _friction) + return { density = _density, restitution = _restitution, friction = _friction } +end + +local ConfigType = +{ + NONE = 0, + COCOSTUDIO = 1, +} + +function __onParseConfig(configType,jasonStr) + if configType == ConfigType.COCOSTUDIO then + ccs.TriggerMng.getInstance():parse(jasonStr) + end +end diff --git a/cocos/scripting/lua/script/Cocos2dConstants.lua b/cocos/scripting/lua/script/Cocos2dConstants.lua index 7534f6c24e..9e12b80b6a 100644 --- a/cocos/scripting/lua/script/Cocos2dConstants.lua +++ b/cocos/scripting/lua/script/Cocos2dConstants.lua @@ -351,4 +351,11 @@ cc.EVENT_KEYBOARD = 3 cc.EVENT_MOUSE = 4 cc.EVENT_ACCELERATION = 5 cc.EVENT_CUSTOM = 6 - \ No newline at end of file + +cc.PHYSICSSHAPE_MATERIAL_DEFAULT = {0.0, 0.5, 0.5} +cc.PHYSICSBODY_MATERIAL_DEFAULT = {0.1, 0.5, 0.5} +cc.GLYPHCOLLECTION_DYNAMIC = 0 +cc.GLYPHCOLLECTION_NEHE = 1 +cc.GLYPHCOLLECTION_ASCII = 2 +cc.GLYPHCOLLECTION_CUSTOM = 3 + diff --git a/cocos/scripting/lua/script/Deprecated.lua b/cocos/scripting/lua/script/Deprecated.lua index 01ce6f62a7..e48ba122e9 100644 --- a/cocos/scripting/lua/script/Deprecated.lua +++ b/cocos/scripting/lua/script/Deprecated.lua @@ -1088,21 +1088,6 @@ end rawset(SceneReader,"purgeSceneReader",SceneReaderDeprecated.purgeSceneReader) --functions of SceneReader will be deprecated end ---functions of ActionManager will be deprecated begin -local ActionManagerDeprecated = { } -function ActionManagerDeprecated.shareManager() - deprecatedTip("ActionManager:shareManager","ccs.ActionManagerEx:getInstance") - return ccs.ActionManagerEx:getInstance() -end -rawset(ActionManager,"shareManager",ActionManagerDeprecated.shareManager) - -function ActionManagerDeprecated.destroyInstance() - deprecatedTip("ActionManager:destroyInstance","ccs.ActionManagerEx:destroyActionManager") - return ccs.ActionManagerEx:destroyActionManager() -end -rawset(ActionManager,"destroyInstance",ActionManagerDeprecated.destroyInstance) ---functions of ActionManager will be deprecated end - --functions of CCEGLView will be deprecated begin local CCEGLViewDeprecated = { } function CCEGLViewDeprecated.sharedOpenGLView() @@ -1112,17 +1097,3 @@ end rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView) --functions of CCEGLView will be deprecated end ---Enums of CCTableView will be deprecated begin -rawset(CCTableView, "kTableViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL) -rawset(CCTableView,"kTableViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM) -rawset(CCTableView,"kTableCellTouched",cc.TABLECELL_TOUCHED) -rawset(CCTableView,"kTableCellSizeForIndex",cc.TABLECELL_SIZE_FOR_INDEX) -rawset(CCTableView,"kTableCellSizeAtIndex",cc.TABLECELL_SIZE_AT_INDEX) -rawset(CCTableView,"kNumberOfCellsInTableView",cc.NUMBER_OF_CELLS_IN_TABLEVIEW) ---Enums of CCTableView will be deprecated end - ---Enums of CCScrollView will be deprecated begin -rawset(CCScrollView, "kScrollViewScroll",cc.SCROLLVIEW_SCRIPT_SCROLL) -rawset(CCScrollView,"kScrollViewZoom",cc.SCROLLVIEW_SCRIPT_ZOOM) ---Enums of CCScrollView will be deprecated end - diff --git a/cocos/scripting/lua/script/DeprecatedClass.lua b/cocos/scripting/lua/script/DeprecatedClass.lua index c06266c319..c899d0a0dc 100644 --- a/cocos/scripting/lua/script/DeprecatedClass.lua +++ b/cocos/scripting/lua/script/DeprecatedClass.lua @@ -175,14 +175,6 @@ end _G["CCEaseElasticOut"] = DeprecatedClass.CCEaseElasticOut() --CCEaseElasticOut class will be Deprecated,end ---CCTableViewCell class will be Deprecated,begin -function DeprecatedClass.CCTableViewCell() - deprecatedTip("CCTableViewCell","cc.TableViewCell") - return cc.TableViewCell -end -_G["CCTableViewCell"] = DeprecatedClass.CCTableViewCell() ---CCTableViewCell class will be Deprecated,end - --CCEaseBackOut class will be Deprecated,begin function DeprecatedClass.CCEaseBackOut() deprecatedTip("CCEaseBackOut","cc.EaseBackOut") @@ -727,14 +719,6 @@ end _G["CCPlace"] = DeprecatedClass.CCPlace() --CCPlace class will be Deprecated,end ---CCScrollView class will be Deprecated,begin -function DeprecatedClass.CCScrollView() - deprecatedTip("CCScrollView","cc.ScrollView") - return cc.ScrollView -end -_G["CCScrollView"] = DeprecatedClass.CCScrollView() ---CCScrollView class will be Deprecated,end - --CCGLProgram class will be Deprecated,begin function DeprecatedClass.CCGLProgram() deprecatedTip("CCGLProgram","cc.GLProgram") @@ -815,14 +799,6 @@ end _G["CCParticleFlower"] = DeprecatedClass.CCParticleFlower() --CCParticleFlower class will be Deprecated,end ---CCTableView class will be Deprecated,begin -function DeprecatedClass.CCTableView() - deprecatedTip("CCTableView","cc.TableView") - return cc.TableView -end -_G["CCTableView"] = DeprecatedClass.CCTableView() ---CCTableView class will be Deprecated,end - --CCParticleSmoke class will be Deprecated,begin function DeprecatedClass.CCParticleSmoke() deprecatedTip("CCParticleSmoke","cc.ParticleSmoke") diff --git a/cocos/scripting/lua/script/GuiConstants.lua b/cocos/scripting/lua/script/GuiConstants.lua new file mode 100644 index 0000000000..028f8d9778 --- /dev/null +++ b/cocos/scripting/lua/script/GuiConstants.lua @@ -0,0 +1,179 @@ +ccui = ccui or {} + +ccui.BrightStyle = +{ + none = -1, + normal = 0, + highlight = 1, +} + +ccui.WidgetType = +{ + widget = 0, --control + container = 1, --container +} + +ccui.TextureResType = +{ + localType = 0, + plistType = 1, +} + +ccui.TouchEventType = +{ + began = 0, + moved = 1, + ended = 2, + canceled = 3, +} + +ccui.SizeType = +{ + absolute = 0, + percent = 1, +} + +ccui.PositionType = { + absolute = 0, + percent = 1, +} + +ccui.CheckBoxEventType = +{ + selected = 0, + unselected = 1, +} + +ccui.TextFiledEventType = +{ + attach_with_ime = 0, + detach_with_ime = 1, + insert_text = 2, + delete_backward = 3, +} + +ccui.LayoutBackGroundColorType = +{ + none = 0, + solid = 1, + gradient = 2, +} + +ccui.LayoutType = +{ + absolute = 0, + linearVertical = 1, + linearHorizontal = 2, + relative = 3, +} + +ccui.LayoutParameterType = +{ + none = 0, + linear = 1, + relative = 2, +} + +ccui.LinearGravity = +{ + none = 0, + left = 1, + top = 2, + right = 3, + bottom = 4, + centerVertical = 5, + centerHorizontal = 6, +} + +ccui.RelativeAlign = +{ + alignNone = 0, + alignParentTopLeft = 1, + alignParentTopCenterHorizontal = 2, + alignParentTopRight = 3, + alignParentLeftCenterVertical = 4, + centerInParent = 5, + alignParentRightCenterVertical = 6, + alignParentLeftBottom = 7, + alignParentBottomCenterHorizontal = 8, + alignParentRightBottom = 9, + locationAboveLeftAlign = 10, + locationAboveCenter = 11, + locationAboveRightAlign = 12, + locationLeftOfTopAlign = 13, + locationLeftOfCenter = 14, + locationLeftOfBottomAlign = 15, + locationRightOfTopAlign = 16, + locationRightOfCenter = 17, + locationRightOfBottomAlign = 18, + locationBelowLeftAlign = 19, + locationBelowCenter = 20, + locationBelowRightAlign = 21, +} + +ccui.SliderEventType = {percentChanged = 0} + +ccui.LoadingBarType = { left = 0, right = 1} + +ccui.ScrollViewDir = { + none = 0, + vertical = 1, + horizontal = 2, + both = 3, +} + +ccui.ScrollViewMoveDir = { + none = 0, + up = 1, + down = 2, + left = 3, + right = 4, +} + +ccui.ScrollviewEventType = { + scrollToTop = 0, + scrollToBottom = 1, + scrollToLeft = 2, + scrollToRight = 3, + scrolling = 4, + bounceTop = 5, + bounceBottom = 6, + bounceLeft = 7, + bounceRight = 8, +} + +ccui.ListViewDirection = { + none = 0, + vertical = 1, + horizontal = 2, +} + +ccui.ListViewMoveDirection = { + none = 0, + up = 1, + down = 2, + left = 3, + right = 4, +} + +ccui.ListViewEventType = { + onsSelectedItem = 0, +} + +ccui.PageViewEventType = { + turning = 0, +} + +ccui.PVTouchDir = { + touchLeft = 0, + touchRight = 1, +} + +ccui.ListViewGravity = { + left = 0, + right = 1, + centerHorizontal = 2, + top = 3, + bottom = 4 , + centerVertical = 5, +} diff --git a/cocos/scripting/lua/script/StudioConstants.lua b/cocos/scripting/lua/script/StudioConstants.lua index 107b0f8406..5f9bca3036 100644 --- a/cocos/scripting/lua/script/StudioConstants.lua +++ b/cocos/scripting/lua/script/StudioConstants.lua @@ -2,186 +2,7 @@ ccs = ccs or {} ccs.MovementEventType = { - START = 0, - COMPLETE = 1, - LOOP_COMPLETE = 2, -} - -ccs.BrightStyle = -{ - none = -1, - normal = 0, - highlight = 1, -} - -ccs.WidgetType = -{ - widget = 0, --control - container = 1, --container -} - -ccs.TextureResType = -{ - UI_TEX_TYPE_LOCAL = 0, - UI_TEX_TYPE_PLIST = 1, -} - -ccs.TouchEventType = -{ - began = 0, - moved = 1, - ended = 2, - canceled = 3, -} - -ccs.SizeType = -{ - absolute = 0, - percent = 1, -} - -ccs.PositionType = { - absolute = 0, - percent = 1, -} - -ccs.CheckBoxEventType = -{ - selected = 0, - unselected = 1, -} - -ccs.TextFiledEventType = -{ - attach_with_ime = 0, - detach_with_ime = 1, - insert_text = 2, - delete_backward = 3, -} - -ccs.LayoutBackGroundColorType = -{ - none = 0, - solid = 1, - gradient = 2, -} - -ccs.LayoutType = -{ - absolute = 0, - linearVertical = 1, - linearHorizontal = 2, - relative = 3, -} - -ccs.UILayoutParameterType = -{ - none = 0, - linear = 1, - relative = 2, -} - -ccs.UILinearGravity = -{ - none = 0, - left = 1, - top = 2, - right = 3, - bottom = 4, - centerVertical = 5, - centerHorizontal = 6, -} - -ccs.UIRelativeAlign = -{ - alignNone = 0, - alignParentTopLeft = 1, - alignParentTopCenterHorizontal = 2, - alignParentTopRight = 3, - alignParentLeftCenterVertical = 4, - centerInParent = 5, - alignParentRightCenterVertical = 6, - alignParentLeftBottom = 7, - alignParentBottomCenterHorizontal = 8, - alignParentRightBottom = 9, - locationAboveLeftAlign = 10, - locationAboveCenter = 11, - locationAboveRightAlign = 12, - locationLeftOfTopAlign = 13, - locationLeftOfCenter = 14, - locationLeftOfBottomAlign = 15, - locationRightOfTopAlign = 16, - locationRightOfCenter = 17, - locationRightOfBottomAlign = 18, - locationBelowLeftAlign = 19, - locationBelowCenter = 20, - locationBelowRightAlign = 21, -} - -ccs.SliderEventType = {percent_changed = 0} - -ccs.LoadingBarType = { left = 0, right = 1} - -ccs.SCROLLVIEW_DIR = { - none = 0, - vertical = 1, - horizontal = 2, - both = 3, -} - -ccs.SCROLLVIEW_MOVE_DIR = { - none = 0, - up = 1, - down = 2, - left = 3, - right = 4, -} - -ccs.ScrollviewEventType = { - SCROLL_TO_TOP = 0, - SCROLL_TO_BOTTOM = 1, - SCROLL_TO_LEFT = 2, - SCROLL_TO_RIGHT = 3, - SCROLLING = 4, - BOUNCE_TOP = 5, - BOUNCE_BOTTOM = 6, - BOUNCE_LEFT = 7, - BOUNCE_RIGHT = 8, -} - -ccs.ListViewDirection = { - none = 0, - vertical = 1, - horizontal = 2, -} - -ccs.ListViewMoveDirection = { - none = 0, - up = 1, - down = 2, - left = 3, - right = 4, -} - -ccs.ListViewEventType = { - init_child = 0, - update_child = 1, -} - -ccs.PageViewEventType = { - turning = 0, -} - -ccs.PVTouchDir = { - touch_left = 0, - touch_right = 1, -} - -ccs.ListViewGravity = { - left = 0, - right = 1, - center_horizontal = 2, - top = 3, - bottom = 4 , - center_vertical = 5, + start = 0, + complete = 1, + loopComplete = 2, } diff --git a/samples/Lua/TestLua/Resources/luaScript/extern.lua b/cocos/scripting/lua/script/extern.lua similarity index 100% rename from samples/Lua/TestLua/Resources/luaScript/extern.lua rename to cocos/scripting/lua/script/extern.lua diff --git a/cocos/storage/local-storage/LocalStorageAndroid.cpp b/cocos/storage/local-storage/LocalStorageAndroid.cpp index a678b17edd..93de8f5dc2 100644 --- a/cocos/storage/local-storage/LocalStorageAndroid.cpp +++ b/cocos/storage/local-storage/LocalStorageAndroid.cpp @@ -1,7 +1,7 @@ -/* - - Copyright (c) 2012 - Zynga Inc. +/*************************************************************************** + Copyright (c) 2012 Zynga Inc. Copyright (c) 2013 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologic Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -20,8 +20,8 @@ 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. +***************************************************************************/ - */ /* Local Storage support for the JS Bindings for iOS. diff --git a/docs/RELEASE_NOTES b/docs/RELEASE_NOTES deleted file mode 100644 index f10872da6c..0000000000 --- a/docs/RELEASE_NOTES +++ /dev/null @@ -1,4 +0,0 @@ -===== cocos2d-x 3.0 Release Notes ===== - -Please, read the online release notes document: -http://www.cocos2d-x.org/wiki/Release_Notes_for_Cocos2d-x_v300 \ No newline at end of file diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md new file mode 100644 index 0000000000..c9e5c61dcd --- /dev/null +++ b/docs/RELEASE_NOTES.md @@ -0,0 +1,711 @@ +# cocos2d-x v3.0 Release Notes # + +**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* + +- [cocos2d-x v3.0 Release Notes](#cocos2d-x-v30-release-notes) +- [Misc Information](#misc-information) +- [Requirements](#requirements) + - [Runtime Requirements](#runtime-requirements) + - [Compiler Requirements](#compiler-requirements) +- [Highlights of v3.0.0](#highlights-of-v300) +- [Features in detail](#features-in-detail) + - [C++11 features](#c++11-features) + - [std::function](#stdfunction) + - [strongly typed enums](#strongly-typed-enums) + - [override](#override) + - [Removed Objective-C patterns](#removed-objective-c-patterns) + - [No more 'CC' prefix for C++ classes and free functions](#no-more-'cc'-prefix-for-c++-classes-and-free-functions) + - [clone() instead of copy()](#clone-instead-of-copy) + - [Singletons use getInstance() and destroyInstance()](#singletons-use-getinstance-and-destroyinstance) + - [getters](#getters) + - [POD types](#pod-types) + - [New renderer](#new-renderer) + - [Improved LabelTTF / LabelBMFont](#improved-labelttf--labelbmfont) + - [New EventDispatcher](#new-eventdispatcher) + - [Adding Touch Event Listener](#adding-touch-event-listener) + - [Adding Mouse Event Listener](#adding-mouse-event-listener) + - [Adding A Keyboard Event Listener](#adding-a-keyboard-event-listener) + - [Adding An Acceleration Event Listener](#adding-an-acceleration-event-listener) + - [Adding A Custom Event Listener](#adding-a-custom-event-listener) + - [Dispatching A Custom Event](#dispatching-a-custom-event) + - [Setting Fixed Priority For A Listener](#setting-fixed-priority-for-a-listener) + - [Removing Event Listener](#removing-event-listener) + - [Removing A Specified Event Listener](#removing-a-specified-event-listener) + - [Removing Custom Event Listener](#removing-custom-event-listener) + - [Removing All Listeners For Specified Event Listener Type](#removing-all-listeners-for-specified-event-listener-type) + - [Removing All Listeners](#removing-all-listeners) + + - [Physics Integration](#physics-integration) + - [PhysicsWorld](#physicsworld) + - [PhysicsBody](#physicsbody) + - [PhysicsShape](#physicsshape) + - [PhysicsJoint](#physicsjoint) + - [PhysicsContact](#physicscontact) +- [Misc API Changes](#misc-api-changes) + - [`ccTypes.h`](#cctypesh) + - [deprecated functions and global variables](#deprecated-functions-and--global-variables) + - [Changes in the Lua bindings](#changes-in-the-lua-bindings) + - [Use bindings-generator tool for Lua binding](#use-bindings-generator-tool-for-lua-binding) + - [Use ScriptHandlerMgr to manage the register and unregister of lua function](#use-scripthandlermgr-to-manage-the-register-and-unregister-of-lua-function) + - [Use "cc" and "ccs" as module name](#use-cc-and-ccs-as-module-name) + - [Deprecated funtions, tables and classes](#deprecated-funtions-tables-and-classes) + - [Use the lua table instead of the some structs and classes binding](#use-the-lua-table-instead-of-the-some-structs-and-classes-binding) + - [Known issues](#known-issues) + +# Misc Information + +* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.0beta.zip +* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.0beta/CHANGELOG +* API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.0beta/index.html + +# Requirements + +## Runtime Requirements + +* Android 2.3 or newer +* iOS 5.0 or newer +* OS X 10.7 or newer +* Windows 7 or newer +* ~~Windows Phone 8 or newer~~ N/A for the moment +* Linux Ubuntu 12.04 (or newer) +* ~~Browsers via Emscripten~~ N/A for the moment +* ~~Marmalade~~ N/A for the moment +* ~~BlackBerry~~ N/A for the moment + +## Compiler Requirements + +* Xcode 4.6 (for iOS or Mac) +* gcc 4.7 for Linux or Android. For Android ndk-r9 or newer is required. +* Visual Studio 2012 (for Windows) + +# Highlights of v3.0 + +* Replaced Objective-C patters with C++ (C++11) patterns and best practices +* Improved Labels +* Improved renderer +* New Event Dispatcher +* Physics integration +* New GUI +* JavaScript remote debugger +* Remote Console support +* Refactor Image - release memory in time and uniform the api of supported file format +* Automatically generated Lua bindings, add LuaJavaBridge and LuaObjcBridge +* Templated containers + +# Features in detail + +## C++11 features + +_Feature added in v3.0-pre-alpha0_ + +A subset of C++11 features are being used in cocos2d-x: + +* `std::function`, including lambda objects for callbacks +* strongly typed enums, for most of the cocos2d-x enums and constants +* `std::thread` for threading +* `override` context keyword, for overriden methods + + +### std::function + +* `CallFunc` can be created with an `std::function` +* `CallFuncN` can be created with an `std::function` +* `CallFuncND` and `CallFuncO` were removed since it can be created with simulated with `CallFuncN` and `CallFunc`. See ActionsTest.cpp for more examples +* `MenuItem` supports `std::function` as callbacks + +`CallFunc` example: + +```cpp +// in v2.1 +CCCallFunc *action1 = CCCallFunc::create( this, callfunc_selector( MyClass::callback_0 ) ); + +// in v3.0 (short version) +auto action1 = CallFunc::create( CC_CALLBACK_0(MyClass::callback_0,this)); +auto action2 = CallFunc::create( CC_CALLBACK_0(MyClass::callback_1,this, additional_parameters)); + +// in v3.0 (long version) +auto action1 = CallFunc::create( std::bind( &MyClass::callback_0, this)); +auto action2 = CallFunc::create( std::bind( &MyClass::callback_1, this, additional_parameters)); + +// in v3.0 you can also use lambdas or any other "Function" object +auto action1 = CallFunc::create( + [&](){ + auto s = Director::sharedDirector()->getWinSize(); + auto label = LabelTTF::create("called:lambda callback", "Marker Felt", 16); + label->setPosition(ccp( s.width/4*1,s.height/2-40)); + this->addChild(label); + } ); +``` + +`MenuItem` example: +```c++ +// in v2.1 +CCMenuItemLabel *item = CCMenuItemLabel::create(label, this, menu_selector(MyClass::callback)); + +// in v3.0 (short version) +auto item = MenuItemLabel::create(label, CC_CALLBACK_1(MyClass::callback, this)); + +// in v3.0 (long version) +auto item = MenuItemLabel::create(label, std::bind(&MyClass::callback, this, std::placeholders::_1)); + +// in v3.0 you can use lambdas or any other "Function" object +auto item = MenuItemLabel::create(label, + [&](Object *sender) { + // do something. Item "sender" clicked + }); +``` + +### strongly typed enums + +_Feature added in v3.0-pre-alpha0_ + +Constants and enums that started with `k`, and that usually were defined as `int` or as simple `enum` where replaced with strongly typed enums ( `enum class` ) to prevent collisions and type errors. +The new format is: + + | v2.1 | v3.0 | + | kTypeValue | Type::VALUE | + +Examples: + + | v2.1 | v3.0 | + | kCCTexture2DPixelFormat_RGBA8888 | Texture2D::PixelFormat::RGBA8888 | + | kCCDirectorProjectionCustom | Director::Projection::CUSTOM | + | ccGREEN | Color3B::GREEN | + | CCPointZero | Point::ZERO | + | CCSizeZero | Size::ZERO | + +The old values can still be used, but are not deprecated. + +### override + +To catch possible errors while overriding methods, subclasses with override methods have the `override` context keyword. +Example: +```c++ +class Sprite : public Node { + bool isFlipY(void) const; + void setFlipY(bool bFlipY); + + // Overrides + virtual void setTexture(Texture2D *texture) override; + virtual Texture2D* getTexture() const override; + inline void setBlendFunc(const BlendFunc &blendFunc) override; + inline const BlendFunc& getBlendFunc() const override; +} +``` + +## Removed Objective-C patterns + +_Feature added in v3.0-pre-alpha0_ + +### No more 'CC' prefix for C++ classes and free functions + +*Changes in classes* + +Since cocos2d-x already uses the `cocos2d` namespace, there is not need to add the prefix `CC` to all its classes. + +Examples: + + | v2.1 | v3.0 | + | CCSprite | Sprite | + | CCNode | Node | + | CCDirector | Director | + | etc... | + +v2.1 class names are still available, but they were tagged as deprecated. + +*Changes in free functions* + +For the *drawing primitives*: +* They were added in the `DrawPrimitives` namespace +* The `cc` prefix was removed + +For the *gl proxy functions*: +* They were added in the `GL` namespace +* The `ccGL` prefix was removed + +Examples: + + | v2.1 | v3.0 | + | ccDrawPoint() | DrawPrimitives::drawPoint() | + | ccDrawCircle() | DrawPrimitives::drawCircle() | + | ccGLBlendFunc() | GL::blendFunc() | + | ccGLBindTexture2D() | GL::bindTexture2D() | + | etc... | + +v2.1 free functions are still available, but they were tagged as deprecated. + + +### clone() instead of copy() + +`clone()` returns an autoreleased version of the copy. + +`copy()` is no longer supported. If you use it, it will compile, but the code will crash. + +Example: +```c++ +// v2.1 +CCMoveBy *action = (CCMoveBy*) move->copy(); +action->autorelease(); + +// v3.0 +// No need to do autorelease, no need to do casting. +auto action = move->clone(); +``` + +### Singletons use getInstance() and destroyInstance() + +All singletons use `getInstance()` and `destroyInstance()` (if applicable) to get and destroy the instance. + +Examples: + + | v2.1 | v3.0 | + | CCDirector->sharedDirector() | Director->getInstance() | + | CCDirector->endDirector() | Director->destroyInstance() | + | etc... | + + +v2.1 methods are still available, but they were tagged as deprecated. + +### getters + +Getters now use the `get` prefix. + +Examples: + + | v2.1 | v3.0* | + | node->boundingBox() | node->getBoundingBox() | + | sprite->nodeToParentTransform() | sprite->getNodeToParentTransform() | + | etc... | + +And getters were also tagged as `const` in their declaration. Example: + +```c++ +// v2.1 +virtual float getScale(); + +// v3.0 +virtual float getScale() const; +``` + +v2.1 methods are still available, but they were tagged as deprecated. + +### POD types + +Methods that were receiving POD types as arguments (eg: `TexParams`, `Point`, `Size`, etc.) are being passed as `const` reference. + +Example: +```c++ +// v2.1 +void setTexParameters(ccTexParams* texParams); + +// v3.0 +void setTexParameters(const ccTexParams& texParams); +``` + + +## New Renderer + +_Feature added in v3.0-beta_ + +The renderer functionality has been decoupled from the Scene graph / Node logic. A new object called `Renderer` is responsible for rendering the object. + +Auto-batching and auto-culling support has been added. + +Please, see this document for detail information about its internal funcitonality: https://docs.google.com/document/d/17zjC55vbP_PYTftTZEuvqXuMb9PbYNxRFu0EGTULPK8/edit + +## Improved LabelTTF / LabelBMFont + +_Feature added in v3.0-alpha0_ + +## New EventDispatcher + +_Feature added in v3.0-alpha0_ + +All events like touch event, keyboard event, acceleration event and custom event are dispatched by `EventDispatcher`. +`TouchDispatcher`, `KeypadDispatcher`, `KeyboardDispatcher`, `AccelerometerDispatcher` were removed. + +### Adding Touch Event Listener + +For TouchOneByOne: +```c++ +auto sprite = Sprite::create("file.png"); +... +auto listener = EventListenerTouchOneByOne::create(); +listener->setSwallowTouch(true); +listener->onTouchBegan = [](Touch* touch, Event* event) { do_some_thing(); return true; }; +listener->onTouchMoved = [](Touch* touch, Event* event) { do_some_thing(); }; +listener->onTouchEnded = [](Touch* touch, Event* event) { do_some_thing(); }; +listener->onTouchCancelled = [](Touch* touch, Event* event) { do_some_thing(); }; +// The priority of the touch listener is based on the draw order of sprite +EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, sprite); +// Or the priority of the touch listener is a fixed value +EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, 100); // 100 is a fixed value +``` + +For TouchAllAtOnce +```c++ +auto sprite = Sprite::create("file.png"); +... +auto listener = EventListenerTouchAllAtOnce::create(); +listener->onTouchesBegan = [](const std::vector& touches, Event* event) { do_some_thing(); }; +listener->onTouchesMoved = [](const std::vector& touches, Event* event) { do_some_thing(); }; +listener->onTouchesEnded = [](const std::vector& touches, Event* event) { do_some_thing(); }; +listener->onTouchesCancelled = [](const std::vector& touches, Event* event) { do_some_thing(); }; +// The priority of the touch listener is based on the draw order of sprite +EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, sprite); +// Or the priority of the touch listener is a fixed value +EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, 100); // 100 is a fixed value +``` + +### Adding Mouse Event Listener ### +```c++ +auto mouseListener = EventListenerMouse::create(); +mouseListener->onMouseScroll = [](Event* event) { EventMouse* e = static_cast(event); do_some_thing(); }; +mouseListener->onMouseUp = [](Event* event) { EventMouse* e = static_cast(event); do_some_thing(); }; +mouseListener->onMouseDown = [](Event* event) { EventMouse* e = static_cast(event); do_some_thing(); }; +dispatcher->addEventListenerWithSceneGraphPriority(mouseListener, this); +``` + +### Adding A Keyboard Event Listener + +```c++ +auto listener = EventListenerKeyboard::create(); +listener->onKeyPressed = CC_CALLBACK_2(SomeClass::onKeyPressed, this); +listener->onKeyReleased = CC_CALLBACK_2(SomeClass::onKeyReleased, this); +EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, this); +``` + +### Adding An Acceleration Event Listener + +```c++ +auto listener = EventListenerAcceleration::create(CC_CALLBACK_2(SomeClass::onAcceleration, this)); +EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, this); +``` + +### Adding A Custom Event Listener + +```c++ +auto listener = EventListenerCustom::create("game_custom_event", [=](EventCustom* event){ + void* userData= event->getUserData(); + do_some_with_user_data(); +}); +dispatcher->addEventListenerWithFixedPriority(listener, 1); +``` + +### Dispatching A Custom Event + +```c++ +EventCustom event("game_custom_event"); +event.setUserData(some_data); +dispatcher->dispatchEvent(&event); +``` + +### Setting Fixed Priority For A Listener + +```c++ +dispatcher->setPriority(fixedPriorityListener, 200); +``` + +### Removing Event Listener + +#### Removing A Specified Event Listener + +```c++ +dispatcher->removeEventListener(listener); +``` + +#### Removing Custom Event Listener #### + +```c++ +dispatcher->removeCustomEventListener("my_custom_event_listener_name"); +``` + +#### Removing All Listeners For An Event Listener Type + +```c++ +dispatcher->removeEventListeners(EventListener::Type::TOUCH_ONE_BY_ONE); +``` + +#### Removing All Listeners + +```c++ +dispatcher->removeAllListeners(); +``` + +## Physics Integration + +_Feature added in v3.0-pre-alpha0_ + +Physics integration have five concepts: `PhysicsWorld`, `PhysicsBody`, `PhysicsShape`, `PhysicsJoint` and `PhysicsContact`. +You must define `CC_USE_PHYSICS` macro in `ccConfig.h` to use the physics API. + +### PhysicsWorld + +A `PhysicsWorld` object simulates collisions and other physical properties, you do not create it directly, you can get it from scene which create with physics. +```c++ +Scene* scene = Scene::createWithPhysics(); +PhysicsWorld* world = scene->getPhysicsWorld(); +``` + +### PhysicsBody + +A `PhysicsBody` object is used to add physics simulation to a node. If you create a `PhysicsBody` and set it to a node, and add the node the a scene which create with physics, it will perform the physics simulation when update. +```c++ +PhysicsBody* body = PhysicsBody::createCircle(5.0f); +Node* node = Node::create(); +node->setPhysicsBody(body); +scene->addChild(node); +``` + +### PhysicsShape + +A `PhysicsShape` object is a shape that make the body can have collisions. you can add one or more `PhysicsShape` to a `PhysicsBody`. +Shape classes: `PhysicsShapeCircle`, `PhysicsShapeBox`, `PhysicsShapePolygon`, `PhysicsShapeEdgeSegment`, `PhysicsShapeEdgeBox`, `PhysicsShapeEdgePolygon`, `PhysicsShapeEdgeChain`. +```c++ +PhysicsShape* shape = PhysicsShapeBox::create(Size(5.0f, 10.0f); +body->addShape(shape); +``` + +### PhysicsJoint + +A `PhysicsJoint` object connects two physics bodies together so that they are simulated together by the physics world. +Joint classes: `PhysicsJointFixed`, `PhysicsJointLimit`, `PhysicsJointPin`, `PhysicsJointDistance`, `PhysicsJointSpring`, `PhysicsJointGroove`, `PhysicsJointRotarySpring`, `PhysicsJointRotaryLimit`, `PhysicsJointRatchet`, `PhysicsJointGear`, `PhysicsJointMotor`. +```c++ +PhysicsJoint* joint = PhysicsJointDistance::construct(bodyA, bodyB, Point::ZERO, Point::ZERO); +world->addJoint(joint); +``` + +### PhysicsContact + +A `PhysicsContact` object is created automatically to describes a contact between two physical bodies in a `PhysicsWorld`. you can control the contact behavior from the physics contact event listener. +Other classes contain the contact information: `PhysicsContactPreSolve`, `PhysicsContactPostSolve`. +The event listener for physics: `EventListenerPhysicsContact`, `EventListenerPhysicsContactWithBodies`, `EventListenerPhysicsContactWithShapes`, `EventListenerPhysicsContactWithGroup`. +```c++ +auto contactListener = EventListenerPhysicsContactWithBodies::create(bodyA, bodyB); +contactListener->onContactBegin = [](EventCustom* event, const PhysicsContact& contact) -> bool +{ +doSomething(); +return true; +}; +_eventDispatcher->addEventListenerWithSceneGraphPriority(contactListener, this); +``` + + +# Misc API Changes + +## `ccTypes.h` + +Remove *cc* prefix for structure names in ccTypes.h, move global functions into static member functions, and move global constants into const static member variables. + + | v2.1 struct names | v3.0 struct names | + | ccColor3B | Color3B | + | ccColor4B | Color4B | + | ccColor4F | Color4F | + | ccVertex2F | Vertex2F | + | ccVertex3F | Vertex3F | + | ccTex2F | Tex2F | + | ccPointSprite | PointSprite | + | ccQuad2 | Quad2 | + | ccQuad3 | Quad3 | + | ccV2F_C4B_T2F | V2F_C4B_T2F | + | ccV2F_C4F_T2F | V2F_C4F_T2F | + | ccV3F_C4B_T2F | V3F_C4B_T2F | + | ccV2F_C4B_T2F_Triangle | V2F_C4B_T2F_Triangle | + | ccV2F_C4B_T2F_Quad | V2F_C4B_T2F_Quad | + | ccV3F_C4B_T2F_Quad | V3F_C4B_T2F_Quad | + | ccV2F_C4F_T2F_Quad | V2F_C4F_T2F_Quad | + | ccBlendFunc | BlendFunc | + | ccT2F_Quad | T2F_Quad | + | ccAnimationFrameData | AnimationFrameData | + +Global functions changed example +```c++ +// in v2.1 +ccColor3B color3B = ccc3(0, 0, 0); +ccc3BEqual(color3B, ccc3(1, 1, 1)); +ccColor4B color4B = ccc4(0, 0, 0, 0); +ccColor4F color4F = ccc4f(0, 0, 0, 0); +color4F = ccc4FFromccc3B(color3B); +color4F = ccc4FFromccc4B(color4B); +ccc4FEqual(color4F, ccc4F(1, 1, 1, 1)); +color4B = ccc4BFromccc4F(color4F); + +color3B = ccWHITE; + +// in v3.0 +Color3B color3B = Color3B(0, 0, 0); +color3B.equals(Color3B(1, 1, 1)); +Color4B color4B = Color4B(0, 0, 0, 0); +Color4F color4F = Color4F(0, 0, 0, 0); +color4F = Color4F(color3B); +color4F = Color4F(color4B); +color4F.equals(Color4F(1, 1, 1, 1)); +color4B = Color4B(color4F); + +color3B = Color3B::WHITE; +``` + +## deprecated functions and global variables + + | v2.1 names | v3.0 names | + | ccp | Point | + | ccpNeg | Point::- | + | ccpAdd | Point::+ | + | ccpSub | Point::- | + | ccpMult | Point::* | + | ccpMidpoint | Point::getMidpoint | + | ccpDot | Point::dot | + | ccpCrosss | Point::cross | + | ccpPerp | Point::getPerp | + | ccpRPerp | Point::getRPerp | + | ccpProject | Point::project | + | ccpRotate | Point::rotate | + | ccpUnrotate | Point::unrotate | + | ccpLengthSQ | Point::getLengthSq() | + | ccpDistanceSQ | Point::getDistanceSq | + | ccpLength | Point::getLength | + | ccpDistance | Point::getDistance | + | ccpNormalize | Point::normalize | + | ccpForAngle | Point::forAngle | + | ccpToAngle | Point::getAngle | + | ccpClamp | Point::getClampPoint | + | ccpFromSize | Point::Point | + | ccpCompOp | Point::compOp | + | ccpLerp | Point::lerp | + | ccpFuzzyEqual | Point::fuzzyEqual | + | ccpCompMult | Point::Point | + | ccpAngleSigned | Point::getAngle | + | ccpAngle | Point::getAngle | + | ccpRotateByAngle | Point::rotateByAngle | + | ccpLineInersect | Point::isLineIntersect | + | ccpSegmentIntersect | Point::isSegmentIntersect | + | ccpIntersectPoint | Point::getIntersectPoint | + | CCPointMake | Point::Point | + | CCSizeMake | Size::Size | + | CCRectMake | Rect::Rect | + | PointZero | Point::ZERO | + | SizeZero | Size::ZERO | + | RectZero | Rect::ZERO | + | TiledGrid3DAction::tile | TiledGrid3DAction::getTile | + | TiledGrid3DAction::originalTile | TiledGrid3DAction::getOriginalTile | + | TiledGrid3D::tile | TiledGrid3D::getTile | + | TiledGrid3D::originalTile | TiledGrid3D::getOriginalTile | + | Grid3DAction::vertex | Grid3DAction::getVertex | + | Grid3DAction::originalVertex | Grid3DAction::getOriginalVertex | + | Grid3D::vertex | Grid3D::getVertex | + | Grid3D::originalVertex | Grid3D::getOriginalVertex | + | Configuration::sharedConfiguration | Configuration::getInstance | + | Configuration::purgeConfiguration | Configuration::destroyInstance() | + | Director::sharedDirector() | Director::getInstance() | + | FileUtils::sharedFileUtils | FileUtils::getInstance | + | FileUtils::purgeFileUtils | FileUtils::destroyInstance | + | EGLView::sharedOpenGLView | EGLView::getInstance | + | ShaderCache::sharedShaderCache | ShaderCache::getInstance | + | ShaderCache::purgeSharedShaderCache | ShaderCache::destroyInstance | + | AnimationCache::sharedAnimationCache | AnimationCache::getInstance | + | AnimationCache::purgeSharedAnimationCache | AnimationCache::destroyInstance | + | SpriteFrameCache::sharedSpriteFrameCache | SpriteFrameCache::getInstance | + | SpriteFrameCache:: purgeSharedSpriteFrameCache | SpriteFrameCache::destroyInstance | + | NotificationCenter::sharedNotificationCenter | NotificationCenter::getInstance | + | NotificationCenter:: purgeNotificationCenter | NotificationCenter::destroyInstance | + | Profiler::sharedProfiler | Profiler::getInstance | + | UserDefault::sharedUserDefault | UserDefault::getInstance | + | UserDefault::purgeSharedUserDefault | UserDefault::destroyInstance | + | Application::sharedApplication | Application::getInstance | + | ccc3() | Color3B() | + | ccc3BEqual() | Color3B::equals() | + | ccc4() | Color4B() | + | ccc4FFromccc3B() | Color4F() | + | ccc4f() | Color4F() | + | ccc4FFromccc4B() | Color4F() | + | ccc4BFromccc4F() | Color4B() | + | ccc4FEqual() | Color4F::equals() | + | ccWHITE | Color3B::WHITE | + | ccYELLOW | Color3B::YELLOW | + | ccBLUE | Color3B::BLUE | + | ccGREEN | Color3B::GREEN | + | ccRED | Color3B::RED | + | ccMAGENTA | Color3B::MAGENTA | + | ccBLACK | Color3B::BLACK | + | ccORANGE | Color3B::ORANGE | + | ccGRAY | Color3B::GRAY | + | kBlendFuncDisable | BlendFunc::BLEND_FUNC_DISABLE | + +## Changes in the Lua bindings + +### Use bindings-generator tool for Lua binding + +Only configurating the *.ini files in the tools/tolua folder,not to write a lot of *.pkg files + +### Use ScriptHandlerMgr to manage the register and unregister of Lua function + +When we want to add register and unregister functions of Lua function for class, we need to change the declarative and defined files and then bind to Lua. +In v3.0, we use the `ScriptHandlerMgr`. As an example, lets see the `MenuItem` class: +In the 2.x version, we needed to add a declaration in the MenuItem header file: +```c++ + virtual void registerScriptTapHandler(int nHandler); + virtual void unregisterScriptTapHandler(void); +``` +then implement them in the .cpp file. In the Lua script ,we use it as follow: +```lua +menuItem:registerScriptTapHandler(luafunction) +``` + +In v3.0 version, we only need to add the `HandlerType` enum in the `ScriptHandlerMgr`, and the implementation in luascript as follow: +```lua +ScriptHandlerMgr:getInstance():registerScriptHandler(menuItem, luafunction,cc.HANDLERTYPE_MENU_CLICKED) +``` + +### Use "cc" and "ccs" as module name + +```lua +// v2.x +CCSprite:create(s_pPathGrossini) +CCEaseIn:create(createSimpleMoveBy(), 2.5) + +UILayout:create() + +// v3.0 +cc.Director:getInstance():getWinSize() +cc.EaseIn:create(createSimpleMoveBy(), 2.5) + +ccs.UILayer:create() +``` + +### Deprecated funtions, tables and classes + +Add a lot of deprecate funtions、table and classes to support 2.x version as far as possible +Note: `Rect does not support the origin and size member variables` + +### Use the Lua table instead of the some structs and classes binding + +Point、Size、Rect、Color3b、Color4b、Color4F、AffineTransform、FontDefinition、Array、Dictionary、PointArray are not bound. +The difference is as follow: +```lua +// v2.x +local pt = CCPoint(0 , 0) +local rect = CCRect(0, 0, 0, 0) +// v3.0 +local pt = cc.p(0, 0) +local rect = cc.rect(0,0,0,0) +``` + +Global functions about these classes are changed as follow: +```lua +// in v2.x +local pt = ccp(0,0) +local color3B = ccc3(0, 0, 0) +local color4B = ccc4(0, 0, 0, 0) + +// in v3.0 +local pt = cc.p(0,0) +local color3B = cc.c3b(0,0,0) +local color4B = cc.c4b(0,0,0,0) +``` + +Through the funtions of the LuaBasicConversion file,they can be converted the Lua table when they are as a parameter in the bindings generator. + + +## Known issues + +You can find all the known issues "here":http://www.cocos2d-x.org/projects/native/issues diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index f8083e1220..9441b8ca26 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -24,17 +24,30 @@ set(EXTENSIONS_SRC physics-nodes/CCPhysicsSprite.cpp ) +if(WIN32) + ADD_DEFINITIONS(-DUNICODE -D_UNICODE) + + set(PLATFORM_EXTENSIONS_SRC + proj.win32/Win32InputBox.cpp + ) +elseif(APPLE) + +else() + +endif() + include_directories( .. ) add_library(extensions STATIC ${EXTENSIONS_SRC} + ${PLATFORM_EXTENSIONS_SRC} ) set_target_properties(extensions PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index 4bd03a0fde..9312c82995 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -80,13 +80,13 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b _parentInited = true; _isPushed = false; - _zoomOnTouchDown = true; // Adjust the background image by default setAdjustBackgroundImage(true); setPreferredSize(Size::ZERO); // Zooming button by default _zoomOnTouchDown = true; + _scaleRatio = 1.1f; // Set the default anchor point ignoreAnchorPointForPosition(false); @@ -199,7 +199,7 @@ void ControlButton::setHighlighted(bool enabled) needsLayout(); if( _zoomOnTouchDown ) { - float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? 1.1f : 1.0f; + float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? _scaleRatio : 1.0f; Action *zoomAction = ScaleTo::create(0.05f, scaleValue); zoomAction->setTag(kZoomActionTag); runAction(zoomAction); diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index 7ab0e1a284..d4208c0566 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -226,6 +226,8 @@ protected: /** Adjust the button zooming on touchdown. Default value is YES. */ CC_PROPERTY(bool, _zoomOnTouchDown, ZoomOnTouchDown); + /** Scale ratio button on touchdown. Default value 1.1f */ + CC_SYNTHESIZE(float, _scaleRatio, ScaleRatio); CC_PROPERTY_PASS_BY_REF(Point, _labelAnchorPoint, LabelAnchorPoint); diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index bafd327d69..ace6ef2cec 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -40,6 +40,7 @@ ControlSlider::ControlSlider() , _minimumAllowedValue(0.0f) , _maximumAllowedValue(0.0f) , _thumbSprite(NULL) +, _selectedThumbSprite(NULL) , _progressSprite(NULL) , _backgroundSprite(NULL) { @@ -49,6 +50,7 @@ ControlSlider::ControlSlider() ControlSlider::~ControlSlider() { CC_SAFE_RELEASE(_thumbSprite); + CC_SAFE_RELEASE(_selectedThumbSprite); CC_SAFE_RELEASE(_progressSprite); CC_SAFE_RELEASE(_backgroundSprite); } @@ -57,6 +59,21 @@ ControlSlider* ControlSlider::create(const char* bgFile, const char* progressFil { // Prepare background for slider Sprite *backgroundSprite = Sprite::create(bgFile); + + // Prepare progress for slider + Sprite *progressSprite = Sprite::create(progressFile); + + // Prepare thumb (menuItem) for slider + Sprite *thumbSprite = Sprite::create(thumbFile); + + return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite); +} + +ControlSlider* ControlSlider::create(const char* bgFile, const char* progressFile, const char* thumbFile, + const char* selectedThumbSpriteFile) +{ + // Prepare background for slider + Sprite *backgroundSprite = Sprite::create(bgFile); // Prepare progress for slider Sprite *progressSprite = Sprite::create(progressFile); @@ -64,7 +81,10 @@ ControlSlider* ControlSlider::create(const char* bgFile, const char* progressFil // Prepare thumb (menuItem) for slider Sprite *thumbSprite = Sprite::create(thumbFile); - return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite); + // Prepare selected thumb (menuItem) for slider + Sprite *selectedThumbSprite = Sprite::create(selectedThumbSpriteFile); + + return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite, selectedThumbSprite); } ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite) @@ -75,19 +95,39 @@ ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressS return pRet; } - bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite) +ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite, + Sprite* selectedThumbSprite) +{ + ControlSlider *pRet = new ControlSlider(); + pRet->initWithSprites(backgroundSprite, pogressSprite, thumbSprite, selectedThumbSprite); + pRet->autorelease(); + return pRet; +} + +bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite) +{ + Sprite* selectedThumbSprite = Sprite::createWithTexture(thumbSprite->getTexture(), + thumbSprite->getTextureRect()); + selectedThumbSprite->setColor(Color3B::GRAY); + return this->initWithSprites(backgroundSprite, progressSprite, thumbSprite, selectedThumbSprite); +} + + bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite, + Sprite* selectedThumbSprite) { if (Control::init()) { - CCASSERT(backgroundSprite, "Background sprite must be not nil"); - CCASSERT(progressSprite, "Progress sprite must be not nil"); - CCASSERT(thumbSprite, "Thumb sprite must be not nil"); + CCASSERT(backgroundSprite, "Background sprite must be not nil"); + CCASSERT(progressSprite, "Progress sprite must be not nil"); + CCASSERT(thumbSprite, "Thumb sprite must be not nil"); + CCASSERT(selectedThumbSprite, "Thumb sprite must be not nil"); ignoreAnchorPointForPosition(false); this->setBackgroundSprite(backgroundSprite); this->setProgressSprite(progressSprite); this->setThumbSprite(thumbSprite); + this->setSelectedThumbSprite(selectedThumbSprite); // Defines the content size Rect maxRect = ControlUtils::RectUnion(backgroundSprite->getBoundingBox(), thumbSprite->getBoundingBox()); @@ -108,6 +148,10 @@ ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressS _thumbSprite->setPosition(Point(0.0f, this->getContentSize().height / 2)); addChild(_thumbSprite); + _selectedThumbSprite->setPosition(Point(0.0f, this->getContentSize().height / 2)); + _selectedThumbSprite->setVisible(false); + addChild(_selectedThumbSprite); + // Init default values _minimumValue = 0.0f; _maximumValue = 1.0f; @@ -227,7 +271,8 @@ void ControlSlider::onTouchEnded(Touch *pTouch, Event *pEvent) void ControlSlider::needsLayout() { - if (NULL == _thumbSprite || NULL == _backgroundSprite || NULL == _progressSprite) + if (NULL == _thumbSprite || NULL == _selectedThumbSprite || NULL == _backgroundSprite + || NULL == _progressSprite) { return; } @@ -237,6 +282,7 @@ void ControlSlider::needsLayout() Point pos = _thumbSprite->getPosition(); pos.x = percent * _backgroundSprite->getContentSize().width; _thumbSprite->setPosition(pos); + _selectedThumbSprite->setPosition(pos); // Stretches content proportional to newLevel Rect textureRect = _progressSprite->getTextureRect(); @@ -247,7 +293,8 @@ void ControlSlider::needsLayout() void ControlSlider::sliderBegan(Point location) { this->setSelected(true); - this->getThumbSprite()->setColor(Color3B::GRAY); + _thumbSprite->setVisible(false); + _selectedThumbSprite->setVisible(true); setValue(valueForLocation(location)); } @@ -262,7 +309,8 @@ void ControlSlider::sliderEnded(Point location) { setValue(valueForLocation(_thumbSprite->getPosition())); } - this->getThumbSprite()->setColor(Color3B::WHITE); + _thumbSprite->setVisible(true); + _selectedThumbSprite->setVisible(false); this->setSelected(false); } diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index 2a9f782e2d..9d5f2bc2ff 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -58,6 +58,22 @@ public: * @see initWithSprites */ static ControlSlider* create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite); + + /** + * Creates slider with a background filename, a progress filename, a thumb + * and a selected thumb image filename. + */ + static ControlSlider* create(const char* bgFile, const char* progressFile, const char* thumbFile, + const char* selectedThumbSpriteFile); + + /** + * Creates a slider with a given background sprite and a progress bar, a thumb + * and a selected thumb . + * + * @see initWithSprites + */ + static ControlSlider* create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite, + Sprite* selectedThumbSprite); /** * @js ctor */ @@ -68,15 +84,27 @@ public: */ virtual ~ControlSlider(); + /** + * Initializes a slider with a background sprite, a progress bar and a thumb + * item. + * + * @param backgroundSprite Sprite, that is used as a background. + * @param progressSprite Sprite, that is used as a progress bar. + * @param thumbSprite Sprite, that is used as a thumb. + */ + virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite); + /** * Initializes a slider with a background sprite, a progress bar and a thumb * item. * - * @param backgroundSprite Sprite, that is used as a background. - * @param progressSprite Sprite, that is used as a progress bar. - * @param thumbSprite Sprite, that is used as a thumb. + * @param backgroundSprite Sprite, that is used as a background. + * @param progressSprite Sprite, that is used as a progress bar. + * @param thumbSprite Sprite, that is used as a thumb. + * @param selectedThumbSprite Sprite, that is used as a selected thumb. */ - virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite); + virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite, + Sprite* selectedThumbSprite); virtual void needsLayout(); @@ -116,8 +144,10 @@ protected: // maybe this should be read-only CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite); + CC_SYNTHESIZE_RETAIN(Sprite*, _selectedThumbSprite, SelectedThumbSprite); CC_SYNTHESIZE_RETAIN(Sprite*, _progressSprite, ProgressSprite); CC_SYNTHESIZE_RETAIN(Sprite*, _backgroundSprite, BackgroundSprite); + }; // end of GUI group diff --git a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp index 13b2329579..f583398f06 100644 --- a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp @@ -43,11 +43,6 @@ public: LabelTTF* onLabel, LabelTTF* offLabel); - /** - * @js NA - * @lua NA - */ - void draw() override; /** * @js NA * @lua NA @@ -93,6 +88,8 @@ public: CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite) CC_SYNTHESIZE_RETAIN(LabelTTF*, _onLabel, OnLabel) CC_SYNTHESIZE_RETAIN(LabelTTF*, _offLabel, OffLabel) + + Sprite* _clipperStencil; protected: /** @@ -116,7 +113,6 @@ protected: Sprite *thumbSprite, LabelTTF* onLabel, LabelTTF* offLabel); - private: CC_DISALLOW_COPY_AND_ASSIGN(ControlSwitchSprite); }; @@ -146,6 +142,7 @@ ControlSwitchSprite::ControlSwitchSprite() , _thumbSprite(NULL) , _onLabel(NULL) , _offLabel(NULL) +, _clipperStencil(nullptr) { } @@ -158,6 +155,7 @@ ControlSwitchSprite::~ControlSwitchSprite() CC_SAFE_RELEASE(_onLabel); CC_SAFE_RELEASE(_offLabel); CC_SAFE_RELEASE(_maskTexture); + CC_SAFE_RELEASE(_clipperStencil); } bool ControlSwitchSprite::initWithMaskSprite( @@ -180,8 +178,24 @@ bool ControlSwitchSprite::initWithMaskSprite( setThumbSprite(thumbSprite); setOnLabel(onLabel); setOffLabel(offLabel); - - addChild(_thumbSprite); + //setOnSprite(nullptr); + //setOffSprite(nullptr); + //setOnLabel(nullptr); + //setOffLabel(nullptr); + ClippingNode* clipper = ClippingNode::create(); + _clipperStencil = Sprite::createWithTexture(maskSprite->getTexture()); + _clipperStencil->retain(); + clipper->setAlphaThreshold(0.1f); + + clipper->setStencil(_clipperStencil); + + clipper->addChild(thumbSprite); + clipper->addChild(onSprite); + clipper->addChild(offSprite); + clipper->addChild(onLabel); + clipper->addChild(offLabel); + + addChild(clipper); // Set up the mask with the Mask shader setMaskTexture(maskSprite->getTexture()); @@ -221,45 +235,6 @@ void ControlSwitchSprite::updateTweenAction(float value, const std::string& key) setSliderXPosition(value); } -void ControlSwitchSprite::draw() -{ - CC_NODE_DRAW_SETUP(); - - GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); - GL::blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - getShaderProgram()->setUniformsForBuiltins(); - - GL::bindTexture2DN(0, getTexture()->getName()); - glUniform1i(_textureLocation, 0); - - GL::bindTexture2DN(1, _maskTexture->getName()); - glUniform1i(_maskLocation, 1); - -#define kQuadSize sizeof(_quad.bl) -#ifdef EMSCRIPTEN - long offset = 0; - setGLBufferData(&_quad, 4 * kQuadSize, 0); -#else - long offset = (long)&_quad; -#endif // EMSCRIPTEN - - // vertex - int diff = offsetof( V3F_C4B_T2F, vertices); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); - - // texCoods - diff = offsetof( V3F_C4B_T2F, texCoords); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); - - // color - diff = offsetof( V3F_C4B_T2F, colors); - glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - GL::bindTexture2DN(0, 0); -} - void ControlSwitchSprite::needsLayout() { _onSprite->setPosition(Point(_onSprite->getContentSize().width / 2 + _sliderXPosition, @@ -269,6 +244,9 @@ void ControlSwitchSprite::needsLayout() _thumbSprite->setPosition(Point(_onSprite->getContentSize().width + _sliderXPosition, _maskTexture->getContentSize().height / 2)); + _clipperStencil->setPosition(Point(_maskTexture->getContentSize().width/2, + _maskTexture->getContentSize().height / 2)); + if (_onLabel) { _onLabel->setPosition(Point(_onSprite->getPosition().x - _thumbSprite->getContentSize().width / 6, diff --git a/extensions/GUI/CCEditBox/CCEditBox.h b/extensions/GUI/CCEditBox/CCEditBox.h index 23f375fc53..a1aac55d6e 100644 --- a/extensions/GUI/CCEditBox/CCEditBox.h +++ b/extensions/GUI/CCEditBox/CCEditBox.h @@ -366,45 +366,45 @@ public: void setReturnType(EditBox::KeyboardReturnType returnType); /* override functions */ - virtual void setPosition(const Point& pos); - virtual void setVisible(bool visible); - virtual void setContentSize(const Size& size); - virtual void setAnchorPoint(const Point& anchorPoint); + virtual void setPosition(const Point& pos) override; + virtual void setVisible(bool visible) override; + virtual void setContentSize(const Size& size) override; + virtual void setAnchorPoint(const Point& anchorPoint) override; /** * @js NA * @lua NA */ - virtual void visit(void); + virtual void visit(void) override; /** * @js NA * @lua NA */ - virtual void onEnter(void); + virtual void onEnter(void) override; /** * @js NA * @lua NA */ - virtual void onExit(void); + virtual void onExit(void) override; /** * @js NA * @lua NA */ - virtual void keyboardWillShow(IMEKeyboardNotificationInfo& info); + virtual void keyboardWillShow(IMEKeyboardNotificationInfo& info) override; /** * @js NA * @lua NA */ - virtual void keyboardDidShow(IMEKeyboardNotificationInfo& info); + virtual void keyboardDidShow(IMEKeyboardNotificationInfo& info) override; /** * @js NA * @lua NA */ - virtual void keyboardWillHide(IMEKeyboardNotificationInfo& info); + virtual void keyboardWillHide(IMEKeyboardNotificationInfo& info) override; /** * @js NA * @lua NA */ - virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info); + virtual void keyboardDidHide(IMEKeyboardNotificationInfo& info) override; /* callback funtions * @js NA diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 7ae70819af..05200d32cb 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -46,10 +46,10 @@ ScrollView::ScrollView() : _zoomScale(0.0f) , _minZoomScale(0.0f) , _maxZoomScale(0.0f) -, _delegate(NULL) +, _delegate(nullptr) , _direction(Direction::BOTH) , _dragging(false) -, _container(NULL) +, _container(nullptr) , _touchMoved(false) , _bounceable(false) , _clippingToBounds(false) @@ -104,8 +104,8 @@ bool ScrollView::initWithViewSize(Size size, Node *container/* = NULL*/) if (!this->_container) { _container = Layer::create(); - this->_container->ignoreAnchorPointForPosition(false); - this->_container->setAnchorPoint(Point(0.0f, 0.0f)); + _container->ignoreAnchorPointForPosition(false); + _container->setAnchorPoint(Point(0.0f, 0.0f)); } this->setViewSize(size); @@ -485,10 +485,17 @@ void ScrollView::addChild(Node * child, int zOrder, int tag) } } +void ScrollView::beforeDraw() +{ + _beforeDrawCommand.init(0, _vertexZ); + _beforeDrawCommand.func = CC_CALLBACK_0(ScrollView::onBeforeDraw, this); + Director::getInstance()->getRenderer()->addCommand(&_beforeDrawCommand); +} + /** * clip this view so that outside of the visible bounds can be hidden. */ -void ScrollView::beforeDraw() +void ScrollView::onBeforeDraw() { if (_clippingToBounds) { @@ -513,11 +520,18 @@ void ScrollView::beforeDraw() } } +void ScrollView::afterDraw() +{ + _afterDrawCommand.init(0, _vertexZ); + _afterDrawCommand.func = CC_CALLBACK_0(ScrollView::onAfterDraw, this); + Director::getInstance()->getRenderer()->addCommand(&_afterDrawCommand); +} + /** * retract what's done in beforeDraw so that there's no side effect to * other nodes. */ -void ScrollView::afterDraw() +void ScrollView::onAfterDraw() { if (_clippingToBounds) { @@ -594,7 +608,7 @@ bool ScrollView::onTouchBegan(Touch* touch, Event* event) //dispatcher does not know about clipping. reject touches outside visible bounds. if (_touches.size() > 2 || _touchMoved || - !frame.containsPoint(_container->convertToWorldSpace(_container->convertTouchToNodeSpace(touch)))) + !frame.containsPoint(touch->getLocation())) { return false; } diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index bef479e49b..c77d74bc13 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -254,11 +254,13 @@ protected: * clip this view so that outside of the visible bounds can be hidden. */ void beforeDraw(); + void onBeforeDraw(); /** * retract what's done in beforeDraw so that there's no side effect to * other nodes. */ void afterDraw(); + void onAfterDraw(); /** * Zoom handling */ @@ -351,6 +353,9 @@ protected: /** Touch listener */ EventListenerTouchOneByOne* _touchListener; + + CustomCommand _beforeDrawCommand; + CustomCommand _afterDrawCommand; }; // end of GUI group diff --git a/extensions/GUI/CCScrollView/CCTableView.cpp b/extensions/GUI/CCScrollView/CCTableView.cpp index 2d20838719..ff143f77d5 100644 --- a/extensions/GUI/CCScrollView/CCTableView.cpp +++ b/extensions/GUI/CCScrollView/CCTableView.cpp @@ -29,6 +29,10 @@ NS_CC_EXT_BEGIN +TableView* TableView::create() +{ + return TableView::create(nullptr, Size::ZERO); +} TableView* TableView::create(TableViewDataSource* dataSource, Size size) { @@ -51,6 +55,7 @@ bool TableView::initWithViewSize(Size size, Node* container/* = NULL*/) { if (ScrollView::initWithViewSize(size,container)) { + CC_SAFE_DELETE(_indices); _indices = new std::set(); _vordering = VerticalFillOrder::BOTTOM_UP; this->setDirection(Direction::VERTICAL); diff --git a/extensions/GUI/CCScrollView/CCTableView.h b/extensions/GUI/CCScrollView/CCTableView.h index 649fc19175..674e10df19 100644 --- a/extensions/GUI/CCScrollView/CCTableView.h +++ b/extensions/GUI/CCScrollView/CCTableView.h @@ -148,6 +148,10 @@ public: TOP_DOWN, BOTTOM_UP }; + + /** Empty contructor of TableView */ + static TableView* create(); + /** * An intialized table view object * diff --git a/extensions/GUI/CCScrollView/CCTableViewCell.cpp b/extensions/GUI/CCScrollView/CCTableViewCell.cpp index 9a015f4632..7df9c478fd 100644 --- a/extensions/GUI/CCScrollView/CCTableViewCell.cpp +++ b/extensions/GUI/CCScrollView/CCTableViewCell.cpp @@ -33,24 +33,14 @@ void TableViewCell::reset() _idx = CC_INVALID_INDEX; } -void TableViewCell::setObjectID(long uIdx) -{ - _idx = uIdx; -} - -long TableViewCell::getObjectID() +ssize_t TableViewCell::getIdx() { return _idx; } -long TableViewCell::getIdx() +void TableViewCell::setIdx(ssize_t idx) { - return _idx; -} - -void TableViewCell::setIdx(long uIdx) -{ - _idx = uIdx; + _idx = idx; } NS_CC_EXT_END diff --git a/extensions/GUI/CCScrollView/CCTableViewCell.h b/extensions/GUI/CCScrollView/CCTableViewCell.h index 96ab28d67d..33438a0f96 100644 --- a/extensions/GUI/CCScrollView/CCTableViewCell.h +++ b/extensions/GUI/CCScrollView/CCTableViewCell.h @@ -37,21 +37,21 @@ NS_CC_EXT_BEGIN class TableViewCell: public Node { public: + CREATE_FUNC(TableViewCell); + TableViewCell() {} /** * The index used internally by SWTableView and its subclasses */ - long getIdx(); - void setIdx(long uIdx); + ssize_t getIdx(); + void setIdx(ssize_t uIdx); /** * Cleans up any resources linked to this cell and resets idx property. */ void reset(); - void setObjectID(long uIdx); - long getObjectID(); private: - long _idx; + ssize_t _idx; }; NS_CC_EXT_END diff --git a/extensions/assets-manager/AssetsManager.cpp b/extensions/assets-manager/AssetsManager.cpp index 52080d811c..23818d9e6d 100644 --- a/extensions/assets-manager/AssetsManager.cpp +++ b/extensions/assets-manager/AssetsManager.cpp @@ -319,7 +319,7 @@ bool AssetsManager::uncompress() return false; } - string fullPath = _storagePath + fileName; + const string fullPath = _storagePath + fileName; // Check if this entry is a directory or a file. const size_t filenameLength = strlen(fileName); @@ -339,15 +339,15 @@ bool AssetsManager::uncompress() //There are not directory entry in some case. //So we need to test whether the file directory exists when uncompressing file entry //, if does not exist then create directory - string fileNameStr(fileName); + const string fileNameStr(fileName); size_t startIndex=0; size_t index=fileNameStr.find("/",startIndex); - while(index!=-1) + while(index != std::string::npos) { - string dir=_storagePath+fileNameStr.substr(0,index); + const string dir=_storagePath+fileNameStr.substr(0,index); FILE *out = fopen(dir.c_str(), "r"); @@ -501,7 +501,7 @@ int assetsManagerProgressFunc(void *ptr, double totalToDownload, double nowDownl bool AssetsManager::downLoad() { // Create a file to save package. - string outFileName = _storagePath + TEMP_PACKAGE_FILE_NAME; + const string outFileName = _storagePath + TEMP_PACKAGE_FILE_NAME; FILE *fp = fopen(outFileName.c_str(), "wb"); if (! fp) { diff --git a/extensions/physics-nodes/CCPhysicsSprite.cpp b/extensions/physics-nodes/CCPhysicsSprite.cpp index fa3772fc70..93ce054384 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.cpp +++ b/extensions/physics-nodes/CCPhysicsSprite.cpp @@ -19,10 +19,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#if (CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION) #include "CCPhysicsSprite.h" -#if defined(CC_ENABLE_CHIPMUNK_INTEGRATION) && defined(CC_ENABLE_BOX2D_INTEGRATION) +#if (CC_ENABLE_CHIPMUNK_INTEGRATION && CC_ENABLE_BOX2D_INTEGRATION) #error "Either Chipmunk or Box2d should be enabled, but not both at the same time" #endif @@ -406,3 +407,4 @@ const kmMat4& PhysicsSprite::getNodeToParentTransform() const } NS_CC_EXT_END +#endif //(CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION) diff --git a/extensions/physics-nodes/CCPhysicsSprite.h b/extensions/physics-nodes/CCPhysicsSprite.h index 50eb8a4158..fcedfca031 100644 --- a/extensions/physics-nodes/CCPhysicsSprite.h +++ b/extensions/physics-nodes/CCPhysicsSprite.h @@ -19,6 +19,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#if (CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION) + #ifndef __PHYSICSNODES_CCPHYSICSSPRITE_H__ #define __PHYSICSNODES_CCPHYSICSSPRITE_H__ @@ -132,3 +134,4 @@ protected: NS_CC_EXT_END #endif // __PHYSICSNODES_CCPHYSICSSPRITE_H__ +#endif //(CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION) diff --git a/extensions/proj.win32/Win32InputBox.cpp b/extensions/proj.win32/Win32InputBox.cpp index 8a0de6ffcb..220a932072 100644 --- a/extensions/proj.win32/Win32InputBox.cpp +++ b/extensions/proj.win32/Win32InputBox.cpp @@ -133,7 +133,11 @@ INT_PTR CWin32InputBox::InputBoxEx(WIN32INPUTBOX_PARAM *param) if (param->DlgTemplateName != 0) { HMODULE hModule = (HMODULE)param->hInstance; +#ifdef __MINGW32__ + HRSRC rcDlg = ::FindResource(hModule, (LPWSTR)(ULONG_PTR)(size_t)(param->DlgTemplateName), RT_DIALOG); +#else HRSRC rcDlg = ::FindResource(hModule, MAKEINTRESOURCE(param->DlgTemplateName), RT_DIALOG); +#endif if (rcDlg == NULL) return 0; diff --git a/extensions/proj.win32/libExtensions.vcxproj b/extensions/proj.win32/libExtensions.vcxproj index 1e00952529..809221d8da 100644 --- a/extensions/proj.win32/libExtensions.vcxproj +++ b/extensions/proj.win32/libExtensions.vcxproj @@ -72,7 +72,7 @@ Level3 - EditAndContinue + OldStyle 4267;4251;4244;%(DisableSpecificWarnings) true diff --git a/external/Box2D/CMakeLists.txt b/external/Box2D/CMakeLists.txt index 36a068b720..eff3db22eb 100644 --- a/external/Box2D/CMakeLists.txt +++ b/external/Box2D/CMakeLists.txt @@ -57,6 +57,6 @@ add_library(box2d STATIC set_target_properties(box2d PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/external/chipmunk/src/CMakeLists.txt b/external/chipmunk/src/CMakeLists.txt index a0d15b7b8a..45c855e838 100644 --- a/external/chipmunk/src/CMakeLists.txt +++ b/external/chipmunk/src/CMakeLists.txt @@ -44,7 +44,7 @@ endif(BUILD_SHARED OR INSTALL_STATIC) set_target_properties(chipmunk_static PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/external/lua/lua/CMakeLists.txt b/external/lua/lua/CMakeLists.txt index c63d80a7b2..81febeffb3 100644 --- a/external/lua/lua/CMakeLists.txt +++ b/external/lua/lua/CMakeLists.txt @@ -37,6 +37,6 @@ add_library(lua STATIC set_target_properties(lua PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/external/lua/tolua/CMakeLists.txt b/external/lua/tolua/CMakeLists.txt index b12e144e75..ccede5366b 100644 --- a/external/lua/tolua/CMakeLists.txt +++ b/external/lua/tolua/CMakeLists.txt @@ -17,6 +17,6 @@ add_library(tolua STATIC set_target_properties(tolua PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/external/tinyxml2/CMakeLists.txt b/external/tinyxml2/CMakeLists.txt index 6877779b2c..f2fd323735 100644 --- a/external/tinyxml2/CMakeLists.txt +++ b/external/tinyxml2/CMakeLists.txt @@ -8,7 +8,7 @@ add_library(tinyxml2 STATIC set_target_properties(tinyxml2 PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/external/unzip/CMakeLists.txt b/external/unzip/CMakeLists.txt index ae98584279..69bdd33b9b 100644 --- a/external/unzip/CMakeLists.txt +++ b/external/unzip/CMakeLists.txt @@ -9,7 +9,7 @@ add_library(unzip STATIC set_target_properties(unzip PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) diff --git a/licenses/LICENSE_FontLabel.txt b/licenses/LICENSE_FontLabel.txt deleted file mode 100644 index a45b29a380..0000000000 --- a/licenses/LICENSE_FontLabel.txt +++ /dev/null @@ -1,79 +0,0 @@ -FontLabel ---------- - -Copyright © 2009 Zynga Game Networks. - - -License -------- - -Apache License, Version 2.0 - -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: - - 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and - 2. You must cause any modified files to carry prominent notices stating that You changed the files; and - 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and - 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. - -You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS diff --git a/licenses/LICENSE_bada_pthread.txt b/licenses/LICENSE_bada_pthread.txt deleted file mode 100644 index 0cab2d908f..0000000000 --- a/licenses/LICENSE_bada_pthread.txt +++ /dev/null @@ -1,22 +0,0 @@ -/* - Bada pthread - Copyright (c) 2010 Markovtsev Vadim - - 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. -*/ diff --git a/licenses/LICENSE_iconv.txt b/licenses/LICENSE_iconv.txt deleted file mode 100644 index e4442fb14b..0000000000 --- a/licenses/LICENSE_iconv.txt +++ /dev/null @@ -1,16 +0,0 @@ -Copyright (C) 1999-2003 Free Software Foundation, Inc. - -The GNU LIBICONV Library is free software; you can redistribute it -and/or modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -The GNU LIBICONV Library is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with the GNU LIBICONV Library; see the file COPYING.LIB. -If not, write to the Free Software Foundation, Inc., 59 Temple Place - -Suite 330, Boston, MA 02111-1307, USA. \ No newline at end of file diff --git a/licenses/LICENSE_sigslot.txt b/licenses/LICENSE_sigslot.txt deleted file mode 100644 index 40501fa1a2..0000000000 --- a/licenses/LICENSE_sigslot.txt +++ /dev/null @@ -1,9 +0,0 @@ -License - -The sigslot library has been placed in the public domain. This means that you are free to use it however you like. - -The author takes no responsibility or liability of any kind for any use that you may make of this library. - -If you screw up, it's your fault. - -If the library screws up, you got it for free, so you should have tested it better - it's still your responsibility. \ No newline at end of file diff --git a/samples/Cpp/AssetsManagerTest/proj.android/AndroidManifest.xml b/samples/Cpp/AssetsManagerTest/proj.android/AndroidManifest.xml index 764617b6cd..b6b69e4442 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/AndroidManifest.xml +++ b/samples/Cpp/AssetsManagerTest/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Cpp/HelloCpp/CMakeLists.txt b/samples/Cpp/HelloCpp/CMakeLists.txt index f5af51def4..861118b09b 100644 --- a/samples/Cpp/HelloCpp/CMakeLists.txt +++ b/samples/Cpp/HelloCpp/CMakeLists.txt @@ -61,7 +61,7 @@ if(WIN32 AND MSVC) set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") else() - set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}") + set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}") set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") diff --git a/samples/Cpp/HelloCpp/proj.android/AndroidManifest.xml b/samples/Cpp/HelloCpp/proj.android/AndroidManifest.xml index dc1995c822..ae64f07a84 100644 --- a/samples/Cpp/HelloCpp/proj.android/AndroidManifest.xml +++ b/samples/Cpp/HelloCpp/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Cpp/HelloCpp/proj.linux/.cproject b/samples/Cpp/HelloCpp/proj.linux/.cproject deleted file mode 100644 index fc14f996d1..0000000000 --- a/samples/Cpp/HelloCpp/proj.linux/.cproject +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/Cpp/HelloCpp/proj.linux/.project b/samples/Cpp/HelloCpp/proj.linux/.project deleted file mode 100644 index e53a1e70a7..0000000000 --- a/samples/Cpp/HelloCpp/proj.linux/.project +++ /dev/null @@ -1,93 +0,0 @@ - - - HelloCpp - - - libcocos2d - libCocosDenshion - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/HelloCocos2dx/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - Classes - 2 - PARENT-1-PROJECT_LOC/Classes - - - - diff --git a/samples/Cpp/HelloCpp/proj.linux/Makefile b/samples/Cpp/HelloCpp/proj.linux/Makefile deleted file mode 100644 index 0548290a52..0000000000 --- a/samples/Cpp/HelloCpp/proj.linux/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -EXECUTABLE = HelloCpp - -INCLUDES = -I.. -I../Classes - -SOURCES = main.cpp \ - ../Classes/AppDelegate.cpp \ - ../Classes/HelloWorldScene.cpp - -COCOS_ROOT = ../../../.. -include $(COCOS_ROOT)/cocos/2d/cocos2dx.mk - -SHAREDLIBS += -lcocos2d -COCOS_LIBS = $(LIB_DIR)/libcocos2d.so - -$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/samples/Cpp/SimpleGame/proj.android/AndroidManifest.xml b/samples/Cpp/SimpleGame/proj.android/AndroidManifest.xml index 0937a1e991..52ef0f9c8c 100644 --- a/samples/Cpp/SimpleGame/proj.android/AndroidManifest.xml +++ b/samples/Cpp/SimpleGame/proj.android/AndroidManifest.xml @@ -11,7 +11,7 @@ android:icon="@drawable/icon"> - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Cpp/SimpleGame/proj.linux/Makefile b/samples/Cpp/SimpleGame/proj.linux/Makefile deleted file mode 100644 index 9204555b28..0000000000 --- a/samples/Cpp/SimpleGame/proj.linux/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -EXECUTABLE = SimpleGame - -INCLUDES = -I.. -I../Classes - -SOURCES = main.cpp \ - ../Classes/AppDelegate.cpp \ - ../Classes/HelloWorldScene.cpp \ - ../Classes/GameOverScene.cpp - -COCOS_ROOT = ../../../.. -include $(COCOS_ROOT)/cocos/2d/cocos2dx.mk - -SHAREDLIBS += -lcocos2d -lcocosdenshion -INCLUDES += -I$(COCOS_ROOT)/cocos/audio/include - -$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index 095984ffca..32917fb7c3 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -139,6 +139,7 @@ Classes/TouchesTest/Ball.cpp \ Classes/TouchesTest/Paddle.cpp \ Classes/TouchesTest/TouchesTest.cpp \ Classes/TransitionsTest/TransitionsTest.cpp \ +Classes/UnitTest/UnitTest.cpp \ Classes/UserDefaultTest/UserDefaultTest.cpp \ Classes/ZwoptexTest/ZwoptexTest.cpp diff --git a/samples/Cpp/TestCpp/CMakeLists.txt b/samples/Cpp/TestCpp/CMakeLists.txt index 91db89f44b..5f409f7601 100644 --- a/samples/Cpp/TestCpp/CMakeLists.txt +++ b/samples/Cpp/TestCpp/CMakeLists.txt @@ -1,5 +1,18 @@ set(APP_NAME testcpp) +if(WIN32) + set(PLATFORM_SRC + Classes/ExtensionsTest/EditBoxTest/EditBoxTest.cpp + Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp + Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp + proj.win32/main.cpp + ) +else() + set(PLATFORM_SRC + proj.linux/main.cpp + ) +endif() + set(SAMPLE_SRC Classes/AccelerometerTest/AccelerometerTest.cpp Classes/ActionManagerTest/ActionManagerTest.cpp @@ -127,12 +140,13 @@ set(SAMPLE_SRC Classes/DataVisitorTest/DataVisitorTest.cpp Classes/ConfigurationTest/ConfigurationTest.cpp Classes/ConsoleTest/ConsoleTest.cpp + Classes/UnitTest/UnitTest.cpp Classes/controller.cpp Classes/testBasic.cpp Classes/AppDelegate.cpp Classes/BaseTest.cpp Classes/VisibleRect.cpp - proj.linux/main.cpp + ${PLATFORM_SRC} ) include_directories( @@ -156,7 +170,7 @@ target_link_libraries(${APP_NAME} box2d ) -set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}") +set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}") set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") @@ -165,4 +179,3 @@ pre_build(${APP_NAME} COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources ) - diff --git a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp index 3cf942b540..c05bb831cd 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include "ActionsEaseTest.h" #include "../testResource.h" diff --git a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.h b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.h index 7751439668..443c532f32 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.h +++ b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.h @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #ifndef _ACTIONS__EASE_TEST_H_ #define _ACTIONS__EASE_TEST_H_ diff --git a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp index e6c552db69..42f3774e3b 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include "ActionsProgressTest.h" #include "../testResource.h" diff --git a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.h b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.h index 1d63fea276..9e16818164 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.h +++ b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.h @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #ifndef _ACTIONS__PROGRESS_TEST_H_ #define _ACTIONS_PROGRESS_TEST_H_ diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp index 229d6f11e6..fa40b74f0a 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include "ActionsTest.h" #include "../testResource.h" #include "cocos2d.h" diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h index b5be2b348b..949ad43a38 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #ifndef _ActionsTest_H_ #define _ActionsTest_H_ diff --git a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp index 3968a54656..285d9b17ae 100644 --- a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp @@ -45,11 +45,30 @@ bool AppDelegate::applicationDidFinishLaunching() auto resourceSize = Size(960, 640); searchPaths.push_back("hd"); searchPaths.push_back("hd/scenetest"); + searchPaths.push_back("hd/scenetest/ArmatureComponentTest"); + searchPaths.push_back("hd/scenetest/AttributeComponentTest"); + searchPaths.push_back("hd/scenetest/BackgroundComponentTest"); + searchPaths.push_back("hd/scenetest/EffectComponentTest"); + searchPaths.push_back("hd/scenetest/LoadSceneEdtiorFileTest"); + searchPaths.push_back("hd/scenetest/ParticleComponentTest"); + searchPaths.push_back("hd/scenetest/SpriteComponentTest"); + searchPaths.push_back("hd/scenetest/TmxMapComponentTest"); + searchPaths.push_back("hd/scenetest/UIComponentTest"); + searchPaths.push_back("hd/scenetest/TriggerTest"); director->setContentScaleFactor(resourceSize.height/designSize.height); } else { - searchPaths.push_back("scenetest"); + searchPaths.push_back("scenetest/ArmatureComponentTest"); + searchPaths.push_back("scenetest/AttributeComponentTest"); + searchPaths.push_back("scenetest/BackgroundComponentTest"); + searchPaths.push_back("scenetest/EffectComponentTest"); + searchPaths.push_back("scenetest/LoadSceneEdtiorFileTest"); + searchPaths.push_back("scenetest/ParticleComponentTest"); + searchPaths.push_back("scenetest/SpriteComponentTest"); + searchPaths.push_back("scenetest/TmxMapComponentTest"); + searchPaths.push_back("scenetest/UIComponentTest"); + searchPaths.push_back("scenetest/TriggerTest"); } pFileUtils->setSearchPaths(searchPaths); @@ -63,6 +82,10 @@ bool AppDelegate::applicationDidFinishLaunching() scene->addChild(layer); director->runWithScene(scene); + // Enable Remote Console + auto console = director->getConsole(); + console->listenOnTCP(5678); + return true; } diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/TestEntries.cpp b/samples/Cpp/TestCpp/Classes/Box2DTestBed/TestEntries.cpp index 5fb831212a..2d6f22f65c 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/TestEntries.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/TestEntries.cpp @@ -120,7 +120,6 @@ TestEntry g_testEntries[] = {"Slider Crank", SliderCrank::Create}, {"Varying Friction", VaryingFriction::Create}, {"Add Pair Stress Test", AddPair::Create}, - {NULL, NULL} }; int g_totalEntries = sizeof(g_testEntries) / sizeof(g_testEntries[0]); diff --git a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 6d4dd13628..68a584d577 100644 --- a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -565,7 +565,7 @@ static const Color4F _planeColor[] = { RawStencilBufferTest::~RawStencilBufferTest() { - CC_SAFE_RELEASE(_sprite); + } std::string RawStencilBufferTest::title() const @@ -584,10 +584,15 @@ void RawStencilBufferTest::setup() if (_stencilBits < 3) { CCLOGWARN("Stencil must be enabled for the current GLView."); } - _sprite = Sprite::create(s_pathGrossini); - _sprite->retain(); - _sprite->setAnchorPoint( Point(0.5, 0) ); - _sprite->setScale( 2.5f ); + + for(int i = 0; i < _planeCount; ++i) + { + Sprite* sprite = Sprite::create(s_pathGrossini); + sprite->setAnchorPoint( Point(0.5, 0) ); + sprite->setScale( 2.5f ); + _sprites.pushBack(sprite); + } + Director::getInstance()->setAlphaBlending(true); } @@ -621,7 +626,7 @@ void RawStencilBufferTest::draw() auto spritePoint = planeSize * i; spritePoint.x += planeSize.x / 2; spritePoint.y = 0; - _sprite->setPosition( spritePoint ); + _sprites.at(i)->setPosition( spritePoint ); iter->init(0, _vertexZ); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i, stencilPoint); @@ -630,7 +635,7 @@ void RawStencilBufferTest::draw() kmGLPushMatrix(); this->transform(); - _sprite->visit(); + _sprites.at(i)->visit(); kmGLPopMatrix(); iter->init(0, _vertexZ); @@ -640,7 +645,7 @@ void RawStencilBufferTest::draw() kmGLPushMatrix(); this->transform(); - _sprite->visit(); + _sprites.at(i)->visit(); kmGLPopMatrix(); } @@ -754,7 +759,11 @@ void RawStencilBufferTest4::setupStencilForClippingOnPlane(GLint plane) auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); - _sprite->setShaderProgram(program ); + for(int i = 0; i < _planeCount; ++i) + { + _sprites.at(i)->setShaderProgram(program ); + } + #endif } @@ -787,7 +796,10 @@ void RawStencilBufferTest5::setupStencilForClippingOnPlane(GLint plane) auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); - _sprite->setShaderProgram( program ); + for(int i = 0; i < _planeCount; ++i) + { + _sprites.at(i)->setShaderProgram(program ); + } #endif } @@ -853,7 +865,10 @@ void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane) auto program = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); - _sprite->setShaderProgram(program); + for(int i = 0; i < _planeCount; ++i) + { + _sprites.at(i)->setShaderProgram(program ); + } #endif glFlush(); } diff --git a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.h b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.h index 41b3f7613b..944c99ca2a 100644 --- a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.h +++ b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.h @@ -165,7 +165,7 @@ protected: void onBeforeDrawClip(int planeIndex, const Point& pt); void onBeforeDrawSprite(int planeIndex, const Point& pt); protected: - Sprite* _sprite; + Vector _sprites; }; class RawStencilBufferTest2 : public RawStencilBufferTest diff --git a/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp b/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp index 63959537d8..6ebcc144cc 100644 --- a/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp @@ -4,17 +4,17 @@ #include "extensions/GUI/CCControlExtension/CCControlSlider.h" // android effect only support ogg -#if (CC_TARGET_PLATFORM == CC_PLATFOR_ANDROID) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #define EFFECT_FILE "effect2.ogg" -#elif( CC_TARGET_PLATFORM == CC_PLATFOR_MARMALADE) +#elif( CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) #define EFFECT_FILE "effect1.raw" #else #define EFFECT_FILE "effect1.wav" #endif // CC_PLATFOR_ANDROID -#if (CC_TARGET_PLATFORM == CC_PLATFOR_WIN32) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #define MUSIC_FILE "music.mid" -#elif (CC_TARGET_PLATFORM == CC_PLATFOR_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFOR_LINUX ) +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX ) #define MUSIC_FILE "background.ogg" #else #define MUSIC_FILE "background.mp3" diff --git a/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.cpp b/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.cpp index d5827c25cb..c4269ea2e9 100644 --- a/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ConsoleTest/ConsoleTest.cpp @@ -133,13 +133,11 @@ void ConsoleTestScene::runThisTest() ConsoleTCP::ConsoleTCP() { - _console = Console::create(); - _console->retain(); + _console = Director::getInstance()->getConsole(); } ConsoleTCP::~ConsoleTCP() { - _console->release(); } void ConsoleTCP::onEnter() @@ -167,8 +165,7 @@ std::string ConsoleTCP::subtitle() const ConsoleCustomCommand::ConsoleCustomCommand() { - _console = Console::create(); - _console->retain(); + _console = Director::getInstance()->getConsole(); static struct Console::Command commands[] = { {"hello", [](int fd, const char* command) { @@ -183,7 +180,6 @@ ConsoleCustomCommand::ConsoleCustomCommand() ConsoleCustomCommand::~ConsoleCustomCommand() { - _console->release(); } void ConsoleCustomCommand::onEnter() diff --git a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 9a751b8d97..61aa2aa0b2 100644 --- a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -302,6 +302,14 @@ DrawNodeTest::DrawNodeTest() draw->drawSegment(Point(20,s.height), Point(20,s.height/2), 10, Color4F(0, 1, 0, 1)); draw->drawSegment(Point(10,s.height/2), Point(s.width/2, s.height/2), 40, Color4F(1, 0, 1, 0.5)); + + // Draw triangle + draw->drawTriangle(Point(10, 10), Point(70, 30), Point(100, 140), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + + // Draw some beziers + draw->drawQuadraticBezier(Point(s.width - 150, s.height - 150), Point(s.width - 70, s.height - 10), Point(s.width - 10, s.height - 10), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + + draw->drawCubicBezier(Point(s.width - 250, 40), Point(s.width - 70, 100), Point(s.width - 30, 250), Point(s.width - 10, s.height - 50), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); } string DrawNodeTest::title() const diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 0baa0e306d..1349970d67 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -635,7 +635,7 @@ void TestParticleDisplay::onEnter() Bone *bone = Bone::create("p1"); bone->addDisplay(p1, 0); - bone->changeDisplayByIndex(0, true); + bone->changeDisplayWithIndex(0, true); bone->setIgnoreMovementBoneData(true); bone->setZOrder(100); bone->setScale(1.2f); @@ -643,7 +643,7 @@ void TestParticleDisplay::onEnter() bone = Bone::create("p2"); bone->addDisplay(p2, 0); - bone->changeDisplayByIndex(0, true); + bone->changeDisplayWithIndex(0, true); bone->setIgnoreMovementBoneData(true); bone->setZOrder(100); bone->setScale(1.2f); @@ -727,7 +727,7 @@ void TestUseMutiplePicture::onTouchesEnded(const std::vector& touches, { ++displayIndex; displayIndex = (displayIndex) % 8; - armature->getBone("weapon")->changeDisplayByIndex(displayIndex, true); + armature->getBone("weapon")->changeDisplayWithIndex(displayIndex, true); } TestColliderDetector::~TestColliderDetector() @@ -1023,7 +1023,7 @@ void TestColliderDetector::update(float delta) // This code is just telling how to get the vertex. // For a more accurate collider detection, you need to implemente yourself. const Map& map = armature2->getBoneDic(); - for(auto element : map) + for(const auto& element : map) { Bone *bone = element.second; ColliderDetector *detector = bone->getColliderDetector(); @@ -1033,12 +1033,12 @@ void TestColliderDetector::update(float delta) const cocos2d::Vector& bodyList = detector->getColliderBodyList(); - for (auto object : bodyList) + for (const auto& object : bodyList) { ColliderBody *body = static_cast(object); const std::vector &vertexList = body->getCalculatedVertexList(); - float minx, miny, maxx, maxy = 0; + float minx = 0, miny = 0, maxx = 0, maxy = 0; int length = vertexList.size(); for (int i = 0; iaddDisplay(this, 0); //Change this bone's display - bone->changeDisplayByIndex(0, true); + bone->changeDisplayWithIndex(0, true); bone->setIgnoreMovementBoneData(true); setPosition(Point(0,0)); @@ -1264,7 +1264,7 @@ void TestArmatureNesting2::onEnter() touchedMenu = false; LabelTTF* label = CCLabelTTF::create("Change Mount", "Arial", 20); - MenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, CC_CALLBACK_1(TestArmatureNesting2::ChangeMountCallback, this)); + MenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, CC_CALLBACK_1(TestArmatureNesting2::changeMountCallback, this)); Menu* pMenu =Menu::create(pMenuItem, nullptr); @@ -1321,7 +1321,7 @@ void TestArmatureNesting2::onTouchesEnded(const std::vector& touches, Ev armature->runAction(Sequence::create(move, nullptr)); } -void TestArmatureNesting2::ChangeMountCallback(Object* pSender) +void TestArmatureNesting2::changeMountCallback(Object* pSender) { hero->stopAllActions(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index 97e31ef697..c3b64debb9 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -336,15 +336,16 @@ public: class TestArmatureNesting2 : public ArmatureTestLayer { public: - virtual void onEnter(); - virtual void onExit(); + virtual void onEnter() override; + virtual void onExit() override; virtual std::string title() const override; virtual std::string subtitle() const override; void onTouchesEnded(const std::vector& touches, Event* event); - virtual void ChangeMountCallback(Object* pSender); + void changeMountCallback(Object* pSender); virtual cocostudio::Armature *createMount(const char *name, Point position); +private: Hero *hero; cocostudio::Armature *horse; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp index b88e8f77b3..1511b8193f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp @@ -29,7 +29,7 @@ void SceneController::onEnter() _fAddTargetTime = 1.0f; static_cast(_owner->getComponent("Audio"))->playBackgroundMusic("background-music-aac.wav", true); - static_cast(_owner->getComponent("ComAttribute"))->setInt("KillCount", 0); + static_cast(_owner->getComponent("CCComAttribute"))->setInt("KillCount", 0); } void SceneController::onExit() @@ -91,9 +91,9 @@ void SceneController::spriteMoveFinished(Node* sender) void SceneController::increaseKillCount() { - int nProjectilesDestroyed = ((ComAttribute*)(_owner->getComponent("ComAttribute")))->getInt("KillCount"); + int nProjectilesDestroyed = ((ComAttribute*)(_owner->getComponent("CCComAttribute")))->getInt("KillCount"); - ComAttribute *p = (ComAttribute*)(_owner->getComponent("ComAttribute")); + ComAttribute *p = (ComAttribute*)(_owner->getComponent("CCComAttribute")); p->setInt("KillCount", ++nProjectilesDestroyed); if (nProjectilesDestroyed >= 5) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 7e3d0302d4..55cafbf86c 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -21,7 +21,7 @@ bool UIButtonTest::init() Size widgetSize = _widget->getSize(); // Add a label in which the button events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("No Event"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -30,7 +30,7 @@ bool UIButtonTest::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Button"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -97,7 +97,7 @@ bool UIButtonTest_Scale9::init() Size widgetSize = _widget->getSize(); // Add a label in which the button events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("No Event"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -106,7 +106,7 @@ bool UIButtonTest_Scale9::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Button scale9 render"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -172,7 +172,7 @@ bool UIButtonTest_PressedAction::init() Size widgetSize = _widget->getSize(); // Add a label in which the button events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("No Event"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -181,7 +181,7 @@ bool UIButtonTest_PressedAction::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Button Pressed Action"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -247,7 +247,7 @@ bool UIButtonTest_Title::init() Size widgetSize = _widget->getSize(); // Add a label in which the text button events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("No Event"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -256,7 +256,7 @@ bool UIButtonTest_Title::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Button with title"); alert->setFontName("Marker Felt"); alert->setFontSize(30); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h index 834bdc9953..061e11f8b2 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h @@ -37,7 +37,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UIButtonTest) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; class UIButtonTest_Scale9 : public UIScene @@ -50,7 +50,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UIButtonTest_Scale9) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; class UIButtonTest_PressedAction : public UIScene @@ -63,7 +63,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UIButtonTest_PressedAction) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; class UIButtonTest_Title : public UIScene @@ -76,7 +76,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UIButtonTest_Title) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; #endif /* defined(__TestCpp__UIButtonTest__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index acfcaa31b3..1e049998a7 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -21,7 +21,7 @@ bool UICheckBoxTest::init() Size widgetSize = _widget->getSize();; // Add a label in which the checkbox events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("No Event"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -30,7 +30,7 @@ bool UICheckBoxTest::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("CheckBox"); alert->setFontName("Marker Felt"); alert->setFontSize(30); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h index 2090b5bea9..90a7003da8 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h @@ -37,7 +37,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UICheckBoxTest) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; #endif /* defined(__TestCpp__UICheckBoxTest__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIGridViewTest/UIGridViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIGridViewTest/UIGridViewTest.cpp deleted file mode 100644 index d43ea27233..0000000000 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIGridViewTest/UIGridViewTest.cpp +++ /dev/null @@ -1,215 +0,0 @@ - - -#include "UIGridViewTest.h" - - -// UIGridViewTest_Mode_Column - -UIGridViewTest_Mode_Column::UIGridViewTest_Mode_Column() -{ -} - -UIGridViewTest_Mode_Column::~UIGridViewTest_Mode_Column() -{ -} - -bool UIGridViewTest_Mode_Column::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add a label in which the scrollview alert will be displayed - _displayValueLabel = gui::Label::create(); - _displayValueLabel->setText("Move by vertical direction"); - _displayValueLabel->setFontName("Marker Felt"); - _displayValueLabel->setFontSize(32); - _displayValueLabel->setAnchorPoint(Point(0.5f, -1)); - _displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); - _uiLayer->addChild(_displayValueLabel); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Layout is in use with GridView bases on column mode"); - alert->setFontName("Marker Felt"); - alert->setFontSize(20); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5)); - _uiLayer->addChild(alert); - - Layout* root = static_cast(_uiLayer->getChildByTag(81)); - - Layout* background = dynamic_cast(root->getChildByName("background_Panel")); - - // Create the grid view with grid layout mode column - GridView* gridView = GridView::create(); - gridView->setLayoutType(LAYOUT_GRID_MODE_COLUMN); - gridView->setScrollEnabled(true); - gridView->setDirection(SCROLLVIEW_DIR_VERTICAL); - gridView->setBounceEnabled(true); - gridView->setTouchEnabled(true); - gridView->setSize(Size(280, 150)); - Size backgroundSize = background->getSize(); - gridView->setPosition(Point((widgetSize.width - backgroundSize.width) / 2.0f + - (backgroundSize.width - gridView->getSize().width) / 2.0f, - (widgetSize.height - backgroundSize.height) / 2.0f + - (backgroundSize.height - gridView->getSize().height) / 2.0f)); - gridView->addEventListenerScrollView(this, scrollvieweventselector(UIGridViewTest_Mode_Column::selectedChildEvent)); - _uiLayer->addChild(gridView); - - - // create items - int count = 19; - for (int i = 0; i < count; ++i) - { - Button* button = Button::create(); - button->setTouchEnabled(true); - button->loadTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", ""); - button->setScale9Enabled(true); - AffineTransform transform = AffineTransformMakeIdentity(); - transform = AffineTransformScale(transform, 3.0f, 1.3f); - button->setSize(SizeApplyAffineTransform(button->getContentSize(), transform)); - button->setTitleText(String::createWithFormat("grid_%d", i)->getCString()); - - Layout* item = Layout::create(); - item->setTouchEnabled(true); - item->setSize(button->getSize()); - button->setPosition(Point(item->getSize().width / 2.0f, item->getSize().height / 2.0f)); - item->addChild(button); - - gridView->addChild(item); - } - - // set grid view row and column - Widget* item = static_cast(gridView->getChildren().at(0)); - int rowCount = gridView->getSize().height / item->getSize().height; - int columnCount = gridView->getSize().width / item->getSize().width; - gridView->setGridLayoutRowAndColumnCount(rowCount, columnCount); - - return true; - } - - return false; -} - -void UIGridViewTest_Mode_Column::selectedChildEvent(Object *pSender, ScrollviewEventType type) -{ - switch (type) - { - case SCROLLVIEW_EVENT_SELECT_CHILD: - { - GridView* gridView = static_cast(pSender); - CCLOG("select child index = %d", gridView->getSelectedChildIndex()); - } - break; - - default: - break; - } -} - - -// UIGridViewTest_Mode_Row - -UIGridViewTest_Mode_Row::UIGridViewTest_Mode_Row() -{ -} - -UIGridViewTest_Mode_Row::~UIGridViewTest_Mode_Row() -{ -} - -bool UIGridViewTest_Mode_Row::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add a label in which the scrollview alert will be displayed - _displayValueLabel = gui::Label::create(); - _displayValueLabel->setText("Move by horizontal direction"); - _displayValueLabel->setFontName("Marker Felt"); - _displayValueLabel->setFontSize(32); - _displayValueLabel->setAnchorPoint(Point(0.5f, -1)); - _displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5)); - _uiLayer->addChild(_displayValueLabel); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Layout is in use with GridView bases on row mode"); - alert->setFontName("Marker Felt"); - alert->setFontSize(20); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5)); - _uiLayer->addChild(alert); - - Layout* root = static_cast(_uiLayer->getChildByTag(81)); - - Layout* background = dynamic_cast(root->getChildByName("background_Panel")); - - // Create the scroll grid with grid layout mode row - GridView* gridView = GridView::create(); - gridView->setLayoutType(LAYOUT_GRID_MODE_ROW); - gridView->setScrollEnabled(true); - gridView->setDirection(SCROLLVIEW_DIR_HORIZONTAL); - gridView->setBounceEnabled(true); - gridView->setTouchEnabled(true); - gridView->setSize(Size(280, 150)); - Size backgroundSize = background->getSize(); - gridView->setPosition(Point((widgetSize.width - backgroundSize.width) / 2.0f + - (backgroundSize.width - gridView->getSize().width) / 2.0f, - (widgetSize.height - backgroundSize.height) / 2.0f + - (backgroundSize.height - gridView->getSize().height) / 2.0f)); - gridView->addEventListenerScrollView(this, scrollvieweventselector(UIGridViewTest_Mode_Row::selectedChildEvent)); - _uiLayer->addChild(gridView); - - - // create items - int count = 19; - for (int i = 0; i < count; ++i) - { - Button* button = Button::create(); - button->setTouchEnabled(true); - button->loadTextures("cocosgui/button.png", "cocosgui/buttonHighlighted.png", ""); - button->setScale9Enabled(true); - AffineTransform transform = AffineTransformMakeIdentity(); - transform = AffineTransformScale(transform, 3.0f, 1.3f); - button->setSize(SizeApplyAffineTransform(button->getContentSize(), transform)); - button->setTitleText(String::createWithFormat("grid_%d", i)->getCString()); - - Layout* item = Layout::create(); - item->setTouchEnabled(true); - item->setSize(button->getSize()); - button->setPosition(Point(item->getSize().width / 2.0f, item->getSize().height / 2.0f)); - item->addChild(button); - - gridView->addChild(item); - } - - // set grid view row and column - Widget* item = static_cast(gridView->getChildren().at(0)); - int rowCount = gridView->getSize().height / item->getSize().height; - int columnCount = gridView->getSize().width / item->getSize().width; - gridView->setGridLayoutRowAndColumnCount(rowCount, columnCount); - - return true; - } - - return false; -} - -void UIGridViewTest_Mode_Row::selectedChildEvent(Object *pSender, ScrollviewEventType type) -{ - switch (type) - { - case SCROLLVIEW_EVENT_SELECT_CHILD: - { - GridView* gridView = static_cast(pSender); - CCLOG("select child index = %d", gridView->getSelectedChildIndex()); - } - break; - - default: - break; - } -} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIGridViewTest/UIGridViewTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIGridViewTest/UIGridViewTest.h deleted file mode 100644 index 4b16afba30..0000000000 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIGridViewTest/UIGridViewTest.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__UIGridViewTest__ -#define __TestCpp__UIGridViewTest__ - -#include "../UIScene.h" - -class UIGridViewTest_Mode_Column : public UIScene -{ -public: - UIGridViewTest_Mode_Column(); - ~UIGridViewTest_Mode_Column(); - bool init(); - void selectedChildEvent(Object* pSender, ScrollviewEventType type); - -protected: - UI_SCENE_CREATE_FUNC(UIGridViewTest_Mode_Column) - gui::Label* _displayValueLabel; -}; - -class UIGridViewTest_Mode_Row : public UIScene -{ -public: - UIGridViewTest_Mode_Row(); - ~UIGridViewTest_Mode_Row(); - bool init(); - void selectedChildEvent(Object* pSender, ScrollviewEventType type); - -protected: - UI_SCENE_CREATE_FUNC(UIGridViewTest_Mode_Row) - gui::Label* _displayValueLabel; -}; - -#endif /* defined(__TestCpp__UIGridViewTest__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp index fcda435217..a06f00d592 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp @@ -11,7 +11,7 @@ bool UIImageViewTest::init() { Size widgetSize = _widget->getSize(); - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("ImageView"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -72,7 +72,7 @@ bool UIImageViewTest_Scale9::init() { Size widgetSize = _widget->getSize(); - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("ImageView scale9 render"); alert->setFontName("Marker Felt"); alert->setFontSize(26); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelAtlasTest/UILabelAtlasTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelAtlasTest/UILabelAtlasTest.cpp index 5fafb31e59..155cb5fcc5 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelAtlasTest/UILabelAtlasTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelAtlasTest/UILabelAtlasTest.cpp @@ -12,7 +12,7 @@ bool UILabelAtlasTest::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("LabelAtlas"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -21,7 +21,7 @@ bool UILabelAtlasTest::init() _uiLayer->addChild(alert); // Create the label atlas - gui::LabelAtlas* labelAtlas = gui::LabelAtlas::create(); + gui::TextAtlas* labelAtlas = gui::TextAtlas::create(); labelAtlas->setProperty("1234567890", "cocosgui/labelatlas.png", 17, 22, "0"); labelAtlas->setPosition(Point((widgetSize.width) / 2, widgetSize.height / 2.0f)); _uiLayer->addChild(labelAtlas); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelBMFontTest/UILabelBMFontTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelBMFontTest/UILabelBMFontTest.cpp index d47185a68a..8a51b45cc8 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelBMFontTest/UILabelBMFontTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelBMFontTest/UILabelBMFontTest.cpp @@ -11,7 +11,7 @@ bool UILabelBMFontTest::init() { Size widgetSize = _widget->getSize(); - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("LabelBMFont"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -20,7 +20,7 @@ bool UILabelBMFontTest::init() _uiLayer->addChild(alert); // Create the LabelBMFont - gui::LabelBMFont* labelBMFont = gui::LabelBMFont::create(); + gui::TextBMFont* labelBMFont = gui::TextBMFont::create(); labelBMFont->setFntFile("cocosgui/bitmapFontTest2.fnt"); labelBMFont->setText("BMFont"); labelBMFont->setPosition(Point(widgetSize.width / 2, widgetSize.height / 2.0f + labelBMFont->getSize().height / 8.0f)); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelTest/UILabelTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelTest/UILabelTest.cpp index 25efa90330..d41bcf0542 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelTest/UILabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILabelTest/UILabelTest.cpp @@ -11,7 +11,7 @@ bool UILabelTest::init() { Size widgetSize = _widget->getSize(); - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Label"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -20,7 +20,7 @@ bool UILabelTest::init() _uiLayer->addChild(alert); // Create the label - gui::Label* label = gui::Label::create(); + gui::Text* label = gui::Text::create(); label->setText("Label"); label->setFontName("AmericanTypewriter"); label->setFontSize(30); @@ -40,7 +40,7 @@ bool UILabelTest_LineWrap::init() { Size widgetSize = _widget->getSize(); - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Label line wrap"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -49,7 +49,7 @@ bool UILabelTest_LineWrap::init() _uiLayer->addChild(alert); // Create the line wrap - gui::Label* label = gui::Label::create(); + gui::Text* label = gui::Text::create(); label->setTextAreaSize(Size(280, 150)); label->setTextHorizontalAlignment(TextHAlignment::CENTER); label->setText("Label can line wrap"); @@ -170,7 +170,7 @@ bool UILabelTest_TTF::init() { Size widgetSize = _widget->getSize(); - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Label set TTF font"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -179,7 +179,7 @@ bool UILabelTest_TTF::init() _uiLayer->addChild(alert); // Create the label - gui::Label* label = gui::Label::create(); + gui::Text* label = gui::Text::create(); label->setText("Label"); label->setFontName("fonts/A Damn Mess.ttf"); label->setFontSize(30); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp index 0463da8521..71aa2c817f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp @@ -20,7 +20,7 @@ bool UILayoutTest::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Layout"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -86,7 +86,7 @@ bool UILayoutTest_Color::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Layout color render"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -153,7 +153,7 @@ bool UILayoutTest_Gradient::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Layout gradient render"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -220,7 +220,7 @@ bool UILayoutTest_BackGroundImage::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Layout background image"); alert->setFontName("Marker Felt"); alert->setFontSize(20); @@ -287,7 +287,7 @@ bool UILayoutTest_BackGroundImage_Scale9::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Layout background image scale9"); alert->setFontName("Marker Felt"); alert->setFontSize(20); @@ -354,7 +354,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Layout Linear Vertical"); alert->setFontName("Marker Felt"); alert->setFontSize(20); @@ -439,7 +439,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Layout Linear Horizontal"); alert->setFontName("Marker Felt"); alert->setFontSize(20); @@ -524,7 +524,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Layout Relative Align Parent"); alert->setFontName("Marker Felt"); alert->setFontSize(20); @@ -673,7 +673,7 @@ bool UILayoutTest_Layout_Relative_Location::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Layout Relative Location"); alert->setFontName("Marker Felt"); alert->setFontSize(20); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp index 9ac47f8d73..26ef4781b2 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp @@ -27,7 +27,7 @@ bool UIListViewTest_Vertical::init() { Size widgetSize = _widget->getSize(); - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("Move by vertical direction"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -36,7 +36,7 @@ bool UIListViewTest_Vertical::init() _uiLayer->addChild(_displayValueLabel); - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("ListView vertical"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -70,7 +70,7 @@ bool UIListViewTest_Vertical::init() (backgroundSize.width - listView->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - listView->getSize().height) / 2.0f)); - listView->addEventListenerScrollView(this, scrollvieweventselector(UIListViewTest_Vertical::selectedItemEvent)); + listView->addEventListenerListView(this, listvieweventselector(UIListViewTest_Vertical::selectedItemEvent)); _uiLayer->addChild(listView); @@ -167,22 +167,20 @@ bool UIListViewTest_Vertical::init() return false; } -void UIListViewTest_Vertical::selectedItemEvent(Object *pSender, ScrollviewEventType type) +void UIListViewTest_Vertical::selectedItemEvent(Object *pSender, ListViewEventType type) { - /* switch (type) { - case SCROLLVIEW_EVENT_SELECT_CHILD: + case LISTVIEW_ONSELECTEDITEM: { ListView* listView = static_cast(pSender); - CCLOG("select child index = %d", listView->getSelectedChildIndex()); + CCLOG("select child index = %ld", listView->getCurSelectedIndex()); } break; default: break; } - */ } // UIListViewTest_Horizontal @@ -202,7 +200,7 @@ bool UIListViewTest_Horizontal::init() { Size widgetSize = _widget->getSize(); - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("Move by horizontal direction"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -211,7 +209,7 @@ bool UIListViewTest_Horizontal::init() _uiLayer->addChild(_displayValueLabel); - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("ListView horizontal"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -245,7 +243,7 @@ bool UIListViewTest_Horizontal::init() (backgroundSize.width - listView->getSize().width) / 2.0f, (widgetSize.height - backgroundSize.height) / 2.0f + (backgroundSize.height - listView->getSize().height) / 2.0f)); - listView->addEventListenerScrollView(this, scrollvieweventselector(UIListViewTest_Horizontal::selectedItemEvent)); + listView->addEventListenerListView(this, listvieweventselector(UIListViewTest_Horizontal::selectedItemEvent)); _uiLayer->addChild(listView); @@ -342,20 +340,18 @@ bool UIListViewTest_Horizontal::init() return false; } -void UIListViewTest_Horizontal::selectedItemEvent(Object *pSender, ScrollviewEventType type) +void UIListViewTest_Horizontal::selectedItemEvent(Object *pSender, ListViewEventType type) { - /* switch (type) { - case SCROLLVIEW_EVENT_SELECT_CHILD: + case LISTVIEW_ONSELECTEDITEM: { ListView* listView = static_cast(pSender); - CCLOG("select child index = %d", listView->getSelectedChildIndex()); + CCLOG("select child index = %ld", listView->getCurSelectedIndex()); } break; default: break; } - */ } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h index c52c33eb81..5424c905cb 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.h @@ -33,11 +33,11 @@ public: UIListViewTest_Vertical(); ~UIListViewTest_Vertical(); bool init(); - void selectedItemEvent(Object* pSender, ScrollviewEventType type); + void selectedItemEvent(Object* pSender, ListViewEventType type); protected: UI_SCENE_CREATE_FUNC(UIListViewTest_Vertical) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; std::vector _array; }; @@ -48,11 +48,11 @@ public: UIListViewTest_Horizontal(); ~UIListViewTest_Horizontal(); bool init(); - void selectedItemEvent(Object* pSender, ScrollviewEventType type); + void selectedItemEvent(Object* pSender, ListViewEventType type); protected: UI_SCENE_CREATE_FUNC(UIListViewTest_Horizontal) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; std::vector _array; }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index 5057a13150..ffb6f081b5 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -25,7 +25,7 @@ bool UILoadingBarTest_Left::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("LoadingBar left"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -107,7 +107,7 @@ bool UILoadingBarTest_Right::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label *alert = gui::Label::create(); + gui::Text *alert = gui::Text::create(); alert->setText("LoadingBar right"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -190,7 +190,7 @@ bool UILoadingBarTest_Left_Scale9::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("LoadingBar left scale9 render"); alert->setFontName("Marker Felt"); alert->setFontSize(20); @@ -275,7 +275,7 @@ bool UILoadingBarTest_Right_Scale9::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label *alert = gui::Label::create(); + gui::Text *alert = gui::Text::create(); alert->setText("LoadingBar right scale9 render"); alert->setFontName("Marker Felt"); alert->setFontSize(20); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp index 18ee92cd67..a2f43dd5af 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp @@ -21,7 +21,7 @@ bool UIPageViewTest::init() Size widgetSize = _widget->getSize(); // Add a label in which the dragpanel events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("Move by horizontal direction"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -30,7 +30,7 @@ bool UIPageViewTest::init() _uiLayer->addChild(_displayValueLabel); // Add the black background - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("PageView"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -65,7 +65,7 @@ bool UIPageViewTest::init() imageView->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f)); layout->addChild(imageView); - gui::Label* label = gui::Label::create(); + gui::Text* label = gui::Text::create(); label->setText(CCString::createWithFormat("page %d", (i + 1))->getCString()); label->setFontName("Marker Felt"); label->setFontSize(30); @@ -92,7 +92,7 @@ void UIPageViewTest::pageViewEvent(Object *pSender, PageViewEventType type) { PageView* pageView = dynamic_cast(pSender); - _displayValueLabel->setText(StringUtils::format("page = %zd", pageView->getCurPageIndex() + 1)); + _displayValueLabel->setText(StringUtils::format("page = %d", static_cast(pageView->getCurPageIndex() + 1))); } break; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h index 20bab13100..5c48851768 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.h @@ -38,7 +38,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UIPageViewTest) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; #endif /* defined(__TestCpp__UIPageViewTest__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPickerViewTest/UIPickerViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPickerViewTest/UIPickerViewTest.cpp deleted file mode 100644 index 53ec3758f2..0000000000 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPickerViewTest/UIPickerViewTest.cpp +++ /dev/null @@ -1,264 +0,0 @@ - - -#include "UIPickerViewTest.h" - -// UIPickerViewTest_Vertical - -UIPickerViewTest_Vertical::UIPickerViewTest_Vertical() -{ - -} - -UIPickerViewTest_Vertical::~UIPickerViewTest_Vertical() -{ - CC_SAFE_RELEASE(m_array); -} - -bool UIPickerViewTest_Vertical::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - m_pDisplayValueLabel = gui::Label::create(); - m_pDisplayValueLabel->setText("Move by vertical direction"); - m_pDisplayValueLabel->setFontName("Marker Felt"); - m_pDisplayValueLabel->setFontSize(32); - m_pDisplayValueLabel->setAnchorPoint(Point(0.5f, -1)); - m_pDisplayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + m_pDisplayValueLabel->getContentSize().height * 1.5)); - _uiLayer->addChild(m_pDisplayValueLabel); - - - gui::Label* alert = gui::Label::create(); - alert->setText("PickerView vertical"); - alert->setFontName("Marker Felt"); - alert->setFontSize(30); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075)); - _uiLayer->addChild(alert); - - Layout* root = static_cast(_uiLayer->getChildByTag(81)); - - Layout* background = dynamic_cast(root->getChildByName("background_Panel")); - Size backgroundSize = background->getContentSize(); - - - // create picker view data - m_array = __Array::create(); - CC_SAFE_RETAIN(m_array); - for (int i = 0; i < 20; ++i) - { - String* ccstr = String::createWithFormat("pickerview_%d", i); - m_array->addObject(ccstr); - } - - - // Create the picker view - PickerView* pickerView = PickerView::create(); - // set picker view direction - pickerView->setDirection(SCROLLVIEW_DIR_VERTICAL); - pickerView->setTouchEnabled(true); - pickerView->setBounceEnabled(true); - pickerView->setBackGroundImage("cocosgui/yellow_edit.png"); - pickerView->setBackGroundImageScale9Enabled(true); - pickerView->setSize(Size(240, 150)); - pickerView->setPosition(Point((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - pickerView->getSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - pickerView->getSize().height) / 2)); - pickerView->addEventListenerScrollView(this, scrollvieweventselector(UIPickerViewTest_Vertical::selectedItemEvent)); - pickerView->addEventListenerPickerView(this, pickervieweventselector(UIPickerViewTest_Vertical::pickItemEvent)); - _uiLayer->addChild(pickerView); - - int count = m_array->count(); - pickerView->setItemCountInContainerWithOddNumber(count / 5); - - for (int i = 0; i < count; ++i) - { - Button* button = Button::create(); - button->loadTextures("cocosgui/orange_edit.png", "cocosgui/orange_edit.png", ""); - button->setScale9Enabled(true); - button->setSize(Size(100, - pickerView->getSize().height / pickerView->getItemCountInContainerWithOddNumber())); - button->setTitleText(static_cast(m_array->getObjectAtIndex(i))->getCString()); - - pickerView->addChild(button); - } - - // create picker render of picker view - Button* button_0 = static_cast(pickerView->getChildren().at(0)); - pickerView->loadPickerTexture("cocosgui/green_edit.png"); - Scale9Sprite* pickerRender = pickerView->getPickerRender(); - pickerRender->setOpacity(pickerView->getOpacity() / 3); - pickerRender->setPreferredSize(Size(pickerView->getSize().width, button_0->getSize().height)); - - return true; - } - - return false; -} - -void UIPickerViewTest_Vertical::selectedItemEvent(Object *pSender, ScrollviewEventType type) -{ - switch (type) - { - case SCROLLVIEW_EVENT_SELECT_CHILD: - { - PickerView* pickerView = static_cast(pSender); - CCLOG("select child index = %d", pickerView->getSelectedChildIndex()); - } - break; - - default: - break; - } -} - -void UIPickerViewTest_Vertical::pickItemEvent(Object *pSender, PickerViewEventType type) -{ - switch (type) - { - case PICKERVIEW_EVENT_PICK_ITEM: - { - PickerView* pickerView = static_cast(pSender); - CCLOG("picker view pick index = %d", pickerView->getPickIndex()); - } - break; - - default: - break; - } -} - -// UIPickerViewTest_Horizontal - -UIPickerViewTest_Horizontal::UIPickerViewTest_Horizontal() -{ - -} - -UIPickerViewTest_Horizontal::~UIPickerViewTest_Horizontal() -{ - CC_SAFE_RELEASE(m_array); -} - -bool UIPickerViewTest_Horizontal::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - m_pDisplayValueLabel = gui::Label::create(); - m_pDisplayValueLabel->setText("Move by horizontal direction"); - m_pDisplayValueLabel->setFontName("Marker Felt"); - m_pDisplayValueLabel->setFontSize(32); - m_pDisplayValueLabel->setAnchorPoint(Point(0.5f, -1)); - m_pDisplayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + m_pDisplayValueLabel->getContentSize().height * 1.5)); - _uiLayer->addChild(m_pDisplayValueLabel); - - - gui::Label* alert = gui::Label::create(); - alert->setText("PickerView horizontal"); - alert->setFontName("Marker Felt"); - alert->setFontSize(30); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075)); - _uiLayer->addChild(alert); - - Layout* root = static_cast(_uiLayer->getChildByTag(81)); - - Layout* background = dynamic_cast(root->getChildByName("background_Panel")); - Size backgroundSize = background->getContentSize(); - - - // create picker view data - m_array = __Array::create(); - CC_SAFE_RETAIN(m_array); - for (int i = 0; i < 20; ++i) - { - String* ccstr = String::createWithFormat("PCKER%d", i); - m_array->addObject(ccstr); - } - const char* title_0 = static_cast(m_array->getObjectAtIndex(0))->getCString(); - - - // Create the picker view - PickerView* pickerView = PickerView::create(); - // set picker view direction - pickerView->setDirection(SCROLLVIEW_DIR_HORIZONTAL); - pickerView->setTouchEnabled(true); - pickerView->setBounceEnabled(true); - pickerView->setBackGroundImage("cocosgui/yellow_edit.png"); - pickerView->setBackGroundImageScale9Enabled(true); - pickerView->setSize(Size(240, 150)); - pickerView->setPosition(Point((widgetSize.width - backgroundSize.width) / 2 + - (backgroundSize.width - pickerView->getSize().width) / 2, - (widgetSize.height - backgroundSize.height) / 2 + - (backgroundSize.height - pickerView->getSize().height) / 2)); - pickerView->addEventListenerScrollView(this, scrollvieweventselector(UIPickerViewTest_Horizontal::selectedItemEvent)); - pickerView->addEventListenerPickerView(this, pickervieweventselector(UIPickerViewTest_Horizontal::pickItemEvent)); - _uiLayer->addChild(pickerView); - - int count = m_array->count(); - pickerView->setItemCountInContainerWithOddNumber(count / 4); - - for (int i = 0; i < count; ++i) - { - Button* button = Button::create(); - button->loadTextures("cocosgui/orange_edit.png", "cocosgui/orange_edit.png", ""); - button->setScale9Enabled(true); - button->setSize(Size(pickerView->getSize().width / pickerView->getItemCountInContainerWithOddNumber(), - 120)); - button->setTitleText(static_cast(m_array->getObjectAtIndex(i))->getCString()); - button->setTitleDimension(Size(button->getTitleFontSize(), - button->getTitleFontSize() * (strlen(title_0) * 2))); - button->setTitleHorizontalAlignment(TextHAlignment::CENTER); - button->setTitleVerticalAlignment(TextVAlignment::CENTER); - - pickerView->addChild(button); - } - - // create picker render of picker view - Button* button_0 = static_cast(pickerView->getChildren().at(0)); - pickerView->loadPickerTexture("cocosgui/green_edit.png"); - Scale9Sprite* pickerRender = pickerView->getPickerRender(); - pickerRender->setOpacity(pickerView->getOpacity() / 3); - pickerRender->setPreferredSize(Size(button_0->getSize().width, pickerView->getSize().height)); - - return true; - } - - return false; -} - -void UIPickerViewTest_Horizontal::selectedItemEvent(Object *pSender, ScrollviewEventType type) -{ - switch (type) - { - case SCROLLVIEW_EVENT_SELECT_CHILD: - { - PickerView* pickerView = static_cast(pSender); - CCLOG("select child index = %d", pickerView->getSelectedChildIndex()); - } - break; - - default: - break; - } -} - -void UIPickerViewTest_Horizontal::pickItemEvent(Object *pSender, PickerViewEventType type) -{ - switch (type) - { - case PICKERVIEW_EVENT_PICK_ITEM: - { - PickerView* pickerView = static_cast(pSender); - CCLOG("picker view pick index = %d", pickerView->getPickIndex()); - } - break; - - default: - break; - } -} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPickerViewTest/UIPickerViewTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPickerViewTest/UIPickerViewTest.h deleted file mode 100644 index 10c47aed5d..0000000000 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPickerViewTest/UIPickerViewTest.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__UIPickViewTest__ -#define __TestCpp__UIPickViewTest__ - -#include "../UIScene.h" - -class UIPickerViewTest_Vertical : public UIScene -{ -public: - UIPickerViewTest_Vertical(); - ~UIPickerViewTest_Vertical(); - bool init(); - void selectedItemEvent(Object* pSender, ScrollviewEventType type); - void pickItemEvent(Object* pSender, PickerViewEventType type); - -protected: - UI_SCENE_CREATE_FUNC(UIPickerViewTest_Vertical) - gui::Label* m_pDisplayValueLabel; - - __Array* m_array; -}; - -class UIPickerViewTest_Horizontal : public UIScene -{ -public: - UIPickerViewTest_Horizontal(); - ~UIPickerViewTest_Horizontal(); - bool init(); - void selectedItemEvent(Object* pSender, ScrollviewEventType type); - void pickItemEvent(Object* pSender, PickerViewEventType type); - -protected: - UI_SCENE_CREATE_FUNC(UIPickerViewTest_Horizontal) - gui::Label* m_pDisplayValueLabel; - - __Array* m_array; -}; - -#endif /* defined(__TestCpp__UIPickViewTest__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPotentiometerTest/UIPotentiometerTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPotentiometerTest/UIPotentiometerTest.cpp deleted file mode 100644 index b94b81e613..0000000000 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIPotentiometerTest/UIPotentiometerTest.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -#include "UIPotentiometerTest.h" - -// UIPotentiometerTest -UIPotentiometerTest::UIPotentiometerTest() -: _displayValueLabel(NULL) -{ -} - -UIPotentiometerTest::~UIPotentiometerTest() -{ -} - -bool UIPotentiometerTest::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add a label in which the button events will be displayed - _displayValueLabel = gui::Label::create(); - _displayValueLabel->setText("No Event"); - _displayValueLabel->setFontName("Marker Felt"); - _displayValueLabel->setFontSize(32); - _displayValueLabel->setAnchorPoint(Point(0.5f, -1)); - _displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height / 3)); - _uiLayer->addChild(_displayValueLabel); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Potentiometer"); - alert->setFontName("Marker Felt"); - alert->setFontSize(30); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2)); - _uiLayer->addChild(alert); - - // Create the potentiometer - Potentiometer *potentiometer = Potentiometer::create(); - potentiometer->setTouchEnabled(true); - potentiometer->loadTexture("cocosgui/potentiometerTrack.png", "cocosgui/potentiometerProgress.png", "cocosgui/potentiometerButton.png"); - potentiometer->setPosition(Point(widgetSize.width / 2 - potentiometer->getSize().width, widgetSize.height / 2)); - potentiometer->addEventListenerPotentiometer(this, potentiometervaluechangedselector(UIPotentiometerTest::valueChangedEvent)); - - _uiLayer->addChild(potentiometer); - - - // Create the potentiometer with allow min and max value - Potentiometer *potentiometerAllow = Potentiometer::create(); - potentiometerAllow->setTouchEnabled(true); - potentiometerAllow->loadTexture("cocosgui/potentiometerTrack.png", "cocosgui/potentiometerProgress.png", "cocosgui/potentiometerButton.png"); - potentiometerAllow->setPosition(Point(widgetSize.width / 2 + potentiometerAllow->getSize().width, widgetSize.height / 2)); - potentiometerAllow->addEventListenerPotentiometer(this, potentiometervaluechangedselector(UIPotentiometerTest::valueChangedEvent)); - - potentiometerAllow->setMinimumAllowValue(0.3); - potentiometerAllow->setMaximumAllowValue(0.7); - potentiometerAllow->setValue(0.3); - - _uiLayer->addChild(potentiometerAllow); - - return true; - } - return false; -} - -void UIPotentiometerTest::valueChangedEvent(Object *pSender, PotentiometerEventType type) -{ - Potentiometer* potentiometer = static_cast(pSender); - - switch (type) - { - case POTENTIOMETER_EVENT_VALUECHANGED: - _displayValueLabel->setText(CCString::createWithFormat("%.02f", potentiometer->getValue())->getCString()); - break; - - default: - break; - } -} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIProgressTimerTest/UIProgressTimerTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIProgressTimerTest/UIProgressTimerTest.cpp deleted file mode 100644 index 9ec70b7f0b..0000000000 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIProgressTimerTest/UIProgressTimerTest.cpp +++ /dev/null @@ -1,362 +0,0 @@ - - -#include "UIProgressTimerTest.h" - -// UIProgressTimerTest_Radial -bool UIProgressTimerTest_Radial::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Progress Timer Radial"); - alert->setFontName("Marker Felt"); - alert->setFontSize(30); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); - _uiLayer->addChild(alert); - - // Create the progress timer - ProgressTo* to1 = ProgressTo::create(2.0f, 100.0f); - ProgressTo* to2 = ProgressTo::create(2.0f, 100.0f); - - gui::ProgressTimer* left = gui::ProgressTimer::create(); - left->loadTexture("cocosgui/potentiometerProgress.png"); - left->setPosition(Point(widgetSize.width / 2.0f - left->getSize().width * 0.75f, widgetSize.height / 2.0f + left->getSize().height / 6.0f)); - left->setType(cocos2d::ProgressTimer::Type::RADIAL); - left->getVirtualRenderer()->runAction(RepeatForever::create(to1)); - _uiLayer->addChild(left); - - gui::ProgressTimer* right = gui::ProgressTimer::create(); - right->loadTexture("cocosgui/potentiometerProgress.png"); - right->setPosition(Point(widgetSize.width / 2.0f + right->getSize().width * 0.75f, widgetSize.height / 2.0f + right->getSize().height / 6.0f)); - right->setType(cocos2d::ProgressTimer::Type::RADIAL); - // Makes the ridial CCW - right->setReverseProgress(true); - right->getVirtualRenderer()->runAction(RepeatForever::create(to2)); - _uiLayer->addChild(right); - - return true; - } - return false; -} - -// UIProgressTimerTest_Horizontal -bool UIProgressTimerTest_Horizontal::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Progress Timer Horizontal"); - alert->setFontName("Marker Felt"); - alert->setFontSize(26); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.125f)); - _uiLayer->addChild(alert); - - // Create the progress timer - ProgressTo* to1 = ProgressTo::create(2.0f, 100.0f); - ProgressTo* to2 = ProgressTo::create(2.0f, 100.0f); - - gui::ProgressTimer* left = gui::ProgressTimer::create(); - left->loadTexture("cocosgui/potentiometerProgress.png"); - left->setPosition(Point(widgetSize.width / 2.0f - left->getSize().width * 0.75f, widgetSize.height / 2.0f + left->getSize().height / 6.0f)); - left->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the left since the midpoint is 0 for the x - left->setMidPoint(Point(0, 0)); - // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - left->setBarChangeRate(Point(1, 0)); - left->getVirtualRenderer()->runAction(RepeatForever::create(to1)); - _uiLayer->addChild(left); - - gui::ProgressTimer* right = gui::ProgressTimer::create(); - right->loadTexture("cocosgui/potentiometerProgress.png"); - right->setPosition(Point(widgetSize.width / 2.0f + right->getSize().width * 0.75f, widgetSize.height / 2.0f + right->getSize().height / 6.0f)); - right->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the left since the midpoint is 1 for the x - right->setMidPoint(Point(1, 0)); - // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - right->setBarChangeRate(Point(1, 0)); - right->getVirtualRenderer()->runAction(RepeatForever::create(to2)); - _uiLayer->addChild(right); - - return true; - } - return false; -} - -// UIProgressTimerTest_Vertical -bool UIProgressTimerTest_Vertical::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Progress Timer Vertical"); - alert->setFontName("Marker Felt"); - alert->setFontSize(26); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.125f)); - _uiLayer->addChild(alert); - - // Create the progress timer - ProgressTo* to1 = ProgressTo::create(2.0f, 100.0f); - ProgressTo* to2 = ProgressTo::create(2.0f, 100.0f); - - gui::ProgressTimer* left = gui::ProgressTimer::create(); - left->loadTexture("cocosgui/potentiometerProgress.png"); - left->setPosition(Point(widgetSize.width / 2.0f - left->getSize().width * 0.75f, widgetSize.height / 2.0f + left->getSize().height / 6.0f)); - left->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left->setMidPoint(Point(0, 0)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Point(0, 1)); - left->getVirtualRenderer()->runAction(RepeatForever::create(to1)); - _uiLayer->addChild(left); - - gui::ProgressTimer* right = gui::ProgressTimer::create(); - right->loadTexture("cocosgui/potentiometerProgress.png"); - right->setPosition(Point(widgetSize.width / 2.0f + right->getSize().width * 0.75f, widgetSize.height / 2.0f + right->getSize().height / 6.0f)); - right->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right->setMidPoint(Point(0, 1)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right->setBarChangeRate(Point(0, 1)); - right->getVirtualRenderer()->runAction(RepeatForever::create(to2)); - _uiLayer->addChild(right); - - return true; - } - return false; -} - -// UIProgressTimerTest_RadialMidpointChanged -bool UIProgressTimerTest_RadialMidpointChanged::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Progress Timer Radial Midpoint Changed"); - alert->setFontName("Marker Felt"); - alert->setFontSize(17); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.325f)); - _uiLayer->addChild(alert); - - // Create the progress timer - ProgressTo* action = ProgressTo::create(2.0f, 100.0f); - - gui::ProgressTimer* left = gui::ProgressTimer::create(); - left->loadTexture("cocosgui/potentiometerProgress.png"); - left->setPosition(Point(widgetSize.width / 2.0f - left->getSize().width * 0.75f, widgetSize.height / 2.0f + left->getSize().height / 6.0f)); - left->setType(cocos2d::ProgressTimer::Type::RADIAL); - left->setMidPoint(Point(0.25f, 0.75f)); - left->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)action->clone())); - _uiLayer->addChild(left); - - gui::ProgressTimer* right = gui::ProgressTimer::create(); - right->loadTexture("cocosgui/potentiometerProgress.png"); - right->setPosition(Point(widgetSize.width / 2.0f + right->getSize().width * 0.75f, widgetSize.height / 2.0f + right->getSize().height / 6.0f)); - right->setType(cocos2d::ProgressTimer::Type::RADIAL); - right->setMidPoint(Point(0.75f, 0.25f)); - right->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)action->clone())); - _uiLayer->addChild(right); - - return true; - } - return false; -} - -// UIProgressTimerTest_BarVarious -bool UIProgressTimerTest_BarVarious::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Progress Timer Bar Various"); - alert->setFontName("Marker Felt"); - alert->setFontSize(26); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.125f)); - _uiLayer->addChild(alert); - - // Create the progress timer - ProgressTo* to = ProgressTo::create(2.0f, 100.0f); - - gui::ProgressTimer* left = gui::ProgressTimer::create(); - left->loadTexture("cocosgui/potentiometerProgress.png"); - left->setPosition(Point(widgetSize.width / 2.0f - left->getSize().width * 1.1, widgetSize.height / 2.0f + left->getSize().height / 6.0f)); - left->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left->setMidPoint(Point(0.5f, 0.5f)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Point(1, 0)); - left->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)to->clone())); - _uiLayer->addChild(left); - - gui::ProgressTimer* middle = gui::ProgressTimer::create(); - middle->loadTexture("cocosgui/potentiometerProgress.png"); - middle->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + middle->getSize().height / 6.0f)); - middle->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle->setMidPoint(Point(0.5f, 0.5f)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle->setBarChangeRate(Point(1, 1)); - middle->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)to->clone())); - _uiLayer->addChild(middle); - - gui::ProgressTimer* right = gui::ProgressTimer::create(); - right->loadTexture("cocosgui/potentiometerProgress.png"); - right->setPosition(Point(widgetSize.width / 2.0f + right->getSize().width * 1.1, widgetSize.height / 2.0f + right->getSize().height / 6.0f)); - right->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right->setMidPoint(Point(0.5f, 0.5f)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right->setBarChangeRate(Point(0, 1)); - right->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)to->clone())); - _uiLayer->addChild(right); - - return true; - } - return false; -} - -// UIProgressTimerTest_BarTintAndFade -bool UIProgressTimerTest_BarTintAndFade::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Progress Timer Bar Tint and Fade"); - alert->setFontName("Marker Felt"); - alert->setFontSize(20); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.725f)); - _uiLayer->addChild(alert); - - // Create the progress timer - ProgressTo* to = ProgressTo::create(6, 100.0f); - Action* tint = Sequence::create(TintTo::create(1, 255, 0, 0), - TintTo::create(1, 0, 255, 0), - TintTo::create(1, 0, 0, 255), - NULL); - Action* fade = Sequence::create(FadeTo::create(1.0f, 0), - FadeTo::create(1.0f, 255), - NULL); - - gui::ProgressTimer* left = gui::ProgressTimer::create(); - left->loadTexture("cocosgui/potentiometerProgress.png"); - left->setPosition(Point(widgetSize.width / 2.0f - left->getSize().width * 1.1, widgetSize.height / 2.0f + left->getSize().height / 6.0f)); - left->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left->setMidPoint(Point(0.5f, 0.5f)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Point(1, 0)); - left->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)to->clone())); - left->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)tint->clone())); - _uiLayer->addChild(left); - - gui::ProgressTimer* middle = gui::ProgressTimer::create(); - middle->loadTexture("cocosgui/potentiometerProgress.png"); - middle->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + middle->getSize().height / 6.0f)); - middle->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle->setMidPoint(Point(0.5f, 0.5f)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle->setBarChangeRate(Point(1, 1)); - middle->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)to->clone())); - middle->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)fade->clone())); - _uiLayer->addChild(middle); - - gui::ProgressTimer* right = gui::ProgressTimer::create(); - right->loadTexture("cocosgui/potentiometerProgress.png"); - right->setPosition(Point(widgetSize.width / 2.0f + right->getSize().width * 1.1, widgetSize.height / 2.0f + right->getSize().height / 6.0f)); - right->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right->setMidPoint(Point(0.5f, 0.5f)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right->setBarChangeRate(Point(0, 1)); - right->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)to->clone())); - right->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)tint->clone())); - right->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)fade->clone())); - _uiLayer->addChild(right); - - return true; - } - return false; -} - -// UIProgressTimerTest_WithSpriteFrame -bool UIProgressTimerTest_WithSpriteFrame::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Progress Timer with SpriteFrame"); - alert->setFontName("Marker Felt"); - alert->setFontSize(20); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.725f)); - _uiLayer->addChild(alert); - - // Create the progress timer - ProgressTo* to = ProgressTo::create(6, 100.0f); - - SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist"); - - gui::ProgressTimer* left = gui::ProgressTimer::create(); - left->loadTexture("grossini_dance_01.png", UI_TEX_TYPE_PLIST); - left->setPosition(Point(widgetSize.width / 2.0f - left->getSize().width * 2.0f, widgetSize.height / 2.0f + left->getSize().height / 6.0f)); - left->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - left->setMidPoint(Point(0.5f, 0.5f)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left->setBarChangeRate(Point(1, 0)); - left->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)to->clone())); - _uiLayer->addChild(left); - - gui::ProgressTimer* middle = gui::ProgressTimer::create(); - middle->loadTexture("grossini_dance_04.png", UI_TEX_TYPE_PLIST); - middle->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + middle->getSize().height / 6.0f)); - middle->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle->setMidPoint(Point(0.5f, 0.5f)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle->setBarChangeRate(Point(1, 1)); - middle->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)to->clone())); - _uiLayer->addChild(middle); - - gui::ProgressTimer* right = gui::ProgressTimer::create(); - right->loadTexture("grossini_dance_03.png", UI_TEX_TYPE_PLIST); - right->setPosition(Point(widgetSize.width / 2.0f + right->getSize().width * 2.0f, widgetSize.height / 2.0f + right->getSize().height / 6.0f)); - right->setType(cocos2d::ProgressTimer::Type::BAR); - // Setup for a bar starting from the bottom since the midpoint is 0 for the y - right->setMidPoint(Point(0.5f, 0.5f)); - // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right->setBarChangeRate(Point(0, 1)); - right->getVirtualRenderer()->runAction(RepeatForever::create((ActionInterval *)to->clone())); - _uiLayer->addChild(right); - - return true; - } - return false; -} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIProgressTimerTest/UIProgressTimerTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIProgressTimerTest/UIProgressTimerTest.h deleted file mode 100644 index b13d9796b1..0000000000 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIProgressTimerTest/UIProgressTimerTest.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__UIProgressTimerTest__ -#define __TestCpp__UIProgressTimerTest__ - -#include "../UIScene.h" - -class UIProgressTimerTest_Radial : public UIScene -{ -public: - bool init(); - -protected: - UI_SCENE_CREATE_FUNC(UIProgressTimerTest_Radial) -}; - -class UIProgressTimerTest_Horizontal : public UIScene -{ -public: - bool init(); - -protected: - UI_SCENE_CREATE_FUNC(UIProgressTimerTest_Horizontal) -}; - -class UIProgressTimerTest_Vertical : public UIScene -{ -public: - bool init(); - -protected: - UI_SCENE_CREATE_FUNC(UIProgressTimerTest_Vertical) -}; - -class UIProgressTimerTest_RadialMidpointChanged : public UIScene -{ -public: - bool init(); - -protected: - UI_SCENE_CREATE_FUNC(UIProgressTimerTest_RadialMidpointChanged) -}; - -class UIProgressTimerTest_BarVarious : public UIScene -{ -public: - bool init(); - -protected: - UI_SCENE_CREATE_FUNC(UIProgressTimerTest_BarVarious) -}; - -class UIProgressTimerTest_BarTintAndFade : public UIScene -{ -public: - bool init(); - -protected: - UI_SCENE_CREATE_FUNC(UIProgressTimerTest_BarTintAndFade) -}; - -class UIProgressTimerTest_WithSpriteFrame : public UIScene -{ -public: - bool init(); - -protected: - UI_SCENE_CREATE_FUNC(UIProgressTimerTest_WithSpriteFrame) -}; - -#endif /* defined(__TestCpp__UIProgressTimerTest__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp index 00773ee5eb..7eafc723da 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp @@ -27,14 +27,19 @@ bool UIScene::init() _uiLayer = Layer::create(); addChild(_uiLayer); - _widget = dynamic_cast(cocostudio::GUIReader::shareReader()->widgetFromJsonFile("cocosgui/UITest/UITest.json")); + _widget = dynamic_cast(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosgui/UITest/UITest.json")); _uiLayer->addChild(_widget); + Size screenSize = Director::getInstance()->getWinSize(); + Size rootSize = _widget->getSize(); + _uiLayer->setPosition(Point((screenSize.width - rootSize.width) / 2, + (screenSize.height - rootSize.height) / 2)); + Layout* root = static_cast(_uiLayer->getChildByTag(81)); - _sceneTitle = dynamic_cast(root->getChildByName("UItest")); + _sceneTitle = dynamic_cast(root->getChildByName("UItest")); - gui::Label* back_label = dynamic_cast(root->getChildByName("back")); + gui::Text* back_label = dynamic_cast(root->getChildByName("back")); back_label->addTouchEventListener(this, toucheventselector(UIScene::toCocosGUITestScene)); Button* left_button = dynamic_cast(root->getChildByName("left_Button")); @@ -46,18 +51,6 @@ bool UIScene::init() Button* right_button = dynamic_cast(root->getChildByName("right_Button")); right_button->addTouchEventListener(this, toucheventselector(UIScene::nextCallback)); - /* - gui::Label* mainMenuLabel = gui::Label::create(); - mainMenuLabel->setText("MainMenu"); - mainMenuLabel->setFontSize(20); - mainMenuLabel->setTouchScaleChangeEnabled(true); - mainMenuLabel->setPosition(Point(430,30)); - mainMenuLabel->setTouchEnabled(true); - mainMenuLabel->addTouchEventListener(this, toucheventselector(UIScene::menuCloseCallback)); - _uiLayer->addWidget(mainMenuLabel); - */ - - return true; } return false; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.h index 71c4e67cdb..32d073c97b 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScene.h @@ -65,7 +65,7 @@ public: virtual void nextCallback(Object* sender, TouchEventType type); /** Title label of the scene. */ - CC_SYNTHESIZE_READONLY(gui::Label*, _sceneTitle, SceneTitle) + CC_SYNTHESIZE_READONLY(gui::Text*, _sceneTitle, SceneTitle) UI_SCENE_CREATE_FUNC(UIScene); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp index f09f8f2804..922b25a2cb 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp @@ -21,7 +21,7 @@ bool UIScrollViewTest_Vertical::init() Size widgetSize = _widget->getSize(); // Add a label in which the scrollview alert will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("Move by vertical direction"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -30,7 +30,7 @@ bool UIScrollViewTest_Vertical::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("ScrollView vertical"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -109,7 +109,7 @@ bool UIScrollViewTest_Horizontal::init() Size widgetSize = _widget->getSize(); // Add a label in which the scrollview alert will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("Move by horizontal direction"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -117,7 +117,7 @@ bool UIScrollViewTest_Horizontal::init() _displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f)); _uiLayer->addChild(_displayValueLabel); - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("ScrollView horizontal"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -203,7 +203,7 @@ bool UIScrollViewTest_Both::init() Size widgetSize = _widget->getSize();; // Add a label in which the dragpanel events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("Move by any direction"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -212,7 +212,7 @@ bool UIScrollViewTest_Both::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("ScrollView both"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -272,7 +272,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init() Size widgetSize = _widget->getSize(); // Add a label in which the dragpanel events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); // _displayValueLabel->setText("No Event"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -281,7 +281,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("ScrollView scroll to percent both directrion"); alert->setFontName("Marker Felt"); alert->setFontSize(20); @@ -334,7 +334,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce::init() Size widgetSize = _widget->getSize(); // Add a label in which the dragpanel events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); // _displayValueLabel->setText("No Event"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -343,7 +343,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("ScrollView scroll to percent both directrion bounce"); alert->setFontName("Marker Felt"); alert->setFontSize(20); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.h index c6bea01434..ffa0d7401a 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.h @@ -36,7 +36,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UIScrollViewTest_Vertical) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; class UIScrollViewTest_Horizontal : public UIScene @@ -48,7 +48,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UIScrollViewTest_Horizontal) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; class UIScrollViewTest_Both : public UIScene @@ -60,7 +60,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UIScrollViewTest_Both) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; class UIScrollViewTest_ScrollToPercentBothDirection : public UIScene @@ -72,7 +72,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UIScrollViewTest_ScrollToPercentBothDirection) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; class UIScrollViewTest_ScrollToPercentBothDirection_Bounce : public UIScene @@ -84,7 +84,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UIScrollViewTest_ScrollToPercentBothDirection_Bounce) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; #endif /* defined(__TestCpp__UIScrollViewTest__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index 0fda6ac340..1723200de6 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -22,7 +22,7 @@ bool UISliderTest::init() Size widgetSize = _widget->getSize(); // Add a label in which the slider alert will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("Move the slider thumb"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -31,7 +31,7 @@ bool UISliderTest::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Slider"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -97,7 +97,7 @@ bool UISliderTest_Scale9::init() Size widgetSize = _widget->getSize(); // Add a label in which the slider alert will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("Move the slider thumb"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -106,7 +106,7 @@ bool UISliderTest_Scale9::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label *alert = gui::Label::create(); + gui::Text *alert = gui::Text::create(); alert->setText("Slider scale9 render"); alert->setFontName("Marker Felt"); alert->setFontSize(30); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.h index 2cd9bfc383..f86ad7f440 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.h @@ -37,7 +37,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UISliderTest) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; class UISliderTest_Scale9 : public UIScene @@ -50,7 +50,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UISliderTest_Scale9) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; #endif /* defined(__TestCpp__UISliderTest__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISwitchTest/UISwitchTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISwitchTest/UISwitchTest.cpp deleted file mode 100644 index 6b5483486b..0000000000 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISwitchTest/UISwitchTest.cpp +++ /dev/null @@ -1,254 +0,0 @@ - - -#include "UISwitchTest.h" - -// UISwitchTest_Horizontal -UISwitchTest_Horizontal::UISwitchTest_Horizontal() -{ -} - -UISwitchTest_Horizontal::~UISwitchTest_Horizontal() -{ -} - -bool UISwitchTest_Horizontal::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add a label in which the switch events will be displayed - _displayValueLabel = gui::Label::create(); - _displayValueLabel->setText("No Event"); - _displayValueLabel->setFontName("Marker Felt"); - _displayValueLabel->setFontSize(32); - _displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f)); - _displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - _uiLayer->addChild(_displayValueLabel); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Switch Horizontal"); - alert->setFontName("Marker Felt"); - alert->setFontSize(30); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); - _uiLayer->addChild(alert); - - // Create the switch - Switch* pSwitch = Switch::create(); - pSwitch->setTouchEnabled(true); - pSwitch->loadTextures("cocosgui/switch-mask.png", "cocosgui/switch-on.png", "cocosgui/switch-off.png", "cocosgui/switch-thumb.png"); - pSwitch->setOnTitleText("On"); - pSwitch->setOffTitleText("Off"); - pSwitch->setOnTitleFontName("Arial-BoldMT"); - pSwitch->setOnTitleFontSize(16); - pSwitch->setOffTitleFontName("Arial-BoldMT"); - pSwitch->setOffTitleFontSize(16); - Size switchSize = pSwitch->getSize(); - pSwitch->setPosition(Point((widgetSize.width - switchSize.width) / 2.0f, (widgetSize.height - switchSize.height) / 2.0f)); - pSwitch->addEventListenerSwitch(this, switchselector(UISwitchTest_Horizontal::switchEvent)); - _uiLayer->addChild(pSwitch); - - return true; - } - return false; -} - -void UISwitchTest_Horizontal::switchEvent(Object *pSender, SwitchEventType type) -{ - Switch* pSwitch = static_cast(pSender); - - if (pSwitch->isOn()) - { - _displayValueLabel->setText("On"); - } - else - { - _displayValueLabel->setText("Off"); - } - - switch (type) - { - case SWITCH_EVENT_ON: - - break; - - case SWITCH_EVENT_OFF: - - break; - - default: - break; - } -} - -// UISwitchTest_Vertical -UISwitchTest_Vertical::UISwitchTest_Vertical() -{ -} - -UISwitchTest_Vertical::~UISwitchTest_Vertical() -{ -} - -bool UISwitchTest_Vertical::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add a label in which the switch events will be displayed - _displayValueLabel = gui::Label::create(); - _displayValueLabel->setText("No Event"); - _displayValueLabel->setFontName("Marker Felt"); - _displayValueLabel->setFontSize(32); - _displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f)); - _displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - _uiLayer->addChild(_displayValueLabel); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Switch Vertical"); - alert->setFontName("Marker Felt"); - alert->setFontSize(30); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f)); - _uiLayer->addChild(alert); - - // Create the switch - Switch* pSwitch = Switch::create(); - pSwitch->setTouchEnabled(true); - pSwitch->loadTextures("cocosgui/switch-mask_v.png", "cocosgui/switch-on_v.png", "cocosgui/switch-off_v.png", "cocosgui/switch-thumb_v.png"); - pSwitch->setOnTitleText("On"); - pSwitch->setOffTitleText("Off"); - pSwitch->setOnTitleFontName("Arial-BoldMT"); - pSwitch->setOnTitleFontSize(16); - pSwitch->setOffTitleFontName("Arial-BoldMT"); - pSwitch->setOffTitleFontSize(16); - Size switchSize = pSwitch->getSize(); - pSwitch->setPosition(Point((widgetSize.width - switchSize.width) / 2.0f, (widgetSize.height - switchSize.height) / 2.0f)); - pSwitch->addEventListenerSwitch(this, switchselector(UISwitchTest_Horizontal::switchEvent)); - _uiLayer->addChild(pSwitch); - - pSwitch->setDirection(SWITCH_DIRECTION_VERTICAL); - - return true; - } - return false; -} - -void UISwitchTest_Vertical::switchEvent(Object *pSender, SwitchEventType type) -{ - Switch *pSwitch = static_cast(pSender); - - if (pSwitch->isOn()) - { - _displayValueLabel->setText("On"); - } - else - { - _displayValueLabel->setText("Off"); - } - - switch (type) - { - case SWITCH_EVENT_ON: - - break; - - case SWITCH_EVENT_OFF: - - break; - - default: - break; - } -} - -// UISwitchTest_VerticalAndTitleVertical -UISwitchTest_VerticalAndTitleVertical::UISwitchTest_VerticalAndTitleVertical() -{ -} - -UISwitchTest_VerticalAndTitleVertical::~UISwitchTest_VerticalAndTitleVertical() -{ -} - -bool UISwitchTest_VerticalAndTitleVertical::init() -{ - if (UIScene::init()) - { - Size widgetSize = _widget->getSize(); - - // Add a label in which the switch events will be displayed - _displayValueLabel = gui::Label::create(); - _displayValueLabel->setText("No Event"); - _displayValueLabel->setFontName("Marker Felt"); - _displayValueLabel->setFontSize(32); - _displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f)); - _displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - _uiLayer->addChild(_displayValueLabel); - - // Add the alert - gui::Label* alert = gui::Label::create(); - alert->setText("Switch Vertical and Title Vertical"); - alert->setFontName("Marker Felt"); - alert->setFontSize(20); - alert->setColor(Color3B(159, 168, 176)); - alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7)); - _uiLayer->addChild(alert); - - // Create the switch - Switch* pSwitch = Switch::create(); - pSwitch->setTouchEnabled(true); - pSwitch->loadTextures("cocosgui/switch-mask_v.png", "cocosgui/switch-on_v.png", "cocosgui/switch-off_v.png", "cocosgui/switch-thumb_v.png"); - pSwitch->setOnTitleText("On"); - pSwitch->setOffTitleText("Off"); - pSwitch->setOnTitleFontName("Arial-BoldMT"); - pSwitch->setOnTitleFontSize(16); - pSwitch->setOffTitleFontName("Arial-BoldMT"); - pSwitch->setOffTitleFontSize(16); - Size switchSize = pSwitch->getSize(); - pSwitch->setPosition(Point((widgetSize.width - switchSize.width) / 2.0f, (widgetSize.height - switchSize.height) / 2.0f)); - pSwitch->addEventListenerSwitch(this, switchselector(UISwitchTest_Horizontal::switchEvent)); - _uiLayer->addChild(pSwitch); - - - pSwitch->setDirection(SWITCH_DIRECTION_VERTICAL); - - // set unicode text with title vertical direction - pSwitch->setTitleDirection(SWITCH_TITLE_DIRECTION_VERTICAL); - - return true; - } - return false; -} - -void UISwitchTest_VerticalAndTitleVertical::switchEvent(Object *pSender, SwitchEventType type) -{ - Switch* pSwitch = static_cast(pSender); - - if (pSwitch->isOn()) - { - _displayValueLabel->setText("On"); - } - else - { - _displayValueLabel->setText("Off"); - } - - switch (type) - { - case SWITCH_EVENT_ON: - - break; - - case SWITCH_EVENT_OFF: - - break; - - default: - break; - } -} diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISwitchTest/UISwitchTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISwitchTest/UISwitchTest.h deleted file mode 100644 index ff5e40945e..0000000000 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UISwitchTest/UISwitchTest.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef __TestCpp__UISwitchTest__ -#define __TestCpp__UISwitchTest__ - -#include "../UIScene.h" - -class UISwitchTest_Horizontal : public UIScene -{ -public: - UISwitchTest_Horizontal(); - ~UISwitchTest_Horizontal(); - bool init(); - void switchEvent(Object* pSender, SwitchEventType type); - -protected: - UI_SCENE_CREATE_FUNC(UISwitchTest_Horizontal) - gui::Label* _displayValueLabel; -}; - -class UISwitchTest_Vertical : public UIScene -{ -public: - UISwitchTest_Vertical(); - ~UISwitchTest_Vertical(); - bool init(); - void switchEvent(Object* pSender, SwitchEventType type); - -protected: - UI_SCENE_CREATE_FUNC(UISwitchTest_Vertical) - gui::Label* _displayValueLabel; -}; - -class UISwitchTest_VerticalAndTitleVertical : public UIScene -{ -public: - UISwitchTest_VerticalAndTitleVertical(); - ~UISwitchTest_VerticalAndTitleVertical(); - bool init(); - void switchEvent(Object* pSender, SwitchEventType type); - -protected: - UI_SCENE_CREATE_FUNC(UISwitchTest_VerticalAndTitleVertical) - gui::Label* _displayValueLabel; -}; - -#endif /* defined(__TestCpp__UISwitchTest__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp index 5c4a710067..0862a7dc52 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp @@ -20,7 +20,7 @@ bool UITextFieldTest::init() Size widgetSize = _widget->getSize(); // Add a label in which the textfield events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("No Event"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -29,7 +29,7 @@ bool UITextFieldTest::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("TextField"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -106,7 +106,7 @@ bool UITextFieldTest_MaxLength::init() Size screenSize = CCDirector::getInstance()->getWinSize(); // Add a label in which the textfield events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("No Event"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -115,7 +115,7 @@ bool UITextFieldTest_MaxLength::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label *alert = gui::Label::create(); + gui::Text *alert = gui::Text::create(); alert->setText("TextField max length"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -200,7 +200,7 @@ bool UITextFieldTest_Password::init() Size screenSize = CCDirector::getInstance()->getWinSize(); // Add a label in which the textfield events will be displayed - _displayValueLabel = gui::Label::create(); + _displayValueLabel = gui::Text::create(); _displayValueLabel->setText("No Event"); _displayValueLabel->setFontName("Marker Felt"); _displayValueLabel->setFontSize(32); @@ -209,7 +209,7 @@ bool UITextFieldTest_Password::init() _uiLayer->addChild(_displayValueLabel); // Add the alert - gui::Label *alert = gui::Label::create(); + gui::Text *alert = gui::Text::create(); alert->setText("TextField password"); alert->setFontName("Marker Felt"); alert->setFontSize(30); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h index 02bb60a612..e568d9f400 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.h @@ -37,7 +37,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UITextFieldTest) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; class UITextFieldTest_MaxLength : public UIScene @@ -50,7 +50,7 @@ public: protected: UI_SCENE_CREATE_FUNC(UITextFieldTest_MaxLength) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; class UITextFieldTest_Password : public UIScene @@ -63,6 +63,6 @@ public: protected: UI_SCENE_CREATE_FUNC(UITextFieldTest_Password) - gui::Label* _displayValueLabel; + gui::Text* _displayValueLabel; }; #endif /* defined(__TestCpp__UITextFieldTest__) */ diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp index 43ab1182c5..66dd77838e 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest.cpp @@ -21,7 +21,7 @@ bool UIWidgetAddNodeTest::init() Size widgetSize = _widget->getSize(); // Add the alert - gui::Label* alert = gui::Label::create(); + gui::Text* alert = gui::Text::create(); alert->setText("Widget Add Node"); alert->setFontName("Marker Felt"); alert->setFontSize(30); @@ -36,7 +36,7 @@ bool UIWidgetAddNodeTest::init() Sprite* sprite = Sprite::create("cocosgui/ccicon.png"); sprite->setPosition(Point(0, sprite->getBoundingBox().size.height / 4)); -// widget->addRenderer(sprite, 0); + widget->addNode(sprite, 0); return true; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index 33d7852a45..70d3ac2cbd 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -5,151 +5,789 @@ #include "cocostudio/CocoStudio.h" #include "gui/CocosGUI.h" #include "TriggerCode/EventDef.h" +#include "../../testResource.h" using namespace cocos2d; using namespace cocostudio; using namespace gui; -SceneEditorTestLayer::~SceneEditorTestLayer() +Layer *Next(); +Layer *Back(); +Layer *Restart(); + +static int s_nIdx = -1; + +Layer *createTests(int index) { - ArmatureDataManager::destroyInstance(); - SceneReader::destroyInstance(); - ActionManagerEx::destroyInstance(); - auto dispatcher = Director::getInstance()->getEventDispatcher(); - dispatcher->removeEventListener(_touchListener); + Layer *layer = nullptr; + switch(index) + { + case TEST_LOADSCENEEDITORFILE: + layer = new LoadSceneEdtiorFileTest(); + break; + case TEST_SPIRTECOMPONENT: + layer = new SpriteComponentTest(); + break; + case TEST_ARMATURECOMPONENT: + layer = new ArmatureComponentTest(); + break; + case TEST_UICOMPONENT: + layer = new UIComponentTest(); + break; + case TEST_TMXMAPCOMPONENT: + layer = new TmxMapComponentTest(); + break; + case TEST_PARTICLECOMPONENT: + layer = new ParticleComponentTest(); + break; + case TEST_EFEECTCOMPONENT: + layer = new EffectComponentTest(); + break; + case TEST_BACKGROUNDCOMPONENT: + layer = new BackgroundComponentTest(); + break; + case TEST_ATTRIBUTECOMPONENT: + layer = new AttributeComponentTest(); + break; + case TEST_TRIGGER: + layer = new TriggerTest(); + break; + default: + break; + } + return layer; } -SceneEditorTestLayer::SceneEditorTestLayer() +Layer *Next() { - _curNode = nullptr; - _touchListener = nullptr; + ++s_nIdx; + s_nIdx = s_nIdx % TEST_SCENEEDITOR_COUNT; + + Layer *layer = createTests(s_nIdx); + layer->autorelease(); + + return layer; } -Scene* SceneEditorTestLayer::scene() +Layer *Back() { - Scene * scene = nullptr; - do - { - // 'scene' is an autorelease object - scene = Scene::create(); - CC_BREAK_IF(! scene); + --s_nIdx; + if( s_nIdx < 0 ) + s_nIdx += TEST_SCENEEDITOR_COUNT; - // 'layer' is an autorelease object - SceneEditorTestLayer *layer = SceneEditorTestLayer::create(); - CC_BREAK_IF(! layer); + Layer *layer = createTests(s_nIdx); + layer->autorelease(); - // add layer as a child to scene - scene->addChild(layer); - } while (0); - - // return the scene - return scene; + return layer; } -// on "init" you need to initialize your instance -bool SceneEditorTestLayer::init() +Layer *Restart() { - bool bRet = false; + Layer *layer = createTests(s_nIdx); + layer->autorelease(); + + return layer; +} + +SceneEditorTestScene::SceneEditorTestScene(bool bPortrait) +{ + TestScene::init(); +} + +void SceneEditorTestScene::runThisTest() +{ + s_nIdx = -1; + addChild(Next()); + CCDirector::getInstance()->replaceScene(this); +} + +void SceneEditorTestScene::MainMenuCallback(Object *pSender) +{ + removeAllChildren(); +} + + +void SceneEditorTestLayer::onEnter() +{ + CCLayer::onEnter(); + + // add title and subtitle + std::string str = title(); + const char *pTitle = str.c_str(); + LabelTTF *label = LabelTTF::create(pTitle, "Arial", 18); + label->setColor(Color3B(255, 255, 255)); + addChild(label, 1, 10000); + label->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 30) ); + + std::string strSubtitle = subtitle(); + if( ! strSubtitle.empty() ) + { + LabelTTF *l = LabelTTF::create(strSubtitle.c_str(), "Arial", 18); + l->setColor(Color3B(0, 0, 0)); + addChild(l, 1, 10001); + l->setPosition(Point(VisibleRect::center().x, VisibleRect::top().y - 60) ); + } + + // add menu + backItem = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(SceneEditorTestLayer::backCallback, this) ); + restartItem = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(SceneEditorTestLayer::restartCallback, this) ); + nextItem = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(SceneEditorTestLayer::nextCallback, this) ); + + + Menu *menu = Menu::create(backItem, restartItem, nextItem, nullptr); + + float fScale = 0.5f; + + menu->setPosition(Point(0, 0)); + backItem->setPosition(Point(VisibleRect::center().x - restartItem->getContentSize().width * 2 * fScale, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); + backItem->setScale(fScale); + + restartItem->setPosition(Point(VisibleRect::center().x, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); + restartItem->setScale(fScale); + + nextItem->setPosition(Point(VisibleRect::center().x + restartItem->getContentSize().width * 2 * fScale, VisibleRect::bottom().y + restartItem->getContentSize().height / 2)); + nextItem->setScale(fScale); + + addChild(menu, 100); + + setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); +} + +void SceneEditorTestLayer::onExit() +{ + removeAllChildren(); + backItem = restartItem = nextItem = nullptr; + Layer::onExit(); +} + +std::string SceneEditorTestLayer::title() +{ + return "SceneReader Test LoadSceneEditorFile"; +} + +std::string SceneEditorTestLayer::subtitle() +{ + return ""; +} + +void SceneEditorTestLayer::restartCallback(Object *pSender) +{ + Scene *s = new SceneEditorTestScene(); + s->addChild(Restart()); + Director::getInstance()->replaceScene(s); + s->release(); +} + +void SceneEditorTestLayer::nextCallback(Object *pSender) +{ + Scene *s = new SceneEditorTestScene(); + s->addChild(Next()); + Director::getInstance()->replaceScene(s); + s->release(); +} + +void SceneEditorTestLayer::backCallback(Object *pSender) +{ + Scene *s = new SceneEditorTestScene(); + s->addChild(Back()); + Director::getInstance()->replaceScene(s); + s->release(); +} + +void SceneEditorTestLayer::draw() +{ + Layer::draw(); +} + + +LoadSceneEdtiorFileTest::LoadSceneEdtiorFileTest() +{ + +} + +LoadSceneEdtiorFileTest::~LoadSceneEdtiorFileTest() +{ + +} + +std::string LoadSceneEdtiorFileTest::title() +{ + return "loadSceneEdtiorFile Test"; +} + +void LoadSceneEdtiorFileTest::onEnter() +{ + SceneEditorTestLayer::onEnter(); do { Node *root = createGameScene(); CC_BREAK_IF(!root); this->addChild(root, 0, 1); - sendEvent(TRIGGEREVENT_INITSCENE); - this->schedule(schedule_selector(SceneEditorTestLayer::gameLogic)); - auto dispatcher = Director::getInstance()->getEventDispatcher(); - auto listener = EventListenerTouchOneByOne::create(); - listener->setSwallowTouches(true); - listener->onTouchBegan = CC_CALLBACK_2(SceneEditorTestLayer::onTouchBegan, this); - listener->onTouchMoved = CC_CALLBACK_2(SceneEditorTestLayer::onTouchMoved, this); - listener->onTouchEnded = CC_CALLBACK_2(SceneEditorTestLayer::onTouchEnded, this); - listener->onTouchCancelled = CC_CALLBACK_2(SceneEditorTestLayer::onTouchCancelled, this); - dispatcher->addEventListenerWithFixedPriority(listener, 1); - _touchListener = listener; + } while (0); +} + +void LoadSceneEdtiorFileTest::onExit() +{ + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); + SceneEditorTestLayer::onExit(); +} + + +cocos2d::Node* LoadSceneEdtiorFileTest::createGameScene() +{ + Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/LoadSceneEdtiorFileTest/FishJoy2.json"); + if (node == nullptr) + { + return nullptr; + } + return node; +} + +SpriteComponentTest::SpriteComponentTest() +{ + +} + +SpriteComponentTest::~SpriteComponentTest() +{ + +} + +std::string SpriteComponentTest::title() +{ + return "Sprite Component Test"; +} + +void SpriteComponentTest::onEnter() +{ + SceneEditorTestLayer::onEnter(); + do + { + Node *root = createGameScene(); + CC_BREAK_IF(!root); + this->addChild(root, 0, 1); + } while (0); +} + +void SpriteComponentTest::onExit() +{ + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); + SceneEditorTestLayer::onExit(); +} + +cocos2d::Node* SpriteComponentTest::createGameScene() +{ + Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/SpriteComponentTest/SpriteComponentTest.json"); + if (node == nullptr) + { + return nullptr; + } + + ActionInterval* action1 = CCBlink::create(2, 10); + ActionInterval* action2 = CCBlink::create(2, 5); + + ComRender *pSister1 = static_cast(node->getChildByTag(10003)->getComponent("CCSprite")); + pSister1->getNode()->runAction(action1); + + ComRender *pSister2 = static_cast(node->getChildByTag(10004)->getComponent("CCSprite")); + pSister2->getNode()->runAction(action2); + + return node; +} + +ArmatureComponentTest::ArmatureComponentTest() +{ + +} + +ArmatureComponentTest::~ArmatureComponentTest() +{ + +} + +std::string ArmatureComponentTest::title() +{ + return "Armature Component Test"; +} + +void ArmatureComponentTest::onEnter() +{ + SceneEditorTestLayer::onEnter(); + do + { + Node *root = createGameScene(); + CC_BREAK_IF(!root); + this->addChild(root, 0, 1); + } while (0); +} + +void ArmatureComponentTest::onExit() +{ + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); + SceneEditorTestLayer::onExit(); +} + +cocos2d::Node* ArmatureComponentTest::createGameScene() +{ + Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/ArmatureComponentTest/ArmatureComponentTest.json"); + if (node == nullptr) + { + return nullptr; + } + ComRender *pBlowFish = static_cast(node->getChildByTag(10007)->getComponent("CCArmature")); + pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Point(-1000.0f, 0))); + + ComRender *pButterflyfish = static_cast(node->getChildByTag(10008)->getComponent("CCArmature")); + pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, Point(-1000.0f, 0))); + + return node; +} + +UIComponentTest::UIComponentTest() +: _node(nullptr) +{ + +} + +UIComponentTest::~UIComponentTest() +{ +} + +std::string UIComponentTest::title() +{ + return "UI Component Test"; +} + +void UIComponentTest::onEnter() +{ + SceneEditorTestLayer::onEnter(); + do + { + Node *root = createGameScene(); + CC_BREAK_IF(!root); + this->addChild(root, 0, 1); + } while (0); +} + +void UIComponentTest::onExit() +{ + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); + SceneEditorTestLayer::onExit(); +} + +cocos2d::Node* UIComponentTest::createGameScene() +{ + Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/UIComponentTest/UIComponentTest.json"); + if (node == nullptr) + { + return nullptr; + } + _node = node; + + ComRender *render = static_cast(_node->getChildByTag(10025)->getComponent("GUIComponent")); + Widget* widget = static_cast(render->getNode()); + Button* button = static_cast(widget->getChildByName("Button_156")); + button->addTouchEventListener(this, toucheventselector(UIComponentTest::touchEvent)); + + return node; +} + +void UIComponentTest::touchEvent(Object *pSender, TouchEventType type) +{ + switch (type) + { + case TOUCH_EVENT_BEGAN: + { + ComRender *pBlowFish = static_cast(_node->getChildByTag(10010)->getComponent("CCArmature")); + pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Point(-1000.0f, 0))); + + ComRender *pButterflyfish = static_cast(_node->getChildByTag(10011)->getComponent("CCArmature")); + pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, Point(-1000.0f, 0))); + } + break; + default: + break; + } +} + +TmxMapComponentTest::TmxMapComponentTest() +{ + +} + +TmxMapComponentTest::~TmxMapComponentTest() +{ + +} + +std::string TmxMapComponentTest::title() +{ + return "TmxMap Component Test"; +} + +void TmxMapComponentTest::onEnter() +{ + SceneEditorTestLayer::onEnter(); + do + { + Node *root = createGameScene(); + CC_BREAK_IF(!root); + this->addChild(root, 0, 1); + } while (0); +} + +void TmxMapComponentTest::onExit() +{ + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); + SceneEditorTestLayer::onExit(); +} + +cocos2d::Node* TmxMapComponentTest::createGameScene() +{ + Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/TmxMapComponentTest/TmxMapComponentTest.json"); + if (node == nullptr) + { + return nullptr; + } + ComRender *tmxMap = static_cast(node->getChildByTag(10015)->getComponent("CCTMXTiledMap")); + ActionInterval *actionTo = SkewTo::create(2, 0.f, 2.f); + ActionInterval *rotateTo = RotateTo::create(2, 61.0f); + ActionInterval *actionScaleTo = ScaleTo::create(2, -0.44f, 0.47f); + + ActionInterval *actionScaleToBack = ScaleTo::create(2, 1.0f, 1.0f); + ActionInterval *rotateToBack = RotateTo::create(2, 0); + ActionInterval *actionToBack = SkewTo::create(2, 0, 0); + + tmxMap->getNode()->runAction(Sequence::create(actionTo, actionToBack, nullptr)); + tmxMap->getNode()->runAction(Sequence::create(rotateTo, rotateToBack, nullptr)); + tmxMap->getNode()->runAction(Sequence::create(actionScaleTo, actionScaleToBack, nullptr)); + return node; +} + +ParticleComponentTest::ParticleComponentTest() +{ + +} + +ParticleComponentTest::~ParticleComponentTest() +{ +} + +std::string ParticleComponentTest::title() +{ + return "Particle Component Test"; +} + +void ParticleComponentTest::onEnter() +{ + SceneEditorTestLayer::onEnter(); + do + { + Node *root = createGameScene(); + CC_BREAK_IF(!root); + this->addChild(root, 0, 1); + } while (0); +} + +void ParticleComponentTest::onExit() +{ + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); + SceneEditorTestLayer::onExit(); +} + +cocos2d::Node* ParticleComponentTest::createGameScene() +{ + Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/ParticleComponentTest/ParticleComponentTest.json"); + if (node == nullptr) + { + return nullptr; + } + + ComRender* Particle = static_cast(node->getChildByTag(10020)->getComponent("CCParticleSystemQuad")); + ActionInterval* jump = JumpBy::create(5, Point(-500,0), 50, 4); + FiniteTimeAction* action = Sequence::create( jump, jump->reverse(), nullptr); + Particle->getNode()->runAction(action); + return node; +} + + +EffectComponentTest::EffectComponentTest() +: _node(nullptr) +{ + +} + +EffectComponentTest::~EffectComponentTest() +{ +} + +std::string EffectComponentTest::title() +{ + return "Effect Component Test"; +} + +void EffectComponentTest::onEnter() +{ + SceneEditorTestLayer::onEnter(); + do + { + Node *root = createGameScene(); + CC_BREAK_IF(!root); + this->addChild(root, 0, 1); + } while (0); +} + +void EffectComponentTest::onExit() +{ + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); + SceneEditorTestLayer::onExit(); +} + +cocos2d::Node* EffectComponentTest::createGameScene() +{ + Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/EffectComponentTest/EffectComponentTest.json"); + if (node == nullptr) + { + return nullptr; + } + _node = node; + ComRender *render = static_cast(_node->getChildByTag(10015)->getComponent("CCArmature")); + Armature *pAr = static_cast(render->getNode()); + pAr->getAnimation()->setMovementEventCallFunc(CC_CALLBACK_0(EffectComponentTest::animationEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + return node; +} + +void EffectComponentTest::animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID) +{ + std::string id = movementID; + + if (movementType == LOOP_COMPLETE) + { + if (id.compare("Fire") == 0) + { + ComAudio *pAudio = static_cast(_node->getChildByTag(10015)->getComponent("CCComAudio")); + pAudio->playEffect(); + } + } +} + +BackgroundComponentTest::BackgroundComponentTest() +{ + +} + +BackgroundComponentTest::~BackgroundComponentTest() +{ +} + +std::string BackgroundComponentTest::title() +{ + return "Background Component Test"; +} + +void BackgroundComponentTest::onEnter() +{ + SceneEditorTestLayer::onEnter(); + do + { + Node *root = createGameScene(); + CC_BREAK_IF(!root); + this->addChild(root, 0, 1); + } while (0); +} + +void BackgroundComponentTest::onExit() +{ + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); + SceneEditorTestLayer::onExit(); +} + +cocos2d::Node* BackgroundComponentTest::createGameScene() +{ + Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/BackgroundComponentTest/BackgroundComponentTest.json"); + if (node == nullptr) + { + return nullptr; + } + + ComAudio *Audio = static_cast(node->getComponent("CCBackgroundAudio")); + Audio->playBackgroundMusic(); + return node; +} + + +AttributeComponentTest::AttributeComponentTest() +: _node(nullptr) +{ + +} + +AttributeComponentTest::~AttributeComponentTest() +{ +} + +std::string AttributeComponentTest::title() +{ + return "Attribute Component Test"; +} + +void AttributeComponentTest::onEnter() +{ + SceneEditorTestLayer::onEnter(); + do + { + Node *root = createGameScene(); + CC_BREAK_IF(!root); + initData(); + this->addChild(root, 0, 1); + } while (0); +} + +void AttributeComponentTest::onExit() +{ + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); + SceneEditorTestLayer::onExit(); +} + +bool AttributeComponentTest::initData() +{ + bool bRet = false; + rapidjson::Document doc; + do { + CC_BREAK_IF(_node == nullptr); + ComAttribute *attribute = static_cast(_node->getChildByTag(10015)->getComponent("CCComAttribute")); + CC_BREAK_IF(attribute == nullptr); + log("Name: %s, HP: %f, MP: %f", attribute->getString("name").c_str(), attribute->getFloat("maxHP"), attribute->getFloat("maxMP")); bRet = true; } while (0); - return bRet; } -void SceneEditorTestLayer::onEnter() +cocos2d::Node* AttributeComponentTest::createGameScene() { - Layer::onEnter(); - sendEvent(TRIGGEREVENT_ENTERSCENE); + Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/AttributeComponentTest/AttributeComponentTest.json"); + if (node == nullptr) + { + return nullptr; + } + _node = node; + return node; } -void SceneEditorTestLayer::onExit() +TriggerTest::TriggerTest() +: _node(nullptr) +, _touchListener(nullptr) +{ + +} + +TriggerTest::~TriggerTest() +{ +} + +std::string TriggerTest::title() +{ + return "Trigger Test"; +} + + +// on "init" you need to initialize your instance +void TriggerTest::onEnter() +{ + SceneEditorTestLayer::onEnter(); + Node *root = createGameScene(); + this->addChild(root, 0, 1); + this->schedule(schedule_selector(TriggerTest::gameLogic)); + auto dispatcher = Director::getInstance()->getEventDispatcher(); + auto listener = EventListenerTouchOneByOne::create(); + listener->setSwallowTouches(true); + listener->onTouchBegan = CC_CALLBACK_2(SceneEditorTestLayer::onTouchBegan, this); + listener->onTouchMoved = CC_CALLBACK_2(SceneEditorTestLayer::onTouchMoved, this); + listener->onTouchEnded = CC_CALLBACK_2(SceneEditorTestLayer::onTouchEnded, this); + listener->onTouchCancelled = CC_CALLBACK_2(SceneEditorTestLayer::onTouchCancelled, this); + dispatcher->addEventListenerWithFixedPriority(listener, 1); + _touchListener = listener; + sendEvent(TRIGGEREVENT_ENTERSCENE); +} + + +void TriggerTest::onExit() { - Layer::onExit(); sendEvent(TRIGGEREVENT_LEAVESCENE); + this->unschedule(schedule_selector(TriggerTest::gameLogic)); + auto dispatcher = Director::getInstance()->getEventDispatcher(); + dispatcher->removeEventListener(_touchListener); + Device::setAccelerometerEnabled(false); + ArmatureDataManager::destroyInstance(); + SceneReader::destroyInstance(); + ActionManagerEx::destroyInstance(); + GUIReader::destroyInstance(); + SceneEditorTestLayer::onExit(); } -bool SceneEditorTestLayer::onTouchBegan(Touch *touch, Event *unused_event) +bool TriggerTest::onTouchBegan(Touch *touch, Event *unused_event) { sendEvent(TRIGGEREVENT_TOUCHBEGAN); return true; } -void SceneEditorTestLayer::onTouchMoved(Touch *touch, Event *unused_event) +void TriggerTest::onTouchMoved(Touch *touch, Event *unused_event) { sendEvent(TRIGGEREVENT_TOUCHMOVED); } -void SceneEditorTestLayer::onTouchEnded(Touch *touch, Event *unused_event) +void TriggerTest::onTouchEnded(Touch *touch, Event *unused_event) { sendEvent(TRIGGEREVENT_TOUCHENDED); } -void SceneEditorTestLayer::onTouchCancelled(Touch *touch, Event *unused_event) +void TriggerTest::onTouchCancelled(Touch *touch, Event *unused_event) { sendEvent(TRIGGEREVENT_TOUCHCANCELLED); } -void SceneEditorTestLayer::gameLogic(float dt) +void TriggerTest::gameLogic(float dt) { sendEvent(TRIGGEREVENT_UPDATESCENE); } -static ActionObject* actionObject = nullptr; -cocos2d::Node* SceneEditorTestLayer::createGameScene() +cocos2d::Node* TriggerTest::createGameScene() { - Node *pNode = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/FishJoy2.json"); - if (pNode == nullptr) + Node *node = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/TriggerTest/TriggerTest.json"); + if (node == nullptr) { return nullptr; } - _curNode = pNode; + _node = node; - MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(SceneEditorTestLayer::toExtensionsMainLayer, this)); - itemBack->setColor(Color3B(255, 255, 255)); - itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); - Menu *menuBack = Menu::create(itemBack, nullptr); - menuBack->setPosition(Point(0.0f, 0.0f)); - menuBack->setZOrder(4); - - pNode->addChild(menuBack); - - return pNode; -} - -void SceneEditorTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) -{ - if (actionObject) - { - actionObject->stop(); - } - ComAudio *pBackMusic = (ComAudio*)(_curNode->getComponent("CCBackgroundAudio")); - pBackMusic->stopBackgroundMusic(); - ExtensionsTestScene *pScene = new ExtensionsTestScene(); - pScene->runThisTest(); - pScene->release(); -} - - -void runSceneEditorTestLayer() -{ - Scene *pScene = SceneEditorTestLayer::scene(); - Director::getInstance()->replaceScene(pScene); + return node; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h index 74a2f62f28..68f08bac2f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.h @@ -3,24 +3,184 @@ #include "cocos2d.h" #include "extensions/cocos-ext.h" +#include "cocostudio/CocoStudio.h" -void runSceneEditorTestLayer(); +class SceneEditorTestScene : public TestScene +{ +public: + SceneEditorTestScene(bool bPortrait = false); + + virtual void runThisTest(); + + // The CallBack for back to the main menu scene + virtual void MainMenuCallback(cocos2d::Object* pSender); +}; + +enum { + TEST_LOADSCENEEDITORFILE = 0, + TEST_SPIRTECOMPONENT, + TEST_ARMATURECOMPONENT, + TEST_UICOMPONENT, + TEST_TMXMAPCOMPONENT, + TEST_PARTICLECOMPONENT, + TEST_EFEECTCOMPONENT, + TEST_BACKGROUNDCOMPONENT, + TEST_ATTRIBUTECOMPONENT, + TEST_TRIGGER, + TEST_SCENEEDITOR_COUNT +}; class SceneEditorTestLayer : public cocos2d::Layer { public: - SceneEditorTestLayer(); - ~SceneEditorTestLayer(); - - // Here's a difference. Method 'init' in cocos2d-x returns bool, - // instead of returning 'id' in cocos2d-iphone - virtual bool init(); - - // callback of Scene Enter virtual void onEnter(); - - // callback of Scene Exit virtual void onExit(); + + virtual std::string title(); + virtual std::string subtitle(); + + virtual void restartCallback(cocos2d::Object* pSender); + virtual void nextCallback(cocos2d::Object* pSender); + virtual void backCallback(cocos2d::Object* pSender); + + virtual void draw(); + +protected: + MenuItemImage *restartItem; + MenuItemImage *nextItem; + MenuItemImage *backItem; +}; + +class LoadSceneEdtiorFileTest : public SceneEditorTestLayer +{ +public: + LoadSceneEdtiorFileTest(); + ~LoadSceneEdtiorFileTest(); + + virtual std::string title(); + virtual void onEnter(); + virtual void onExit(); + cocos2d::Node* createGameScene(); +}; + + +class SpriteComponentTest : public SceneEditorTestLayer +{ +public: + SpriteComponentTest(); + ~SpriteComponentTest(); + + virtual std::string title(); + virtual void onEnter(); + virtual void onExit(); + cocos2d::Node* createGameScene(); + +}; + +class ArmatureComponentTest : public SceneEditorTestLayer +{ +public: + ArmatureComponentTest(); + ~ArmatureComponentTest(); + + virtual std::string title(); + virtual void onEnter(); + virtual void onExit(); + cocos2d::Node* createGameScene(); + +}; + +class UIComponentTest : public SceneEditorTestLayer +{ +public: + UIComponentTest(); + ~UIComponentTest(); + + virtual std::string title(); + virtual void onEnter(); + virtual void onExit(); + cocos2d::Node* createGameScene(); + void touchEvent(cocos2d::Object *pSender, cocos2d::gui::TouchEventType type); +private: + cocos2d::Node* _node; +}; + +class TmxMapComponentTest : public SceneEditorTestLayer +{ +public: + TmxMapComponentTest(); + ~TmxMapComponentTest(); + + virtual std::string title(); + virtual void onEnter(); + virtual void onExit(); + cocos2d::Node* createGameScene(); + +}; + +class ParticleComponentTest : public SceneEditorTestLayer +{ +public: + ParticleComponentTest(); + ~ParticleComponentTest(); + + virtual std::string title(); + virtual void onEnter(); + virtual void onExit(); + cocos2d::Node* createGameScene(); +}; + +class EffectComponentTest : public SceneEditorTestLayer +{ +public: + EffectComponentTest(); + ~EffectComponentTest(); + + virtual std::string title(); + virtual void onEnter(); + virtual void onExit(); + cocos2d::Node* createGameScene(); + void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID); +private: + cocos2d::Node* _node; +}; + +class BackgroundComponentTest : public SceneEditorTestLayer +{ +public: + BackgroundComponentTest(); + ~BackgroundComponentTest(); + + virtual std::string title(); + virtual void onEnter(); + virtual void onExit(); + cocos2d::Node* createGameScene(); +}; + +class AttributeComponentTest : public SceneEditorTestLayer +{ +public: + AttributeComponentTest(); + ~AttributeComponentTest(); + + virtual std::string title(); + virtual void onEnter(); + virtual void onExit(); + bool initData(); + cocos2d::Node* createGameScene(); +private: + cocos2d::Node* _node; +}; + +class TriggerTest : public SceneEditorTestLayer +{ +public: + TriggerTest(); + ~TriggerTest(); + + virtual std::string title(); + virtual void onEnter(); + virtual void onExit(); // default implements are used to call script callback if exist virtual bool onTouchBegan(Touch *touch, Event *unused_event); @@ -31,20 +191,11 @@ public: // update of game void gameLogic(float dt); - // there's no 'id' in cpp, so we recommand to return the exactly class pointer - static cocos2d::Scene* scene(); - - // implement the "static node()" method manually - CREATE_FUNC(SceneEditorTestLayer); - - // init scene + // create scene cocos2d::Node* createGameScene(); - - //back to Extensions Main Layer - void toExtensionsMainLayer(cocos2d::Object *sender); - + private: - cocos2d::Node *_curNode; + cocos2d::Node *_node; cocos2d::EventListener* _touchListener; }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp index 67de017b49..4449d2cd9d 100755 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp @@ -7,7 +7,7 @@ using namespace cocostudio; IMPLEMENT_CLASS_INFO(PlayMusic) PlayMusic::PlayMusic(void) -:_nTag(-1) +:_tag(-1) { } @@ -24,15 +24,15 @@ void PlayMusic::done() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - CC_BREAK_IF(pNode == nullptr); - ComAudio *audio = (ComAudio*)(pNode->getComponent(_comName.c_str())); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + CC_BREAK_IF(node == nullptr); + ComAudio *audio = (ComAudio*)(node->getComponent(_comName.c_str())); CC_BREAK_IF(audio == nullptr); - if (_nType == 0) + if (_type == 0) { audio->playBackgroundMusic(); } - else if (_nType == 1) + else if (_type == 1) { audio->playEffect(); } @@ -49,7 +49,7 @@ void PlayMusic::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "componentName") @@ -59,7 +59,7 @@ void PlayMusic::serialize(const rapidjson::Value &val) } else if (key == "type") { - _nType = DICTOOL->getIntValue_json(subDict, "value"); + _type = DICTOOL->getIntValue_json(subDict, "value"); continue; } } @@ -71,8 +71,8 @@ void PlayMusic::removeAll() IMPLEMENT_CLASS_INFO(TMoveTo) TMoveTo::TMoveTo(void) -:_nTag(-1) -,_fDuration(0.0f) +:_tag(-1) +,_duration(0.0f) { } @@ -89,11 +89,11 @@ void TMoveTo::done() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - CC_BREAK_IF(pNode == nullptr); - ActionInterval* actionTo = MoveTo::create(_fDuration, _pos); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + CC_BREAK_IF(node == nullptr); + ActionInterval* actionTo = MoveTo::create(_duration, _pos); CC_BREAK_IF(actionTo == nullptr); - pNode->runAction(actionTo); + node->runAction(actionTo); } while (0); } @@ -106,12 +106,12 @@ void TMoveTo::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "Duration") { - _fDuration = DICTOOL->getFloatValue_json(subDict, "value"); + _duration = DICTOOL->getFloatValue_json(subDict, "value"); continue; } else if (key == "x") @@ -129,13 +129,15 @@ void TMoveTo::serialize(const rapidjson::Value &val) void TMoveTo::removeAll() { + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + node->getActionManager()->removeAllActions(); } IMPLEMENT_CLASS_INFO(TMoveBy) TMoveBy::TMoveBy(void) -:_nTag(-1) -,_fDuration(0.0f) -,_bReverse(false) +:_tag(-1) +,_duration(0.0f) +,_reverse(false) { } @@ -152,18 +154,18 @@ void TMoveBy::done() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - CC_BREAK_IF(pNode == nullptr); - ActionInterval* actionBy = MoveBy::create(_fDuration, _pos); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + CC_BREAK_IF(node == nullptr); + ActionInterval* actionBy = MoveBy::create(_duration, _pos); CC_BREAK_IF(actionBy == nullptr); - if (_bReverse == true) + if (_reverse == true) { ActionInterval* actionByBack = actionBy->reverse(); - pNode->runAction( CCSequence::create(actionBy, actionByBack, nullptr)); + node->runAction( CCSequence::create(actionBy, actionByBack, nullptr)); } else { - pNode->runAction(actionBy); + node->runAction(actionBy); } } while (0); } @@ -177,12 +179,12 @@ void TMoveBy::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "Duration") { - _fDuration = DICTOOL->getFloatValue_json(subDict, "value"); + _duration = DICTOOL->getFloatValue_json(subDict, "value"); continue; } else if (key == "x") @@ -197,7 +199,7 @@ void TMoveBy::serialize(const rapidjson::Value &val) } else if (key == "IsReverse") { - _bReverse = (bool)(DICTOOL->getIntValue_json(subDict, "value")); + _reverse = (bool)(DICTOOL->getIntValue_json(subDict, "value")); continue; } } @@ -205,16 +207,17 @@ void TMoveBy::serialize(const rapidjson::Value &val) void TMoveBy::removeAll() { - CCLOG("TMoveBy::removeAll"); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + node->getActionManager()->removeAllActions(); } IMPLEMENT_CLASS_INFO(TRotateTo) TRotateTo::TRotateTo(void) -: _nTag(-1) -, _fDuration(0.0f) -, _fDeltaAngle(0.0f) +: _tag(-1) +, _duration(0.0f) +, _deltaAngle(0.0f) { } @@ -231,11 +234,11 @@ void TRotateTo::done() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - CC_BREAK_IF(pNode == nullptr); - ActionInterval* actionTo = RotateTo::create(_fDuration, _fDeltaAngle); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + CC_BREAK_IF(node == nullptr); + ActionInterval* actionTo = RotateTo::create(_duration, _deltaAngle); CC_BREAK_IF(actionTo == nullptr); - pNode->runAction(actionTo); + node->runAction(actionTo); } while (0); } @@ -248,17 +251,17 @@ void TRotateTo::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "Duration") { - _fDuration = DICTOOL->getFloatValue_json(subDict, "value"); + _duration = DICTOOL->getFloatValue_json(subDict, "value"); continue; } else if (key == "DeltaAngle") { - _fDeltaAngle = DICTOOL->getFloatValue_json(subDict, "value"); + _deltaAngle = DICTOOL->getFloatValue_json(subDict, "value"); continue; } } @@ -266,17 +269,18 @@ void TRotateTo::serialize(const rapidjson::Value &val) void TRotateTo::removeAll() { - CCLOG("TRotateTo::removeAll"); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + node->getActionManager()->removeAllActions(); } IMPLEMENT_CLASS_INFO(TRotateBy) TRotateBy::TRotateBy(void) -: _nTag(-1) -, _fDuration(0.0f) -, _fDeltaAngle(0.0f) -, _bReverse(false) +: _tag(-1) +, _duration(0.0f) +, _deltaAngle(0.0f) +, _reverse(false) { } @@ -293,18 +297,18 @@ void TRotateBy::done() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - CC_BREAK_IF(pNode == nullptr); - ActionInterval* actionBy = RotateBy::create(_fDuration, _fDeltaAngle); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + CC_BREAK_IF(node == nullptr); + ActionInterval* actionBy = RotateBy::create(_duration, _deltaAngle); CC_BREAK_IF(actionBy == nullptr); - if (_bReverse == true) + if (_reverse == true) { ActionInterval* actionByBack = actionBy->reverse(); - pNode->runAction( Sequence::create(actionBy, actionByBack, nullptr)); + node->runAction( Sequence::create(actionBy, actionByBack, nullptr)); } else { - pNode->runAction(actionBy); + node->runAction(actionBy); } } while (0); } @@ -318,22 +322,22 @@ void TRotateBy::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "Duration") { - _fDuration = DICTOOL->getFloatValue_json(subDict, "value"); + _duration = DICTOOL->getFloatValue_json(subDict, "value"); continue; } else if (key == "DeltaAngle") { - _fDeltaAngle = DICTOOL->getFloatValue_json(subDict, "value"); + _deltaAngle = DICTOOL->getFloatValue_json(subDict, "value"); continue; } else if (key == "IsReverse") { - _bReverse = (int)(DICTOOL->getIntValue_json(subDict, "value")); + _reverse = (int)(DICTOOL->getIntValue_json(subDict, "value")); continue; } } @@ -341,15 +345,16 @@ void TRotateBy::serialize(const rapidjson::Value &val) void TRotateBy::removeAll() { - CCLOG("TRotateBy::removeAll"); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + node->getActionManager()->removeAllActions(); } IMPLEMENT_CLASS_INFO(TScaleTo) TScaleTo::TScaleTo(void) -: _nTag(-1) -, _fDuration(0.0f) +: _tag(-1) +, _duration(0.0f) { } @@ -366,11 +371,11 @@ void TScaleTo::done() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - CC_BREAK_IF(pNode == nullptr); - ActionInterval* actionTo = ScaleTo::create(_fDuration, _scale.x, _scale.y); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + CC_BREAK_IF(node == nullptr); + ActionInterval* actionTo = ScaleTo::create(_duration, _scale.x, _scale.y); CC_BREAK_IF(actionTo == nullptr); - pNode->runAction(actionTo); + node->runAction(actionTo); } while (0); } @@ -383,12 +388,12 @@ void TScaleTo::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "Duration") { - _fDuration = DICTOOL->getFloatValue_json(subDict, "value"); + _duration = DICTOOL->getFloatValue_json(subDict, "value"); continue; } else if (key == "ScaleX") @@ -406,16 +411,17 @@ void TScaleTo::serialize(const rapidjson::Value &val) void TScaleTo::removeAll() { - CCLOG("TScaleTo::removeAll"); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + node->getActionManager()->removeAllActions(); } IMPLEMENT_CLASS_INFO(TScaleBy) TScaleBy::TScaleBy(void) -: _nTag(-1) -, _fDuration(0.0f) -, _bReverse(false) +: _tag(-1) +, _duration(0.0f) +, _reverse(false) { } @@ -432,18 +438,18 @@ void TScaleBy::done() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - CC_BREAK_IF(pNode == nullptr); - ActionInterval* actionBy = ScaleBy::create(_fDuration, _scale.x, _scale.y); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + CC_BREAK_IF(node == nullptr); + ActionInterval* actionBy = ScaleBy::create(_duration, _scale.x, _scale.y); CC_BREAK_IF(actionBy == nullptr); - if (_bReverse == true) + if (_reverse == true) { ActionInterval* actionByBack = actionBy->reverse(); - pNode->runAction(Sequence::create(actionBy, actionByBack, nullptr)); + node->runAction(Sequence::create(actionBy, actionByBack, nullptr)); } else { - pNode->runAction(actionBy); + node->runAction(actionBy); } } while (0); } @@ -457,12 +463,12 @@ void TScaleBy::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "Duration") { - _fDuration = DICTOOL->getFloatValue_json(subDict, "value"); + _duration = DICTOOL->getFloatValue_json(subDict, "value"); continue; } else if (key == "ScaleX") @@ -477,7 +483,7 @@ void TScaleBy::serialize(const rapidjson::Value &val) } else if (key == "IsReverse") { - _bReverse = (bool)(DICTOOL->getIntValue_json(subDict, "value")); + _reverse = (bool)(DICTOOL->getIntValue_json(subDict, "value")); continue; } } @@ -485,15 +491,16 @@ void TScaleBy::serialize(const rapidjson::Value &val) void TScaleBy::removeAll() { - CCLOG("TScaleBy::removeAll"); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + node->getActionManager()->removeAllActions(); } IMPLEMENT_CLASS_INFO(TSkewTo) TSkewTo::TSkewTo(void) -: _nTag(-1) -, _fDuration(0.0f) +: _tag(-1) +, _duration(0.0f) { } @@ -510,11 +517,11 @@ void TSkewTo::done() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - CC_BREAK_IF(pNode == nullptr); - ActionInterval* actionTo = SkewTo::create(_fDuration, _skew.x, _skew.y); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + CC_BREAK_IF(node == nullptr); + ActionInterval* actionTo = SkewTo::create(_duration, _skew.x, _skew.y); CC_BREAK_IF(actionTo == nullptr); - pNode->runAction(actionTo); + node->runAction(actionTo); } while (0); } @@ -527,12 +534,12 @@ void TSkewTo::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "Duration") { - _fDuration = DICTOOL->getFloatValue_json(subDict, "value"); + _duration = DICTOOL->getFloatValue_json(subDict, "value"); continue; } else if (key == "SkewX") @@ -550,16 +557,17 @@ void TSkewTo::serialize(const rapidjson::Value &val) void TSkewTo::removeAll() { - CCLOG("TSkewTo::removeAll"); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + node->getActionManager()->removeAllActions(); } IMPLEMENT_CLASS_INFO(TSkewBy) TSkewBy::TSkewBy(void) -: _nTag(-1) -, _fDuration(0.0f) -, _bReverse(false) +: _tag(-1) +, _duration(0.0f) +, _reverse(false) { } @@ -576,18 +584,18 @@ void TSkewBy::done() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - CC_BREAK_IF(pNode == nullptr); - ActionInterval* actionBy = SkewBy::create(_fDuration, _skew.x, _skew.y); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + CC_BREAK_IF(node == nullptr); + ActionInterval* actionBy = SkewBy::create(_duration, _skew.x, _skew.y); CC_BREAK_IF(actionBy == nullptr); - if (_bReverse == true) + if (_reverse == true) { ActionInterval* actionByBack = actionBy->reverse(); - pNode->runAction(Sequence::create(actionBy, actionByBack, nullptr)); + node->runAction(Sequence::create(actionBy, actionByBack, nullptr)); } else { - pNode->runAction(actionBy); + node->runAction(actionBy); } } while (0); } @@ -601,12 +609,12 @@ void TSkewBy::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "Duration") { - _fDuration = DICTOOL->getFloatValue_json(subDict, "value"); + _duration = DICTOOL->getFloatValue_json(subDict, "value"); continue; } else if (key == "SKewX") @@ -621,23 +629,24 @@ void TSkewBy::serialize(const rapidjson::Value &val) } else if (key == "IsReverse") { - _bReverse = (bool)(DICTOOL->getIntValue_json(subDict, "value")); + _reverse = (bool)(DICTOOL->getIntValue_json(subDict, "value")); } } } void TSkewBy::removeAll() { - CCLOG("TSkewBy::removeAll"); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + node->getActionManager()->removeAllActions(); } IMPLEMENT_CLASS_INFO(TriggerState) TriggerState::TriggerState(void) -:_nID(-1) -,_nState(0) { + _id = -1; + _state = 0; } TriggerState::~TriggerState(void) @@ -651,20 +660,20 @@ bool TriggerState::init() void TriggerState::done() { - TriggerObj *obj = TriggerMng::getInstance()->getTriggerObj(_nID); + TriggerObj *obj = TriggerMng::getInstance()->getTriggerObj(_id); if (obj != nullptr) { - if (_nState == 0) + if (_state == 0) { - obj->setEnable(false); + obj->setEnabled(false); } - else if (_nState == 1) + else if (_state == 1) { - obj->setEnable(true); + obj->setEnabled(true); } - else if (_nState == 2) + else if (_state == 2) { - TriggerMng::getInstance()->removeTriggerObj(_nID); + TriggerMng::getInstance()->removeTriggerObj(_id); } } @@ -680,12 +689,12 @@ void TriggerState::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "ID") { - _nID = DICTOOL->getIntValue_json(subDict, "value"); + _id = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "State") { - _nState = DICTOOL->getIntValue_json(subDict, "value"); + _state = DICTOOL->getIntValue_json(subDict, "value"); continue; } } @@ -698,7 +707,7 @@ void TriggerState::removeAll() IMPLEMENT_CLASS_INFO(ArmaturePlayAction) ArmaturePlayAction::ArmaturePlayAction(void) -: _nTag(-1) +: _tag(-1) { } @@ -715,9 +724,9 @@ void ArmaturePlayAction::done() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - CC_BREAK_IF(pNode == nullptr); - ComRender *pRender = (ComRender*)(pNode->getComponent(_ComName.c_str())); + Node *node = SceneReader::getInstance()->getNodeByTag(_tag); + CC_BREAK_IF(node == nullptr); + ComRender *pRender = (ComRender*)(node->getComponent(_ComName.c_str())); CC_BREAK_IF(pRender == nullptr); Armature *pAr = (Armature *)(pRender->getNode()); CC_BREAK_IF(pAr == nullptr); @@ -734,7 +743,7 @@ void ArmaturePlayAction::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "componentName") diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.h index fd6f0b6010..f2a55f17b8 100755 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.h @@ -17,9 +17,9 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; + int _tag; std::string _comName; - int _nType; + int _type; }; class TMoveTo: public cocostudio::BaseTriggerAction @@ -34,8 +34,8 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; - float _fDuration; + int _tag; + float _duration; cocos2d::Point _pos; }; @@ -52,10 +52,10 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; - float _fDuration; + int _tag; + float _duration; cocos2d::Point _pos; - bool _bReverse; + bool _reverse; }; @@ -71,9 +71,9 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; - float _fDuration; - float _fDeltaAngle; + int _tag; + float _duration; + float _deltaAngle; }; @@ -89,10 +89,10 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; - float _fDuration; - float _fDeltaAngle; - bool _bReverse; + int _tag; + float _duration; + float _deltaAngle; + bool _reverse; }; @@ -108,8 +108,8 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; - float _fDuration; + int _tag; + float _duration; cocos2d::Point _scale; }; @@ -126,10 +126,10 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; - float _fDuration; + int _tag; + float _duration; cocos2d::Point _scale; - bool _bReverse; + bool _reverse; }; @@ -146,8 +146,8 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; - float _fDuration; + int _tag; + float _duration; cocos2d::Point _skew; }; @@ -164,10 +164,10 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; - float _fDuration; + int _tag; + float _duration; cocos2d::Point _skew; - bool _bReverse; + bool _reverse; }; @@ -183,8 +183,8 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nID; - int _nState; + int _id; + int _state; }; class ArmaturePlayAction : public cocostudio::BaseTriggerAction @@ -199,7 +199,7 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; + int _tag; std::string _ComName; std::string _aniname; }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp index eb9a57ea73..00b78174f6 100755 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp @@ -8,29 +8,29 @@ using namespace cocostudio; IMPLEMENT_CLASS_INFO(TimeElapsed) TimeElapsed::TimeElapsed(void) -:_fTotalTime(0.0f) -,_fTmpTime(0.0f) -,_pScheduler(nullptr) -,_bSuc(false) +:_totalTime(0.0f) +,_tmpTime(0.0f) +,_scheduler(nullptr) +,_suc(false) { - _pScheduler = Director::getInstance()->getScheduler(); - _pScheduler->retain(); + _scheduler = Director::getInstance()->getScheduler(); + _scheduler->retain(); } TimeElapsed::~TimeElapsed(void) { - CC_SAFE_RELEASE(_pScheduler); + CC_SAFE_RELEASE(_scheduler); } bool TimeElapsed::init() { - _pScheduler->scheduleSelector(schedule_selector(TimeElapsed::update), this, 0.0f , kRepeatForever, 0.0f, false); + _scheduler->scheduleSelector(schedule_selector(TimeElapsed::update), this, 0.0f , kRepeatForever, 0.0f, false); return true; } bool TimeElapsed::detect() { - return _bSuc; + return _suc; } void TimeElapsed::serialize(const rapidjson::Value &val) @@ -42,31 +42,31 @@ void TimeElapsed::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "TotalTime") { - _fTotalTime = DICTOOL->getFloatValue_json(subDict, "value"); + _totalTime = DICTOOL->getFloatValue_json(subDict, "value"); } } } void TimeElapsed::removeAll() { - _pScheduler->unscheduleUpdateForTarget(this); + _scheduler->unscheduleUpdateForTarget(this); } void TimeElapsed::update(float dt) { - _fTmpTime += dt; - if (_fTmpTime > _fTotalTime) + _tmpTime += dt; + if (_tmpTime > _totalTime) { - _fTmpTime = 0.0f; - _bSuc = true; + _tmpTime = 0.0f; + _suc = true; } } IMPLEMENT_CLASS_INFO(ArmatureActionState) ArmatureActionState::ArmatureActionState(void) -: _nTag(-1) -, _nState(-1) -, _bSuc(false) +: _tag(-1) +, _state(-1) +, _suc(false) { } @@ -78,7 +78,7 @@ bool ArmatureActionState::init() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); + Node *pNode = SceneReader::getInstance()->getNodeByTag(_tag); CC_BREAK_IF(pNode == nullptr); ComRender *pRender = (ComRender*)(pNode->getComponent(_comName.c_str())); CC_BREAK_IF(pRender == nullptr); @@ -92,7 +92,7 @@ bool ArmatureActionState::init() bool ArmatureActionState::detect() { - return _bSuc; + return _suc; } void ArmatureActionState::serialize(const rapidjson::Value &val) @@ -104,7 +104,7 @@ void ArmatureActionState::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "componentName") @@ -119,7 +119,7 @@ void ArmatureActionState::serialize(const rapidjson::Value &val) } else if (key == "ActionType") { - _nState = DICTOOL->getIntValue_json(subDict, "value"); + _state = DICTOOL->getIntValue_json(subDict, "value"); continue; } } @@ -129,7 +129,7 @@ void ArmatureActionState::removeAll() { do { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); + Node *pNode = SceneReader::getInstance()->getNodeByTag(_tag); CC_BREAK_IF(pNode == nullptr); ComRender *pRender = (ComRender*)(pNode->getComponent(_comName.c_str())); CC_BREAK_IF(pRender == nullptr); @@ -142,15 +142,15 @@ void ArmatureActionState::removeAll() void ArmatureActionState::animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID) { std::string id = movementID; - if (movementType == _nState && id.compare(_aniname) == 0) + if (movementType == _state && id.compare(_aniname) == 0) { - _bSuc = true; + _suc = true; } } IMPLEMENT_CLASS_INFO(NodeInRect) NodeInRect::NodeInRect(void) -:_nTag(-1) +:_tag(-1) { } @@ -166,7 +166,7 @@ bool NodeInRect::init() bool NodeInRect::detect() { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); + Node *pNode = SceneReader::getInstance()->getNodeByTag(_tag); if (pNode != nullptr && abs(pNode->getPositionX() - _origin.x) <= _size.width && abs(pNode->getPositionY() - _origin.y) <= _size.height) { return true; @@ -183,7 +183,7 @@ void NodeInRect::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "originX") @@ -217,8 +217,8 @@ void NodeInRect::removeAll() IMPLEMENT_CLASS_INFO(NodeVisible) NodeVisible::NodeVisible(void) -: _nTag(-1) -, _bVisible(false) +: _tag(-1) +, _visible(false) { } @@ -233,8 +233,8 @@ bool NodeVisible::init() bool NodeVisible::detect() { - Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag); - if (pNode != nullptr && pNode->isVisible() == _bVisible) + Node *pNode = SceneReader::getInstance()->getNodeByTag(_tag); + if (pNode != nullptr && pNode->isVisible() == _visible) { return true; } @@ -250,12 +250,12 @@ void NodeVisible::serialize(const rapidjson::Value &val) std::string key = DICTOOL->getStringValue_json(subDict, "key"); if (key == "Tag") { - _nTag = DICTOOL->getIntValue_json(subDict, "value"); + _tag = DICTOOL->getIntValue_json(subDict, "value"); continue; } else if (key == "Visible") { - _bVisible = DICTOOL->getIntValue_json(subDict, "value"); + _visible = DICTOOL->getIntValue_json(subDict, "value"); continue; } } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.h index 13cb07c086..c889cbadd1 100755 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.h @@ -18,10 +18,10 @@ public: virtual void removeAll(); virtual void update(float dt); private: - float _fTotalTime; - float _fTmpTime; - cocos2d::Scheduler *_pScheduler; - bool _bSuc; + float _totalTime; + float _tmpTime; + cocos2d::Scheduler *_scheduler; + bool _suc; }; @@ -38,11 +38,11 @@ public: virtual void removeAll(); void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID); private: - int _nTag; + int _tag; std::string _comName; std::string _aniname; - int _nState; - bool _bSuc; + int _state; + bool _suc; }; @@ -58,7 +58,7 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; + int _tag; cocos2d::Point _origin; cocos2d::Size _size; }; @@ -75,8 +75,8 @@ public: virtual void serialize(const rapidjson::Value &val); virtual void removeAll(); private: - int _nTag; - bool _bVisible; + int _tag; + bool _visible; }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp index 3444655173..393f64ff47 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -81,7 +81,10 @@ static struct { }, { "CocoStudioComponentsTest", [](Object *sender) { runComponentsTestLayerTest(); } }, - { "CocoStudioSceneTest", [](Object *sender) { runSceneEditorTestLayer(); } + { "CocoStudioSceneTest", [](Object *sender) { SceneEditorTestScene *scene = new SceneEditorTestScene(); + scene->runThisTest(); + scene->release(); + } }, { "CocoStudioGUITest", [](Object *sender) { diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp index d085c2ce91..22658d5fb0 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp @@ -4,7 +4,7 @@ USING_NS_CC; USING_NS_CC_EXT; -using namespace network; +using namespace cocos2d::network; HttpClientTest::HttpClientTest() : _labelStatusCode(NULL) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.h index 9f7d1d3fa3..774793e660 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/HttpClientTest.h @@ -20,7 +20,7 @@ public: void onMenuDeleteTestClicked(cocos2d::Object *sender); //Http Response Callback - void onHttpRequestCompleted(network::HttpClient *sender, network::HttpResponse *response); + void onHttpRequestCompleted(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response); private: cocos2d::LabelTTF* _labelStatusCode; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp index 58e9650a12..3f40ff4b5d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp @@ -12,7 +12,7 @@ USING_NS_CC; USING_NS_CC_EXT; -using namespace network; +using namespace cocos2d::network; SocketIOTestLayer::SocketIOTestLayer(void) : _sioClient(NULL) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.h index 56695bb6a4..ee4f4540d5 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.h @@ -14,16 +14,16 @@ class SocketIOTestLayer : public cocos2d::Layer - , public network::SocketIO::SIODelegate + , public cocos2d::network::SocketIO::SIODelegate { public: SocketIOTestLayer(void); virtual ~SocketIOTestLayer(void); - virtual void onConnect(network::SIOClient* client); - virtual void onMessage(network::SIOClient* client, const std::string& data); - virtual void onClose(network::SIOClient* client); - virtual void onError(network::SIOClient* client, const std::string& data); + virtual void onConnect(cocos2d::network::SIOClient* client); + virtual void onMessage(cocos2d::network::SIOClient* client, const std::string& data); + virtual void onClose(cocos2d::network::SIOClient* client); + virtual void onError(cocos2d::network::SIOClient* client, const std::string& data); void toExtensionsMainLayer(cocos2d::Object *sender); @@ -38,10 +38,10 @@ public: void onMenuTestEndpointDisconnectClicked(cocos2d::Object *sender); - void testevent(network::SIOClient *client, const std::string& data); - void echotest(network::SIOClient *client, const std::string& data); + void testevent(cocos2d::network::SIOClient *client, const std::string& data); + void echotest(cocos2d::network::SIOClient *client, const std::string& data); - network::SIOClient *_sioClient, *_sioEndpoint; + cocos2d::network::SIOClient *_sioClient, *_sioEndpoint; cocos2d::LabelTTF *_sioClientStatus; }; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp index 39a3ec5cc1..d04259101b 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp @@ -11,7 +11,6 @@ USING_NS_CC; USING_NS_CC_EXT; -using namespace network; WebSocketTestLayer::WebSocketTestLayer() : _wsiSendText(NULL) @@ -74,9 +73,9 @@ WebSocketTestLayer::WebSocketTestLayer() menuBack->setPosition(Point::ZERO); addChild(menuBack); - _wsiSendText = new WebSocket(); - _wsiSendBinary = new WebSocket(); - _wsiError = new WebSocket(); + _wsiSendText = new network::WebSocket(); + _wsiSendBinary = new network::WebSocket(); + _wsiError = new network::WebSocket(); if (!_wsiSendText->init(*this, "ws://echo.websocket.org")) { @@ -202,7 +201,7 @@ void WebSocketTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) // Menu Callbacks void WebSocketTestLayer::onMenuSendTextClicked(cocos2d::Object *sender) { - if (_wsiSendText->getReadyState() == WebSocket::State::OPEN) + if (_wsiSendText->getReadyState() == network::WebSocket::State::OPEN) { _sendTextStatus->setString("Send Text WS is waiting..."); _wsiSendText->send("Hello WebSocket, I'm a text message."); @@ -217,7 +216,7 @@ void WebSocketTestLayer::onMenuSendTextClicked(cocos2d::Object *sender) void WebSocketTestLayer::onMenuSendBinaryClicked(cocos2d::Object *sender) { - if (_wsiSendBinary->getReadyState() == WebSocket::State::OPEN) + if (_wsiSendBinary->getReadyState() == network::WebSocket::State::OPEN) { _sendBinaryStatus->setString("Send Binary WS is waiting..."); char buf[] = "Hello WebSocket,\0 I'm\0 a\0 binary\0 message\0."; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.h index fcec4ec724..ce1529eef0 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.h @@ -15,16 +15,16 @@ class WebSocketTestLayer : public cocos2d::Layer -, public network::WebSocket::Delegate +, public cocos2d::network::WebSocket::Delegate { public: WebSocketTestLayer(); virtual ~WebSocketTestLayer(); - virtual void onOpen(network::WebSocket* ws); - virtual void onMessage(network::WebSocket* ws, const network::WebSocket::Data& data); - virtual void onClose(network::WebSocket* ws); - virtual void onError(network::WebSocket* ws, const network::WebSocket::ErrorCode& error); + virtual void onOpen(cocos2d::network::WebSocket* ws); + virtual void onMessage(cocos2d::network::WebSocket* ws, const cocos2d::network::WebSocket::Data& data); + virtual void onClose(cocos2d::network::WebSocket* ws); + virtual void onError(cocos2d::network::WebSocket* ws, const cocos2d::network::WebSocket::ErrorCode& error); void toExtensionsMainLayer(cocos2d::Object *sender); @@ -33,9 +33,9 @@ public: void onMenuSendBinaryClicked(cocos2d::Object *sender); private: - network::WebSocket* _wsiSendText; - network::WebSocket* _wsiSendBinary; - network::WebSocket* _wsiError; + cocos2d::network::WebSocket* _wsiSendText; + cocos2d::network::WebSocket* _wsiSendBinary; + cocos2d::network::WebSocket* _wsiError; cocos2d::LabelTTF* _sendTextStatus; cocos2d::LabelTTF* _sendBinaryStatus; diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp index 1c1ae1084a..0bbb8cc63a 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp @@ -25,6 +25,7 @@ static std::function createFunctions[] = { CL(LayerExtendedBlendOpacityTest), CL(LayerBug3162A), CL(LayerBug3162B), + CL(LayerColorOccludeBug), }; static int sceneIdx=-1; @@ -954,3 +955,27 @@ std::string LayerBug3162B::subtitle() const { return "u and m layer color is effected/diseffected with b layer"; } + +std::string LayerColorOccludeBug::title() const +{ + return "Layer Color Occlude Bug Test"; +} + +std::string LayerColorOccludeBug::subtitle() const +{ + return "Layer Color Should not occlude titles and any sprites"; +} + +void LayerColorOccludeBug::onEnter() +{ + LayerTest::onEnter(); + Director::getInstance()->setDepthTest(true); + _layer = LayerColor::create(Color4B(0, 80, 95, 255)); + addChild(_layer); +} + +void LayerColorOccludeBug::onExit() +{ + LayerTest::onExit(); + Director::getInstance()->setDepthTest(false); +} diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h index 61a8602200..61b4f6fc2c 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h @@ -202,6 +202,19 @@ private: LayerColor* _layer[3]; }; +class LayerColorOccludeBug : public LayerTest +{ +public: + CREATE_FUNC(LayerColorOccludeBug); + virtual void onEnter() override; + virtual void onExit() override; + virtual std::string title() const override; + virtual std::string subtitle() const override; + +private: + LayerColor* _layer; +}; + class LayerTestScene : public TestScene { public: diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp index e91fcdb3f6..f4da9b94c8 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include "MenuTest.h" #include "../testResource.h" diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h index db6e0a918d..1910968546 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #ifndef _MENU_TEST_H_ #define _MENU_TEST_H_ diff --git a/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp b/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp index 5f41c4fdd9..d23091db12 100644 --- a/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp @@ -749,6 +749,15 @@ std::string RemoveListenerAfterAddingTest::subtitle() const // //DirectorEventTest // +DirectorEventTest::DirectorEventTest() +:_count1(0) +,_count2(0) +,_count3(0) +,_count4(0) +{ + +} + void DirectorEventTest::onEnter() { EventDispatcherTestDemo::onEnter(); diff --git a/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h b/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h index 0512b3c31d..2de772a6af 100644 --- a/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h +++ b/samples/Cpp/TestCpp/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h @@ -117,6 +117,7 @@ class DirectorEventTest : public EventDispatcherTestDemo { public: CREATE_FUNC(DirectorEventTest); + DirectorEventTest(); virtual void onEnter() override; virtual void onExit() override; diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp index a9af857f5c..4d69c14542 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include "NodeTest.h" #include "../testResource.h" @@ -22,40 +47,36 @@ Layer* restartCocosNodeAction(); static int sceneIdx = -1; -#define MAX_LAYER 14 -Layer* createCocosNodeLayer(int nIndex) +static std::function createFunctions[] = { - switch(nIndex) - { - case 0: return new CameraCenterTest(); - case 1: return new Test2(); - case 2: return new Test4(); - case 3: return new Test5(); - case 4: return new Test6(); - case 5: return new StressTest1(); - case 6: return new StressTest2(); - case 7: return new NodeToWorld(); - case 8: return new SchedulerTest1(); - case 9: return new CameraOrbitTest(); - case 10: return new CameraZoomTest(); - case 11: return new ConvertToNode(); - case 12: return new NodeOpaqueTest(); - case 13: return new NodeNonOpaqueTest(); - } + CL(CameraTest1), + CL(CameraTest2), + CL(CameraCenterTest), + CL(Test2), + CL(Test4), + CL(Test5), + CL(Test6), + CL(StressTest1), + CL(StressTest2), + CL(NodeToWorld), + CL(NodeToWorld3D), + CL(SchedulerTest1), + CL(CameraOrbitTest), + CL(CameraZoomTest), + CL(ConvertToNode), + CL(NodeOpaqueTest), + CL(NodeNonOpaqueTest), +}; - return NULL; -} +#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) Layer* nextCocosNodeAction() { sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - auto layer = createCocosNodeLayer(sceneIdx); - layer->autorelease(); - - return layer; + return createFunctions[sceneIdx](); } Layer* backCocosNodeAction() @@ -65,18 +86,12 @@ Layer* backCocosNodeAction() if( sceneIdx < 0 ) sceneIdx += total; - auto layer = createCocosNodeLayer(sceneIdx); - layer->autorelease(); - - return layer; + return createFunctions[sceneIdx](); } Layer* restartCocosNodeAction() { - auto layer = createCocosNodeLayer(sceneIdx); - layer->autorelease(); - - return layer; + return createFunctions[sceneIdx](); } @@ -504,6 +519,56 @@ std::string NodeToWorld::title() const return "nodeToParent transform"; } +//------------------------------------------------------------------ +// +// NodeToWorld3D +// +//------------------------------------------------------------------ +NodeToWorld3D::NodeToWorld3D() +{ + // + // This code tests that nodeToParent works OK: + // - It tests different anchor Points + // - It tests different children anchor points + + Size s = Director::getInstance()->getWinSize(); + auto parent = Node::create(); + parent->setContentSize(s); + parent->setAnchorPoint(Point(0.5, 0.5)); + parent->setPosition(s.width/2, s.height/2); + this->addChild(parent); + + auto back = Sprite::create(s_back3); + parent->addChild( back, -10); + back->setAnchorPoint( Point(0,0) ); + auto backSize = back->getContentSize(); + + auto item = MenuItemImage::create(s_PlayNormal, s_PlaySelect); + auto menu = Menu::create(item, NULL); + menu->alignItemsVertically(); + menu->setPosition( Point(backSize.width/2, backSize.height/2)); + back->addChild(menu); + + auto rot = RotateBy::create(5, 360); + auto fe = RepeatForever::create( rot); + item->runAction( fe ); + + auto move = MoveBy::create(3, Point(200,0)); + auto move_back = move->reverse(); + auto seq = Sequence::create( move, move_back, NULL); + auto fe2 = RepeatForever::create(seq); + back->runAction(fe2); + + auto orbit = OrbitCamera::create(10, 0, 1, 0, 360, 0, 90); + parent->runAction(orbit); +} + +std::string NodeToWorld3D::title() const +{ + return "nodeToParent transform in 3D"; +} + + //------------------------------------------------------------------ // // CameraOrbitTest @@ -840,6 +905,174 @@ std::string NodeNonOpaqueTest::subtitle() const return "Node rendered with GL_BLEND enabled"; } + +// +// MySprite: Used by CameraTest1 and CameraTest2 +// +class MySprite : public Sprite +{ +public: + static MySprite* create(const std::string &spritefilename) + { + auto sprite = new MySprite; + sprite->initWithFile(spritefilename); + sprite->autorelease(); + + auto shader = CCShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); + sprite->setShaderProgram(shader); + return sprite; + } + virtual void draw() override; + void onDraw(); + +protected: + CustomCommand _customCommand; + +}; + +void MySprite::draw() +{ + _customCommand.init(0, _vertexZ); + _customCommand.func = CC_CALLBACK_0(MySprite::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(&_customCommand); +} + +void MySprite::onDraw() +{ + CC_NODE_DRAW_SETUP(); + + GL::blendFunc( _blendFunc.src, _blendFunc.dst ); + + GL::bindTexture2D( _texture->getName() ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); + +#define kQuadSize sizeof(_quad.bl) + long offset = (long)&_quad; + + // vertex + int diff = offsetof( V3F_C4B_T2F, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + + // texCoods + diff = offsetof( V3F_C4B_T2F, texCoords); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + + // color + diff = offsetof( V3F_C4B_T2F, colors); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); + + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + CHECK_GL_ERROR_DEBUG(); + CC_INCREMENT_GL_DRAWS(1); +} +//------------------------------------------------------------------ +// +// CameraTest1 +// +//------------------------------------------------------------------ + +void CameraTest1::onEnter() +{ + TestCocosNodeDemo::onEnter(); + Director::getInstance()->setProjection(Director::Projection::_3D); + Director::getInstance()->setDepthTest(true); +} + +void CameraTest1::onExit() +{ + Director::getInstance()->setProjection(Director::Projection::_2D); + TestCocosNodeDemo::onExit(); +} + +CameraTest1::CameraTest1() +{ + auto s = Director::getInstance()->getWinSize(); + + _sprite1 = MySprite::create(s_back3); + addChild( _sprite1 ); + _sprite1->setPosition( Point(1*s.width/4, s.height/2) ); + _sprite1->setScale(0.5); + + _sprite2 = Sprite::create(s_back3); + addChild( _sprite2 ); + _sprite2->setPosition( Point(3*s.width/4, s.height/2) ); + _sprite2->setScale(0.5); + + auto camera = OrbitCamera::create(10, 0, 1, 0, 360, 0, 0); + _sprite1->runAction( camera ); + _sprite2->runAction( camera->clone() ); +} + +std::string CameraTest1::title() const +{ + return "Camera Test 1"; +} + +std::string CameraTest1::subtitle() const +{ + return "Both images should rotate with a 3D effect"; +} +//------------------------------------------------------------------ +// +// CameraTest2 +// +//------------------------------------------------------------------ +void CameraTest2::onEnter() +{ + TestCocosNodeDemo::onEnter(); + Director::getInstance()->setProjection(Director::Projection::_3D); + Director::getInstance()->setDepthTest(true); +} + +void CameraTest2::onExit() +{ + Director::getInstance()->setProjection(Director::Projection::_2D); + TestCocosNodeDemo::onExit(); +} + +CameraTest2::CameraTest2() +{ + auto s = Director::getInstance()->getWinSize(); + + _sprite1 = MySprite::create(s_back3); + addChild( _sprite1 ); + _sprite1->setPosition( Point(1*s.width/4, s.height/2) ); + _sprite1->setScale(0.5); + + _sprite2 = Sprite::create(s_back3); + addChild( _sprite2 ); + _sprite2->setPosition( Point(3*s.width/4, s.height/2) ); + _sprite2->setScale(0.5); + + kmVec3 eye, center, up; + + kmVec3Fill(&eye, 150, 0, 200); + kmVec3Fill(¢er, 0, 0, 0); + kmVec3Fill(&up, 0, 1, 0); + + kmMat4 lookupMatrix; + kmMat4LookAt(&lookupMatrix, &eye, ¢er, &up); + + _sprite1->setAdditionalTransform(lookupMatrix); + _sprite2->setAdditionalTransform(lookupMatrix); + +} + +std::string CameraTest2::title() const +{ + return "Camera Test 2"; +} + +std::string CameraTest2::subtitle() const +{ + return "Both images should look the same"; +} + +/// +/// main +/// void CocosNodeTestScene::runThisTest() { auto layer = nextCocosNodeAction(); diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h index 99f03bafbb..2207c65f7c 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #ifndef _NODE_TEST_H_ #define _NODE_TEST_H_ @@ -8,8 +33,6 @@ class TestCocosNodeDemo : public BaseTest { public: - TestCocosNodeDemo(void); - ~TestCocosNodeDemo(void); virtual std::string title() const override; virtual std::string subtitle() const override; @@ -18,11 +41,16 @@ public: void restartCallback(Object* sender); void nextCallback(Object* sender); void backCallback(Object* sender); + +protected: + TestCocosNodeDemo(); + virtual ~TestCocosNodeDemo(); }; class Test2 : public TestCocosNodeDemo { public: + CREATE_FUNC(Test2); virtual void onEnter(); virtual std::string title() const override; }; @@ -30,120 +58,195 @@ public: class Test4 : public TestCocosNodeDemo { public: - Test4(); + CREATE_FUNC(Test4); void delay2(float dt); void delay4(float dt); virtual std::string title() const override; + +protected: + Test4(); }; class Test5 : public TestCocosNodeDemo { public: - Test5(); - void addAndRemove(float dt); + CREATE_FUNC(Test5); + void addAndRemove(float dt); virtual std::string title() const override; + +protected: + Test5(); }; class Test6 : public TestCocosNodeDemo { public: - Test6(); + CREATE_FUNC(Test6); void addAndRemove(float dt); - virtual std::string title() const override; + +protected: + Test6(); }; class StressTest1 : public TestCocosNodeDemo { +public: + CREATE_FUNC(StressTest1); void shouldNotCrash(float dt); void removeMe(Node* node); -public: - StressTest1(); - virtual std::string title() const override; + +protected: + StressTest1(); }; class StressTest2 : public TestCocosNodeDemo { - void shouldNotLeak(float dt); public: - StressTest2(); - + CREATE_FUNC(StressTest2); + void shouldNotLeak(float dt); virtual std::string title() const override; + +protected: + StressTest2(); }; class SchedulerTest1 : public TestCocosNodeDemo { public: - SchedulerTest1(); + CREATE_FUNC(SchedulerTest1); void doSomething(float dt); - virtual std::string title() const override; + +protected: + SchedulerTest1(); }; class NodeToWorld : public TestCocosNodeDemo { public: - NodeToWorld(); + CREATE_FUNC(NodeToWorld); virtual std::string title() const override; + +protected: + NodeToWorld(); +}; + +class NodeToWorld3D : public TestCocosNodeDemo +{ +public: + CREATE_FUNC(NodeToWorld3D); + virtual std::string title() const override; + +protected: + NodeToWorld3D(); }; class CameraOrbitTest : public TestCocosNodeDemo { public: - CameraOrbitTest(); - - virtual void onEnter(); - virtual void onExit(); + CREATE_FUNC(CameraOrbitTest); + virtual void onEnter() override; + virtual void onExit() override; virtual std::string title() const override; + +protected: + CameraOrbitTest(); }; class CameraZoomTest : public TestCocosNodeDemo { - float _z; public: - CameraZoomTest(); + CREATE_FUNC(CameraZoomTest); void update(float dt); - virtual void onEnter(); - virtual void onExit(); - + virtual void onEnter() override; + virtual void onExit() override; virtual std::string title() const override; + +protected: + CameraZoomTest(); + float _z; }; class CameraCenterTest : public TestCocosNodeDemo { public: - CameraCenterTest(); + CREATE_FUNC(CameraCenterTest); virtual std::string title() const override; virtual std::string subtitle() const override; + +protected: + CameraCenterTest(); +}; + +class CameraTest1 : public TestCocosNodeDemo +{ +public: + CREATE_FUNC(CameraTest1); + virtual std::string title() const override; + virtual std::string subtitle() const override; + virtual void onEnter() override; + virtual void onExit() override; + +protected: + CameraTest1(); + + Sprite *_sprite1; + Sprite *_sprite2; +}; + +class CameraTest2 : public TestCocosNodeDemo +{ +public: + CREATE_FUNC(CameraTest2); + virtual std::string title() const override; + virtual std::string subtitle() const override; + virtual void onEnter() override; + virtual void onExit() override; + +protected: + CameraTest2(); + + Sprite *_sprite1; + Sprite *_sprite2; }; class ConvertToNode : public TestCocosNodeDemo { public: - ConvertToNode(); + CREATE_FUNC(ConvertToNode); void onTouchesEnded(const std::vector& touches, Event *event); virtual std::string title() const override; virtual std::string subtitle() const override; + +protected: + ConvertToNode(); }; class NodeOpaqueTest : public TestCocosNodeDemo { public: - NodeOpaqueTest(); + CREATE_FUNC(NodeOpaqueTest); virtual std::string title() const override; virtual std::string subtitle() const override; + +protected: + NodeOpaqueTest(); }; class NodeNonOpaqueTest : public TestCocosNodeDemo { public: - NodeNonOpaqueTest(); + CREATE_FUNC(NodeNonOpaqueTest); virtual std::string title() const override; virtual std::string subtitle() const override; + +protected: + NodeNonOpaqueTest(); }; class CocosNodeTestScene : public TestScene diff --git a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp index d7ecafe32b..54a2095f42 100644 --- a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp @@ -1553,8 +1553,7 @@ void MultipleParticleSystemsBatched::onEnter() removeChild(_background, true); _background = NULL; - auto batchNode = new ParticleBatchNode(); - batchNode->initWithTexture(NULL, 3000); + ParticleBatchNode *batchNode = ParticleBatchNode::createWithTexture(nullptr, 3000); addChild(batchNode, 1, 2); @@ -1569,8 +1568,6 @@ void MultipleParticleSystemsBatched::onEnter() batchNode->addChild(particleSystem); } - batchNode->release(); - _emitter = NULL; } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp index df7cce7c38..f14ca83fac 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceAllocTest.cpp @@ -80,7 +80,6 @@ void AllocBasicLayer::showCurrentTest() scene->initWithQuantityOfNodes(nodes); Director::getInstance()->replaceScene(scene); - scene->release(); } } @@ -478,5 +477,4 @@ void runAllocPerformanceTest() scene->initWithQuantityOfNodes(kNodesIncrease); Director::getInstance()->replaceScene(scene); - scene->release(); } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp index 3fde8293b7..96a3aeb67a 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -109,7 +109,6 @@ void NodeChildrenMenuLayer::showCurrentTest() scene->initWithQuantityOfNodes(nodes); Director::getInstance()->replaceScene(scene); - scene->release(); } } @@ -979,5 +978,4 @@ void runNodeChildrenTest() scene->initWithQuantityOfNodes(kNodesIncrease); Director::getInstance()->replaceScene(scene); - scene->release(); } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp index 1f4adbbf1a..d653d67bb3 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp @@ -196,24 +196,21 @@ void ParticleMainScene::createParticleSystem() // } // else { - particleSystem = ParticleSystemQuad::create(); + particleSystem = ParticleSystemQuad::createWithTotalParticles(quantityParticles); } switch( subtestNumber) { case 1: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); - particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; case 2: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); - particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; case 3: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); - particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; // case 4: @@ -223,21 +220,17 @@ void ParticleMainScene::createParticleSystem() // break; case 4: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); - particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; case 5: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); - particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; case 6: Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); - particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); break; // case 8: -// particleSystem->initWithTotalParticles(quantityParticles); // ////---- particleSystem.texture = [[TextureCache sharedTextureCache] addImage:@"fire.pvr"]; // particleSystem->setTexture(Director::getInstance()->getTextureCache()->addImage("Images/fire.png")); // break; @@ -247,7 +240,6 @@ void ParticleMainScene::createParticleSystem() break; } addChild(particleSystem, 0, kTagParticleSystem); - particleSystem->release(); doTest(); diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h index 2bbf6b1aee..040283506b 100644 --- a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h @@ -26,6 +26,8 @@ private: class PhysicsDemoDisabled : public BaseTest { public: + CREATE_FUNC(PhysicsDemoDisabled); + virtual void onEnter() override; }; #else diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index 3438a8a84e..9a18f256be 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -101,12 +101,6 @@ RenderTextureSave::RenderTextureSave() // note that the render texture is a Node, and contains a sprite of its texture for convience, // so we can just parent it to the scene like any other Node this->addChild(_target, -1); - - // create a brush image to draw into the texture with - _brush = Sprite::create("Images/fire.png"); - _brush->retain(); - _brush->setColor(Color3B::RED); - _brush->setOpacity(20); auto listener = EventListenerTouchAllAtOnce::create(); listener->onTouchesMoved = CC_CALLBACK_2(RenderTextureSave::onTouchesMoved, this); @@ -170,7 +164,6 @@ void RenderTextureSave::saveImage(cocos2d::Object *sender) RenderTextureSave::~RenderTextureSave() { - _brush->release(); _target->release(); Director::getInstance()->getTextureCache()->removeUnusedTextures(); } @@ -190,20 +183,28 @@ void RenderTextureSave::onTouchesMoved(const std::vector& touches, Event if (distance > 1) { int d = (int)distance; + _brushs.clear(); + for(int i = 0; i < d; ++i) + { + Sprite * sprite = Sprite::create("Images/fire.png"); + sprite->setColor(Color3B::RED); + sprite->setOpacity(20); + _brushs.pushBack(sprite); + } for (int i = 0; i < d; i++) { float difx = end.x - start.x; float dify = end.y - start.y; float delta = (float)i / distance; - _brush->setPosition(Point(start.x + (difx * delta), start.y + (dify * delta))); - _brush->setRotation(rand() % 360); + _brushs.at(i)->setPosition(Point(start.x + (difx * delta), start.y + (dify * delta))); + _brushs.at(i)->setRotation(rand() % 360); float r = (float)(rand() % 50 / 50.f) + 0.25f; - _brush->setScale(r); + _brushs.at(i)->setScale(r); /*_brush->setColor(Color3B(CCRANDOM_0_1() * 127 + 128, 255, 255));*/ // Use CCRANDOM_0_1() will cause error when loading libtests.so on android, I don't know why. - _brush->setColor(Color3B(rand() % 127 + 128, 255, 255)); + _brushs.at(i)->setColor(Color3B(rand() % 127 + 128, 255, 255)); // Call visit to draw the brush, don't call draw.. - _brush->visit(); + _brushs.at(i)->visit(); } } @@ -442,32 +443,80 @@ RenderTextureTestDepthStencil::RenderTextureTestDepthStencil() { auto s = Director::getInstance()->getWinSize(); - auto sprite = Sprite::create("Images/fire.png"); - sprite->setPosition(Point(s.width * 0.25f, 0)); - sprite->setScale(10); - auto rend = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8); + _spriteDS = Sprite::create("Images/fire.png"); + _spriteDS->retain(); + _spriteDS->setPosition(Point(s.width * 0.25f, 0)); + _spriteDS->setScale(10); + + _spriteDraw = Sprite::create("Images/fire.png"); + _spriteDraw->retain(); + _spriteDraw->setPosition(Point(s.width * 0.25f, 0)); + _spriteDraw->setScale(10); + //! move sprite half width and height, and draw only where not marked + _spriteDraw->setPosition(_spriteDraw->getPosition() + Point(_spriteDraw->getContentSize().width * _spriteDraw->getScale() * 0.5, _spriteDraw->getContentSize().height * _spriteDraw->getScale() * 0.5)); + + _rend = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8); + _rend->setPosition(Point(s.width * 0.5f, s.height * 0.5f)); + + this->addChild(_rend); +} + +RenderTextureTestDepthStencil::~RenderTextureTestDepthStencil() +{ + CC_SAFE_RELEASE(_spriteDraw); + CC_SAFE_RELEASE(_spriteDS); +} + +void RenderTextureTestDepthStencil::draw() +{ + _renderCmds[0].init(0, _vertexZ); + _renderCmds[0].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeClear, this); + Director::getInstance()->getRenderer()->addCommand(&_renderCmds[0]); + + _rend->beginWithClear(0, 0, 0, 0, 0, 0); + + _renderCmds[1].init(0, _vertexZ); + _renderCmds[1].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforeStencil, this); + Director::getInstance()->getRenderer()->addCommand(&_renderCmds[1]); + + _spriteDS->visit(); + + _renderCmds[2].init(0, _vertexZ); + _renderCmds[2].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onBeforDraw, this); + Director::getInstance()->getRenderer()->addCommand(&_renderCmds[2]); + + _spriteDraw->visit(); + + _rend->end(); + + _renderCmds[3].init(0, _vertexZ); + _renderCmds[3].func = CC_CALLBACK_0(RenderTextureTestDepthStencil::onAfterDraw, this); + Director::getInstance()->getRenderer()->addCommand(&_renderCmds[3]); + +} + +void RenderTextureTestDepthStencil::onBeforeClear() +{ glStencilMask(0xFF); - rend->beginWithClear(0, 0, 0, 0, 0, 0); +} +void RenderTextureTestDepthStencil::onBeforeStencil() +{ //! mark sprite quad into stencil buffer glEnable(GL_STENCIL_TEST); glStencilFunc(GL_NEVER, 1, 0xFF); glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); - sprite->visit(); +} - //! move sprite half width and height, and draw only where not marked - sprite->setPosition(sprite->getPosition() + Point(sprite->getContentSize().width * sprite->getScale() * 0.5, sprite->getContentSize().height * sprite->getScale() * 0.5)); +void RenderTextureTestDepthStencil::onBeforDraw() +{ glStencilFunc(GL_NOTEQUAL, 1, 0xFF); - sprite->visit(); - - rend->end(); +} +void RenderTextureTestDepthStencil::onAfterDraw() +{ glDisable(GL_STENCIL_TEST); - - rend->setPosition(Point(s.width * 0.5f, s.height * 0.5f)); - - this->addChild(rend); } std::string RenderTextureTestDepthStencil::title() const diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h index ea7dbaa7f1..32ee7c111d 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h @@ -4,6 +4,7 @@ #include "cocos2d.h" #include "../testBasic.h" #include "../BaseTest.h" +#include "renderer/CCCustomCommand.h" class RenderTextureTest : public BaseTest { @@ -31,7 +32,7 @@ public: private: RenderTexture *_target; - Sprite *_brush; + Vector _brushs; }; class RenderTextureIssue937 : public RenderTextureTest @@ -82,8 +83,21 @@ class RenderTextureTestDepthStencil : public RenderTextureTest public: CREATE_FUNC(RenderTextureTestDepthStencil); RenderTextureTestDepthStencil(); + virtual ~RenderTextureTestDepthStencil(); virtual std::string title() const override; virtual std::string subtitle() const override; + virtual void draw() override; +private: + CustomCommand _renderCmds[4]; + void onBeforeClear(); + void onBeforeStencil(); + void onBeforDraw(); + void onAfterDraw(); + +private: + RenderTexture* _rend; + Sprite* _spriteDS; + Sprite* _spriteDraw; }; class RenderTextureTargetNode : public RenderTextureTest diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp index 4f69133030..ba6c1f01c1 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp @@ -122,7 +122,6 @@ ShaderNode::ShaderNode() ShaderNode::~ShaderNode() { - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); } ShaderNode* ShaderNode::shaderNodeWithVertex(const char *vert, const char *frag) @@ -136,10 +135,14 @@ ShaderNode* ShaderNode::shaderNodeWithVertex(const char *vert, const char *frag) bool ShaderNode::initWithVertex(const char *vert, const char *frag) { - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(ShaderNode::listenBackToForeground), - EVNET_COME_TO_FOREGROUND, - NULL); +#if CC_ENABLE_CACHE_TEXTURE_DATA + auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ + this->setShaderProgram(NULL); + loadShaderVertex(_vertFileName.c_str(), _fragFileName.c_str()); + }); + + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); +#endif loadShaderVertex(vert, frag); @@ -157,12 +160,6 @@ bool ShaderNode::initWithVertex(const char *vert, const char *frag) return true; } -void ShaderNode::listenBackToForeground(Object *obj) -{ - this->setShaderProgram(NULL); - loadShaderVertex(_vertFileName.c_str(), _fragFileName.c_str()); -} - void ShaderNode::loadShaderVertex(const char *vert, const char *frag) { auto shader = new GLProgram(); @@ -437,7 +434,6 @@ public: bool initWithTexture(Texture2D* texture, const Rect& rect); void draw(); void initProgram(); - void listenBackToForeground(Object *obj); static SpriteBlur* create(const char *pszFileName); @@ -454,7 +450,6 @@ private: SpriteBlur::~SpriteBlur() { - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); } SpriteBlur* SpriteBlur::create(const char *pszFileName) @@ -472,20 +467,18 @@ SpriteBlur* SpriteBlur::create(const char *pszFileName) return pRet; } -void SpriteBlur::listenBackToForeground(Object *obj) -{ - setShaderProgram(NULL); - initProgram(); -} - bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect) { if( Sprite::initWithTexture(texture, rect) ) { - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(SpriteBlur::listenBackToForeground), - EVNET_COME_TO_FOREGROUND, - NULL); +#if CC_ENABLE_CACHE_TEXTURE_DATA + auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ + setShaderProgram(NULL); + initProgram(); + }); + + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); +#endif auto s = getTexture()->getContentSizeInPixels(); diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h index 9459bd584a..741b0bb66f 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h @@ -118,7 +118,6 @@ public: bool initWithVertex(const char *vert, const char *frag); void loadShaderVertex(const char *vert, const char *frag); - void listenBackToForeground(Object *obj); virtual void update(float dt); virtual void setPosition(const Point &newPosition); diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp index 89fddc5be0..569bef3915 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest2.cpp @@ -2,6 +2,8 @@ #include "ShaderTest.h" #include "../testResource.h" #include "cocos2d.h" +#include "renderer/CCRenderCommand.h" +#include "renderer/CCCustomCommand.h" namespace ShaderTest2 { @@ -118,6 +120,10 @@ protected: virtual void setCustomUniforms() = 0; protected: std::string _fragSourceFile; + +protected: + CustomCommand _renderCommand; + void onDraw(); }; @@ -127,21 +133,17 @@ ShaderSprite::ShaderSprite() ShaderSprite::~ShaderSprite() { - NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND); -} - -void ShaderSprite::listenBackToForeground(Object *obj) -{ - setShaderProgram(NULL); - initShader(); } void ShaderSprite::setBackgroundNotification() { - NotificationCenter::getInstance()->addObserver(this, - callfuncO_selector(ShaderSprite::listenBackToForeground), - EVNET_COME_TO_FOREGROUND, - NULL); +#if CC_ENABLE_CACHE_TEXTURE_DATA + auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){ + this->setShaderProgram(nullptr); + this->initShader(); + }); + _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); +#endif } void ShaderSprite::initShader() @@ -175,11 +177,19 @@ void ShaderSprite::initShader() } void ShaderSprite::draw() +{ + _renderCommand.init(0, _vertexZ); + _renderCommand.func = CC_CALLBACK_0(ShaderSprite::onDraw, this); + Director::getInstance()->getRenderer()->addCommand(&_renderCommand); + +} + +void ShaderSprite::onDraw() { CC_NODE_DRAW_SETUP(); - + setCustomUniforms(); - + GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); GL::blendFunc(_blendFunc.src, _blendFunc.dst); GL::bindTexture2D( getTexture()->getName()); @@ -204,8 +214,6 @@ void ShaderSprite::draw() glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - CC_INCREMENT_GL_DRAWS(1); } class NormalSprite : public ShaderSprite, public ShaderSpriteCreator diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index d3578f7962..8f885e907c 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -e14a3c9f23fccd862ac2ffcba41ee7094ab54981 \ No newline at end of file +689b357d7acda141d13a3dfc4cb52aabb274f6cd \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.h b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.h index a413c9f869..05d171675f 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.h +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.h @@ -37,7 +37,7 @@ protected: public: SpriteTestDemo(void); - ~SpriteTestDemo(void); + virtual ~SpriteTestDemo(void); void restartCallback(Object* sender); void nextCallback(Object* sender); @@ -383,7 +383,7 @@ class SpriteOffsetAnchorSkew : public SpriteTestDemo public: CREATE_FUNC(SpriteOffsetAnchorSkew); SpriteOffsetAnchorSkew(); - ~SpriteOffsetAnchorSkew(); + virtual ~SpriteOffsetAnchorSkew(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -393,7 +393,7 @@ class SpriteOffsetAnchorRotationalSkew : public SpriteTestDemo public: CREATE_FUNC(SpriteOffsetAnchorRotationalSkew); SpriteOffsetAnchorRotationalSkew(); - ~SpriteOffsetAnchorRotationalSkew(); + virtual ~SpriteOffsetAnchorRotationalSkew(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -403,7 +403,7 @@ class SpriteBatchNodeOffsetAnchorSkew : public SpriteTestDemo public: CREATE_FUNC(SpriteBatchNodeOffsetAnchorSkew); SpriteBatchNodeOffsetAnchorSkew(); - ~SpriteBatchNodeOffsetAnchorSkew(); + virtual ~SpriteBatchNodeOffsetAnchorSkew(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -413,7 +413,7 @@ class SpriteOffsetAnchorRotationalSkewScale : public SpriteTestDemo public: CREATE_FUNC(SpriteOffsetAnchorRotationalSkewScale); SpriteOffsetAnchorRotationalSkewScale(); - ~SpriteOffsetAnchorRotationalSkewScale(); + virtual ~SpriteOffsetAnchorRotationalSkewScale(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -423,7 +423,7 @@ class SpriteBatchNodeOffsetAnchorRotationalSkew : public SpriteTestDemo public: CREATE_FUNC(SpriteBatchNodeOffsetAnchorRotationalSkew); SpriteBatchNodeOffsetAnchorRotationalSkew(); - ~SpriteBatchNodeOffsetAnchorRotationalSkew(); + virtual ~SpriteBatchNodeOffsetAnchorRotationalSkew(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -433,7 +433,7 @@ class SpriteOffsetAnchorSkewScale : public SpriteTestDemo public: CREATE_FUNC(SpriteOffsetAnchorSkewScale); SpriteOffsetAnchorSkewScale(); - ~SpriteOffsetAnchorSkewScale(); + virtual ~SpriteOffsetAnchorSkewScale(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -443,7 +443,7 @@ class SpriteBatchNodeOffsetAnchorSkewScale : public SpriteTestDemo public: CREATE_FUNC(SpriteBatchNodeOffsetAnchorSkewScale); SpriteBatchNodeOffsetAnchorSkewScale(); - ~SpriteBatchNodeOffsetAnchorSkewScale(); + virtual ~SpriteBatchNodeOffsetAnchorSkewScale(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -453,7 +453,7 @@ class SpriteBatchNodeOffsetAnchorRotationalSkewScale : public SpriteTestDemo public: CREATE_FUNC(SpriteBatchNodeOffsetAnchorRotationalSkewScale); SpriteBatchNodeOffsetAnchorRotationalSkewScale(); - ~SpriteBatchNodeOffsetAnchorRotationalSkewScale(); + virtual ~SpriteBatchNodeOffsetAnchorRotationalSkewScale(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -463,7 +463,7 @@ class SpriteOffsetAnchorFlip : public SpriteTestDemo public: CREATE_FUNC(SpriteOffsetAnchorFlip); SpriteOffsetAnchorFlip(); - ~SpriteOffsetAnchorFlip(); + virtual ~SpriteOffsetAnchorFlip(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -473,7 +473,7 @@ class SpriteBatchNodeOffsetAnchorFlip : public SpriteTestDemo public: CREATE_FUNC(SpriteBatchNodeOffsetAnchorFlip); SpriteBatchNodeOffsetAnchorFlip(); - ~SpriteBatchNodeOffsetAnchorFlip(); + virtual ~SpriteBatchNodeOffsetAnchorFlip(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -533,7 +533,7 @@ class SpriteChildrenVisibilityIssue665 : public SpriteTestDemo public: CREATE_FUNC(SpriteChildrenVisibilityIssue665); SpriteChildrenVisibilityIssue665(); - ~SpriteChildrenVisibilityIssue665(); + virtual ~SpriteChildrenVisibilityIssue665(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -668,7 +668,7 @@ class SpriteBatchNodeSkewNegativeScaleChildren : public SpriteTestDemo public: CREATE_FUNC(SpriteBatchNodeSkewNegativeScaleChildren); SpriteBatchNodeSkewNegativeScaleChildren(); - ~SpriteBatchNodeSkewNegativeScaleChildren(); + virtual ~SpriteBatchNodeSkewNegativeScaleChildren(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -678,7 +678,7 @@ class SpriteBatchNodeRotationalSkewNegativeScaleChildren : public SpriteTestDemo public: CREATE_FUNC(SpriteBatchNodeRotationalSkewNegativeScaleChildren); SpriteBatchNodeRotationalSkewNegativeScaleChildren(); - ~SpriteBatchNodeRotationalSkewNegativeScaleChildren(); + virtual ~SpriteBatchNodeRotationalSkewNegativeScaleChildren(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -688,7 +688,7 @@ class SpriteSkewNegativeScaleChildren : public SpriteTestDemo public: CREATE_FUNC(SpriteSkewNegativeScaleChildren); SpriteSkewNegativeScaleChildren(); - ~SpriteSkewNegativeScaleChildren(); + virtual ~SpriteSkewNegativeScaleChildren(); virtual std::string title() const override; virtual std::string subtitle() const override; }; @@ -698,7 +698,7 @@ class SpriteRotationalSkewNegativeScaleChildren : public SpriteTestDemo public: CREATE_FUNC(SpriteRotationalSkewNegativeScaleChildren); SpriteRotationalSkewNegativeScaleChildren(); - ~SpriteRotationalSkewNegativeScaleChildren(); + virtual ~SpriteRotationalSkewNegativeScaleChildren(); virtual std::string title() const override; virtual std::string subtitle() const override; }; diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index 3373be2eaf..95bcb47323 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + // local import #include "Texture2dTest.h" #include "../testResource.h" @@ -1511,21 +1536,20 @@ void TextureAsync::loadImages(float dt) for( int j=0;j < 8; j++) { char szSpriteName[100] = {0}; sprintf(szSpriteName, "Images/sprites_test/sprite-%d-%d.png", i, j); - Director::getInstance()->getTextureCache()->addImageAsync(szSpriteName,this, callfuncO_selector(TextureAsync::imageLoaded)); + Director::getInstance()->getTextureCache()->addImageAsync(szSpriteName, CC_CALLBACK_1(TextureAsync::imageLoaded, this)); } } - Director::getInstance()->getTextureCache()->addImageAsync("Images/background1.jpg",this, callfuncO_selector(TextureAsync::imageLoaded)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/background2.jpg",this, callfuncO_selector(TextureAsync::imageLoaded)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/background.png",this, callfuncO_selector(TextureAsync::imageLoaded)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/atlastest.png",this, callfuncO_selector(TextureAsync::imageLoaded)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_atlas.png",this, callfuncO_selector(TextureAsync::imageLoaded)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background1.jpg", CC_CALLBACK_1(TextureAsync::imageLoaded, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background2.jpg", CC_CALLBACK_1(TextureAsync::imageLoaded, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background.png", CC_CALLBACK_1(TextureAsync::imageLoaded, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/atlastest.png", CC_CALLBACK_1(TextureAsync::imageLoaded, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_atlas.png", CC_CALLBACK_1(TextureAsync::imageLoaded, this)); } -void TextureAsync::imageLoaded(Object* pObj) +void TextureAsync::imageLoaded(Texture2D* texture) { - auto tex = static_cast(pObj); auto director = Director::getInstance(); //CCASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread"); @@ -1534,7 +1558,7 @@ void TextureAsync::imageLoaded(Object* pObj) // This test just creates a sprite based on the Texture - auto sprite = Sprite::createWithTexture(tex); + auto sprite = Sprite::createWithTexture(texture); sprite->setAnchorPoint(Point(0,0)); addChild(sprite, -1); @@ -1544,7 +1568,7 @@ void TextureAsync::imageLoaded(Object* pObj) _imageOffset++; - log("Image loaded: %p", tex); + log("Image loaded: %p", texture); } std::string TextureAsync::title() const diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h index 5b8f9207ab..c331e0d254 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #ifndef __TEXTURE2D_TEST_H__ #define __TEXTURE2D_TEST_H__ @@ -387,7 +412,7 @@ public: CREATE_FUNC(TextureAsync); virtual ~TextureAsync(); void loadImages(float dt); - void imageLoaded(Object* pObj); + void imageLoaded(cocos2d::Texture2D* texture); virtual std::string title() const override; virtual std::string subtitle() const override; virtual void onEnter(); diff --git a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp index 698a2935fd..31c4beaef9 100644 --- a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.cpp @@ -21,29 +21,29 @@ TextureCacheTest::TextureCacheTest() this->addChild(_labelPercent); // load textrues - Director::getInstance()->getTextureCache()->addImageAsync("Images/HelloWorld.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_01.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_02.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_03.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_04.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_05.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_06.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_07.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_08.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_09.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_10.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_11.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_12.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_13.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_14.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/background1.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/background2.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/background3.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); - Director::getInstance()->getTextureCache()->addImageAsync("Images/blocks.png", this, callfuncO_selector(TextureCacheTest::loadingCallBack)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/HelloWorld.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_01.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_02.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_03.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_04.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_05.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_06.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_07.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_08.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_09.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_10.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_11.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_12.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_13.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/grossini_dance_14.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background1.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background2.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/background3.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); + Director::getInstance()->getTextureCache()->addImageAsync("Images/blocks.png", CC_CALLBACK_1(TextureCacheTest::loadingCallBack, this)); } -void TextureCacheTest::loadingCallBack(Object *obj) +void TextureCacheTest::loadingCallBack(cocos2d::Texture2D *texture) { ++_numberOfLoadedSprites; char tmp[10]; diff --git a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.h b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.h index fed36cad2d..b2dfdf7d2e 100644 --- a/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.h +++ b/samples/Cpp/TestCpp/Classes/TextureCacheTest/TextureCacheTest.h @@ -10,7 +10,7 @@ class TextureCacheTest : public Layer public: TextureCacheTest(); void addSprite(); - void loadingCallBack(cocos2d::Object *obj); + void loadingCallBack(cocos2d::Texture2D *texture); private: cocos2d::LabelTTF *_labelLoading; diff --git a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp index 338838baf9..75f0fd6eee 100644 --- a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp @@ -1089,7 +1089,10 @@ TMXTilePropertyTest::TMXTilePropertyTest() addChild(map ,0 ,kTagTileMap); for(int i=1;i<=20;i++){ - log("GID:%i, Properties:%s", i, map->getPropertiesForGID(i).asString().c_str()); + for(const auto& value : map->getPropertiesForGID(i).asValueMap()) + { + log("GID:%i, Properties:%s, %s", i, value.first.c_str(), value.second.asString().c_str()); + } } } @@ -1238,6 +1241,42 @@ std::string TMXOrthoFromXMLTest::title() const { return "TMX created from XML test"; } +//------------------------------------------------------------------ +// +// TMXOrthoXMLFormatTest +// +//------------------------------------------------------------------ + +TMXOrthoXMLFormatTest::TMXOrthoXMLFormatTest() +{ + // this test tests for: + // 1. load xml format tilemap + // 2. gid lower than firstgid is ignored + // 3. firstgid in tsx is ignored, tile property in tsx loaded correctly. + auto map = TMXTiledMap::create("TileMaps/xml-test.tmx"); + addChild(map, 0, kTagTileMap); + + auto s = map->getContentSize(); + log("ContentSize: %f, %f", s.width,s.height); + + auto& children = map->getChildren(); + for(const auto &node : children) { + auto child = static_cast(node); + child->getTexture()->setAntiAliasTexParameters(); + } + + for(int i=24;i<=26;i++){ + log("GID:%i, Properties:%s", i, map->getPropertiesForGID(i).asValueMap()["name"].asString().c_str()); + } + + auto action = ScaleBy::create(2, 0.5f); + map->runAction(action); +} + +std::string TMXOrthoXMLFormatTest::title() const +{ + return "you should see blue, green and yellow in console."; +} //------------------------------------------------------------------ // @@ -1311,43 +1350,44 @@ enum static int sceneIdx = -1; -#define MAX_LAYER 28 +#define MAX_LAYER 29 + +static std::function createFunctions[] = { + CLN(TMXIsoZorder), + CLN(TMXOrthoZorder), + CLN(TMXIsoVertexZ), + CLN(TMXOrthoVertexZ), + CLN(TMXOrthoTest), + CLN(TMXOrthoTest2), + CLN(TMXOrthoTest3), + CLN(TMXOrthoTest4), + CLN(TMXIsoTest), + CLN(TMXIsoTest1), + CLN(TMXIsoTest2), + CLN(TMXUncompressedTest), + CLN(TMXHexTest), + CLN(TMXReadWriteTest), + CLN(TMXTilesetTest), + CLN(TMXOrthoObjectsTest), + CLN(TMXIsoObjectsTest), + CLN(TMXResizeTest), + CLN(TMXIsoMoveLayer), + CLN(TMXOrthoMoveLayer), + CLN(TMXOrthoFlipTest), + CLN(TMXOrthoFlipRunTimeTest), + CLN(TMXOrthoFromXMLTest), + CLN(TMXOrthoXMLFormatTest), + CLN(TileMapTest), + CLN(TileMapEditTest), + CLN(TMXBug987), + CLN(TMXBug787), + CLN(TMXGIDObjectsTest), + +}; Layer* createTileMalayer(int nIndex) { - switch(nIndex) - { - case 0: return new TMXIsoZorder(); - case 1: return new TMXOrthoZorder(); - case 2: return new TMXIsoVertexZ(); - case 3: return new TMXOrthoVertexZ(); - case 4: return new TMXOrthoTest(); - case 5: return new TMXOrthoTest2(); - case 6: return new TMXOrthoTest3(); - case 7: return new TMXOrthoTest4(); - case 8: return new TMXIsoTest(); - case 9: return new TMXIsoTest1(); - case 10: return new TMXIsoTest2(); - case 11: return new TMXUncompressedTest (); - case 12: return new TMXHexTest(); - case 13: return new TMXReadWriteTest(); - case 14: return new TMXTilesetTest(); - case 15: return new TMXOrthoObjectsTest(); - case 16: return new TMXIsoObjectsTest(); - case 17: return new TMXResizeTest(); - case 18: return new TMXIsoMoveLayer(); - case 19: return new TMXOrthoMoveLayer(); - case 20: return new TMXOrthoFlipTest(); - case 21: return new TMXOrthoFlipRunTimeTest(); - case 22: return new TMXOrthoFromXMLTest(); - case 23: return new TileMapTest(); - case 24: return new TileMapEditTest(); - case 25: return new TMXBug987(); - case 26: return new TMXBug787(); - case 27: return new TMXGIDObjectsTest(); - } - - return NULL; + return createFunctions[nIndex](); } Layer* nextTileMapAction() @@ -1355,10 +1395,7 @@ Layer* nextTileMapAction() sceneIdx++; sceneIdx = sceneIdx % MAX_LAYER; - auto layer = createTileMalayer(sceneIdx); - layer->autorelease(); - - return layer; + return createTileMalayer(sceneIdx); } Layer* backTileMapAction() @@ -1366,20 +1403,14 @@ Layer* backTileMapAction() sceneIdx--; int total = MAX_LAYER; if( sceneIdx < 0 ) - sceneIdx += total; - - auto layer = createTileMalayer(sceneIdx); - layer->autorelease(); + sceneIdx += total; - return layer; + return createTileMalayer(sceneIdx); } Layer* restartTileMapAction() { - auto layer = createTileMalayer(sceneIdx); - layer->autorelease(); - - return layer; + return createTileMalayer(sceneIdx); } diff --git a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.h b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.h index 95d8ba1e85..234c7b2e00 100644 --- a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.h +++ b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.h @@ -256,13 +256,20 @@ public: void flipIt(float dt); }; -class TMXOrthoFromXMLTest : public TileDemo +class TMXOrthoFromXMLTest : public TileDemo { public: TMXOrthoFromXMLTest(); virtual std::string title() const override; }; +class TMXOrthoXMLFormatTest : public TileDemo +{ +public: + TMXOrthoXMLFormatTest(); + virtual std::string title() const override; +}; + class TMXBug987 : public TileDemo { public: diff --git a/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp b/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp index d46d4a15c2..5f4baf3d37 100644 --- a/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TouchesTest/TouchesTest.cpp @@ -43,7 +43,6 @@ PongLayer::PongLayer() _ball->setPosition( VisibleRect::center() ); _ball->setVelocity( _ballStartingVelocity ); addChild( _ball ); - _ball->retain(); auto paddleTexture = Director::getInstance()->getTextureCache()->addImage(s_Paddle); @@ -77,7 +76,6 @@ PongLayer::PongLayer() PongLayer::~PongLayer() { - _ball->release(); } void PongLayer::resetAndScoreBallForPlayer(int player) @@ -102,7 +100,6 @@ void PongLayer::doStep(float delta) resetAndScoreBallForPlayer( kLowPlayer ); else if (_ball->getPosition().y < VisibleRect::bottom().y-_ball->radius()) resetAndScoreBallForPlayer( kHighPlayer ); - _ball->draw(); } void PongScene::runThisTest() diff --git a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp index aaa8915438..7c71d0799e 100644 --- a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #include "TransitionsTest.h" #include "../testResource.h" #include "CCConfiguration.h" @@ -142,127 +167,82 @@ public: } }; -#define MAX_LAYER 41 +#define STRINGIFY(x) #x -static std::string transitions[MAX_LAYER] = { - "CCTransitionJumpZoom", +#define TRANS(__className__) { \ + [](float t, Scene* s){ return __className__::create(t,s);}, \ + STRINGIFY(__className__), \ + } +struct _transitions { + std::function function; + const char * name; +} transitions[] = { + TRANS(TransitionJumpZoom), + TRANS(TransitionProgressRadialCCW), + TRANS(TransitionProgressRadialCW), + TRANS(TransitionProgressHorizontal), + TRANS(TransitionProgressVertical), + TRANS(TransitionProgressInOut), + TRANS(TransitionProgressOutIn), - "CCTransitionProgressRadialCCW", - "CCTransitionProgressRadialCW", - "CCTransitionProgressHorizontal", - "CCTransitionProgressVertical", - "CCTransitionProgressInOut", - "CCTransitionProgressOutIn", + TRANS(TransitionCrossFade), - "CCTransitionCrossFade", - "TransitionPageForward", - "TransitionPageBackward", - "CCTransitionFadeTR", - "CCTransitionFadeBL", - "CCTransitionFadeUp", - "CCTransitionFadeDown", - "CCTransitionTurnOffTiles", - "CCTransitionSplitRows", - "CCTransitionSplitCols", + TRANS(PageTransitionForward), + TRANS(PageTransitionBackward), + TRANS(TransitionFadeTR), + TRANS(TransitionFadeBL), + TRANS(TransitionFadeUp), + TRANS(TransitionFadeDown), - "CCTransitionFade", - "FadeWhiteTransition", + TRANS(TransitionTurnOffTiles), - "FlipXLeftOver", - "FlipXRightOver", - "FlipYUpOver", - "FlipYDownOver", - "FlipAngularLeftOver", - "FlipAngularRightOver", + TRANS(TransitionSplitRows), + TRANS(TransitionSplitCols), - "ZoomFlipXLeftOver", - "ZoomFlipXRightOver", - "ZoomFlipYUpOver", - "ZoomFlipYDownOver", - "ZoomFlipAngularLeftOver", - "ZoomFlipAngularRightOver", + TRANS(TransitionFade), + TRANS(FadeWhiteTransition), - "CCTransitionShrinkGrow", - "CCTransitionRotoZoom", + TRANS(FlipXLeftOver), + TRANS(FlipXRightOver), + TRANS(FlipYUpOver), + TRANS(FlipYDownOver), + TRANS(FlipAngularLeftOver), + TRANS(FlipAngularRightOver), - "CCTransitionMoveInL", - "CCTransitionMoveInR", - "CCTransitionMoveInT", - "CCTransitionMoveInB", - "CCTransitionSlideInL", - "CCTransitionSlideInR", - "CCTransitionSlideInT", - "CCTransitionSlideInB", + TRANS(ZoomFlipXLeftOver), + TRANS(ZoomFlipXRightOver), + TRANS(ZoomFlipYUpOver), + TRANS(ZoomFlipYDownOver), + TRANS(ZoomFlipAngularLeftOver), + TRANS(ZoomFlipAngularRightOver), + TRANS(TransitionShrinkGrow), + TRANS(TransitionRotoZoom), + TRANS(TransitionMoveInL), + TRANS(TransitionMoveInR), + TRANS(TransitionMoveInT), + TRANS(TransitionMoveInB), + + TRANS(TransitionSlideInL), + TRANS(TransitionSlideInR), + TRANS(TransitionSlideInT), + TRANS(TransitionSlideInB), }; + + +#define MAX_LAYER (sizeof(transitions) / sizeof(transitions[0])) + + static int s_nSceneIdx = 0; -TransitionScene* createTransition(int nIndex, float t, Scene* s) +TransitionScene* createTransition(int index, float t, Scene* s) { // fix bug #486, without setDepthTest(false), FlipX,Y will flickers Director::getInstance()->setDepthTest(false); - switch(nIndex) - { - case 0: return TransitionJumpZoom::create(t, s); - - case 1: return TransitionProgressRadialCCW::create(t, s); - case 2: return TransitionProgressRadialCW::create(t, s); - case 3: return TransitionProgressHorizontal::create(t, s); - case 4: return TransitionProgressVertical::create(t, s); - case 5: return TransitionProgressInOut::create(t, s); - case 6: return TransitionProgressOutIn::create(t, s); - - case 7: return TransitionCrossFade::create(t,s); - - case 8: return PageTransitionForward::create(t, s); - case 9: return PageTransitionBackward::create(t, s); - case 10: return TransitionFadeTR::create(t, s); - case 11: return TransitionFadeBL::create(t, s); - case 12: return TransitionFadeUp::create(t, s); - case 13: return TransitionFadeDown::create(t, s); - - case 14: return TransitionTurnOffTiles::create(t, s); - - case 15: return TransitionSplitRows::create(t, s); - case 16: return TransitionSplitCols::create(t, s); - - case 17: return TransitionFade::create(t, s); - case 18: return FadeWhiteTransition::create(t, s); - - case 19: return FlipXLeftOver::create(t, s); - case 20: return FlipXRightOver::create(t, s); - case 21: return FlipYUpOver::create(t, s); - case 22: return FlipYDownOver::create(t, s); - case 23: return FlipAngularLeftOver::create(t, s); - case 24: return FlipAngularRightOver::create(t, s); - - case 25: return ZoomFlipXLeftOver::create(t, s); - case 26: return ZoomFlipXRightOver::create(t, s); - case 27: return ZoomFlipYUpOver::create(t, s); - case 28: return ZoomFlipYDownOver::create(t, s); - case 29: return ZoomFlipAngularLeftOver::create(t, s); - case 30: return ZoomFlipAngularRightOver::create(t, s); - - case 31: return TransitionShrinkGrow::create(t, s); - case 32: return TransitionRotoZoom::create(t, s); - - case 33: return TransitionMoveInL::create(t, s); - case 34: return TransitionMoveInR::create(t, s); - case 35: return TransitionMoveInT::create(t, s); - case 36: return TransitionMoveInB::create(t, s); - - case 37: return TransitionSlideInL::create(t, s); - case 38: return TransitionSlideInR::create(t, s); - case 39: return TransitionSlideInT::create(t, s); - case 40: return TransitionSlideInB::create(t, s); - - default: break; - } - - return NULL; -} + return transitions[index].function(t,s); +} void TransitionsTestScene::runThisTest() @@ -286,7 +266,7 @@ TestLayer1::TestLayer1(void) bg1->setPosition( Point(size.width/2, size.height/2) ); addChild(bg1, -1); - auto title = LabelTTF::create( (transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 ); + auto title = LabelTTF::create( (transitions[s_nSceneIdx]).name, "Thonburi", 32 ); addChild(title); title->setColor( Color3B(255,32,32) ); title->setPosition( Point(x/2, y-100) ); @@ -415,7 +395,7 @@ TestLayer2::TestLayer2() bg1->setPosition( Point(size.width/2, size.height/2) ); addChild(bg1, -1); - auto title = LabelTTF::create((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 ); + auto title = LabelTTF::create((transitions[s_nSceneIdx]).name, "Thonburi", 32 ); addChild(title); title->setColor( Color3B(255,32,32) ); title->setPosition( Point(x/2, y-100) ); diff --git a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.h b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.h index ccf7ba3100..c923409816 100644 --- a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.h +++ b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.h @@ -1,3 +1,28 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + #ifndef _TRANSITIONS_TEST_H_ #define _TRANSITIONS_TEST_H_ diff --git a/samples/Cpp/TestCpp/Classes/UnitTest/UnitTest.cpp b/samples/Cpp/TestCpp/Classes/UnitTest/UnitTest.cpp new file mode 100644 index 0000000000..5027ac3c43 --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/UnitTest/UnitTest.cpp @@ -0,0 +1,604 @@ +#include "UnitTest.h" + +// For ' < o > ' multiply test scene. + +static std::function createFunctions[] = { + CL(TemplateVectorTest), + CL(TemplateMapTest), + CL(ValueTest) +}; + +static int sceneIdx = -1; +static const int MAX_LAYER = (sizeof(createFunctions) / sizeof(createFunctions[0])); + +static Layer* nextAction() +{ + sceneIdx++; + sceneIdx = sceneIdx % MAX_LAYER; + + auto layer = (createFunctions[sceneIdx])(); + return layer; +} + +static Layer* backAction() +{ + sceneIdx--; + int total = MAX_LAYER; + if( sceneIdx < 0 ) + sceneIdx += total; + + auto layer = (createFunctions[sceneIdx])(); + return layer; +} + +static Layer* restartAction() +{ + auto layer = (createFunctions[sceneIdx])(); + return layer; +} + +void UnitTestScene::runThisTest() +{ + sceneIdx = -1; + addChild(nextAction()); + Director::getInstance()->replaceScene(this); +} + +void UnitTestDemo::onEnter() +{ + BaseTest::onEnter(); +} + +void UnitTestDemo::onExit() +{ + BaseTest::onExit(); +} + +std::string UnitTestDemo::title() const +{ + return "UnitTest"; +} + +std::string UnitTestDemo::subtitle() const +{ + return ""; +} + +void UnitTestDemo::restartCallback(Object* sender) +{ + auto s = new UnitTestScene(); + s->addChild( restartAction() ); + Director::getInstance()->replaceScene(s); + s->release(); +} + +void UnitTestDemo::nextCallback(Object* sender) +{ + auto s = new UnitTestScene(); + s->addChild( nextAction() ); + Director::getInstance()->replaceScene(s); + s->release(); +} + +void UnitTestDemo::backCallback(Object* sender) +{ + auto s = new UnitTestScene(); + s->addChild( backAction() ); + Director::getInstance()->replaceScene(s); + s->release(); +} + +//--------------------------------------------------------------- + +void TemplateVectorTest::onEnter() +{ + UnitTestDemo::onEnter(); + + Vector vec; + CCASSERT(vec.empty(), ""); + CCASSERT(vec.capacity() == 0, ""); + CCASSERT(vec.size() == 0, ""); + CCASSERT(vec.max_size() > 0, ""); + + auto node1 = Node::create(); + node1->setTag(1); + vec.pushBack(node1); + CCASSERT(node1->retainCount() == 2, ""); + + auto node2 = Node::create(); + node2->setTag(2); + vec.pushBack(node2); + CCASSERT(vec.getIndex(node1) == 0, ""); + CCASSERT(vec.getIndex(node2) == 1, ""); + + auto node3 = Node::create(); + node3->setTag(3); + vec.insert(1, node3); + CCASSERT(vec.at(0)->getTag() == 1, ""); + CCASSERT(vec.at(1)->getTag() == 3, ""); + CCASSERT(vec.at(2)->getTag() == 2, ""); + + // Test copy constructor + Vector vec2(vec); + CCASSERT(vec2.size() == vec.size(), ""); + ssize_t size = vec.size(); + for (ssize_t i = 0; i < size; ++i) + { + CCASSERT(vec2.at(i) == vec.at(i), ""); + CCASSERT(vec.at(i)->retainCount() == 3, ""); + CCASSERT(vec2.at(i)->retainCount() == 3, ""); + } + + // Test copy assignment operator + Vector vec3; + vec3 = vec2; + CCASSERT(vec3.size() == vec2.size(), ""); + size = vec3.size(); + for (ssize_t i = 0; i < size; ++i) + { + CCASSERT(vec3.at(i) == vec2.at(i), ""); + CCASSERT(vec3.at(i)->retainCount() == 4, ""); + CCASSERT(vec2.at(i)->retainCount() == 4, ""); + CCASSERT(vec.at(i)->retainCount() == 4, ""); + } + + // Test move constructor + + auto createVector = [this](){ + Vector ret; + + for (int i = 0; i < 20; i++) + { + ret.pushBack(Node::create()); + } + + int j = 1000; + for (auto& child : ret) + { + child->setTag(j++); + } + + return ret; + }; + + Vector vec4(createVector()); + for (const auto& child : vec4) + { + CCASSERT(child->retainCount() == 2, ""); + } + + // Test init Vector with capacity + Vector vec5(10); + CCASSERT(vec5.capacity() == 10, ""); + vec5.reserve(20); + CCASSERT(vec5.capacity() == 20, ""); + + CCASSERT(vec5.size() == 0, ""); + CCASSERT(vec5.empty(), ""); + + auto toRemovedNode = Node::create(); + vec5.pushBack(toRemovedNode); + CCASSERT(toRemovedNode->retainCount() == 2, ""); + + // Test move assignment operator + vec5 = createVector(); + CCASSERT(toRemovedNode->retainCount() == 1, ""); + CCASSERT(vec5.size() == 20, "size should be 20"); + + for (const auto& child : vec5) + { + CCASSERT(child->retainCount() == 2, ""); + } + + // Test Vector::find + CCASSERT(vec.find(node3) == (vec.begin() + 1), ""); + CCASSERT(std::find(std::begin(vec), std::end(vec), node2) == (vec.begin() + 2), ""); + + CCASSERT(vec.front()->getTag() == 1, ""); + CCASSERT(vec.back()->getTag() == 2, ""); + + CCASSERT(vec.getRandomObject(), ""); + CCASSERT(!vec.contains(Node::create()), ""); + CCASSERT(vec.contains(node1), ""); + CCASSERT(vec.contains(node2), ""); + CCASSERT(vec.contains(node3), ""); + CCASSERT(vec.equals(vec2), ""); + CCASSERT(vec.equals(vec3), ""); + + // Insert + vec5.insert(2, node1); + CCASSERT(vec5.at(2)->getTag() == 1, ""); + CCASSERT(vec5.size() == 21, ""); + vec5.back()->setTag(100); + vec5.popBack(); + CCASSERT(vec5.size() == 20, ""); + CCASSERT(vec5.back()->getTag() != 100, ""); + + // Erase and clear + Vector vec6 = createVector(); + Vector vec7 = vec6; // Copy for check + + CCASSERT(vec6.size() == 20, ""); + vec6.erase(vec6.begin() + 1); // + CCASSERT(vec6.size() == 19, ""); + CCASSERT((*(vec6.begin() + 1))->getTag() == 1002, ""); + vec6.erase(vec6.begin() + 2, vec6.begin() + 10); + CCASSERT(vec6.size() == 11, ""); + CCASSERT(vec6.at(0)->getTag() == 1000, ""); + CCASSERT(vec6.at(1)->getTag() == 1002, ""); + CCASSERT(vec6.at(2)->getTag() == 1011, ""); + CCASSERT(vec6.at(3)->getTag() == 1012, ""); + vec6.erase(3); + CCASSERT(vec6.at(3)->getTag() == 1013, ""); + vec6.eraseObject(vec6.at(2)); + CCASSERT(vec6.at(2)->getTag() == 1013, ""); + vec6.clear(); + + // Check the retain count in vec7 + CCASSERT(vec7.size() == 20, ""); + for (const auto& child : vec7) + { + CCASSERT(child->retainCount() == 2, ""); + } + + // Sort + Vector vecForSort = createVector(); + std::sort(vecForSort.begin(), vecForSort.end(), [](Node* a, Node* b){ + return a->getTag() >= b->getTag(); + }); + + for (int i = 0; i < 20; ++i) + { + CCASSERT(vecForSort.at(i)->getTag() - 1000 == (19 - i), ""); + } + + // Reverse + vecForSort.reverse(); + for (int i = 0; i < 20; ++i) + { + CCASSERT(vecForSort.at(i)->getTag() - 1000 == i, ""); + } + + // Swap + Vector vecForSwap = createVector(); + vecForSwap.swap(2, 4); + CCASSERT(vecForSwap.at(2)->getTag() == 1004, ""); + CCASSERT(vecForSwap.at(4)->getTag() == 1002, ""); + vecForSwap.swap(vecForSwap.at(2), vecForSwap.at(4)); + CCASSERT(vecForSwap.at(2)->getTag() == 1002, ""); + CCASSERT(vecForSwap.at(4)->getTag() == 1004, ""); + + // shrinkToFit + Vector vecForShrink = createVector(); + vecForShrink.reserve(100); + CCASSERT(vecForShrink.capacity() == 100, ""); + vecForShrink.pushBack(Node::create()); + vecForShrink.shrinkToFit(); + CCASSERT(vecForShrink.capacity() == 21, ""); + + // get random object + // Set the seed by time + srand(time(nullptr)); + Vector vecForRandom = createVector(); + log("<--- begin ---->"); + for (int i = 0; i < vecForRandom.size(); ++i) + { + log("Vector: random object tag = %d", vecForRandom.getRandomObject()->getTag()); + } + log("<---- end ---->"); + + // Self assignment + Vector vecSelfAssign = createVector(); + vecSelfAssign = vecSelfAssign; + CCASSERT(vecSelfAssign.size() == 20, ""); + + for (const auto& child : vecSelfAssign) + { + CCASSERT(child->retainCount() == 2, ""); + } + + vecSelfAssign = std::move(vecSelfAssign); + CCASSERT(vecSelfAssign.size() == 20, ""); + + for (const auto& child : vecSelfAssign) + { + CCASSERT(child->retainCount() == 2, ""); + } + + // const at + Vector vecConstAt = createVector(); + constFunc(vecConstAt); +} + +void TemplateVectorTest::constFunc(const Vector& vec) const +{ + log("vec[8] = %d", vec.at(8)->getTag()); +} + +std::string TemplateVectorTest::subtitle() const +{ + return "Vector, should not crash"; +} + + +//--------------------------------------------------------------- + +void TemplateMapTest::onEnter() +{ + UnitTestDemo::onEnter(); + + auto createMap = [this](){ + Map ret; + for (int i = 0; i < 20; ++i) + { + auto node = Node::create(); + node->setTag(1000 + i); + ret.insert(StringUtils::toString(i), node); + } + + return ret; + }; + + // Default constructor + Map map1; + CCASSERT(map1.empty(), ""); + CCASSERT(map1.size() == 0, ""); + CCASSERT(map1.keys().empty(), ""); + CCASSERT(map1.keys(Node::create()).empty(), ""); + + // Move constructor + Map map2 = createMap(); + for (const auto& e : map2) + { + CCASSERT(e.second->retainCount() == 2, ""); + } + + // Copy constructor + Map map3(map2); + for (const auto& e : map3) + { + CCASSERT(e.second->retainCount() == 3, ""); + } + + // Move assignment operator + Map map4; + auto unusedNode = Node::create(); + map4.insert("unused",unusedNode); + map4 = createMap(); + CCASSERT(unusedNode->retainCount() == 1, ""); + for (const auto& e : map4) + { + CCASSERT(e.second->retainCount() == 2, ""); + } + + // Copy assignment operator + Map map5; + map5 = map4; + for (const auto& e : map5) + { + CCASSERT(e.second->retainCount() == 3, ""); + } + + // Check size + CCASSERT(map4.size() == map5.size(), ""); + + for (const auto& e : map4) + { + CCASSERT(e.second == map5.find(e.first)->second, ""); + } + + // bucket_count, bucket_size(n), bucket + log("--------------"); + log("bucket_count = %d", static_cast(map4.bucketCount())); + log("size = %d", static_cast(map4.size())); + for (int i = 0; i < map4.bucketCount(); ++i) + { + log("bucket_size(%d) = %d", i, static_cast(map4.bucketSize(i))); + } + for (const auto& e : map4) + { + log("bucket(\"%s\"), bucket index = %d", e.first.c_str(), static_cast(map4.bucket(e.first))); + } + + log("----- all keys---------"); + + // keys and at + auto keys = map4.keys(); + for (const auto& key : keys) + { + log("key = %s", key.c_str()); + } + + auto node10Key = map4.at("10"); + map4.insert("100", node10Key); + map4.insert("101", node10Key); + map4.insert("102", node10Key); + + log("------ keys for object --------"); + auto keysForObject = map4.keys(node10Key); + for (const auto& key : keysForObject) + { + log("key = %s", key.c_str()); + } + log("--------------"); + + // at in const function + constFunc(map4); + + // find + auto nodeToFind = map4.find("10"); + CCASSERT(nodeToFind->second->getTag() == 1010, ""); + + // insert + Map map6; + auto node1 = Node::create(); + node1->setTag(101); + auto node2 = Node::create(); + node2->setTag(102); + auto node3 = Node::create(); + node3->setTag(103); + map6.insert("insert01", node1); + map6.insert("insert02", node2); + map6.insert("insert03", node3); + + CCASSERT(node1->retainCount() == 2, ""); + CCASSERT(node2->retainCount() == 2, ""); + CCASSERT(node3->retainCount() == 2, ""); + CCASSERT(map6.at("insert01") == node1, ""); + CCASSERT(map6.at("insert02") == node2, ""); + CCASSERT(map6.at("insert03") == node3, ""); + + // erase + Map mapForErase = createMap(); + mapForErase.erase(mapForErase.find("9")); + CCASSERT(mapForErase.find("9") == mapForErase.end(), ""); + CCASSERT(mapForErase.size() == 19, ""); + + mapForErase.erase("7"); + CCASSERT(mapForErase.find("7") == mapForErase.end(), ""); + CCASSERT(mapForErase.size() == 18, ""); + + std::vector itemsToRemove; + itemsToRemove.push_back("2"); + itemsToRemove.push_back("3"); + itemsToRemove.push_back("4"); + mapForErase.erase(itemsToRemove); + CCASSERT(mapForErase.size() == 15, ""); + + // clear + Map mapForClear = createMap(); + auto mapForClearCopy = mapForClear; + mapForClear.clear(); + + for (const auto& e : mapForClearCopy) + { + CCASSERT(e.second->retainCount() == 2, ""); + } + + // get random object + // Set the seed by time + srand(time(nullptr)); + Map mapForRandom = createMap(); + log("<--- begin ---->"); + for (int i = 0; i < mapForRandom.size(); ++i) + { + log("Map: random object tag = %d", mapForRandom.getRandomObject()->getTag()); + } + log("<---- end ---->"); + + // Self assignment + Map mapForSelfAssign = createMap(); + mapForSelfAssign = mapForSelfAssign; + CCASSERT(mapForSelfAssign.size() == 20, ""); + + for (const auto& e : mapForSelfAssign) + { + CCASSERT(e.second->retainCount() == 2, ""); + } + + mapForSelfAssign = std::move(mapForSelfAssign); + CCASSERT(mapForSelfAssign.size() == 20, ""); + + for (const auto& e : mapForSelfAssign) + { + CCASSERT(e.second->retainCount() == 2, ""); + } +} + +void TemplateMapTest::constFunc(const Map& map) const +{ + log("[%s]=(tag)%d", "0", map.at("0")->getTag()); + log("[%s]=(tag)%d", "1", map.find("1")->second->getTag()); +} + +std::string TemplateMapTest::subtitle() const +{ + return "Map, should not crash"; +} + +//---------------------------------- + +void ValueTest::onEnter() +{ + UnitTestDemo::onEnter(); + + Value v1; + CCASSERT(v1.getType() == Value::Type::NONE, ""); + CCASSERT(v1.isNull(), ""); + + Value v2(100); + CCASSERT(v2.getType() == Value::Type::INTEGER, ""); + CCASSERT(!v2.isNull(), ""); + + Value v3(101.4f); + CCASSERT(v3.getType() == Value::Type::FLOAT, ""); + CCASSERT(!v3.isNull(), ""); + + Value v4(106.1); + CCASSERT(v4.getType() == Value::Type::DOUBLE, ""); + CCASSERT(!v4.isNull(), ""); + + unsigned char byte = 50; + Value v5(byte); + CCASSERT(v5.getType() == Value::Type::BYTE, ""); + CCASSERT(!v5.isNull(), ""); + + Value v6(true); + CCASSERT(v6.getType() == Value::Type::BOOLEAN, ""); + CCASSERT(!v6.isNull(), ""); + + Value v7("string"); + CCASSERT(v7.getType() == Value::Type::STRING, ""); + CCASSERT(!v7.isNull(), ""); + + Value v8(std::string("string2")); + CCASSERT(v8.getType() == Value::Type::STRING, ""); + CCASSERT(!v8.isNull(), ""); + + auto createValueVector = [&](){ + ValueVector ret; + ret.push_back(v1); + ret.push_back(v2); + ret.push_back(v3); + return ret; + }; + + + Value v9(createValueVector()); + CCASSERT(v9.getType() == Value::Type::VECTOR, ""); + CCASSERT(!v9.isNull(), ""); + + auto createValueMap = [&](){ + ValueMap ret; + ret["aaa"] = v1; + ret["bbb"] = v2; + ret["ccc"] = v3; + return ret; + }; + + Value v10(createValueMap()); + CCASSERT(v10.getType() == Value::Type::MAP, ""); + CCASSERT(!v10.isNull(), ""); + + auto createValueMapIntKey = [&](){ + ValueMapIntKey ret; + ret[111] = v1; + ret[222] = v2; + ret[333] = v3; + return ret; + }; + + Value v11(createValueMapIntKey()); + CCASSERT(v11.getType() == Value::Type::INT_KEY_MAP, ""); + CCASSERT(!v11.isNull(), ""); +} + +std::string ValueTest::subtitle() const +{ + return "Value Test, should not crash"; +} + +void ValueTest::constFunc(const Value& value) const +{ + +} diff --git a/samples/Cpp/TestCpp/Classes/UnitTest/UnitTest.h b/samples/Cpp/TestCpp/Classes/UnitTest/UnitTest.h new file mode 100644 index 0000000000..f969b11249 --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/UnitTest/UnitTest.h @@ -0,0 +1,56 @@ +#ifndef __UNIT_TEST__ +#define __UNIT_TEST__ + +#include "../testBasic.h" +#include "../BaseTest.h" + +class UnitTestScene : public TestScene +{ +public: + virtual void runThisTest() override; +}; + +class UnitTestDemo : public BaseTest +{ +public: + virtual void onEnter() override; + virtual void onExit() override; + + virtual std::string title() const override; + virtual std::string subtitle() const override; + + virtual void restartCallback(Object* sender) override; + virtual void nextCallback(Object* sender) override; + virtual void backCallback(Object* sender) override; +}; + +//------------------------------------- + +class TemplateVectorTest : public UnitTestDemo +{ +public: + CREATE_FUNC(TemplateVectorTest); + virtual void onEnter() override; + virtual std::string subtitle() const override; + void constFunc(const Vector& vec) const; +}; + +class TemplateMapTest : public UnitTestDemo +{ +public: + CREATE_FUNC(TemplateMapTest); + virtual void onEnter() override; + virtual std::string subtitle() const override; + void constFunc(const Map& map) const; +}; + +class ValueTest : public UnitTestDemo +{ +public: + CREATE_FUNC(ValueTest); + virtual void onEnter() override; + virtual std::string subtitle() const override; + void constFunc(const Value& value) const; +}; + +#endif /* __UNIT_TEST__ */ diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp index 9051e1cd46..750ba02a9f 100644 --- a/samples/Cpp/TestCpp/Classes/controller.cpp +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -19,6 +19,7 @@ struct { // TESTS MUST BE ORDERED ALPHABETICALLY // violators will be prosecuted // + { "AUnitTest", []() { return new UnitTestScene(); }}, { "ANewRenderTest", []() { return new NewRendererTestScene(); } }, { "Accelerometer", []() { return new AccelerometerTestScene(); } }, { "ActionManagerTest", [](){return new ActionManagerTestScene(); } }, diff --git a/samples/Cpp/TestCpp/Classes/testBasic.h b/samples/Cpp/TestCpp/Classes/testBasic.h index fe00736d5d..2062ca2857 100644 --- a/samples/Cpp/TestCpp/Classes/testBasic.h +++ b/samples/Cpp/TestCpp/Classes/testBasic.h @@ -18,5 +18,6 @@ public: // C++ 11 #define CL(__className__) [](){ return __className__::create();} +#define CLN(__className__) [](){ auto obj = new __className__(); obj->autorelease(); return obj; } #endif diff --git a/samples/Cpp/TestCpp/Classes/tests.h b/samples/Cpp/TestCpp/Classes/tests.h index d104a894d4..d030ae34f3 100644 --- a/samples/Cpp/TestCpp/Classes/tests.h +++ b/samples/Cpp/TestCpp/Classes/tests.h @@ -1,6 +1,7 @@ #ifndef _TESTS_H_ #define _TESTS_H_ +#include "UnitTest/UnitTest.h" #include "NewRendererTest/NewRendererTest.h" #include "ConsoleTest/ConsoleTest.h" #include "NewEventDispatcherTest/NewEventDispatcherTest.h" diff --git a/samples/Cpp/TestCpp/Resources/scenetest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/ArmatureComponentTest/Images/startMenuBG.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/Images/startMenuBG.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/ArmatureComponentTest/Images/startMenuBG.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/ArmatureComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/hd/scenetest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/ArmatureComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/fishes/blowFish/Blowfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/ArmatureComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/hd/scenetest/fishes/blowFish/Blowfish0.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/ArmatureComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/Images/startMenuBG.png.REMOVED.git-id new file mode 100644 index 0000000000..ab08309b7e --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/Images/startMenuBG.png.REMOVED.git-id @@ -0,0 +1 @@ +5d84575ee663bd1c3d56b7501b6183302afb62e2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/Misc/music_logo.mp3.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/Misc/music_logo.mp3.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/hd/scenetest/Misc/music_logo.mp3.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/Misc/music_logo.mp3.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/Misc/music_logo.wav.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/Misc/music_logo.wav.REMOVED.git-id new file mode 100644 index 0000000000..709b2d86c0 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/Misc/music_logo.wav.REMOVED.git-id @@ -0,0 +1 @@ +48e8461c309cb59d5610805d9774e64c22468263 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/startMenu/Fish_UI/starMenuButton01.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/startMenu/Fish_UI/starMenuButton01.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/hd/scenetest/startMenu/Fish_UI/starMenuButton01.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/startMenu/Fish_UI/starMenuButton01.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/startMenu/Fish_UI/starMenuButton02.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/startMenu/Fish_UI/starMenuButton02.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/hd/scenetest/startMenu/Fish_UI/starMenuButton02.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/startMenu/Fish_UI/starMenuButton02.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/hd/scenetest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/BackgroundComponentTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/EffectComponentTest/CowBoy/Cowboy.ExportJson.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/EffectComponentTest/CowBoy/Cowboy.ExportJson.REMOVED.git-id new file mode 100644 index 0000000000..4dd0da7eee --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/EffectComponentTest/CowBoy/Cowboy.ExportJson.REMOVED.git-id @@ -0,0 +1 @@ +434a36b3e7fa9c849986cf6128b7d4402a382eb7 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/EffectComponentTest/CowBoy/Cowboy0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/EffectComponentTest/CowBoy/Cowboy0.png.REMOVED.git-id new file mode 100644 index 0000000000..1ab13aff50 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/EffectComponentTest/CowBoy/Cowboy0.png.REMOVED.git-id @@ -0,0 +1 @@ +06fb5524ddc56e1aaa5872fae8b646a97345f6fe \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/Images/startMenuBG.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/hd/scenetest/Images/startMenuBG.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/Images/startMenuBG.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/scenetest/Misc/music_logo.mp3.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.mp3.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/Misc/music_logo.mp3.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.mp3.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.wav.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.wav.REMOVED.git-id new file mode 100644 index 0000000000..709b2d86c0 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.wav.REMOVED.git-id @@ -0,0 +1 @@ +48e8461c309cb59d5610805d9774e64c22468263 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/scenetest/fishes/blowFish/Blowfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/fishes/blowFish/Blowfish0.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/starMenuButton01.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/starMenuButton01.png.REMOVED.git-id new file mode 100644 index 0000000000..607f8adcb9 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/starMenuButton01.png.REMOVED.git-id @@ -0,0 +1 @@ +c6b8f5b59f6d563cef4a4eba19985716ff1e1f6e \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/starMenuButton02.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/starMenuButton02.png.REMOVED.git-id new file mode 100644 index 0000000000..958d03a9c2 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/starMenuButton02.png.REMOVED.git-id @@ -0,0 +1 @@ +db7f2b0850ff959c24ceca59bcae78b1afcb4c80 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..22c8929ad6 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +9a5e05761c2f6db85e7cd8f3dcf1932b6b6eb2d8 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/TriggerTest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/TriggerTest/Images/startMenuBG.png.REMOVED.git-id new file mode 100644 index 0000000000..ab08309b7e --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/TriggerTest/Images/startMenuBG.png.REMOVED.git-id @@ -0,0 +1 @@ +5d84575ee663bd1c3d56b7501b6183302afb62e2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/TriggerTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/TriggerTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..13d9610346 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/TriggerTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +e22c64c159404622ff93915eb9f01be011001dac \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/TriggerTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/TriggerTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..d35dbb70ac --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/TriggerTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +d7d85cd75e382c2dd04ddc34ca1d07e2ffff66d5 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/UIComponentTest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/UIComponentTest/Images/startMenuBG.png.REMOVED.git-id new file mode 100644 index 0000000000..ab08309b7e --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/UIComponentTest/Images/startMenuBG.png.REMOVED.git-id @@ -0,0 +1 @@ +5d84575ee663bd1c3d56b7501b6183302afb62e2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/UIComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/UIComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..13d9610346 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/UIComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +e22c64c159404622ff93915eb9f01be011001dac \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/scenetest/UIComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/scenetest/UIComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..d35dbb70ac --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/scenetest/UIComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +d7d85cd75e382c2dd04ddc34ca1d07e2ffff66d5 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/ArmatureComponentTest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/ArmatureComponentTest/Images/startMenuBG.png.REMOVED.git-id new file mode 100644 index 0000000000..ab08309b7e --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/ArmatureComponentTest/Images/startMenuBG.png.REMOVED.git-id @@ -0,0 +1 @@ +5d84575ee663bd1c3d56b7501b6183302afb62e2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/ArmatureComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/ArmatureComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..13d9610346 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/ArmatureComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +e22c64c159404622ff93915eb9f01be011001dac \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/ArmatureComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/ArmatureComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..d35dbb70ac --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/ArmatureComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +d7d85cd75e382c2dd04ddc34ca1d07e2ffff66d5 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/Images/startMenuBG.png.REMOVED.git-id new file mode 100644 index 0000000000..ab08309b7e --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/Images/startMenuBG.png.REMOVED.git-id @@ -0,0 +1 @@ +5d84575ee663bd1c3d56b7501b6183302afb62e2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/Misc/music_logo.mp3.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/Misc/music_logo.mp3.REMOVED.git-id new file mode 100644 index 0000000000..604b21ac01 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/Misc/music_logo.mp3.REMOVED.git-id @@ -0,0 +1 @@ +4b2aa3f3fbf2f96bced91d0da0e8fc2f7f863a61 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/Misc/music_logo.wav.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/Misc/music_logo.wav.REMOVED.git-id new file mode 100644 index 0000000000..709b2d86c0 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/Misc/music_logo.wav.REMOVED.git-id @@ -0,0 +1 @@ +48e8461c309cb59d5610805d9774e64c22468263 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/scenetest/BackgroundComponentTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/scenetest/EffectComponentTest/CowBoy/Cowboy.ExportJson.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/EffectComponentTest/CowBoy/Cowboy.ExportJson.REMOVED.git-id new file mode 100644 index 0000000000..4dd0da7eee --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/EffectComponentTest/CowBoy/Cowboy.ExportJson.REMOVED.git-id @@ -0,0 +1 @@ +434a36b3e7fa9c849986cf6128b7d4402a382eb7 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/EffectComponentTest/CowBoy/Cowboy0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/EffectComponentTest/CowBoy/Cowboy0.png.REMOVED.git-id new file mode 100644 index 0000000000..d2c12af0e0 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/EffectComponentTest/CowBoy/Cowboy0.png.REMOVED.git-id @@ -0,0 +1 @@ +2b61d3b005b4076c5ff22a78a00822c0f0dc0875 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Images/startMenuBG.png.REMOVED.git-id new file mode 100644 index 0000000000..ab08309b7e --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Images/startMenuBG.png.REMOVED.git-id @@ -0,0 +1 @@ +5d84575ee663bd1c3d56b7501b6183302afb62e2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.mp3.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.mp3.REMOVED.git-id new file mode 100644 index 0000000000..604b21ac01 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.mp3.REMOVED.git-id @@ -0,0 +1 @@ +4b2aa3f3fbf2f96bced91d0da0e8fc2f7f863a61 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.wav.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.wav.REMOVED.git-id new file mode 100644 index 0000000000..709b2d86c0 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.wav.REMOVED.git-id @@ -0,0 +1 @@ +48e8461c309cb59d5610805d9774e64c22468263 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..13d9610346 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +e22c64c159404622ff93915eb9f01be011001dac \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..d35dbb70ac --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +d7d85cd75e382c2dd04ddc34ca1d07e2ffff66d5 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..e303572866 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +d9c89ed8831db643cc80a0651e5398e26861bbd0 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/TriggerTest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/TriggerTest/Images/startMenuBG.png.REMOVED.git-id new file mode 100644 index 0000000000..ab08309b7e --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/TriggerTest/Images/startMenuBG.png.REMOVED.git-id @@ -0,0 +1 @@ +5d84575ee663bd1c3d56b7501b6183302afb62e2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/TriggerTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/TriggerTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..13d9610346 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/TriggerTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +e22c64c159404622ff93915eb9f01be011001dac \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/TriggerTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/TriggerTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..d35dbb70ac --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/TriggerTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +d7d85cd75e382c2dd04ddc34ca1d07e2ffff66d5 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/UIComponentTest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/UIComponentTest/Images/startMenuBG.png.REMOVED.git-id new file mode 100644 index 0000000000..ab08309b7e --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/UIComponentTest/Images/startMenuBG.png.REMOVED.git-id @@ -0,0 +1 @@ +5d84575ee663bd1c3d56b7501b6183302afb62e2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/UIComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/UIComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..13d9610346 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/UIComponentTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +e22c64c159404622ff93915eb9f01be011001dac \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/scenetest/UIComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/UIComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id new file mode 100644 index 0000000000..d35dbb70ac --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/scenetest/UIComponentTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id @@ -0,0 +1 @@ +d7d85cd75e382c2dd04ddc34ca1d07e2ffff66d5 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/proj.android/AndroidManifest.xml b/samples/Cpp/TestCpp/proj.android/AndroidManifest.xml index c88f0dce5c..48c245c963 100644 --- a/samples/Cpp/TestCpp/proj.android/AndroidManifest.xml +++ b/samples/Cpp/TestCpp/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Cpp/TestCpp/proj.linux/.cproject b/samples/Cpp/TestCpp/proj.linux/.cproject deleted file mode 100644 index 66a12db761..0000000000 --- a/samples/Cpp/TestCpp/proj.linux/.cproject +++ /dev/null @@ -1,429 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/Cpp/TestCpp/proj.linux/.project b/samples/Cpp/TestCpp/proj.linux/.project deleted file mode 100644 index 41bd136722..0000000000 --- a/samples/Cpp/TestCpp/proj.linux/.project +++ /dev/null @@ -1,142 +0,0 @@ - - - TestCpp - - - libBox2D - libChipmunk - libcocos2d - libCocosDenshion - libextension - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/TestCpp/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - Classes - 2 - PARENT-1-PROJECT_LOC/Classes - - - extensions - 2 - PARENT-4-PROJECT_LOC/extensions - - - - - 1373359140703 - - 22 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-WebSocket* - - - - 1345105423456 - extensions - 10 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-true-false-proj.win32 - - - - 1345106176896 - Classes/ExtensionsTest - 10 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-true-false-EditBoxTest - - - - 1345105383081 - extensions/GUI - 10 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-true-false-CCEditBox - - - - diff --git a/samples/Cpp/TestCpp/proj.linux/Makefile b/samples/Cpp/TestCpp/proj.linux/Makefile deleted file mode 100644 index da31571fb0..0000000000 --- a/samples/Cpp/TestCpp/proj.linux/Makefile +++ /dev/null @@ -1,174 +0,0 @@ -EXECUTABLE = TestCpp - -DEFINES += -DCC_KEYBOARD_SUPPORT - -INCLUDES = -I../../../../external \ - -I../../../../cocos/editor-support \ - -I../../../../cocos \ - -I../Classes - -SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ - ../Classes/ActionManagerTest/ActionManagerTest.cpp \ - ../Classes/ActionsEaseTest/ActionsEaseTest.cpp \ - ../Classes/ActionsProgressTest/ActionsProgressTest.cpp \ - ../Classes/ActionsTest/ActionsTest.cpp \ - ../Classes/Box2DTest/Box2dTest.cpp \ - ../Classes/Box2DTestBed/Box2dView.cpp \ - ../Classes/Box2DTestBed/GLES-Render.cpp \ - ../Classes/Box2DTestBed/Test.cpp \ - ../Classes/Box2DTestBed/TestEntries.cpp \ - ../Classes/BugsTest/Bug-1159.cpp \ - ../Classes/BugsTest/Bug-1174.cpp \ - ../Classes/BugsTest/Bug-350.cpp \ - ../Classes/BugsTest/Bug-422.cpp \ - ../Classes/BugsTest/Bug-458/Bug-458.cpp \ - ../Classes/BugsTest/Bug-458/QuestionContainerSprite.cpp \ - ../Classes/BugsTest/Bug-624.cpp \ - ../Classes/BugsTest/Bug-886.cpp \ - ../Classes/BugsTest/Bug-899.cpp \ - ../Classes/BugsTest/Bug-914.cpp \ - ../Classes/BugsTest/BugsTest.cpp \ - ../Classes/ChipmunkTest/ChipmunkTest.cpp \ - ../Classes/ClickAndMoveTest/ClickAndMoveTest.cpp \ - ../Classes/ClippingNodeTest/ClippingNodeTest.cpp \ - ../Classes/CocosDenshionTest/CocosDenshionTest.cpp \ - ../Classes/CurlTest/CurlTest.cpp \ - ../Classes/CurrentLanguageTest/CurrentLanguageTest.cpp \ - ../Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp \ - ../Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp \ - ../Classes/EffectsTest/EffectsTest.cpp \ - ../Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \ - ../Classes/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ - ../Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp \ - ../Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp \ - ../Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \ - ../Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \ - ../Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp \ - ../Classes/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp \ - ../Classes/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp \ - ../Classes/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp \ - ../Classes/ExtensionsTest/ControlExtensionTest/CCControlSceneManager.cpp \ - ../Classes/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \ - ../Classes/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \ - ../Classes/ExtensionsTest/ControlExtensionTest/CCControlPotentiometerTest/CCControlPotentiometerTest.cpp \ - ../Classes/ExtensionsTest/ControlExtensionTest/CCControlStepperTest/CCControlStepperTest.cpp \ - ../Classes/ExtensionsTest/TableViewTest/TableViewTestScene.cpp \ - ../Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp \ - ../Classes/ExtensionsTest/ExtensionsTest.cpp \ - ../Classes/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp \ - ../Classes/ExtensionsTest/NetworkTest/HttpClientTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp \ - ../Classes/ExtensionsTest/CocoStudioComponentsTest/ComponentsTestScene.cpp \ - ../Classes/ExtensionsTest/CocoStudioComponentsTest/EnemyController.cpp \ - ../Classes/ExtensionsTest/CocoStudioComponentsTest/GameOverScene.cpp \ - ../Classes/ExtensionsTest/CocoStudioComponentsTest/PlayerController.cpp \ - ../Classes/ExtensionsTest/CocoStudioComponentsTest/ProjectileController.cpp \ - ../Classes/ExtensionsTest/CocoStudioComponentsTest/SceneController.cpp \ - ../Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UIScene.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UISceneManager.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UIDragPanelTest/UIDragPanelTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UILabelAtlasTest/UILabelAtlasTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UILabelBMFontTest/UILabelBMFontTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UILabelTest/UILabelTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UIListViewTest/UIListViewTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UINodeContainerTest/UINodeContainerTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UIPageViewTest/UIPageViewTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UIPanelTest/UIPanelTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UIScrollViewTest/UIScrollViewTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UITextAreaTest/UITextAreaTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UITextButtonTest/UITextButtonTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp \ - ../Classes/ExtensionsTest/CocoStudioGUITest/CocosGUIScene.cpp \ - ../Classes/ExtensionsTest/Scale9SpriteTest/Scale9SpriteTest.cpp \ - ../Classes/NewEventDispatcherTest/NewEventDispatcherTest.cpp \ - ../Classes/FontTest/FontTest.cpp \ - ../Classes/IntervalTest/IntervalTest.cpp \ - ../Classes/KeyboardTest/KeyboardTest.cpp \ - ../Classes/InputTest/MouseTest.cpp \ - ../Classes/KeypadTest/KeypadTest.cpp \ - ../Classes/LabelTest/LabelTest.cpp \ - ../Classes/LabelTest/LabelTestNew.cpp \ - ../Classes/LayerTest/LayerTest.cpp \ - ../Classes/MenuTest/MenuTest.cpp \ - ../Classes/MotionStreakTest/MotionStreakTest.cpp \ - ../Classes/MutiTouchTest/MutiTouchTest.cpp \ - ../Classes/NodeTest/NodeTest.cpp \ - ../Classes/ParallaxTest/ParallaxTest.cpp \ - ../Classes/ParticleTest/ParticleTest.cpp \ - ../Classes/PerformanceTest/PerformanceAllocTest.cpp \ - ../Classes/PerformanceTest/PerformanceNodeChildrenTest.cpp \ - ../Classes/PerformanceTest/PerformanceParticleTest.cpp \ - ../Classes/PerformanceTest/PerformanceSpriteTest.cpp \ - ../Classes/PerformanceTest/PerformanceTest.cpp \ - ../Classes/PerformanceTest/PerformanceTextureTest.cpp \ - ../Classes/PerformanceTest/PerformanceTouchesTest.cpp \ - ../Classes/PhysicsTest/PhysicsTest.cpp \ - ../Classes/RenderTextureTest/RenderTextureTest.cpp \ - ../Classes/RotateWorldTest/RotateWorldTest.cpp \ - ../Classes/SceneTest/SceneTest.cpp \ - ../Classes/SchedulerTest/SchedulerTest.cpp \ - ../Classes/ShaderTest/ShaderTest.cpp \ - ../Classes/ShaderTest/ShaderTest2.cpp \ - ../Classes/SpriteTest/SpriteTest.cpp \ - ../Classes/TextInputTest/TextInputTest.cpp \ - ../Classes/Texture2dTest/Texture2dTest.cpp \ - ../Classes/TexturePackerEncryptionTest/TextureAtlasEncryptionTest.cpp \ - ../Classes/TextureCacheTest/TextureCacheTest.cpp \ - ../Classes/TileMapTest/TileMapTest.cpp \ - ../Classes/TouchesTest/Ball.cpp \ - ../Classes/TouchesTest/Paddle.cpp \ - ../Classes/TouchesTest/TouchesTest.cpp \ - ../Classes/TransitionsTest/TransitionsTest.cpp \ - ../Classes/UserDefaultTest/UserDefaultTest.cpp \ - ../Classes/ZwoptexTest/ZwoptexTest.cpp \ - ../Classes/FileUtilsTest/FileUtilsTest.cpp \ - ../Classes/SpineTest/SpineTest.cpp \ - ../Classes/DataVisitorTest/DataVisitorTest.cpp \ - ../Classes/ConfigurationTest/ConfigurationTest.cpp \ - ../Classes/controller.cpp \ - ../Classes/testBasic.cpp \ - ../Classes/AppDelegate.cpp \ - ../Classes/BaseTest.cpp \ - ../Classes/VisibleRect.cpp \ - main.cpp - -SHAREDLIBS = -lcocos2d -lcocosdenshion -lcurl -lpng -COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so - - -include ../../../../cocos/2d/cocos2dx.mk - -STATICLIBS += \ - $(STATICLIBS_DIR)/curl/prebuilt/linux/$(POSTFIX)/libcurl.a \ - $(LIB_DIR)/libextension.a \ - $(LIB_DIR)/libbox2d.a \ - $(LIB_DIR)/libchipmunk.a \ - $(LIB_DIR)/libgui.a \ - $(LIB_DIR)/libcocosbuilder.a \ - $(LIB_DIR)/libspine.a \ - $(LIB_DIR)/libcocostudio.a \ - $(LIB_DIR)/libnetwork.a - -####### Build rules -$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) - -####### Compile -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ - -$(OBJ_DIR)/%.o: %.c $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CC)$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@ diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj index b69b1f411b..2815c3c7f3 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj @@ -168,6 +168,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ + + @@ -189,6 +191,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ + @@ -310,6 +313,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ + + + @@ -330,6 +336,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ + diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters index a5f386187d..a6990872b6 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters @@ -301,6 +301,12 @@ {c4dbbfb3-0e91-492f-bbbf-f03fb26f3f54} + + {1821914f-c088-4946-8c1e-19ab57b5eabc} + + + {5ff3af4e-0610-480b-b297-8f407e12f369} + @@ -624,9 +630,6 @@ Classes\ExtensionsTest\CocoStudioComponentsTest - - Classes\ExtensionsTest\CocoStudioSceneTest - Classes\NewEventDispatcherTest @@ -700,6 +703,18 @@ Classes\ExtensionsTest\CocoStudioGUITest\UILayoutTest + + Classes\UnitTest + + + Classes\ExtensionsTest\CocoStudioSceneTest + + + Classes\ExtensionsTest\CocoStudioSceneTest\TriggerCode + + + Classes\ExtensionsTest\CocoStudioSceneTest\TriggerCode + @@ -1200,9 +1215,6 @@ Classes\ExtensionsTest\CocoStudioComponentsTest - - Classes\ExtensionsTest\CocoStudioSceneTest - Classes\NewEventDispatcherTest @@ -1291,5 +1303,20 @@ Classes\ExtensionsTest\CocoStudioGUITest\UILayoutTest + + Classes\UnitTest + + + Classes\ExtensionsTest\CocoStudioSceneTest + + + Classes\ExtensionsTest\CocoStudioSceneTest\TriggerCode + + + Classes\ExtensionsTest\CocoStudioSceneTest\TriggerCode + + + Classes\ExtensionsTest\CocoStudioSceneTest\TriggerCode + \ No newline at end of file diff --git a/samples/Javascript/CocosDragonJS/proj.android/AndroidManifest.xml b/samples/Javascript/CocosDragonJS/proj.android/AndroidManifest.xml index d68537fcf2..fb10a9db77 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/AndroidManifest.xml +++ b/samples/Javascript/CocosDragonJS/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Javascript/CrystalCraze/proj.android/AndroidManifest.xml b/samples/Javascript/CrystalCraze/proj.android/AndroidManifest.xml index 8a38988fae..3917dd65f4 100644 --- a/samples/Javascript/CrystalCraze/proj.android/AndroidManifest.xml +++ b/samples/Javascript/CrystalCraze/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Javascript/MoonWarriors/proj.android/AndroidManifest.xml b/samples/Javascript/MoonWarriors/proj.android/AndroidManifest.xml index f61fe3e0db..59eba07645 100644 --- a/samples/Javascript/MoonWarriors/proj.android/AndroidManifest.xml +++ b/samples/Javascript/MoonWarriors/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index 0da7de9714..d5d37f513a 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -48,10 +48,42 @@ bool AppDelegate::applicationDidFinishLaunching() // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); - FileUtils::getInstance()->addSearchPath("res"); - FileUtils::getInstance()->addSearchPath("script"); - FileUtils::getInstance()->addSearchPath("res/scenetest"); + auto fileUtils = FileUtils::getInstance(); + std::vector searchPaths; + searchPaths.push_back("script"); + const char* paths[] = { + "res", + "res/scenetest", + "res/scenetest/ArmatureComponentTest", + "res/scenetest/AttributeComponentTest", + "res/scenetest/BackgroundComponentTest", + "res/scenetest/EffectComponentTest", + "res/scenetest/LoadSceneEdtiorFileTest", + "res/scenetest/ParticleComponentTest", + "res/scenetest/SpriteComponentTest", + "res/scenetest/TmxMapComponentTest", + "res/scenetest/UIComponentTest", + "res/scenetest/TriggerTest", + }; + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + std::string testFolder = "tests/"; + searchPaths.push_back(testFolder); + + for (const auto& path : paths) + { + searchPaths.push_back(testFolder + path); + } +#else + for (const auto& path : paths) + { + searchPaths.push_back(path); + } +#endif + + fileUtils->setSearchPaths(searchPaths); + ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); sc->addRegisterCallback(register_all_cocos2dx_extension); diff --git a/samples/Javascript/TestJavascript/proj.android/AndroidManifest.xml b/samples/Javascript/TestJavascript/proj.android/AndroidManifest.xml index 7beabd487a..4949d888fd 100644 --- a/samples/Javascript/TestJavascript/proj.android/AndroidManifest.xml +++ b/samples/Javascript/TestJavascript/proj.android/AndroidManifest.xml @@ -12,7 +12,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj b/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj index bb12af0fb5..e3be6f4245 100644 --- a/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj +++ b/samples/Javascript/TestJavascript/proj.win32/TestJavascript.vcxproj @@ -237,6 +237,9 @@ xcopy "$(ProjectDir)..\..\Shared\tests" "$(OutDir)\TestJavascriptRes\" /e /Y {39379840-825a-45a0-b363-c09ffef864bd} + + {e78cdc6b-f37d-48d2-ad91-1db549497e32} + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} diff --git a/samples/Javascript/WatermelonWithMe/proj.android/AndroidManifest.xml b/samples/Javascript/WatermelonWithMe/proj.android/AndroidManifest.xml index 6bbdd131cb..2f6da28f49 100644 --- a/samples/Javascript/WatermelonWithMe/proj.android/AndroidManifest.xml +++ b/samples/Javascript/WatermelonWithMe/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Lua/HelloLua/CMakeLists.txt b/samples/Lua/HelloLua/CMakeLists.txt index e0d1f3a753..894fc66565 100644 --- a/samples/Lua/HelloLua/CMakeLists.txt +++ b/samples/Lua/HelloLua/CMakeLists.txt @@ -28,7 +28,7 @@ target_link_libraries(${APP_NAME} cocos2d ) -set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}") +set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}") set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") diff --git a/samples/Lua/HelloLua/proj.android/AndroidManifest.xml b/samples/Lua/HelloLua/proj.android/AndroidManifest.xml index 95394a531e..087e4852fb 100644 --- a/samples/Lua/HelloLua/proj.android/AndroidManifest.xml +++ b/samples/Lua/HelloLua/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Lua/HelloLua/proj.linux/.cproject b/samples/Lua/HelloLua/proj.linux/.cproject deleted file mode 100644 index 05f6db5b1d..0000000000 --- a/samples/Lua/HelloLua/proj.linux/.cproject +++ /dev/null @@ -1,436 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/Lua/HelloLua/proj.linux/.project b/samples/Lua/HelloLua/proj.linux/.project deleted file mode 100644 index 8d606ff4a1..0000000000 --- a/samples/Lua/HelloLua/proj.linux/.project +++ /dev/null @@ -1,54 +0,0 @@ - - - HelloLua - - - libcocos2d - libCocosDenshion - libextension - liblua - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - Classes - 2 - PARENT-1-PROJECT_LOC/Classes - - - cocos2dx_support - 2 - PARENT-4-PROJECT_LOC/scripting/lua/cocos2dx_support - - - - - 1373360284806 - - 22 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-Lua_web_socket.* - - - - diff --git a/samples/Lua/HelloLua/proj.linux/Makefile b/samples/Lua/HelloLua/proj.linux/Makefile deleted file mode 100644 index 6a0ddf230c..0000000000 --- a/samples/Lua/HelloLua/proj.linux/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -EXECUTABLE = HelloLua - -COCOS_ROOT = ../../../.. -INCLUDES = -I../Classes \ - -I$(COCOS_ROOT)/audio/include \ - -I$(COCOS_ROOT)/cocos/scripting/lua/bindings \ - -I$(COCOS_ROOT)/external/lua/lua - -SOURCES = main.cpp ../Classes/AppDelegate.cpp - -SHAREDLIBS += -lcocos2d -lcocosdenshion -llua -lextension - -include $(COCOS_ROOT)/cocos/2d/cocos2dx.mk - -$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - cp -n ../../../../cocos/scripting/lua/script/* ../../../../samples/Lua/HelloLua/Resources - $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) - -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj b/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj index aae3a8cf1f..dc57ee0d68 100644 --- a/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj +++ b/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj @@ -168,6 +168,9 @@ {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + {b7c2a162-dec9-4418-972e-240ab3cbfcae} + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} diff --git a/samples/Lua/TestLua/CMakeLists.txt b/samples/Lua/TestLua/CMakeLists.txt index 743f3eeb3f..bc9427168f 100644 --- a/samples/Lua/TestLua/CMakeLists.txt +++ b/samples/Lua/TestLua/CMakeLists.txt @@ -28,7 +28,7 @@ target_link_libraries(${APP_NAME} cocos2d ) -set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${APP_NAME}") +set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}") set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") diff --git a/samples/Lua/TestLua/Classes/AppDelegate.cpp b/samples/Lua/TestLua/Classes/AppDelegate.cpp index d07fb61f22..98f5922eec 100644 --- a/samples/Lua/TestLua/Classes/AppDelegate.cpp +++ b/samples/Lua/TestLua/Classes/AppDelegate.cpp @@ -61,11 +61,11 @@ bool AppDelegate::applicationDidFinishLaunching() searchPaths.insert(searchPaths.begin(), "cocosbuilderRes"); if (screenSize.height > 320) { - searchPaths.insert(searchPaths.begin(), "hd/scenetest"); + searchPaths.insert(searchPaths.begin(), "hd/scenetest/LoadSceneEdtiorFileTest"); } else { - searchPaths.insert(searchPaths.begin(), "scenetest"); + searchPaths.insert(searchPaths.begin(), "scenetest/LoadSceneEdtiorFileTest"); } #if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua index 7531500dc8..d47b24034e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua @@ -10,15 +10,14 @@ local ArmatureTestIndex = TEST_COCOSTUDIO_WITH_SKELETON = 3, TEST_DRAGON_BONES_2_0 = 4, TEST_PERFORMANCE = 5, - TEST_PERFORMANCE_BATCHNODE = 6, - TEST_CHANGE_ZORDER = 7, - TEST_ANIMATION_EVENT = 8, - TEST_FRAME_EVENT = 9, - TEST_PARTICLE_DISPLAY = 10, - TEST_USE_DIFFERENT_PICTURE = 11, - TEST_ANCHORPOINT = 12, - TEST_ARMATURE_NESTING = 13, - TEST_ARMATURE_NESTING_2 = 14, + TEST_CHANGE_ZORDER = 6, + TEST_ANIMATION_EVENT = 7, + TEST_FRAME_EVENT = 8, + TEST_PARTICLE_DISPLAY = 9, + TEST_USE_DIFFERENT_PICTURE = 10, + TEST_ANCHORPOINT = 11, + TEST_ARMATURE_NESTING = 12, + TEST_ARMATURE_NESTING_2 = 13, } local armatureSceneIdx = ArmatureTestIndex.TEST_ASYNCHRONOUS_LOADING @@ -80,8 +79,6 @@ function ArmatureTestLayer.title(idx) return "Test Export From DragonBones version 2.0" elseif ArmatureTestIndex.TEST_PERFORMANCE == idx then return "Test Performance" - elseif ArmatureTestIndex.TEST_PERFORMANCE_BATCHNODE == idx then - return "Test Performance of using BatchNode" elseif ArmatureTestIndex.TEST_CHANGE_ZORDER == idx then return "Test Change ZOrder Of Different Armature" elseif ArmatureTestIndex.TEST_ANIMATION_EVENT == idx then @@ -106,8 +103,6 @@ function ArmatureTestLayer.subTitle(idx) return "current percent :" elseif ArmatureTestIndex.TEST_PERFORMANCE == idx then return "Current Armature Count : " - elseif ArmatureTestIndex.TEST_PERFORMANCE_BATCHNODE == idx then - return "Current Armature Count : " elseif ArmatureTestIndex.TEST_PARTICLE_DISPLAY == idx then return "Touch to change animation" elseif ArmatureTestIndex.TEST_USE_DIFFERENT_PICTURE == idx then @@ -125,7 +120,12 @@ function ArmatureTestLayer.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) layer:creatTitleAndSubTitle(armatureSceneIdx) end @@ -174,7 +174,7 @@ function ArmatureTestLayer:createMenu() end function ArmatureTestLayer.toExtensionMenu() - ccs.ArmatureDataManager:destoryInstance() + ccs.ArmatureDataManager:destroyInstance() local scene = CocoStudioTestMain() if scene ~= nil then cc.Director:getInstance():replaceScene(scene) @@ -278,7 +278,12 @@ function TestAsynchronousLoading.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -301,7 +306,7 @@ function TestDirectLoading:onEnter() ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("armature/bear.ExportJson") ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/bear.ExportJson") local armature = ccs.Armature:create("bear") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(cc.p(VisibleRect:center())) self:addChild(armature) end @@ -311,7 +316,13 @@ function TestDirectLoading.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) + layer:creatTitleAndSubTitle(armatureSceneIdx) end return layer @@ -333,7 +344,7 @@ end function TestCSWithSkeleton:onEnter() local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setScale(0.2) armature:setAnchorPoint(cc.p(0.5, 0.5)) armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2)) @@ -346,7 +357,12 @@ function TestCSWithSkeleton.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) layer:creatTitleAndSubTitle(armatureSceneIdx) end @@ -368,7 +384,7 @@ end function TestDragonBones20:onEnter() local armature = ccs.Armature:create("Dragon") - armature:getAnimation():playByIndex(1) + armature:getAnimation():playWithIndex(1) armature:getAnimation():setSpeedScale(0.4) armature:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y * 0.3)) armature:setScale(0.6) @@ -381,7 +397,12 @@ function TestDragonBones20.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) layer:creatTitleAndSubTitle(armatureSceneIdx) end return layer @@ -423,7 +444,7 @@ function TestPerformance:addArmature(num) for i = 1, num do self._armatureCount = self._armatureCount + 1 local armature = ccs.Armature:create("Knight_f/Knight") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(50 + self._armatureCount * 2, 150) armature:setScale(0.6) self:addArmatureToParent(armature) @@ -480,7 +501,12 @@ function TestPerformance.create() layer:createMenu() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer end @@ -557,7 +583,12 @@ function TestPerformanceBatchNode.create() layer:createMenu() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer end @@ -580,21 +611,21 @@ function TestChangeZorder:onEnter() self.currentTag = -1 local armature = ccs.Armature:create("Knight_f/Knight") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100 )) armature:setScale(0.6) self.currentTag = self.currentTag + 1 self:addChild(armature, self.currentTag, self.currentTag) armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setScale(0.24) armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100)) self.currentTag = self.currentTag + 1 self:addChild(armature, self.currentTag, self.currentTag) armature = ccs.Armature:create("Dragon") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100)) armature:setScale(0.6) self.currentTag = self.currentTag + 1 @@ -615,8 +646,13 @@ function TestChangeZorder.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer end @@ -654,7 +690,7 @@ function TestAnimationEvent:onEnter() local function animationEvent(armatureBack,movementType,movementID) local id = movementID - if movementType == ccs.MovementEventType.LOOP_COMPLETE then + if movementType == ccs.MovementEventType.loopComplete then if id == "Fire" then local actionToRight = cc.MoveTo:create(2, cc.p(VisibleRect:right().x - 50, VisibleRect:right().y)) armatureBack:stopAllActions() @@ -680,8 +716,13 @@ function TestAnimationEvent.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer end @@ -700,27 +741,32 @@ function TestFrameEvent.extend(target) end function TestFrameEvent:onEnter() + + local gridNode = cc.NodeGrid:create() + local armature = ccs.Armature:create("HeroAnimation") armature:getAnimation():play("attack") armature:getAnimation():setSpeedScale(0.5) armature:setPosition(cc.p(VisibleRect:center().x - 50, VisibleRect:center().y -100)) local function onFrameEvent( bone,evt,originFrameIndex,currentFrameIndex) - if (not self:getActionByTag(frameEventActionTag)) or (not self:getActionByTag(frameEventActionTag):isDone()) then - self:stopAllActions() + if (not gridNode:getActionByTag(frameEventActionTag)) or (not gridNode:getActionByTag(frameEventActionTag):isDone()) then + gridNode:stopAllActions() + local action = cc.ShatteredTiles3D:create(0.2, cc.size(16,12), 5, false) action:setTag(frameEventActionTag) - self:runAction(action) + gridNode:runAction(action) end end armature:getAnimation():setFrameEventCallFunc(onFrameEvent) + gridNode:addChild(armature) - self:addChild(armature) + self:addChild(gridNode) local function checkAction(dt) - if self:getNumberOfRunningActions() == 0 and self:getGrid() ~= nil then - self:setGrid(nil) + if gridNode:getNumberOfRunningActions() == 0 and gridNode:getGrid() ~= nil then + gridNode:setGrid(nil) end end @@ -740,7 +786,12 @@ function TestFrameEvent.create() layer:createMenu() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer end @@ -765,7 +816,7 @@ function TestParticleDisplay:onEnter() self.animationID = 0 self.armature = ccs.Armature:create("robot") - self.armature:getAnimation():playByIndex(0) + self.armature:getAnimation():playWithIndex(0) self.armature:setPosition(VisibleRect:center()) self.armature:setScale(0.48) self:addChild(self.armature) @@ -775,7 +826,7 @@ function TestParticleDisplay:onEnter() local bone = ccs.Bone:create("p1") bone:addDisplay(p1, 0) - bone:changeDisplayByIndex(0, true) + bone:changeDisplayWithIndex(0, true) bone:setIgnoreMovementBoneData(true) bone:setZOrder(100) bone:setScale(1.2) @@ -783,7 +834,7 @@ function TestParticleDisplay:onEnter() bone = ccs.Bone:create("p2") bone:addDisplay(p2, 0) - bone:changeDisplayByIndex(0, true) + bone:changeDisplayWithIndex(0, true) bone:setIgnoreMovementBoneData(true) bone:setZOrder(100) bone:setScale(1.2) @@ -791,7 +842,7 @@ function TestParticleDisplay:onEnter() local function onTouchBegan(x, y) self.animationID = (self.animationID + 1) % self.armature:getAnimation():getMovementCount() - self.armature:getAnimation():playByIndex(self.animationID) + self.armature:getAnimation():playWithIndex(self.animationID) return false end @@ -810,8 +861,13 @@ function TestParticleDisplay.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -837,7 +893,7 @@ function TestUseMutiplePicture:onEnter() self.displayIndex = 1 self.armature = ccs.Armature:create("Knight_f/Knight") - self.armature:getAnimation():playByIndex(0) + self.armature:getAnimation():playWithIndex(0) self.armature:setPosition(cc.p(VisibleRect:left().x + 70, VisibleRect:left().y)) self.armature:setScale(1.2) self:addChild(self.armature) @@ -861,7 +917,7 @@ function TestUseMutiplePicture:onEnter() local function onTouchBegan(x, y) self.displayIndex = (self.displayIndex + 1) % (table.getn(weapon) - 1) - self.armature:getBone("weapon"):changeDisplayByIndex(self.displayIndex, true) + self.armature:getBone("weapon"):changeDisplayWithIndex(self.displayIndex, true) return false end @@ -880,8 +936,13 @@ function TestUseMutiplePicture.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -904,7 +965,7 @@ function TestAnchorPoint:onEnter() local i = 1 for i = 1 , 5 do local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(VisibleRect:center()) armature:setScale(0.2) self:addChild(armature, 0, i - 1) @@ -923,8 +984,13 @@ function TestAnchorPoint.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -950,7 +1016,7 @@ function TestArmatureNesting:onEnter() self.weaponIndex = 0 self.armature = ccs.Armature:create("cyborg") - self.armature:getAnimation():playByIndex(1) + self.armature:getAnimation():playWithIndex(1) self.armature:setPosition(VisibleRect:center()) self.armature:setScale(1.2) self.armature:getAnimation():setSpeedScale(0.4) @@ -958,8 +1024,8 @@ function TestArmatureNesting:onEnter() local function onTouchBegan(x, y) self.weaponIndex = (self.weaponIndex + 1) % 4 - self.armature:getBone("armInside"):getChildArmature():getAnimation():playByIndex(self.weaponIndex) - self.armature:getBone("armOutside"):getChildArmature():getAnimation():playByIndex(self.weaponIndex) + self.armature:getBone("armInside"):getChildArmature():getAnimation():playWithIndex(self.weaponIndex) + self.armature:getBone("armOutside"):getChildArmature():getAnimation():playWithIndex(self.weaponIndex) return false end @@ -978,8 +1044,13 @@ function TestArmatureNesting.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -1005,7 +1076,7 @@ function Hero:changeMount(armature) --note self:retain() - self:playByIndex(0) + self:playWithIndex(0) self._mount:getBone("hero"):removeDisplay(0) self._mount:stopAllActions() self:setPosition(self._mount:getPosition()) @@ -1015,22 +1086,22 @@ function Hero:changeMount(armature) else self._mount = armature self:retain() - self:removeFromParentAndCleanup(false) + self:removeFromParent(false) local bone = armature:getBone("hero") bone:addDisplay(self, 0) - bone:changeDisplayByIndex(0, true) + bone:changeDisplayWithIndex(0, true) bone:setIgnoreMovementBoneData(true) self:setPosition(cc.p(0,0)) - self:playByIndex(1) + self:playWithIndex(1) self:setScale(1) self:release() end end -function Hero:playByIndex(index) - self:getAnimation():playByIndex(index) +function Hero:playWithIndex(index) + self:getAnimation():playWithIndex(index) if nil ~= self._mount then - self._mount:getAnimation():playByIndex(index) + self._mount:getAnimation():playWithIndex(index) end end @@ -1112,7 +1183,7 @@ function TestArmatureNesting2:onEnter() self._hero = Hero.create("hero") self._hero._layer = self - self._hero:playByIndex(0) + self._hero:playWithIndex(0) self._hero:setPosition(cc.p(VisibleRect:left().x + 20, VisibleRect:left().y)) self:addChild(self._hero) @@ -1126,7 +1197,7 @@ end function TestArmatureNesting2:createMount(name,pt) local armature = ccs.Armature:create(name) - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(pt) self:addChild(armature) return armature @@ -1139,7 +1210,12 @@ function TestArmatureNesting2.create() layer:createMenu() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -1153,7 +1229,7 @@ local armatureSceneArr = TestCSWithSkeleton.create, TestDragonBones20.create, TestPerformance.create, - TestPerformanceBatchNode.create, + --TestPerformanceBatchNode.create, TestChangeZorder.create, TestAnimationEvent.create, TestFrameEvent.create, diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id index ca5791ada7..8d7bc14119 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioGUITest/CocoStudioGUITest.lua.REMOVED.git-id @@ -1 +1 @@ -63707dd119d9dad00da66996544c1892162dab08 \ No newline at end of file +1cb290e913d84d8cd141945c8b4a78ea45481cd5 \ No newline at end of file diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua index c7f557b0be..3c453756a4 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua @@ -1,3 +1,7 @@ +require "luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/acts" +require "luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/cons" +require "luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/eventDef" + local SceneEditorTestLayer = class("SceneEditorTestLayer") SceneEditorTestLayer._curNode = nil @@ -12,15 +16,16 @@ function SceneEditorTestLayer.extend(target) end function SceneEditorTestLayer:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/FishJoy2.json") + local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/LoadSceneEdtiorFileTest/FishJoy2.json") if nil == node then return end self._curNode = node local function menuCloseCallback( sender ) - ccs.SceneReader:getInstance():destroySceneReader() - ccs.ActionManagerEx:destroyActionManager() + ccs.SceneReader:destroyInstance() + ccs.ActionManagerEx:destroyInstance() + ccs.TriggerMng.destroyInstance() local scene = CocoStudioTestMain() if scene ~= nil then cc.Director:getInstance():replaceScene(scene) @@ -42,9 +47,53 @@ function SceneEditorTestLayer:createGameScene() ccs.ActionManagerEx:getInstance():playActionByName("startMenu_1.json","Animation1") + local function onNodeEvent(event) + if event == "enter" then + self:onEnter() + elseif event == "exit" then + self:onExit() + end + end + + self:registerScriptHandler(onNodeEvent) + + local listener = cc.EventListenerTouchOneByOne:create() + listener:setSwallowTouches(true) + listener:registerScriptHandler(self.onTouchBegan,cc.Handler.EVENT_TOUCH_BEGAN ) + listener:registerScriptHandler(self.onTouchMoved,cc.Handler.EVENT_TOUCH_MOVED ) + listener:registerScriptHandler(self.onTouchEnded,cc.Handler.EVENT_TOUCH_ENDED ) + listener:registerScriptHandler(self.onTouchCancelled,cc.Handler.EVENT_TOUCH_CANCELLED ) + local eventDispatcher = self:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self) + return node end +function SceneEditorTestLayer:onEnter() + ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_ENTERSCENE) +end + +function SceneEditorTestLayer:onExit() + ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_LEAVESCENE) +end + +function SceneEditorTestLayer:onTouchBegan(touch,event) + ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHBEGAN) + return true +end + +function SceneEditorTestLayer:onTouchMoved(touch,event) + ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHMOVED) +end + +function SceneEditorTestLayer:onTouchEnded(touch,event) + ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHENDED) +end + +function SceneEditorTestLayer:onTouchCancelled(touch,event) + ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHCANCELLED) +end + function SceneEditorTestLayer.create() local scene = cc.Scene:create() local layer = SceneEditorTestLayer.extend(cc.LayerColor:create()) diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/acts.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/acts.lua new file mode 100644 index 0000000000..b7080e57cf --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/acts.lua @@ -0,0 +1,122 @@ +require "CocoStudio" + +local TMoveBy = class("TMoveBy") +TMoveBy._tag = -1 +TMoveBy._duration = 0 +TMoveBy._x = 0 +TMoveBy._y = 0 +TMoveBy._reverse = false +function TMoveBy:ctor() + self._tag = -1 + self._duration = 0.0 + self._x = 0 + self._y = 0 + self._reverse = false +end + +function TMoveBy:init() + return true +end + +function TMoveBy:done() + local node = ccs.SceneReader:getInstance():getNodeByTag(self._tag) + if nil == node then + return + end + + local actionBy = cc.MoveBy:create(self._duration, cc.p(self._x, self._y)) + if nil == actionBy then + return + end + + if false == self._reverse then + local actionByBack = actionBy:reverse() + node:runAction(cc.Sequence:create(actionBy, actionByBack)) + else + node:runAction(actionBy) + end +end + +function TMoveBy:serialize(value) + local dataItems = value["dataitems"] + if nil ~= dataItems then + local count = table.getn(dataItems) + for i = 1, count do + local subDict = dataItems[i] + local key = subDict["key"] + if key == "Tag" then + self._tag = subDict["value"] + elseif key == "Duration" then + self._duration = subDict["value"] + elseif key == "x" then + self._x = subDict["value"] + elseif key == "y" then + self._y = subDict["value"] + elseif key == "IsReverse" then + self._reverse = subDict["value"] + end + end + end +end + +function TMoveBy:removeAll() + print("TMoveBy::removeAll") +end + +local TScaleTo = class("TScaleTo") +TScaleTo._tag = -1 +TScaleTo._duration = 0 +TScaleTo._scaleX = 0 +TScaleTo._scaleY = 0 + +function TScaleTo:ctor() + self._tag = -1 + self._duration = 0 + self._scaleX = 0 + self._scaleY = 0 +end + +function TScaleTo:init() + return true +end + +function TScaleTo:done() + local node = ccs.SceneReader:getInstance():getNodeByTag(self._tag) + if nil == node then + return + end + + local actionTo = cc.ScaleTo:create(self._duration, self._scaleX, self._scaleY) + if nil == actionTo then + return + end + + node:runAction(actionTo) +end + +function TScaleTo:serialize(value) + local dataItems = value["dataitems"] + if nil ~= dataItems then + local count = table.getn(dataItems) + for i = 1, count do + local subDict = dataItems[i] + local key = subDict["key"] + if key == "Tag" then + self._tag = subDict["value"] + elseif key == "Duration" then + self._duration = subDict["value"] + elseif key == "ScaleX" then + self._scaleX = subDict["value"] + elseif key == "ScaleY" then + self._scaleY = subDict["value"] + end + end + end +end + +function TScaleTo:removeAll() + print("TScaleTo::removeAll") +end + +ccs.registerTriggerClass("TScaleTo",TScaleTo.new) +ccs.registerTriggerClass("TMoveBy",TMoveBy.new) diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/cons.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/cons.lua new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/cons.lua @@ -0,0 +1 @@ + diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/eventDef.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/eventDef.lua new file mode 100644 index 0000000000..a973745b38 --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/TriggerCode/eventDef.lua @@ -0,0 +1,12 @@ + +triggerEventDef = +{ + TRIGGEREVENT_ENTERSCENE = 0, + TRIGGEREVENT_LEAVESCENE = 1, + TRIGGEREVENT_INITSCENE = 2, + TRIGGEREVENT_UPDATESCENE = 3, + TRIGGEREVENT_TOUCHBEGAN = 4, + TRIGGEREVENT_TOUCHMOVED = 5, + TRIGGEREVENT_TOUCHENDED = 6, + TRIGGEREVENT_TOUCHCANCELLED = 7, +} diff --git a/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua b/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua index b6ea8eb8a2..705ef3fac0 100644 --- a/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua @@ -8,23 +8,33 @@ local originCreateLayer = createTestLayer local function createTestLayer(title, subtitle) local ret = originCreateLayer(title, subtitle) - local bg = cc.Sprite:create("Images/background3.png") - ret:addChild(bg, 0, kTagBackground) - bg:setPosition( VisibleRect:center() ) + local bgNode = cc.NodeGrid:create() + bgNode:setAnchorPoint(cc.p(0.5,0.5)) + ret:addChild(bgNode,0,kTagBackground) + local bg = cc.Sprite:create("Images/background3.png") + bg:setPosition( VisibleRect:center()) + bgNode:addChild(bg) + + local target1 = cc.NodeGrid:create() + target1:setAnchorPoint(cc.p(0.5,0.5)) local grossini = cc.Sprite:create("Images/grossinis_sister2.png") - bg:addChild(grossini, 1, kTagSprite1) - grossini:setPosition( cc.p(VisibleRect:left().x+VisibleRect:getVisibleRect().width/3.0, VisibleRect:bottom().y+ 200) ) + target1:addChild(grossini) + bgNode:addChild(target1,1,kTagSprite1) + target1:setPosition(cc.p(VisibleRect:left().x+VisibleRect:getVisibleRect().width/3.0, VisibleRect:bottom().y+ 200) ) local sc = cc.ScaleBy:create(2, 5) local sc_back = sc:reverse() - grossini:runAction( cc.RepeatForever:create(cc.Sequence:create(sc, sc_back))) + target1:runAction( cc.RepeatForever:create(cc.Sequence:create(sc, sc_back))) + local target2 = cc.NodeGrid:create() + target2:setAnchorPoint(cc.p(0.5,0.5)) local tamara = cc.Sprite:create("Images/grossinis_sister1.png") - bg:addChild(tamara, 1, kTagSprite2) - tamara:setPosition( cc.p(VisibleRect:left().x+2*VisibleRect:getVisibleRect().width/3.0,VisibleRect:bottom().y+200) ) + target2:addChild(tamara) + bgNode:addChild(target2,1,kTagSprite2) + target2:setPosition( cc.p(VisibleRect:left().x+2*VisibleRect:getVisibleRect().width/3.0,VisibleRect:bottom().y+200) ) local sc2 = cc.ScaleBy:create(2, 5) local sc2_back = sc2:reverse() - tamara:runAction( cc.RepeatForever:create(cc.Sequence:create(sc2, sc2_back))) + target2:runAction( cc.RepeatForever:create(cc.Sequence:create(sc2, sc2_back))) return ret end @@ -51,9 +61,9 @@ local function Effect1() local reuse = cc.ReuseGrid:create(1) local delay = cc.DelayTime:create(8) - local orbit = cc.OrbitCamera:create(5, 1, 2, 0, 180, 0, -90) - local orbit_back = orbit:reverse() - target:runAction( cc.RepeatForever:create( cc.Sequence:create(orbit, orbit_back))) + -- local orbit = cc.OrbitCamera:create(5, 1, 2, 0, 180, 0, -90) + -- local orbit_back = orbit:reverse() + -- target:runAction( cc.RepeatForever:create( cc.Sequence:create(orbit, orbit_back))) target:runAction( cc.Sequence:create(lens, delay, reuse, waves)) return ret end @@ -165,7 +175,8 @@ local function Effect4() -- ret:addChild(pTarget) -- director:getActionManager():addAction(seq, pTarget, false) - ret:runAction( lens ) + local bg = ret:getChildByTag(kTagBackground) + bg:runAction( lens ) return ret end @@ -216,6 +227,7 @@ local function Issue631() layer:addChild(sprite, 10) -- foreground + local layer2BaseGrid = cc.NodeGrid:create() local layer2 = cc.LayerColor:create(cc.c4b( 0, 255,0,255 ) ) local fog = cc.Sprite:create("Images/Fog.png") @@ -225,9 +237,10 @@ local function Issue631() fog:setBlendFunc(gl.SRC_ALPHA , gl.ONE_MINUS_SRC_ALPHA ) layer2:addChild(fog, 1) - ret:addChild(layer2, 1) + ret:addChild(layer2BaseGrid, 1) + layer2BaseGrid:addChild(layer2) - layer2:runAction( cc.RepeatForever:create(effect) ) + layer2BaseGrid:runAction( cc.RepeatForever:create(effect) ) return ret end diff --git a/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua b/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua index 34e4b7cd05..b5fbe8e1d0 100644 --- a/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua @@ -11,17 +11,16 @@ local MAX_LAYER = 22 local testLayer = nil local titleLabel = nil local entry = nil +local gridNodeTarget = nil local function checkAnim(dt) - local s2 = testLayer:getChildByTag(kTagBackground) - if s2 == nil then + + if nil == gridNodeTarget then return end - if s2:getNumberOfRunningActions() == 0 then - if s2:getGrid() ~= nil then - s2:setGrid(nil) - end + if gridNodeTarget:getNumberOfRunningActions() == 0 and nil ~=gridNodeTarget:getGrid() then + gridNodeTarget:setGrid(nil) end end @@ -85,14 +84,14 @@ end -- Shaky3DDemo -------------------------------------- local function Shaky3DDemo(t) - return cc.Shaky3D:create(t, cc.size(15,10), 5, false); + return cc.Shaky3D:create(t, cc.size(15,10), 5, false) end -------------------------------------- -- Waves3DDemo -------------------------------------- local function Waves3DDemo(t) - return cc.Waves3D:create(t, cc.size(15,10), 5, 40); + return cc.Waves3D:create(t, cc.size(15,10), 5, 40) end -------------------------------------- @@ -121,56 +120,56 @@ end -- Lens3DDemo -------------------------------------- local function Lens3DDemo(t) - return cc.Lens3D:create(t, cc.size(15,10), cc.p(size.width/2,size.height/2), 240); + return cc.Lens3D:create(t, cc.size(15,10), cc.p(size.width/2,size.height/2), 240) end -------------------------------------- -- Ripple3DDemo -------------------------------------- local function Ripple3DDemo(t) - return cc.Ripple3D:create(t, cc.size(32,24), cc.p(size.width/2,size.height/2), 240, 4, 160); + return cc.Ripple3D:create(t, cc.size(32,24), cc.p(size.width/2,size.height/2), 240, 4, 160) end -------------------------------------- -- LiquidDemo -------------------------------------- local function LiquidDemo(t) - return cc.Liquid:create(t, cc.size(16,12), 4, 20); + return cc.Liquid:create(t, cc.size(16,12), 4, 20) end -------------------------------------- -- WavesDemo -------------------------------------- local function WavesDemo(t) - return cc.Waves:create(t, cc.size(16,12), 4, 20, true, true); + return cc.Waves:create(t, cc.size(16,12), 4, 20, true, true) end -------------------------------------- -- TwirlDemo -------------------------------------- local function TwirlDemo(t) - return cc.Twirl:create(t, cc.size(12,8), cc.p(size.width/2, size.height/2), 1, 2.5); + return cc.Twirl:create(t, cc.size(12,8), cc.p(size.width/2, size.height/2), 1, 2.5) end -------------------------------------- -- ShakyTiles3DDemo -------------------------------------- local function ShakyTiles3DDemo(t) - return cc.ShakyTiles3D:create(t, cc.size(16,12), 5, false); + return cc.ShakyTiles3D:create(t, cc.size(16,12), 5, false) end -------------------------------------- -- ShatteredTiles3DDemo -------------------------------------- local function ShatteredTiles3DDemo(t) - return cc.ShatteredTiles3D:create(t, cc.size(16,12), 5, false); + return cc.ShatteredTiles3D:create(t, cc.size(16,12), 5, false) end -------------------------------------- -- ShuffleTilesDemo -------------------------------------- local function ShuffleTilesDemo(t) - local shuffle = cc.ShuffleTiles:create(t, cc.size(16,12), 25); + local shuffle = cc.ShuffleTiles:create(t, cc.size(16,12), 25) local shuffle_back = shuffle:reverse() local delay = cc.DelayTime:create(2) @@ -181,7 +180,7 @@ end -- FadeOutTRTilesDemo -------------------------------------- local function FadeOutTRTilesDemo(t) - local fadeout = cc.FadeOutTRTiles:create(t, cc.size(16,12)); + local fadeout = cc.FadeOutTRTiles:create(t, cc.size(16,12)) local back = fadeout:reverse() local delay = cc.DelayTime:create(0.5) @@ -192,7 +191,7 @@ end -- FadeOutBLTilesDemo -------------------------------------- local function FadeOutBLTilesDemo(t) - local fadeout = cc.FadeOutBLTiles:create(t, cc.size(16,12)); + local fadeout = cc.FadeOutBLTiles:create(t, cc.size(16,12)) local back = fadeout:reverse() local delay = cc.DelayTime:create(0.5) @@ -203,7 +202,7 @@ end -- FadeOutUpTilesDemo -------------------------------------- local function FadeOutUpTilesDemo(t) - local fadeout = cc.FadeOutUpTiles:create(t, cc.size(16,12)); + local fadeout = cc.FadeOutUpTiles:create(t, cc.size(16,12)) local back = fadeout:reverse() local delay = cc.DelayTime:create(0.5) @@ -214,7 +213,7 @@ end -- FadeOutDownTilesDemo -------------------------------------- local function FadeOutDownTilesDemo(t) - local fadeout = cc.FadeOutDownTiles:create(t, cc.size(16,12)); + local fadeout = cc.FadeOutDownTiles:create(t, cc.size(16,12)) local back = fadeout:reverse() local delay = cc.DelayTime:create(0.5) @@ -225,7 +224,7 @@ end -- TurnOffTilesDemo -------------------------------------- local function TurnOffTilesDemo(t) - local fadeout = cc.TurnOffTiles:create(t, cc.size(48,32), 25); + local fadeout = cc.TurnOffTiles:create(t, cc.size(48,32), 25) local back = fadeout:reverse() local delay = cc.DelayTime:create(0.5) @@ -236,28 +235,28 @@ end -- WavesTiles3DDemo -------------------------------------- local function WavesTiles3DDemo(t) - return cc.WavesTiles3D:create(t, cc.size(15,10), 4, 120); + return cc.WavesTiles3D:create(t, cc.size(15,10), 4, 120) end -------------------------------------- -- JumpTiles3DDemo -------------------------------------- local function JumpTiles3DDemo(t) - return cc.JumpTiles3D:create(t, cc.size(15,10), 2, 30); + return cc.JumpTiles3D:create(t, cc.size(15,10), 2, 30) end -------------------------------------- -- SplitRowsDemo -------------------------------------- local function SplitRowsDemo(t) - return cc.SplitRows:create(t, 9); + return cc.SplitRows:create(t, 9) end -------------------------------------- -- SplitColsDemo -------------------------------------- local function SplitColsDemo(t) - return cc.SplitCols:create(t, 9); + return cc.SplitCols:create(t, 9) end -------------------------------------- @@ -265,7 +264,7 @@ end -------------------------------------- local function PageTurn3DDemo(t) cc.Director:getInstance():setDepthTest(true) - return cc.PageTurn3D:create(t, cc.size(15,10)); + return cc.PageTurn3D:create(t, cc.size(15,10)) end -------------------------------------- @@ -327,30 +326,31 @@ end function CreateEffectsTestLayer() testLayer = cc.LayerColor:create(cc.c4b(32,128,32,255)) - local x, y = size.width, size.height - local node = cc.Node:create() + gridNodeTarget = cc.NodeGrid:create() local effect = createEffect(ActionIdx, 3) - node:runAction(effect) - testLayer:addChild(node, 0, kTagBackground) - + gridNodeTarget:runAction(effect) + testLayer:addChild(gridNodeTarget, 0, kTagBackground) + local bg = cc.Sprite:create(s_back3) - node:addChild(bg, 0) - bg:setPosition(cc.p(size.width / 2, size.height / 2)) + gridNodeTarget:addChild(bg, 0) + bg:setPosition(VisibleRect:center()) local grossini = cc.Sprite:create(s_pPathSister2) - node:addChild(grossini, 1) - grossini:setPosition( cc.p(x / 3, y / 2) ) + gridNodeTarget:addChild(grossini, 1) + grossini:setPosition( cc.p(VisibleRect:left().x+VisibleRect:getVisibleRect().width/3,VisibleRect:center().y) ) local sc = cc.ScaleBy:create(2, 5) local sc_back = sc:reverse() - grossini:runAction(cc.RepeatForever:create(cc.Sequence:create(sc, sc_back))) + grossini:runAction( cc.RepeatForever:create(cc.Sequence:create(sc, sc_back) ) ) local tamara = cc.Sprite:create(s_pPathSister1) - node:addChild(tamara, 1) - tamara:setPosition(cc.p(2 * x / 3, y / 2)) + gridNodeTarget:addChild(tamara, 1) + tamara:setPosition( cc.p(VisibleRect:left().x+2*VisibleRect:getVisibleRect().width/3,VisibleRect:center().y) ) local sc2 = cc.ScaleBy:create(2, 5) local sc2_back = sc2:reverse() - tamara:runAction(cc.RepeatForever:create(cc.Sequence:create(sc2, sc2_back))) + tamara:runAction( cc.RepeatForever:create(cc.Sequence:create(sc2, sc2_back)) ) + + local x, y = size.width, size.height titleLabel = cc.LabelTTF:create(EffectsList[ActionIdx], "Marker Felt", 32) titleLabel:setPosition(x / 2, y - 80) diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua index 261dd70730..b831962568 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua @@ -11,9 +11,7 @@ local ExtensionTestEnum = TEST_COCOSBUILDER = 2, TEST_WEBSOCKET = 3, TEST_EDITBOX = 4, - TEST_TABLEVIEW = 5, - TEST_SCROLLVIEW = 6, - TEST_MAX_COUNT = 7, + TEST_MAX_COUNT = 5, } local testsName = @@ -23,8 +21,6 @@ local testsName = "CocosBuilderTest", "WebSocketTest", "EditBoxTest", - "TableViewTest", - "ScrollViewTest", } @@ -992,195 +988,6 @@ local function runEditBoxTest() return newScene end - -local TableViewTestLayer = class("TableViewTestLayer") -TableViewTestLayer.__index = TableViewTestLayer - -function TableViewTestLayer.extend(target) - local t = tolua.getpeer(target) - if not t then - t = {} - tolua.setpeer(target, t) - end - setmetatable(t, TableViewTestLayer) - return target -end - -function TableViewTestLayer.scrollViewDidScroll(view) - print("scrollViewDidScroll") -end - -function TableViewTestLayer.scrollViewDidZoom(view) - print("scrollViewDidZoom") -end - -function TableViewTestLayer.tableCellTouched(table,cell) - print("cell touched at index: " .. cell:getIdx()) -end - -function TableViewTestLayer.cellSizeForTable(table,idx) - return 60,60 -end - -function TableViewTestLayer.tableCellAtIndex(table, idx) - local strValue = string.format("%d",idx) - local cell = table:dequeueCell() - local label = nil - if nil == cell then - cell = cc.TableViewCell:new() - local sprite = cc.Sprite:create("Images/Icon.png") - sprite:setAnchorPoint(cc.p(0,0)) - sprite:setPosition(cc.p(0, 0)) - cell:addChild(sprite) - - label = cc.LabelTTF:create(strValue, "Helvetica", 20.0) - label:setPosition(cc.p(0,0)) - label:setAnchorPoint(cc.p(0,0)) - label:setTag(123) - cell:addChild(label) - else - label = tolua.cast(cell:getChildByTag(123),"LabelTTF") - if nil ~= label then - label:setString(strValue) - end - end - - return cell -end - -function TableViewTestLayer.numberOfCellsInTableView(table) - return 25 -end - -function TableViewTestLayer:init() - - local winSize = cc.Director:getInstance():getWinSize() - - local tableView = cc.TableView:create(cc.size(600,60)) - tableView:setDirection(cc.SCROLLVIEW_DIRECTION_HORIZONTAL) - tableView:setPosition(cc.p(20, winSize.height / 2 - 150)) - tableView:setDelegate() - self:addChild(tableView) - --registerScriptHandler functions must be before the reloadData funtion - tableView:registerScriptHandler(TableViewTestLayer.numberOfCellsInTableView,cc.NUMBER_OF_CELLS_IN_TABLEVIEW) - tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL) - tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM) - tableView:registerScriptHandler(TableViewTestLayer.tableCellTouched,cc.TABLECELL_TOUCHED) - tableView:registerScriptHandler(TableViewTestLayer.cellSizeForTable,cc.TABLECELL_SIZE_FOR_INDEX) - tableView:registerScriptHandler(TableViewTestLayer.tableCellAtIndex,cc.TABLECELL_SIZE_AT_INDEX) - tableView:reloadData() - - tableView = cc.TableView:create(cc.size(60, 350)) - tableView:setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL) - tableView:setPosition(cc.p(winSize.width - 150, winSize.height / 2 - 150)) - tableView:setDelegate() - tableView:setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN) - self:addChild(tableView) - tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL) - tableView:registerScriptHandler(TableViewTestLayer.scrollViewDidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM) - tableView:registerScriptHandler(TableViewTestLayer.tableCellTouched,cc.TABLECELL_TOUCHED) - tableView:registerScriptHandler(TableViewTestLayer.cellSizeForTable,cc.TABLECELL_SIZE_FOR_INDEX) - tableView:registerScriptHandler(TableViewTestLayer.tableCellAtIndex,cc.TABLECELL_SIZE_AT_INDEX) - tableView:registerScriptHandler(TableViewTestLayer.numberOfCellsInTableView,cc.NUMBER_OF_CELLS_IN_TABLEVIEW) - tableView:reloadData() - - -- Back Menu - local pToMainMenu = cc.Menu:create() - CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(cc.p(0, 0)) - self:addChild(pToMainMenu,10) - - return true -end - -function TableViewTestLayer.create() - local layer = TableViewTestLayer.extend(cc.Layer:create()) - if nil ~= layer then - layer:init() - end - - return layer -end - -local function runTableViewTest() - local newScene = cc.Scene:create() - local newLayer = TableViewTestLayer.create() - newScene:addChild(newLayer) - return newScene -end - -local function runScrollViewTest() - local newScene = cc.Scene:create() - local newLayer = cc.Layer:create() - - -- Back Menu - local pToMainMenu = cc.Menu:create() - CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(cc.p(0, 0)) - newLayer:addChild(pToMainMenu,10) - - local layerColor = cc.LayerColor:create(cc.c4b(128,64,0,255)) - newLayer:addChild(layerColor) - - local scrollView1 = cc.ScrollView:create() - local screenSize = cc.Director:getInstance():getWinSize() - local function scrollView1DidScroll() - print("scrollView1DidScroll") - end - local function scrollView1DidZoom() - print("scrollView1DidZoom") - end - if nil ~= scrollView1 then - scrollView1:setViewSize(cc.size(screenSize.width / 2,screenSize.height)) - scrollView1:setPosition(cc.p(0,0)) - scrollView1:setScale(1.0) - scrollView1:ignoreAnchorPointForPosition(true) - local flowersprite1 = cc.Sprite:create("ccb/flower.jpg") - if nil ~= flowersprite1 then - scrollView1:setContainer(flowersprite1) - scrollView1:updateInset() - end - scrollView1:setDirection(cc.SCROLLVIEW_DIRECTION_BOTH ) - scrollView1:setClippingToBounds(true) - scrollView1:setBounceable(true) - scrollView1:setDelegate() - scrollView1:registerScriptHandler(scrollView1DidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL) - scrollView1:registerScriptHandler(scrollView1DidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM) - end - newLayer:addChild(scrollView1) - - local scrollView2 = cc.ScrollView:create() - local function scrollView2DidScroll() - print("scrollView2DidScroll") - end - local function scrollView2DidZoom() - print("scrollView2DidZoom") - end - if nil ~= scrollView2 then - scrollView2:setViewSize(cc.size(screenSize.width / 2,screenSize.height)) - scrollView2:setPosition(cc.p(screenSize.width / 2,0)) - scrollView2:setScale(1.0) - scrollView2:ignoreAnchorPointForPosition(true) - local flowersprite2 = cc.Sprite:create("ccb/flower.jpg") - if nil ~= flowersprite2 then - scrollView2:setContainer(flowersprite2) - scrollView2:updateInset() - end - scrollView2:setDirection(cc.SCROLLVIEW_DIRECTION_BOTH ) - scrollView2:setClippingToBounds(true) - scrollView2:setBounceable(true) - scrollView2:setDelegate() - scrollView2:registerScriptHandler(scrollView2DidScroll,cc.SCROLLVIEW_SCRIPT_SCROLL) - scrollView2:registerScriptHandler(scrollView2DidZoom,cc.SCROLLVIEW_SCRIPT_ZOOM) - end - newLayer:addChild(scrollView2) - - newScene:addChild(newLayer) - return newScene -end - - - local CreateExtensionsTestTable = { runNotificationCenterTest, @@ -1188,8 +995,6 @@ local CreateExtensionsTestTable = runCocosBuilder, runWebSocketTest, runEditBoxTest, - runTableViewTest, - runScrollViewTest, } diff --git a/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua b/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua index 54e27c2682..47e4d0103e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua @@ -446,7 +446,6 @@ local function CameraOrbitTest() sprite:setScale(0.5) p:addChild(sprite, 0) sprite:setPosition(cc.p(s.width / 4 * 1, s.height / 2)) - local cam = sprite:getCamera() local orbit = cc.OrbitCamera:create(2, 1, 0, 0, 360, 0, 0) sprite:runAction(cc.RepeatForever:create(orbit)) @@ -488,12 +487,12 @@ local function CameraZoomTest_update(dt) z = z + dt * 100 local sprite = CameraZoomTest_layer:getChildByTag(20) - local cam = sprite:getCamera() - cam:setEye(0, 0, z) + -- local cam = sprite:getCamera() + -- cam:setEye(0, 0, z) sprite = CameraZoomTest_layer:getChildByTag(40) - cam = sprite:getCamera() - cam:setEye(0, 0, -z) + -- cam = sprite:getCamera() + -- cam:setEye(0, 0, -z) end local function CameraZoomTest_onEnterOrExit(tag) @@ -515,9 +514,9 @@ local function CameraZoomTest() local sprite = cc.Sprite:create(s_pPathGrossini) CameraZoomTest_layer:addChild(sprite, 0) sprite:setPosition(cc.p(s.width / 4 * 1, s.height / 2)) - local cam = sprite:getCamera() - cam:setEye(0, 0, 415 / 2) - cam:setCenter(0, 0, 0) + -- local cam = sprite:getCamera() + -- cam:setEye(0, 0, 415 / 2) + -- cam:setCenter(0, 0, 0) -- CENTER sprite = cc.Sprite:create(s_pPathGrossini) diff --git a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua index 6673fc8d67..0267dd0eb0 100644 --- a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua @@ -733,7 +733,7 @@ local function runParticleTest() --remove the "fire.png" from the TextureCache cache. local pTexture = cc.TextureCache:getInstance():addImage("Images/fire.png") cc.TextureCache:getInstance():removeTexture(pTexture) - local pParticleSystem = cc.ParticleSystemQuad:new() + local pParticleSystem = cc.ParticleSystemQuad:createWithTotalParticles(nQuantityParticles) if 1 == nSubtestNumber then cc.Texture2D:setDefaultAlphaPixelFormat(cc.TEXTURE2_D_PIXEL_FORMAT_RGB_A8888) elseif 2 == nSubtestNumber then @@ -752,7 +752,6 @@ local function runParticleTest() end if nil ~= pParticleSystem then - pParticleSystem:initWithTotalParticles(nQuantityParticles) pParticleSystem:setTexture(cc.TextureCache:getInstance():addImage("Images/fire.png")) end diff --git a/samples/Lua/TestLua/Resources/luaScript/PhysicsTest/PhysicsTest.lua b/samples/Lua/TestLua/Resources/luaScript/PhysicsTest/PhysicsTest.lua new file mode 100644 index 0000000000..0434b0a3c4 --- /dev/null +++ b/samples/Lua/TestLua/Resources/luaScript/PhysicsTest/PhysicsTest.lua @@ -0,0 +1,620 @@ +local size = cc.Director:getInstance():getWinSize() +local MATERIAL_DEFAULT = cc.PhysicsMaterial(0.1, 0.5, 0.5) +local curLayer = nil +local STATIC_COLOR = cc.c4f(1.0, 0.0, 0.0, 1.0) +local DRAG_BODYS_TAG = 0x80 + +local function range(from, to, step) + step = step or 1 + return function(_, lastvalue) + local nextvalue = lastvalue + step + if step > 0 and nextvalue <= to or step < 0 and nextvalue >= to or + step == 0 + then + return nextvalue + end + end, nil, from - step +end + +local function initWithLayer(layer, callback) + curLayer = layer + layer.spriteTexture = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100):getTexture() + + local debug = false + local function toggleDebugCallback(sender) + debug = not debug + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setDebugDrawMask(debug and cc.PhysicsWorld.DEBUGDRAW_ALL or cc.PhysicsWorld.DEBUGDRAW_NONE) + end + + layer.toggleDebug = toggleDebugCallback; + cc.MenuItemFont:setFontSize(18) + local item = cc.MenuItemFont:create("Toogle debug") + item:registerScriptTapHandler(toggleDebugCallback) + local menu = cc.Menu:create(item) + layer:addChild(menu) + menu:setPosition(size.width - 50, size.height - 10) + Helper.initWithLayer(layer) + + local function onNodeEvent(event) + if "enter" == event then + callback() + end + end + layer:registerScriptHandler(onNodeEvent) +end + +local function addGrossiniAtPosition(layer, p, scale) + scale = scale or 1.0 + + local posx = math.random() * 200.0 + local posy = math.random() * 100.0 + posx = (math.floor(posx) % 4) * 85 + posy = (math.floor(posy) % 3) * 121 + + local sp = cc.Sprite:createWithTexture(layer.spriteTexture, cc.rect(posx, posy, 85, 121)) + sp:setScale(scale) + sp:setPhysicsBody(cc.PhysicsBody:createBox(cc.size(48.0*scale, 108.0*scale))) + layer:addChild(sp) + sp:setPosition(p) + return sp +end + +local function onTouchBegan(touch, event) + local location = touch:getLocation() + local arr = cc.Director:getInstance():getRunningScene():getPhysicsWorld():getShapes(location) + + local body + for _, obj in ipairs(arr) do + if bit.band(obj:getBody():getTag(), DRAG_BODYS_TAG) ~= 0 then + body = obj:getBody(); + break; + end + end + + if body then + local mouse = cc.Node:create(); + mouse:setPhysicsBody(cc.PhysicsBody:create(PHYSICS_INFINITY, PHYSICS_INFINITY)); + mouse:getPhysicsBody():setDynamic(false); + mouse:setPosition(location); + curLayer:addChild(mouse); + local joint = cc.PhysicsJointPin:construct(mouse:getPhysicsBody(), body, location); + joint:setMaxForce(5000.0 * body:getMass()); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():addJoint(joint); + touch.mouse = mouse + + return true; + end + + return false; +end + +local function onTouchMoved(touch, event) + if touch.mouse then + touch.mouse:setPosition(touch:getLocation()); + end +end + +local function onTouchEnded(touch, event) + if touch.mouse then + curLayer:removeChild(touch.mouse) + touch.mouse = nil + end +end + +local function makeBall(layer, point, radius, material) + material = material or MATERIAL_DEFAULT + + local ball + if layer.ball then + ball = cc.Sprite:createWithTexture(layer.ball:getTexture()) + else + ball = cc.Sprite:create("Images/ball.png") + end + + ball:setScale(0.13 * radius) + + local body = cc.PhysicsBody:createCircle(radius, material) + ball:setPhysicsBody(body) + ball:setPosition(point) + + return ball +end + +local function makeBox(point, size, material) + material = material or DEFAULT_MATERIAL + local box = math.random() > 0.5 and cc.Sprite:create("Images/YellowSquare.png") or cc.Sprite:create("Images/CyanSquare.png"); + + box:setScaleX(size.width/100.0); + box:setScaleY(size.height/100.0); + + local body = cc.PhysicsBody:createBox(size); + box:setPhysicsBody(body); + box:setPosition(cc.p(point.x, point.y)); + + return box; +end + +local function makeTriangle(point, size, material) + material = material or DEFAULT_MATERIAL + local triangle = math.random() > 0.5 and cc.Sprite:create("Images/YellowTriangle.png") or cc.Sprite:create("Images/CyanTriangle.png"); + + if size.height == 0 then + triangle:setScale(size.width/100.0); + else + triangle:setScaleX(size.width/50.0) + triangle:setScaleY(size.height/43.5) + end + + vers = { cc.p(0, size.height/2), cc.p(size.width/2, -size.height/2), cc.p(-size.width/2, -size.height/2)}; + + local body = cc.PhysicsBody:createPolygon(vers); + triangle:setPhysicsBody(body); + triangle:setPosition(point); + + return triangle; +end + +local function PhysicsDemoClickAdd() + local layer = cc.Layer:create() + local function onEnter() + local function onTouchEnded(touch, event) + local location = touch:getLocation(); + addGrossiniAtPosition(layer, location) + end + + local touchListener = cc.EventListenerTouchOneByOne:create() + touchListener:registerScriptHandler(function() return true end, cc.Handler.EVENT_TOUCH_BEGAN) + touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED) + local eventDispatcher = layer:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) + + addGrossiniAtPosition(layer, VisibleRect:center()) + + local node = cc.Node:create() + node:setPhysicsBody(cc.PhysicsBody:createEdgeBox(cc.size(VisibleRect:getVisibleRect().width, VisibleRect:getVisibleRect().height))) + node:setPosition(VisibleRect:center()) + layer:addChild(node) + end + initWithLayer(layer, onEnter) + Helper.titleLabel:setString("Grossini") + Helper.subtitleLabel:setString("multi touch to add grossini") + + return layer +end + +local function PhysicsDemoLogoSmash() + local layer = cc.Layer:create() + + local function onEnter() + local logo_width = 188.0 + local logo_height = 35.0 + local logo_raw_length = 24.0 + local logo_image = { + 15,-16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,-64,15,63,-32,-2,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,31,-64,15,127,-125,-1,-128,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,127,-64,15,127,15,-1,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,-64,15,-2, + 31,-1,-64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,-64,0,-4,63,-1,-32,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,1,-1,-64,15,-8,127,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,-1,-64,0,-8,-15,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-31,-1,-64,15,-8,-32, + -1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,-15,-1,-64,9,-15,-32,-1,-32,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,31,-15,-1,-64,0,-15,-32,-1,-32,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,63,-7,-1,-64,9,-29,-32,127,-61,-16,63,15,-61,-1,-8,31,-16,15,-8,126,7,-31, + -8,31,-65,-7,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-2,63,-8,31,-4,-1,15,-13, + -4,63,-1,-3,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-2,63,-8,31,-4,-1,15,-13, + -2,63,-1,-3,-1,-64,9,-29,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, + -2,63,-33,-1,-1,-32,9,-25,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, + -1,63,-33,-1,-1,-16,9,-25,-32,0,7,-8,127,-97,-25,-1,-1,63,-4,63,-4,-1,15,-13, + -1,63,-49,-1,-1,-8,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, + -1,-65,-49,-1,-1,-4,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, + -1,-65,-57,-1,-1,-2,9,-57,-32,0,7,-8,127,-97,-25,-8,-1,63,-2,127,-4,-1,15,-13, + -1,-1,-57,-1,-1,-1,9,-57,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, + -1,-61,-1,-1,-1,-119,-57,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, + -1,-61,-1,-1,-1,-55,-49,-32,0,7,-1,-1,-97,-25,-8,-1,63,-1,-1,-4,-1,15,-13,-1, + -1,-63,-1,-1,-1,-23,-49,-32,127,-57,-1,-1,-97,-25,-1,-1,63,-1,-1,-4,-1,15,-13, + -1,-1,-63,-1,-1,-1,-16,-49,-32,-1,-25,-1,-1,-97,-25,-1,-1,63,-33,-5,-4,-1,15, + -13,-1,-1,-64,-1,-9,-1,-7,-49,-32,-1,-25,-8,127,-97,-25,-1,-1,63,-33,-5,-4,-1, + 15,-13,-1,-1,-64,-1,-13,-1,-32,-49,-32,-1,-25,-8,127,-97,-25,-1,-2,63,-49,-13, + -4,-1,15,-13,-1,-1,-64,127,-7,-1,-119,-17,-15,-1,-25,-8,127,-97,-25,-1,-2,63, + -49,-13,-4,-1,15,-13,-3,-1,-64,127,-8,-2,15,-17,-1,-1,-25,-8,127,-97,-25,-1, + -8,63,-49,-13,-4,-1,15,-13,-3,-1,-64,63,-4,120,0,-17,-1,-1,-25,-8,127,-97,-25, + -8,0,63,-57,-29,-4,-1,15,-13,-4,-1,-64,63,-4,0,15,-17,-1,-1,-25,-8,127,-97, + -25,-8,0,63,-57,-29,-4,-1,-1,-13,-4,-1,-64,31,-2,0,0,103,-1,-1,-57,-8,127,-97, + -25,-8,0,63,-57,-29,-4,-1,-1,-13,-4,127,-64,31,-2,0,15,103,-1,-1,-57,-8,127, + -97,-25,-8,0,63,-61,-61,-4,127,-1,-29,-4,127,-64,15,-8,0,0,55,-1,-1,-121,-8, + 127,-97,-25,-8,0,63,-61,-61,-4,127,-1,-29,-4,63,-64,15,-32,0,0,23,-1,-2,3,-16, + 63,15,-61,-16,0,31,-127,-127,-8,31,-1,-127,-8,31,-128,7,-128,0,0 + }; + + local function get_pixel(x, y) + return bit.band(bit.rshift(logo_image[bit.rshift(x, 3) + y*logo_raw_length + 1], bit.band(bit.bnot(x), 0x07)), 1) + end + + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0, 0)); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setUpdateRate(5.0); + + layer.ball = cc.SpriteBatchNode:create("Images/ball.png", #logo_image); + layer:addChild(layer.ball); + for y in range(0, logo_height-1) do + for x in range(0, logo_width-1) do + if get_pixel(x, y) == 1 then + local x_jitter = 0.05*math.random(); + local y_jitter = 0.05*math.random(); + + local ball = makeBall(layer, cc.p(2*(x - logo_width/2 + x_jitter) + VisibleRect:getVisibleRect().width/2, + 2*(logo_height-y + y_jitter) + VisibleRect:getVisibleRect().height/2 - logo_height/2), + 0.95, cc.PhysicsMaterial(0.01, 0.0, 0.0)); + + ball:getPhysicsBody():setMass(1.0); + ball:getPhysicsBody():setMoment(PHYSICS_INFINITY); + + layer.ball:addChild(ball); + end + end + end + + local bullet = makeBall(layer, cc.p(400, 0), 10, cc.PhysicsMaterial(PHYSICS_INFINITY, 0, 0)); + bullet:getPhysicsBody():setVelocity(cc.p(200, 0)); + bullet:setPosition(cc.p(-500, VisibleRect:getVisibleRect().height/2)) + layer.ball:addChild(bullet); + end + + initWithLayer(layer, onEnter) + Helper.titleLabel:setString("Logo Smash") + + return layer +end + +local function PhysicsDemoJoints() + local layer = cc.Layer:create() + local function onEnter() + layer:toggleDebug(); + + local touchListener = cc.EventListenerTouchOneByOne:create() + touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN) + touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED) + touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED) + local eventDispatcher = layer:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer) + + local width = (VisibleRect:getVisibleRect().width - 10) / 4; + local height = (VisibleRect:getVisibleRect().height - 50) / 4; + + local node = cc.Node:create(); + local box = cc.PhysicsBody:create(); + node:setPhysicsBody(box); + box:setDynamic(false); + node:setPosition(cc.p(0, 0)); + layer:addChild(node); + + local scene = cc.Director:getInstance():getRunningScene(); + for i in range(0, 3) do + for j in range(0, 3) do + local offset = cc.p(VisibleRect:leftBottom().x + 5 + j * width + width/2, VisibleRect:leftBottom().y + 50 + i * height + height/2); + box:addShape(cc.PhysicsShapeEdgeBox:create(cc.size(width, height), cc.PHYSICSSHAPE_MATERIAL_DEFAULT, 1, offset)); + print("i,j") + print(i) + print(j) + local index = i*4 + j + if index == 0 then + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBall(layer, cc.p(offset.x + 30, offset.y), 10); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + + local joint = cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), offset); + cc.Director:getInstance():getRunningScene():getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + elseif index == 1 then + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + + local joint = cc.PhysicsJointFixed:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), offset); + scene:getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + elseif index == 2 then + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + + local joint = cc.PhysicsJointDistance:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), cc.p(0, 0), cc.p(0, 0)); + scene:getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + elseif index == 3 then + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + + local joint = cc.PhysicsJointLimit:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), cc.p(0, 0), cc.p(0, 0), 30.0, 60.0); + scene:getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + elseif index == 4 then + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + + local joint = cc.PhysicsJointSpring:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), cc.p(0, 0), cc.p(0, 0), 500.0, 0.3); + scene:getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + elseif index == 5 then + local sp1 = makeBall(layer, cc.p(offset.x - 30, offset.y), 10); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + + local joint = cc.PhysicsJointGroove:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), cc.p(30, 15), cc.p(30, -15), cc.p(-30, 0)) + scene:getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + elseif index == 6 then + local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), box, cc.p(sp1:getPosition()))); + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2:getPhysicsBody(), box, cc.p(sp2:getPosition()))); + local joint = cc.PhysicsJointRotarySpring:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), 3000.0, 60.0); + scene:getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + elseif index == 7 then + local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), box, cc.p(sp1:getPosition()))); + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2:getPhysicsBody(), box, cc.p(sp2:getPosition()))); + local joint = cc.PhysicsJointRotaryLimit:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), 0.0, math.pi/2); + scene:getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + elseif index == 8 then + local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), box, cc.p(sp1:getPosition()))); + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2:getPhysicsBody(), box, cc.p(sp2:getPosition()))); + local joint = cc.PhysicsJointRatchet:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), 0.0, math.pi/2); + scene:getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + elseif index == 9 then + local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), box, cc.p(sp1:getPosition()))); + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2:getPhysicsBody(), box, cc.p(sp2:getPosition()))); + local joint = cc.PhysicsJointGear:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), 0.0, 2.0); + scene:getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + elseif index == 10 then + local sp1 = makeBox(cc.p(offset.x - 30, offset.y), cc.size(30, 10)); + sp1:getPhysicsBody():setTag(DRAG_BODYS_TAG); + local sp2 = makeBox(cc.p(offset.x + 30, offset.y), cc.size(30, 10)); + sp2:getPhysicsBody():setTag(DRAG_BODYS_TAG); + + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp1:getPhysicsBody(), box, cc.p(sp1:getPosition()))); + scene:getPhysicsWorld():addJoint(cc.PhysicsJointPin:construct(sp2:getPhysicsBody(), box, cc.p(sp2:getPosition()))); + local joint = cc.PhysicsJointMotor:construct(sp1:getPhysicsBody(), sp2:getPhysicsBody(), math.pi/2); + scene:getPhysicsWorld():addJoint(joint); + + layer:addChild(sp1); + layer:addChild(sp2); + end + end + end + end + + initWithLayer(layer, onEnter) + Helper.titleLabel:setString("Joints") + return layer +end + +local function PhysicsDemoPyramidStack() + local layer = cc.Layer:create() + + local function onEnter() + local touchListener = cc.EventListenerTouchOneByOne:create(); + touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN); + touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED); + touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED); + local eventDispatcher = layer:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer); + + local node = cc.Node:create(); + node:setPhysicsBody(cc.PhysicsBody:createEdgeSegment(cc.p(VisibleRect:leftBottom().x, VisibleRect:leftBottom().y + 50), cc.p(VisibleRect:rightBottom().x, VisibleRect:rightBottom().y + 50))); + layer:addChild(node); + + local ball = cc.Sprite:create("Images/ball.png"); + ball:setScale(1); + ball:setPhysicsBody(cc.PhysicsBody:createCircle(10)); + ball:getPhysicsBody():setTag(DRAG_BODYS_TAG); + ball:setPosition(cc.p(VisibleRect:bottom().x, VisibleRect:bottom().y + 60)); + layer:addChild(ball); + + for i in range(0, 13) do + for j in range(0, i) do + local x = VisibleRect:bottom().x + (i/2 - j) * 11 + local y = VisibleRect:bottom().y + (14 - i) * 23 + 100 + local sp = addGrossiniAtPosition(layer, cc.p(x, y), 0.2); + sp:getPhysicsBody():setTag(DRAG_BODYS_TAG); + end + end + end + + initWithLayer(layer, onEnter) + Helper.titleLabel:setString("Pyramid Stack") + + return layer +end + +local function PhysicsDemoRayCast() + local layer = cc.Layer:create() + + local function onEnter() + local function onTouchEnded(touch, event) + local location = touch:getLocation(); + + local r = math.random(3); + if r ==1 then + layer:addChild(makeBall(layer, location, 5 + math.random()*10)); + elseif r == 2 then + layer:addChild(makeBox(location, cc.size(10 + math.random()*15, 10 + math.random()*15))); + elseif r == 3 then + layer:addChild(makeTriangle(location, cc.size(10 + math.random()*20, 10 + math.random()*20))); + end + end + + local touchListener = cc.EventListenerTouchOneByOne:create(); + touchListener:registerScriptHandler(function() return true end, cc.Handler.EVENT_TOUCH_BEGAN); + touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED); + local eventDispatcher = layer:getEventDispatcher() + eventDispatcher:addEventListenerWithSceneGraphPriority(touchListener, layer); + + cc.Director:getInstance():getRunningScene():getPhysicsWorld():setGravity(cc.p(0,0)); + + local node = cc.DrawNode:create(); + node:setPhysicsBody(cc.PhysicsBody:createEdgeSegment(cc.p(VisibleRect:leftBottom().x, VisibleRect:leftBottom().y + 50), cc.p(VisibleRect:rightBottom().x, VisibleRect:rightBottom().y + 50))) + node:drawSegment(cc.p(VisibleRect:leftBottom().x, VisibleRect:leftBottom().y + 50), cc.p(VisibleRect:rightBottom().x, VisibleRect:rightBottom().y + 50), 1, STATIC_COLOR); + layer:addChild(node); + + local mode = 0 + cc.MenuItemFont:setFontSize(18); + local item = cc.MenuItemFont:create("Toogle debugChange Mode(any)") + local function changeModeCallback(sender) + mode = (mode + 1) % 3; + + if mode == 0 then + item:setString("Change Mode(any)"); + elseif mode == 1 then + item:setString("Change Mode(nearest)"); + elseif mode == 2 then + item:setString("Change Mode(multiple)"); + end + end + + item:registerScriptTapHandler(changeModeCallback) + + local menu = cc.Menu:create(item); + layer:addChild(menu); + menu:setPosition(cc.p(VisibleRect:left().x+100, VisibleRect:top().y-10)); + + local angle = 0 + local drawNode = nil + local function update(delta) + local L = 150.0; + local point1 = VisibleRect:center() + local d = cc.p(L * math.cos(angle), L * math.sin(angle)); + local point2 = cc.p(point1.x + d.x, point1.y + d.y) + + if drawNode then layer:removeChild(drawNode); end + drawNode = cc.DrawNode:create(); + if mode == 0 then + local point3 = cc.p(point2.x, point2.y) + local function func(world, info) + point3 = info.contact + return false + end + + cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(func, point1, point2); + drawNode:drawSegment(point1, point3, 1, STATIC_COLOR); + + if point2.x ~= point3.x or point2.y ~= point3.y then + drawNode:drawDot(point3, 2, cc.c4f(1.0, 1.0, 1.0, 1.0)); + end + layer:addChild(drawNode); + elseif mode == 1 then + local point3 = cc.p(point2.x, point2.y) + local friction = 1.0; + local function func(world, info) + if friction > info.fraction then + point3 = info.contact; + friction = info.fraction; + end + return true; + end + + cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(func, point1, point2); + drawNode:drawSegment(point1, point3, 1, STATIC_COLOR); + + if point2.x ~= point3.x or point2.y ~= point3.y then + drawNode:drawDot(point3, 2, cc.c4f(1.0, 1.0, 1.0, 1.0)); + end + layer:addChild(drawNode); + elseif mode == 2 then + local points = {} + + local function func(world, info) + points[#points + 1] = info.contact; + return true; + end + + cc.Director:getInstance():getRunningScene():getPhysicsWorld():rayCast(func, point1, point2); + drawNode:drawSegment(point1, point2, 1, STATIC_COLOR); + + for _, p in ipairs(points) do + drawNode:drawDot(p, 2, cc.c4f(1.0, 1.0, 1.0, 1.0)); + end + + layer:addChild(drawNode); + end + + angle = angle + 0.25 * math.pi / 180.0; + + end + + layer:scheduleUpdateWithPriorityLua(update, 0); + end + + initWithLayer(layer, onEnter) + Helper.titleLabel:setString("Ray Cast") + + return layer +end + +local function registerOnEnter() + layer:registerOn(PhysicsDemoLogoSmash) +end + +function PhysicsTest() + cclog("PhysicsTest") + local scene = cc.Scene:createWithPhysics() + + Helper.usePhysics = true + Helper.createFunctionTable = { + PhysicsDemoLogoSmash, + PhysicsDemoPyramidStack, + PhysicsDemoClickAdd, + PhysicsDemoRayCast, + PhysicsDemoJoints, + } + + scene:addChild(Helper.createFunctionTable[1]()) + scene:addChild(CreateBackMenuItem()) + return scene +end diff --git a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua index c53801e734..c2326ca230 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua @@ -174,14 +174,14 @@ local function TMXOrthoTest() child:getTexture():setAntiAliasTexParameters() end - local x = 0 - local y = 0 - local z = 0 - x, y, z = map:getCamera():getEye() - cclog("before eye x="..x..",y="..y..",z="..z) - map:getCamera():setEye(x-200, y, z+300) - x, y, z = map:getCamera():getEye() - cclog("after eye x="..x..",y="..y..",z="..z) + -- local x = 0 + -- local y = 0 + -- local z = 0 + -- x, y, z = map:getCamera():getEye() + -- cclog("before eye x="..x..",y="..y..",z="..z) + -- map:getCamera():setEye(x-200, y, z+300) + -- x, y, z = map:getCamera():getEye() + -- cclog("after eye x="..x..",y="..y..",z="..z) local function onNodeEvent(event) diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua index 06c967b2a6..60cb715089 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua @@ -1,5 +1,5 @@ -require "luaScript/extern" +require "extern" require "luaScript/VisibleRect" require "luaScript/TouchesTest/Paddle" diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua index 050d587ed5..61da0a5171 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua @@ -1,4 +1,4 @@ -require "luaScript/extern" +require "extern" require "luaScript/VisibleRect" Paddle = class("Paddle", function(texture) diff --git a/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua b/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua index 7d00240f8a..5d53b1f8e5 100644 --- a/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua +++ b/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua @@ -1,4 +1,4 @@ -require "luaScript/extern" +require "extern" require "Cocos2d" VisibleRect = class("VisibleRect") diff --git a/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua b/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua index a84dbbf085..2b716a6b8a 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua @@ -74,8 +74,8 @@ local function ZwoptexGenericTest() local str1 = string.format("grossini_dance_%02d.png", spriteFrameIndex) local str2 = string.format("grossini_dance_generic_%02d.png", spriteFrameIndex) - sprite1:setDisplayFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(str1)) - sprite2:setDisplayFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(str2)) + sprite1:setSpriteFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(str1)) + sprite2:setSpriteFrame(cc.SpriteFrameCache:getInstance():getSpriteFrame(str2)) end sprite1:retain() diff --git a/samples/Lua/TestLua/Resources/luaScript/helper.lua b/samples/Lua/TestLua/Resources/luaScript/helper.lua index 911924f1fe..c2706d02d3 100644 --- a/samples/Lua/TestLua/Resources/luaScript/helper.lua +++ b/samples/Lua/TestLua/Resources/luaScript/helper.lua @@ -31,6 +31,7 @@ end -- back menu callback local function MainMenuCallback() + Helper.usePhysics = false local scene = cc.Scene:create() scene:addChild(CreateTestMenu()) @@ -82,7 +83,12 @@ function Helper.restartAction() end function Helper.newScene() - local scene = cc.Scene:create() + local scene + if Helper.usePhysics then + scene = cc.Scene:createWithPhysics() + else + scene = cc.Scene:create() + end Helper.currentLayer = Helper.createFunctionTable[Helper.index]() scene:addChild(Helper.currentLayer) scene:addChild(CreateBackMenuItem()) diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index bba1c79a98..17302973c2 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -1,10 +1,9 @@ - - require "Cocos2d" require "Cocos2dConstants" require "Opengl" require "OpenglConstants" require "StudioConstants" +require "GuiConstants" require "luaScript/helper" require "luaScript/testResource" require "luaScript/VisibleRect" @@ -51,6 +50,7 @@ require "luaScript/UserDefaultTest/UserDefaultTest" require "luaScript/ZwoptexTest/ZwoptexTest" require "luaScript/LuaBridgeTest/LuaBridgeTest" require "luaScript/XMLHttpRequestTest/XMLHttpRequestTest" +require "luaScript/PhysicsTest/PhysicsTest" local LINE_SPACE = 40 @@ -95,6 +95,7 @@ local _allTests = { { isSupported = true, name = "ParallaxTest" , create_func = ParallaxTestMain }, { isSupported = true, name = "ParticleTest" , create_func = ParticleTest }, { isSupported = true, name = "PerformanceTest" , create_func= PerformanceTestMain }, + { isSupported = true, name = "PhysicsTest" , create_func = PhysicsTest }, { isSupported = true, name = "RenderTextureTest" , create_func = RenderTextureTestMain }, { isSupported = true, name = "RotateWorldTest" , create_func = RotateWorldTest }, { isSupported = true, name = "SceneTest" , create_func = SceneTestMain }, diff --git a/samples/Lua/TestLua/proj.android/AndroidManifest.xml b/samples/Lua/TestLua/proj.android/AndroidManifest.xml index fb1ec4abb6..5eb27de989 100644 --- a/samples/Lua/TestLua/proj.android/AndroidManifest.xml +++ b/samples/Lua/TestLua/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/samples/Lua/TestLua/proj.linux/.cproject b/samples/Lua/TestLua/proj.linux/.cproject deleted file mode 100644 index 8dab88e511..0000000000 --- a/samples/Lua/TestLua/proj.linux/.cproject +++ /dev/null @@ -1,446 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/Lua/TestLua/proj.linux/.project b/samples/Lua/TestLua/proj.linux/.project deleted file mode 100644 index a7e8a57215..0000000000 --- a/samples/Lua/TestLua/proj.linux/.project +++ /dev/null @@ -1,56 +0,0 @@ - - - TestLua - - - libBox2D - libChipmunk - libcocos2d - libCocosDenshion - libextension - liblua - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - Classes - 2 - PARENT-1-PROJECT_LOC/Classes - - - cocos2dx_support - 2 - PARENT-4-PROJECT_LOC/scripting/lua/cocos2dx_support - - - - - 1373360472191 - - 22 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-Lua_web_socket.* - - - - diff --git a/samples/Lua/TestLua/proj.linux/Makefile b/samples/Lua/TestLua/proj.linux/Makefile deleted file mode 100644 index 8e9246c6ee..0000000000 --- a/samples/Lua/TestLua/proj.linux/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -EXECUTABLE = TestLua - -COCOS_ROOT = ../../../.. -INCLUDES = -I../Classes \ - -I$(COCOS_ROOT)/audio/include \ - -I$(COCOS_ROOT)/cocos/scripting/lua/bindings \ - -I$(COCOS_ROOT)/external/lua/lua \ - -I$(COCOS_ROOT)/external/lua/tolua \ - -I$(COCOS_ROOT)/extensions - -SOURCES = main.cpp \ -../Classes/AppDelegate.cpp \ -../Classes/lua_assetsmanager_test_sample.cpp - -SHAREDLIBS += -lcocos2d -lcocosdenshion -llua - -include $(COCOS_ROOT)/cocos/2d/cocos2dx.mk - -$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - cp -R -n ../../../../samples/Cpp/TestCpp/Resources ../../../../samples/Lua/TestLua - cp -n ../../../../cocos/scripting/lua/script/* ../../../../samples/Lua/TestLua/Resources - $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) - -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj b/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj index b95a8da2f8..7d04e0f16c 100644 --- a/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj +++ b/samples/Lua/TestLua/proj.win32/TestLua.win32.vcxproj @@ -72,7 +72,7 @@ Level3 MultiThreadedDebugDLL false - EditAndContinue + OldStyle EnableFastChecks Disabled WIN32;_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -184,6 +184,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\websockets\prebuilt\win32\*.*" "$ {b57cf53f-2e49-4031-9822-047cc0e6bde2} + + {b7c2a162-dec9-4418-972e-240ab3cbfcae} + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} diff --git a/template/multi-platform-cpp/CMakeLists.txt b/template/multi-platform-cpp/CMakeLists.txt index 2876cb3746..b2bfd73699 100644 --- a/template/multi-platform-cpp/CMakeLists.txt +++ b/template/multi-platform-cpp/CMakeLists.txt @@ -1,9 +1,9 @@ cmake_minimum_required(VERSION 2.6) -set(APP_NAME HelloCpp) +set(APP_NAME MyGame) project (${APP_NAME}) -include(../../build/BuildHelpers.CMakeLists.txt) +include(cocos2d/build/BuildHelpers.CMakeLists.txt) option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) @@ -45,7 +45,7 @@ set(GAME_SRC Classes/HelloWorldScene.cpp ) -set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/../..) +set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d) include_directories( ${COCOS2D_ROOT} @@ -76,7 +76,6 @@ include_directories( link_directories( /usr/local/lib - ${COCOS2D_ROOT}/lib ${COCOS2D_ROOT}/external/jpeg/prebuilt/linux/${ARCH_DIR} ${COCOS2D_ROOT}/external/tiff/prebuilt/linux/${ARCH_DIR} ${COCOS2D_ROOT}/external/webp/prebuilt/linux/${ARCH_DIR} @@ -85,6 +84,50 @@ link_directories( ${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR} ) +# kazmath +add_subdirectory(${COCOS2D_ROOT}/cocos/math/kazmath) + +# chipmunk library +add_subdirectory(${COCOS2D_ROOT}/external/chipmunk/src) + +# box2d library +add_subdirectory(${COCOS2D_ROOT}/external/Box2D) + +# unzip library +add_subdirectory(${COCOS2D_ROOT}/external/unzip) + +# tinyxml2 library +add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2) + +# audio +add_subdirectory(${COCOS2D_ROOT}/cocos/audio) + +# cocos base library +add_subdirectory(${COCOS2D_ROOT}/cocos/base) + +# cocos 2d library +add_subdirectory(${COCOS2D_ROOT}/cocos/2d) + +# gui +add_subdirectory(${COCOS2D_ROOT}/cocos/gui) + +# network +add_subdirectory(${COCOS2D_ROOT}/cocos/network) + +# extensions +add_subdirectory(${COCOS2D_ROOT}/extensions) + +## Editor Support + +# spine +add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/spine) + +# cocosbuilder +add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocosbuilder) + +# cocostudio +add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocostudio) + # add the executable add_executable(${APP_NAME} ${GAME_SRC} @@ -99,40 +142,15 @@ endif() target_link_libraries(${APP_NAME} gui network - curl - ldap - lber - idn - rtmp spine cocostudio cocosbuilder extensions - box2d audio - ${FMOD_LIB} cocos2d - cocosbase - chipmunk - tinyxml2 - kazmath - unzip - jpeg - webp - tiff - freetype - fontconfig - png - pthread - glfw - GLEW - GL - X11 - rt - z ) -set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin") +set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin") set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") diff --git a/template/multi-platform-cpp/proj.android/AndroidManifest.xml b/template/multi-platform-cpp/proj.android/AndroidManifest.xml index 466677da86..d2a87966cc 100644 --- a/template/multi-platform-cpp/proj.android/AndroidManifest.xml +++ b/template/multi-platform-cpp/proj.android/AndroidManifest.xml @@ -11,7 +11,7 @@ android:icon="@drawable/icon"> - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/template/multi-platform-cpp/proj.ios_mac/HelloCpp.xcodeproj/project.pbxproj b/template/multi-platform-cpp/proj.ios_mac/HelloCpp.xcodeproj/project.pbxproj index fdf23b3796..5b91461e19 100644 --- a/template/multi-platform-cpp/proj.ios_mac/HelloCpp.xcodeproj/project.pbxproj +++ b/template/multi-platform-cpp/proj.ios_mac/HelloCpp.xcodeproj/project.pbxproj @@ -243,7 +243,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../../../build/cocos2d_libs.xcodeproj; sourceTree = ""; }; + 1AC6FAE5180E9839004C840B /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../cocos2d/build/cocos2d_libs.xcodeproj; sourceTree = ""; }; 1ACB3243164770DE00914215 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../../cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = ""; }; 1AFAF8B316D35DE700DB1158 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppDelegate.cpp; path = ../Classes/AppDelegate.cpp; sourceTree = ""; }; 1AFAF8B416D35DE700DB1158 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ../Classes/AppDelegate.h; sourceTree = ""; }; @@ -820,8 +820,8 @@ GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ( "$(inherited)", - "$(SRCROOT)/../../../cocos/2d/platform/ios", - "$(SRCROOT)/../../../cocos/2d/platform/ios/Simulation", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/ios", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/ios/Simulation", ); INFOPLIST_FILE = ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; @@ -849,8 +849,8 @@ GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ( "$(inherited)", - "$(SRCROOT)/../../../cocos/2d/platform/ios", - "$(SRCROOT)/../../../cocos/2d/platform/ios/Simulation", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/ios", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/ios/Simulation", ); INFOPLIST_FILE = ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; @@ -881,8 +881,8 @@ GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ( "$(inherited)", - "$(SRCROOT)/../../../cocos/2d/platform/mac", - "$(SRCROOT)/../../../external/glfw3/include/mac", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/mac", + "$(SRCROOT)/../cocos2d/external/glfw3/include/mac", ); INFOPLIST_FILE = mac/Info.plist; LIBRARY_SEARCH_PATHS = ""; @@ -908,8 +908,8 @@ GCC_SYMBOLS_PRIVATE_EXTERN = NO; HEADER_SEARCH_PATHS = ( "$(inherited)", - "$(SRCROOT)/../../../cocos/2d/platform/mac", - "$(SRCROOT)/../../../external/glfw3/include/mac", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/mac", + "$(SRCROOT)/../cocos2d/external/glfw3/include/mac", ); INFOPLIST_FILE = mac/Info.plist; LIBRARY_SEARCH_PATHS = ""; @@ -927,19 +927,19 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( - "$(SRCROOT)/../../..", - "$(SRCROOT)/../../../cocos", - "$(SRCROOT)/../../../cocos/base", - "$(SRCROOT)/../../../cocos/physics", - "$(SRCROOT)/../../../cocos/math/kazmath/include", - "$(SRCROOT)/../../../cocos/2d", - "$(SRCROOT)/../../../cocos/gui", - "$(SRCROOT)/../../../cocos/network", - "$(SRCROOT)/../../../cocos/audio/include", - "$(SRCROOT)/../../../cocos/editor-support", - "$(SRCROOT)/../../../extensions", - "$(SRCROOT)/../../../external", - "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", + "$(SRCROOT)/../cocos2d", + "$(SRCROOT)/../cocos2d/cocos", + "$(SRCROOT)/../cocos2d/cocos/base", + "$(SRCROOT)/../cocos2d/cocos/physics", + "$(SRCROOT)/../cocos2d/cocos/math/kazmath/include", + "$(SRCROOT)/../cocos2d/cocos/2d", + "$(SRCROOT)/../cocos2d/cocos/gui", + "$(SRCROOT)/../cocos2d/cocos/network", + "$(SRCROOT)/../cocos2d/cocos/audio/include", + "$(SRCROOT)/../cocos2d/cocos/editor-support", + "$(SRCROOT)/../cocos2d/extensions", + "$(SRCROOT)/../cocos2d/external", + "$(SRCROOT)/../cocos2d/external/chipmunk/include/chipmunk", ); ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -955,19 +955,19 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( - "$(SRCROOT)/../../..", - "$(SRCROOT)/../../../cocos", - "$(SRCROOT)/../../../cocos/base", - "$(SRCROOT)/../../../cocos/physics", - "$(SRCROOT)/../../../cocos/math/kazmath/include", - "$(SRCROOT)/../../../cocos/2d", - "$(SRCROOT)/../../../cocos/gui", - "$(SRCROOT)/../../../cocos/network", - "$(SRCROOT)/../../../cocos/audio/include", - "$(SRCROOT)/../../../cocos/editor-support", - "$(SRCROOT)/../../../extensions", - "$(SRCROOT)/../../../external", - "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", + "$(SRCROOT)/../cocos2d", + "$(SRCROOT)/../cocos2d/cocos", + "$(SRCROOT)/../cocos2d/cocos/base", + "$(SRCROOT)/../cocos2d/cocos/physics", + "$(SRCROOT)/../cocos2d/cocos/math/kazmath/include", + "$(SRCROOT)/../cocos2d/cocos/2d", + "$(SRCROOT)/../cocos2d/cocos/gui", + "$(SRCROOT)/../cocos2d/cocos/network", + "$(SRCROOT)/../cocos2d/cocos/audio/include", + "$(SRCROOT)/../cocos2d/cocos/editor-support", + "$(SRCROOT)/../cocos2d/extensions", + "$(SRCROOT)/../cocos2d/external", + "$(SRCROOT)/../cocos2d/external/chipmunk/include/chipmunk", ); OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/template/multi-platform-cpp/proj.linux/.cproject b/template/multi-platform-cpp/proj.linux/.cproject deleted file mode 100644 index 9c759e341f..0000000000 --- a/template/multi-platform-cpp/proj.linux/.cproject +++ /dev/null @@ -1,422 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/template/multi-platform-cpp/proj.linux/.project b/template/multi-platform-cpp/proj.linux/.project deleted file mode 100644 index 7cd8c680f4..0000000000 --- a/template/multi-platform-cpp/proj.linux/.project +++ /dev/null @@ -1,110 +0,0 @@ - - - HelloCpp - - - libBox2D - libChipmunk - libcocos2d - libCocosDenshion - libextension - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?children? - ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\|| - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/HelloCpp/Debug} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - Classes - 2 - PARENT-1-PROJECT_LOC/Classes - - - - - 1345106176896 - Classes/ExtensionsTest - 10 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-true-false-EditBoxTest - - - - diff --git a/template/multi-platform-cpp/proj.linux/Makefile b/template/multi-platform-cpp/proj.linux/Makefile deleted file mode 100644 index 1b851ad66a..0000000000 --- a/template/multi-platform-cpp/proj.linux/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -EXECUTABLE = HelloCpp - -INCLUDES = -I.. -I../Classes - -SOURCES = main.cpp \ - ../Classes/AppDelegate.cpp \ - ../Classes/HelloWorldScene.cpp - -COCOS_ROOT = ../../.. -include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk - -SHAREDLIBS += -lcocos2d -COCOS_LIBS = $(LIB_DIR)/libcocos2d.so - -$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ - -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/template/multi-platform-cpp/proj.linux/build.sh b/template/multi-platform-cpp/proj.linux/build.sh index d6316e4764..99dcf294d3 100755 --- a/template/multi-platform-cpp/proj.linux/build.sh +++ b/template/multi-platform-cpp/proj.linux/build.sh @@ -1,59 +1,26 @@ #!/bin/bash -TXTCOLOR_DEFAULT="\033[0;m" -TXTCOLOR_RED="\033[0;31m" -TXTCOLOR_GREEN="\033[0;32m" +# Exit on error +set -e -COCOS2DX20_TRUNK=`pwd`/../../.. -OUTPUT_DEBUG=$COCOS2DX20_TRUNK/lib/linux/debug/ -OUTPUT_RELEASE=$COCOS2DX20_TRUNK/lib/linux/release/ +rm -rf ../bin +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -check_make_result() -{ - if [ 0 != $? ]; then - exit 1 - fi -} +#make global libs +cd ../cocos2d +#install depend libs +sudo ./build/install-deps-linux.sh +mkdir -p linux-build +cd linux-build +cmake .. -DBUILD_LIBS_LUA=OFF -DBUILD_HelloCpp=OFF -DBUILD_TestCpp=OFF -DBUILD_HelloLua=OFF -DBUILD_TestLua=OFF +make -j4 -DEPENDS='libx11-dev' -DEPENDS+=' libxmu-dev' -DEPENDS+=' libglu1-mesa-dev' -DEPENDS+=' libgl2ps-dev' -DEPENDS+=' libxi-dev' -DEPENDS+=' libglfw-dev' -DEPENDS+=' g++' -DEPENDS+=' libzip-dev' -DEPENDS+=' libcurl4-gnutls-dev' -DEPENDS+=' libfontconfig1-dev' -DEPENDS+=' libsqlite3-dev' -DEPENDS+=' libglew-dev' - -for i in $DEPENDS; do - PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $i | grep "install ok installed") - echo Checking for $i: $PKG_OK - if [ "" == "$PKG_OK" ]; then - echo -e $TXTCOLOR_GREEN"No $i. Setting up $i, please enter your password:"$TXTCOLOR_DEFAULT - sudo apt-get --force-yes --yes install $i - fi -done - -mkdir -p $OUTPUT_DEBUG -mkdir -p $OUTPUT_RELEASE - -make -C $COCOS2DX20_TRUNK/external/Box2D/proj.linux DEBUG=1 -check_make_result - -make -C $COCOS2DX20_TRUNK/external/chipmunk/proj.linux DEBUG=1 -check_make_result - -make -C $COCOS2DX20_TRUNK/cocos2dx/proj.linux DEBUG=1 -check_make_result - -make -C $COCOS2DX20_TRUNK/CocosDenshion/proj.linux DEBUG=1 -check_make_result - -make -C $COCOS2DX20_TRUNK/extensions/proj.linux DEBUG=1 -check_make_result - -make DEBUG=1 -check_make_result +#make bin +cd $DIR +rm -rf bin +mkdir -p build +cd build +cmake ../.. +make -j4 +cd .. +mv ../bin bin diff --git a/template/multi-platform-cpp/proj.linux/main.cpp b/template/multi-platform-cpp/proj.linux/main.cpp index fe87d9a1cd..78a0c780cb 100644 --- a/template/multi-platform-cpp/proj.linux/main.cpp +++ b/template/multi-platform-cpp/proj.linux/main.cpp @@ -14,6 +14,6 @@ int main(int argc, char **argv) // create the application instance AppDelegate app; EGLView eglView; - eglView.init("TestCPP",900,640); + eglView.init("Cocos2d-x Game",900,640); return Application::getInstance()->run(); } diff --git a/template/multi-platform-cpp/proj.win32/HelloCpp.sln b/template/multi-platform-cpp/proj.win32/HelloCpp.sln index 774ee12d79..b4dca4c0f5 100644 --- a/template/multi-platform-cpp/proj.win32/HelloCpp.sln +++ b/template/multi-platform-cpp/proj.win32/HelloCpp.sln @@ -8,11 +8,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp", "HelloCpp.vcxpro {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos2d\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\cocos2d\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\..\..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\cocos2d\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj b/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj index f2e35df259..e29153ca14 100644 --- a/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj +++ b/template/multi-platform-cpp/proj.win32/HelloCpp.vcxproj @@ -36,13 +36,13 @@ - - + + - - + + @@ -143,14 +143,14 @@ xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\win32\*.*" "$(OutDir)" - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} false - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/template/multi-platform-js/Classes/AppDelegate.cpp b/template/multi-platform-js/Classes/AppDelegate.cpp index 0794c10c9a..e409b974b5 100644 --- a/template/multi-platform-js/Classes/AppDelegate.cpp +++ b/template/multi-platform-js/Classes/AppDelegate.cpp @@ -5,7 +5,6 @@ #include "ScriptingCore.h" #include "jsb_cocos2dx_auto.hpp" #include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_spine_auto.hpp" #include "cocos2d_specifics.hpp" #include "extension/jsb_cocos2dx_extension_manual.h" #include "chipmunk/js_bindings_chipmunk_registration.h" @@ -41,7 +40,6 @@ bool AppDelegate::applicationDidFinishLaunching() sc->addRegisterCallback(register_all_cocos2dx_extension); sc->addRegisterCallback(register_cocos2dx_js_extensions); sc->addRegisterCallback(register_all_cocos2dx_extension_manual); - sc->addRegisterCallback(register_all_cocos2dx_spine); sc->addRegisterCallback(jsb_register_chipmunk); sc->addRegisterCallback(JSB_register_opengl); sc->addRegisterCallback(jsb_register_system); diff --git a/template/multi-platform-js/proj.android/AndroidManifest.xml b/template/multi-platform-js/proj.android/AndroidManifest.xml index 0977e3eb08..9b92bfa562 100644 --- a/template/multi-platform-js/proj.android/AndroidManifest.xml +++ b/template/multi-platform-js/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/template/multi-platform-js/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj b/template/multi-platform-js/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj index c43a50cddd..3f18ef509c 100644 --- a/template/multi-platform-js/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj +++ b/template/multi-platform-js/proj.ios_mac/HelloJavascript.xcodeproj/project.pbxproj @@ -275,26 +275,26 @@ /* Begin PBXFileReference section */ 15FD5C5F183A60FE005CFF55 /* cocos2d-jsb.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = "cocos2d-jsb.js"; path = "../Resources/cocos2d-jsb.js"; sourceTree = ""; }; 15FD5C67183A6112005CFF55 /* cocos2d-jsb.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = "cocos2d-jsb.js"; path = "../Resources/cocos2d-jsb.js"; sourceTree = ""; }; - 15FD5C69183A6170005CFF55 /* jsb_cocos2d_gui.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_gui.js; path = ../../../cocos/scripting/javascript/script/jsb_cocos2d_gui.js; sourceTree = ""; }; - 15FD5C6A183A6170005CFF55 /* jsb_cocos2d_studio.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_studio.js; path = ../../../cocos/scripting/javascript/script/jsb_cocos2d_studio.js; sourceTree = ""; }; - 15FD5C6D183A6189005CFF55 /* jsb_cocos2d_gui.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_gui.js; path = ../../../cocos/scripting/javascript/script/jsb_cocos2d_gui.js; sourceTree = ""; }; - 15FD5C6E183A6189005CFF55 /* jsb_cocos2d_studio.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_studio.js; path = ../../../cocos/scripting/javascript/script/jsb_cocos2d_studio.js; sourceTree = ""; }; - 1A6767ED180E9B160076BC67 /* debugger */ = {isa = PBXFileReference; lastKnownFileType = folder; name = debugger; path = ../../../cocos/scripting/javascript/script/debugger; sourceTree = ""; }; - 1A6767EE180E9B160076BC67 /* jsb_chipmunk_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_chipmunk_constants.js; path = ../../../cocos/scripting/javascript/script/jsb_chipmunk_constants.js; sourceTree = ""; }; - 1A6767EF180E9B160076BC67 /* jsb_chipmunk.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_chipmunk.js; path = ../../../cocos/scripting/javascript/script/jsb_chipmunk.js; sourceTree = ""; }; - 1A6767F0180E9B160076BC67 /* jsb_cocos2d_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_constants.js; path = ../../../cocos/scripting/javascript/script/jsb_cocos2d_constants.js; sourceTree = ""; }; - 1A6767F1180E9B160076BC67 /* jsb_cocos2d_extension.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_extension.js; path = ../../../cocos/scripting/javascript/script/jsb_cocos2d_extension.js; sourceTree = ""; }; - 1A6767F2180E9B160076BC67 /* jsb_cocos2d.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d.js; path = ../../../cocos/scripting/javascript/script/jsb_cocos2d.js; sourceTree = ""; }; - 1A6767F3180E9B160076BC67 /* jsb_cocosbuilder.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_cocosbuilder.js; path = ../../../cocos/scripting/javascript/script/jsb_cocosbuilder.js; sourceTree = ""; }; - 1A6767F4180E9B160076BC67 /* jsb_debugger.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_debugger.js; path = ../../../cocos/scripting/javascript/script/jsb_debugger.js; sourceTree = ""; }; - 1A6767F5180E9B160076BC67 /* jsb_deprecated.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_deprecated.js; path = ../../../cocos/scripting/javascript/script/jsb_deprecated.js; sourceTree = ""; }; - 1A6767F6180E9B160076BC67 /* jsb_opengl_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_opengl_constants.js; path = ../../../cocos/scripting/javascript/script/jsb_opengl_constants.js; sourceTree = ""; }; - 1A6767F7180E9B160076BC67 /* jsb_opengl.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_opengl.js; path = ../../../cocos/scripting/javascript/script/jsb_opengl.js; sourceTree = ""; }; - 1A6767F8180E9B160076BC67 /* jsb_sys.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_sys.js; path = ../../../cocos/scripting/javascript/script/jsb_sys.js; sourceTree = ""; }; - 1A6767F9180E9B160076BC67 /* jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb.js; path = ../../../cocos/scripting/javascript/script/jsb.js; sourceTree = ""; }; + 15FD5C69183A6170005CFF55 /* jsb_cocos2d_gui.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_gui.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_cocos2d_gui.js; sourceTree = ""; }; + 15FD5C6A183A6170005CFF55 /* jsb_cocos2d_studio.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_studio.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_cocos2d_studio.js; sourceTree = ""; }; + 15FD5C6D183A6189005CFF55 /* jsb_cocos2d_gui.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_gui.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_cocos2d_gui.js; sourceTree = ""; }; + 15FD5C6E183A6189005CFF55 /* jsb_cocos2d_studio.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_studio.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_cocos2d_studio.js; sourceTree = ""; }; + 1A6767ED180E9B160076BC67 /* debugger */ = {isa = PBXFileReference; lastKnownFileType = folder; name = debugger; path = ../cocos2d/cocos/scripting/javascript/script/debugger; sourceTree = ""; }; + 1A6767EE180E9B160076BC67 /* jsb_chipmunk_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_chipmunk_constants.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_chipmunk_constants.js; sourceTree = ""; }; + 1A6767EF180E9B160076BC67 /* jsb_chipmunk.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_chipmunk.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_chipmunk.js; sourceTree = ""; }; + 1A6767F0180E9B160076BC67 /* jsb_cocos2d_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_constants.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_cocos2d_constants.js; sourceTree = ""; }; + 1A6767F1180E9B160076BC67 /* jsb_cocos2d_extension.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d_extension.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_cocos2d_extension.js; sourceTree = ""; }; + 1A6767F2180E9B160076BC67 /* jsb_cocos2d.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_cocos2d.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_cocos2d.js; sourceTree = ""; }; + 1A6767F3180E9B160076BC67 /* jsb_cocosbuilder.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_cocosbuilder.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_cocosbuilder.js; sourceTree = ""; }; + 1A6767F4180E9B160076BC67 /* jsb_debugger.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_debugger.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_debugger.js; sourceTree = ""; }; + 1A6767F5180E9B160076BC67 /* jsb_deprecated.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_deprecated.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_deprecated.js; sourceTree = ""; }; + 1A6767F6180E9B160076BC67 /* jsb_opengl_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_opengl_constants.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_opengl_constants.js; sourceTree = ""; }; + 1A6767F7180E9B160076BC67 /* jsb_opengl.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_opengl.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_opengl.js; sourceTree = ""; }; + 1A6767F8180E9B160076BC67 /* jsb_sys.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_sys.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb_sys.js; sourceTree = ""; }; + 1A6767F9180E9B160076BC67 /* jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb.js; path = ../cocos2d/cocos/scripting/javascript/script/jsb.js; sourceTree = ""; }; 1A82F5FA169AC92500C4B13A /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; - 1A96A4F2174A3432008653A9 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../../../cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = ""; }; - 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../../../build/cocos2d_libs.xcodeproj; sourceTree = ""; }; + 1A96A4F2174A3432008653A9 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../cocos2d/cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = ""; }; + 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../cocos2d/build/cocos2d_libs.xcodeproj; sourceTree = ""; }; 1AE4B40016D1FECD003C6D1C /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = main.js; path = ../Resources/main.js; sourceTree = ""; }; 1AE4B40116D1FECD003C6D1C /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; name = res; path = ../Resources/res; sourceTree = ""; }; 1AE4B40216D1FECD003C6D1C /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; name = src; path = ../Resources/src; sourceTree = ""; }; @@ -905,9 +905,9 @@ ); HEADER_SEARCH_PATHS = ( "$(inherited)", - "$(SRCROOT)/../../../cocos/2d/platform/mac", - "$(SRCROOT)/../../../external/spidermonkey/include/mac", - "$(SRCROOT)/../../../external/glfw3/include/mac", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/mac", + "$(SRCROOT)/../cocos2d/external/spidermonkey/include/mac", + "$(SRCROOT)/../cocos2d/external/glfw3/include/mac", ); INFOPLIST_FILE = mac/Info.plist; LIBRARY_SEARCH_PATHS = ""; @@ -930,9 +930,9 @@ ); HEADER_SEARCH_PATHS = ( "$(inherited)", - "$(SRCROOT)/../../../cocos/2d/platform/mac", - "$(SRCROOT)/../../../external/spidermonkey/include/mac", - "$(SRCROOT)/../../../external/glfw3/include/mac", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/mac", + "$(SRCROOT)/../cocos2d/external/spidermonkey/include/mac", + "$(SRCROOT)/../cocos2d/external/glfw3/include/mac", ); INFOPLIST_FILE = mac/Info.plist; LIBRARY_SEARCH_PATHS = ""; @@ -960,21 +960,21 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( - "$(SRCROOT)/../../..", - "$(SRCROOT)/../../../cocos", - "$(SRCROOT)/../../../cocos/base", - "$(SRCROOT)/../../../cocos/physics", - "$(SRCROOT)/../../../cocos/math/kazmath/include", - "$(SRCROOT)/../../../cocos/2d", - "$(SRCROOT)/../../../cocos/gui", - "$(SRCROOT)/../../../cocos/network", - "$(SRCROOT)/../../../cocos/audio/include", - "$(SRCROOT)/../../../cocos/editor-support", - "$(SRCROOT)/../../../cocos/scripting/javascript/bindings", - "$(SRCROOT)/../../../cocos/scripting/auto-generated/js-bindings", - "$(SRCROOT)/../../../extensions", - "$(SRCROOT)/../../../external", - "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", + "$(SRCROOT)/../cocos2d", + "$(SRCROOT)/../cocos2d/cocos", + "$(SRCROOT)/../cocos2d/cocos/base", + "$(SRCROOT)/../cocos2d/cocos/physics", + "$(SRCROOT)/../cocos2d/cocos/math/kazmath/include", + "$(SRCROOT)/../cocos2d/cocos/2d", + "$(SRCROOT)/../cocos2d/cocos/gui", + "$(SRCROOT)/../cocos2d/cocos/network", + "$(SRCROOT)/../cocos2d/cocos/audio/include", + "$(SRCROOT)/../cocos2d/cocos/editor-support", + "$(SRCROOT)/../cocos2d/cocos/scripting/javascript/bindings", + "$(SRCROOT)/../cocos2d/cocos/scripting/auto-generated/js-bindings", + "$(SRCROOT)/../cocos2d/extensions", + "$(SRCROOT)/../cocos2d/external", + "$(SRCROOT)/../cocos2d/external/chipmunk/include/chipmunk", ); IPHONEOS_DEPLOYMENT_TARGET = 5.1; ONLY_ACTIVE_ARCH = YES; @@ -997,21 +997,21 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( - "$(SRCROOT)/../../..", - "$(SRCROOT)/../../../cocos", - "$(SRCROOT)/../../../cocos/base", - "$(SRCROOT)/../../../cocos/physics", - "$(SRCROOT)/../../../cocos/math/kazmath/include", - "$(SRCROOT)/../../../cocos/2d", - "$(SRCROOT)/../../../cocos/gui", - "$(SRCROOT)/../../../cocos/network", - "$(SRCROOT)/../../../cocos/audio/include", - "$(SRCROOT)/../../../cocos/editor-support", - "$(SRCROOT)/../../../cocos/scripting/javascript/bindings", - "$(SRCROOT)/../../../cocos/scripting/auto-generated/js-bindings", - "$(SRCROOT)/../../../extensions", - "$(SRCROOT)/../../../external", - "$(SRCROOT)/../../../external/chipmunk/include/chipmunk", + "$(SRCROOT)/../cocos2d", + "$(SRCROOT)/../cocos2d/cocos", + "$(SRCROOT)/../cocos2d/cocos/base", + "$(SRCROOT)/../cocos2d/cocos/physics", + "$(SRCROOT)/../cocos2d/cocos/math/kazmath/include", + "$(SRCROOT)/../cocos2d/cocos/2d", + "$(SRCROOT)/../cocos2d/cocos/gui", + "$(SRCROOT)/../cocos2d/cocos/network", + "$(SRCROOT)/../cocos2d/cocos/audio/include", + "$(SRCROOT)/../cocos2d/cocos/editor-support", + "$(SRCROOT)/../cocos2d/cocos/scripting/javascript/bindings", + "$(SRCROOT)/../cocos2d/cocos/scripting/auto-generated/js-bindings", + "$(SRCROOT)/../cocos2d/extensions", + "$(SRCROOT)/../cocos2d/external", + "$(SRCROOT)/../cocos2d/external/chipmunk/include/chipmunk", ); IPHONEOS_DEPLOYMENT_TARGET = 5.1; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; @@ -1035,9 +1035,9 @@ ); HEADER_SEARCH_PATHS = ( "$(inherited)", - "$(SRCROOT)/../../../cocos/2d/platform/ios", - "$(SRCROOT)/../../../cocos/2d/platform/ios/Simulation", - "$(SRCROOT)/../../../external/spidermonkey/include/ios", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/ios", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/ios/Simulation", + "$(SRCROOT)/../cocos2d/external/spidermonkey/include/ios", ); INFOPLIST_FILE = ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; @@ -1062,9 +1062,9 @@ ); HEADER_SEARCH_PATHS = ( "$(inherited)", - "$(SRCROOT)/../../../cocos/2d/platform/ios", - "$(SRCROOT)/../../../cocos/2d/platform/ios/Simulation", - "$(SRCROOT)/../../../external/spidermonkey/include/ios", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/ios", + "$(SRCROOT)/../cocos2d/cocos/2d/platform/ios/Simulation", + "$(SRCROOT)/../cocos2d/external/spidermonkey/include/ios", ); INFOPLIST_FILE = ios/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; diff --git a/template/multi-platform-js/proj.win32/HelloJavascript.sln b/template/multi-platform-js/proj.win32/HelloJavascript.sln index 5880df4c17..05d76f1c83 100644 --- a/template/multi-platform-js/proj.win32/HelloJavascript.sln +++ b/template/multi-platform-js/proj.win32/HelloJavascript.sln @@ -10,16 +10,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloJavascript", "HelloJav {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos2d\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\cocos2d\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\..\..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\cocos2d\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" ProjectSection(ProjectDependencies) = postProject {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "..\..\..\cocos\scripting\javascript\bindings\proj.win32\libJSBinding.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "..\cocos2d\cocos\scripting\javascript\bindings\proj.win32\libJSBinding.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}" ProjectSection(ProjectDependencies) = postProject {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} @@ -27,15 +27,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBinding", "..\..\..\co {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForChipmunk", "..\..\..\cocos\scripting\javascript\bindings\chipmunk\libJSBindingForChipmunk.vcxproj", "{21070E58-EEC6-4E16-8B4F-6D083DF55790}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForChipmunk", "..\cocos2d\cocos\scripting\javascript\bindings\chipmunk\libJSBindingForChipmunk.vcxproj", "{21070E58-EEC6-4E16-8B4F-6D083DF55790}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libLocalStorage", "..\..\..\cocos\storage\local-storage\proj.win32\libLocalStorage.vcxproj", "{632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libLocalStorage", "..\cocos2d\cocos\storage\local-storage\proj.win32\libLocalStorage.vcxproj", "{632A8F38-D0F0-4D22-86B3-D69F5E6BF63A}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForLocalStorage", "..\..\..\cocos\scripting\javascript\bindings\localstorage\libJSBindingForLocalStorage.vcxproj", "{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForLocalStorage", "..\cocos2d\cocos\scripting\javascript\bindings\localstorage\libJSBindingForLocalStorage.vcxproj", "{68F5F371-BD7B-4C30-AE5B-0B08F22E0CDE}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForExtension", "..\..\..\cocos\scripting\javascript\bindings\extension\libJSBindingForExtension.vcxproj", "{625F7391-9A91-48A1-8CFC-79508C822637}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libJSBindingForExtension", "..\cocos2d\cocos\scripting\javascript\bindings\extension\libJSBindingForExtension.vcxproj", "{625F7391-9A91-48A1-8CFC-79508C822637}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\..\..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\cocos2d\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj b/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj index 35da6b1ee0..caf0791fc7 100644 --- a/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj +++ b/template/multi-platform-js/proj.win32/HelloJavascript.vcxproj @@ -34,13 +34,13 @@ - - + + - - + + @@ -184,31 +184,31 @@ xcopy "$(ProjectDir)..\Resources" "$(OutDir)\HelloJavascriptRes\" /e /Y - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - + {21070e58-eec6-4e16-8b4f-6d083df55790} - + {625f7391-9a91-48a1-8cfc-79508c822637} - + {68f5f371-bd7b-4c30-ae5b-0b08f22e0cde} - + {39379840-825a-45a0-b363-c09ffef864bd} - + {632a8f38-d0f0-4d22-86b3-d69f5e6bf63a} - + {21b2c324-891f-48ea-ad1a-5ae13de12e28} - + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/template/multi-platform-lua/CMakeLists.txt b/template/multi-platform-lua/CMakeLists.txt index 48fa5bf121..ccf8e4b634 100644 --- a/template/multi-platform-lua/CMakeLists.txt +++ b/template/multi-platform-lua/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.6) set(APP_NAME HelloLua) project (${APP_NAME}) -include(../../build/BuildHelpers.CMakeLists.txt) +include(cocos2d/build/BuildHelpers.CMakeLists.txt) option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) @@ -44,7 +44,7 @@ set(GAME_SRC Classes/AppDelegate.cpp ) -set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/../..) +set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d) include_directories( Classes @@ -79,7 +79,6 @@ include_directories( link_directories( /usr/local/lib - ${COCOS2D_ROOT}/lib ${COCOS2D_ROOT}/external/jpeg/prebuilt/linux/${ARCH_DIR} ${COCOS2D_ROOT}/external/tiff/prebuilt/linux/${ARCH_DIR} ${COCOS2D_ROOT}/external/webp/prebuilt/linux/${ARCH_DIR} @@ -88,6 +87,60 @@ link_directories( ${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR} ) +# kazmath +add_subdirectory(${COCOS2D_ROOT}/cocos/math/kazmath) + +# chipmunk library +add_subdirectory(${COCOS2D_ROOT}/external/chipmunk/src) + +# box2d library +add_subdirectory(${COCOS2D_ROOT}/external/Box2D) + +# unzip library +add_subdirectory(${COCOS2D_ROOT}/external/unzip) + +# tinyxml2 library +add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2) + +# audio +add_subdirectory(${COCOS2D_ROOT}/cocos/audio) + +# cocos base library +add_subdirectory(${COCOS2D_ROOT}/cocos/base) + +# cocos 2d library +add_subdirectory(${COCOS2D_ROOT}/cocos/2d) + +# gui +add_subdirectory(${COCOS2D_ROOT}/cocos/gui) + +# network +add_subdirectory(${COCOS2D_ROOT}/cocos/network) + +# extensions +add_subdirectory(${COCOS2D_ROOT}/extensions) + +## Editor Support + +# spine +add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/spine) + +# cocosbuilder +add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocosbuilder) + +# cocostudio +add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocostudio) + +## Scripting +# lua +add_subdirectory(${COCOS2D_ROOT}/external/lua/lua) + +# tolua +add_subdirectory(${COCOS2D_ROOT}/external/lua/tolua) + +# luabinding +add_subdirectory(${COCOS2D_ROOT}/cocos/scripting) + # add the executable add_executable(${APP_NAME} ${GAME_SRC} @@ -101,44 +154,17 @@ endif() target_link_libraries(${APP_NAME} luabinding - tolua - lua gui network - curl - ldap - lber - idn - rtmp spine cocostudio cocosbuilder extensions - box2d audio - ${FMOD_LIB} cocos2d - cocosbase - chipmunk - tinyxml2 - kazmath - unzip - jpeg - webp - tiff - freetype - fontconfig - png - pthread - glfw - GLEW - GL - X11 - rt - z ) -set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/bin") +set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin") set_target_properties(${APP_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") @@ -146,5 +172,6 @@ set_target_properties(${APP_NAME} PROPERTIES pre_build(${APP_NAME} COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources + COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_ROOT}/cocos/scripting/lua/script ${APP_BIN_DIR}/Resources ) diff --git a/template/multi-platform-lua/proj.android/AndroidManifest.xml b/template/multi-platform-lua/proj.android/AndroidManifest.xml index 17a26a9913..fb69c258c2 100644 --- a/template/multi-platform-lua/proj.android/AndroidManifest.xml +++ b/template/multi-platform-lua/proj.android/AndroidManifest.xml @@ -10,7 +10,7 @@ - delete + //EGL_GREEN_SIZE, 6, -->delete + //EGL_RED_SIZE, 5, -->delete + EGL_BUFFER_SIZE, 32, //-->new field + EGL_DEPTH_SIZE, 16, + EGL_STENCIL_SIZE, 8, + EGL_NONE + };*/ + + //2.Set the format of window + // getWindow().setFormat(PixelFormat.TRANSLUCENT); + + } +} diff --git a/template/multi-platform-lua/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj b/template/multi-platform-lua/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj index ec0d5f7366..eecc14f8cb 100644 --- a/template/multi-platform-lua/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj +++ b/template/multi-platform-lua/proj.ios_mac/HelloLua.xcodeproj/project.pbxproj @@ -7,6 +7,12 @@ objects = { /* Begin PBXBuildFile section */ + 01A8D331187A504A001CC002 /* CocoStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 01A8D32E187A5049001CC002 /* CocoStudio.lua */; }; + 01A8D332187A504A001CC002 /* CocoStudio.lua in Resources */ = {isa = PBXBuildFile; fileRef = 01A8D32E187A5049001CC002 /* CocoStudio.lua */; }; + 01A8D333187A504A001CC002 /* extern.lua in Resources */ = {isa = PBXBuildFile; fileRef = 01A8D32F187A504A001CC002 /* extern.lua */; }; + 01A8D334187A504A001CC002 /* extern.lua in Resources */ = {isa = PBXBuildFile; fileRef = 01A8D32F187A504A001CC002 /* extern.lua */; }; + 01A8D335187A504A001CC002 /* GuiConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 01A8D330187A504A001CC002 /* GuiConstants.lua */; }; + 01A8D336187A504A001CC002 /* GuiConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 01A8D330187A504A001CC002 /* GuiConstants.lua */; }; 15A8A4441834C43700142BE0 /* libchipmunk iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4291834BDA200142BE0 /* libchipmunk iOS.a */; }; 15A8A4451834C43700142BE0 /* libcocos2dx iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4251834BDA200142BE0 /* libcocos2dx iOS.a */; }; 15A8A4461834C43700142BE0 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15A8A4271834BDA200142BE0 /* libcocos2dx-extensions iOS.a */; }; @@ -219,24 +225,27 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../../../build/cocos2d_libs.xcodeproj; sourceTree = ""; }; - 15A8A4551834C6AD00142BE0 /* AudioEngine.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = AudioEngine.lua; path = ../../../cocos/scripting/lua/script/AudioEngine.lua; sourceTree = ""; }; - 15A8A4561834C6AD00142BE0 /* CCBReaderLoad.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CCBReaderLoad.lua; path = ../../../cocos/scripting/lua/script/CCBReaderLoad.lua; sourceTree = ""; }; - 15A8A4571834C6AD00142BE0 /* Cocos2d.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2d.lua; path = ../../../cocos/scripting/lua/script/Cocos2d.lua; sourceTree = ""; }; - 15A8A4581834C6AD00142BE0 /* Cocos2dConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2dConstants.lua; path = ../../../cocos/scripting/lua/script/Cocos2dConstants.lua; sourceTree = ""; }; - 15A8A4591834C6AD00142BE0 /* Deprecated.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Deprecated.lua; path = ../../../cocos/scripting/lua/script/Deprecated.lua; sourceTree = ""; }; - 15A8A45A1834C6AD00142BE0 /* DeprecatedClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedClass.lua; path = ../../../cocos/scripting/lua/script/DeprecatedClass.lua; sourceTree = ""; }; - 15A8A45B1834C6AD00142BE0 /* DeprecatedEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedEnum.lua; path = ../../../cocos/scripting/lua/script/DeprecatedEnum.lua; sourceTree = ""; }; - 15A8A45C1834C6AD00142BE0 /* DeprecatedOpenglEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedOpenglEnum.lua; path = ../../../cocos/scripting/lua/script/DeprecatedOpenglEnum.lua; sourceTree = ""; }; - 15A8A45D1834C6AD00142BE0 /* DrawPrimitives.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DrawPrimitives.lua; path = ../../../cocos/scripting/lua/script/DrawPrimitives.lua; sourceTree = ""; }; - 15A8A45E1834C6AD00142BE0 /* json.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = json.lua; path = ../../../cocos/scripting/lua/script/json.lua; sourceTree = ""; }; - 15A8A45F1834C6AD00142BE0 /* luaj.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = luaj.lua; path = ../../../cocos/scripting/lua/script/luaj.lua; sourceTree = ""; }; - 15A8A4601834C6AD00142BE0 /* luaoc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = luaoc.lua; path = ../../../cocos/scripting/lua/script/luaoc.lua; sourceTree = ""; }; - 15A8A4611834C6AD00142BE0 /* Opengl.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Opengl.lua; path = ../../../cocos/scripting/lua/script/Opengl.lua; sourceTree = ""; }; - 15A8A4621834C6AD00142BE0 /* OpenglConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OpenglConstants.lua; path = ../../../cocos/scripting/lua/script/OpenglConstants.lua; sourceTree = ""; }; - 15A8A4631834C6AD00142BE0 /* StudioConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = StudioConstants.lua; path = ../../../cocos/scripting/lua/script/StudioConstants.lua; sourceTree = ""; }; + 01A8D32E187A5049001CC002 /* CocoStudio.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CocoStudio.lua; path = ../cocos2d/cocos/scripting/lua/script/CocoStudio.lua; sourceTree = ""; }; + 01A8D32F187A504A001CC002 /* extern.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = extern.lua; path = ../cocos2d/cocos/scripting/lua/script/extern.lua; sourceTree = ""; }; + 01A8D330187A504A001CC002 /* GuiConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = GuiConstants.lua; path = ../cocos2d/cocos/scripting/lua/script/GuiConstants.lua; sourceTree = ""; }; + 15A8A4031834BDA200142BE0 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../cocos2d/build/cocos2d_libs.xcodeproj; sourceTree = ""; }; + 15A8A4551834C6AD00142BE0 /* AudioEngine.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = AudioEngine.lua; path = ../cocos2d/cocos/scripting/lua/script/AudioEngine.lua; sourceTree = ""; }; + 15A8A4561834C6AD00142BE0 /* CCBReaderLoad.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CCBReaderLoad.lua; path = ../cocos2d/cocos/scripting/lua/script/CCBReaderLoad.lua; sourceTree = ""; }; + 15A8A4571834C6AD00142BE0 /* Cocos2d.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2d.lua; path = ../cocos2d/cocos/scripting/lua/script/Cocos2d.lua; sourceTree = ""; }; + 15A8A4581834C6AD00142BE0 /* Cocos2dConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2dConstants.lua; path = ../cocos2d/cocos/scripting/lua/script/Cocos2dConstants.lua; sourceTree = ""; }; + 15A8A4591834C6AD00142BE0 /* Deprecated.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Deprecated.lua; path = ../cocos2d/cocos/scripting/lua/script/Deprecated.lua; sourceTree = ""; }; + 15A8A45A1834C6AD00142BE0 /* DeprecatedClass.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedClass.lua; path = ../cocos2d/cocos/scripting/lua/script/DeprecatedClass.lua; sourceTree = ""; }; + 15A8A45B1834C6AD00142BE0 /* DeprecatedEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedEnum.lua; path = ../cocos2d/cocos/scripting/lua/script/DeprecatedEnum.lua; sourceTree = ""; }; + 15A8A45C1834C6AD00142BE0 /* DeprecatedOpenglEnum.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DeprecatedOpenglEnum.lua; path = ../cocos2d/cocos/scripting/lua/script/DeprecatedOpenglEnum.lua; sourceTree = ""; }; + 15A8A45D1834C6AD00142BE0 /* DrawPrimitives.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = DrawPrimitives.lua; path = ../cocos2d/cocos/scripting/lua/script/DrawPrimitives.lua; sourceTree = ""; }; + 15A8A45E1834C6AD00142BE0 /* json.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = json.lua; path = ../cocos2d/cocos/scripting/lua/script/json.lua; sourceTree = ""; }; + 15A8A45F1834C6AD00142BE0 /* luaj.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = luaj.lua; path = ../cocos2d/cocos/scripting/lua/script/luaj.lua; sourceTree = ""; }; + 15A8A4601834C6AD00142BE0 /* luaoc.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = luaoc.lua; path = ../cocos2d/cocos/scripting/lua/script/luaoc.lua; sourceTree = ""; }; + 15A8A4611834C6AD00142BE0 /* Opengl.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Opengl.lua; path = ../cocos2d/cocos/scripting/lua/script/Opengl.lua; sourceTree = ""; }; + 15A8A4621834C6AD00142BE0 /* OpenglConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OpenglConstants.lua; path = ../cocos2d/cocos/scripting/lua/script/OpenglConstants.lua; sourceTree = ""; }; + 15A8A4631834C6AD00142BE0 /* StudioConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = StudioConstants.lua; path = ../cocos2d/cocos/scripting/lua/script/StudioConstants.lua; sourceTree = ""; }; 15A8A4871834C90E00142BE0 /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; }; - 15C1568D1683131500D239F2 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../../../cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = ""; }; + 15C1568D1683131500D239F2 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../cocos2d/cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = ""; }; 1AC3622316D47C5C000847F2 /* background.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = background.mp3; path = ../Resources/background.mp3; sourceTree = ""; }; 1AC3622416D47C5C000847F2 /* background.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; name = background.ogg; path = ../Resources/background.ogg; sourceTree = ""; }; 1AC3622516D47C5C000847F2 /* crop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = crop.png; path = ../Resources/crop.png; sourceTree = ""; }; @@ -370,6 +379,9 @@ 1A0227A417A3AA1A00B867AD /* Lua Common */ = { isa = PBXGroup; children = ( + 01A8D32E187A5049001CC002 /* CocoStudio.lua */, + 01A8D32F187A504A001CC002 /* extern.lua */, + 01A8D330187A504A001CC002 /* GuiConstants.lua */, 15A8A4551834C6AD00142BE0 /* AudioEngine.lua */, 15A8A4561834C6AD00142BE0 /* CCBReaderLoad.lua */, 15A8A4571834C6AD00142BE0 /* Cocos2d.lua */, @@ -722,6 +734,9 @@ 5023815717EBBCE400990C9B /* menu2.png in Resources */, 5023817617EBBE3400990C9B /* Icon.icns in Resources */, 15A8A4651834C6AD00142BE0 /* AudioEngine.lua in Resources */, + 01A8D332187A504A001CC002 /* CocoStudio.lua in Resources */, + 01A8D334187A504A001CC002 /* extern.lua in Resources */, + 01A8D336187A504A001CC002 /* GuiConstants.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -772,6 +787,9 @@ 5023811A17EBBCAC00990C9B /* Default.png in Resources */, 5091733817ECE17A00D62437 /* Icon-50.png in Resources */, 5023812117EBBCAC00990C9B /* Icon-72.png in Resources */, + 01A8D331187A504A001CC002 /* CocoStudio.lua in Resources */, + 01A8D333187A504A001CC002 /* extern.lua in Resources */, + 01A8D335187A504A001CC002 /* GuiConstants.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -824,7 +842,7 @@ 10000, ); SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../cocos $(SRCROOT)/../../../cocos/base $(SRCROOT)/../../../cocos/2d $(SRCROOT)/../../../cocos/physics $(SRCROOT)/../../../cocos/math/kazmath/include $(SRCROOT)/../../../cocos/2d/platform/mac $(SRCROOT)/../../../cocos/audio/include $(SRCROOT)/../../../cocos/editor-support $(SRCROOT)/../../../cocos/gui $(SRCROOT)/../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../external $(SRCROOT)/../../../external/glfw3/include/mac $(SRCROOT)/../../../cocos/scripting/lua/bindings $(SRCROOT)/../../../external/lua/luajit/include $(SRCROOT)/../../../external/lua/tolua"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos2d/cocos $(SRCROOT)/../cocos2d/cocos/base $(SRCROOT)/../cocos2d/cocos/2d $(SRCROOT)/../cocos2d/cocos/physics $(SRCROOT)/../cocos2d/cocos/math/kazmath/include $(SRCROOT)/../cocos2d/cocos/2d/platform/mac $(SRCROOT)/../cocos2d/cocos/audio/include $(SRCROOT)/../cocos2d/cocos/editor-support $(SRCROOT)/../cocos2d/cocos/gui $(SRCROOT)/../cocos2d/external/chipmunk/include/chipmunk $(SRCROOT)/../cocos2d/external $(SRCROOT)/../cocos2d/external/glfw3/include/mac $(SRCROOT)/../cocos2d/cocos/scripting/lua/bindings $(SRCROOT)/../cocos2d/external/lua/luajit/include $(SRCROOT)/../cocos2d/external/lua/tolua"; }; name = Debug; }; @@ -850,7 +868,7 @@ 10000, ); SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../cocos $(SRCROOT)/../../../cocos/base $(SRCROOT)/../../../cocos/2d $(SRCROOT)/../../../cocos/physics $(SRCROOT)/../../../cocos/math/kazmath/include $(SRCROOT)/../../../cocos/2d/platform/mac $(SRCROOT)/../../../cocos/audio/include $(SRCROOT)/../../../cocos/editor-support $(SRCROOT)/../../../cocos/gui $(SRCROOT)/../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../external $(SRCROOT)/../../../external/glfw3/include/mac $(SRCROOT)/../../../cocos/scripting/lua/bindings $(SRCROOT)/../../../external/lua/luajit/include $(SRCROOT)/../../../external/lua/tolua"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos2d/cocos $(SRCROOT)/../cocos2d/cocos/base $(SRCROOT)/../cocos2d/cocos/2d $(SRCROOT)/../cocos2d/cocos/physics $(SRCROOT)/../cocos2d/cocos/math/kazmath/include $(SRCROOT)/../cocos2d/cocos/2d/platform/mac $(SRCROOT)/../cocos2d/cocos/audio/include $(SRCROOT)/../cocos2d/cocos/editor-support $(SRCROOT)/../cocos2d/cocos/gui $(SRCROOT)/../cocos2d/external/chipmunk/include/chipmunk $(SRCROOT)/../cocos2d/external $(SRCROOT)/../cocos2d/external/glfw3/include/mac $(SRCROOT)/../cocos2d/cocos/scripting/lua/bindings $(SRCROOT)/../cocos2d/external/lua/luajit/include $(SRCROOT)/../cocos2d/external/lua/tolua"; }; name = Release; }; @@ -942,7 +960,7 @@ LIBRARY_SEARCH_PATHS = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../cocos $(SRCROOT)/../../../cocos/base $(SRCROOT)/../../../cocos/2d $(SRCROOT)/../../../cocos/physics $(SRCROOT)/../../../cocos/math/kazmath/include $(SRCROOT)/../../../cocos/2d/platform/ios $(SRCROOT)/../../../cocos/audio/include $(SRCROOT)/../../../cocos/editor-support $(SRCROOT)/../../../cocos/gui $(SRCROOT)/../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../external $(SRCROOT)/../../../cocos/scripting/lua/bindings $(SRCROOT)/../../../external/lua/luajit/include $(SRCROOT)/../../../external/lua/tolua"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos2d/cocos $(SRCROOT)/../cocos2d/cocos/base $(SRCROOT)/../cocos2d/cocos/2d $(SRCROOT)/../cocos2d/cocos/physics $(SRCROOT)/../cocos2d/cocos/math/kazmath/include $(SRCROOT)/../cocos2d/cocos/2d/platform/ios $(SRCROOT)/../cocos2d/cocos/audio/include $(SRCROOT)/../cocos2d/cocos/editor-support $(SRCROOT)/../cocos2d/cocos/gui $(SRCROOT)/../cocos2d/external/chipmunk/include/chipmunk $(SRCROOT)/../cocos2d/external $(SRCROOT)/../cocos2d/cocos/scripting/lua/bindings $(SRCROOT)/../cocos2d/external/lua/luajit/include $(SRCROOT)/../cocos2d/external/lua/tolua"; }; name = Debug; }; @@ -964,7 +982,7 @@ LIBRARY_SEARCH_PATHS = ""; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../cocos $(SRCROOT)/../../../cocos/base $(SRCROOT)/../../../cocos/2d $(SRCROOT)/../../../cocos/physics $(SRCROOT)/../../../cocos/math/kazmath/include $(SRCROOT)/../../../cocos/2d/platform/ios $(SRCROOT)/../../../cocos/audio/include $(SRCROOT)/../../../cocos/editor-support $(SRCROOT)/../../../cocos/gui $(SRCROOT)/../../../external/chipmunk/include/chipmunk $(SRCROOT)/../../../external $(SRCROOT)/../../../cocos/scripting/lua/bindings $(SRCROOT)/../../../external/lua/luajit/include $(SRCROOT)/../../../external/lua/tolua"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../cocos2d/cocos $(SRCROOT)/../cocos2d/cocos/base $(SRCROOT)/../cocos2d/cocos/2d $(SRCROOT)/../cocos2d/cocos/physics $(SRCROOT)/../cocos2d/cocos/math/kazmath/include $(SRCROOT)/../cocos2d/cocos/2d/platform/ios $(SRCROOT)/../cocos2d/cocos/audio/include $(SRCROOT)/../cocos2d/cocos/editor-support $(SRCROOT)/../cocos2d/cocos/gui $(SRCROOT)/../cocos2d/external/chipmunk/include/chipmunk $(SRCROOT)/../cocos2d/external $(SRCROOT)/../cocos2d/cocos/scripting/lua/bindings $(SRCROOT)/../cocos2d/external/lua/luajit/include $(SRCROOT)/../cocos2d/external/lua/tolua"; }; name = Release; }; diff --git a/template/multi-platform-lua/proj.linux/.cproject b/template/multi-platform-lua/proj.linux/.cproject deleted file mode 100644 index d0575ca9b7..0000000000 --- a/template/multi-platform-lua/proj.linux/.cproject +++ /dev/null @@ -1,411 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/template/multi-platform-lua/proj.linux/.project b/template/multi-platform-lua/proj.linux/.project deleted file mode 100644 index 54e0b8d7d3..0000000000 --- a/template/multi-platform-lua/proj.linux/.project +++ /dev/null @@ -1,44 +0,0 @@ - - - HelloLua - - - libBox2D - libChipmunk - libcocos2d - libCocosDenshion - liblua - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - Classes - 2 - PARENT-1-PROJECT_LOC/Classes - - - cocos2dx_support - 2 - PARENT-4-PROJECT_LOC/scripting/lua/cocos2dx_support - - - diff --git a/template/multi-platform-lua/proj.linux/Makefile b/template/multi-platform-lua/proj.linux/Makefile deleted file mode 100644 index b9cdb5c66c..0000000000 --- a/template/multi-platform-lua/proj.linux/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -EXECUTABLE = HelloLua - -COCOS_ROOT = ../../.. -INCLUDES = -I../ -I../Classes -I$(COCOS_ROOT)/audio/include \ - -I$(COCOS_ROOT)/scripting/lua/lua \ - -I$(COCOS_ROOT)/scripting/lua/tolua \ - -I$(COCOS_ROOT)/scripting/lua/cocos2dx_support - -SOURCES = main.cpp ../Classes/AppDelegate.cpp - -SHAREDLIBS += -lcocos2d -lcocosdenshion -llua -COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so $(LIB_DIR)/liblua.so - -include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk - -$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - cp -n ../../../scripting/lua/script/* ../../../../samples/Lua/TestLua/Resources - $(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS) - -$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ - -$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) - @mkdir -p $(@D) - $(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@ diff --git a/template/multi-platform-lua/proj.linux/build.sh b/template/multi-platform-lua/proj.linux/build.sh new file mode 100755 index 0000000000..d1408e62a4 --- /dev/null +++ b/template/multi-platform-lua/proj.linux/build.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Exit on error +set -e + +rm -rf ../bin +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +#make global libs +cd ../cocos2d +#install depend libs +sudo ./build/install-deps-linux.sh +mkdir -p linux-build +cd linux-build +cmake .. -DBUILD_HelloCpp=OFF -DBUILD_TestCpp=OFF -DBUILD_HelloLua=OFF -DBUILD_TestLua=OFF +make -j4 + +#make bin +cd $DIR +rm -rf bin +mkdir -p build +cd build +cmake ../.. +make -j4 +cd .. +mv ../bin bin +cp ../cocos2d/cocos/scripting/lua/script/* bin/Resources diff --git a/template/multi-platform-lua/proj.linux/main.cpp b/template/multi-platform-lua/proj.linux/main.cpp index fe87d9a1cd..5e5565893c 100644 --- a/template/multi-platform-lua/proj.linux/main.cpp +++ b/template/multi-platform-lua/proj.linux/main.cpp @@ -14,6 +14,6 @@ int main(int argc, char **argv) // create the application instance AppDelegate app; EGLView eglView; - eglView.init("TestCPP",900,640); + eglView.init("Cocos2d-x Game Using LUA",900,640); return Application::getInstance()->run(); } diff --git a/template/multi-platform-lua/proj.win32/HelloLua.sln b/template/multi-platform-lua/proj.win32/HelloLua.sln index d5769661f0..5f6caa40b0 100644 --- a/template/multi-platform-lua/proj.win32/HelloLua.sln +++ b/template/multi-platform-lua/proj.win32/HelloLua.sln @@ -4,34 +4,37 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "HelloLua.vcxproj", "{4E6A7A0E-DDD8-4BAA-8B22-C964069364ED}" ProjectSection(ProjectDependencies) = postProject {21B2C324-891F-48EA-AD1A-5AE13DE12E28} = {21B2C324-891F-48EA-AD1A-5AE13DE12E28} + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE} = {B7C2A162-DEC9-4418-972E-240AB3CBFCAE} {DDC3E27F-004D-4DD4-9DD3-931A013D2159} = {DDC3E27F-004D-4DD4-9DD3-931A013D2159} {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\..\..\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libExtensions", "..\cocos2d\extensions\proj.win32\libExtensions.vcxproj", "{21B2C324-891F-48EA-AD1A-5AE13DE12E28}" ProjectSection(ProjectDependencies) = postProject {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} = {207BC7A9-CCF1-4F2F-A04D-45F72242AE25} {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\..\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\cocos2d\external\chipmunk\proj.win32\chipmunk.vcxproj", "{207BC7A9-CCF1-4F2F-A04D-45F72242AE25}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos2d\cocos\2d\cocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\..\..\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libAudio", "..\cocos2d\cocos\audio\proj.win32\CocosDenshion.vcxproj", "{F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "..\..\..\cocos\scripting\lua\bindings\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblua", "..\cocos2d\cocos\scripting\lua\bindings\liblua.vcxproj", "{DDC3E27F-004D-4DD4-9DD3-931A013D2159}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libNetwork", "..\..\..\cocos\network\proj.win32\libNetwork.vcxproj", "{DF2638C0-8128-4847-867C-6EAFE3DEE7B5}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libNetwork", "..\cocos2d\cocos\network\proj.win32\libNetwork.vcxproj", "{DF2638C0-8128-4847-867C-6EAFE3DEE7B5}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosBuilder", "..\..\..\cocos\editor-support\cocosbuilder\proj.win32\libCocosBuilder.vcxproj", "{811C0DAB-7B96-4BD3-A154-B7572B58E4AB}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosBuilder", "..\cocos2d\cocos\editor-support\cocosbuilder\proj.win32\libCocosBuilder.vcxproj", "{811C0DAB-7B96-4BD3-A154-B7572B58E4AB}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosStudio", "..\..\..\cocos\editor-support\cocostudio\proj.win32\libCocosStudio.vcxproj", "{B57CF53F-2E49-4031-9822-047CC0E6BDE2}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosStudio", "..\cocos2d\cocos\editor-support\cocostudio\proj.win32\libCocosStudio.vcxproj", "{B57CF53F-2E49-4031-9822-047CC0E6BDE2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGUI", "..\..\..\cocos\gui\proj.win32\libGUI.vcxproj", "{7E06E92C-537A-442B-9E4A-4761C84F8A1A}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGUI", "..\cocos2d\cocos\gui\proj.win32\libGUI.vcxproj", "{7E06E92C-537A-442B-9E4A-4761C84F8A1A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos2d\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -79,6 +82,10 @@ Global {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Debug|Win32.Build.0 = Debug|Win32 {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Release|Win32.ActiveCfg = Release|Win32 {7E06E92C-537A-442B-9E4A-4761C84F8A1A}.Release|Win32.Build.0 = Release|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.ActiveCfg = Debug|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.Build.0 = Debug|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.ActiveCfg = Release|Win32 + {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj index 6762f6a744..dade088c62 100644 --- a/template/multi-platform-lua/proj.win32/HelloLua.vcxproj +++ b/template/multi-platform-lua/proj.win32/HelloLua.vcxproj @@ -36,13 +36,13 @@ - - + + - - + + @@ -104,13 +104,13 @@ - xcopy "$(ProjectDir)..\..\..\cocos\scripting\lua\script" "$(ProjectDir)..\Resources" /e /Y + xcopy "$(ProjectDir)..\cocos2d\cocos\scripting\lua\script" "$(ProjectDir)..\Resources" /e /Y if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\cocos2d\external\websockets\prebuilt\win32\*.*" "$(OutDir)" @@ -160,7 +160,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(Ou if not exist "$(OutDir)" mkdir "$(OutDir)" -xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(OutDir)" +xcopy /Y /Q "$(ProjectDir)..\cocos2d\external\websockets\prebuilt\win32\*.*" "$(OutDir)" @@ -175,31 +175,34 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(Ou - + {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e} - + {f8edd7fa-9a51-4e80-baeb-860825d2eac6} - + {811c0dab-7b96-4bd3-a154-b7572b58e4ab} - + {b57cf53f-2e49-4031-9822-047cc0e6bde2} - + + {b7c2a162-dec9-4418-972e-240ab3cbfcae} + + {7e06e92c-537a-442b-9e4a-4761c84f8a1a} - + {df2638c0-8128-4847-867c-6eafe3dee7b5} - + {ddc3e27f-004d-4dd4-9dd3-931a013d2159} - + {21b2c324-891f-48ea-ad1a-5ae13de12e28} - + {207bc7a9-ccf1-4f2f-a04d-45f72242ae25} diff --git a/tools/jenkins-scripts/Monkeyrunner_TestCpp.py b/tools/jenkins-scripts/Monkeyrunner_TestCpp.py deleted file mode 100644 index 40c9e8f7f5..0000000000 --- a/tools/jenkins-scripts/Monkeyrunner_TestCpp.py +++ /dev/null @@ -1,839 +0,0 @@ -# Imports the monkeyrunner modules used by this program -import sys -import subprocess -import random -import os -from com.android.monkeyrunner import MonkeyRunner as mr -from com.android.monkeyrunner import MonkeyDevice as md -from com.android.monkeyrunner import MonkeyImage as mi - -#Define test functions. -def common_test(a,b,c): - for i in range(a,b): - mr.sleep(c) - device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') - -def random_click(a,b,c): - for i in range(a,b): - touch_x = random.randint(0,s_width/20*19) - touch_y = random.randint(0,s_height) - device.touch(touch_x,touch_y,'DOWN_AND_UP') - mr.sleep(c) - -def random_drag(a,b,c): - for i in range(a,b): - drag_x = random.randint(0,s_width/20*18) - drag_y = random.randint(0,s_height) - drop_x = random.randint(0,s_width/20*18) - drop_y = random.randint(0,s_height) - device.drag((drag_x,drag_y),(drop_x,drop_y)) - -def check_activity(a): - print "get running activities..." - subprocess.call("adb shell ps > running_activities.txt",shell=True) - #subprocess.call("adb pull running_activities.txt",shell=True) - - f1 = open('running_activities.txt') - while True: - line = f1.readline() - if not line.find('org.cocos2dx.testcpp') == -1: - break; - if len(line) == 0: - str = "TestCpp wasn't running,maybe it has crashes,please checkout:" - f2 = file('monkeyrunner_Error.log','w') - print "get logcat information..." - f2.write(str) - f2.write(a) - #subprocess.call("adb shell logcat | $ANDROID_NDK/ndk-stack -sym $ANDROID_HOME/tools/obj/local/armeabi > monkeyrunner_Error.log",shell=True); - f2.close() - sys.exit(1) - print "subprocess has finished!" - f1.close() - -# Connects to the current device, returning a MonkeyDevice object -device = mr.waitForConnection() -if not device: - print >> sys.stderr,"fail" - check_activity("is there a device connect to the testing machine.") - sys.exit(1) -else: - print "Start......" - -# Installs the Android package. Notice that this method returns a boolean, so you can test -# to see if the installation worked. -if device.installPackage(sys.argv[1]): - print "Install success!" -else: - print "Install failed,please make sure you have put apk in the right places" - check_activity("you have put apk in the right place") - sys.exit(1) - -# sets a variable with the package's internal name -package = 'org.cocos2dx.testcpp' -print "Package name: "+ package - -# sets a variable with the name of an Activity in the package -activity = 'org.cocos2dx.testcpp.TestCpp' -print "Activity name: " + activity - -# sets the name of the component to start -runComponent = package + '/' + activity - -# Runs the component -device.startActivity(component=runComponent) -print "Running activity......" - -#Set Screen's Length and Width -s_width = 800 -s_height = 480 - -#Set boolean variable of Acticity_IsRunning -Acticity_IsRunning = 1 - -#----------------ActionsTest---------------- -print "Run ActionsTest" -mr.sleep(2.0) -device.touch(s_width/2,s_height/48*5,'DOWN_AND_UP') -#Last Test -#device.touch(s_width/8*3,s_height/16*15,'DOWN_AND_UP') -common_test(1,28,1.0) -common_test(1,3,3.0) -common_test(1,6,1.0) -mr.sleep(1.0) -#Next Test -#device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -print "ActionsTest finished!" -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ActionsTest") - -#----------------TransitionsTest---------------- -print "Run TransitionsTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/6,'DOWN_AND_UP') -common_test(1,27,1.0) -mr.sleep(1.0) -print "TransitionsTest finished!" -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("TransitionsTest") - -#----------------ActionsProgressTest---------------- -print "Run ActionsProgressTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/48*11,'DOWN_AND_UP') -common_test(1,8,2.0) -mr.sleep(1.0) -print "ActionsProgressTest finished!" -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ActionsProgressTest") - -#----------------EffectsTest---------------- -mr.sleep(1.0) -print "Run EffectsTest" -device.touch(s_width/2,s_height/3,'DOWN_AND_UP') -common_test(1,22,3.0) -mr.sleep(1.0) -print "EffectsTest finished!" -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("EffectsTest") - -#----------------ClickAndMoveTest---------------- -print "Run ClickAndMoveTest" -mr.sleep(5.0) -device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP') -mr.sleep(1.0) -random_click(1,11,2.0) -mr.sleep(1.0) -random_click(1,101,0.0) -mr.sleep(1.0) -print "ClickAndMoveTest finished!" -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ClickAndMoveTest") - -#----------------RotateWorldTest---------------- -print "Run RotateWorldTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/2,'DOWN_AND_UP') -mr.sleep(5.0) -print "RotateWorldTest finished!" -mr.sleep(3.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("RotateWorldTest") - -#----------------ParticleTest---------------- -print "Run ParticleTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP') -common_test(1,43,2.0) -print "ParticleTest finished!" -mr.sleep(2.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ParticleTest") - -#----------------ActionsEaseTest---------------- -print "Run ActionsEaseTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/3*2,'DOWN_AND_UP') -mr.sleep(2.0) -common_test(1,14,2.0) -print "ActionsEaseTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ActionsEaseTest") - -#----------------MotionStreakTest---------------- -print "Run MontionStreakTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP') -mr.sleep(1.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -random_drag(1,11,0.5) -mr.sleep(1.0) -device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP') -mr.sleep(1.0) -random_drag(1,11,0.5) -print "MontionStreakTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("MontionStreakTest") - -#----------------DrawPrimitivesTest---------------- -print "Run DrawprimitivesTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/6*5,'DOWN_AND_UP') -mr.sleep(1.0) -print "DrawPrimitivesTest finished!" -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("DrawPrimitivesTest") - -#----------------NodeTest---------------- -print "Run NodeTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*11,'DOWN_AND_UP') -mr.sleep(1.0) -common_test(1,14,1.0) -print "NodeTest finished!" -mr.sleep(3.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("NodeTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------TouchesTest---------------- -print "Run TouchesTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/12,'DOWN_AND_UP') -print "TouchesTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("TouchesTest") - -#----------------MenuTest---------------- -print "Run MenuTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/6,'DOWN_AND_UP') -mr.sleep(1.0) -#Atlas Sprite -device.touch(s_width/2,s_height/48*13,'DOWN_AND_UP') -mr.sleep(1.0) -#Play -device.touch(s_width/8*3,s_height/24*11,'DOWN_AND_UP') -mr.sleep(1.0) -#items -device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP') -device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP') -mr.sleep(1.0) -#Configuration -device.touch(400,260,'DOWN_AND_UP') -mr.sleep(1.0) -print "MenuTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("MenuTest") - -#----------------ActionManagerTest---------------- -print "Run ActionManagerTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/48*11,'DOWN_AND_UP') -common_test(1,5,3.0) -print "ActionManagerTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ActionManagerTest") - -#----------------LayerTest---------------- -print "Run LayerTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/3,'DOWN_AND_UP') -random_drag(1,11,0.5) -mr.sleep(1.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(2.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(2.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -random_drag(1,11,0.5) -print "LayerTest finished!" -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("LayerTest") - -#----------------SceneTest---------------- -print "Run SceneTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP') -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP') -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP') -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP') -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP') -mr.sleep(1.0) -device.touch(s_width/2,s_height/2,'DOWN_AND_UP') -mr.sleep(1.5) -device.touch(s_width/2,s_height/2,'DOWN_AND_UP') -mr.sleep(1.5) -device.touch(s_width/2,s_height/2,'DOWN_AND_UP') -print "SceneTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("SceneTest") - -#----------------ParallaxTest---------------- -print "Run ParallaxTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/2,'DOWN_AND_UP') -mr.sleep(5.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -random_drag(1,11,0.5) -print "ParallaxTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ParallaxTest") - -#----------------TileMapTest---------------- -print "Run TileMapTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP') -mr.sleep(2.0) -for TileMap_i in range(1,20): - random_drag(1,5,2.0) - #Next Test - device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') - -mr.sleep(2.0) -print "TileMapTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("TileMapTest") - -#----------------IntervalTest---------------- -print "Run IntervalTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/3*2,'DOWN_AND_UP') -mr.sleep(3.0) -device.touch(s_width/2,s_height/12,'DOWN_AND_UP') -mr.sleep(1.0) -device.touch(s_width/2,s_height/12,'DOWN_AND_UP') -print "IntervalTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("IntervalTest") - -#----------------ChipmunkAccelTouchTest---------------- -print "Run ChipmunkAccelTouchTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP') -random_click(1,21,0.1) -print "ChipmunkAccelTouchTest finished!" -mr.sleep(2.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ChipmunkAccelTouchTest") - -#----------------LabelTest---------------- -print "Run LabelTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/6*5,'DOWN_AND_UP') -mr.sleep(3.0) -common_test(1,26,0.5) -mr.sleep(1.0) -print "LableTest finished!" -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("LabelTest") - -#----------------TestInputTest---------------- -print "Run TestInputTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*11,'DOWN_AND_UP') -print "TestInputTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("TestInputTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------SpriteTest---------------- -print "Run SpriteTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/16,'DOWN_AND_UP') -mr.sleep(1.0) -random_click(1,11,0.1) -mr.sleep(2.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -random_click(1,11,0.1) -mr.sleep(1.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(1.0) -common_test(1,109,0.5) -print "SpriteTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("SpriteTest") - -#----------------SchdulerTest---------------- -print "Run SchdulerTest" -mr.sleep(2.0) -device.touch(s_width/2,s_height/48*7,'DOWN_AND_UP') -mr.sleep(1.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -#Scheduler timeScale Test -mr.sleep(1.0) -device.drag((s_width/16*9,s_height/8*5),(s_width/16*7,s_height/8*5)) -mr.sleep(1.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -#Two custom schedulers -mr.sleep(1.0) -device.drag((s_width/16*5,s_height/24),(s_width/16*3,s_height/24)) -mr.sleep(1.0) -common_test(1,11,1) -print "SchdulerTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("SchdulerTest") - -#----------------RenderTextureTest---------------- -print "Run RenderTextureTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/48*11,'DOWN_AND_UP') -mr.sleep(1.0) -random_drag(1,11,0.5) -mr.sleep(1.0) -device.touch(s_width/8*7,s_height/24,'DOWN_AND_UP') -mr.sleep(1.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(1.0) -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(1.0) -#Testing Z Buffer in Render Texture -random_click(1,11,0.1) -mr.sleep(1.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -print "RenderTextureTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("RenderTextureTest") - -#----------------Testure2DTest---------------- -print "Run Testure2DTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/16*5,'DOWN_AND_UP') -common_test(1,36,0.5) -print "Testure2DTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("Testure2DTest") - -#----------------Box2dTest---------------- -print "Run Box2dTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/48*19,'DOWN_AND_UP') -random_click(1,31,0.1) -print "Box2dTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("Box2dTest") - -#----------------Box2dTestBed---------------- -print "Run Box2dTestBed" -mr.sleep(1.0) -device.touch(s_width/2,s_height/48*23,'DOWN_AND_UP') -common_test(1,36,2.0) -print "Box2dTestBed finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("Box2dTestBed") - -#----------------EffectAdvancedTest---------------- -print "Run EffectAdvancedTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/16*9,'DOWN_AND_UP') -common_test(1,6,1.0) -print "EffectAdvancedTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("EffectAdvancedTest") - -#----------------Accelerometer---------------- -print "Run Accelerometer" -mr.sleep(5.0) -device.touch(s_width/2,s_height/48*31,'DOWN_AND_UP') -mr.sleep(1.0) -print "Accelerometer finished!" -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -mr.sleep(3.0) -check_activity("Accelerometer") - -#----------------KeypadTest---------------- -print "Run KeypadTest" -mr.sleep(3.0) -device.touch(s_width/2,s_height/48*35,'DOWN_AND_UP') -mr.sleep(1.0) -device.press('KEYCODE_BACK','DOWN_AND_UP') -print "KeypadTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("KeypadTest") - -#----------------CocosDenshionTest---------------- -print "Run CocosDenshionTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/48*39,'DOWN_AND_UP') -#device.touch(400,30,'DOWN_AND_UP') -#device.touch(400,100,'DOWN_AND_UP') -print "CocosDenshionTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("CocosDenshionTest") - -#----------------PerformanceTest---------------- -print "Run PerformanceTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/48*43,'DOWN_AND_UP') -mr.sleep(1.0) -#PerformanceNodeChildrenTest -device.touch(s_width/2,s_height/12,'DOWN_AND_UP') -mr.sleep(1.0) -common_test(1,6,1.0) -#Back -device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP') -mr.sleep(1.0) -#PerformanceParticleTest -device.touch(s_width/2,s_height/6,'DOWN_AND_UP') -mr.sleep(1.0) -#for NodeChildren_i in range(1,5): -# device.touch(450,240,'DOWN_AND_UP') -# mr.sleep(1.0) -# device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -# mr.sleep(1.0) -common_test(1,5,1.0) -#Back -device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP') -mr.sleep(1.0) -#PerformanceSpriteTest -device.touch(s_width/2,s_height/4,'DOWN_AND_UP') -mr.sleep(1.0) -#for NodeChildren_i in range(1,8): -# device.touch(430,80,'DOWN_AND_UP') -# mr.sleep(1.0) -# device.touch(370,80,'DOWN_AND_UP') -# mr.sleep(1.0) -common_test(1,8,1.0) -#Back -device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP') -mr.sleep(1.0) -#PerformanceTextureTest -#device.touch(s_width/2,s_height/3,'DOWN_AND_UP') -#mr.sleep(1.0) -#Back -#device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP') -#mr.sleep(1.0) -#PerformanceTouchesTest -device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP') -mr.sleep(1.0) -random_drag(1,11,0.2) -#Next Test -mr.sleep(1.0) -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(1.0) -random_drag(1,11,0.2) -mr.sleep(1.0) -#Back -device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP') -print "PerformanceTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("PerformanceTest") - -#----------------ZwoptexTest---------------- -print "Run ZwoptexTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/48*47,'DOWN_AND_UP') -print "ZwoptexTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ZwoptexTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------CurlTest---------------- -print "Run CurlTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/4,'DOWN_AND_UP') -mr.sleep(1.0) -random_click(1,2,1.0) -print "CurlTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("CurlTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------UserDefaultTest---------------- -print "Run UserDefaultTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/3,'DOWN_AND_UP') -print "UserDefaultTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("UserDefaultTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------BugsTest---------------- -print "Run BugsTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*5,'DOWN_AND_UP') -print "BugsTest is finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("BugsTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------FontTest---------------- -print "Run FontTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/2,'DOWN_AND_UP') -mr.sleep(1.0) -common_test(1,6,0.5) -mr.sleep(1.0) -print "FontTest finished!" -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("FontTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------CurrentLanguageTest---------------- -print "Run CurrentLanguageTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/12*7,'DOWN_AND_UP') -print "CurrentLanguageTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("CurrentLanguageTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------TextureCacheTest---------------- -print "Run TextureCacheTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/3*2,'DOWN_AND_UP') -print "TextureCacheTest is finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("TextureCacheTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------ExtensionsTest---------------- -print "Run ExtensionsTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/4*3,'DOWN_AND_UP') -#NotificationCenterTest -mr.sleep(1.0) -device.touch(s_width/2,s_height/12,'DOWN_AND_UP') -mr.sleep(1.0) -device.touch(s_width/40*23,s_height/2,'DOWN_AND_UP') -mr.sleep(1.0) -device.touch(s_width/40*23,s_height/2,'DOWN_AND_UP') -#Back -mr.sleep(1.0) -device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP') -#CCControlButtonTest -mr.sleep(1.5) -device.touch(s_width/2,s_height/6,'DOWN_AND_UP') -mr.sleep(1.5) -device.drag((s_width/2,s_height/48*25),(s_width/20*13,s_height/48*25)) -mr.sleep(1.5) -device.drag((s_width/20*13,s_height/48*25),(s_width/20*7,s_height/48*25)) - #Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(1.5) -device.touch(s_width/16*7,s_height/2,'DOWN_AND_UP') -mr.sleep(1.5) -device.touch(s_width/40*19,s_height/2,'DOWN_AND_UP') -mr.sleep(1.5) - #Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(1.5) - #Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(1.5) -random_click(1,10,0.1) - #Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(1.5) -random_click(1,10,0.1) -mr.sleep(1.5) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -mr.sleep(1.5) -random_click(1,10,0.1) -mr.sleep(1.5) - #Back -device.touch(s_width/20*19,s_height/96*91,'DOWN_AND_UP') -mr.sleep(1.5) -#CocosBuilderTest -device.touch(s_width/2,s_height/4,'DOWN_AND_UP') -mr.sleep(1.5) - #Menus & Items -device.touch(s_width/4,s_height/2,'DOWN_AND_UP') -mr.sleep(1.5) -device.touch(s_width/4,s_height/24*11,'DOWN_AND_UP') -mr.sleep(1.5) -device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP') -mr.sleep(1.5) - #ItemBack -device.touch(s_width/40,s_height/24,'DOWN_AND_UP') -mr.sleep(1.5) - #Sprite & 9 Slice -device.touch(s_width/4*3,s_height/2,'DOWN_AND_UP') -mr.sleep(1.5) - #ItemBack -device.touch(s_width/40,s_height/24,'DOWN_AND_UP') -mr.sleep(1.5) - #Button -device.touch(s_width/4,s_height/8*5,'DOWN_AND_UP') -mr.sleep(1.5) -device.touch(s_width/2,s_height/24*11,'DOWN_AND_UP') -mr.sleep(1.5) -device.drag((s_width/2,s_height/24*11),(s_width/2,s_height/8*5)) -mr.sleep(1.5) - #ItemBack -device.touch(s_width/40,s_height/24,'DOWN_AND_UP') -mr.sleep(1.5) - #Labels -device.touch(s_width/4*3,s_height/8*5,'DOWN_AND_UP') -mr.sleep(1.5) - #ItemBack -device.touch(s_width/40,s_height/24,'DOWN_AND_UP') -mr.sleep(1.5) - #Particle Systems -device.touch(s_width/40,s_height/4*3,'DOWN_AND_UP') -mr.sleep(1.5) - #ItemBack -device.touch(s_width/40,s_height/24,'DOWN_AND_UP') -mr.sleep(1.5) - #Scroll Views -device.touch(s_width/4*3,s_height/4*3,'DOWN_AND_UP') -mr.sleep(1.5) -random_drag(1,10,0.2) -mr.sleep(1.5) - #ItemBack -device.touch(s_width/40,s_height/24,'DOWN_AND_UP') -mr.sleep(1.5) -print "ExtensionsTest finished!" -mr.sleep(1.5) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ExtensionsTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------ShaderTest---------------- -print "Run ShaderTest" -mr.sleep(1.0) -device.touch(s_width/2,s_height/6*5,'DOWN_AND_UP') -mr.sleep(7.0) -common_test(1,7,1.0) -mr.sleep(2.0) -device.drag((s_width/2,s_height/3*2),(s_width/80*51,s_height/3*2)) -mr.sleep(1.0) -device.drag((s_width/80*51,s_height/3*2),(s_width/80*29,s_height/3*2)) -mr.sleep(1.0) -#Next Test -device.touch(s_width/8*5,s_height/16*15,'DOWN_AND_UP') -print "ShaderTest finished!" -mr.sleep(3.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("ShaderTest") -mr.sleep(1.0) -device.drag((s_width/4*3,s_height/16*15),(s_width/4*3,0)) - -#----------------MutiTouchTest---------------- -print "Run MutiTouchTest" -mr.sleep(3.0) -device.touch(s_width/2,s_height/12*11,'DOWN_AND_UP') -mr.sleep(1.0) -random_drag(1,10,0.1) -print "MutiTouchTest finished!" -mr.sleep(1.0) -#MainMenu -device.touch(s_width/40*39,s_height/96*91,'DOWN_AND_UP') -check_activity("MutiTouchTest") - -#----------------Quit---------------- -mr.sleep(1.0) -device.touch(s_width/80*77,s_height/12,'DOWN_AND_UP') diff --git a/tools/jenkins-scripts/ReportManager.py b/tools/jenkins-scripts/ReportManager.py deleted file mode 100644 index 9e7207263c..0000000000 --- a/tools/jenkins-scripts/ReportManager.py +++ /dev/null @@ -1,52 +0,0 @@ -#------------------------------------------------ -# Monkeyrunner Test Report -# 10/08/2012 -#------------------------------------------------ - -from email.MIMEBase import MIMEBase -from email.MIMEText import MIMEText -from email.MIMEMultipart import MIMEMultipart -from email.utils import COMMASPACE,formatdate -from email import Encoders -from email.header import Header -import smtplib,email,os,sys - -if os.path.exists(os.getcwd()+'\\monkeyrunner_Error.log') or os.path.exists(os.getcwd()+'/monkeyrunner_Error.log'): - print "Sending Monkeyrunner Test Report..." - mail_from = 'redmine@cocos2d-x.org' #where the mail from - mail_to = ['739657621@qq.com','yangguangzaidongji@hotmail.com','yangguangzaidongji@gmail.com'] - to_string ='' - for item in mail_to: - to_string += item +',' - mail_subject = "Monkeyrunner Test Report" - msg = MIMEMultipart() - #msg = MIMEText('body') - mail_attachment = 'monkeyrunner_Error.log' - #msg = "\nhell" - print mail_to - - username = 'redmine@cocos2d-x.org' - password = 'cocos2d-x.org' - msg["From"] = mail_from - msg["To"] = to_string - msg["Subject"] = mail_subject - msg["Date"] = formatdate(localtime=True) - mail_body = "Monkeyrunner Test Finish! See attachment for logs." - msg.attach(MIMEText(mail_body)) - - #Add attachment. - fp = open(mail_attachment,"rb") - part = MIMEBase("application", "octet-stream") - part.set_payload(fp.read()) - fp.close() - Encoders.encode_base64(part) - part.add_header("Content-Disposition", "attachment; filename=%s" % mail_attachment) - msg.attach(part) - - #Send email. - server = smtplib.SMTP('smtp.gmail.com:587') - server.starttls() - server.login(username,password) - server.sendmail(mail_from, mail_to, msg.as_string()) - print 'Eamil success!' - server.quit() diff --git a/tools/jenkins-scripts/ant.properties b/tools/jenkins-scripts/ant.properties deleted file mode 100644 index 30a7872e3d..0000000000 --- a/tools/jenkins-scripts/ant.properties +++ /dev/null @@ -1,20 +0,0 @@ -# This file is used to override default values used by the Ant build system. -# -# This file must be checked in Version Control Systems, as it is -# integral to the build system of your project. -# This file is only used by the Ant script. -# You can use this to override default values such as -# 'source.dir' for the location of your java source folder and -# 'out.dir' for the location of your output folder. -# You can also use it define how the release builds are signed by declaring -# the following properties: -# 'key.store' for the location of your keystore and -# 'key.alias' for the name of the key to use. -# The password will be asked during the build when you use the 'release' target. -key.store=C:/.android/debug.keystore -key.alias=androiddebugkey -key.store.password=android -key.alias.password=android -#proguard.config=proguard.cfg -# Project target. -target=android-8 \ No newline at end of file diff --git a/tools/jenkins-scripts/build.xml b/tools/jenkins-scripts/build.xml deleted file mode 100644 index dd45cdcb55..0000000000 --- a/tools/jenkins-scripts/build.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tools/jenkins-scripts/create-job.py b/tools/jenkins-scripts/create-job.py new file mode 100644 index 0000000000..1aac211cdf --- /dev/null +++ b/tools/jenkins-scripts/create-job.py @@ -0,0 +1,31 @@ +#create ghprb job by pr number + +import os +import sys +import json +import requests + +#get pr number from cmd +pr_num = sys.argv[1] + +#get github access token +access_token = os.environ['GITHUB_ACCESS_TOKEN'] + +#get pr data via github api + +api_get_pr = "https://api.github.com/repos/cocos2d/cocos2d-x/pulls/"+str(pr_num)+"?access_token="+access_token + +r = requests.get(api_get_pr) +pr = r.json() + +#forge a payload +payload = {"action":"opened","number":"","pull_request":""} +payload['number']=pr_num +payload['pull_request']=pr + +jenkins_trigger_url="http://ci.cocos2d-x.org:8000/job/cocos-2dx-pull-request-build/buildWithParameters?token="+access_token + +#send trigger and payload +post_data = {'payload':""} +post_data['payload']=json.dumps(payload) +requests.post(jenkins_trigger_url, data=post_data) diff --git a/tools/jenkins-scripts/gen_jsb.sh b/tools/jenkins-scripts/gen_jsb.sh new file mode 100755 index 0000000000..1e8fc1b084 --- /dev/null +++ b/tools/jenkins-scripts/gen_jsb.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Generate JS and Lua bindings for Cocos2D-X +# ... using Android NDK system headers +# ... and automatically update submodule references +# ... and push these changes to remote repos + +# Dependencies +# +# For bindings generator: +# (see ../../../tojs/genbindings.sh and ../../../tolua/genbindings.sh +# ... for the defaults used if the environment is not customized) +# +# * $PYTHON_BIN +# * $CLANG_ROOT +# * $NDK_ROOT +# +echo "[test]start generate js binding..." +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +COCOS2DX_ROOT="$DIR"/../.. +TOJS_ROOT=$COCOS2DX_ROOT/tools/tojs +TOLUA_ROOT=$COCOS2DX_ROOT/tools/tolua +GENERATED_WORKTREE="$COCOS2DX_ROOT"/cocos/scripting/auto-generated + + +# Exit on error +set -e + +generate_bindings_glue_codes() +{ + echo "Create auto-generated jsbinding glue codes." + pushd "$TOJS_ROOT" + ./genbindings.sh + popd + + echo "Create auto-generated luabinding glue codes." + pushd "$TOLUA_ROOT" + ./genbindings.sh + popd +} + +# Update submodule of auto-gen Binding repo. +pushd "$GENERATED_WORKTREE" + +echo "Delete all directories and files except '.git' and 'README.md'." +ls -a | grep -E -v ^\[.\]\{1,2\}$ | grep -E -v ^\.git$ | grep -E -v ^README\.md$ | xargs -I{} rm -rf {} +popd + + + +# 1. Generate JS bindings +generate_bindings_glue_codes + +echo +echo Bindings generated successfully +echo + + diff --git a/tools/jenkins-scripts/mac/android/build-android-2.2-3.2-debug.sh b/tools/jenkins-scripts/mac/android/build-android-2.2-3.2-debug.sh deleted file mode 100755 index cc6feacab2..0000000000 --- a/tools/jenkins-scripts/mac/android/build-android-2.2-3.2-debug.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -#This script is used to finish a android automated compiler. -#You should make sure have finished the environment setting. -#Here are the environment variables you should set. -#$COCOS2DX_ROOT $ANDROID_SDK_ROOT $ANDROID_NDK_ROOT $NDK_ROOT - -antcompile() -{ - #Make sure the original target is android-8 - sed '/target=/s/=.*$/=android-8/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - - #Android ant build(debug ,API level:8) - ant debug - #If build failed,make sure the Jenkins could get the errorlevel. - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-debug.apk TestCpp-debug-8.apk - cd .. - fi - - #Change API level.(API level:10) - sed '/target=/s/=.*$/=android-10/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant debug - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-debug.apk TestCpp-debug-10.apk - cd .. - fi - - #Change API level.(API level:11) - sed '/target=/s/=.*$/=android-11/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant debug - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-debug.apk TestCpp-debug-11.apk - cd .. - fi - - #Change API level.(API level:12) - sed '/target=/s/=.*$/=android-12/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant debug - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-debug.apk TestCpp-debug-12.apk - cd .. - fi - - #Change API level.(API level:13) - sed '/target=/s/=.*$/=android-13/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant debug - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-debug.apk TestCpp-debug-13.apk - cd .. - fi - - #After all test versions completed,changed current API level to the original.(API level:8) - sed '/target=/s/=.*$/=android-8/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties -} - -#record the relevant catalog -compileresult=0 -CUR=$(pwd) -cd ../../../.. -ROOT=$(pwd) -IsTestCpp=1 - -#copy configuration files to target. -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Cpp/TestCpp/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Cpp/TestCpp/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Cpp/TestCpp/proj.android -cd $ROOT/samples/Cpp/TestCpp/proj.android -sh rootconfig-mac.sh TestCpp -sh build_native.sh - -#update android project configuration files -cd $ROOT/samples/Cpp/TestCpp -android update project -p proj.android -cd proj.android -antcompile - -IsTestCpp=0 - -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Cpp/HelloCpp/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Cpp/HelloCpp/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Cpp/HelloCpp/proj.android -cd $ROOT/samples/Cpp/HelloCpp/proj.android -sh rootconfig-mac.sh HelloCpp -sh build_native.sh -cd $ROOT/samples/Cpp/HelloCpp -android update project -p proj.android -cd proj.android -antcompile - -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Lua/HelloLua/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Lua/HelloLua/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Lua/HelloLua/proj.android -cd $ROOT/samples/Lua/HelloLua/proj.android -sh rootconfig-mac.sh HelloLua -sh build_native.sh -cd $ROOT/samples/Lua/HelloLua -android update project -p proj.android -cd proj.android -antcompile - -#return the compileresult. -cd $ROOT -if [ $compileresult != 0 ]; then -# git checkout -f -# git clean -df -x - exit 1 -else -# git checkout -f -# git clean -df -x - exit 0 -fi \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/android/build-android-2.2-3.2-release.sh b/tools/jenkins-scripts/mac/android/build-android-2.2-3.2-release.sh deleted file mode 100755 index 61fd96784a..0000000000 --- a/tools/jenkins-scripts/mac/android/build-android-2.2-3.2-release.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/bin/bash -#This script is used to finish a android automated compiler. -#You should make sure have finished the environment setting. -#Here are the environment variables you should set. -#$COCOS2DX_ROOT $ANDROID_SDK_ROOT $ANDROID_NDK_ROOT $NDK_ROOT - -antcompile() -{ - #Make sure the original target is android-8 - sed '/target=/s/=.*$/=android-8/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - - #Android ant build(debug ,API level:8) - ant release - #If build failed,make sure the Jenkins could get the errorlevel. - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-release.apk TestCpp-release-8.apk - cd .. - fi - - #Change API level.(API level:10) - sed '/target=/s/=.*$/=android-10/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant release - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-release.apk TestCpp-release-10.apk - cd .. - fi - - #Change API level.(API level:11) - sed '/target=/s/=.*$/=android-11/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant release - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-release.apk TestCpp-release-11.apk - cd .. - fi - - #Change API level.(API level:12) - sed '/target=/s/=.*$/=android-12/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant release - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-release.apk TestCpp-release-12.apk - cd .. - fi - - #Change API level.(API level:13) - sed '/target=/s/=.*$/=android-13/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant release - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-release.apk TestCpp-release-13.apk - cd .. - fi - - #After all test versions completed,changed current API level to the original.(API level:8) - sed '/target=/s/=.*$/=android-8/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties -} - -#record the relevant catalog -compileresult=0 -CUR=$(pwd) -cd ../../../.. -ROOT=$(pwd) -IsTestCpp=1 - -#copy configuration files to target. -sed -i '' '14d' $CUR/ant.properties -gsed -i "14 i\\key.store=$ANDROID_HOME/debug.keystore" $CUR/ant.properties -cp $CUR/../debug.keystore $ANDROID_HOME - -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Cpp/TestCpp/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Cpp/TestCpp/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Cpp/TestCpp/proj.android -cd samples/Cpp/TestCpp/proj.android -sh rootconfig-mac.sh TestCpp -sh build_native.sh - -#update android project configuration files -cd .. -android update project -p proj.android -cd proj.android -antcompile - -IsTestCpp=0 - -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Cpp/HelloCpp/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Cpp/HelloCpp/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Cpp/HelloCpp/proj.android -cd ../../Cpp/HelloCpp/proj.android -sh rootconfig-mac.sh HelloCpp -sh build_native.sh -cd .. -android update project -p proj.android -cd proj.android -antcompile - -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Lua/HelloLua/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Lua/HelloLua/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Lua/HelloLua/proj.android -cd ../../Lua/HelloLua/proj.android -sh rootconfig-mac.sh HelloLua -sh build_native.sh -cd .. -android update project -p proj.android -cd proj.android -antcompile - -#return the compileresult. -cd ../../.. -if [ $compileresult != 0 ]; then -# git checkout -f -# git clean -df -x - exit 1 -else -# git checkout -f -# git clean -df -x - exit 0 -fi \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/android/build-android-4.x-debug.sh b/tools/jenkins-scripts/mac/android/build-android-4.x-debug.sh deleted file mode 100755 index 83e9769894..0000000000 --- a/tools/jenkins-scripts/mac/android/build-android-4.x-debug.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -#This script is used to finish a android automated compiler. -#You should make sure have finished the environment setting. -#Here are the environment variables you should set. -#$COCOS2DX_ROOT $ANDROID_SDK_ROOT $ANDROID_NDK_ROOT $NDK_ROOT - -antcompile() -{ - #Change API level.(API level:14) - sed '/target=/s/=.*$/=android-14/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant debug - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-debug.apk TestCpp-debug-14.apk - cd .. - fi - - #Change API level.(API level:15) - sed '/target=/s/=.*$/=android-15/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant debug - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-debug.apk TestCpp-debug-15.apk - cd .. - fi - - #After all test versions completed,changed current API level to the original.(API level:8) - sed '/target=/s/=.*$/=android-8/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties -} - -#record the relevant catalog -compileresult=0 -CUR=$(pwd) -cd ../../../.. -ROOT=$(pwd) -IsTestCpp=1 - -#copy configuration files to target. -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Cpp/TestCpp/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Cpp/TestCpp/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Cpp/TestCpp/proj.android -cd samples/Cpp/TestCpp/proj.android -sh rootconfig-mac.sh TestCpp -sh build_native.sh - -#update android project configuration files -cd .. -android update project -p proj.android -cd proj.android -antcompile - -IsTestCpp=0 - -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Cpp/HelloCpp/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Cpp/HelloCpp/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Cpp/HelloCpp/proj.android -cd ../../Cpp/HelloCpp/proj.android -sh rootconfig-mac.sh HelloCpp -sh build_native.sh -cd .. -android update project -p proj.android -cd proj.android -antcompile - -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Lua/HelloLua/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Lua/HelloLua/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Lua/HelloLua/proj.android -cd ../../Lua/HelloLua/proj.android -sh rootconfig-mac.sh HelloLua -sh build_native.sh -cd .. -android update project -p proj.android -cd proj.android -antcompile - -#return the compileresult. -cd ../../.. -if [ $compileresult != 0 ]; then -# git checkout -f -# git clean -df -x - exit 1 -else -# git checkout -f -# git clean -df -x - exit 0 -fi diff --git a/tools/jenkins-scripts/mac/android/build-android-4.x-release.sh b/tools/jenkins-scripts/mac/android/build-android-4.x-release.sh deleted file mode 100755 index 120ab5ad4a..0000000000 --- a/tools/jenkins-scripts/mac/android/build-android-4.x-release.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -#This script is used to finish a android automated compiler. -#You should make sure have finished the environment setting. -#Here are the environment variables you should set. -#$COCOS2DX_ROOT $ANDROID_SDK_ROOT $ANDROID_NDK_ROOT $NDK_ROOT - -antcompile() -{ - #Change API level.(API level:14) - sed '/target=/s/=.*$/=android-14/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant release - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-release.apk TestCpp-release-14.apk - cd .. - fi - - #Change API level.(API level:15) - sed '/target=/s/=.*$/=android-15/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties - ant release - compileresult=$[$compileresult+$?] - if [ $IsTestCpp == 1 ] && [ $? == 0 ] - then - cd bin - mv TestCpp-release.apk TestCpp-release-15.apk - cd .. - fi - - #After all test versions completed,changed current API level to the original.(API level:8) - sed '/target=/s/=.*$/=android-8/' ant.properties > anttmp.properties - cp anttmp.properties ant.properties - rm anttmp.properties -} - -#record the relevant catalog -compileresult=0 -CUR=$(pwd) -cd ../../../.. -ROOT=$(pwd) -IsTestCpp=1 - -#copy configuration files to target. -sed -i '' '14d' $CUR/ant.properties -gsed -i "14 i\\key.store=$ANDROID_HOME/debug.keystore" $CUR/ant.properties -cp $CUR/../debug.keystore $ANDROID_HOME - -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Cpp/TestCpp/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Cpp/TestCpp/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Cpp/TestCpp/proj.android -cd samples/Cpp/TestCpp/proj.android -sh rootconfig-mac.sh TestCpp -sh build_native.sh - -#update android project configuration files -cd .. -android update project -p proj.android -cd proj.android -antcompile - -IsTestCpp=0 - -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Cpp/HelloCpp/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Cpp/HelloCpp/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Cpp/HelloCpp/proj.android -cd ../../Cpp/HelloCpp/proj.android -sh rootconfig-mac.sh HelloCpp -sh build_native.sh -cd .. -android update project -p proj.android -cd proj.android -antcompile - -cp $ROOT/tools/jenkins_scripts/ant.properties $ROOT/samples/Lua/HelloLua/proj.android -cp $ROOT/tools/jenkins_scripts/build.xml $ROOT/samples/Lua/HelloLua/proj.android -cp $ROOT/tools/jenkins_scripts/mac/rootconfig-mac.sh $ROOT/samples/Lua/HelloLua/proj.android -cd ../../Lua/HelloLua/proj.android -sh rootconfig-mac.sh HelloLua -sh build_native.sh -cd .. -android update project -p proj.android -cd proj.android -antcompile - -#return the compileresult. -cd ../../.. -if [ $compileresult != 0 ]; then -# git checkout -f -# git clean -df -x - exit 1 -else -# git checkout -f -# git clean -df -x - exit 0 -fi \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/android/generate-js-cxx-bindings.sh b/tools/jenkins-scripts/mac/android/generate-js-cxx-bindings.sh deleted file mode 100755 index 887ba2c055..0000000000 --- a/tools/jenkins-scripts/mac/android/generate-js-cxx-bindings.sh +++ /dev/null @@ -1,190 +0,0 @@ -#!/bin/bash - -# Generate JS bindings for Cocos2D-X -# ... using Android NDK system headers -# ... and automatically update submodule references -# ... and push these changes to remote repos - -# Dependencies -# -# For bindings generator: -# (see ../../../tojs/genbindings.sh -# ... for the defaults used if the environment is not customized) -# -# * $PYTHON_BIN -# * $CLANG_ROOT -# * $NDK_ROOT -# -# For automatically pushing changes: -# -# * REMOTE_AUTOGEN_BINDINGS_REPOSITORY -# * REMOTE_COCOS2DX_REPOSITORY -# * Note : Ensure you have commit access to above repositories -# * COCOS2DX_PULL_BASE -# * hub -# * see http://defunkt.io/hub/ -# * Ensure that hub has an OAuth token to REMOTE_COCOS2DX_REPOSITORY -# * see http://defunkt.io/hub/hub.1.html#CONFIGURATION - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -COCOS2DX_ROOT="$DIR"/../../../.. -GENERATED_WORKTREE="$COCOS2DX_ROOT"/scripting/javascript/bindings/generated - -if [ -z "${HUB+aaa}" ]; then -# ... if HUB is not set, use "$HOME/bin/hub" - HUB="$HOME/bin/hub" -fi - -# Update cocos2d-x repo -# It needs to be updated in Jenkins command before executing this script. -#pushd "$COCOS2DX_ROOT" - -#git checkout -f -#git checkout gles20 -#git pull upstream gles20 -#rm -rf "$GENERATED_WORKTREE" -#git submodule update --init - -#popd - -# Update submodule of auto-gen JSBinding repo. -pushd "$GENERATED_WORKTREE" - -git checkout -f -git clean -fdx -git fetch origin -git checkout -B master origin/master - -# Delete all directories and files except '.git' and 'README'. -ls -a | grep -E -v ^\[.\]\{1,2\}$ | grep -E -v ^\.git$ | grep -E -v ^README$ | xargs -I{} rm -rf {} - -popd - -# Exit on error -set -e - -# 1. Generate JS bindings -COCOS2DX_ROOT="$COCOS2DX_ROOT" /bin/bash ../../../tojs/genbindings.sh - -echo -echo Bindings generated successfully -echo - -if [ -z "${REMOTE_AUTOGEN_BINDINGS_REPOSITORY+aaa}" ]; then - echo - echo Environment variable must be set REMOTE_AUTOGEN_BINDINGS_REPOSITORY - echo This script expects to automatically push changes - echo to this repo - echo example - echo REMOTE_AUTOGEN_BINDINGS_REPOSITORY=\"git@github.com:folecr/cocos2dx-autogen-bindings.git\" - echo REMOTE_AUTOGEN_BINDINGS_REPOSITORY=\"\$HOME/test/cocos2dx-autogen-bindings\" - echo - echo Exiting with failure. - echo - exit 1 -fi - -if [ -z "${COMMITTAG+aaa}" ]; then -# ... if COMMITTAG is not set, use this machine's hostname - COMMITTAG=`hostname -s` -fi - -echo -echo Using "'$COMMITTAG'" in the commit messages -echo - -ELAPSEDSECS=`date +%s` -echo Using "$ELAPSEDSECS" in the branch names for pseudo-uniqueness - -GENERATED_BRANCH=autogeneratedbindings_"$ELAPSEDSECS" - - -# 2. In JSBindings repo, Check if there are any files that are different from the index - -pushd "$GENERATED_WORKTREE" - -# Run status to record the output in the log -git status - -echo -echo Comparing with origin/master ... -echo - -# Don't exit on non-zero return value -set +e - -git diff --stat --exit-code origin/master - -DIFF_RETVAL=$? -if [ $DIFF_RETVAL -eq 0 ] -then - echo - echo "No differences in generated files" - echo "Exiting with success." - echo - exit 0 -else - echo - echo "Generated files differ from origin/master. Continuing." - echo -fi - -# Exit on error -set -e - -# 3. In JSBindings repo, Check out a branch named "autogeneratedbindings" and commit the auto generated bindings to it -git checkout -b "$GENERATED_BRANCH" -git add --verbose . -git add --verbose -u . -git commit --verbose -m "$COMMITTAG : autogenerated bindings" - -# 4. In JSBindings repo, Push the commit with generated bindings to "master" of the auto generated bindings repository -git push --verbose "$REMOTE_AUTOGEN_BINDINGS_REPOSITORY" "$GENERATED_BRANCH":master - -popd - -if [ -z "${REMOTE_COCOS2DX_REPOSITORY+aaa}" ]; then - echo - echo Environment variable is not set REMOTE_COCOS2DX_REPOSITORY - echo This script will NOT automatically push changes - echo unless this variable is set. - echo example - echo REMOTE_COCOS2DX_REPOSITORY=\"git@github.com:cocos2d/cocos2d-x.git\" - echo REMOTE_COCOS2DX_REPOSITORY=\"\$HOME/test/cocos2d-x\" - echo - echo Exiting with success. - echo - exit 0 -fi - -COCOS_BRANCH=updategeneratedsubmodule_"$ELAPSEDSECS" - -pushd "${DIR}" - -# 5. In Cocos2D-X repo, Checkout a branch named "updategeneratedsubmodule" Update the submodule reference to point to the commit with generated bindings -cd "${COCOS2DX_ROOT}" -git add scripting/javascript/bindings/generated -git checkout -b "$COCOS_BRANCH" -git commit -m "$COMMITTAG : updating submodule reference to latest autogenerated bindings" - -# 6. In Cocos2D-X repo, Push the commit with updated submodule to "gles20" of the cocos2d-x repository -git push "$REMOTE_COCOS2DX_REPOSITORY" "$COCOS_BRANCH" - -if [ -z "${COCOS2DX_PULL_BASE+aaa}" ]; then - echo - echo Environment variable is not set COCOS2DX_PULL_BASE - echo This script will NOT automatically generate pull requests - echo unless this variable is set. - echo example - echo COCOS2DX_PULL_BASE=\"cocos2d/cocos2d-x:master\" - echo COCOS2DX_PULL_BASE=\"username/repository:branch\" - echo - echo Exiting with success. - echo - exit 0 -fi - -# 7. -${HUB} pull-request "$COMMITTAG : updating submodule reference to latest autogenerated bindings" -b "$COCOS2DX_PULL_BASE" -h "$COCOS_BRANCH" - -popd diff --git a/tools/jenkins-scripts/mac/android/test-android-2.2-3.2-debug.sh b/tools/jenkins-scripts/mac/android/test-android-2.2-3.2-debug.sh deleted file mode 100755 index 6608fd9240..0000000000 --- a/tools/jenkins-scripts/mac/android/test-android-2.2-3.2-debug.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -#This script is used to finished a android automated compiler in Mac OS. -#You'd better add "export PATH=$PATH:$ANDROID_HOME/platform-tools" and "export -#PATH=$PATH:$ANDROID_HOME/tools" to you bash_profile,it will be very convenient. - -#Copy monkeyrunner python script to tools directory. -cd ../.. -CUR=$(pwd) -cp $CUR/Monkeyrunner_TestCpp.py $ANDROID_HOME/tools -cp $CUR/ReportManager.py $ANDROID_HOME/tools - -cd ../.. -PROJECT_HOME=$(pwd) -#cp -r samples/TestCpp/proj.android/obj $ANDROID_HOME/tools -cd samples/Cpp/TestCpp/proj.android/bin - -#Copy test apk to tools directory. -CUR=$(pwd) -cp $CUR/TestCpp-debug-8.apk $ANDROID_HOME/tools -cp $CUR/TestCpp-debug-10.apk $ANDROID_HOME/tools -cp $CUR/TestCpp-debug-11.apk $ANDROID_HOME/tools -cp $CUR/TestCpp-debug-12.apk $ANDROID_HOME/tools -cp $CUR/TestCpp-debug-13.apk $ANDROID_HOME/tools - -#Enter tools directory. -cd $ANDROID_HOME/tools - -#If monkeyrunner test failed,it automatically exit and make ERRORLEVEL nonzero. - -#Running monkeyrunner test(debug,API level:8) -mv TestCpp-debug-8.apk TestCpp-debug.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-debug.apk - -#Running monkeyrunner test(debug,API level:10) -mv TestCpp-debug-10.apk TestCpp-debug.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-debug.apk - -#Running monkeyrunner test(debug,API level:11) -mv TestCpp-debug-11.apk TestCpp-debug.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-debug.apk - -#Running monkeyrunner test(debug,API level:12) -mv TestCpp-debug-12.apk TestCpp-debug.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-debug.apk - -#Running monkeyrunner test(debug,API level:13) -mv TestCpp-debug-13.apk TestCpp-debug.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-debug.apk - -rm Monkeyrunner_TestCpp.py -rm ReportManager.py - -#Monkeyrunner success! -echo Monkeyrunner Test Success! - -#Clean project files. -cd $PROJECT_HOME - -git checkout -f -git clean -df -x - -#End \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/android/test-android-2.2-3.2-release.sh b/tools/jenkins-scripts/mac/android/test-android-2.2-3.2-release.sh deleted file mode 100755 index 8fe4976d30..0000000000 --- a/tools/jenkins-scripts/mac/android/test-android-2.2-3.2-release.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -#This script is used to finished a android automated compiler in Mac OS. -#You'd better add "export PATH=$PATH:$ANDROID_HOME/platform-tools" and "export -#PATH=$PATH:$ANDROID_HOME/tools" to you bash_profile,it will be very convenient. - -#Copy monkeyrunner python script to tools directory. -cd ../.. -CUR=$(pwd) -cp $CUR/Monkeyrunner_TestCpp.py $ANDROID_HOME/tools -cp $CUR/ReportManager.py $ANDROID_HOME/tools - -cd ../.. -PROJECT_HOME=$(pwd) -cd samples/Cpp/TestCpp/proj.android/bin - -#Copy test apk to tools directory. -CUR=$(pwd) -cp $CUR/TestCpp-release-8.apk $ANDROID_HOME/tools -cp $CUR/TestCpp-release-10.apk $ANDROID_HOME/tools -cp $CUR/TestCpp-release-11.apk $ANDROID_HOME/tools -cp $CUR/TestCpp-release-12.apk $ANDROID_HOME/tools -cp $CUR/TestCpp-release-13.apk $ANDROID_HOME/tools - -#Enter tools directory. -cd $ANDROID_HOME/tools - -#If monkeyrunner test failed,it automatically exit and make ERRORLEVEL nonzero. - -#Running monkeyrunner test(release,API level:8) -mv TestCpp-release-8.apk TestCpp-release.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-release.apk - -#Running monkeyrunner test(release,API level:10) -mv TestCpp-release-10.apk TestCpp-release.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-release.apk - -#Running monkeyrunner test(release,API level:11) -mv TestCpp-release-11.apk TestCpp-release.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-release.apk - -#Running monkeyrunner test(release,API level:12) -mv TestCpp-release-12.apk TestCpp-release.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-release.apk - -#Running monkeyrunner test(release,API level:13) -mv TestCpp-release-13.apk TestCpp-release.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-release.apk - -rm Monkeyrunner_TestCpp.py -rm ReportManager.py - -#Monkeyrunner success! -echo Monkeyrunner Test Success! - -#Clean project files. -cd $PROJECT_HOME - -git checkout -f -git clean -df -x - -#End \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/android/test-android-4.x-debug.sh b/tools/jenkins-scripts/mac/android/test-android-4.x-debug.sh deleted file mode 100755 index 5d31e9f621..0000000000 --- a/tools/jenkins-scripts/mac/android/test-android-4.x-debug.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -#This script is used to finished a android automated compiler in Mac OS. -#You'd better add "export PATH=$PATH:$ANDROID_HOME/platform-tools" and "export -#PATH=$PATH:$ANDROID_HOME/tools" to you bash_profile,it will be very convenient. - -#Copy monkeyrunner python script to tools directory. -cd ../.. -CUR=$(pwd) -cp $CUR/Monkeyrunner_TestCpp.py $ANDROID_HOME/tools -cp $CUR/ReportManager.py $ANDROID_HOME/tools - -cd ../.. -PROJECT_HOME=$(pwd) -cd samples/Cpp/TestCpp/proj.android/bin - -#Copy test apk to tools directory. -CUR=$(pwd) -cp $CUR/TestCpp-debug-14.apk $ANDROID_HOME/tools -cp $CUR/TestCpp-debug-15.apk $ANDROID_HOME/tools - -#Enter tools directory. -cd $ANDROID_HOME/tools - -#If monkeyrunner test failed,it automatically exit and make ERRORLEVEL nonzero. - -#Running monkeyrunner test(debug,API level:14) -mv TestCpp-debug-14.apk TestCpp-debug.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-debug.apk - -#Running monkeyrunner test(debug,API level:15) -mv TestCpp-debug-15.apk TestCpp-debug.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-debug.apk - -rm Monkeyrunner_TestCpp.py -rm ReportManager.py - -#Monkeyrunner success! -echo Monkeyrunner Test Success! - -#Clean project files. -cd $PROJECT_HOME - -git checkout -f -git clean -df -x - -#End \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/android/test-android-4.x-release.sh b/tools/jenkins-scripts/mac/android/test-android-4.x-release.sh deleted file mode 100755 index 8432addde4..0000000000 --- a/tools/jenkins-scripts/mac/android/test-android-4.x-release.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -#This script is used to finished a android automated compiler in Mac OS. -#You'd better add "export PATH=$PATH:$ANDROID_HOME/platform-tools" and "export -#PATH=$PATH:$ANDROID_HOME/tools" to you bash_profile,it will be very convenient. - -#Copy monkeyrunner python script to tools directory. -cd ../.. -CUR=$(pwd) -cp $CUR/Monkeyrunner_TestCpp.py $ANDROID_HOME/tools -cp $CUR/ReportManager.py $ANDROID_HOME/tools - -cd ../.. -PROJECT_HOME=$(pwd) -cd samples/Cpp/TestCpp/proj.android/bin - -#Copy test apk to tools directory. -CUR=$(pwd) -cp $CUR/TestCpp-release-14.apk $ANDROID_HOME/tools -cp $CUR/TestCpp-release-15.apk $ANDROID_HOME/tools - -#Enter tools directory. -cd $ANDROID_HOME/tools - -#If monkeyrunner test failed,it automatically exit and make ERRORLEVEL nonzero. - -#Running monkeyrunner test(release,API level:14) -mv TestCpp-release-14.apk TestCpp-release.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-release.apk - -#Running monkeyrunner test(release,API level:15) -mv TestCpp-release-15.apk TestCpp-release.apk -monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if [ $? != 0 ]; then - python ReportManager.py - exit 1 -fi -rm TestCpp-release.apk - -rm Monkeyrunner_TestCpp.py -rm ReportManager.py - -#Monkeyrunner success! -echo Monkeyrunner Test Success! - -#Clean project files. -cd $PROJECT_HOME - -git checkout -f -git clean -df -x - -#End \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/debug.keystore b/tools/jenkins-scripts/mac/debug.keystore deleted file mode 100644 index cfc159027a..0000000000 Binary files a/tools/jenkins-scripts/mac/debug.keystore and /dev/null differ diff --git a/tools/jenkins-scripts/mac/iOS_SikuliTest.sikuli/iOS_SikuliTest.html b/tools/jenkins-scripts/mac/iOS_SikuliTest.sikuli/iOS_SikuliTest.html deleted file mode 100644 index 1cb7370325..0000000000 --- a/tools/jenkins-scripts/mac/iOS_SikuliTest.sikuli/iOS_SikuliTest.html +++ /dev/null @@ -1,573 +0,0 @@ - - - - - - -
-

iOS_SikuliTest.sikuli

(Download this script) -
-
-setAutoWaitTimeout(10000)
-
-val = getFindFailedResponse()
-if val == ABORT:
-    print "Abort"
-if val == SKIP:
-    print "SKIP"
-if val == PROMPT:
-    print "PROMPT"
-if val == RETRY:
-    print "RETRY"
-
-def common_test(a,b,c):
-    for i in range(a,b):
-        wait(c)
-        if exists():
-            click()
-
-#ActionTest
-click()
-print("Run ActionsTest")
-common_test(1,28,1.0)
-click(Pattern().targetOffset(-93,0))
-common_test(1,3,3.0)
-common_test(1,6,1.0)
-print("ActionsTest finished!")
-click()
-
-#TransitionsTest
-click()
-print("Run TransitionsTest")
-common_test(1,27,1.0)
-print("TransitionsTest finished!")
-click(Pattern().targetOffset(49,0))
-
-#ActionsProgressTest
-click()
-print("Run ActionsProgressTest")
-common_test(1,8,1.0)
-print("ActionsProgressTest finished!")
-click()
-
-
-#EffectsTest
-click()
-print("Run EffectsTest")
-common_test(1,22,3.0)
-print("Effects finished!")
-click()
-
-#ClickAndMoveTest
-print("Run ClickAndMoveTest")
-click()
-wait(4)
-click()
-click(Pattern().targetOffset(200,-3))
-click()
-
-print("ClickAndMoveTest finished!")
-
-#RotateWorldTest
-print("Run RotateWorldTest")
-click()
-wait(4)
-click()
-print("RotateWorldTest finished!")
-
-#ParticleTest
-print("Run ParticleTest")
-click()
-common_test(1,43,2.0)
-print("ParticleTest finished!")
-click()
-
-dragDrop(Pattern().targetOffset(91,17), Pattern().targetOffset(93,-19))
-
-#ActionEaseTest
-print("Run ActionEaseTest")
-click()
-common_test(1,14,2.0)
-click()
-print("ActionEaseTest finished!")
-
-#MotionStreakTest
-print("Run MotionStreakTest")
-click()
-wait(1.0)
-click(Pattern().targetOffset(20,0))
-wait(1.0)
-click()
-dragDrop(, )
-click(Pattern().targetOffset(20,0))
-dragDrop(, )
-click()
-click(Pattern().targetOffset(20,0))
-wait(1.0)
-click()
-print("MotionStreakTest finished!")
-
-#DrawPimitivesTest
-print("Run DrawPimitivesTest")
-click()
-if exists():
-    print("DrawPrimitivesTest success!")
-print("DrawPimitivesTest finished!")
-click()
-
-#NodeTest
-print("Run NodeTest")
-click()
-common_test(1,14,1.0)
-click()
-print("NodeTest finished!")
-
-#TouchesTest
-print("Run TouchesTest")
-click()
-wait(1.0)
-click()
-print("TouchesTest finished!")
-
-#MenuTest
-print("Run MenuTest")
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-print("MenuTest finished!")
-
-#ActionManagerTest
-print("Run ActionManagerTest")
-click()
-common_test(1,5,3.0)
-click()
-print("ActionManagerTest finished!")
-
-#LayerTest
-print("Run LayerTest")
-click()
-dragDrop(, )
-click()
-wait(1.0)
-click()
-wait(1.0)
-click()
-dragDrop(, )
-common_test(1,3,1.0)
-click()
-print("LayerTest finished!")
-
-dragDrop(Pattern().targetOffset(98,6), Pattern().targetOffset(106,-11))
-
-#SceneTest
-print("Run SceneTest")
-click()
-click()
-click()
-click()
-click()
-click()
-print("SceneTest finished!")
-
-#ParallaxTest
-print("Run ParallaxTest")
-click()
-wait(3.0)
-click()
-dragDrop(, )
-click()
-print("ParallaxTest finished!")
-
-#TileMapTest
-print("Run TileMapTest")
-click()
-common_test(1,21,2.0)
-click()
-print("TileMapTest finished!")
-
-#IntervalTest
-print("Run IntervalTest")
-click()
-wait(2.0)
-click()
-wait(1.0)
-click()
-click()
-print("IntervalTest finished!")
-
-#ChipmunkAccelTouchTest
-print("Run ChipmunkAccelTouchTest")
-click()
-for i in range(1,3):
-    click()
-for i in range(1,3):
-    click()
-wait(3.0)
-click()
-print("ChipmunkAccelTouchTest finished!")
-
-#LabelTest
-print("Run LabelTest")
-click()
-wait(1.0)
-common_test(1,26,0.5)
-click()
-print("LabelTest finished!")
-
-#TextInputTest
-print("Run TextInputTest")
-click()
-type(, "1q~<?;\@")
-click()
-click()
-type(, "1q~<?;\@")
-click()
-click()
-print("TextInputTest finished!")
-
-dragDrop(Pattern().targetOffset(100,14), Pattern().targetOffset(75,-8))
-
-#SpriteTest
-print("Run SpriteTest")
-click()
-for i in range(1,3):
-    click()
-for j in range(1,3):
-    click()
-click()
-for i in range(1,3):
-    click()
-for j in range(1,3):
-    click()
-common_test(1,100,0.5)
-click()
-print("SpriteTest finished!")
-
-#SchdulerTest
-print("Run SchdulerTest")
-click()
-wait(1.0)
-click()
-dragDrop(Pattern().targetOffset(23,0),Pattern().targetOffset(-50,0))
-click()
-dragDrop(,Pattern().targetOffset(58,0))
-common_test(1,11,1)
-click()
-print("SchdulerTest finished!")
-
-#RenderTextureTest
-print("Run RenderTextureTest")
-click()
-dragDrop(, )
-dragDrop(, )
-click()
-click()
-click()
-wait(1.0)
-click()
-click()
-click()
-click()
-click()
-wait(1.0)
-click()
-print("RenderTextureTest finished!")
-
-#Texture2DTest
-print("Run Texture2DTest")
-click()
-common_test(1,36,0.5)
-click()
-print("Texture2DTest finished!")
-
-#Box2dTest
-print("Run Box2dTest")
-click()
-for i in range(1,6):
-    click()
-for i in range(1,6):
-    click()
-click()
-print("Box2dTest finished!")
-
-#Box2dTestBed
-print("Run Box2dTestBed")
-click()
-common_test(1,36,2.0)
-click()
-print("Box2dTestBed finished!")
-
-#EffectAdvancedTest
-print("Run EffectAdvancedTest")
-click()
-common_test(1,6,1.0)
-click()
-print("EffectAdvancedTest finished!")
-
-#Accelerometer
-print("Run Accelerometer")
-click()
-click()
-print("Accelerometer finished!")
-
-dragDrop(Pattern().targetOffset(120,2), Pattern().targetOffset(130,-9))
-
-#KeypadTest
-print("Run KeypadTest")
-click()
-click()
-print("KeypadTest finished!")
-
-#CocosDenshionTest
-print("Run CocosDenshionTest")
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-dragDrop(Pattern().targetOffset(-130,15), Pattern().targetOffset(-140,-15))
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-dragDrop(Pattern().targetOffset(-120,6), Pattern().targetOffset(-130,-9))
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-print("CocosDenshionTest finished!")
-
-#PerformanceTest
-print("Run PerformanceTest")
-click()
-click()
-click()
-common_test(1,6,0.5)
-click()
-click()
-click()
-common_test(1,5,0.5)
-click()
-click()
-common_test(1,5,0.5)
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-print("PerformanceTest finished!")
-
-#ZwoptexTest
-print("Run ZwoptexTest")
-click()
-click()
-print("ZwoptexTest finished!")
-
-#CurlTest
-print("Run CurlTest")
-click()
-click()
-click()
-print("CurlTest finished!")
-
-#UserDefaultTest
-print("Run UserDefaultTest")
-click()
-click()
-print("UserDefaultTest finished!")
-
-#BugsTest
-print("Run BugsTest")
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-dragDrop(Pattern().targetOffset(-103,16), Pattern().targetOffset(-100,-19))
-click()
-click()
-click()
-wait(0.5)
-click()
-click()
-print("BugsTest finished!")
-
-dragDrop(Pattern().targetOffset(-110,17), Pattern().targetOffset(-120,-9))
-
-#FontTest
-print("Run FontTest")
-click()
-common_test(1,6,0.5)
-click()
-print("FontTest finished!")
-
-#CurrentLauguageTest
-print("Run CurrentLauguageTest")
-click()
-click()
-print("CurrentLauguageTest finished!")
-
-#TextureCacheTest
-print("Run TextureCacheTest")
-click()
-click()
-print("TextureCacheTest finished!")
-
-#ExtensionsTest
-print("Run ExtensionsTest")
-click()
-click()
-click()
-click()
-click()
-wait(0.5)
-dragDrop(Pattern().targetOffset(-120,0),Pattern().targetOffset(120,0))
-click()
-click()
-click()
-click(Pattern().targetOffset(-19,0))
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-click()
-print("ExtensionsTest finished!")
-
-#ShaderTest
-print("Run ShaderTest")
-click()
-common_test(1,7,0.5)
-wait(0.5)
-dragDrop(Pattern().targetOffset(-44,0),Pattern().targetOffset(80,0))
-click()
-click()
-print("ShaderTest finished!")
-
-#MutiTouchTest
-print("Run MutiTouchTest")
-click()
-for i in range(1,3):
-    dragDrop(, )
-    dragDrop(, Pattern().targetOffset(-50,0))
-click()
-print("MutiTouchTest finished!")
-
-#Quit
-print("Quit")
-click()
-
- - diff --git a/tools/jenkins-scripts/mac/iOS_SikuliTest.sikuli/iOS_SikuliTest.py b/tools/jenkins-scripts/mac/iOS_SikuliTest.sikuli/iOS_SikuliTest.py deleted file mode 100644 index 899939d6b3..0000000000 --- a/tools/jenkins-scripts/mac/iOS_SikuliTest.sikuli/iOS_SikuliTest.py +++ /dev/null @@ -1,498 +0,0 @@ -setAutoWaitTimeout(10000) - -val = getFindFailedResponse() -if val == ABORT: - print "Abort" -if val == SKIP: - print "SKIP" -if val == PROMPT: - print "PROMPT" -if val == RETRY: - print "RETRY" - -def common_test(a,b,c): - for i in range(a,b): - wait(c) - if exists("Next.png"): - click("Next.png") - -#ActionTest -click("ActionsTest.png") -print("Run ActionsTest") -common_test(1,28,1.0) -click(Pattern("MainMenu_Common.png").targetOffset(-93,0)) -common_test(1,3,3.0) -common_test(1,6,1.0) -print("ActionsTest finished!") -click("MainMenu_Common.png") - -#TransitionsTest -click("TransitionsTest.png") -print("Run TransitionsTest") -common_test(1,27,1.0) -print("TransitionsTest finished!") -click(Pattern("1346297215212.png").targetOffset(49,0)) - -#ActionsProgressTest -click("ActionsProgressTest.png") -print("Run ActionsProgressTest") -common_test(1,8,1.0) -print("ActionsProgressTest finished!") -click("MainMenu_ActionsProgress.png") - - -#EffectsTest -click("EffectsTest.png") -print("Run EffectsTest") -common_test(1,22,3.0) -print("Effects finished!") -click("MainMenu_Effects.png") - -#ClickAndMoveTest -print("Run ClickAndMoveTest") -click("CickAndMoveTest.png") -wait(4) -click("ClickAndMove_Click.png") -click(Pattern("ClickAndMove_Click.png").targetOffset(200,-3)) -click("MainMenu_ClickAndMove.png") - -print("ClickAndMoveTest finished!") - -#RotateWorldTest -print("Run RotateWorldTest") -click("RotateWorldTest.png") -wait(4) -click("MainMenu_ActionsProgress.png") -print("RotateWorldTest finished!") - -#ParticleTest -print("Run ParticleTest") -click("ParticleTest.png") -common_test(1,43,2.0) -print("ParticleTest finished!") -click("MainMenu_Common.png") - -dragDrop(Pattern("ParticleTest-1.png").targetOffset(91,17), Pattern("Acti0nsTest.png").targetOffset(93,-19)) - -#ActionEaseTest -print("Run ActionEaseTest") -click("ActionsEaseTest.png") -common_test(1,14,2.0) -click("MainMenu_Common.png") -print("ActionEaseTest finished!") - -#MotionStreakTest -print("Run MotionStreakTest") -click("MotionStreakTest.png") -wait(1.0) -click(Pattern("MotionStreak_ChangeFastMode.png").targetOffset(20,0)) -wait(1.0) -click("Next.png") -dragDrop("Motion_Drag1.png", "Motion_Drag2.png") -click(Pattern("MotionStreak_ChangeFastMode.png").targetOffset(20,0)) -dragDrop("Motion_Drag1.png", "Motion_Drag2.png") -click("Next.png") -click(Pattern("MotionStreak_ChangeFastMode.png").targetOffset(20,0)) -wait(1.0) -click("MainMenu_Common.png") -print("MotionStreakTest finished!") - -#DrawPimitivesTest -print("Run DrawPimitivesTest") -click("DrawPrimitivesTest.png") -if exists("DrawPrimitives.png"): - print("DrawPrimitivesTest success!") -print("DrawPimitivesTest finished!") -click("MainMenu_DrawPimitives.png") - -#NodeTest -print("Run NodeTest") -click("NodeTest.png") -common_test(1,14,1.0) -click("MainMenu_Common.png") -print("NodeTest finished!") - -#TouchesTest -print("Run TouchesTest") -click("TouchesTest.png") -wait(1.0) -click("MainMenu_Common.png") -print("TouchesTest finished!") - -#MenuTest -print("Run MenuTest") -click("MenuTest.png") -click("MenuTest_AtlasSprite.png") -click("MenuTest_HighScores.png") -click("MenuTest_Play.png") -click("MenuTest_Eitems.png") -click("MenuTest_Config.png") -click("MenuTest_Back.png") -click("MenuTest_Quit.png") -click("MainMenu_Common.png") -print("MenuTest finished!") - -#ActionManagerTest -print("Run ActionManagerTest") -click("ActionManaerTest.png") -common_test(1,5,3.0) -click("MainMenu_Common.png") -print("ActionManagerTest finished!") - -#LayerTest -print("Run LayerTest") -click("LayerTest.png") -dragDrop("Layer_Drag1.png", "Layer_Drag2.png") -click("Next.png") -wait(1.0) -click("Next.png") -wait(1.0) -click("Next.png") -dragDrop("Layer_Drag3.png", "Layer_Drag4.png") -common_test(1,3,1.0) -click("MainMenu_Common.png") -print("LayerTest finished!") - -dragDrop(Pattern("LaverTest-1.png").targetOffset(98,6), Pattern("Acti0nsEaseT.png").targetOffset(106,-11)) - -#SceneTest -print("Run SceneTest") -click("SceneTest.png") -click("Scene_pushScene.png") -click("Scene_relaceScene.png") -click("Scene_popToRoot.png") -click("Scene_Quit.png") -click("MainMenu_Common.png") -print("SceneTest finished!") - -#ParallaxTest -print("Run ParallaxTest") -click("ParaIIaxTest.png") -wait(3.0) -click("Next.png") -dragDrop("Parallax_Drag1.png", "Parallax_Drag2.png") -click("MainMenu_Parallax.png") -print("ParallaxTest finished!") - -#TileMapTest -print("Run TileMapTest") -click("TileMapTest.png") -common_test(1,21,2.0) -click("MainMenu_TileMap.png") -print("TileMapTest finished!") - -#IntervalTest -print("Run IntervalTest") -click("IntervaITest.png") -wait(2.0) -click("Interval_pause.png") -wait(1.0) -click("Interval_pause.png") -click("MainMenu_Common.png") -print("IntervalTest finished!") - -#ChipmunkAccelTouchTest -print("Run ChipmunkAccelTouchTest") -click("ChipmunkAccelTouchTest.png") -for i in range(1,3): - click("ChipmunkAccelTouchTest_Click.png") -for i in range(1,3): - click("it.png") -wait(3.0) -click("MainMenu_Common.png") -print("ChipmunkAccelTouchTest finished!") - -#LabelTest -print("Run LabelTest") -click("LabeITest.png") -wait(1.0) -common_test(1,26,0.5) -click("MainMenu_Common.png") -print("LabelTest finished!") - -#TextInputTest -print("Run TextInputTest") -click("TextInputTest.png") -type("TextInput_herefor.png", "1q~ tmp.txt - -#Get sdk's numbers -sdk_num=`grep "Simulator - iOS" tmp.txt|wc -l` -grep "Simulator - iOS" tmp.txt > tmp1.txt -sed 's/Simulator - iOS [4-5].[0-9]//' tmp1.txt> tmp.txt - -#Use a for circulation to build each version of sdks -cp tmp.txt $(pwd)/TestCpp/proj.ios -cd TestCpp/proj.ios -echo $sdk_num > sdk_num.txt -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' tmp.txt) - echo $a - -#Build debug version - xcodebuild -configuration Debug $a - compileresult=$[$compileresult+$?] - if [ $? == 0 ]; then - var1=build/Debug-iphonesimulator - var2=${a:(-3):3} - var3=${var1}${var2} - echo 'Debug-iphonesimulator'${var2} >> directory_name.txt - mv build/Debug-iphonesimulator $var3 - fi - sed -i '' '1d' tmp.txt -done - -cd ../.. -#Use a for circulation to build each version of sdks -cp tmp.txt $(pwd)/HelloCpp/proj.ios -cd HelloCpp/proj.ios -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' tmp.txt) - echo $a - - -#Build debug version - xcodebuild -configuration Debug $a - compileresult=$[$compileresult+$?] - sed -i '' '1d' tmp.txt -done - -cd ../.. -#Use a for circulation to build each version of sdks -cp tmp.txt $(pwd)/HelloLua/proj.ios -cd HelloLua/proj.ios -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' tmp.txt) - echo $a - -#Build debug version - xcodebuild -configuration Debug $a - compileresult=$[$compileresult+$?] - sed -i '' '1d' tmp.txt -done - -#return the compileresult. -cd ../../.. -if [ $compileresult != 0 ]; then - echo Error. - echo $compilesult -# git checkout -f -# git clean -df -x - exit 1 -else - echo Success. - echo $compileresult -# git checkout -f -# git clean -df -x -fi \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/ios/build-ios-release.sh b/tools/jenkins-scripts/mac/ios/build-ios-release.sh deleted file mode 100755 index ae1bb19af1..0000000000 --- a/tools/jenkins-scripts/mac/ios/build-ios-release.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -#This script is used to finish a ios automated compiler. - -compileresult=0 -cd ../../../../samples -#List simulator sdks -xcodebuild -showsdks > tmp.txt - -#Get sdk's numbers -sdk_num=`grep "Simulator - iOS" tmp.txt|wc -l` -grep "Simulator - iOS" tmp.txt > tmp1.txt -sed 's/Simulator - iOS [4-5].[0-9]//' tmp1.txt> tmp.txt - -#Use a for circulation to build each version of sdks -cp tmp.txt $(pwd)/TestCpp/proj.ios -cd TestCpp/proj.ios -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' tmp.txt) - echo $a - -#Build release version - xcodebuild -configuration Release $a - compileresult=$[$compileresult+$?] - sed -i '' '1d' tmp.txt -done - -cd ../.. -#Use a for circulation to build each version of sdks -cp tmp.txt $(pwd)/HelloCpp/proj.ios -cd HelloCpp/proj.ios -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' tmp.txt) - echo $a - - -#Build release version - xcodebuild -configuration Release $a - compileresult=$[$compileresult+$?] - sed -i '' '1d' tmp.txt -done - -cd ../.. -#Use a for circulation to build each version of sdks -cp tmp.txt $(pwd)/HelloLua/proj.ios -cd HelloLua/proj.ios -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' tmp.txt) - echo $a - -#Build release version - xcodebuild -configuration Release $a - compileresult=$[$compileresult+$?] - sed -i '' '1d' tmp.txt -done - -#return the compileresult. -cd ../../.. -if [ $compileresult != 0 ]; then - echo Error. - echo $compilesult -# git checkout -f -# git clean -df -x - exit 1 -else - echo Success. - echo $compileresult -# git checkout -f -# git clean -df -x -fi \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/ios/iphonesim b/tools/jenkins-scripts/mac/ios/iphonesim deleted file mode 100755 index f421018374..0000000000 Binary files a/tools/jenkins-scripts/mac/ios/iphonesim and /dev/null differ diff --git a/tools/jenkins-scripts/mac/ios/test-ios-debug.sh b/tools/jenkins-scripts/mac/ios/test-ios-debug.sh deleted file mode 100755 index 87fdfe0596..0000000000 --- a/tools/jenkins-scripts/mac/ios/test-ios-debug.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!bin/bash -#This script is used to finish a ios test automation. - -compileresult=0 - -cd .. -cp -r iOS_SikuliTest.sikuli ../../../samples/Cpp/TestCpp/proj.ios -cd ../../../samples/Cpp/TestCpp/proj.ios -sdk_num=$(sed -n '1p' sdk_num.txt) - -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' directory_name.txt) - echo $a - ./iphonesim launch $(pwd)/build/${a}/TestCpp.app & - $SIKULI_HOME/sikuli-ide.sh -r $(pwd)/iOS_SikuliTest.sikuli -done - -#Sikuli Test success! -echo Sikuli Test Success! -#git checkout -f -#git clean -df -x -exit 0 - -#End \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/ios/test-ios-release.sh b/tools/jenkins-scripts/mac/ios/test-ios-release.sh deleted file mode 100755 index 87fdfe0596..0000000000 --- a/tools/jenkins-scripts/mac/ios/test-ios-release.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!bin/bash -#This script is used to finish a ios test automation. - -compileresult=0 - -cd .. -cp -r iOS_SikuliTest.sikuli ../../../samples/Cpp/TestCpp/proj.ios -cd ../../../samples/Cpp/TestCpp/proj.ios -sdk_num=$(sed -n '1p' sdk_num.txt) - -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' directory_name.txt) - echo $a - ./iphonesim launch $(pwd)/build/${a}/TestCpp.app & - $SIKULI_HOME/sikuli-ide.sh -r $(pwd)/iOS_SikuliTest.sikuli -done - -#Sikuli Test success! -echo Sikuli Test Success! -#git checkout -f -#git clean -df -x -exit 0 - -#End \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/mac/build-mac-all.sh b/tools/jenkins-scripts/mac/mac/build-mac-all.sh deleted file mode 100755 index 4696701751..0000000000 --- a/tools/jenkins-scripts/mac/mac/build-mac-all.sh +++ /dev/null @@ -1,15 +0,0 @@ -# cpp -xcodebuild clean build -project ../../../../samples/Cpp/HelloCpp/proj.mac/HelloCpp.xcodeproj -alltargets -configuration Debug -xcodebuild clean build -project ../../../../samples/Cpp/HelloCpp/proj.mac/HelloCpp.xcodeproj -alltargets -configuration Release - -xcodebuild clean build -project ../../../../samples/Cpp/TestCpp/proj.mac/TestCpp.xcodeproj -alltargets -configuration Debug -xcodebuild clean build -project ../../../../samples/Cpp/TestCpp/proj.mac/TestCpp.xcodeproj -alltargets -configuration Release - -# lua -# TBD - -# javascript -# TBD - -# other sample games -# TBD diff --git a/tools/jenkins-scripts/mac/mac/build-mac-debug.sh b/tools/jenkins-scripts/mac/mac/build-mac-debug.sh deleted file mode 100755 index 1a2492e196..0000000000 --- a/tools/jenkins-scripts/mac/mac/build-mac-debug.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -#This script is used to finish a mac automated compiler. - -compileresult=0 -cd ../../../../samples/Cpp -#List simulator sdks -xcodebuild -showsdks > tmp.txt - -#Get sdk's numbers -sdk_num=`grep "Mac OS X 10" tmp.txt|wc -l` -grep "Mac OS X 10" tmp.txt > tmp1.txt -sed 's/Mac OS X 10.[0-9]//' tmp1.txt> tmp.txt - -#Use a for circulation to build each version of sdks -cp tmp.txt $(pwd)/TestCpp/proj.mac -cd TestCpp/proj.mac -echo $sdk_num > sdk_num.txt -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' tmp.txt) - echo $a - -#Build debug version - xcodebuild -configuration Debug $a - compileresult=$[$compileresult+$?] - if [ $? == 0 ]; then - var1=build/Debug - var2=${a:(-4):4} - var3=${var1}${var2} - echo 'Debug'${var2} >> directory_name.txt - mv build/Debug $var3 - fi - sed -i '' '1d' tmp.txt -done - -cd ../.. -#Use a for circulation to build each version of sdks -cp tmp.txt $(pwd)/HelloCpp/proj.mac -cd HelloCpp/proj.mac -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' tmp.txt) - echo $a - -#Build debug version - xcodebuild -configuration Debug $a - compileresult=$[$compileresult+$?] - sed -i '' '1d' tmp.txt -done - -#return the compileresult. -cd ../../.. -if [ $compileresult != 0 ]; then - echo Error. - echo $compilesult -# git checkout -f -# git clean -df -x - exit 1 -else - echo Success. - echo $compileresult -# git checkout -f -# git clean -df -x -fi \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/mac/build-mac-release.sh b/tools/jenkins-scripts/mac/mac/build-mac-release.sh deleted file mode 100755 index 51d6d26282..0000000000 --- a/tools/jenkins-scripts/mac/mac/build-mac-release.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -#This script is used to finish a mac automated compiler. - -compileresult=0 -cd ../../../../samples/Cpp -#List simulator sdks -xcodebuild -showsdks > tmp.txt - -#Get sdk's numbers -sdk_num=`grep "Mac OS X 10" tmp.txt|wc -l` -grep "Mac OS X 10" tmp.txt > tmp1.txt -sed 's/Mac OS X 10.[0-9]//' tmp1.txt> tmp.txt - -#Use a for circulation to build each version of sdks -cp tmp.txt $(pwd)/TestCpp/proj.mac -cd TestCpp/proj.mac -echo $sdk_num > sdk_num.txt -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' tmp.txt) - echo $a - -#Build release version - xcodebuild -configuration Release $a - compileresult=$[$compileresult+$?] - if [ $? == 0 ]; then - var1=build/Debug - var2=${a:(-4):4} - var3=${var1}${var2} - echo 'Debug'${var2} >> directory_name.txt - mv build/Debug $var3 - fi - sed -i '' '1d' tmp.txt -done - -cd ../.. -#Use a for circulation to build each version of sdks -cp tmp.txt $(pwd)/HelloCpp/proj.mac -cd HelloCpp/proj.mac -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' tmp.txt) - echo $a - -#Build release version - xcodebuild -configuration Release $a - compileresult=$[$compileresult+$?] - sed -i '' '1d' tmp.txt -done - -#return the compileresult. -cd ../../.. -if [ $compileresult != 0 ]; then - echo Error. - echo $compilesult -# git checkout -f -# git clean -df -x - exit 1 -else - echo Success. - echo $compileresult -# git checkout -f -# git clean -df -x -fi \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/mac/test-mac-debug.sh b/tools/jenkins-scripts/mac/mac/test-mac-debug.sh deleted file mode 100755 index ff2afb7e12..0000000000 --- a/tools/jenkins-scripts/mac/mac/test-mac-debug.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!bin/bash -#This script is used to finish a ios test automation. - -compileresult=0 - -cd .. -cp -r iOS_SikuliTest.sikuli ../../../samples/Cpp/TestCpp/proj.mac -cd ../../../samples/Cpp/TestCpp/proj.mac -sdk_num=$(sed -n '1p' sdk_num.txt) - -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' directory_name.txt) - echo $a - $(pwd)/build/${a}/TestCpp.app/Contents/MacOS/TestCpp & - $SIKULI_HOME/sikuli-ide.sh -r $(pwd)/iOS_SikuliTest.sikuli -done - -#Sikuli Test success! -echo Sikuli Test Success! -#git checkout -f -#git clean -df -x -exit 0 - -#End \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/mac/test-mac-release.sh b/tools/jenkins-scripts/mac/mac/test-mac-release.sh deleted file mode 100755 index e22e439910..0000000000 --- a/tools/jenkins-scripts/mac/mac/test-mac-release.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!bin/bash -#This script is used to finish a ios test automation. - -compileresult=0 - -cd .. -cp -r iOS_SikuliTest.sikuli ../../../samples/Cpp/TestCpp/proj.mac -cd ../../../samples/TestCpp/Cpp/proj.mac -sdk_num=$(sed -n '1p' sdk_num.txt) - -for((i=1;i<=$sdk_num;i++)) -do - a=$(sed -n '1p' directory_name.txt) - echo $a - $(pwd)/build/${a}/TestCpp.app/Contents/MacOS/TestCpp & - $SIKULI_HOME/sikuli-ide.sh -r $(pwd)/iOS_SikuliTest.sikuli -done - -#Sikuli Test success! -echo Sikuli Test Success! -#git checkout -f -#git clean -df -x -exit 0 - -#End \ No newline at end of file diff --git a/tools/jenkins-scripts/mac/rootconfig-mac.sh b/tools/jenkins-scripts/mac/rootconfig-mac.sh deleted file mode 100644 index f675a76fcd..0000000000 --- a/tools/jenkins-scripts/mac/rootconfig-mac.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -#get params for build_native.sh -CUR=$(pwd) -cd ../../.. -#COCOS2DX=$(pwd) - -#var1=NDK_ROOT_LOCAL= -#_NDK_ROOT=${var1}${ANDROID_NDK} - -#var2=COCOS2DX_ROOT_LOCAL= -#_COCOS2DX_ROOT=${var2}${COCOS2DX} -#echo $_NDK_ROOT -#echo $_COCOS2DX_ROOT - -#Modify the configuration files -#sed -i '' '3,4d' $CUR/build_native.sh -sed -i '' '13d' $CUR/project.properties -#gsed -i "3 i\\$_NDK_ROOT" $CUR/build_native.sh -#gsed -i "4 i\\$_COCOS2DX_ROOT" $CUR/build_native.sh - -#Modify the xml file -if [ $1 = TestCpp ]; then - gsed -i '2d' $CUR/build.xml - gsed -i '2 i\' $CUR/build.xml -elif [ $1 = HelloCpp ]; then - gsed -i '2d' $CUR/build.xml - gsed -i '2 i\' $CUR/build.xml -else - gsed -i '2d' $CUR/build.xml - gsed -i '2 i\' $CUR/build.xml -fi diff --git a/tools/jenkins-scripts/pull-request-builder.py b/tools/jenkins-scripts/pull-request-builder.py new file mode 100755 index 0000000000..3f258e4401 --- /dev/null +++ b/tools/jenkins-scripts/pull-request-builder.py @@ -0,0 +1,174 @@ +#Github pull reqest builder for Jenkins + +import json +import os +import re +import urllib2 +import urllib +import base64 +import requests +import sys +import traceback +import platform + +#set Jenkins build description using submitDescription to mock browser behavior +#TODO: need to set parent build description +def set_description(desc, url): + req_data = urllib.urlencode({'description': desc}) + req = urllib2.Request(url + 'submitDescription', req_data) + #print(os.environ['BUILD_URL']) + req.add_header('Content-Type', 'application/x-www-form-urlencoded') + base64string = base64.encodestring(os.environ['JENKINS_ADMIN']+ ":" + os.environ['JENKINS_ADMIN_PW']).replace('\n', '') + req.add_header("Authorization", "Basic " + base64string) + try: + urllib2.urlopen(req) + except: + traceback.print_exc() +def main(): + #get payload from os env + payload_str = os.environ['payload'] + #parse to json obj + payload = json.loads(payload_str) + + #get pull number + pr_num = payload['number'] + print 'pr_num:' + str(pr_num) + + #build for pull request action 'open' and 'synchronize', skip 'close' + action = payload['action'] + print 'action: ' + action + + pr = payload['pull_request'] + + url = pr['html_url'] + print "url:" + url + pr_desc = '

pr#' + str(pr_num) + ' is '+ action +'

' + + + + #get statuses url + statuses_url = pr['statuses_url'] + + #get pr target branch + branch = pr['base']['ref'] + + #set commit status to pending + target_url = os.environ['BUILD_URL'] + + set_description(pr_desc, target_url) + + if((action != 'opened') and (action != 'synchronize')): + print 'pull request #' + str(pr_num) + ' is '+action+', no build triggered' + return(0) + + r = requests.get(pr['url']+"/commits") + commits = r.json() + last_commit = commits[len(commits)-1] + message = last_commit['commit']['message'] + + pattern = re.compile("\[ci(\s+)skip\]", re.I) + result = pattern.search(message) + if result is not None: + print 'skip build for pull request #' + str(pr_num) + return(0) + + data = {"state":"pending", "target_url":target_url} + access_token = os.environ['GITHUB_ACCESS_TOKEN'] + Headers = {"Authorization":"token " + access_token} + + try: + requests.post(statuses_url, data=json.dumps(data), headers=Headers) + except: + traceback.print_exc() + + #reset path to workspace root + os.system("cd " + os.environ['WORKSPACE']); + os.system("git checkout develop") + os.system("git branch -D pull" + str(pr_num)) + #clean workspace + print "git clean -xdf" + os.system("git clean -xdf") + + + #fetch pull request to local repo + git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/head" + os.system(git_fetch_pr) + + #checkout + git_checkout = "git checkout -b " + "pull" + str(pr_num) + " FETCH_HEAD" + os.system(git_checkout) + + #update submodule + git_update_submodule = "git submodule update --init --force" + os.system(git_update_submodule) + + # Generate binding glue codes + if(platform.system() == 'Darwin'): + os.system("tools/jenkins-scripts/gen_jsb.sh") + + #make temp dir + print "current dir is" + os.environ['WORKSPACE'] + os.system("cd " + os.environ['WORKSPACE']); + os.mkdir("android_build_objs") + #add symbol link + PROJECTS=["Cpp/HelloCpp","Cpp/TestCpp","Cpp/SimpleGame","Cpp/AssetsManagerTest", + "Javascript/TestJavascript","Javascript/CocosDragonJS","Javascript/CrystalCraze", + "Javascript/MoonWarriors","Javascript/WatermelonWithMe","Lua/HelloLua","Lua/TestLua"] + print platform.system() + if(platform.system() == 'Darwin'): + for item in PROJECTS: + cmd = "ln -s " + os.environ['WORKSPACE']+"/android_build_objs/ " + os.environ['WORKSPACE']+"/samples/"+item+"/proj.android/obj" + os.system(cmd) + elif(platform.system() == 'Windows'): + for item in PROJECTS: + p = item.replace("/", os.sep) + cmd = "mklink /J "+os.environ['WORKSPACE']+os.sep+"samples"+os.sep +p+os.sep+"proj.android"+os.sep+"obj " + os.environ['WORKSPACE']+os.sep+"android_build_objs" + print cmd + os.system(cmd) + + #build + #TODO: support android-mac build currently + #TODO: add android-windows7 build + #TODO: add android-linux build + #TODO: add ios build + #TODO: add mac build + #TODO: add win32 build + if(branch == 'develop'): + ret = os.system("python build/android-build.py -n -j10 all") + elif(branch == 'master'): + ret = os.system("samples/Cpp/TestCpp/proj.android/build_native.sh") + + #get build result + print "build finished and return " + str(ret) + exit_code = 1 + if ret == 0: + exit_code = 0 + data['state'] = "success" + + else: + exit_code = 1 + data['state'] = "failure" + + #set commit status + try: + requests.post(statuses_url, data=json.dumps(data), headers=Headers) + except: + traceback.print_exc() + + #clean workspace + os.system("cd " + os.environ['WORKSPACE']); + os.system("git checkout develop") + os.system("git branch -D pull" + str(pr_num)) + + return(exit_code) + +# -------------- main -------------- +if __name__ == '__main__': + sys_ret = 0 + try: + sys_ret = main() + except: + traceback.print_exc() + sys_ret = 1 + finally: + sys.exit(sys_ret) diff --git a/tools/jenkins-scripts/windows/android/androidtestcommon.bat b/tools/jenkins-scripts/windows/android/androidtestcommon.bat deleted file mode 100755 index 3a1d23a756..0000000000 --- a/tools/jenkins-scripts/windows/android/androidtestcommon.bat +++ /dev/null @@ -1,89 +0,0 @@ -echo off -rem =========Basic parameters============ -rem jdk path -set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_31 -rem jdk version -set JDK_Version=1.6 -rem sdk path -set AndroidHome=D:\Windows7\android-sdk-windows -rem android version path -set AndroidVersion=\platforms\android-8 -rem android project path -set AndroidProject=D:\cocos2d-x\samples\Cpp\TestCpp\proj.android -rem unsigned apk name -set unsign_apk=Tests.apk -rem signed apk name -set sign_apk=Tests-sign.apk -rem sign keystore -set apk_key=cdykeystore -set apk_keypass=123456 -set apk_keystore=D:\cdykeystore - -for %%x in ("%AndroidProject%") do set AndroidProject=%%~sx -for %%x in ("%JAVA_HOME%") do set JAVA_HOME=%%~sx -for %%x in ("%AndroidHome%") do set AndroidHome=%%~sx - -rem jdk kit -set EXE_JAVA=%JAVA_HOME%\bin\java -set JAVAC=%JAVA_HOME%\bin\javac -set JAR=%JAVA_HOME%\bin\jar -set KeyTool=%JAVA_HOME%\bin\keytool -set Jarsigner=%JAVA_HOME%\bin\jarsigner - -rem sdk kit -set AndroidAAPT=%AndroidHome%\platform-tools\aapt.exe -set AndroidDx=%AndroidHome%\platform-tools\dx.bat -set AndroidApkBuilder=%AndroidHome%\tools\apkbuilder.bat -set AndroidJar=%AndroidHome%%AndroidVersion%\android.jar - -rem android project directory -set AndroidProjectDrive=D: -set AndroidProjectRes=%AndroidProject%\res -set AndroidProjectGen=%AndroidProject%\gen -set AndroidProjectBin=%AndroidProject%\bin -set AndroidProjectAsset=%AndroidProject%\assets -set AndroidProjectLibs=%AndroidProject%\libs -set AndroidProjectAndroidMainfest=%AndroidProject%\AndroidManifest.xml -set AndroidProjectSrc=%AndroidProject%\src\org\cocos2dx\tests\*.java -set AndroidProjectSrc=%AndroidProjectSrc% %AndroidProject%\src\org\cocos2dx\lib\*.java -set AndroidProjectSrc=%AndroidProjectSrc% %AndroidProject%\gen\org\cocos2dx\tests\*.java - -rem output file -set AndroidProjectClassDex=%AndroidProject%\bin\classes.dex -set AndroidProjectResources=%AndroidProject%\bin\resources.ap_ -set AndroidProjectApk="%AndroidProject%\bin\%unsign_apk%" -set AndroidProjectSignApk="%AndroidProject%\bin\%sign_apk%" - -mkdir %AndroidProject%\gen -mkdir %AndroidProject%\src\org\cocos2dx\lib -mkdir %AndroidProject%\bin -::mkdir %AndroidProject%\bin\classes -xcopy D:\cocos2d-x\cocos2dx\platform\android\java\src\org\cocos2dx\lib %AndroidProject%\src\org\cocos2dx\lib /s - -echo generate R.java file -%AndroidAAPT% package -f -m -J %AndroidProjectGen% -S %AndroidProjectRes% -I %AndroidJar% -M %AndroidProjectAndroidMainfest% - -echo generate class file -%JAVAC% -encoding UTF-8 -target %JDK_Version% -bootclasspath %AndroidJar% -d %AndroidProjectBin% %AndroidProjectSrc% %AndroidProjectGen%\org\cocos2dx\tests\R.java - -echo generate dex file -echo on -%AndroidProjectDrive% -cd %AndroidProjectBin% -rem packaging the *.class file into *.jar file -%JAR% cvf %AndroidProjectBin%\classes.jar *.* -cd %AndroidProject% -rem generate *.dex file -call %AndroidDx% --dex --output=%AndroidProjectClassDex% %AndroidProjectBin%\classes.jar - -echo package resources files -%AndroidAAPT% package -f -M %AndroidProjectAndroidMainfest% -S %AndroidProjectRes% -A %AndroidProjectAsset% -I %AndroidJar% -F %AndroidProjectResources% - -echo generate unsigned apk file -call %AndroidApkBuilder% %AndroidProjectApk% -v -u -z %AndroidProjectResources% -f %AndroidProjectClassDex% -rf %AndroidProject%\src -nf %AndroidProjectLibs% -rj %AndroidProjectLibs% - -echo generate signed apk file -%Jarsigner% -verbose -keystore %apk_keystore% -keypass %apk_keypass% -storepass %apk_keypass% -signedjar %AndroidProjectSignApk% %AndroidProjectApk% cdykeystore - -echo sign success! -pause \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/android/build-android-2.2-3.2-debug.bat b/tools/jenkins-scripts/windows/android/build-android-2.2-3.2-debug.bat deleted file mode 100755 index f95720db38..0000000000 --- a/tools/jenkins-scripts/windows/android/build-android-2.2-3.2-debug.bat +++ /dev/null @@ -1,156 +0,0 @@ -::This script is used to accomplish a android automated compile. -::You should make sure have accomplished the environment settings. -:: Don't change it until you know what you do. - -::Here are the environment variables you should set. -::%ANT_HOME% %ANDROID_HOME% %JAVA_HOME% %CYGWIN% %ANDROID_NDK% -echo off -if not exist "%CYGWIN%" echo Couldn't find Cygwin at "%CYGWIN%" and you should set it like this "C:\cygwin"& pause & exit 1 -if not exist "%ANDROID_HOME%" echo Couldn't find ANDROID_HOME at "%ANDROID_HOME%" and you should set it like this "D:\xx\android-sdk-windows"& pause & exit 2 -if not exist "%ANDROID_NDK%" echo Couldn't find Cygwin at "%ANDROID_NDK%" and you should set it like this "D:\xx\android-ndk-r8"& pause & exit 3 -if not exist "%JAVA_HOME%" echo Couldn't find Cygwin at "%JAVA_HOME%" and you should set it like it this "C:\xx\jdk1.7.0_05"& pause & exit 4 -if not exist "%ANT_HOME%" echo Couldn't find Ant at "%ANT_HOME%" and you should set it like this "D:\xx\apache-ant-1.8.4" $ pause $ exit 5 - -set _PROJECTNAME=TestCpp -set _LANGUAGE_=Cpp -set _ROOT_=%cd%\..\..\..\.. -cd %_ROOT_% - -:project -::Copy build Configuration files to target directory -copy %_ROOT_%\tools\jenkins_scripts\ant.properties %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android /Y -copy %_ROOT_%\tools\jenkins_scripts\build.xml %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android /Y -copy %_ROOT_%\tools\jenkins_scripts\windows\android\rootconfig.sh %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android /Y - -::Modify the configuration files -cd %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android -rootconfig.sh %_PROJECTNAME% -cd .. -set _PROJECTLOCATION=%cd% - -::A command line that make the current user get the ownrship of project. -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F - -::Use cygwin compile the source code. -cygpath "%_PROJECTLOCATION%\proj.android\build_native.sh"|call %CYGWIN%\Cygwin.bat - -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F -::echo "%_PROJECTION%/proj.android/build_native.sh"|call %CYGWIN%\Cygwin.bat - -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F -call android update project -p proj.android -cd proj.android - -::Make sure the original android build target is android-8 -for /f "delims=" %%a in ('findstr /i "target=android-" ant.properties') do set xx=%%a -echo %xx% -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="%xx%" (echo/target=android-8)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Android ant build(debug,API level:8). -call ant debug -set result8=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto API_10 -if %result8% NEQ 0 goto API_10 -cd bin -ren TestCpp-debug.apk TestCpp-debug-8.apk -cd .. - -:API_10 -::Change API level.(API level:10) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-8" (echo/target=android-10)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Android ant build(debug,API level:10). -call ant debug -set result10=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto API_11 -if %result10% NEQ 0 goto API_11 -cd bin -ren TestCpp-debug.apk TestCpp-debug-10.apk -cd .. - -:API_11 -::Change API level.(API level:11) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-10" (echo/target=android-11)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Android ant build(debug,API level:11). -call ant debug -set result11=%ERRORlEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto API_12 -if %result11% NEQ 0 goto API_12 -cd bin -ren TestCpp-debug.apk TestCpp-debug-11.apk -cd .. - -:API_12 -::Change API level.(API level:12) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-11" (echo/target=android-12)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Android ant build(debug,API level:12). -call ant debug -set result12=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto API_13 -if %result12% NEQ 0 goto API_13 -cd bin -ren TestCpp-debug.apk TestCpp-debug-12.apk -cd .. - -:API_13 -::Change API level.(API level:13) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-12" (echo/target=android-13)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Android ant build(debug,API level:13). -call ant debug -set result13=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto NEXTPROJ -if %result13% NEQ 0 goto NEXTPROJ -cd bin -ren TestCpp-debug.apk TestCpp-debug-13.apk -cd .. - -:NEXTPROJ -::After all test versions completed,changed current API level to the original.(API level:8) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-13" (echo/target=android-8)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Calculate the errorlevel and change build target. -cd %_ROOT_% -if "%_PROJECTNAME%"=="TestCpp" set /a TestCpp_Result=(result8+result10+result11+result12+result13) && set _PROJECTNAME=HelloCpp&& goto project -if "%_PROJECTNAME%"=="HelloCpp" set /a HelloCpp_Result=(result8+result10+result11+result12+result13) && set _LANGUAGE_=Lua&& set _PROJECTNAME=HelloLua&& goto project -if "%_PROJECTNAME%"=="HelloLua" set /a HelloLua_Result=(result8+result10+result11+result12+result13) -set /a Compile_Result=(TestCpp_Result+HelloCpp_Result+HelloLua_Result) -if %Compile_Result% NEQ 0 goto error - -goto success - -:error -echo Compile Error! -echo %Compile_Result% -::git checkout -f -::git clean -df -x -exit 1 - -:success -echo Compile Success! -echo %Compile_Result% -::git checkout -f -::git clean -df -x -exit 0 - -::End. \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/android/build-android-2.2-3.2-release.bat b/tools/jenkins-scripts/windows/android/build-android-2.2-3.2-release.bat deleted file mode 100755 index b15aa3f036..0000000000 --- a/tools/jenkins-scripts/windows/android/build-android-2.2-3.2-release.bat +++ /dev/null @@ -1,179 +0,0 @@ -::This script is used to accomplish a android automated compile. -::You should make sure have accomplished the environment settings. -:: Don't change it until you know what you do. - -::Here are the environment variables you should set. -::%ANT_HOME% %ANDROID_HOME% %JAVA_HOME% %CYGWIN% %ANDROID_NDK% -if not exist "%CYGWIN%" echo Couldn't find Cygwin at "%CYGWIN%" and you should set it like this "C:\cygwin"& pause & exit 1 -if not exist "%ANDROID_HOME%" echo Couldn't find ANDROID_HOME at "%ANDROID_HOME%" and you should set it like this "D:\xx\android-sdk-windows"& pause & exit 2 -if not exist "%ANDROID_NDK%" echo Couldn't find Cygwin at "%ANDROID_NDK%" and you should set it like this "D:\xx\android-ndk-r8"& pause & exit 3 -if not exist "%JAVA_HOME%" echo Couldn't find Cygwin at "%JAVA_HOME%" and you should set it like it this "C:\xx\jdk1.7.0_05"& pause & exit 4 -if not exist "%ANT_HOME%" echo Couldn't find Ant at "%ANT_HOME%" and you should set it like this "D:\xx\apache-ant-1.8.4" $ pause $ exit 5 - -set _PROJECTNAME=TestCpp -set _LANGUAGE_=Cpp -set _ROOT_=%cd%\..\..\..\.. -cd %_ROOT_% - -:project -::Copy build Configuration files to target directory -copy %_ROOT_%\tools\jenkins_scripts\ant.properties %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android -copy %_ROOT_%\tools\jenkins_scripts\build.xml %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android -copy %_ROOT_%\tools\jenkins_scripts\windows\android\rootconfig.sh %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android - -::Modify the configuration files -cd %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android -rootconfig.sh %_PROJECTNAME% -cd .. -set _PROJECTLOCATION=%cd% - -::A command line that make the current user get the ownrship of project. -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F - -::Use cygwin compile the source code. -cygpath "%_PROJECTLOCATION%\proj.android\build_native.sh"|call %CYGWIN%\Cygwin.bat - -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F -::echo "%_PROJECTION%/proj.android/build_native.sh"|call %CYGWIN%\Cygwin.bat - -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F -call android update project -p proj.android -cd proj.android - -::Make sure the original android build target is android-8 -for /f "delims=" %%a in ('findstr /i "target=android-" ant.properties') do set xx=%%a -echo %xx% -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="%xx%" (echo/target=android-8)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -for /f "delims=" %%a in (ant.properties) do set num=%%a&call :lis -move ant1.properties ant.properties - -::Android ant build(release,API level:8). -call ant release -set result8=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto API_10 -if %result8% NEQ 0 goto API_10 -cd bin -ren TestCpp-release.apk TestCpp-release-8.apk -cd .. - -:API_10 -::Change API level.(API level:10) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-8" (echo/target=android-10)else echo/%%a -)>>"ant1.properties" -move ant1.properties ant.properties - -for /f "delims=" %%a in (ant.properties) do set num=%%a&call :lis -move ant1.properties ant.properties - -::Android ant build(release,API level:10). -call ant release -set result10=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto API_11 -if %result10% NEQ 0 goto API_11 -cd bin -ren TestCpp-release.apk TestCpp-release-10.apk -cd .. - -:API_11 -::Change API level.(API level:11) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-10" (echo/target=android-11)else echo/%%a -)>>"ant1.properties" -move ant1.properties ant.properties - -for /f "delims=" %%a in (ant.properties) do set num=%%a&call :lis -move ant1.properties ant.properties - -::Android ant build(release,API level:11). -call ant release -set result11=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto API_12 -if %result11% NEQ 0 goto API_12 -cd bin -ren TestCpp-release.apk TestCpp-release-11.apk -cd .. - -:API_12 -::Change API level.(API level:12) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-11" (echo/target=android-12)else echo/%%a -)>>"ant1.properties" -move ant1.properties ant.properties - -for /f "delims=" %%a in (ant.properties) do set num=%%a&call :lis -move ant1.properties ant.properties - -::Android ant build(release,API level:12). -call ant release -set result12=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto API_13 -if %result12% NEQ 0 goto API_13 -cd bin -ren TestCpp-release.apk TestCpp-release-12.apk -cd .. - -:API_13 -::Change API level.(API level:13) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-12" (echo/target=android-13)else echo/%%a -)>>"ant1.properties" -move ant1.properties ant.properties - -for /f "delims=" %%a in (ant.properties) do set num=%%a&call :lis -move ant1.properties ant.properties - -::Android ant build(release,API level:13). -call ant release -set result13=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto NEXTPROJ -if %result13% NEQ 0 goto NEXTPROJ -cd bin -ren TestCpp-release.apk TestCpp-release-13.apk -cd .. - -:NEXTPROJ -::After all test versions completed,changed current API level to the original.(API level:8) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-13" (echo/target=android-8)else echo/%%a -)>>"ant1.properties" -move ant1.properties ant.properties - -for /f "delims=" %%a in (ant.properties) do set num=%%a&call :lis -move ant1.properties ant.properties - -::Calculate the errorlevel and change build target. -cd %_ROOT_% -if "%_PROJECTNAME%"=="TestCpp" set /a testresult1=(result8+result10+result11+result12+result13) && set _PROJECTNAME=HelloCpp&& goto project -if "%_PROJECTNAME%"=="HelloCpp" set /a testresult2=(result8+result10+result11+result12+result13) && set _LANGUAGE_=Lua&& set _PROJECTNAME=HelloLua&& goto project -if "%_PROJECTNAME%"=="HelloLua" set /a testresult3=(result8+result10+result11+result12+result13) -set /a testresult=(testresult1+testresult2+testresult3) -if %testresult% NEQ 0 goto error - -goto success - -:lis -if "%num%"=="" goto :eof -if "%num:~-1%"==" " set num=%num:~0,-1%&goto lis -echo %num%>>ant1.properties -goto :eof - -:error -echo Compile Error! -echo %Compile_Result% -::git checkout -f -::git clean -df -x -exit 1 - -:success -echo Compile Success! -echo %Compile_Result% -::git checkout -f -::git clean -df -x -exit 0 - -::End. \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/android/build-android-4.x-debug.bat b/tools/jenkins-scripts/windows/android/build-android-4.x-debug.bat deleted file mode 100755 index 08e1cdba24..0000000000 --- a/tools/jenkins-scripts/windows/android/build-android-4.x-debug.bat +++ /dev/null @@ -1,112 +0,0 @@ -::This script is used to accomplish a android automated compile. -::You should make sure have accomplished the environment settings. -:: Don't change it until you know what you do. - -::Here are the environment variables you should set. -::%ANT_HOME% %ANDROID_HOME% %JAVA_HOME% %CYGWIN% %ANDROID_NDK% -if not exist "%CYGWIN%" echo Couldn't find Cygwin at "%CYGWIN%" and you should set it like this "C:\cygwin"& pause & exit 1 -if not exist "%ANDROID_HOME%" echo Couldn't find ANDROID_HOME at "%ANDROID_HOME%" and you should set it like this "D:\xx\android-sdk-windows"& pause & exit 2 -if not exist "%ANDROID_NDK%" echo Couldn't find Cygwin at "%ANDROID_NDK%" and you should set it like this "D:\xx\android-ndk-r8"& pause & exit 3 -if not exist "%JAVA_HOME%" echo Couldn't find Cygwin at "%JAVA_HOME%" and you should set it like it this "C:\xx\jdk1.7.0_05"& pause & exit 4 -if not exist "%ANT_HOME%" echo Couldn't find Ant at "%ANT_HOME%" and you should set it like this "D:\xx\apache-ant-1.8.4" $ pause $ exit 5 - -set _PROJECTNAME=TestCpp -set _LANGUAGE_=CPP -set _ROOT_=%cd%\..\..\..\.. -cd _ROOT_ - -:project -::Copy build Configuration files to target directory -copy %_ROOT_%\tools\jenkins_scripts\ant.properties %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android -copy %_ROOT_%\tools\jenkins_scripts\build.xml %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android -copy %_ROOT_%\tools\jenkins_scripts\windows\android\rootconfig.sh %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android - -::Modify the configuration files -cd %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android -rootconfig.sh %_PROJECTNAME% -cd .. -set _PROJECTLOCATION=%cd% - -::A command line that make the current user get the ownrship of project. -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F - -::Use cygwin compile the source code. -cygpath "%_PROJECTLOCATION%\proj.android\build_native.sh"|call %CYGWIN%\Cygwin.bat - -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F -::echo "%_PROJECTION%/proj.android/build_native.sh"|call %CYGWIN%\Cygwin.bat - -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F -call android update project -p proj.android -cd proj.android - -for /f "delims=" %%a in ('findstr /i "target=android-" ant.properties') do set xx=%%a -echo %xx% -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="%xx%" (echo/target=android-8)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Change API level.(API level:14) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-8" (echo/target=android-14)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Android ant build(debug,API level:14). -call ant debug -set result14=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto API_15 -if %result14% NEQ 0 goto API_15 -cd bin -ren TestCpp-debug.apk TestCpp-debug-14.apk -cd .. - -:API_15 -::Change API level.(API level:15) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-14" (echo/target=android-15)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Android ant build(debug,API level:15). -call ant debug -set result15=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto NEXTPROJ -if %result15% NEQ 0 goto NEXTPROJ -cd bin -ren TestCpp-debug.apk TestCpp-debug-15.apk -cd .. - -:NEXTPROJ -::After all test versions completed,changed current API level to the original.(API level:8) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-15" (echo/target=android-8)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Calculate the errorlevel and change build target. -cd %_ROOT_% -IF "%_PROJECTNAME%"=="TestCpp" set /a testresult1=(result14+result15) && set _PROJECTNAME=HelloCpp&& goto project -IF "%_PROJECTNAME%"=="HelloCpp" set /a testresult2=(result14+result15) && set _LANGUAGE_=Lua&& set _PROJECTNAME=HelloLua&& goto project -IF "%_PROJECTNAME%"=="HelloLua" set /a testresult3=(result14+result15) -set /a testresult=(testresult1+testresult2+testresult3) -IF %testresult% NEQ 0 goto error - -goto success - -:error -echo Compile Error! -echo %Compile_Result% -::git checkout -f -::git clean -df -x -exit 1 - -:success -echo Compile Success! -echo %Compile_Result% -::git checkout -f -::git clean -df -x -exit 0 - -::End. \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/android/build-android-4.x-release.bat b/tools/jenkins-scripts/windows/android/build-android-4.x-release.bat deleted file mode 100755 index 3fb2c39088..0000000000 --- a/tools/jenkins-scripts/windows/android/build-android-4.x-release.bat +++ /dev/null @@ -1,127 +0,0 @@ -::This script is used to accomplish a android automated compile. -::You should make sure have accomplished the environment settings. -:: Don't change it until you know what you do. - -::Here are the environment variables you should set. -::%ANT_HOME% %ANDROID_HOME% %JAVA_HOME% %CYGWIN% %ANDROID_NDK% -if not exist "%CYGWIN%" echo Couldn't find Cygwin at "%CYGWIN%" and you should set it like this "C:\cygwin"& pause & exit 1 -if not exist "%ANDROID_HOME%" echo Couldn't find ANDROID_HOME at "%ANDROID_HOME%" and you should set it like this "D:\xx\android-sdk-windows"& pause & exit 2 -if not exist "%ANDROID_NDK%" echo Couldn't find Cygwin at "%ANDROID_NDK%" and you should set it like this "D:\xx\android-ndk-r8"& pause & exit 3 -if not exist "%JAVA_HOME%" echo Couldn't find Cygwin at "%JAVA_HOME%" and you should set it like it this "C:\xx\jdk1.7.0_05"& pause & exit 4 -if not exist "%ANT_HOME%" echo Couldn't find Ant at "%ANT_HOME%" and you should set it like this "D:\xx\apache-ant-1.8.4" $ pause $ exit 5 - -set _PROJECTNAME=TestCpp -set _LANGUAGE=Cpp -set _ROOT_=%cd%\..\..\..\.. -cd %_ROOT_% - -:project -::Copy build Configuration files to target directory -copy %_ROOT_%\tools\jenkins_scripts\ant.properties %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android -copy %_ROOT_%\tools\jenkins_scripts\build.xml %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android -copy %_ROOT_%\tools\jenkins_scripts\windows\android\rootconfig.sh %_ROOT_%\samples\%_LANGUAGE_%\%_PROJECTNAME%\proj.android - -::Modify the configuration files -cd %_ROOT_%\samples\%_PROJECTNAME%\proj.android -rootconfig.sh %_PROJECTNAME% -cd .. -set _PROJECTLOCATION=%cd% - -::A command line that make the current user get the ownrship of project. -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F - -::Use cygwin compile the source code. -cygpath "%_PROJECTLOCATION%\proj.android\build_native.sh"|call %CYGWIN%\Cygwin.bat - -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F -::echo "%_PROJECTION%/proj.android/build_native.sh"|call %CYGWIN%\Cygwin.bat - -::cacls proj.android\*.* /T /E /C /P %_USERNAME%:F -call android update project -p proj.android -cd proj.android - -for /f "delims=" %%a in ('findstr /i "target=android-" ant.properties') do set xx=%%a -echo %xx% -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="%xx%" (echo/target=android-8)else echo/%%a -)>>"anttmp.properties" -move anttmp.properties ant.properties - -::Change API level.(API level:14) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-8" (echo/target=android-14)else echo/%%a -)>>"ant1.properties" -move ant1.properties ant.properties - -for /f "delims=" %%a in (ant.properties) do set num=%%a&call :lis -move ant1.properties ant.properties - -::Android ant build(release,API level:14). -call ant release -set result14=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto API_15 -if %result14% NEQ 0 goto API_15 -cd bin -ren TestCpp-release.apk TestCpp-release-14.apk -cd .. - -:API_15 -::Change API level.(API level:15) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-14" (echo/target=android-15)else echo/%%a -)>>"ant1.properties" -move ant1.properties ant.properties - -for /f "delims=" %%a in (ant.properties) do set num=%%a&call :lis -move ant1.properties ant.properties - -::Android ant build(release,API level:15). -call ant release -set result15=%ERRORLEVEL% -if "%_PROJECTNAME%" NEQ "TestCpp" goto NEXTPROJ -if %result15% NEQ 0 goto NEXTPROJ -cd bin -ren TestCpp-release.apk TestCpp-release-15.apk -cd .. - -:NEXTPROJ -::After all test versions completed,changed current API level to the original.(API level:8) -for /f "delims=" %%a in (ant.properties) do ( -if "%%a"=="target=android-15" (echo/target=android-8)else echo/%%a -)>>"ant1.properties" -move ant1.properties ant.properties - -for /f "delims=" %%a in (ant.properties) do set num=%%a&call :lis -move ant1.properties ant.properties - -::Calculate the errorlevel and change build target. -cd %_ROOT_% -IF "%_PROJECTNAME%"=="TestCpp" set /a testresult1=(result14+result15) && set _PROJECTNAME=HelloCpp&& goto project -IF "%_PROJECTNAME%"=="HelloCpp" set /a testresult2=(result14+result15) && set _LANGUAGE_=Lua&& set _PROJECTNAME=HelloLua&& goto project -IF "%_PROJECTNAME%"=="HelloLua" set /a testresult3=(result14+result15) -set /a testresult=(testresult1+testresult2+testresult3) -IF %testresult% NEQ 0 goto error - -goto success - -:lis -if "%num%"=="" goto :eof -if "%num:~-1%"==" " set num=%num:~0,-1%&goto lis -echo %num%>>ant1.properties -goto :eof - -:error -echo Compile Error! -echo %Compile_Result% -::git checkout -f -::git clean -df -x -exit 1 - -:success -echo Compile Success! -echo %Compile_Result% -::git checkout -f -::git clean -df -x -exit 0 - -::End. \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/android/rootconfig.sh b/tools/jenkins-scripts/windows/android/rootconfig.sh deleted file mode 100755 index c69604e104..0000000000 --- a/tools/jenkins-scripts/windows/android/rootconfig.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -#This script is used to modify parameters in profile,so it will be convenient for ant to build different project. - -#Change the path expression of current path to cygwin path. -#NDK_ROOT=$($CYGWIN/bin/cygpath.exe $ANDROID_NDK) -#echo $NDK_ROOT -CUR=$(pwd) -#tmp=$(pwd) -#COCOS2DX=$($CYGWIN/bin/cygpath.exe $tmp) -#echo $COCOS2DX - -#var1=NDK_ROOT_LOCAL= -#_NDK_ROOT=${var1}${NDK_ROOT} - -#var2=COCOS2DX_ROOT_LOCAL= -#_COCOS2DX_ROOT=${var2}${COCOS2DX} -#echo $_NDK_ROOT -#echo $_COCOS2DX_ROOT - -#Modify the configuration files -#sed -i '3,4d' $CUR/build_native.sh -sed -i '13d' $CUR/project.properties -#sed -i "3 i\\$_NDK_ROOT" $CUR/build_native.sh -#sed -i "4 i\\$_COCOS2DX_ROOT" $CUR/build_native.sh - -#Modify the project name -if [ $1 = TestCpp ]; then - sed -i '2d' $CUR/build.xml - sed -i '2 i\' $CUR/build.xml -elif [ $1 = HelloCpp ]; then - sed -i '2d' $CUR/build.xml - sed -i '2 i\' $CUR/build.xml -elif [ $1 = HelloLua ]; then - sed -i '2d' $CUR/build.xml - sed -i '2 i\' $CUR/build.xml -elif [ $1 = TestLua ]; then - sed -i '2d' $CUR/build.xml - sed -i '2 i\' $CUR/build.xml -elif [ $1 = TestJavascript ]; then - sed -i '2d' $CUR/build.xml - sed -i '2 i\' $CUR/build.xml -elif [ $1 = SimpleGame ]; then - sed -i '2d' $CUR/build.xml - sed -i '2 i\' $CUR/build.xml -fi \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/android/test-android-2.2-3.2-debug.bat b/tools/jenkins-scripts/windows/android/test-android-2.2-3.2-debug.bat deleted file mode 100644 index 6b0c5bf4e4..0000000000 --- a/tools/jenkins-scripts/windows/android/test-android-2.2-3.2-debug.bat +++ /dev/null @@ -1,73 +0,0 @@ -::This script is used to accomplish a android automated compiler. -::You should make sure have accomplished the environment setting. -::You should add %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools to the environment variable of Path. - -::Copy monkeyrunner python script to android sdk tools directory. -cd ..\.. -copy %cd%\Monkeyrunner_TestCpp.py %ANDROID_HOME%\tools -copy %cd%\ReportManager.py %ANDROID_HOME%\tools - -cd ..\.. -set PROJECT_HOME=%cd% -cd samples\Cpp\TestCpp\proj.android\bin - -::Copy test apk to android sdk tools directory. -copy %cd%\TestCpp-debug-8.apk %ANDROID_HOME%\tools -copy %cd%\TestCpp-debug-10.apk %ANDROID_HOME%\tools -copy %cd%\TestCpp-debug-11.apk %ANDROID_HOME%\tools -copy %cd%\TestCpp-debug-12.apk %ANDROID_HOME%\tools -copy %cd%\TestCpp-debug-13.apk %ANDROID_HOME%\tools - -::Enter android sdk tools directory. -set ANDROID_ROOT=%ANDROID_HOME:~0,2% -%ANDROID_ROOT% -cd %ANDROID_HOME%\tools - -::If monkeyrunner test failed,it automatically exit and make ERRORLEVEL nonzero. - -::Running monkeyrunner test(debug,API level:8). -ren TestCpp-debug-8.apk TestCpp-debug.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-debug.apk - -::Running monkeyrunner test(debug,API level:10). -ren TestCpp-debug-10.apk TestCpp-debug.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-debug.apk - -::Running monkeyrunner test(debug,API level:11). -ren TestCpp-debug-11.apk TestCpp-debug.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-debug.apk - -::Running monkeyrunner test(debug,API level:12). -ren TestCpp-debug-12.apk TestCpp-debug.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-debug.apk - -::Running monkeyrunner test(debug,API level:13). -ren TestCpp-debug-13.apk TestCpp-debug.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-debug.apk - -rm Monkeyrunner_TestCpp.py -rm ReportManager.py - -::Monkeyrunner success! -echo Monkeyrunner Test Success! - -::Clean project files. -set PROJECT_ROOT=%PROJECT_HOME:~0,2% -%PROJECT_ROOT% -cd %PROJECT_HOME% - -git checkout -f -git clean -df -x -exit 0 - -::End \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/android/test-android-2.2-3.2-release.bat b/tools/jenkins-scripts/windows/android/test-android-2.2-3.2-release.bat deleted file mode 100644 index d583f491a4..0000000000 --- a/tools/jenkins-scripts/windows/android/test-android-2.2-3.2-release.bat +++ /dev/null @@ -1,73 +0,0 @@ -::This script is used to accomplish a android automated compiler. -::You should make sure have accomplished the environment setting. -::You should add %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools to the environment variable of Path. - -::Copy monkeyrunner python script to android sdk tools directory. -cd ..\.. -copy %cd%\Monkeyrunner_TestCpp.py %ANDROID_HOME%\tools -copy %cd%\ReportManager.py %ANDROID_HOME%\tools - -cd ..\.. -set PROJECT_HOME=%cd% -cd samples\Cpp\TestCpp\proj.android\bin - -::Copy test apk to android sdk tools directory. -copy %cd%\TestCpp-release-8.apk %ANDROID_HOME%\tools -copy %cd%\TestCpp-release-10.apk %ANDROID_HOME%\tools -copy %cd%\TestCpp-release-11.apk %ANDROID_HOME%\tools -copy %cd%\TestCpp-release-12.apk %ANDROID_HOME%\tools -copy %cd%\TestCpp-release-13.apk %ANDROID_HOME%\tools - -::Enter android sdk tools directory. -set ANDROID_ROOT=%ANDROID_HOME:~0,2% -%ANDROID_ROOT% -cd %ANDROID_HOME%\tools - -::If monkeyrunner test failed,it automatically exit and make ERRORLEVEL nonzero. - -::Running monkeyrunner test(release,API level:8). -ren TestCpp-release-8.apk TestCpp-release.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-release.apk - -::Running monkeyrunner test(release,API level:10). -ren TestCpp-release-10.apk TestCpp-release.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-release.apk - -::Running monkeyrunner test(release,API level:11). -ren TestCpp-release-11.apk TestCpp-release.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-release.apk - -::Running monkeyrunner test(release,API level:12). -ren TestCpp-release-12.apk TestCpp-release.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-release.apk - -::Running monkeyrunner test(release,API level:13). -ren TestCpp-release-13.apk TestCpp-release.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-release.apk - -rm Monkeyrunner_TestCpp.py -rm ReportManager.py - -::Monkeyrunner success! -echo Monkeyrunner Test Success! - -::Clean project files. -set PROJECT_ROOT=%PROJECT_HOME:~0,2% -%PROJECT_ROOT% -cd %PROJECT_HOME% - -git checkout -f -git clean -df -x -exit 0 - -::End \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/android/test-android-4.x-debug.bat b/tools/jenkins-scripts/windows/android/test-android-4.x-debug.bat deleted file mode 100644 index f668e891d5..0000000000 --- a/tools/jenkins-scripts/windows/android/test-android-4.x-debug.bat +++ /dev/null @@ -1,52 +0,0 @@ -::This script is used to accomplish a android automated compiler. -::You should make sure have accomplished the environment setting. -::You should add %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools to the environment variable of Path. - -::Copy monkeyrunner python script to android sdk tools directory. -cd ..\.. -copy %cd%\Monkeyrunner_TestCpp.py %ANDROID_HOME%\tools -copy %cd%\ReportManager.py %ANDROID_HOME%\tools - -cd ..\.. -set PROJECT_HOME=%cd% -cd samples\Cpp\TestCpp\proj.android\bin - -::Copy test apk to android sdk tools directory. -copy %cd%\TestCpp-debug-14.apk %ANDROID_HOME%\tools -copy %cd%\TestCpp-debug-15.apk %ANDROID_HOME%\tools - -::Enter android sdk tools directory. -set ANDROID_ROOT=%ANDROID_HOME:~0,2% -%ANDROID_ROOT% -cd %ANDROID_HOME%\tools - -::If monkeyrunner test failed,it automatically exit and make ERRORLEVEL nonzero. - -::Running monkeyrunner test(debug,API level:14). -ren TestCpp-debug-14.apk TestCpp-debug.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-debug.apk - -::Running monkeyrunner test(debug,API level:15). -ren TestCpp-debug-15.apk TestCpp-debug.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-debug.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-debug.apk - -rm Monkeyrunner_TestCpp.py -rm ReportManager.py - -::Monkeyrunner success! -echo Monkeyrunner Test Success! - -::Clean project files. -set PROJECT_ROOT=%PROJECT_HOME:~0,2% -%PROJECT_ROOT% -cd %PROJECT_HOME% - -git checkout -f -git clean -df -x -exit 0 - -::End \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/android/test-android-4.x-release.bat b/tools/jenkins-scripts/windows/android/test-android-4.x-release.bat deleted file mode 100644 index c93c6d30b5..0000000000 --- a/tools/jenkins-scripts/windows/android/test-android-4.x-release.bat +++ /dev/null @@ -1,52 +0,0 @@ -::This script is used to accomplish a android automated compiler. -::You should make sure have accomplished the environment setting. -::You should add %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools to the environment variable of Path. - -::Copy monkeyrunner python script to android sdk tools directory. -cd ..\.. -copy %cd%\Monkeyrunner_TestCpp.py %ANDROID_HOME%\tools -copy %cd%\ReportManager.py %ANDROID_HOME%\tools - -cd ..\.. -set PROJECT_HOME=%cd% -cd samples\Cpp\TestCpp\proj.android\bin - -::Copy test apk to android sdk tools directory. -copy %cd%\TestCpp-release-14.apk %ANDROID_HOME%\tools -copy %cd%\TestCpp-release-15.apk %ANDROID_HOME%\tools - -::Enter android sdk tools directory. -set ANDROID_ROOT=%ANDROID_HOME:~0,2% -%ANDROID_ROOT% -cd %ANDROID_HOME%\tools - -::If monkeyrunner test failed,it automatically exit and make ERRORLEVEL nonzero. - -::Running monkeyrunner test(release,API level:14). -ren TestCpp-release-14.apk TestCpp-release.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-release.apk - -::Running monkeyrunner test(release,API level:15). -ren TestCpp-release-15.apk TestCpp-release.apk -call monkeyrunner Monkeyrunner_TestCpp.py TestCpp-release.apk -if %ERRORLEVEL% NEQ 0 call python ReportManager.py && exit 1 -rm TestCpp-release.apk - -rm Monkeyrunner_TestCpp.py -rm ReportManager.py - -::Monkeyrunner success! -echo Monkeyrunner Test Success! - -::Clean project files. -set PROJECT_ROOT=%PROJECT_HOME:~0,2% -%PROJECT_ROOT% -cd %PROJECT_HOME% - -git checkout -f -git clean -df -x -exit 0 - -::End \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Action0/ObjectRepository.bdb.REMOVED.git-id b/tools/jenkins-scripts/windows/win32/qtp_win32/Action0/ObjectRepository.bdb.REMOVED.git-id deleted file mode 100644 index 60a18c6b19..0000000000 --- a/tools/jenkins-scripts/windows/win32/qtp_win32/Action0/ObjectRepository.bdb.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -7cda137d3b8d286470f2b504faaa77d981947cbf \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Action0/Resource.mtr b/tools/jenkins-scripts/windows/win32/qtp_win32/Action0/Resource.mtr deleted file mode 100644 index cb618ad251..0000000000 Binary files a/tools/jenkins-scripts/windows/win32/qtp_win32/Action0/Resource.mtr and /dev/null differ diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Action0/Script.mts b/tools/jenkins-scripts/windows/win32/qtp_win32/Action0/Script.mts deleted file mode 100644 index 90fb8f6028..0000000000 --- a/tools/jenkins-scripts/windows/win32/qtp_win32/Action0/Script.mts +++ /dev/null @@ -1 +0,0 @@ -RunAction "Action1", oneIteration \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Action1/ObjectRepository.bdb.REMOVED.git-id b/tools/jenkins-scripts/windows/win32/qtp_win32/Action1/ObjectRepository.bdb.REMOVED.git-id deleted file mode 100644 index 5e94460c25..0000000000 --- a/tools/jenkins-scripts/windows/win32/qtp_win32/Action1/ObjectRepository.bdb.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -cce3386fa528b6991eb274e15c5ea60da91cb073 \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Action1/Resource.mtr b/tools/jenkins-scripts/windows/win32/qtp_win32/Action1/Resource.mtr deleted file mode 100644 index 6e81cf2109..0000000000 Binary files a/tools/jenkins-scripts/windows/win32/qtp_win32/Action1/Resource.mtr and /dev/null differ diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Action1/Script.mts b/tools/jenkins-scripts/windows/win32/qtp_win32/Action1/Script.mts deleted file mode 100644 index 69244b19c6..0000000000 --- a/tools/jenkins-scripts/windows/win32/qtp_win32/Action1/Script.mts +++ /dev/null @@ -1,716 +0,0 @@ -Dim Milliseconds -DefaultTimeout = Setting("DefaultTimeout") - -If DefaultTimeout > 10000 Then - Milliseconds = 10000 - Setting("DefaultTimeout") = Milliseconds -End If - -Err.Clear -On Error Resume Next -call CaseFunctionName - -If Err.Number <> 0 Then - - If Dialog("TestCpp.exe").Exist(3) Then - Dialog("TestCpp.exe").Activate - Dialog("TestCpp.exe").Move 872,177 - Dialog("TestCpp.exe").WinObject("DirectUIHWND").Click 21,235 - Wait 1 - End If - - If DIalog("Microsoft Visual C++ Runtime").Exist(3) Then - Dialog("Microsoft Visual C++ Runtime").Activate - Dialog("Microsoft Visual C++ Runtime").Move 872,177 - Wait 1 - End If - - WriteLog Err.Number - WriteLog Err.Description - WriteLog Err.Source - - Dim FileName ,TimeNow, ResPath - ResPath = Environment.Value("TestDir") - ResPath = ResPath & "\" - TestNameNow=environment.Value("TestName") - FileName = ResPath & ""&TestNameNow & ".png" - - desktop.CaptureBitmap filename,True - Systemutil.closedescendentprocesses - - If Dialog("TestCpp.exe").Exist(3) Then - Dialog("TestCpp.exe").WinObject("关闭程序").Click - End If - - If Dialog("Microsoft Visual C++ Runtime").Exist(3) Then - Dialog("Microsoft Visual C++ Runtime").WinButton("中止(A)").Click - End If - -End If -Err.Clear -On Error goto 0 - -Function common_test(a,b,c) - For i = a To b - Window("Cocos2dxWin32").Click 338,291 - Wait c - Next -End Function - -Function random_click(a,b,c) - Dim touch_x,touch_y - Randomize - For Response = a To b - touch_x = Int((400 * Rnd + 0)) - touch_y = Int((250 * Rnd + 0)) - Window("Cocos2dxWin32").Click touch_x,touch_y - Wait c - Next -End Function - -Function random_drag(a,b,c) - Dim drag_x,drag_y,drop_x,drop_y - Randomize - For Response = a To b - drag_x = Int((400 * Rnd + 0)) - drag_y = Int((250 * Rnd + 0)) - drop_x = Int((400 * Rnd + 0)) - drop_y = Int((250 * Rnd + 0)) - Window("Cocos2dxWin32").Drag drag_x,drag_y - Window("Cocos2dxWin32").Drop drop_x,drop_y - Wait c - Next -End Function - -Function CaseFunctionName() - 'SystemUtil.BlockInput - Window("Cocos2dxWin32").Activate - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'ActionsTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 241,43 - Wait 2 - - Call common_test(1,27,1) - - Window("Cocos2dxWin32").Click 338,291 - Wait 5 - Window("Cocos2dxWin32").Click 338,291 - Wait 2 - - Call common_test(1,5,1) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - Wait 2 - - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'TransitionsTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 236,77 - Wait 2 - - Call common_test(1,26,1) - Wait 1 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - Wait 2 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'ActionsProgressTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 287,113 - Wait 2 - - Call common_test(1,7,2) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - Wait 2 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'EffectsTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 236,163 - Wait 3 - - Call common_test(1,21,4) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - Wait 2 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'ClickAndMoveTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 228,199 - Wait 3 - - Call random_click(1,10,2) - - Call random_click(1,100,0) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - Wait 2 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'RotateWorldTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 237,235 - Wait 3.5 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - Wait 2 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'ParticleTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 236,276 - Wait 3 - - Call common_test(1,42,2) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - Wait 2 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'ActionEaseTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Drag 363,307 - Window("Cocos2dxWin32").Drop 363,10 - Wait 1 - Window("Cocos2dxWin32").Click 237,19 - Wait 2 - - Call common_test(1,13,2) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - Wait 2 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'MotionStreakTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 240,61 - Wait 2 - - Window("Cocos2dxWin32").Click 230,239 - Window("Cocos2dxWin32").Click 338,291 - - Call random_drag(1,10,0) - Window("Cocos2dxWin32").Click 230,239 - Call random_drag(1,10,0) - - Window("Cocos2dxWin32").Click 338,291 - Wait 2 - - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'DrawPrimitivesTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 235,101 - Wait 1 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'NodeTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 237,139 - Wait 1 - - Call common_test(1,13,1) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'TouchesTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 238,183 - Window("Cocos2dxWin32").Drag 236,221 - Window("Cocos2dxWin32").Drop 175,226 - - Wait 5 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'MenuTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 234,220 - Window("Cocos2dxWin32").Click 238,63 - Window("Cocos2dxWin32").Click 158,132 - - Window("Cocos2dxWin32").Click 238,155 - Window("Cocos2dxWin32").Click 236,180 - Window("Cocos2dxWin32").Click 158,188 - Window("Cocos2dxWin32").Click 313,184 - Window("Cocos2dxWin32").Click 190,217 - Window("Cocos2dxWin32").Click 235,216 - Window("Cocos2dxWin32").Click 205,144 - Window("Cocos2dxWin32").Click 218,143 - Window("Cocos2dxWin32").Click 237,247 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'ActionManagerTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 234,261 - - Call common_test(1,4,3) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'LayerTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 240,302 - - Call random_drag(1,10,0) - Window("Cocos2dxWin32").Click 338,291 - Wait 2 - Window("Cocos2dxWin32").Click 338,291 - Wait 2 - Window("Cocos2dxWin32").Click 338,291 - Call random_drag(1,10,0) - Window("Cocos2dxWin32").Click 338,291 - Wait 1 - Window("Cocos2dxWin32").Click 242,164 - Wait 1 - Window("Cocos2dxWin32").Click 338,291 - Wait 1 - Window("Cocos2dxWin32").Click 254,163 - Wait 1 - Window("Cocos2dxWin32").Click 338,291 - Wait 1 - Window("Cocos2dxWin32").Click 231,164 - Wait 1 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'SceneTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Drag 370,306 - Window("Cocos2dxWin32").Drop 370,-20 - Wait 1 - Window("Cocos2dxWin32").Click 234,17 - Wait 1 - Window("Cocos2dxWin32").Click 230,111 - Window("Cocos2dxWin32").Click 230,111 - Window("Cocos2dxWin32").Click 230,111 - Window("Cocos2dxWin32").Click 233,163 - Window("Cocos2dxWin32").Click 226,218 - Window("Cocos2dxWin32").Click 226,218 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'ParallaxTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 232,55 - Wait 5 - Window("Cocos2dxWin32").Click 338,291 - - Call random_drag(1,10,0) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'TileMapTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 233,99 - Wait 2 - Window("Cocos2dxWin32").Click 338,291 - Wait 2 - - Call random_drag(1,10,0) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'IntervalTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 235,139 - Wait 3 - Window("Cocos2dxWin32").Click 224,48 - Wait 1 - Window("Cocos2dxWin32").Click 231,52 - Window("Cocos2dxWin32").Click 228,56 - Window("Cocos2dxWin32").Click 228,56 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'ChipmunkAccelTouchTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 235,178 - - Call random_click(1,20,2) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'LabelTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 239,216 - Wait 3 - Call common_test(1,25,0.5) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'TextInputTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 236,255 - - Window("Cocos2dxWin32").Click 238,161 - Const constring = "0123456789abcdefgchijklmnopqrstuvwxyz" - Dim TextInput_i,TextInput_j,randstring - Randomize - For TextInput_i=1 To 8 - randstring = randstring & Mid(constring, Int(Len(constring)*Rnd)+1, 1) - Next - Window("Cocos2dxWin32").Type randstring - Window("Cocos2dxWin32").Click 338,291 - Window("Cocos2dxWin32").Click 238,161 - Randomize - For TextInput_j=1 To 8 - randstring = randstring & Mid(constring, Int(Len(constring)*Rnd)+1, 1) - Next - Window("Cocos2dxWin32").Type randstring - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'SpriteTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 238,294 - - Call random_click(1,15,0.2) - Window("Cocos2dxWin32").Click 338,291 - Call random_click(1,15,0.2) - Window("Cocos2dxWin32").Click 338,291 - Call common_test(1,108,0.5) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'SchdulerTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Drag 359,309 - Window("Cocos2dxWin32").Drop 359,-11 - Wait 1 - 'Schedule with delay of 3sec,repeat 4 - Window("Cocos2dxWin32").Click 236,15 - Window("Cocos2dxWin32").Click 338,291 - 'Scheduler timeScale Test - Window("Cocos2dxWin32").Drag 260,212 - Window("Cocos2dxWin32").Drop 301,212 - Wait 1 - Window("Cocos2dxWin32").Drag 301,212 - Window("Cocos2dxWin32").Drop 209,214 - Wait 1 - Window("Cocos2dxWin32").Drag 209,214 - Window("Cocos2dxWin32").Drop 100,208 - Wait 2 - Window("Cocos2dxWin32").Click 338,291 - 'Two custom schedulers - Window("Cocos2dxWin32").Drag 126,16 - Window("Cocos2dxWin32").Drop 81,22 - Wait 1 - Window("Cocos2dxWin32").Drag 361,19 - Window("Cocos2dxWin32").Drop 422,22 - Wait 3 - Window("Cocos2dxWin32").Click 338,291 - 'Self -remove an scheduler - Window("Cocos2dxWin32").Click 338,291 - 'Pause/Resume - Window("Cocos2dxWin32").Click 338,291 - 'Pause/Resume - Wait 3 - Window("Cocos2dxWin32").Click 338,291 - 'Unschedule All selectors - Window("Cocos2dxWin32").Click 338,291 - 'Unschedule All selectors(HARD) - Wait 2 - Window("Cocos2dxWin32").Click 338,291 - 'Unschedule All selectors - Wait 4 - Window("Cocos2dxWin32").Click 338,291 - 'Schedule from Schedule - Window("Cocos2dxWin32").Click 338,291 - 'Schedule update with priority - Window("Cocos2dxWin32").Click 338,291 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'RenderTextureTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 240,59 - 'Save Image - - Call random_drag(1,10,0) - Window("Cocos2dxWin32").Click 388,17 - Window("Cocos2dxWin32").Click 398,41 - Wait 1 - Window("Cocos2dxWin32").Click 338,291 - 'Testing issue #937 - Window("Cocos2dxWin32").Click 338,291 - 'Testing Z Buffer in Render Texture - Call random_click(1,10,0) - Window("Cocos2dxWin32").Click 338,291 - 'Testing depthStencil attachment - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'Texture2DTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 234,97 - Call common_test(1,35,0.5) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'Box2dTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 235,134 - Call random_click(1,30,2) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'Box2dTestBed - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 236,176 - Call common_test(1,35,2) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'EffectAdvancedTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 237,217 - Call common_test(1,5,1) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'AccelerometerTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 244,255 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'KeypadTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 240,298 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'CocosDenshionTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Drag 377,314 - Window("Cocos2dxWin32").Drop 377,0 - Wait 1 - Window("Cocos2dxWin32").Click 243,20 - - Window("Cocos2dxWin32").Click 248,38 - Wait 1 - Window("Cocos2dxWin32").Click 248,78 - Wait 1 - Window("Cocos2dxWin32").Click 247,121 - Wait 1 - Window("Cocos2dxWin32").Click 246,158 - Wait 1 - Window("Cocos2dxWin32").Click 251,202 - Wait 1 - Window("Cocos2dxWin32").Click 246,238 - Wait 1 - Window("Cocos2dxWin32").Click 241,282 - Wait 1 - Window("Cocos2dxWin32").Drag 427,260 - Window("Cocos2dxWin32").Drop 427,6 - Window("Cocos2dxWin32").Click 232,18 - Wait 1 - Window("Cocos2dxWin32").Click 245,56 - Wait 1 - Window("Cocos2dxWin32").Click 242,109 - Wait 1 - Window("Cocos2dxWin32").Click 242,144 - Wait 1 - Window("Cocos2dxWin32").Click 243,189 - Wait 1 - Window("Cocos2dxWin32").Click 243,230 - Wait 1 - Window("Cocos2dxWin32").Click 254,275 - Wait 1 - Window("Cocos2dxWin32").Click 248,304 - Wait 1 - Window("Cocos2dxWin32").Drag 412,272 - Window("Cocos2dxWin32").Drop 412,-13 - Window("Cocos2dxWin32").Click 235,124 - Wait 1 - Window("Cocos2dxWin32").Click 238,158 - Wait 1 - Window("Cocos2dxWin32").Click 229,200 - Wait 1 - Window("Cocos2dxWin32").Click 239,243 - Wait 1 - Window("Cocos2dxWin32").Click 246,277 - Wait 1 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'PerformanceTest - ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 237,64 - Window("Cocos2dxWin32").Click 238,37 - - 'PerformanceNodeChildrenTest - Window("Cocos2dxWin32").Click 238,38 - Dim Performance_i - For Performance_i = 1 To 4 - Window("Cocos2dxWin32").Click 273,145 - Window("Cocos2dxWin32").Click 338,291 - Wait 1 - Next - 'Back - Window("Cocos2dxWin32").Click 427,290 - - 'PerformanceParticeTest - Window("Cocos2dxWin32").Click 237,78 - - For Performance_j = 1 To 4 - Window("Cocos2dxWin32").Click 273,145 - Window("Cocos2dxWin32").Click 338,291 - Wait 1 - Next - 'Back - Window("Cocos2dxWin32").Click 427,290 - 'PerformanceSpriteTest - Window("Cocos2dxWin32").Click 233,120 - Dim Performance_k - For Performance_k = 1 To 5 - Window("Cocos2dxWin32").Click 271,64 - Window("Cocos2dxWin32").Click 338,291 - Wait 1 - Next - 'Back - Window("Cocos2dxWin32").Click 427,290 - - 'PerformanceTextureTest - Window("Cocos2dxWin32").Click 229,159 - 'Back - Window("Cocos2dxWin32").Click 427,290 - - 'PerformanceTouchesTest - Window("Cocos2dxWin32").Click 234,200 - Call random_drag(1,10,0) - Window("Cocos2dxWin32").Click 338,291 - Call random_drag(1,10,0) - 'Back - Window("Cocos2dxWin32").Click 427,290 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'ZwoptexTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 233,104 - Wait 1 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'CurlTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 239,141 - Window("Cocos2dxWin32").Click 242,160 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'UserDefaultTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 238,184 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'BugsTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 240,222 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'FontTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 237,261 - Call common_test(1,4,0.5) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'CurrentLanguageTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 244,301 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'TextureCacheTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Drag 385,309 - Window("Cocos2dxWin32").Drop 385,33 - Wait 1 - Window("Cocos2dxWin32").Click 241,159 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'ExtensionsTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 241,197 - Wait 1 - 'NotificationCenterTest - Window("Cocos2dxWin32").Click 235,41 - Window("Cocos2dxWin32").Click 339,166 - Window("Cocos2dxWin32").Click 339,166 - Window("Cocos2dxWin32").Click 113,189 - 'Back - Window("Cocos2dxWin32").Click 429,289 - Wait 1 - 'CCControlButtonTest - Window("Cocos2dxWin32").Click 238,79 - Window("Cocos2dxWin32").Drag 118,181 - Window("Cocos2dxWin32").Drop 374,189 - Wait 1 - Window("Cocos2dxWin32").Drag 367,179 - Window("Cocos2dxWin32").Drop 76,183 - Wait 1 - 'Back - Window("Cocos2dxWin32").Click 422,293 - 'CocosBuilderTest - Window("Cocos2dxWin32").Click 237,119 - 'Menus_Items - Window("Cocos2dxWin32").Click 137,158 - Window("Cocos2dxWin32").Click 242,157 - Window("Cocos2dxWin32").Click 113,147 - Window("Cocos2dxWin32").Click 23,20 - 'Button - Window("Cocos2dxWin32").Click 132,209 - Window("Cocos2dxWin32").Click 240,149 - Window("Cocos2dxWin32").Drag 255,150 - Window("Cocos2dxWin32").Drop 259,233 - Window("Cocos2dxWin32").Click 23,20 - 'Particle Systems - Window("Cocos2dxWin32").Click 131,261 - Window("Cocos2dxWin32").Click 23,20 - 'Sprites_9 Slice - Window("Cocos2dxWin32").Click 341,161 - Window("Cocos2dxWin32").Click 23,20 - 'Labels - Window("Cocos2dxWin32").Click 345,210 - Window("Cocos2dxWin32").Click 23,20 - 'ScrollViewTest - Window("Cocos2dxWin32").Click 347,259 - Call random_drag(1,10,0) - Window("Cocos2dxWin32").Click 23,20 - - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'SharderTest - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 242,239 - Dim Sharder_i - Call common_test(1,6,0.5) - Window("Cocos2dxWin32").Drag 197,235 - Window("Cocos2dxWin32").Drop 358,236 - Wait 1 - Window("Cocos2dxWin32").Drag 358,236 - Window("Cocos2dxWin32").Drop 78,221 - - Window("Cocos2dxWin32").Click 338,291 - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'MutiTouchTest - ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 240,279 - Call random_drag(1,5,0) - 'MainMenu - Window("Cocos2dxWin32").Click 441,296 - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - 'Quit - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - Window("Cocos2dxWin32").Click 461,22 - 'SystemUtil.UnblockInput -End function diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Default.xls b/tools/jenkins-scripts/windows/win32/qtp_win32/Default.xls deleted file mode 100644 index 3320733acf..0000000000 Binary files a/tools/jenkins-scripts/windows/win32/qtp_win32/Default.xls and /dev/null differ diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Error_Sub.vbs b/tools/jenkins-scripts/windows/win32/qtp_win32/Error_Sub.vbs deleted file mode 100644 index a3921e9364..0000000000 Binary files a/tools/jenkins-scripts/windows/win32/qtp_win32/Error_Sub.vbs and /dev/null differ diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Error_appcrash.qrs b/tools/jenkins-scripts/windows/win32/qtp_win32/Error_appcrash.qrs deleted file mode 100644 index 4f6c0d3259..0000000000 Binary files a/tools/jenkins-scripts/windows/win32/qtp_win32/Error_appcrash.qrs and /dev/null differ diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Parameters.mtr b/tools/jenkins-scripts/windows/win32/qtp_win32/Parameters.mtr deleted file mode 100644 index a231386bc8..0000000000 Binary files a/tools/jenkins-scripts/windows/win32/qtp_win32/Parameters.mtr and /dev/null differ diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/Test.tsp b/tools/jenkins-scripts/windows/win32/qtp_win32/Test.tsp deleted file mode 100644 index 08429fa187..0000000000 Binary files a/tools/jenkins-scripts/windows/win32/qtp_win32/Test.tsp and /dev/null differ diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/TestCpp_Appcrash.tsr.REMOVED.git-id b/tools/jenkins-scripts/windows/win32/qtp_win32/TestCpp_Appcrash.tsr.REMOVED.git-id deleted file mode 100644 index 9d2b35038c..0000000000 --- a/tools/jenkins-scripts/windows/win32/qtp_win32/TestCpp_Appcrash.tsr.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -1bbfcd16748887dfb66d264a6327737e2ed5a3b1 \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/default.cfg b/tools/jenkins-scripts/windows/win32/qtp_win32/default.cfg deleted file mode 100644 index fd60da2ba3..0000000000 --- a/tools/jenkins-scripts/windows/win32/qtp_win32/default.cfg +++ /dev/null @@ -1,89 +0,0 @@ -[General] -XlBridgeTimeout=120 -ContinueOnError=0 -AutomaticTransactions=0 -AutomaticTransactionsPerFunc=0 -automatic_nested_transactions=1 - -[ThinkTime] -Options=RECORDED -Factor=1.000000 -LimitFlag=0 -Limit=10 -ThinkTimeRandomLow=50 -ThinkTimeRandomHigh=150 - -[Log] -LogOptions=LogExtended -MsgClassData=0 -MsgClassParameters=0 -MsgClassFull=0 - -[RtsNetwork] -LoadImages=1 -LoadActiveX=1 -LoadJava=0 -LoadScripts=1 -NavigationTimeout=60000 -ObjectTimeout=3000 - -[RtsPerformance] -MinThinkTime=3500 -MaxThinkTime=3500 -AutoThinkTime=1 -EnableChecks=0 -ExcludeThinkTime=0 -FitThinkTime=0 - -[RtsUserInfo] -UserName= -Password=503ee35ae - -[RtsGeneral] -EnableAutoTrans=1 -FailOnHttpErrors=0 -RunInSeparateThread=0 - -[WEB] -HttpVer=1.1 -UseCustomAgent=1 -SimulateCache=1 -TurboLoadTechnology=0 -WinInetReplay=0 -EnableModemSpeed=0 -ModemSpeed=14400 -KeepAlive=Yes -SearchForImages=1 -CacheSize=20000 -MaxConnections=4 -AutomaticThinkTime=0 -MaxAutoThinkTime=0 -MinAutoThinkTime=0 -ConnectTimeout=120 -ReceiveTimeout=120 -ResolveTimeout=120 -EnableChecks=1 -AnalogMode=1 -ResetContext=1 -ProxyUseBrowser=1 -ProxyUseProxy=0 -ProxyHTTPHost= -ProxyHTTPSHost= -ProxyHTTPPort=0 -ProxyHTTPSPort=0 -ProxyUseSame=0 -ProxyNoLocal=0 -ProxyBypass= -ProxyUserName= -ProxyPassword= -UseMshtml=1 -Retry401ThinkTime="0" -CustomUserAgent=Mozilla/4.0 (compatible; MSIE 5.5; Windows NT) -UseBrowserEmulation=0 - -[RtsConfigfuration] -AutMode=0 -ScalableMode=1 -EnableShowBrowser=0 -[Snapshots] -SnapshotOnErrorActive=0 diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/default.usp b/tools/jenkins-scripts/windows/win32/qtp_win32/default.usp deleted file mode 100644 index a03af91ba7..0000000000 --- a/tools/jenkins-scripts/windows/win32/qtp_win32/default.usp +++ /dev/null @@ -1,15 +0,0 @@ -[RunLogicInitRoot] -RunLogicActionType="VuserInit" - -[RunLogicEndRoot] -RunLogicActionType="VuserEnd" - -[RunLogicRunRoot] -RunLogicNumOfIterations="1" -MercIniTreeSons="Action0" -RunLogicActionOrder="Action0" - -[RunLogicRunRoot:Action0] -MercIniTreeFather="RunLogicRunRoot" -RunLogicObjectKind="Action" -RunLogicInterpreterType="ActiveScript" diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/lock.lck b/tools/jenkins-scripts/windows/win32/qtp_win32/lock.lck deleted file mode 100644 index 99cfda21cc..0000000000 Binary files a/tools/jenkins-scripts/windows/win32/qtp_win32/lock.lck and /dev/null differ diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/qtp_win32.usr b/tools/jenkins-scripts/windows/win32/qtp_win32/qtp_win32.usr deleted file mode 100644 index c1473d2703..0000000000 --- a/tools/jenkins-scripts/windows/win32/qtp_win32/qtp_win32.usr +++ /dev/null @@ -1,54 +0,0 @@ -[General] -Type=Tulip -RunType=ActiveScript -DefaultCfg=default.cfg -DefaultRunLogic=default.usp -ParamRightBrace=> -ParamLeftBrace=< -NewFunctionHeader=1 -MinorVersion=0 -MajorVersion=6 -DevelopTool=AQT - -[Actions] -Action0=Action0\Script.mts -Action1=Action1\Script.mts - -[VuserProfiles] -Profiles=Default Profile - -[CfgFiles] -Default Profile=default.cfg - -[RunLogicFiles] -Default Profile=default.usp - -[Rendezvous] - -[Transactions] - -[ActiveScript] -Lang=none - -[TulipInfo] -ProductName=QuickTest Professional -Version=10.00 - -[TulipAddins] -ActiveX= -Database= -Windows Applications= -TEA= -Web= -XML= - -[ExtraFiles] -Test.tsp= -Default.xls= -Parameters.mtr= -Action0\Script.mts= -Action0\Resource.mtr= -Action0\ObjectRepository.bdb= -Action1\Script.mts= -Action1\Resource.mtr= -Action1\ObjectRepository.bdb= diff --git a/tools/jenkins-scripts/windows/win32/qtp_win32/qtrunner.vbs b/tools/jenkins-scripts/windows/win32/qtp_win32/qtrunner.vbs deleted file mode 100644 index 17aadc0696..0000000000 Binary files a/tools/jenkins-scripts/windows/win32/qtp_win32/qtrunner.vbs and /dev/null differ diff --git a/tools/jenkins-scripts/windows/win32/test-win-vs2008-debug.bat b/tools/jenkins-scripts/windows/win32/test-win-vs2008-debug.bat deleted file mode 100644 index 46cb7a6fab..0000000000 --- a/tools/jenkins-scripts/windows/win32/test-win-vs2008-debug.bat +++ /dev/null @@ -1,32 +0,0 @@ -::This script is used to accomplish a vs project automated testing. -::You should make sure you have set %VS90COMNTOOLS%. - -::Set the directory of qtp project. -set qtpproj=%cd% -cd ..\..\..\..\ - -::Compile vs project. -"%VS90COMNTOOLS%..\IDE\devenv.com" "%cd%\cocos2d-win32.vc2008.sln" /Build "Debug|Win32" - -::Set the directory of test project's resources. -set CC_TEST_RES=%cd%\samples\TestCpp\Resources\*.* -set CC_HELLOWORLD_RES=%cd%\samples\HelloCpp\Resources\*.* -set CC_HELLOLUA_RES=%cd%\samples\HelloLua\Resources\*.* -set CC_TESTJS_RES=%cd%\samples\TestJavascript\Resources\*.* - -cd Debug.win32 - -::Copy resources to destination directory. -xcopy /E /Y /Q "%CC_TEST_RES%" . -xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . -xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . -xcopy /E /Y /Q "%CC_TESTJS_RES%" . - -::Run qtp test. -cd .. -cd %qtpproj%\qtp_win32 - -::Call automated test script. -cscript qtrunner.vbs - -pause \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/win32/test-win-vs2008_release.bat b/tools/jenkins-scripts/windows/win32/test-win-vs2008_release.bat deleted file mode 100644 index 95799657b0..0000000000 --- a/tools/jenkins-scripts/windows/win32/test-win-vs2008_release.bat +++ /dev/null @@ -1,32 +0,0 @@ -::This script is used to accomplish a vs project automated testing. -::You should make sure you have set %VS90COMNTOOLS%. - -::Set the directory of qtp project. -set qtpproj=%cd% -cd ..\..\..\..\ - -::Compile vs project. -"%VS90COMNTOOLS%..\IDE\devenv.com" "%cd%\cocos2d-win32.vc2008.sln" /Build "Release|Win32" - -::Set the directory of test project's resources. -set CC_TEST_RES=%cd%\samples\Cpp\TestCpp\Resources\*.* -set CC_HELLOWORLD_RES=%cd%\samples\Cpp\HelloCpp\Resources\*.* -set CC_HELLOLUA_RES=%cd%\samples\Lua\HelloLua\Resources\*.* -set CC_TESTJS_RES=%cd%\samples\Javascript\TestJavascript\Resources\*.* - -cd Debug.win32 - -::Copy resources to destination directory. -xcopy /E /Y /Q "%CC_TEST_RES%" . -xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . -xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . -xcopy /E /Y /Q "%CC_TESTJS_RES%" . - -::Run qtp test. -cd .. -cd %qtpproj%\qtp_win32 - -::Call automated test script. -cscript qtrunner.vbs - -pause \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/win32/test-win-vs2010_debug.bat b/tools/jenkins-scripts/windows/win32/test-win-vs2010_debug.bat deleted file mode 100644 index f38b2f5a8e..0000000000 --- a/tools/jenkins-scripts/windows/win32/test-win-vs2010_debug.bat +++ /dev/null @@ -1,32 +0,0 @@ -::This script is used to accomplish a vs project automated testing. -::You should make sure you have set %VS100COMNTOOLS%. - -::Set the directory of qtp project. -set qtpproj=%cd% -cd ..\..\..\..\ - -::Compile vs project. -"%VS100COMNTOOLS%..\IDE\devenv.com" "%cd%\cocos2d-win32.vc2010.sln" /Build "Debug|Win32" - -::Set the directory of test project's resources. -set CC_TEST_RES=%cd%\samples\TestCpp\Resources\*.* -set CC_HELLOWORLD_RES=%cd%\samples\HelloCpp\Resources\*.* -set CC_HELLOLUA_RES=%cd%\samples\HelloLua\Resources\*.* -set CC_TESTJS_RES=%cd%\samples\TestJavascript\Resources\*.* - -cd Debug.win32 - -::Copy resources to destination directory. -xcopy /E /Y /Q "%CC_TEST_RES%" . -xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . -xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . -xcopy /E /Y /Q "%CC_TESTJS_RES%" . - -::Run qtp test. -cd .. -cd %qtpproj%\qtp_win32 - -::Call automated test script. -cscript qtrunner.vbs - -pause \ No newline at end of file diff --git a/tools/jenkins-scripts/windows/win32/test-win-vs2010_release.bat b/tools/jenkins-scripts/windows/win32/test-win-vs2010_release.bat deleted file mode 100644 index 535cc923ac..0000000000 --- a/tools/jenkins-scripts/windows/win32/test-win-vs2010_release.bat +++ /dev/null @@ -1,32 +0,0 @@ -::This script is used to accomplish a vs project automated testing. -::You should make sure you have set %VS100COMNTOOLS%. - -::Set the directory of qtp project. -set qtpproj=%cd% -cd ..\..\..\..\ - -::Compile vs project. -"%VS100COMNTOOLS%..\IDE\devenv.com" "%cd%\cocos2d-win32.vc2010.sln" /Build "Release|Win32" - -::Set the directory of test project's resources. -set CC_TEST_RES=%cd%\samples\Cpp\TestCpp\Resources\*.* -set CC_HELLOWORLD_RES=%cd%\samples\Cpp\HelloCpp\Resources\*.* -set CC_HELLOLUA_RES=%cd%\samples\Lua\HelloLua\Resources\*.* -set CC_TESTJS_RES=%cd%\samples\Javascript\TestJavascript\Resources\*.* - -cd Release.win32 - -::Copy resources to destination directory. -xcopy /E /Y /Q "%CC_TEST_RES%" . -xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . -xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . -xcopy /E /Y /Q "%CC_TESTJS_RES%" . - -::Run qtp test. -cd .. -cd %qtpproj%\qtp_win32 - -::Call automated test script. -cscript qtrunner.vbs - -pause \ No newline at end of file diff --git a/tools/project-creator/README.md b/tools/project-creator/README.md new file mode 100644 index 0000000000..7417a3ecdb --- /dev/null +++ b/tools/project-creator/README.md @@ -0,0 +1,19 @@ +#Creating A Project + +First you need to install the Python environment. + +There are two ways to create a new cocos project. +Notice: The best project path is an English path without spaces. +##1.UI +* Windows: double click the "create_project.py" file +* Mac: use `./create_project.py` +* Linux: The Tkinter library was not installed automatically in Linux, therefore, in order to use the GUI to operate, you have to install Tkinter manually (see http://tkinter.unpythonic.net/wiki/How_to_install_Tkinter). There is another way to create projects by command line. See below for details. + +##2.console +To use this, open the terminal and type: +``` + $ cd cocos2d-x/tools/project-creator + $ ./project-creator.py --help + $ ./project-creator.py -n mygame -k com.your_company.mygame -l cpp -p /home/mygame + $ cd /home/mygame +``` diff --git a/tools/project-creator/config-create/config.gitingore b/tools/project-creator/config-create/config.gitingore new file mode 100644 index 0000000000..3a95807b43 --- /dev/null +++ b/tools/project-creator/config-create/config.gitingore @@ -0,0 +1,102 @@ +#This configure file use .gitingore rules. +#So you can config this file like config .gitingore +# + +# Ignore thumbnails created by windows +Thumbs.db +.git + +# ignore copy files +/lib +/linux-build +/samples +/template + +# Ignore files build by Visual Studio +win32-msvc-vs201*-x86 +*.obj +*.exe +*.pdb +*.aps +*.vcproj.*.user +*.vspscc +*_i.c +*.i +*.icf +*_p.c +*.ncb +*.suo +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug/ +[Dd]ebug.win32/ +*.sbr +*.sdf +obj/ +[Rr]elease/ +[Rr]elease.win32/ +_ReSharper*/ +[Tt]est[Rr]esult* +ipch/ +*.opensdf + +# Ignore files build by ndk and eclipse +libs/ +bin/ +obj/ +gen/ +assets/ +local.properties + +# Ignore python compiled files +*.pyc + +# Ignore files build by airplay and marmalade +build_*_xcode/ +build_*_vc10/ + +# Ignore files build by xcode +*.mode*v* +*.pbxuser +*.xcbkptlist +*.xcscheme +*.xcworkspacedata +*.xcuserstate +*.xccheckout +xcschememanagement.plist +.DS_Store +._.* +xcuserdata/ +DerivedData/ + +# Ignore files built by AppCode +.idea/ + +# Ignore files built by bada +.Simulator-Debug/ +.Target-Debug/ +.Target-Release/ + +# Ignore files built by blackberry +Simulator/ +Device-Debug/ +Device-Release/ + +# Ignore vim swaps +*.swp +*.swo + +# Ignore files created by create_project.py +/projects + +# CTags +tags + +#include +!/tools/cocos2d-console/console/bin/ +!/plugin-x/plugin-x_ios.xcworkspace/ \ No newline at end of file diff --git a/tools/project-creator/config-create/create_config.py b/tools/project-creator/config-create/create_config.py new file mode 100755 index 0000000000..b2c9e46b08 --- /dev/null +++ b/tools/project-creator/config-create/create_config.py @@ -0,0 +1,148 @@ +#!/usr/bin/python +#coding=utf-8 +"""**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************""" + +import os +import sys +import re + +class CocosFileList: + """ + Function: + List cocos engine's files and save to "../module/cocos_file_list.json". + config "config.gitingore" file can set exclude or include files. + """ + + def __init__(self): + self.excludeConfig=[] + self.inludeConfig=[] + self.rootDir = "" + self.fileList=[] + + def readIngoreFile(self, fileName): + """ + Read configure file which use ".gitingore"'s rules. + """ + pfile = "" + try: + pfile = open(fileName, 'r') + except IOError: + return + + for line in pfile: + line = line.strip() + if not line or line[0] == "#": + continue + + #convert .gitingore regular expression to python's regular expression + line=line.replace('.', '\\.') + line=line.replace('*', '.*') + line="%s$" %line + if line[0] == "!": + self.inludeConfig.append(line[1:]) + else: + self.excludeConfig.append(line) + pfile.close() + + def parseFileList(self, rootDir): + self.rootDir = os.path.abspath(rootDir) + self.__parseFileList(rootDir) + + def __parseFileList(self, folderdir): + """ + """ + for item in os.listdir(folderdir): + path = os.path.join(folderdir, item) + relativePath = path[len(self.rootDir)+1:len(path)] + relativePath = relativePath.replace('\\', '/') + if os.path.isdir(path): + if ( + self.__bInclude("/%s" %relativePath) or + self.__bInclude("/%s/" %relativePath) or + self.__bInclude(item) or + self.__bInclude("%s/" %item) + ): + self.fileList.append("%s/" %relativePath) + continue + if ( + self.__bExclude("/%s" %relativePath) or + self.__bExclude("/%s/" %relativePath) or + self.__bExclude(item) or + self.__bExclude("%s/" %item) + ): + continue + self.__parseFileList(path) + else: + if ( + not self.__bInclude("/%s" %relativePath) and + not self.__bInclude(item) + ): + if ( + self.__bExclude("/%s" %relativePath) or + self.__bExclude(item) + ): + continue + print(relativePath) + self.fileList.append(relativePath) + + def __bExclude(self, item): + bexclude = False + for index in range(len(self.excludeConfig)): + if re.match(self.excludeConfig[index], item): + bexclude = True + break + return bexclude + + def __bInclude(self, item): + binclude = False + for index in range(len(self.inludeConfig)): + if re.match(self.inludeConfig[index], item): + binclude = True + break + return binclude + + def writeFileList(self,fileName): + """ + Save content to file with json format. + """ + f = open(fileName,"w") + content = "[\n\"%s\"\n]" % ("\",\n\"".join(self.fileList)) + f.write(content) + f.close() + return True + +# ------------ main -------------- +if __name__ == '__main__': + + cocos_root =os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..")) + cocos_file_path =os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "module", "cocos_files.json")) + cocos_file_ingore =os.path.abspath(os.path.join(os.path.dirname(__file__), "config.gitingore")) + print ("begin list files") + cocosObj = CocosFileList() + cocosObj.readIngoreFile(cocos_file_ingore) + cocosObj.parseFileList(cocos_root) + cocosObj.writeFileList(cocos_file_path) + print ("had list files to cocos_file_list.json") + diff --git a/tools/project-creator/create_project.py b/tools/project-creator/create_project.py index 640fa4e038..4a58425739 100755 --- a/tools/project-creator/create_project.py +++ b/tools/project-creator/create_project.py @@ -1,177 +1,53 @@ #!/usr/bin/python -# create_project.py -# Create cross-platform cocos2d-x project -# Copyright (c) 2012 cocos2d-x.org -# Author: WangZhe +#coding=utf-8 +"""**************************************************************************** +Copyright (c) 2013 cocos2d-x.org -# define global variables -PLATFORMS = { - "cpp" : ["ios_mac", "android", "win32", "linux"], - "lua" : ["ios_mac", "android", "win32", "linux"], - "javascript" : ["ios_mac", "android", "win32"] -} +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. +****************************************************************************""" -# begin import sys -import os, os.path -import json -import shutil - -def checkParams(): - from optparse import OptionParser - - # set the parser to parse input params - # the correspond variable name of "-x, --xxx" is parser.xxx - parser = OptionParser(usage="Usage: %prog -p -k -l \nSample: %prog -p MyGame -k com.MyCompany.AwesomeGame -l javascript") - parser.add_option("-p", "--project", metavar="PROJECT_NAME", help="Set a project name") - parser.add_option("-k", "--package", metavar="PACKAGE_NAME", help="Set a package name for project") - parser.add_option("-l", "--language", - metavar="PROGRAMMING_NAME", - type="choice", - choices=["cpp", "lua", "javascript"], - help="Major programming language you want to use, should be [cpp | lua | javascript]") - - #parse the params - (opts, args) = parser.parse_args() - - # generate our internal params - context = {}.fromkeys(("language", "src_project_name", "src_package_name", "dst_project_name", "dst_package_name", "src_project_path", "dst_project_path", "script_dir")) - platforms_list = [] - - context["script_dir"] = os.path.abspath(os.path.dirname(__file__)) - - if opts.project: - context["dst_project_name"] = opts.project - context["dst_project_path"] = os.path.abspath(os.path.join(context["script_dir"], "..", "..", "projects", context["dst_project_name"])) - else: - parser.error("-p or --project is not specified") - - if opts.package: - context["dst_package_name"] = opts.package - else: - parser.error("-k or --package is not specified") - - if opts.language: - context["language"] = opts.language - else: - parser.error("-l or --language is not specified") - - # fill in src_project_name and src_package_name according to "language" - template_dir = os.path.abspath(os.path.join(context["script_dir"], "..", "..", "template")) - if ("cpp" == context["language"]): - context["src_project_name"] = "HelloCpp" - context["src_package_name"] = "org.cocos2dx.hellocpp" - context["src_project_path"] = os.path.join(template_dir, "multi-platform-cpp") - elif ("lua" == context["language"]): - context["src_project_name"] = "HelloLua" - context["src_package_name"] = "org.cocos2dx.hellolua" - context["src_project_path"] = os.path.join(template_dir, "multi-platform-lua") - elif ("javascript" == context["language"]): - context["src_project_name"] = "HelloJavascript" - context["src_package_name"] = "org.cocos2dx.hellojavascript" - context["src_project_path"] = os.path.join(template_dir, "multi-platform-js") - else: - print ("Your language parameter doesn\'t exist." \ - "Check correct language option\'s parameter") - sys.exit() - platforms_list = PLATFORMS.get(context["language"], []) - return context, platforms_list -# end of checkParams(context) function - -def replaceString(filepath, src_string, dst_string): - content = "" - f1 = open(filepath, "rb") - for line in f1: - strline = line.decode('utf8') - if src_string in strline: - content += strline.replace(src_string, dst_string) - else: - content += strline - f1.close() - f2 = open(filepath, "wb") - f2.write(content.encode('utf8')) - f2.close() -# end of replaceString - -def processPlatformProjects(context, platform): - # determine proj_path - proj_path = os.path.join(context["dst_project_path"], "proj." + platform) - java_package_path = "" - - # read json config file for the current platform - conf_path = os.path.join(context["script_dir"], "%s.json" % platform) - f = open(conf_path) - data = json.load(f) - - # rename package path, like "org.cocos2dx.hello" to "com.company.game". This is a special process for android - if platform == "android": - src_pkg = context["src_package_name"].split('.') - dst_pkg = context["dst_package_name"].split('.') - - java_package_path = os.path.join(*dst_pkg) - - # rename files and folders - for item in data["rename"]: - tmp = item.replace("PACKAGE_PATH", java_package_path) - src = tmp.replace("PROJECT_NAME", context["src_project_name"]) - dst = tmp.replace("PROJECT_NAME", context["dst_project_name"]) - if os.path.exists(os.path.join(proj_path, src)): - os.rename(os.path.join(proj_path, src), os.path.join(proj_path, dst)) - - # remove useless files and folders - for item in data["remove"]: - dst = item.replace("PROJECT_NAME", context["dst_project_name"]) - if os.path.exists(os.path.join(proj_path, dst)): - shutil.rmtree(os.path.join(proj_path, dst)) - - # rename package_name. This should be replaced at first. Don't change this sequence - for item in data["replace_package_name"]: - tmp = item.replace("PACKAGE_PATH", java_package_path) - dst = tmp.replace("PROJECT_NAME", context["dst_project_name"]) - if os.path.exists(os.path.join(proj_path, dst)): - replaceString(os.path.join(proj_path, dst), context["src_package_name"], context["dst_package_name"]) - - # rename project_name - for item in data["replace_project_name"]: - tmp = item.replace("PACKAGE_PATH", java_package_path) - dst = tmp.replace("PROJECT_NAME", context["dst_project_name"]) - if os.path.exists(os.path.join(proj_path, dst)): - replaceString(os.path.join(proj_path, dst), context["src_project_name"], context["dst_project_name"]) - - # done! - print ("proj.%s\t\t: Done!" % platform) -# end of processPlatformProjects - -def createPlatformProjects(): - # prepare valid "context" dictionary - context, platforms_list = checkParams() - # print context, platforms_list - - # copy "lauguage"(cpp/lua/javascript) platform.proj into cocos2d-x/projects//folder - if os.path.exists(context["dst_project_path"]): - print ("Error:" + context["dst_project_path"] + " folder is already existing") - print ("Please remove the old project or choose a new PROJECT_NAME in -project parameter") - sys.exit() - else: - shutil.copytree(context["src_project_path"], context["dst_project_path"], True) - - # call process_proj from each platform's script folder - for platform in platforms_list: - processPlatformProjects(context, platform) - # exec "import %s.handle_project_files" % (platform) - # exec "%s.handle_project_files.handle_project_files(context)" % (platform) - - print ("New project has been created in this path: " + context["dst_project_path"].replace("/tools/project-creator/../..", "")) - print ("Have Fun!") +def commandCreate(): + from module.core import CocosProject + project = CocosProject() + name, package, language, path = project.checkParams() + project.createPlatformProjects(name, package, language, path) - - - -# -------------- main -------------- -# dump argvs -# print sys.argv +# ------------ main -------------- if __name__ == '__main__': - createPlatformProjects() + """ + There have double ways to create cocos project. + 1.UI + 2.console + #create_project.py --help + #create_project.py -n MyGame -k com.MyCompany.AwesomeGame -l javascript -p c:/mycompany + """ + if len(sys.argv)==1: + try: + from module.ui import createTkCocosDialog + createTkCocosDialog() + except ImportError: + commandCreate() + else: + commandCreate() + diff --git a/tools/project-creator/__init__.py b/tools/project-creator/module/__init__.py old mode 100755 new mode 100644 similarity index 100% rename from tools/project-creator/__init__.py rename to tools/project-creator/module/__init__.py diff --git a/tools/project-creator/module/cocos_files.json.REMOVED.git-id b/tools/project-creator/module/cocos_files.json.REMOVED.git-id new file mode 100644 index 0000000000..38b25afe6d --- /dev/null +++ b/tools/project-creator/module/cocos_files.json.REMOVED.git-id @@ -0,0 +1 @@ +0a2d046187d7848172fadf6ee4a7e80897e6a75c \ No newline at end of file diff --git a/tools/project-creator/module/core.py b/tools/project-creator/module/core.py new file mode 100644 index 0000000000..f12ce71553 --- /dev/null +++ b/tools/project-creator/module/core.py @@ -0,0 +1,279 @@ +#!/usr/bin/python +#coding=utf-8 +"""**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************""" + +import sys +import os, os.path +import json +import shutil + +def replaceString(filepath, src_string, dst_string): + """ From file's content replace specified string + Arg: + filepath: Specify a file contains the path + src_string: old string + dst_string: new string + """ + content = "" + f1 = open(filepath, "rb") + for line in f1: + strline = line.decode('utf8') + if src_string in strline: + content += strline.replace(src_string, dst_string) + else: + content += strline + f1.close() + f2 = open(filepath, "wb") + f2.write(content.encode('utf8')) + f2.close() +#end of replaceString + +class CocosProject: + + def __init__(self): + """ + """ + self.platforms= { + "cpp" : ["ios_mac", "android", "win32", "linux"], + "lua" : ["ios_mac", "android", "win32", "linux"], + "javascript" : ["ios_mac", "android", "win32"] + } + self.context = { + "language": None, + "src_project_name": None, + "src_package_name": None, + "dst_project_name": None, + "dst_package_name": None, + "src_project_path": None, + "dst_project_path": None, + "cocos_file_list":None, + "script_dir": None + } + self.platforms_list = [] + self.cocos_root =os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..")) + self.callbackfun = None + self.totalStep =1 + self.step=0 + + def checkParams(self): + """Custom and check param list. + """ + from optparse import OptionParser + # set the parser to parse input params + # the correspond variable name of "-x, --xxx" is parser.xxx + parser = OptionParser( + usage="Usage: %prog -n -k -l -p \n\ + Sample: %prog -n MyGame -k com.MyCompany.AwesomeGame -l javascript -p c:/mycompany" + ) + parser.add_option("-n", "--name", metavar="PROJECT_NAME",help="Set a project name") + parser.add_option("-k", "--package", metavar="PACKAGE_NAME",help="Set a package name for project") + parser.add_option("-l", "--language",metavar="PROGRAMMING_NAME", + type="choice", + choices=["cpp", "lua", "javascript"], + help="Major programming language you want to use, should be [cpp | lua | javascript]") + parser.add_option("-p", "--path", metavar="PROJECT_PATH",help="Set generate project path for project") + + # parse the params + (opts, args) = parser.parse_args() + if not opts.name: + parser.error("-n or --name is not specified") + + if not opts.package: + parser.error("-k or --package is not specified") + + if not opts.language: + parser.error("-l or --language is not specified") + + if not opts.path: + parser.error("-p or --path is not specified") + + return opts.name, opts.package, opts.language, opts.path + + def createPlatformProjects(self, projectName, packageName, language, projectPath, callbackfun = None): + """ Create a plantform project. + Arg: + projectName: Project name, like this: "helloworld". + packageName: It's used for android platform,like this:"com.cocos2dx.helloworld". + language: There have three languages can be choice: [cpp | lua | javascript], like this:"javascript". + projectPath: The path of generate project. + callbackfun: It's new project callback function.There have four Params. + As follow: + def newProjectCallBack(step, totalStep, showMsg): + #step: processing step,at present + #totalStep: all the steps + #showMsg: message about the progress + pass + + """ + self.callbackfun = callbackfun + + # init our internal params + self.context["dst_project_name"] = projectName + self.context["dst_package_name"] = packageName + self.context["language"] = language + self.context["dst_project_path"] = os.path.join(projectPath,projectName) + self.context["script_dir"] = os.path.abspath(os.path.dirname(__file__)) + self.context["cocos_file_list"] = os.path.join(self.context["script_dir"], "cocos_files.json") + + # fill in src_project_name and src_package_name according to "language" + template_dir = os.path.abspath(os.path.join(self.cocos_root, "template")) + if ("cpp" == self.context["language"]): + self.context["src_project_name"] = "HelloCpp" + self.context["src_package_name"] = "org.cocos2dx.hellocpp" + self.context["src_project_path"] = os.path.join(template_dir, "multi-platform-cpp") + elif ("lua" == self.context["language"]): + self.context["src_project_name"] = "HelloLua" + self.context["src_package_name"] = "org.cocos2dx.hellolua" + self.context["src_project_path"] = os.path.join(template_dir, "multi-platform-lua") + elif ("javascript" == self.context["language"]): + self.context["src_project_name"] = "HelloJavascript" + self.context["src_package_name"] = "org.cocos2dx.hellojavascript" + self.context["src_project_path"] = os.path.join(template_dir, "multi-platform-js") + else: + print ("Your language parameter doesn\'t exist." \ + "Check correct language option\'s parameter") + return False + + # copy "lauguage"(cpp/lua/javascript) platform.proj into cocos2d-x/projects//folder + if os.path.exists(self.context["dst_project_path"]): + print ("Error:" + self.context["dst_project_path"] + " folder is already existing") + print ("Please remove the old project or choose a new PROJECT_NAME in -project parameter") + return False + else: + shutil.copytree(self.context["src_project_path"], self.context["dst_project_path"], True) + + # check cocos engine exist + + if not os.path.exists(self.context["cocos_file_list"]): + print ("cocos_file_list.json doesn\'t exist." \ + "generate it, please") + return False + + f = open(self.context["cocos_file_list"]) + fileList = json.load(f) + f.close() + self.platforms_list = self.platforms.get(self.context["language"], []) + self.totalStep = len(self.platforms_list) + len(fileList) + self.step = 0 + + #begin copy engine + print("###begin copy engine") + print("waitting copy cocos2d ...") + dstPath = os.path.join(self.context["dst_project_path"],"cocos2d") + for index in range(len(fileList)): + srcfile = os.path.join(self.cocos_root,fileList[index]) + dstfile = os.path.join(dstPath,fileList[index]) + if not os.path.exists(os.path.dirname(dstfile)): + os.makedirs(os.path.dirname(dstfile)) + + #copy file or folder + if os.path.exists(srcfile): + if os.path.isdir(srcfile): + if os.path.exists(dstfile): + shutil.rmtree(dstfile) + shutil.copytree(srcfile, dstfile) + else: + if os.path.exists(dstfile): + os.remove(dstfile) + shutil.copy(srcfile, dstfile) + self.step = self.step + 1 + if self.callbackfun and self.step%int(self.totalStep/50) == 0: + self.callbackfun(self.step,self.totalStep,fileList[index]) + print("cocos2d\t\t: Done!") + # call process_proj from each platform's script folder + for platform in self.platforms_list: + self.__processPlatformProjects(platform) + + print ("###New project has been created in this path: ") + print (self.context["dst_project_path"].replace("\\", "/")) + print ("Have Fun!") + return True + + def __processPlatformProjects(self, platform): + """ Process each platform project. + Arg: + platform: "ios_mac", "android", "win32", "linux" + """ + + # determine proj_path + proj_path = os.path.join(self.context["dst_project_path"], "proj." + platform) + java_package_path = "" + + # read json config file for the current platform + conf_path = os.path.join(self.context["script_dir"], "%s.json" % platform) + f = open(conf_path) + data = json.load(f) + + # rename package path, like "org.cocos2dx.hello" to "com.company.game". This is a special process for android + if platform == "android": + src_pkg = self.context["src_package_name"].split('.') + dst_pkg = self.context["dst_package_name"].split('.') + + java_package_path = os.path.join(*dst_pkg) + + # rename files and folders + for item in data["rename"]: + tmp = item.replace("PACKAGE_PATH", java_package_path) + src = tmp.replace("PROJECT_NAME", self.context["src_project_name"]) + dst = tmp.replace("PROJECT_NAME", self.context["dst_project_name"]) + if os.path.exists(os.path.join(proj_path, src)): + os.rename(os.path.join(proj_path, src), os.path.join(proj_path, dst)) + + # remove useless files and folders + for item in data["remove"]: + dst = item.replace("PROJECT_NAME", self.context["dst_project_name"]) + if os.path.exists(os.path.join(proj_path, dst)): + shutil.rmtree(os.path.join(proj_path, dst)) + + # rename package_name. This should be replaced at first. Don't change this sequence + for item in data["replace_package_name"]: + tmp = item.replace("PACKAGE_PATH", java_package_path) + dst = tmp.replace("PROJECT_NAME", self.context["dst_project_name"]) + if os.path.exists(os.path.join(proj_path, dst)): + replaceString(os.path.join(proj_path, dst), self.context["src_package_name"], self.context["dst_package_name"]) + + # rename project_name + for item in data["replace_project_name"]: + tmp = item.replace("PACKAGE_PATH", java_package_path) + dst = tmp.replace("PROJECT_NAME", self.context["dst_project_name"]) + if os.path.exists(os.path.join(proj_path, dst)): + replaceString(os.path.join(proj_path, dst), self.context["src_project_name"], self.context["dst_project_name"]) + + # done! + showMsg = "proj.%s\t\t: Done!" % platform + self.step += 1 + if self.callbackfun: + self.callbackfun(self.step,self.totalStep,showMsg) + print (showMsg) + # end of processPlatformProjects + +# -------------- main -------------- +# dump argvs +# print sys.argv +if __name__ == '__main__': + project = CocosProject() + name, package, language, path = project.checkParams() + project.createPlatformProjects(name, package, language, path) + diff --git a/tools/project-creator/module/ui.py b/tools/project-creator/module/ui.py new file mode 100644 index 0000000000..98d261cbf0 --- /dev/null +++ b/tools/project-creator/module/ui.py @@ -0,0 +1,283 @@ +#!/usr/bin/python +#coding=utf-8 +"""**************************************************************************** +Copyright (c) 2013 cocos2d-x.org + +http://www.cocos2d-x.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +****************************************************************************""" + +import platform +import os, os.path +import shutil +import threading +import time + +from module.core import CocosProject + +#import head files by python version. +if int(platform.python_version().split('.')[0])>=3: + from tkinter import * + from tkinter.filedialog import * + from tkinter.messagebox import * + from queue import * +else: + from Tkinter import * + from tkFileDialog import * + from tkMessageBox import * + from Queue import * + + +class ThreadedTask(threading.Thread): + """Create cocos project thread. + """ + def __init__(self, queue, projectName, packageName, language, projectPath): + threading.Thread.__init__(self) + self.queue = queue + self.projectName = projectName + self.packageName = packageName + self.language = language + self.projectPath = projectPath + + def run(self): + """Create cocos project. + custom message rules to notify ui + As follow: + begin@%d@%d@%s --- create before + doing@%d@%d@%s --- creating + end@%d@%d@%s --- create after + """ + #delete exist project. + if os.path.exists(os.path.join(self.projectPath, self.projectName)): + print ("###begin remove: " + self.projectName) + try: + shutil.rmtree(os.path.join(self.projectPath, self.projectName)) + print ("###remove finish: " + self.projectName) + except: + print ("###remove folder failure %s" %self.projectName) + putMsg = "end@%d@%d@%s" %(100, 100, "create failure") + self.queue.put(putMsg) + putMsg = "begin@%d@%d@%s" %(0, 100, "begin create") + self.queue.put(putMsg) + + project = CocosProject() + breturn = project.createPlatformProjects( + self.projectName, + self.packageName, + self.language, + self.projectPath, + self.newProjectCallBack + ) + if breturn: + putMsg = "end@%d@%d@%s" %(100, 100, "create successful") + else: + putMsg = "end@%d@%d@%s" %(100, 100, "create failure") + self.queue.put(putMsg) + + def newProjectCallBack(self, step, totalStep, showMsg): + """Creating cocos project callback. + """ + putMsg = "doing@%d@%d@%s" %(step, totalStep, showMsg) + self.queue.put(putMsg) + +class StdoutRedirector(object): + """Redirect output. + """ + def __init__(self, text_area): + self.text_area = text_area + + def write(self, str): + self.text_area.insert(END, str) + self.text_area.see(END) + +class TkCocosDialog(Frame): + def __init__(self, parent): + Frame.__init__(self,parent) + + self.projectName = "" + self.packageName = "" + self.language = "" + + self.parent = parent + self.columnconfigure(3, weight=1) + self.rowconfigure(5, weight=1) + + # project name frame + self.labName = Label(self, text="Project Name:") + self.strName = StringVar() + self.strName.set("MyGame") + self.editName = Entry(self, textvariable=self.strName) + self.labName.grid(sticky=W, pady=4, padx=5) + self.editName.grid(row=0, column=1, columnspan=4,padx=5, pady=2,sticky=E+W) + + # package name frame + self.labPackage = Label(self, text="Package Name:") + self.strPackage=StringVar() + self.strPackage.set("com.MyCompany.AwesomeGame") + self.editPackage = Entry(self, textvariable=self.strPackage) + self.labPackage.grid(row=1, column=0,sticky=W, padx=5) + self.editPackage.grid(row=1, column=1, columnspan=4,padx=5, pady=2,sticky=E+W) + + # project path frame + self.labPath = Label(self, text="Project Path:") + self.editPath = Entry(self) + self.btnPath = Button(self, text="...", width = 6, command = self.pathCallback) + self.labPath.grid(row=2, column=0,sticky=W, pady=4, padx=5) + self.editPath.grid(row=2, column=1, columnspan=3,padx=5, pady=2, sticky=E+W) + self.btnPath.grid(row=2, column=4,) + + # language frame + self.labLanguage = Label(self, text="Language:") + self.var=IntVar() + self.var.set(1) + self.checkcpp = Radiobutton(self, text="C++", variable=self.var, value=1) + self.checklua = Radiobutton(self, text="Lua", variable=self.var, value=2) + self.checkjs = Radiobutton(self, text="JavaScript", variable=self.var, value=3) + self.labLanguage.grid(row=3, column=0,sticky=W, padx=5) + self.checkcpp.grid(row=3, column=1,sticky=N+W) + self.checklua.grid(row=3, column=2,padx=5,sticky=N+W) + self.checkjs.grid(row=3, column=3,padx=5,sticky=N+W) + + # show progress + self.progress = Scale(self, state= DISABLED, from_=0, to=100, orient=HORIZONTAL) + self.progress.set(0) + self.progress.grid(row=4, column=0, columnspan=5,padx=5, pady=2,sticky=E+W+S+N) + + # msg text frame + self.text=Text(self,background = '#d9efff') + self.text.bind("", lambda e : "break") + self.text.grid(row=5, column=0, columnspan=5, rowspan=1, padx=5, sticky=E+W+S+N) + + # new project button + self.btnCreate = Button(self, text="create", command = self.createBtnCallback) + self.btnCreate.grid(row=7, column=3, columnspan=1, rowspan=1,pady=2,ipadx=15,ipady =10, sticky=W) + + #center window on desktop + curWidth = 500 + curHeight = 450 + scnWidth = self.parent.winfo_screenwidth() + scnHeight = self.parent.winfo_screenheight() + tmpcnf = '%dx%d+%d+%d'%(curWidth, curHeight, int((scnWidth-curWidth)/2), int((scnHeight-curHeight)/2)) + self.parent.geometry(tmpcnf) + self.parent.title("Cocos Project Creator") + + #fix size + #self.parent.maxsize(curWidth, curHeight) + #self.parent.minsize(curWidth, curHeight) + + #redirect out to text + self.pack(fill=BOTH, expand=1) + sys.stdout = StdoutRedirector(self.text) + + def process_queue(self): + """ + """ + #message is empty + if self.queue.empty(): + self.parent.after(100, self.process_queue) + return + + #parse message + msg = self.queue.get(0) + msglist = msg.split("@") + if len(msglist) < 4: + return + + #begin + if msglist[0] == "begin": + self.progress['state'] = NORMAL + #doing + elif msglist[0] == "doing": + pass + + self.progress.set(int(int(msglist[1])*100/int(msglist[2]))) + #end + if msglist[0] == "end": + showwarning("create", msglist[3]) + self.progress.set(0) + self.text.insert(END,"=================END==============\n") + self.progress['state'] = DISABLED + self.btnCreate['state'] = NORMAL + return + self.parent.after(100, self.process_queue) + + def createBtnCallback(self): + """Create button event. + """ + #Check project name + projectName = self.editName.get() + if projectName == "": + showwarning("warning", "projectName is empty") + return + + #Check the package name is effective + packageName = self.editPackage.get() + packageList = packageName.split(".") + if len(packageList) < 2: + showwarning("warning", "packageName format error!") + return + for index in range(len(packageList)): + if (packageList[index] == "") or (packageList[index][0].isdigit()): + showwarning("warning", "packageName format error!") + return + + # get select language type + language = "cpp" + if self.var.get() == 1: + language = "cpp" + elif self.var.get() == 2: + language = "lua" + elif self.var.get() == 3: + language = "javascript" + + projectPath = self.editPath.get() + if projectPath == "": + showwarning("warning", "projectPath is empty") + return + + # if project has already exist,.... + if os.path.exists(os.path.join(projectPath, projectName)): + if not askyesno("warning", "%s had exist,do you want to recreate!" %projectName ): + return + + #create a new thread to deal with create new project. + self.btnCreate['state'] = DISABLED + self.queue = Queue() + ThreadedTask(self.queue, projectName, packageName, language, projectPath).start() + self.parent.after(100, self.process_queue) + + def pathCallback(self): + """Paht button event. + """ + filepath = askdirectory() + if filepath: + self.editPath.delete(0, END) + self.editPath.insert(0, filepath) + +def createTkCocosDialog(): + + old_stdout = sys.stdout + root = Tk() + app = TkCocosDialog(root) + root.mainloop() + sys.stdout = old_stdout + +if __name__ =='__main__': + createTkCocosDialog() \ No newline at end of file diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index e5dc054b3a..99f57b9e8e 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -37,8 +37,9 @@ classes_need_extend = Node Layer.* Sprite MenuItemFont Scene DrawNode # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = Node::[^setPosition$ setGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule setContentSize setAnchorPoint], +skip = Node::[^setPosition$ setGLServerState description getUserObject .*UserData getGLServerState .*schedule setContentSize setAnchorPoint], Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc], + NodeGrid::[setGrid], SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants], MotionStreak::[getBlendFunc setBlendFunc draw update], AtlasNode::[getBlendFunc setBlendFunc], @@ -101,14 +102,15 @@ skip = Node::[^setPosition$ setGrid setGLServerState description getUserObject . Bezier.*::[create actionWithDuration], CardinalSpline.*::[create actionWithDuration setPoints], Scheduler::[pause resume unschedule schedule update isTargetPaused], - TextureCache::[addPVRTCImage], + TextureCache::[addPVRTCImage addImageAsync], Timer::[getSelector createWithScriptHandler], *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType onTouch.* onAcc.* onKey.* onRegisterTouchListener], FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getFileData getDataFromFile], Application::[^application.* ^run$], Camera::[getEyeXYZ getCenterXYZ getUpXYZ], ccFontDefinition::[*], - NewTextureAtlas::[*] + NewTextureAtlas::[*], + RenderTexture::[listenToBackground listenToForeground] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], MenuItemFont::[setFontNameObj=setFontName setFontSizeObj=setFontSize getFontSizeObj=getFontSize getFontNameObj=getFontName], diff --git a/tools/tojs/cocos2dx_extension.ini b/tools/tojs/cocos2dx_extension.ini index f91748cd66..9c131621f5 100644 --- a/tools/tojs/cocos2dx_extension.ini +++ b/tools/tojs/cocos2dx_extension.ini @@ -71,3 +71,4 @@ abstract_classes = # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = no +classes_need_extend = ScrollView TableView TableViewCell diff --git a/tools/tojs/cocos2dx_gui.ini b/tools/tojs/cocos2dx_gui.ini index 3eddc48cd9..0659c3469f 100644 --- a/tools/tojs/cocos2dx_gui.ini +++ b/tools/tojs/cocos2dx_gui.ini @@ -5,7 +5,7 @@ prefix = cocos2dx_gui # create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) # all classes will be embedded in that namespace -target_namespace = ccs +target_namespace = ccui # the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::gui::Label". cpp_namespace = cocos2d::gui @@ -30,7 +30,7 @@ headers = %(cocosdir)s/cocos/gui/CocosGUI.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 = Helper Layout Widget Layer Button CheckBox ImageView Label LabelAtlas LabelBMFont LoadingBar Slider Switch TextField ScrollView PageView ListView LayoutParameter LinearLayoutParameter RelativeLayoutParameter +classes = Helper Layout Widget Layer Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider Switch TextField ScrollView PageView ListView LayoutParameter LinearLayoutParameter RelativeLayoutParameter # 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 diff --git a/tools/tojs/cocos2dx_studio.ini b/tools/tojs/cocos2dx_studio.ini index c071886085..64cd414f96 100644 --- a/tools/tojs/cocos2dx_studio.ini +++ b/tools/tojs/cocos2dx_studio.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.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 = Armature ArmatureAnimation Skin Bone ArmatureDataManager InputDelegate ComController ComAudio ComAttribute ComRender ActionManagerEx SceneReader GUIReader BatchNode ActionObject BaseData Tween ColliderFilter DisplayManager +classes = Armature ArmatureAnimation Skin Bone ColliderDetector ColliderBody ArmatureDataManager InputDelegate ComController ComAudio ComAttribute ComRender ActionManagerEx SceneReader GUIReader BatchNode ActionObject BaseData Tween ColliderFilter DisplayManager # 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 @@ -52,7 +52,10 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*H Tween::[(s|g)etMovementBoneData], DisplayManager::[initDisplayList (s|g)etCurrentDecorativeDisplay getDecorativeDisplayByIndex], ActionNode::[initWithDictionary], - ActionObject::[initWithDictionary] + ActionObject::[initWithDictionary], + ColliderDetector::[addContourData.* removeContourData], + ColliderBody::[getContourData getCalculatedVertexList], + SceneReader::[setTarget] rename_functions = ActionManagerEx::[shareManager=getInstance purgeActionManager=purge], SceneReader::[purgeSceneReader=purge], @@ -71,8 +74,9 @@ base_classes_to_skip = Object ProcessBase # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = ArmatureDataManager ComAttribute InputDelegate ComRender ComAudio InputDelegate ActionManagerEx SceneReader GUIReader BatchNode ColliderFilter +abstract_classes = ColliderDetector ColliderBody ArmatureDataManager ComAttribute InputDelegate ComRender ComAudio InputDelegate ActionManagerEx SceneReader GUIReader BatchNode ColliderFilter # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = no +classes_need_extend = Armature diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 65487bdcce..a3fced78fd 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/2d/cocos2d.h %(cocosdir)s/cocos/audio/include/Simpl # 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 = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image Event.* +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Object$ UserDefault EGLViewProtocol EGLView Image Event(?!.*(Physics).*).* # 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 @@ -99,7 +99,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS Bezier.*::[create actionWithDuration], CardinalSpline.*::[create actionWithDuration setPoints], Scheduler::[pause resume unschedule schedule update isTargetPaused], - TextureCache::[addPVRTCImage], + TextureCache::[addPVRTCImage addImageAsync], Timer::[getSelector createWithScriptHandler], *::[copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate onTouch.* onAcc.* onKey.* onRegisterTouchListener], FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getFileData getDataFromFile], @@ -112,7 +112,8 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS EGLViewProtocol::[setTouchDelegate], EGLView::[end swapBuffers], NewTextureAtlas::[*], - DisplayLinkDirector::[mainLoop setAnimationInterval startAnimation stopAnimation] + DisplayLinkDirector::[mainLoop setAnimationInterval startAnimation stopAnimation], + RenderTexture::[listenToBackground listenToForeground] rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], ProgressTimer::[setReverseProgress=setReverseDirection], diff --git a/tools/tolua/cocos2dx_extension.ini b/tools/tolua/cocos2dx_extension.ini index 2ac5b8f3c6..d75f375305 100644 --- a/tools/tolua/cocos2dx_extension.ini +++ b/tools/tolua/cocos2dx_extension.ini @@ -27,7 +27,7 @@ headers = %(cocosdir)s/extensions/cocos-ext.h %(cocosdir)s/cocos/editor-support/ # 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 = AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* ScrollView$ TableView$ TableViewCell$ EditBox$ +classes = AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control.* ControlButton.* EditBox$ # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -38,12 +38,10 @@ classes = AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getCCBMemberVariableAssigner readFloat getCCBSelectorResolver toLowerCase lastPathComponent deletePathExtension endsWith concat getResolutionScale getAnimatedProperties readBool readInt addOwnerCallbackNode addDocumentCallbackName readCachedString readNodeGraphFromData addDocumentCallbackNode getLoadedSpriteSheet initWithData readFileWithCleanUp getOwner$ readNodeGraphFromFile createSceneWithNodeGraphFromFile getAnimationManagers$ setAnimationManagers], CCBAnimationManager::[setAnimationCompletedCallback setCallFunc addNode], - ScrollView::[(g|s)etDelegate$], .*Delegate::[*], .*Loader.*::[*], *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate .*HSV], EditBox::[(g|s)etDelegate ^keyboard.* touchDownAction getScriptEditBoxHandler registerScriptEditBoxHandler unregisterScriptEditBoxHandler], - TableView::[create (g|s)etDataSource$ (g|s)etDelegate], AssetsManager::[(g|s)etDelegate], AssetsManagerDelegateProtocol::[*], Control::[removeHandleOfControlEvent addHandleOfControlEvent], diff --git a/tools/tolua/cocos2dx_gui.ini b/tools/tolua/cocos2dx_gui.ini new file mode 100644 index 0000000000..876afe3252 --- /dev/null +++ b/tools/tolua/cocos2dx_gui.ini @@ -0,0 +1,68 @@ +[cocos2dx_gui] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_gui + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = ccui + +# the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::gui::Label". +cpp_namespace = cocos2d::gui + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 + +cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/gui -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath/include -I%(cocosdir)s/extensions -I%(cocosdir)s/external -I%(cocosdir)s + +cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/gui/CocosGUI.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 = Helper Widget Layer Layout RootWidget Button CheckBox ImageView Text TextAtlas TextBMFont LoadingBar Slider Switch TextField ScrollView ListView PageView LayoutParameter LinearLayoutParameter RelativeLayoutParameter + +# 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 +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener (s|g)etBlendFunc ccTouch.*], + Widget::[(s|g)etUserObject], + Layer::[getInputManager], + LayoutParameter::[(s|g)etMargin], + Helper::[init], + ImageView::[doubleClickEvent checkDoubleClick] + +rename_functions = + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = Helper + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = Object + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = Helper + +# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. +script_control_cpp = no + diff --git a/tools/tolua/cocos2dx_physics.ini b/tools/tolua/cocos2dx_physics.ini new file mode 100644 index 0000000000..7c6c3ed78f --- /dev/null +++ b/tools/tolua/cocos2dx_physics.ini @@ -0,0 +1,67 @@ +[cocos2dx_physics] +# the prefix to be added to the generated functions. You might or might not use this in your own +# templates +prefix = cocos2dx_physics + +# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`) +# all classes will be embedded in that namespace +target_namespace = cc + +android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include +android_flags = -D_SIZE_T_DEFINED_ + +clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include +clang_flags = -nostdinc -x c++ -std=c++11 + +cocos_headers = -I%(cocosdir)s/cocos/2d -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/physics -I%(cocosdir)s/cocos/2d/platform -I%(cocosdir)s/cocos/2d/platform/android -I%(cocosdir)s/cocos/math/kazmath/include -I%(cocosdir)s/cocos/physics +cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT -DCC_USE_PHYSICS=1 + +cxxgenerator_headers = + +# extra arguments for clang +extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s + +# what headers to parse +headers = %(cocosdir)s/cocos/2d/cocos2d.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 = Event(.*(Physics).*) Physics.* + +# 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 +# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just +# add a single "*" as functions. See bellow for several examples. A special class name is "*", which +# will apply to all class names. This is a convenience wildcard to be able to skip similar named +# functions from all classes. + +skip = PhysicsBody::[getJoints createPolygon createEdgeChain createEdgePolygon], + PhysicsShape::[recenterPoints getPolyonCenter], + PhysicsShapeBox::[getPoints], + PhysicsShapeEdgeBox::[getPoints], + PhysicsShapePolygon::[getPoints], + PhysicsShapeEdgePolygon::[getPoints], + PhysicsShapeEdgeChain::[getPoints], + PhysicsWorld::[getScene queryPoint queryRect rayCast] + + +rename_functions = + +rename_classes = + +# for all class names, should we remove something when registering in the target VM? +remove_prefix = + +# classes for which there will be no "parent" lookup +classes_have_no_parents = PhysicsWorld PhysicsJoint PhysicsContactPreSolve PhysicsContactPostSolve + +# base classes which will be skipped when their sub-classes found them. +base_classes_to_skip = + +# classes that create no constructor +# Set is special and we will use a hand-written constructor +abstract_classes = + +# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. +script_control_cpp = no + diff --git a/tools/tolua/cocos2dx_studio.ini b/tools/tolua/cocos2dx_studio.ini index 177bf5718d..455f5da0ad 100644 --- a/tools/tolua/cocos2dx_studio.ini +++ b/tools/tolua/cocos2dx_studio.ini @@ -8,7 +8,7 @@ prefix = cocos2dx_studio target_namespace = ccs # the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::gui::Label". -cpp_namespace = cocos2d::gui cocostudio +cpp_namespace = cocostudio android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include android_flags = -D_SIZE_T_DEFINED_ @@ -26,11 +26,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/gui/CocosGUI.h %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.h +headers = %(cocosdir)s/cocos/editor-support/cocostudio/CocoStudio.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 = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ Widget Layout RootWidget Button CheckBox ImageView Label CCLabelAtlas LabelAtlas LoadingBar ScrollView Slider CCTextField TextField ListView LabelBMFont PageView Helper Layer LayoutParameter GReader LinearLayoutParameter RelativeLayoutParameter SceneReader ActionManagerEx ComAudio ComController ComAttribute ComRender BatchNode +classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ ActionManagerEx ComAudio ComController ComAttribute ComRender BatchNode SceneReader GUIReader ActionObject Tween DisplayManager # 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 @@ -45,14 +45,14 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .* Skin::[(s|g)etSkinData], ArmatureAnimation::[updateHandler updateFrameData frameEvent setMovementEventCallFunc setFrameEventCallFunc], Bone::[(s|g)etIgnoreMovementBoneData], - Layer::[getInputManager], - LayoutParameter::[(s|g)etMargin], - Helper::[init], - GReader::[setPropsForImageButtonFromJsonDictionary], - ImageView::[doubleClickEvent], ActionManagerEx::[initWithDictionary], + ActionObject::[initWithDictionary], + DisplayManager::[initDisplayList (s|g)etCurrentDecorativeDisplay getDecorativeDisplayByIndex], + Tween::[(s|g)etMovementBoneData], + GUIReader::[storeFileDesignSize getFileDesignSize], ActionNode::[initWithDictionary], - ActionObject::[initWithDictionary] + ActionObject::[initWithDictionary], + BaseData::[copy subtract] rename_functions = GUIReader::[shareReader=getInstance purgeGUIReader=destroyInstance], ActionManagerEx::[shareManager=getInstance purgeActionManager=destroyInstance], @@ -72,7 +72,7 @@ base_classes_to_skip = Object ProcessBase # classes that create no constructor # Set is special and we will use a hand-written constructor -abstract_classes = ArmatureDataManager +abstract_classes = ArmatureDataManager ComAttribute ComRender ComAudio ActionManagerEx SceneReader GUIReader BatchNode # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = no diff --git a/tools/tolua/genbindings.sh b/tools/tolua/genbindings.sh index 9870d0f364..eb463fcfa5 100755 --- a/tools/tolua/genbindings.sh +++ b/tools/tolua/genbindings.sh @@ -85,8 +85,14 @@ LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py echo "Generating bindings for cocos2dx_extension..." LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_extension.ini -s cocos2dx_extension -t lua -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/lua-bindings -n lua_cocos2dx_extension_auto +echo "Generating bindings for cocos2dx_gui..." +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_gui.ini -s cocos2dx_gui -t lua -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/lua-bindings -n lua_cocos2dx_gui_auto + echo "Generating bindings for cocos2dx_studio..." LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_studio.ini -s cocos2dx_studio -t lua -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/lua-bindings -n lua_cocos2dx_studio_auto echo "Generating bindings for cocos2dx_spine..." LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_spine.ini -s cocos2dx_spine -t lua -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/lua-bindings -n lua_cocos2dx_spine_auto + +echo "Generating bindings for cocos2dx_physics..." +LD_LIBRARY_PATH=${CLANG_ROOT}/lib $PYTHON_BIN ${CXX_GENERATOR_ROOT}/generator.py ${TO_JS_ROOT}/cocos2dx_physics.ini -s cocos2dx_physics -t lua -o ${COCOS2DX_ROOT}/cocos/scripting/auto-generated/lua-bindings -n lua_cocos2dx_physics_auto diff --git a/tools/travis-scripts/run-script.sh b/tools/travis-scripts/run-script.sh index b609c7cc43..aa9c47f5c6 100755 --- a/tools/travis-scripts/run-script.sh +++ b/tools/travis-scripts/run-script.sh @@ -76,11 +76,21 @@ elif [ "$PLATFORM"x = "linux"x ]; then cd linux-build cmake ../.. make -j10 - cd ../../template/multi-platform-cpp - cmake . + # build template + echo "Building template projects for linux ..." + cd $COCOS2DX_ROOT/tools/project-creator + ./create_project.py -n MyGameCpp -k com.MyCompany.AwesomeGameCpp -l cpp -p $HOME + ./create_project.py -n MyGameLua -k com.MyCompany.AwesomeGameLua -l lua -p $HOME + cd $HOME/MyGameCpp + mkdir build + cd build + cmake .. make -j10 - cd ../multi-platform-lua - cmake . + + cd $HOME/MyGameLua + mkdir build + cd build + cmake .. make -j10 elif [ "$PLATFORM"x = "emscripten"x ]; then